lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Wed, 3 Apr 2019 15:36:48 +0300
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     Rasmus Villemoes <linux@...musvillemoes.dk>
Cc:     Yury Norov <yury.norov@...il.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Arnd Bergmann <arnd@...db.de>,
        Kees Cook <keescook@...omium.org>,
        Matthew Wilcox <willy@...radead.org>,
        Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>,
        Mike Travis <travis@....com>, Yury Norov <ynorov@...vell.com>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/5] lib: make bitmap_parselist_user() a wrapper on
 bitmap_parselist()

On Wed, Apr 03, 2019 at 02:17:39PM +0200, Rasmus Villemoes wrote:
> On 03/04/2019 13.17, Andy Shevchenko wrote:
> > On Wed, Apr 03, 2019 at 02:15:22PM +0300, Andy Shevchenko wrote:
> >> On Wed, Apr 03, 2019 at 07:45:36AM +0300, Yury Norov wrote:
> >>> Currently we parse user data byte after byte which leads to
> >>> overcomplification of parsing algorithm. The only user of
> >>> bitmap_parselist_user() is not performance-critical, and so we
> >>> can copy user data to kernel buffer and simply call
> >>> bitmap_parselist(). This rework lets us unify and simplify
> >>> bitmap_parselist() and bitmap_parselist_user(), which is done
> >>> in the following patch.
> >>
> >>> +	buf = kmalloc(ulen + 1, GFP_KERNEL);
> >>> +	if (!buf)
> >>> +		return -ENOMEM;
> >>> +
> >>> +	buf[ulen] = 0;
> >>> +
> >>> +	ret = copy_from_user(buf, ubuf, ulen);
> >>> +	if (ret)
> >>> +		goto out;
> >>
> >> Why not memdup_user() ?
> > 
> > Even more precisely (for strings) strndup_user().
> > 
> 
> But the user buffer is not nul-terminated, i.e. it's not a string. 

Missed that. I stand corrected.

> What
> you want is memdup_user_nul() - take a length-delimited user buffer and
> turn it into a nul-terminated string in kernel memory.

Good, we have a helper.

-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ