linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: Vitaly Lipatov <lav@etersoft.ru>, wine-patches <wine-patches@winehq.org>
Cc: "J. Bruce Fields" <bfields@fieldses.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH v3] fs/fcntl: restore checking against COMPAT_LOFF_T_MAX for F_GETLK64
Date: Tue, 14 Nov 2017 14:12:58 -0500	[thread overview]
Message-ID: <1510686778.4757.11.camel@kernel.org> (raw)
In-Reply-To: <20171114164818.6783-1-lav@etersoft.ru>

On Tue, 2017-11-14 at 19:48 +0300, Vitaly Lipatov wrote:
> for fcntl64 with F_GETLK64 we need use checking against COMPAT_LOFF_T_MAX.
> 
> Fixes: 94073ad77fff2 "fs/locks: don't mess with the address limit in compat_fcntl64"
> 
> Signed-off-by: Vitaly Lipatov <lav@etersoft.ru>
> ---
>  fs/fcntl.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/fcntl.c b/fs/fcntl.c
> index 30f47d0..e9443d9 100644
> --- a/fs/fcntl.c
> +++ b/fs/fcntl.c
> @@ -590,17 +590,17 @@ convert_fcntl_cmd(unsigned int cmd)
>   * GETLK was successful and we need to return the data, but it needs to fit in
>   * the compat structure.
>   * l_start shouldn't be too big, unless the original start + end is greater than
> - * COMPAT_OFF_T_MAX, in which case the app was asking for trouble, so we return
> + * off_t_max, in which case the app was asking for trouble, so we return
>   * -EOVERFLOW in that case.  l_len could be too big, in which case we just
>   * truncate it, and only allow the app to see that part of the conflicting lock
>   * that might make sense to it anyway
>   */
> -static int fixup_compat_flock(struct flock *flock)
> +static int fixup_compat_flock(struct flock *flock, loff_t off_t_max)
>  {
> -	if (flock->l_start > COMPAT_OFF_T_MAX)
> +	if (flock->l_start > off_t_max)
>  		return -EOVERFLOW;
> -	if (flock->l_len > COMPAT_OFF_T_MAX)
> -		flock->l_len = COMPAT_OFF_T_MAX;
> +	if (flock->l_len > off_t_max)
> +		flock->l_len = off_t_max;
>  	return 0;
>  }
> 

Wait...

Does this do anything at all in the case where you pass in
COMPAT_LOFF_T_MAX? l_start and l_len are either off_t or loff_t
(depending on arch).

Either one will fit in the F_GETLK64/F_OFD_GETLK struct, so I don't see
a need to check here.

>  
> @@ -631,7 +631,7 @@ COMPAT_SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd,
>  		err = fcntl_getlk(f.file, convert_fcntl_cmd(cmd), &flock);
>  		if (err)
>  			break;
> -		err = fixup_compat_flock(&flock);
> +		err = fixup_compat_flock(&flock, COMPAT_OFF_T_MAX);
>  		if (err)
>  			return err;
>  		err = put_compat_flock(&flock, compat_ptr(arg));
> @@ -644,7 +644,7 @@ COMPAT_SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd,
>  		err = fcntl_getlk(f.file, convert_fcntl_cmd(cmd), &flock);
>  		if (err)
>  			break;
> -		err = fixup_compat_flock(&flock);
> +		err = fixup_compat_flock(&flock, COMPAT_LOFF_T_MAX);
>  		if (err)
>  			return err;
>  		err = put_compat_flock64(&flock, compat_ptr(arg));

Maybe a simpler fix would be to just remove the fixup_compat_flock call
above?

PS: if you send any more patches, please cc Christoph. He did the
earlier work on cleaning up the compat syscall code, and I'd like him to
be kept in the loop on this as well.

Thanks,
-- 
Jeff Layton <jlayton@kernel.org>

  parent reply	other threads:[~2017-11-14 19:13 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-14  1:30 [PATCH] fs/fcntl: restore checking against COMPAT_LOFF_T_MAX for F_GETLK64 Vitaly Lipatov
2017-11-14 11:29 ` Jeff Layton
2017-11-14 11:37   ` Vitaly Lipatov
2017-11-14 13:47 ` [PATCH v2] " Vitaly Lipatov
2017-11-14 14:06   ` Jeff Layton
2017-11-14 16:48     ` Vitaly Lipatov
2017-11-14 16:48   ` [PATCH v3] " Vitaly Lipatov
2017-11-14 17:17     ` J. Bruce Fields
2017-11-14 19:12     ` Jeff Layton [this message]
2017-11-14 19:25       ` Vitaly Lipatov
2017-11-14 20:19         ` Jeff Layton
2017-11-14 21:22           ` Vitaly Lipatov
2017-11-15 13:16             ` Jeff Layton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1510686778.4757.11.camel@kernel.org \
    --to=jlayton@kernel.org \
    --cc=bfields@fieldses.org \
    --cc=hch@lst.de \
    --cc=lav@etersoft.ru \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=wine-patches@winehq.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).