Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp135317rwn; Fri, 16 Sep 2022 17:01:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5JJUB1SH2TeiTMOFOWslZTLuZ/jenX/Awd47NJvll8qNICqngmav77RTisw5ITZHQwD4Qt X-Received: by 2002:a63:1258:0:b0:439:c1e0:fab6 with SMTP id 24-20020a631258000000b00439c1e0fab6mr3499466pgs.377.1663372904879; Fri, 16 Sep 2022 17:01:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663372904; cv=none; d=google.com; s=arc-20160816; b=iAoZiLWSDYjMsIqmwzL44ezZxE9er/9K3rWEEQOsCeSmkEUmd0SXYja6oGSf0zB/xF Ord8M7K99ED/1Zc7BbWAIEpyQUjvjY7nD3/PVj/uUiyJ7iW+XlR+9Gg494ZlgLXOjaEj sd1cpkWwDswX0k2qw9aECndM+RoI3j9/dHUuEfTt0P7qaBn2hgGSj4AF4TzKxBgkh91N wt/tz4Hqo7EhFnylqOkLEVZtC/oaB31lSfYyMp14Fvti6O7+sNCPSmpwroc4HwHslhxE 2W2Fo65Wq7WFIpAG+n6uvf6N7QvCLiHaFMlP2x4w1Qxzf6BUy/yV3zqGSiifVvWjber5 30hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=hVYgjD14dkpMYNR9ErmG+kXNP6DYZQgQ7WEFL+Mvm8k=; b=JLefBuu9ePlCwsFAiJO3w+5O4ZbTjH0pV7J28EQ3PSSm0TecRczFENPcKCBalK+xXk N55biZoEONk3HKkRFiUWK5vir2B9gBfdOQaaEoUj22vpi4jJMJSdR6Ad+Fr1b6eSTxsH rw+kV7094w2TQgqFvwgkAlPBEuuqO7HN8MDIsS0neLnqO/pZJzeF/Kr8OnWdCO/yD+4e DpAbZehJwiRc0izmS8vtt//MEmw7kItQSnJgg5ABaS6MOMWYGLCN/3PET2B/XfyAkp1e a8Fnqm49BhqSxd7bAJu3zWnannDtk0RoHSRWK4NaSHnXadNhW7Ci0nhORnPmKhFMK8pB o5pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pOwlYMFM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u14-20020a170902e5ce00b0017543def6fbsi25707178plf.60.2022.09.16.17.01.32; Fri, 16 Sep 2022 17:01:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pOwlYMFM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229766AbiIPW7G (ORCPT + 99 others); Fri, 16 Sep 2022 18:59:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229577AbiIPW7E (ORCPT ); Fri, 16 Sep 2022 18:59:04 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73E43B07DF for ; Fri, 16 Sep 2022 15:59:03 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E263CB8295E for ; Fri, 16 Sep 2022 22:59:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20B19C433C1; Fri, 16 Sep 2022 22:58:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663369140; bh=woX7AGmuU2N902gGUPhtT7Z+7N0u/k69ufjvL0LI040=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=pOwlYMFMHavTaqxChCVwoTvOkTevrimVfcNCbvsCLX49uXAz34KJuo9VcI+Boz/FC PsGOqRyqcDl0KGZVlIuFcMxCr1tff8SZz2Qrsjcv3BPWPIYordclnB9P7Z5mpmvhuc P9BCY59k4g0WnUaKhp7DeuTOcfZqGuYbv3t81Us6RJ+KUXdVFnb/dA/baTp3BlvzcE FPBJQMquGNMw3LDq0bdZ+9JgQhIhfWlfIdvHCRtmx4DnUm46dPyxRrK+SXAbEROA2D /y51ezigXM4GclCdt97w921mM9fxp45jxaX8D8V2wy3kXFnMPRCpDapdMVjoesDGeP XU6hunkuGL9sg== Message-ID: Date: Sat, 17 Sep 2022 00:58:56 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.1 Subject: Re: [PATCH] mm/slub: fix to return errno if kmalloc() fails Content-Language: en-US To: Marion & Christophe JAILLET , Chao Yu , linux-mm@kvack.org Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, Chao Yu , muchun.song@linux.dev References: <20220830141009.150075-1-chao@kernel.org> <2025305d-16db-abdf-6cd3-1fb93371c2b4@wanadoo.fr> <4b87891d-b475-0ad6-db36-a9c1f334c785@wanadoo.fr> From: "Vlastimil Babka (SUSE)" In-Reply-To: <4b87891d-b475-0ad6-db36-a9c1f334c785@wanadoo.fr> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/13/22 07:26, Marion & Christophe JAILLET wrote: > > Le 13/09/2022 à 05:42, Chao Yu a écrit : >> On 2022/9/10 0:47, Christophe JAILLET wrote: >>> Le 30/08/2022 à 16:10, Chao Yu a écrit : >>>> From: Chao Yu >>>> >>>> In create_unique_id(), kmalloc(, GFP_KERNEL) can fail due to >>>> out-of-memory, if it fails, return errno correctly rather than >>>> triggering panic via BUG_ON(); >>>> >>>> kernel BUG at mm/slub.c:5893! >>>> Internal error: Oops - BUG: 0 [#1] PREEMPT SMP >>>> >>>> Call trace: > [...] >>>> >>>> Cc: >>>> Reported-by: syzbot+81684812ea68216e08c5@syzkaller.appspotmail.com >>>> Signed-off-by: Chao Yu >>>> --- >>>>   mm/slub.c | 5 ++++- >>>>   1 file changed, 4 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/mm/slub.c b/mm/slub.c >>>> index 862dbd9af4f5..e6f3727b9ad2 100644 >>>> --- a/mm/slub.c >>>> +++ b/mm/slub.c >>>> @@ -5890,7 +5890,8 @@ static char *create_unique_id(struct kmem_cache *s) >>>>       char *name = kmalloc(ID_STR_LENGTH, GFP_KERNEL); >>> >>> Hi, >>> >>> looks that ID_STR_LENGTH could even be reduced to 32 or 16. >>> >>> The 2nd BUG_ON at the end of the function could certainly be just removed >>> as well or remplaced by a: >>>         if (p > name + ID_STR_LENGTH - 1) { >>>          kfree(name); >>>          return -E; >>>      } >> >> Hi Christophe, Vlastimil, >> >> Should I include this in v3? or may be in another patch? > > Hi, > > My own preference would be for 3 patches. > > Yours, as-is. > It fixes a specific issue spotted by syzbot. Yeah and it's already in git. > Another one for removing a BUG_ON() (that, IIUC can't happen!) > Mostly a clean-up or a good practice in order to remove BUG_ON() from the > kernel we it can be handled another way. > > Eventually a 3rd one for reducing ID_STR_LENGTH. > I guess that it is safe to reduce it to 32 or 16, but the impact on RL would > be so small, that I wonder if it worth proposing it. Agree. Doing 2+3 in the same patch would be OK with me too.