fsverity: Update misleading comment in fsverity_ioctl_read_metadata()
Eric Biggers
maintainerPATCH 1/1 fsverity: Update misleading comment in fsverity_ioctl_read_metadata()
The comment in fsverity_ioctl_read_metadata(), which justifies not checking for FMODE_READ, doesn't consider that the nonstandard access mode 3 (ioctl-only) exists.
It's reasonable to continue to allow this ioctl in that case, since this *is* an ioctl, and opening a file with mode 3 checks for read (and write) access. However, adjust the comment to not be misleading.
--- fs/verity/read_metadata.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/verity/read_metadata.c +3 -2
@@ -170,8 +170,9 @@ int fsverity_ioctl_read_metadata(struct file *filp, const void __user *uarg)if (!vi)return -ENODATA ;/* not a verity file */ /* -* Note that we don't have to explicitly check that the file is open for -* reading, since verity files can only be opened for reading. +* No need to check for FMODE_READ. Verity files can't be open for +* writing, and opening with access mode 3 (ioctl-only) requires read +* (and write) permission, so the opener has read permission either way. */ if (copy_from_user (&arg, uarg,sizeof (arg)))
base-commit: ccc4d9f8912a5d9f519a34c3633fe53c8f9b429e
Signature · 1 line
2.56.0.218.g1ec904b173-goog
Quoted 9 lines · Eric Biggers
The comment in
fsverity_ioctl_read_metadata(), which justifies not checking forFMODE_READ, doesn't consider that the nonstandard access mode 3 (ioctl-only) exists.It's reasonable to continue to allow this ioctl in that case, since this *is* an ioctl, and opening a file with mode 3 checks for read (and write) access. However, adjust the comment to not be misleading.
Signed-off-by Eric Biggers <[email protected]>
Looks good to me
Signature · 1 line
- Andrey
Eric Biggers
maintainerQuoted 5 lines · Andrey Albershteyn
Quoted 4 lines · Eric Biggers
The comment in
fsverity_ioctl_read_metadata(), which justifies not checking forFMODE_READ, doesn't consider that the nonstandard access mode 3 (ioctl-only) exists.
Quoted 8 lines
Quoted 5 lines
It's reasonable to continue to allow this ioctl in that case, since this *is* an ioctl, and opening a file with mode 3 checks for read (and write) access. However, adjust the comment to not be misleading.
Signed-off-by Eric Biggers <[email protected]>Looks good to me
Reviewed-by Andrey Albershteyn <[email protected]>
Thanks. I'm actually reconsidering this patch, though:
* This ioctl returns hashes of file contents blocks, which reveal information that normally a read would be needed for.
* "opening a file with mode 3 checks for read (and write) access" is true for the DAC permissions, but it's not true for some LSMs such as Landlock where it bypasses their read permission check.
So requiring FMODE_READ for this might be the way to go.
- Eric