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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8003EECAAD8 for ; Fri, 16 Sep 2022 22:59:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9BA108D0002; Fri, 16 Sep 2022 18:59:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 969A38D0001; Fri, 16 Sep 2022 18:59:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8311B8D0002; Fri, 16 Sep 2022 18:59:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 7481A8D0001 for ; Fri, 16 Sep 2022 18:59:02 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 4B96D1A1C2E for ; Fri, 16 Sep 2022 22:59:02 +0000 (UTC) X-FDA: 79919465724.02.0109953 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf10.hostedemail.com (Postfix) with ESMTP id 08EC7C0092 for ; Fri, 16 Sep 2022 22:59:01 +0000 (UTC) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 1EA3062DB8; 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663369142; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=hVYgjD14dkpMYNR9ErmG+kXNP6DYZQgQ7WEFL+Mvm8k=; b=krEHRq4QE+7XbWSArvbSjfPprdyqdZucra34KQHwCfQgYhC858IxzVVOMff64B1K5URzxW GJRBaaCDPi3U2+2vb62Z9pBkhEedr8RDr2151LQ3MAnRIzc9e/w57LhAJ7XscFvEJiZJYY vA0VHk+gXTXt404TbzVcB8M2Wd5Utfk= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=pOwlYMFM; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf10.hostedemail.com: domain of vbabka@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=vbabka@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663369142; a=rsa-sha256; cv=none; b=qOFnl8Blz1plvEYVd99a1cVPSpu2HEtE95QhgiAobYsaRf6hBSAwJhUYoz++Pt6plQkWJQ VtLFuMKuYPoyR/3ewbM/FlIYG6EKeZD6pWPlkzqUUKTvpexqABy1WL08+7Jq0VRxopO6Br EJR83gRM3UkrNpB8JYso7dbvUD+wwAM= Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=pOwlYMFM; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf10.hostedemail.com: domain of vbabka@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=vbabka@kernel.org X-Rspam-User: X-Stat-Signature: uaqwyhz7bjcw5hw7ob5j36m1zb6xwriy X-Rspamd-Queue-Id: 08EC7C0092 X-Rspamd-Server: rspam12 X-HE-Tag: 1663369141-833030 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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.