Skip to contentSkip to conversation

Patch "vfs: read file_handle only once in handle_to_path" has been added to the 3.14-stable tree

PATCH [email protected] 1 participant 1 message Jun 3, 2015

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

vfs: read file_handle only once in handle_to_path

to the 3.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
vfs-read-file_handle-only-once-in-handle_to_path.patch
and it can be found in the queue-3.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From 161f873b89136eb1e69477c847d5a5033239d9ba Mon Sep 17 00:00:00 2001

From: Sasha Levin <[email protected]>
Date: Wed, 28 Jan 2015 15:30:43 -0500
Subject: vfs: read file_handle only once in handle_to_path

From: Sasha Levin <[email protected]>

commit 161f873b89136eb1e69477c847d5a5033239d9ba upstream.

We used to read file_handle twice. Once to get the amount of extra bytes, and once to fetch the entire structure.

This may be problematic since we do size verifications only after the first read, so if the number of extra bytes changes in userspace between the first and second calls, we'll have an incoherent view of file_handle.

Instead, read the constant size once, and copy that over to the final structure without having to re-read it again.

---
 fs/fhandle.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/fhandle.c +3 -2
@@ -195,8 +195,9 @@ static int handle_to_path(int mountdirfd
 		goto out_err;
 	}
 	/* copy the full handle */
-	if (copy_from_user(handle, ufh,
-			   sizeof(struct file_handle) +
+	*handle = f_handle;
+	if (copy_from_user(&handle->f_handle,
+			   &ufh->f_handle,
 			   f_handle.handle_bytes)) {
 		retval = -EFAULT;
 		goto out_handle;

Patches currently in stable-queue which might be from [email protected] are

queue-3.14/vfs-read-file_handle-only-once-in-handle_to_path.patch queue-3.14/kernel-use-the-gnu89-standard-explicitly.patch queue-3.14/fs-omfs-add-null-terminator-in-the-end-up-the-token-list.patch