diff mbox

[git,pull] vfs.git part 1

Message ID CA+55aFyREtWvwCLc0iHMUOLo-VLDpxju7WwEmjOSyByHre3avQ@mail.gmail.com
State New, archived
Headers show

Commit Message

Linus Torvalds July 7, 2017, 3:59 p.m. UTC
On Fri, Jul 7, 2017 at 5:46 AM, Michael Ellerman <mpe@ellerman.id.au> wrote:
> Al Viro <viro@ZenIV.linux.org.uk> writes:
>
>>
>>   Switch flock copyin/copyout primitives to copy_{from,to}_user() (2017-06-26 23:52:44 -0400)
>
> This commit seems to have broken networking on a bunch of my PPC
> machines (64-bit kernel, 32-bit userspace).

Bah. I think that commit is entirely broken, due to having the
arguments to the "copy_flock_fields()" in the wrong order.

The copy_flock_fields() macro has the arguments in order <from, to>,
but all the users seem to do it the other way around.

I think it would have been more obvious if the put_compat_flock*()
source argument had been "const".

> Patch coming.

I'm not seeing a patch, so I did my own. But it's _entirely_ untested.
Does the attached fix things for you?

                     Linus
fs/fcntl.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

Comments

Linus Torvalds July 7, 2017, 4:30 p.m. UTC | #1
On Fri, Jul 7, 2017 at 8:59 AM, Linus Torvalds
<torvalds@linux-foundation.org> wrote:
>
>> Patch coming.
>
> I'm not seeing a patch, so I did my own. But it's _entirely_ untested.
> Does the attached fix things for you?

Oh, I see you sent a patch to the list but didn't cc me like in this thread.

Hmm. Al - I'd like to add the "const" parts at least. How the ordering
gets fixed (I changed it in the users of the macro, Michael changed
the macro itself) I don't much care about.

Can you get me a pull request soon since this presumably also breaks
every other compat case, and it just happened that power was the one
that noticed it first.. Or I can just commit my version, but I guess
Michael's is at least tested..

               Linus
Michael Ellerman July 7, 2017, 10:55 p.m. UTC | #2
Linus Torvalds <torvalds@linux-foundation.org> writes:

> On Fri, Jul 7, 2017 at 8:59 AM, Linus Torvalds
> <torvalds@linux-foundation.org> wrote:
>>
>>> Patch coming.
>>
>> I'm not seeing a patch, so I did my own. But it's _entirely_ untested.
>> Does the attached fix things for you?
>
> Oh, I see you sent a patch to the list but didn't cc me like in this thread.

Oops, I sent it To you, but I forgot to make it a reply to this thread
which was daft.

cheers
diff mbox

Patch

diff --git a/fs/fcntl.c b/fs/fcntl.c
index b6bd89628025..eeb19e22fd08 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -527,43 +527,43 @@  SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd,
 	(to).l_len = (from).l_len;		\
 	(to).l_pid = (from).l_pid;
 
-static int get_compat_flock(struct flock *kfl, struct compat_flock __user *ufl)
+static int get_compat_flock(struct flock *kfl, const struct compat_flock __user *ufl)
 {
 	struct compat_flock fl;
 
 	if (copy_from_user(&fl, ufl, sizeof(struct compat_flock)))
 		return -EFAULT;
-	copy_flock_fields(*kfl, fl);
+	copy_flock_fields(fl, *kfl);
 	return 0;
 }
 
-static int get_compat_flock64(struct flock *kfl, struct compat_flock64 __user *ufl)
+static int get_compat_flock64(struct flock *kfl, const struct compat_flock64 __user *ufl)
 {
 	struct compat_flock64 fl;
 
 	if (copy_from_user(&fl, ufl, sizeof(struct compat_flock64)))
 		return -EFAULT;
-	copy_flock_fields(*kfl, fl);
+	copy_flock_fields(fl, *kfl);
 	return 0;
 }
 
-static int put_compat_flock(struct flock *kfl, struct compat_flock __user *ufl)
+static int put_compat_flock(const struct flock *kfl, struct compat_flock __user *ufl)
 {
 	struct compat_flock fl;
 
 	memset(&fl, 0, sizeof(struct compat_flock));
-	copy_flock_fields(fl, *kfl);
+	copy_flock_fields(*kfl, fl);
 	if (copy_to_user(ufl, &fl, sizeof(struct compat_flock)))
 		return -EFAULT;
 	return 0;
 }
 
-static int put_compat_flock64(struct flock *kfl, struct compat_flock64 __user *ufl)
+static int put_compat_flock64(const struct flock *kfl, struct compat_flock64 __user *ufl)
 {
 	struct compat_flock64 fl;
 
 	memset(&fl, 0, sizeof(struct compat_flock64));
-	copy_flock_fields(fl, *kfl);
+	copy_flock_fields(*kfl, fl);
 	if (copy_to_user(ufl, &fl, sizeof(struct compat_flock64)))
 		return -EFAULT;
 	return 0;