mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-04 11:24:04 +08:00
v6.4/vfs.open
-----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQRAhzRXHqcMeLMyaSiRxhvAZXjcogUCZEEn8AAKCRCRxhvAZXjc okJoAQC1bjJp4SQw7VQhTuyv0Ak67PACwKPNUPQyHcqMV5s5DAD/fcnMjq7+UieH TEk/zRBGWWI8m0wb51MMO+VVM2GeXwI= =EKj/ -----END PGP SIGNATURE----- Merge tag 'v6.4/vfs.open' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs Pull vfs open fixlet from Christian Brauner: "EINVAL ist keinmal: This contains the changes to make O_DIRECTORY when specified together with O_CREAT an invalid request. The wider background is that a regression report about the behavior of O_DIRECTORY | O_CREAT was sent to fsdevel about a behavior that was changed multiple years and LTS releases earlier during v5.7 development. This has also been covered in https://lwn.net/Articles/926782/ which provides an excellent summary of the discussion" * tag 'v6.4/vfs.open' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs: open: return EINVAL for O_DIRECTORY | O_CREAT
This commit is contained in:
commit
97adb49f05
18
fs/open.c
18
fs/open.c
@ -1196,13 +1196,21 @@ inline int build_open_flags(const struct open_how *how, struct open_flags *op)
|
||||
}
|
||||
|
||||
/*
|
||||
* In order to ensure programs get explicit errors when trying to use
|
||||
* O_TMPFILE on old kernels, O_TMPFILE is implemented such that it
|
||||
* looks like (O_DIRECTORY|O_RDWR & ~O_CREAT) to old kernels. But we
|
||||
* have to require userspace to explicitly set it.
|
||||
* Block bugs where O_DIRECTORY | O_CREAT created regular files.
|
||||
* Note, that blocking O_DIRECTORY | O_CREAT here also protects
|
||||
* O_TMPFILE below which requires O_DIRECTORY being raised.
|
||||
*/
|
||||
if ((flags & (O_DIRECTORY | O_CREAT)) == (O_DIRECTORY | O_CREAT))
|
||||
return -EINVAL;
|
||||
|
||||
/* Now handle the creative implementation of O_TMPFILE. */
|
||||
if (flags & __O_TMPFILE) {
|
||||
if ((flags & O_TMPFILE_MASK) != O_TMPFILE)
|
||||
/*
|
||||
* In order to ensure programs get explicit errors when trying
|
||||
* to use O_TMPFILE on old kernels we enforce that O_DIRECTORY
|
||||
* is raised alongside __O_TMPFILE.
|
||||
*/
|
||||
if (!(flags & O_DIRECTORY))
|
||||
return -EINVAL;
|
||||
if (!(acc_mode & MAY_WRITE))
|
||||
return -EINVAL;
|
||||
|
@ -91,7 +91,6 @@
|
||||
|
||||
/* a horrid kludge trying to make sure that this will fail on old kernels */
|
||||
#define O_TMPFILE (__O_TMPFILE | O_DIRECTORY)
|
||||
#define O_TMPFILE_MASK (__O_TMPFILE | O_DIRECTORY | O_CREAT)
|
||||
|
||||
#ifndef O_NDELAY
|
||||
#define O_NDELAY O_NONBLOCK
|
||||
|
@ -91,7 +91,6 @@
|
||||
|
||||
/* a horrid kludge trying to make sure that this will fail on old kernels */
|
||||
#define O_TMPFILE (__O_TMPFILE | O_DIRECTORY)
|
||||
#define O_TMPFILE_MASK (__O_TMPFILE | O_DIRECTORY | O_CREAT)
|
||||
|
||||
#ifndef O_NDELAY
|
||||
#define O_NDELAY O_NONBLOCK
|
||||
|
Loading…
Reference in New Issue
Block a user