From: Jeff Layton <jlayton@kernel.org>
To: Vitaly Lipatov <lav@etersoft.ru>
Cc: wine-patches <wine-patches@winehq.org>,
"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: Wed, 15 Nov 2017 08:16:45 -0500 [thread overview]
Message-ID: <1510751805.4235.33.camel@kernel.org> (raw)
In-Reply-To: <f4d385a49749a4f7aa08749c3614f776@etersoft.ru>
On Wed, 2017-11-15 at 00:22 +0300, Vitaly Lipatov wrote:
> Jeff Layton писал 14.11.17 23:19:
> > On Tue, 2017-11-14 at 22:25 +0300, Vitaly Lipatov wrote:
> > > Jeff Layton писал 14.11.17 22:12:
> > > ...
> > > > 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.
> > >
> > > I am not sure, can off_t be bigger than loff_t ?
> >
> > I don't think so, at least not in any possible situation we care about
> > here.
>
> We have this checking for ages:
> if (f.l_start > COMPAT_LOFF_T_MAX)
> ret = -EOVERFLOW;
> http://debian.securedservers.com/kernel/pub/linux/kernel/people/akpm/patches/2.6/2.6.15-rc5/2.6.15-rc5-mm1/broken-out/fix-overflow-tests-for-compat_sys_fcntl64-locking.patch
>
I'm not convinced that those checks ever did anything, tbh.
> >
> > > If not, we have just skip checking against COMPAT_LOFF_T_MAX.
> > >
> > > ...
> > > > > @@ -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?
> > > >
> >
> > Ok. If you have a test for this, mind testing and sending a patch?
>
> I think if COMPAT_LOFF_T_MAX is exists, that value can be smaller than
> can fit in off_t.
> Checking against COMPAT_LOFF_T_MAX keep old logic works for me last 10
> years.
>
> I have some tests around wine project I worked on. May be later I will
> do additional tests.
>
I am making an assumption here that l_start and l_end can never be
larger than a signed 64-bit value. I don't see how it ever could be,
given that it's defined as a long long, but I suppose we could add some
exotic arch later that does something weird.
Maybe we can just add a BUILD_BUG_ON for that? I'll send along an
alternate patch in a few mins.
--
Jeff Layton <jlayton@kernel.org>
prev parent reply other threads:[~2017-11-15 13:16 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
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 [this message]
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=1510751805.4235.33.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.