diff options
author | Greg Kurz <groug@kaod.org> | 2020-09-23 22:11:45 +0800 |
---|---|---|
committer | Dominique Martinet <asmadeus@codewreck.org> | 2020-11-03 09:29:56 +0100 |
commit | 478ba09edc1f2f2ee27180a06150cb2d1a686f9c (patch) | |
tree | 84615f1570076f3c5b74790496c62761db7c6662 /crypto/xcbc.c | |
parent | 987a64850996db22bbcf2c1d0a051446a343fa2c (diff) | |
download | linux-stable-478ba09edc1f2f2ee27180a06150cb2d1a686f9c.tar.gz linux-stable-478ba09edc1f2f2ee27180a06150cb2d1a686f9c.tar.bz2 linux-stable-478ba09edc1f2f2ee27180a06150cb2d1a686f9c.zip |
fs/9p: search open fids first
A previous patch fixed the "create-unlink-getattr" idiom: if getattr is
called on an unlinked file, we try to find an open fid attached to the
corresponding inode.
We have a similar issue with file permissions and setattr:
open("./test.txt", O_RDWR|O_CREAT, 0666) = 4
chmod("./test.txt", 0) = 0
truncate("./test.txt", 0) = -1 EACCES (Permission denied)
ftruncate(4, 0) = -1 EACCES (Permission denied)
The failure is expected with truncate() but not with ftruncate().
This happens because the lookup code does find a matching fid in the
dentry list. Unfortunately, this is not an open fid and the server
will be forced to rely on the path name, rather than on an open file
descriptor. This is the case in QEMU: the setattr operation will use
truncate() and fail because of bad write permissions.
This patch changes the logic in the lookup code, so that we consider
open fids first. It gives a chance to the server to match this open
fid to an open file descriptor and use ftruncate() instead of truncate().
This does not change the current behaviour for truncate() and other
path name based syscalls, since file permissions are checked earlier
in the VFS layer.
With this patch, we get:
open("./test.txt", O_RDWR|O_CREAT, 0666) = 4
chmod("./test.txt", 0) = 0
truncate("./test.txt", 0) = -1 EACCES (Permission denied)
ftruncate(4, 0) = 0
Link: http://lkml.kernel.org/r/20200923141146.90046-4-jianyong.wu@arm.com
Signed-off-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
Diffstat (limited to 'crypto/xcbc.c')
0 files changed, 0 insertions, 0 deletions