Re: [PATCH] mm/uaccess: Use 'unsigned long' to placate UBSAN warnings, again

From: Josh Poimboeuf
Date: Wed Jan 13 2021 - 20:59:41 EST


On Thu, Jan 07, 2021 at 01:07:21PM -0800, Kees Cook wrote:
> On Wed, Jan 06, 2021 at 04:06:57PM -0800, Randy Dunlap wrote:
> > On 1/6/21 3:37 PM, Kees Cook wrote:
> > > On Mon, Jan 04, 2021 at 04:13:17PM +0100, Peter Zijlstra wrote:
> > >> On Tue, Dec 22, 2020 at 11:04:54PM -0600, Josh Poimboeuf wrote:
> > >>> GCC 7 has a known bug where UBSAN ignores '-fwrapv' and generates false
> > >>> signed-overflow-UB warnings. The type mismatch between 'i' and
> > >>> 'nr_segs' in copy_compat_iovec_from_user() is causing such a warning,
> > >>> which also happens to violate uaccess rules:
> > >>>
> > >>> lib/iov_iter.o: warning: objtool: iovec_from_user()+0x22d: call to __ubsan_handle_add_overflow() with UACCESS enabled
> > >>>
> > >>> Fix it by making the variable types match.
> > >>>
> > >>> This is similar to a previous commit:
> > >>>
> > >>> 29da93fea3ea ("mm/uaccess: Use 'unsigned long' to placate UBSAN warnings on older GCC versions")
> > >>
> > >> Maybe it's time we make UBSAN builds depend on GCC-8+ ?
> > >
> > > I would be totally fine with that. The only thing I can think of that
> > > might care is syzbot. Dmitry, does syzbot use anything older than gcc 8?
> >
> > I use UBSAN successfully with GCC 7.5.0.
> > However, I can revert whatever future patch someone adds for this...
>
> Peter, which GCC version specifically are you seeing this on? (i.e. can
> I just make in 7.5+ instead of 8+ to make Randy's life easier?)

I don't think that would help, we saw this bug on GCC 7.5.

--
Josh