Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp1967695ioo; Mon, 23 May 2022 07:16:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybC8Q+nrmk3HN4QCaURF4uqsRu98f32CIPzZ+Cml+ijueAkHfYUwObAHM/GxNzp9lt2KbM X-Received: by 2002:a17:902:6b0b:b0:158:d1e7:3d0f with SMTP id o11-20020a1709026b0b00b00158d1e73d0fmr22396308plk.71.1653315378720; Mon, 23 May 2022 07:16:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653315378; cv=none; d=google.com; s=arc-20160816; b=M/HNnBg7glqd6v4FmVgQLQbG6aYWaArdSRFOehdZqwhGjcwLNCOFKASdfE9IpIrfQc PHOzAhKZJu47kBfbom4H4zkJJ7wYT4JOaO3KUF9+nXTxPtdEgsjrJ1ZmTVBMaYlnSVW+ tdZ3B/ZP3m3My+Sj3bkwwYqKDYhNji9RW7R+sov6v0+DOgjWyWQJFBtD8mDnSjDuSQSE m+L0mnFTyoE0Bjh1ePzBnCpTEZ2DYjnzCAA71ZJ/QvCQbxGQ/tUyW8HL+Usg5s2oyFjx q0DFipYL85nKVZImBrsgDK/oHcm5MNzMOxUL2m317Icw7brs54upBE5Z4RHWn/5twtuz q/mA== 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=TeTm3K7EF1EHFf4zmoe+1aSPiBLGVwE736RxR6JriQw=; b=mXIhn4phmeN0RDxyaywPK/0+25Ldka9pCEt1vLCzDT64hCXwridsGJEhMIaLVpPSJ+ 4rJyz6dwvgCDh8JfvqHCncIzGZrf4YwMSkdv/ZOa+gRYiA+twksXm8/8vnY7od9Mneu8 ftxF2T2nGDLFlk4zO7G/GNzxRUOektlbzB1BdzqJQ+nFs6YqzgH5u0EAnm948V1c2GqZ v/uq6qjdq0pzBHAeY/bUbuAVBT6rHrMpkiKUuAeLZF4a81S6eOcc6yxHqqXa3CqaspPs 2bYGM/YO5879KujQRyywO5TE8Nne3IfrlLm9v4tIn0ieLVKQNKc5GuYKqEieRcc4ZamB ayYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@toxicpanda-com.20210112.gappssmtp.com header.s=20210112 header.b=dUgXLYss; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id pc18-20020a17090b3b9200b001dff2cac583si17546382pjb.75.2022.05.23.07.16.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 07:16:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@toxicpanda-com.20210112.gappssmtp.com header.s=20210112 header.b=dUgXLYss; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 80AE9289AD; Mon, 23 May 2022 07:15:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236978AbiEWOPx (ORCPT + 99 others); Mon, 23 May 2022 10:15:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236947AbiEWOPw (ORCPT ); Mon, 23 May 2022 10:15:52 -0400 Received: from mail-qt1-x835.google.com (mail-qt1-x835.google.com [IPv6:2607:f8b0:4864:20::835]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56FF059946 for ; Mon, 23 May 2022 07:15:51 -0700 (PDT) Received: by mail-qt1-x835.google.com with SMTP id g3so12599584qtb.7 for ; Mon, 23 May 2022 07:15:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=TeTm3K7EF1EHFf4zmoe+1aSPiBLGVwE736RxR6JriQw=; b=dUgXLYssqjZOWLLmGZ0Y4NRp9EshPYtG+0fwuB/KWuaOLfXyG0etFLRwpPjzLGby9u OQoAmsd3vaBSwoXAu+BB0gKbAXMa/mJJqJNO2aNn9Z7Jv5IhKyIbzS806hyNENGwtWYS Dq0chKEovCxugRgG8xQBCDm4wNtyDrfH6FqFlfVNq7I7Jbqdt+34VIoglN/XLkMN8Vds eI766KmxRlTbhXjW5hoH0fdi9s10E7pSk5ISpsWrWfySDKpXnqgYcY4oOdxDsR6//zYh usPENfThWB9sGRfV4iB6gfwHrVfgOxn/C1PQEJqBya0H5C2IOYB82vaPEb/uw88Un+xK h6jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=TeTm3K7EF1EHFf4zmoe+1aSPiBLGVwE736RxR6JriQw=; b=RLuVEc73NbX1TXxGaSg1DmqXU71ESbGyJ4vXrMaBkoahbcauRjcJGmicKFMKKTmGhG CxaYSIgc/ZZYukU/eQjjP+EwiUC1GGRiDIj6/c1vdunYhTv8Esvhyc8qX6uSIkJvPSF2 6k6bQzn+0JAivfnQzwmLKAKhVil9kywgMeovapH9zQFHfXXB0U4KxG3C4R8q4SIaUmha ak8ETiLNqVERaRV5WHGE4vytxRoenzgI1PoChAIWfejnXcsLhVpnFFgD7CVgBWYO8TxI ME8jug1kPcZntDHprBt+kSW6G9PAUYV5iW8/MgRtJs23Rm4cXmdV65d1etGtrRj4XwRZ Glhw== X-Gm-Message-State: AOAM531FCznQ232ARobFMHgGqjqngApODG4amFCLCeDfukJa4MqvTi4y QGFeROX9lgKgA8D7XfcPO0lPXw== X-Received: by 2002:ac8:5915:0:b0:2f3:db7f:7ad8 with SMTP id 21-20020ac85915000000b002f3db7f7ad8mr16039086qty.77.1653315350326; Mon, 23 May 2022 07:15:50 -0700 (PDT) Received: from localhost (cpe-174-109-172-136.nc.res.rr.com. [174.109.172.136]) by smtp.gmail.com with ESMTPSA id w36-20020a05622a192400b002f39b99f69dsm4250366qtc.55.2022.05.23.07.15.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 07:15:49 -0700 (PDT) Date: Mon, 23 May 2022 10:15:48 -0400 From: Josef Bacik To: Yu Kuai Cc: axboe@kernel.dk, ming.lei@redhat.com, linux-block@vger.kernel.org, nbd@other.debian.org, linux-kernel@vger.kernel.org, yi.zhang@huawei.com Subject: Re: [PATCH -next v3 5/6] nbd: fix possible overflow on 'first_minor' in nbd_dev_add() Message-ID: References: <20220521073749.3146892-1-yukuai3@huawei.com> <20220521073749.3146892-6-yukuai3@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220521073749.3146892-6-yukuai3@huawei.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_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: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, May 21, 2022 at 03:37:48PM +0800, Yu Kuai wrote: > From: Zhang Wensheng > > 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. > > Fixes: b0d9111a2d53 ("nbd: use an idr to keep track of nbd devices") > Fixes: 940c264984fd ("nbd: fix possible overflow for 'first_minor' in nbd_dev_add()") > Signed-off-by: Zhang Wensheng > Signed-off-by: Yu Kuai Reviewed-by: Josef Bacik Thanks, Josef