From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 911F6C4360F for ; Wed, 3 Apr 2019 11:17:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5E6222084C for ; Wed, 3 Apr 2019 11:17:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726199AbfDCLRv (ORCPT ); Wed, 3 Apr 2019 07:17:51 -0400 Received: from mga12.intel.com ([192.55.52.136]:60254 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725935AbfDCLRv (ORCPT ); Wed, 3 Apr 2019 07:17:51 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Apr 2019 04:17:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,304,1549958400"; d="scan'208";a="312781848" Received: from smile.fi.intel.com (HELO smile) ([10.237.72.86]) by orsmga005.jf.intel.com with ESMTP; 03 Apr 2019 04:17:47 -0700 Received: from andy by smile with local (Exim 4.92) (envelope-from ) id 1hBdtp-0001bD-LU; Wed, 03 Apr 2019 14:17:45 +0300 Date: Wed, 3 Apr 2019 14:17:45 +0300 From: Andy Shevchenko To: Yury Norov Cc: Andrew Morton , Rasmus Villemoes , Arnd Bergmann , Kees Cook , Matthew Wilcox , Tetsuo Handa , Mike Travis , Yury Norov , linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/5] lib: make bitmap_parselist_user() a wrapper on bitmap_parselist() Message-ID: <20190403111745.GQ9224@smile.fi.intel.com> References: <20190403044540.16322-1-ynorov@marvell.com> <20190403044540.16322-2-ynorov@marvell.com> <20190403111522.GP9224@smile.fi.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190403111522.GP9224@smile.fi.intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(). -- With Best Regards, Andy Shevchenko