Commit 406c706
vfs: vfs_tmpfile: ensure O_EXCL flag is enforced
If O_EXCL is *not* specified, then linkat() can be
used to link the temporary file into the filesystem.
If O_EXCL is specified then linkat() should fail (-1).
After commit 863f144 ("vfs: open inside ->tmpfile()")
the O_EXCL flag is no longer honored by the vfs layer for
tmpfile, which means the file can be linked even if O_EXCL
flag is specified, which is a change in behaviour for
userspace!
The open flags was previously passed as a parameter, so it
was uneffected by the changes to file->f_flags caused by
finish_open(). This patch fixes the issue by storing
file->f_flags in a local variable so the O_EXCL test
logic is restored.
This regression was detected by Android CTS Bionic fcntl()
tests running on android-mainline [1].
[1] https://android.googlesource.com/platform/bionic/+/
refs/heads/master/tests/fcntl_test.cpp#352
Fixes: 863f144 ("vfs: open inside ->tmpfile()")
Acked-by: Miklos Szeredi <[email protected]>
Tested-by: Will McVicker <[email protected]>
Signed-off-by: Peter Griffin <[email protected]>
Signed-off-by: Al Viro <[email protected]>1 parent 7ee47dc commit 406c706
1 file changed
+2
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3591 | 3591 | | |
3592 | 3592 | | |
3593 | 3593 | | |
| 3594 | + | |
3594 | 3595 | | |
3595 | 3596 | | |
3596 | 3597 | | |
| |||
3613 | 3614 | | |
3614 | 3615 | | |
3615 | 3616 | | |
3616 | | - | |
| 3617 | + | |
3617 | 3618 | | |
3618 | 3619 | | |
3619 | 3620 | | |
| |||
0 commit comments