Skip to contentSkip to conversation

fsverity: Update misleading comment in fsverity_ioctl_read_metadata()

PATCH In review Eric Biggers 2 participants 3 messages Oct 21 – Oct 22 fs-verity: read-only file-based authenticity protection

lore
Share & tools
lore

Eric Biggers

author maintainer
#0 lore raw

PATCH 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
index b4c0892430cde..5e81847bdb036 100644
@@ -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
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Eric Biggers

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.

Looks good to me

Signature · 1 line
- Andrey
author maintainer
#2 lore raw
Quoted 5 lines · Andrey Albershteyn
Quoted 4 lines · Eric Biggers

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.

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.

Looks good to me

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