Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp667586rwd; Thu, 25 May 2023 02:04:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6DDz1q0EVQ+vVi8Dc07ZoispRynWRGvqWq8OoK/3YsevZQQRDPZT54fEpcmP9V/haVdLmh X-Received: by 2002:a17:90b:4b0d:b0:252:b345:7953 with SMTP id lx13-20020a17090b4b0d00b00252b3457953mr847081pjb.24.1685005464925; Thu, 25 May 2023 02:04:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685005464; cv=none; d=google.com; s=arc-20160816; b=0wgKo/gXvNKUpU2QUV4FJ2j/BLTfxLA7ELmqoGiV6NfR05UeSNk3zbaH5e2dQX78Pt vbgoxZg5soqOaeUeRWhhCUvSJVyTff88SCw4NajLOqxNq5ekyW9HoyabJP/aNM8Ui0EW 37wMng7mtOfAYbXaEuQJTF7U0Vy1rYgOh5QISFh4ZPNBRWs3dR6UJiGctlwVCiVxo7WS 9GDNi78bDlbe+GhVsZFko9br78GosTQjwGxxDBlGy8rJA148k/WDb3fnZKiHh/Yu1LFu yHSwE5u1a/1WEtEs3TdNoDTIzYVE9nuRTA1a4QkHBfSR1g20kdv7fa4cbSnMtIxiaBci TvCQ== 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=K9sG0POcwk6ioMsTPXOQV3eSTLgEBbB2sxvA5LCbWcQ=; b=d+KjH1/EJ+5bdoVhlKqhZUocrLgChFmLo9S4oYPIMRjrl0RACghiBG3MfKab67dTj2 mRle+rmsP0iRtC72faunwh9czKNHf4jjNhEDIPZmNwO5rhNj76nC68RUJJBZbgOuvXJb ilECAkdrZtzQPVAh/YigB6tNjwdboTqXHCnxaK6+rYBP0PycHOlWJBjR9MldOS8K2X7o /RLiSSwqi65yr3TVO6abdyTjqwTpZEyz/TFtK/vNUDuPocjzDRtZ/7MCfhOLeEilwCoJ hmASyLjEs8xGu0u4NxgUDOK9Q3C8tDAfYG1hlY6cXKKfmazHNwvA26zg2aqU2+mP3uHB mqqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=fdt7VIxb; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t9-20020a17090abc4900b002536b553afdsi3237086pjv.98.2023.05.25.02.03.57; Thu, 25 May 2023 02:04:24 -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=@infradead.org header.s=bombadil.20210309 header.b=fdt7VIxb; 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 S240300AbjEYIzf (ORCPT + 99 others); Thu, 25 May 2023 04:55:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240294AbjEYIze (ORCPT ); Thu, 25 May 2023 04:55:34 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 550FB1B0; Thu, 25 May 2023 01:55:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=K9sG0POcwk6ioMsTPXOQV3eSTLgEBbB2sxvA5LCbWcQ=; b=fdt7VIxbv3TkQRWM91jZwpprV9 ZJ6UeaeNYURZHcPVWl9lz509obvVWnmwXb94DjsnzdOTi1W5NRxUZgm2G3iLTvanTBrrRKA2uUBmW R6Le1Lg0MiA0ZT1X3YX7aEMYsV8Hmk91GojRCW2d3WSGcp15cT8xeI+PBwhD71nTJXrz8Yl75BfiX wDqDKKIlWysLrK0rRjcX0ZddExqgE/5YrnkwxWDzH2gxFiPnx8D0zSdtvNZk/rBZJ+Q+00ABKMECF gp4O0zcjlabod1RTaTrITZTNx6itpSK+cG5turE8dUFqrt8KB4fkxbhUY1mYJ1gyVxHcskP5cHHud qsE4p1SA==; Received: from hch by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1q26kq-00G3tZ-2y; Thu, 25 May 2023 08:55:28 +0000 Date: Thu, 25 May 2023 01:55:28 -0700 From: Christoph Hellwig To: Zhong Jinghua Cc: axboe@kernel.dk, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, zhongjinghua@huawei.com, yi.zhang@huawei.com, yukuai3@huawei.com, chengzhihao1@huawei.com, yangerkun@huawei.com Subject: Re: [PATCH -next] block: Fix the partition start may overflow in add_partition() Message-ID: References: <20230522070615.1485014-1-zhongjinghua@huaweicloud.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230522070615.1485014-1-zhongjinghua@huaweicloud.com> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 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?