Message ID | 20230527101851.3266500-1-linan666@huaweicloud.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp250461vqr; Sat, 27 May 2023 03:38:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6qXdPMWY1F4rh5RTaOJ4siS8+sI+J6dsxcWiCrJzjYSvNsG3UYJHRC1xx/3/6psgEXFsFc X-Received: by 2002:a05:6a20:7486:b0:10b:764b:a942 with SMTP id p6-20020a056a20748600b0010b764ba942mr2313672pzd.11.1685183881982; Sat, 27 May 2023 03:38:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685183881; cv=none; d=google.com; s=arc-20160816; b=TOt/+R6WoXdJm1WAs2iD7JAGB79XIVq2nJS/pNJPj5sR3hIPlAPNDNK0SyveejTQUA i7MYJpCOK29OG+IxZQA8kjrDbxYw4IKfQZnxtObUAHNJ7Jo6JGWRhOH5rjm+pML9nbLO ziSEnv2IHBc8XZ2LdnTTVOX6vRcdiocL83ozv9CVG4VvOS+RR+yCiB1tmYnroDnNK89y VL7dwkmFmJqk21c0SrYcyuPLOdmNqA6XyTCTvRiNeOzXR9goO3UHcxE7UqtyMIgC0KP5 QHaAlMVgC37yKHp1eEZ7GlUch6kbDmqTeCUQQHwWj2wcQJJYgSQ+3/uGseRhbWZRo+1H rl8w== 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 :message-id:date:subject:cc:to:from; bh=96NJc/JGbTHh1Q+s5hAL3AOshHFcBUpX12YOmlgFIg8=; b=px8z1oGEwjEYVPxDcmuwvv/sL+Pz+5RJUjwdhm97AyeGSJ3KvjB45xP71apqljwCw3 YPBlj15T6sgghdCdP3Qhc5p49l2WFZ1+7YGubSZ9MbwSMOu67ddhM9UMbHjf+mN3zy5W /lWv1m7nlHDfWuNcZ8q8AQeZQYXelvaYzls7mYN62njkJ9bwPETP60ZkpMtiWZwvfBky w/fhhPIzudv7z8FbHspoC+XJ9A0JcH+A1vlfrY6zEmBl0oY8B5wA29alzkHFdXHA1xAb gNTV21MpM0080+1Y9rKTxVuW1AzWUA4g96ESi3ZSF0ovQhFIo8rCkpQbJxrOF6DWCINv 90Qg== 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 e21-20020a637455000000b0053f23ff9817si2554713pgn.874.2023.05.27.03.37.49; Sat, 27 May 2023 03:38:01 -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 S232170AbjE0KUh (ORCPT <rfc822;zhanglyra.2023@gmail.com> + 99 others); Sat, 27 May 2023 06:20:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231634AbjE0KUf (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 27 May 2023 06:20:35 -0400 Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61EFD114; Sat, 27 May 2023 03:20:33 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4QSyV340tlz4f3tDn; Sat, 27 May 2023 18:20:27 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP4 (Coremail) with SMTP id gCh0CgBH_rFr2XFkGW9JKQ--.57203S4; Sat, 27 May 2023 18:20:29 +0800 (CST) From: linan666@huaweicloud.com To: song@kernel.org 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] md/bitmap: check input value with ULONG_MAX in timeout_store Date: Sat, 27 May 2023 18:18:50 +0800 Message-Id: <20230527101851.3266500-1-linan666@huaweicloud.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: gCh0CgBH_rFr2XFkGW9JKQ--.57203S4 X-Coremail-Antispam: 1UD129KBjvdXoWrKFWfWFyDZr1rAw45uF1rZwb_yoW3uwb_u3 WqqFySqrWqkry2yrn8Jw1IvryUtw4UWF1DCwn2v3ya9w1ru3yUGr9Y9wnxZF18XrWUCFy5 JFyFgry8Aw4UKjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUb3xYFVCjjxCrM7AC8VAFwI0_Gr0_Xr1l1xkIjI8I6I8E6xAIw20E Y4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l8cAvFVAK0II2c7xJM28CjxkF64kEwV A0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2Ix0cI8IcVCY1x02 67AKxVWxJVW8Jr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxV AFwI0_GcCE3s1lnxkEFVAIw20F6cxK64vIFxWle2I262IYc4CY6c8Ij28IcVAaY2xG8wAq x4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14 v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwAKzVCY07xG64k0 F24lc7CjxVAaw2AFwI0_Jw0_GFyl42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr 0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY 17CE14v26r1q6r43MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcV C0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE42xK8VAvwI8IcIk0rVWrJr0_WFyUJwCI 42IY6I8E87Iv67AKxVW8JVWxJwCI42IY6I8E87Iv6xkF7I0E14v26r4UJVWxJrUvcSsGvf C2KfnxnUUI43ZEXa7IU1vJmUUUUUU== X-CM-SenderInfo: polqt0awwwqx5xdzvxpfor3voofrz/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,KHOP_HELO_FCRDNS, SPF_HELO_NONE,SPF_NONE,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: <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?1767043374322462316?= X-GMAIL-MSGID: =?utf-8?q?1767043374322462316?= |
Series |
md/bitmap: check input value with ULONG_MAX in timeout_store
|
|
Commit Message
Li Nan
May 27, 2023, 10:18 a.m. UTC
From: Li Nan <linan122@huawei.com> The type of timeout is unsigned long, but it is compared with 'LONG_MAX' in timeout_store(), which lead to value within (LONG_MAX, ULONG_MAX.]/HZ can't be set. Fix it by checking input value with ULONG_MAX. Signed-off-by: Li Nan <linan122@huawei.com> --- drivers/md/md-bitmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Comments
Hi, 在 2023/05/27 18:18, linan666@huaweicloud.com 写道: > From: Li Nan <linan122@huawei.com> > > The type of timeout is unsigned long, but it is compared with 'LONG_MAX' > in timeout_store(), which lead to value within (LONG_MAX, ULONG_MAX.]/HZ > can't be set. Fix it by checking input value with ULONG_MAX. > nak, because MAX_SCHEDULE_TIMEOUT is LONG_MAX, and LONG_MAX should be enough for real use case. Thanks, Kuai > Signed-off-by: Li Nan <linan122@huawei.com> > --- > drivers/md/md-bitmap.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c > index bc8d7565171d..5fd9cba65be8 100644 > --- a/drivers/md/md-bitmap.c > +++ b/drivers/md/md-bitmap.c > @@ -2460,7 +2460,7 @@ timeout_store(struct mddev *mddev, const char *buf, size_t len) > return rv; > > /* just to make sure we don't overflow... */ > - if (timeout >= LONG_MAX / HZ) > + if (timeout >= ULONG_MAX / HZ) > return -EINVAL; > > timeout = timeout * HZ / 10000; >
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index bc8d7565171d..5fd9cba65be8 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -2460,7 +2460,7 @@ timeout_store(struct mddev *mddev, const char *buf, size_t len) return rv; /* just to make sure we don't overflow... */ - if (timeout >= LONG_MAX / HZ) + if (timeout >= ULONG_MAX / HZ) return -EINVAL; timeout = timeout * HZ / 10000;