The patch titled Subject: lib: make bitmap_parse_user a wrapper on bitmap_parse has been added to the -mm tree. Its filename is lib-make-bitmap_parse_user-a-wrapper-on-bitmap_parse.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/lib-make-bitmap_parse_user-a-wrapper-on-bitmap_parse.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/lib-make-bitmap_parse_user-a-wrapper-on-bitmap_parse.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Yury Norov <yury.norov@xxxxxxxxx> Subject: lib: make bitmap_parse_user a wrapper on bitmap_parse Currently we parse user data byte after byte which leads to overcomplicating of parsing algorithm. There are no performance critical users of bitmap_parse_user(), and so we can duplicate user data to kernel buffer and simply call bitmap_parselist(). This rework lets us unify and simplify bitmap_parse() and bitmap_parse_user(), which is done in the following patch. Link: http://lkml.kernel.org/r/20200102043031.30357-5-yury.norov@xxxxxxxxx Signed-off-by: Yury Norov <yury.norov@xxxxxxxxx> Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> Cc: Amritha Nambiar <amritha.nambiar@xxxxxxxxx> Cc: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> Cc: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> Cc: Kees Cook <keescook@xxxxxxxxxxxx> Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx> Cc: Miklos Szeredi <mszeredi@xxxxxxxxxx> Cc: Rasmus Villemoes <linux@xxxxxxxxxxxxxxxxxx> Cc: Steffen Klassert <steffen.klassert@xxxxxxxxxxx> Cc: "Tobin C . Harding" <tobin@xxxxxxxxxx> Cc: Vineet Gupta <vineet.gupta1@xxxxxxxxxxxx> Cc: Will Deacon <will.deacon@xxxxxxx> Cc: Willem de Bruijn <willemb@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- lib/bitmap.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) --- a/lib/bitmap.c~lib-make-bitmap_parse_user-a-wrapper-on-bitmap_parse +++ a/lib/bitmap.c @@ -464,22 +464,22 @@ EXPORT_SYMBOL(__bitmap_parse); * then it must be terminated with a \0. * @maskp: pointer to bitmap array that will contain result. * @nmaskbits: size of bitmap, in bits. - * - * Wrapper for __bitmap_parse(), providing it with user buffer. - * - * We cannot have this as an inline function in bitmap.h because it needs - * linux/uaccess.h to get the access_ok() declaration and this causes - * cyclic dependencies. */ int bitmap_parse_user(const char __user *ubuf, unsigned int ulen, unsigned long *maskp, int nmaskbits) { - if (!access_ok(ubuf, ulen)) - return -EFAULT; - return __bitmap_parse((const char __force *)ubuf, - ulen, 1, maskp, nmaskbits); + char *buf; + int ret; + buf = memdup_user_nul(ubuf, ulen); + if (IS_ERR(buf)) + return PTR_ERR(buf); + + ret = bitmap_parse(buf, ulen, maskp, nmaskbits); + + kfree(buf); + return ret; } EXPORT_SYMBOL(bitmap_parse_user); _ Patches currently in -mm which might be from yury.norov@xxxxxxxxx are lib-string-add-strnchrnul.patch bitops-more-bits_to_-macros.patch lib-add-test-for-bitmap_parse.patch lib-add-test-for-bitmap_parse-fix.patch lib-make-bitmap_parse_user-a-wrapper-on-bitmap_parse.patch lib-rework-bitmap_parse.patch lib-new-testcases-for-bitmap_parse_user.patch cpumask-dont-calculate-length-of-the-input-string.patch