lkml.org 
[lkml]   [2023]   [Nov]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] drivers/tty/vt: copy userspace arrays safely
On Fri, Nov 03, 2023 at 06:24:09AM +1000, David Airlie wrote:
> On Fri, Nov 3, 2023 at 6:14 AM Al Viro <viro@zeniv.linux.org.uk> wrote:
> >
> > On Thu, Nov 02, 2023 at 08:21:35PM +0100, Philipp Stanner wrote:
> > > The functions (v)memdup_user() are utilized to copy userspace arrays.
> > > This is done without overflow checks.
> > >
> > > Use the new wrappers memdup_array_user() and vmemdup_array_user() to
> > > copy the arrays more safely.
> >
> > > @@ -644,7 +644,7 @@ int con_set_unimap(struct vc_data *vc, ushort ct, struct unipair __user *list)
> > > if (!ct)
> > > return 0;
> >
> > > - unilist = vmemdup_user(list, array_size(sizeof(*unilist), ct));
> > > + unilist = vmemdup_array_user(list, ct, sizeof(*unilist));
> > > if (IS_ERR(unilist))
> > > return PTR_ERR(unilist);
> >
> > a 16bit value times sizeof(something).
>
> So since it's already using array_size here, moving it to a new helper
> for consistency just makes things clearer, and so you are fine with
> the patch?

Sigh... OK, if you want it spelled out, there we go. I have no objections
to the contents of patches; e.g. in case of ppp ioctl it saves the reader
a grep in search of structure definitions, which is a good thing. The one
and only suggestion I have for those patches is that such patches might be
better off with explicit "in this case the overflow is avoided due to
<reasons>, but use of this helper makes it obviously safe" - or, in case
of real bugs, "the overflow is, indeed, possible here", in which case
Fixes: ... and Cc: stable might be in order.

\
 
 \ /
  Last update: 2023-11-02 21:50    [W:0.043 / U:3.928 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site