Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1060121pxb; Fri, 1 Apr 2022 03:36:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyk4dWFeJXUS2MHoFto7sxDQjjmwCTNOc5Eryaq4fjNy9IqvMNueBfrvwZfvn7nVN6WL8qT X-Received: by 2002:a17:902:6a8b:b0:156:612e:190e with SMTP id n11-20020a1709026a8b00b00156612e190emr5031773plk.132.1648809370988; Fri, 01 Apr 2022 03:36:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648809370; cv=none; d=google.com; s=arc-20160816; b=zXAvtqUlZgx2UFrQzJUjChATZUUODkv3tPK/1tfCsHcFuu/TNPcnL7cjjWc/1SixoD h5GHhlsGsPgEM3/U4cePQi5eDJyWYib13T83tY7J5rmDD+6RE9tNxFu7bGK9qvQygbCC clv79Xtmyh3ZPwKT1dlituOY/vjDUZo5vUvXoQ/J0HTktpEACVbAN7gZCrP/lBbUjphS 7z76a1/tYiZPFhe4oBeWGbDrMmjDtlmTy3kQwd5CsfDudXaFRR19SiK2I0VMng4TBDS/ fL4e/Cfkbp7eKUIc2JBjkEV1jUKhqfisbR6kxmEJlzVdq8THlBhAiokiCyjIfRr+UGnM BEmg== 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:date :message-id:subject:references:in-reply-to:cc:to:from:dkim-signature; bh=l8CekeoQZXHX4U3TiS2vpp4O2YuTCmdU/BDSBQosw7Q=; b=rYuVpaAoWkupJ4kpiySjPt3a8MED/1pUcaN+burjckgdBn1WlPhhXWaMYTaNA7uMRe /16jIOxCDvXtLSmUXmUM/YxKv3Z6SUomIkZGfm9nru7goEKZDMpwORIIL1p5Y7mmcRU+ r5hcoGJ+r9glE+VDFusoxH90/KPZneEHw6s0beMnjEMBY7zWYzeU8MDCPoFKWKHKzj+r u7OiR9i+NXUlpaxm3kBETaAHlCQSgnIjfUZJZjtpgkV0yINC6oI3CgUEQbeV0Va37l5i axsH1Ca7F0mWL9O1epipXl/i5bcVWwl0vOUQmX4m62aD0x6bwzOjy8+l8xdHojb7r7Vq LJiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20210112.gappssmtp.com header.s=20210112 header.b=2t3SM0cZ; 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 b198-20020a6334cf000000b003816043f011si2105829pga.518.2022.04.01.03.35.57; Fri, 01 Apr 2022 03:36:10 -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=@kernel-dk.20210112.gappssmtp.com header.s=20210112 header.b=2t3SM0cZ; 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 S237569AbiCaOcf (ORCPT + 99 others); Thu, 31 Mar 2022 10:32:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237562AbiCaOcd (ORCPT ); Thu, 31 Mar 2022 10:32:33 -0400 Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4392B1D67D9 for ; Thu, 31 Mar 2022 07:30:46 -0700 (PDT) Received: by mail-il1-x12d.google.com with SMTP id x9so16858116ilc.3 for ; Thu, 31 Mar 2022 07:30:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20210112.gappssmtp.com; s=20210112; h=from:to:cc:in-reply-to:references:subject:message-id:date :mime-version:content-transfer-encoding; bh=l8CekeoQZXHX4U3TiS2vpp4O2YuTCmdU/BDSBQosw7Q=; b=2t3SM0cZXUR72lsXD7aWv01f4VUP1+TsCWH1VXhR9gW8eeqvvAYm8IPed6tPPC/+bT /wf9r2P3V48ygYra/UM1VT50ENC51HGaz5CRa65IhBEmNu5LJEGBB7CqL0dNZJ++bP5l ZuFHQmFFFJgh/P90XI1k0WCdnaV/65iQKBTWubWDoonZK3zxaSLZQXZus5lAGOBhywkZ TrV5h5uml6+9t1iFBJ5FnSDBddgz0muYcbWXUBl6LXRAAfpdksB4eK30BIE/mJJM1ZHC rmY/8/X0BmT2ei/CA6CADJPhXxCAdFQCskc1lcm8c4RtAGPxzECZY8oM8CNOmAkuRemv /OtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:in-reply-to:references:subject :message-id:date:mime-version:content-transfer-encoding; bh=l8CekeoQZXHX4U3TiS2vpp4O2YuTCmdU/BDSBQosw7Q=; b=IWWZfV1vqBuOCnIZrdPcyHoq2vYKCYt7eOegnDD8Ycn3WG9WIAqKS/8O4kOh8gQUt/ 1CK9qFdVPOfN57ZLWilYSmOw1ldvV+Bjz+TPD/QE6cElBVqMYVmd4ZfnqHCpoc2nTuC9 PGi0LWcGktWrXpqazRPV+aU26HG4Zpqwpn26/8HC6sEL3+YTqEXzwbjAvCpI2uGfC54P neOqNcrcQTiwOoIc9xr57AFgLF68iDd5ejpRfApcELZAl49IqJYV+47aUV1YLyZ+sAcG DOUR6dtwPt3w/n5AykMzOr69mCPmcxQNk44y4LUmKnOLMArdMBIFq9if3O2YCV7zwdK2 EjMg== X-Gm-Message-State: AOAM533yBI5Gx0SjZ9hPXoqaTaoA1Txhme5Qyq3zhUW9IghGOdkez0VM fdspjOtdoAud4USS8lz/lCH/AQ== X-Received: by 2002:a05:6e02:1c0a:b0:2c7:75de:d84 with SMTP id l10-20020a056e021c0a00b002c775de0d84mr13381733ilh.186.1648737045567; Thu, 31 Mar 2022 07:30:45 -0700 (PDT) Received: from [127.0.1.1] ([207.135.234.126]) by smtp.gmail.com with ESMTPSA id i3-20020a056602134300b0064620a85b6dsm13883109iov.12.2022.03.31.07.30.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Mar 2022 07:30:44 -0700 (PDT) From: Jens Axboe To: josef@toxicpanda.com, Zhang Wensheng Cc: linux-block@vger.kernel.org, nbd@other.debian.org, linux-kernel@vger.kernel.org, yukuai3@huawei.com In-Reply-To: <20220310093224.4002895-1-zhangwensheng5@huawei.com> References: <20220310093224.4002895-1-zhangwensheng5@huawei.com> Subject: Re: [PATCH -next] nbd: fix possible overflow on 'first_minor' in nbd_dev_add() Message-Id: <164873704446.46490.778795283218997371.b4-ty@kernel.dk> Date: Thu, 31 Mar 2022 08:30:44 -0600 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,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 On Thu, 10 Mar 2022 17:32:24 +0800, Zhang Wensheng wrote: > When 'index' is a big numbers, it may become negative which forced > to 'int'. then 'index << part_shift' might overflow to a positive > value that is not greater than '0xfffff', then sysfs might complains > about duplicate creation. Because of this, move the 'index' judgment > to the front will fix it and be better. > > > [...] Applied, thanks! [1/1] nbd: fix possible overflow on 'first_minor' in nbd_dev_add() commit: 6d35d04a9e18990040e87d2bbf72689252669d54 Best regards, -- Jens Axboe