Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp512773rwe; Wed, 31 Aug 2022 06:39:20 -0700 (PDT) X-Google-Smtp-Source: AA6agR4Yx0KQnm1tq0IJYV5LwpyGQDvP91rzFGFFqFsqB/clKH/WtC9dSR5WburKAzZ5aVPbLikY X-Received: by 2002:a05:6402:530d:b0:446:e22:cca2 with SMTP id eo13-20020a056402530d00b004460e22cca2mr24668161edb.237.1661953160063; Wed, 31 Aug 2022 06:39:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661953160; cv=none; d=google.com; s=arc-20160816; b=MFy5l//eNYBLVgsTlyjdL4C8/QRGRaiZV0E4IgRUbQMul7dU2yk6qB1bLa778zZckK K4smPyhX7Tm06f+uv6N6JaaXcC++7BKSYEnwdy+oAV3dwK5oOjUDOSyothcfvyibbCcX lj1gup3mhe8XNM0BZpGrFHjjrJPbCbbeDMSqYSEpz+EXMVCNTmtOyefdu69TB51A4GK+ 11yZhg1mWOgv0E4IRCQygRWnVbiNVTouD5MTfPFrGStTls2vcNzq9MoYN6j7MuRcdfi+ qI0uhoVmypFCUleWcbExFwAOycgWSxRzdizEhXscxc6yWG0P8C8/5cVyg4xBu/66QSKr InrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=1PE3GKnhwOhRif7fn1enjVH8DVXVUvhYKrLN724969I=; b=jMZnKBHefqkbFhkhuRbHUWgIn4UYASvKB4qqOju5/LVqC/RpDzHMewYERzxMpdFpZQ dUYl+b68C5u0Nfk/qGVuMTWQS/1oFg3SX8ZQQqZnOtbnwGSIhzz1bd0cgRbgs5r0NEPu J5cVmAnq2OIWTXWG+Vm2iLDYM54bkqMU8+rzeI/FoYWz7WiiSH2YQymGdLizVaRIlJBn w0APlewDEQ1VXD7/agYvsuThXfO3wvDIIejc4acmN5i4XTsTZ5hDb4EqR9ola/Zp9Bmc M2sP5azxCV3PhacFLt+HjM4NpYfl3DUABHTv1P9XSfU938seCE7gVvkQoH17u68wftEe hyGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=BDicR5TJ; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q34-20020a05640224a200b0043c2919cfd3si9542118eda.602.2022.08.31.06.38.54; Wed, 31 Aug 2022 06:39:20 -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=@gmail.com header.s=20210112 header.b=BDicR5TJ; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230080AbiHaNfT (ORCPT + 99 others); Wed, 31 Aug 2022 09:35:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231269AbiHaNev (ORCPT ); Wed, 31 Aug 2022 09:34:51 -0400 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2699FD571A for ; Wed, 31 Aug 2022 06:33:56 -0700 (PDT) Received: by mail-pg1-x531.google.com with SMTP id x80so9947243pgx.0 for ; Wed, 31 Aug 2022 06:33:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc; bh=1PE3GKnhwOhRif7fn1enjVH8DVXVUvhYKrLN724969I=; b=BDicR5TJvL5oR2CfoULAhbPtsjdaQUo8LupEgctXNvDRwIdsaxZVxk3GBI3Erzm4vk aCYL0FK9UAa4d751uPbhSGOVQLb0E5V+/9+zN2P+pfgn58Te4w2jJ+geGwfNLM8wQYt1 ruQNla7c/YWtBBlAJ8wxKBaBOsNNDhvAFLM2wkK1VEnF7sqNw4dwUyun7xT11TmgwUp9 rE+/GTAen/+frXJ3pcZ8s8nWEZZiu1fgC49WIdMaW+rwKMCqe19QG+uaJvutr2PnTaxH C9cbKyr3IhIae0cxmQLNUUt1HhQvdiha6n8HF5vaUf7hJGsEATD/PErOya2PB4zTlQdC iPeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc; bh=1PE3GKnhwOhRif7fn1enjVH8DVXVUvhYKrLN724969I=; b=IPoT/Lk5YZOydo4/kBYNxH0RkZfvBEP/IPIHOe5lrr+TgIRRgnym2w5zTKyoxOHGwn QnvO95IzRSBm78a5fhwpayGgb7ZqZsA2wBytLNRb1pXZo7O9uu41Kwc9nu8mlrquDZfa 5u3k0dlpWy/42FLvHKpKJ5FVC7fa4uHHcRHqOGxHN5E9fJHwYWfY+aNZlAiNehrD7sxS VWKQioHKrsXxFz5Ku0nNNSfO2BAFYAGf/QHR1UrNu46ku/eXAXzNfB5jgKz3oTyLfvXQ 4IyUZd5VXtnRTvCUsmH+SVOorHbPYR1qc9e+I56M0vDGf9UAy/IuktT/eEjkNKGiO32c YYew== X-Gm-Message-State: ACgBeo3iQB/p0BS65UMqIO251gqCjzHWKZwp4bUI2YT6QqxmoGSP1rOl WPZNEDT2BJeV/1coRstEt9Rz1LBIonc= X-Received: by 2002:a65:6d93:0:b0:42c:50ec:8025 with SMTP id bc19-20020a656d93000000b0042c50ec8025mr9689713pgb.62.1661952834522; Wed, 31 Aug 2022 06:33:54 -0700 (PDT) Received: from hyeyoo ([114.29.91.56]) by smtp.gmail.com with ESMTPSA id pj7-20020a17090b4f4700b001fb277223bdsm1306189pjb.2.2022.08.31.06.33.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Aug 2022 06:33:53 -0700 (PDT) Date: Wed, 31 Aug 2022 22:33:48 +0900 From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Chao Yu Cc: linux-mm@kvack.org, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, jaegeuk@kernel.org, Chao Yu , stable@kernel.org, syzbot+81684812ea68216e08c5@syzkaller.appspotmail.com Subject: Re: [PATCH] mm/slub: fix to return errno if kmalloc() fails Message-ID: References: <20220830141009.150075-1-chao@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220830141009.150075-1-chao@kernel.org> X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HK_RANDOM_ENVFROM, HK_RANDOM_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no 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 Tue, Aug 30, 2022 at 10:10:09PM +0800, Chao Yu wrote: > 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: > sysfs_slab_add+0x258/0x260 mm/slub.c:5973 > __kmem_cache_create+0x60/0x118 mm/slub.c:4899 > create_cache mm/slab_common.c:229 [inline] > kmem_cache_create_usercopy+0x19c/0x31c mm/slab_common.c:335 > kmem_cache_create+0x1c/0x28 mm/slab_common.c:390 > f2fs_kmem_cache_create fs/f2fs/f2fs.h:2766 [inline] > f2fs_init_xattr_caches+0x78/0xb4 fs/f2fs/xattr.c:808 > f2fs_fill_super+0x1050/0x1e0c fs/f2fs/super.c:4149 > mount_bdev+0x1b8/0x210 fs/super.c:1400 > f2fs_mount+0x44/0x58 fs/f2fs/super.c:4512 > legacy_get_tree+0x30/0x74 fs/fs_context.c:610 > vfs_get_tree+0x40/0x140 fs/super.c:1530 > do_new_mount+0x1dc/0x4e4 fs/namespace.c:3040 > path_mount+0x358/0x914 fs/namespace.c:3370 > do_mount fs/namespace.c:3383 [inline] > __do_sys_mount fs/namespace.c:3591 [inline] > __se_sys_mount fs/namespace.c:3568 [inline] > __arm64_sys_mount+0x2f8/0x408 fs/namespace.c:3568 > > Cc: > Reported-by: syzbot+81684812ea68216e08c5@syzkaller.appspotmail.com Fixes: 81819f0fc8285 ("SLUB core") > 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); > char *p = name; > > - BUG_ON(!name); > + if (!name) > + return ERR_PTR(-ENOMEM); > > *p++ = ':'; > /* > @@ -5948,6 +5949,8 @@ static int sysfs_slab_add(struct kmem_cache *s) > * for the symlinks. > */ > name = create_unique_id(s); > + if (IS_ERR(name)) > + return PTR_ERR(name); > } > > s->kobj.kset = kset; > -- > 2.25.1 > > Looks good to me. Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Thanks! -- Thanks, Hyeonggon