lkml.org 
[lkml]   [2020]   [Apr]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 6/6] sysctl: pass kernel pointers to ->proc_handler
On Fri, Apr 17, 2020 at 11:17:18AM -0700, Matthew Wilcox wrote:
> > if (error)
> > - goto out;
> > + goto out_free_buf;
> >
> > /* careful: calling conventions are nasty here */
>
> I think this comment can go now ;-)

It actually long predates the set_fs that was only added for BPF,
and goes back to:

330d57fb98a91 ("[PATCH] Fix sysctl unregistration oops (CVE-2005-2709)")
in the history.git tree.

> > - } else {
> > - error = table->proc_handler(table, write, buf, &count, ppos);
> > - }
> > + error = table->proc_handler(table, write, kbuf, &count, ppos);
> > + if (error)
> > + goto out_free_buf;
> > +
> > + error = -EFAULT;
> > + if (copy_to_user(ubuf, kbuf, count))
> > + goto out_free_buf;
>
> Can we skip this if !write? Indeed, don't we have to in case the user has
> passed a pointer to a read-only memory page?

Indeed.

\
 
 \ /
  Last update: 2020-04-21 09:43    [W:0.089 / U:2.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site