Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp977784rwd; Thu, 25 May 2023 06:38:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7mIJwWuwFkzNN33LcaITHZ/8RGXvYeY+bGhaK7yBA88Dpq9KRePLky1kPGZfLYJgN5jjgm X-Received: by 2002:a17:902:e80d:b0:1ac:482e:ed4d with SMTP id u13-20020a170902e80d00b001ac482eed4dmr1963327plg.18.1685021930086; Thu, 25 May 2023 06:38:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685021930; cv=none; d=google.com; s=arc-20160816; b=a6m6ncBdTxMZYsLSA0d08DasIsWruwTsoCVBKFtlr3UOQEVVoy0QkAKoCfD2ZB967R OroufNXTYCTP8U7gd9zIxcWoownqYWuvIDcg9UXMBp4hkBG3hOhePDGNj4D9cp/mrUU2 qIndwLGpSeN8knq01OLbx4TzTHGJg3tZUO++XxM9S9iNg5at5EgFu5JOuh6iqOeaMHkE QJGoPy7eV2z5qseT0/pqN7UMn3EW3ZclT5YUov/Ha65P/fiN4nNk7AT0K3+mQaIwlw6g O/c0bCQf0d5IFdjftmz30A7A44HvviBPTFMVxSMm0DmBX5Pwngzpf3x9XGqT+GAjGCy1 tXDw== 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:subject:user-agent:mime-version:date:message-id; bh=4m7wOneZ9ppqpvSpow97YMGa9P1U1fBB86/aUJsx1+E=; b=0dyRMhNmwZyxNRbim+MaBGW745DAKAiVNx0fPaC8u+94TceSPlYTbGlQ5k6LuWDZoq vDkw5BCHQpSJ0LgbTGXv3xQ+Fe/fUwLQhgtmBFlUsDuz5rZ84QyHtG3UPDydrkz5L3+Z oQcDbcvs/1/VWLcJ/jd8Qxh/z27dMVUqbZYqqLV+LR/sJ17M5qeo/i9YawuIi5/149OP 3/M3MBWWn9R3JkMLBt5aXHOpSzZcA/yI07zDtTCy4VUZQN4xk5FQo/CfZE5xsk60wuE0 jSqaZAue3DFcfngPjFVLcBHC9alIIrjcwFh3DZZEWyhSDnBdjxrCOnTIGq4AE8LUuUmo zoBA== 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m16-20020a170902db1000b001a1f70cc7dbsi1544611plx.562.2023.05.25.06.38.37; Thu, 25 May 2023 06:38:50 -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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241261AbjEYNU0 (ORCPT + 99 others); Thu, 25 May 2023 09:20:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241251AbjEYNUY (ORCPT ); Thu, 25 May 2023 09:20:24 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9110A135; Thu, 25 May 2023 06:20:23 -0700 (PDT) Received: from kwepemm600002.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4QRpZV4l3NzTkdS; Thu, 25 May 2023 21:20:18 +0800 (CST) Received: from [10.174.178.159] (10.174.178.159) by kwepemm600002.china.huawei.com (7.193.23.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Thu, 25 May 2023 21:20:19 +0800 Message-ID: <9e3302ac-7e1e-0925-3da1-7c9070c51a3c@huawei.com> Date: Thu, 25 May 2023 21:20:07 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: [PATCH -next] block: Fix the partition start may overflow in add_partition() To: Christoph Hellwig , Zhong Jinghua CC: , , , , , , References: <20230522070615.1485014-1-zhongjinghua@huaweicloud.com> From: zhongjinghua In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.178.159] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemm600002.china.huawei.com (7.193.23.29) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,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: X-Mailing-List: linux-kernel@vger.kernel.org 在 2023/5/25 16:55, Christoph Hellwig 写道: > On Mon, May 22, 2023 at 03:06:15PM +0800, Zhong Jinghua wrote: >> + if (p.start < 0 || p.length <= 0 || p.start + p.length < 0) >> + return -EINVAL; >> + >> start = p.start >> SECTOR_SHIFT; >> length = p.length >> SECTOR_SHIFT; >> >> + /* length may be equal to 0 after right shift */ >> + if (!length || start + length > get_capacity(bdev->bd_disk)) >> + return -EINVAL; > While we're at it, shouldn't these be switched to use > check_add_overflow? p.start + p.length < 0 can use  check_add_overflow instead.