From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752361AbdGGS77 (ORCPT ); Fri, 7 Jul 2017 14:59:59 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:34192 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751034AbdGGS76 (ORCPT ); Fri, 7 Jul 2017 14:59:58 -0400 Date: Fri, 7 Jul 2017 19:59:55 +0100 From: Al Viro To: Linus Torvalds Cc: Michael Ellerman , Linux Kernel Mailing List , linux-fsdevel , "linuxppc-dev@lists.ozlabs.org" Subject: Re: [git pull] vfs.git part 1 Message-ID: <20170707185955.GH10672@ZenIV.linux.org.uk> References: <20170705071423.GY10672@ZenIV.linux.org.uk> <87eftsv2hj.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.8.0 (2017-02-23) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 07, 2017 at 10:35:41AM -0700, Linus Torvalds wrote: > Comments? Michael, does this work for your case? Looks sane... > +++ b/fs/fcntl.c > @@ -520,50 +520,50 @@ SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd, > > #ifdef CONFIG_COMPAT > /* careful - don't use anywhere else */ > -#define copy_flock_fields(from, to) \ > - (to).l_type = (from).l_type; \ > - (to).l_whence = (from).l_whence; \ > - (to).l_start = (from).l_start; \ > - (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) > +#define copy_flock_fields(dst, src) \ > + (dst)->l_type = (src)->l_type; \ > + (dst)->l_whence = (src)->l_whence; \ > + (dst)->l_start = (src)->l_start; \ > + (dst)->l_len = (src)->l_len; \ > + (dst)->l_pid = (src)->l_pid; > + > +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(kfl, &fl); > 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(kfl, &fl); > 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(&fl, kfl); > 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(&fl, kfl); > if (copy_to_user(ufl, &fl, sizeof(struct compat_flock64))) > return -EFAULT; > return 0;