Message ID | 20230427085612.1346752-2-linan666@huaweicloud.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp129664vqo; Thu, 27 Apr 2023 02:01:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7OYc89zorhWtQnsqWdew/bUGX1BEiCWbKzBM0WPh1oKgxNYKu0cFRpHPy3ABGw8Y29JCDy X-Received: by 2002:a05:6a00:148e:b0:640:dbe5:e2ee with SMTP id v14-20020a056a00148e00b00640dbe5e2eemr1579428pfu.10.1682586098917; Thu, 27 Apr 2023 02:01:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682586098; cv=none; d=google.com; s=arc-20160816; b=L79VFwkhbSjEMT4aVKht0iEx2Oo9oP0s+Dql33fmyGehu97qwaNaNhoPJXCCcjOLhC GkZzLD1tDLfntI+tzkzIATBPDmgSyLnknqhla8oyf5cV4qD86dDpCKXy17/UwZXbwmnl 3X1bJYsnV/ogsBEqtQvwmTm4PzaYbZmDtyRqskznCifgUNI+J/vFHy01KO8kED3MYUXs tT9/t5lhh/j0XhlpVJs4AxVoVf0r2nXZmMEFTvxigSNAxoW1CBBCc4uT9U4Pgx/Iiea5 ZADsYDjMEoFNAOr2/DkWQbNnMTZv3J0wVX6h0Zj5XssYrqxU8BtdjRxEF4B8GzzS37UT nx9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=LL1aKNxPh1D2em9KcZly4hssoml0HrPB5ANjfqGzigY=; b=zwvqdA4idUd/K/zgt1SzLjRJo4n2eH1AEUhxDuBLKEGczkmNyuRiiBpRL61TBrcVJ1 GjGeQLUsprZoQMGu4N1ENaPl8snABDjL8wwas3pci9mPp+XrZrb/mhwZp2rx4TeSYIvB ejuhbNEily3scPkyYB/bfXphqNoF7vi86SO9X3G1bjNO+wieN7SlBW1i8EhAtCxAwcV6 bThOHuGFGpZL6hjMlA78SZ/LKaOfx5Cy0J6kwfLIZkzim4uWqLNZFtkRxpEovPnkwILX zyzdzoMNs7BzXHFI0rjKnKsVWsvLOxbLhXbKc0mi5w8qDub0GqGEdbgXZnR4+JYsQgvg 6s9g== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y21-20020aa79435000000b0063d334a2eb2si15285516pfo.183.2023.04.27.02.01.22; Thu, 27 Apr 2023 02:01:38 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242986AbjD0I5Q (ORCPT <rfc822;zxc52fgh@gmail.com> + 99 others); Thu, 27 Apr 2023 04:57:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232094AbjD0I5O (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 27 Apr 2023 04:57:14 -0400 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 637EC19AF; Thu, 27 Apr 2023 01:57:12 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Q6V3n03fMz4f3mJP; Thu, 27 Apr 2023 16:57:09 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP4 (Coremail) with SMTP id gCh0CgBH_rHjOEpkmCsBIQ--.37560S5; Thu, 27 Apr 2023 16:57:10 +0800 (CST) From: linan666@huaweicloud.com To: song@kernel.org, neilb@suse.de, Rob.Becker@riverbed.com Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org, linan122@huawei.com, yukuai3@huawei.com, yi.zhang@huawei.com, houtao1@huawei.com, yangerkun@huawei.com Subject: [PATCH 1/3] md/raid10: fix slab-out-of-bounds in md_bitmap_get_counter Date: Thu, 27 Apr 2023 16:56:10 +0800 Message-Id: <20230427085612.1346752-2-linan666@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230427085612.1346752-1-linan666@huaweicloud.com> References: <20230427085612.1346752-1-linan666@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: gCh0CgBH_rHjOEpkmCsBIQ--.37560S5 X-Coremail-Antispam: 1UD129KBjvdXoWrur48urW5XF4UKw4rZFy7Jrb_yoWftrX_C3 4rXFyxJrWUCry3AwnrXw4xZrWjyw1Du3Z7WFsaqrySvF18u343WrW0yrnxt3WrGrW09ry5 Jryj9ayrur4YkjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbkxYFVCjjxCrM7AC8VAFwI0_Xr0_Wr1l1xkIjI8I6I8E6xAIw20E Y4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l82xGYIkIc2x26280x7IE14v26r18M2 8IrcIa0xkI8VCY1x0267AKxVWUCVW8JwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK 021l84ACjcxK6xIIjxv20xvE14v26F1j6w1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r 4UJVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_ GcCE3s1lnxkEFVAIw20F6cxK64vIFxWle2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64 xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j 6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwACI402YVCY1x02628vn2 kIc2xKxwAKzVCY07xG64k0F24l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_ Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17 CE14v26r1q6r43MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0 I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I 8E87Iv67AKxVW8JVWxJwCI42IY6I8E87Iv6xkF7I0E14v26r4UJVWxJrUvcSsGvfC2Kfnx nUUI43ZEXa7IU858n5UUUUU== X-CM-SenderInfo: polqt0awwwqx5xdzvxpfor3voofrz/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764319401236729984?= X-GMAIL-MSGID: =?utf-8?q?1764319401236729984?= |
Series |
md: bugfix of writing raid sysfs
|
|
Commit Message
Li Nan
April 27, 2023, 8:56 a.m. UTC
From: Li Nan <linan122@huawei.com> If we write a large number to md/bitmap_set_bits, md_bitmap_checkpage() will return -EINVAL because "page >= bitmap->pages", but the return value was not checked immediately in md_bitmap_get_counter() in order to set *blocks value and slab-out-of-bounds occurs. Return directly if err is -EINVAL. Fixes: ef4256733506 ("md/bitmap: optimise scanning of empty bitmaps.") Signed-off-by: Li Nan <linan122@huawei.com> --- drivers/md/md-bitmap.c | 2 ++ 1 file changed, 2 insertions(+)
Comments
Hi, 在 2023/04/27 16:56, linan666@huaweicloud.com 写道: > From: Li Nan <linan122@huawei.com> > > If we write a large number to md/bitmap_set_bits, md_bitmap_checkpage() > will return -EINVAL because "page >= bitmap->pages", but the return value > was not checked immediately in md_bitmap_get_counter() in order to set > *blocks value and slab-out-of-bounds occurs. > > Return directly if err is -EINVAL. > > Fixes: ef4256733506 ("md/bitmap: optimise scanning of empty bitmaps.") > Signed-off-by: Li Nan <linan122@huawei.com> This patch looks good to me, feel free to add: Reviewed-by: Yu Kuai <yukuai3@huawei.com> By the way, I think it's better for bitmap_store() to return error number if bitmap doesn't exist or setting dirty bits failed. Thnaks, Kuai > --- > drivers/md/md-bitmap.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c > index 920bb68156d2..0b41ef422da7 100644 > --- a/drivers/md/md-bitmap.c > +++ b/drivers/md/md-bitmap.c > @@ -1388,6 +1388,8 @@ __acquires(bitmap->lock) > int err; > > err = md_bitmap_checkpage(bitmap, page, create, 0); > + if (err == -EINVAL) > + return NULL; > > if (bitmap->bp[page].hijacked || > bitmap->bp[page].map == NULL) >
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index 920bb68156d2..0b41ef422da7 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -1388,6 +1388,8 @@ __acquires(bitmap->lock) int err; err = md_bitmap_checkpage(bitmap, page, create, 0); + if (err == -EINVAL) + return NULL; if (bitmap->bp[page].hijacked || bitmap->bp[page].map == NULL)