Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp534362pxb; Thu, 31 Mar 2022 10:58:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+z+yXD71ro/KujwufQE+bpuVtAQ+tWRiO1cCuohpeAelc+5LT7nqkgtvDy+P/gdvSqOSZ X-Received: by 2002:a17:906:26da:b0:6d6:da2e:d338 with SMTP id u26-20020a17090626da00b006d6da2ed338mr6041293ejc.700.1648749493102; Thu, 31 Mar 2022 10:58:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648749493; cv=none; d=google.com; s=arc-20160816; b=EYwCFb0b1ljhIXzL03wE01MswSeM83OGsQnNE8DdvACxw4tUYI9er/0bOkRzV1fpIu 0WC+YBs1/9zdZ9dQij0JXJzA1kIwwWJyIcOM1NXTI5k36AkWwH/Wm90MVzx/p8Mo7/Ge 0oXsMNquR302f1VogJop5ITMI6sQ3xkswc5SqHr9JZ/4+en8uWlkk0Il00w5uMLkTEnr nH7jdmy505bkhmioaDqm7H1wKWvRXFsJ3/q7KcgOOfv5xtwi/YCWS94/UAlDdwFJvXwm 68AYiKGwK44ChibQcs5WttjBliVaUlVjnNO5INknceLyWtrwCh2lnE0arXGm78rvSFaH P3Dg== 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=RUo5kwiJz1bXcAqbqhS7EP1tVYXGo0oDgLG0Vt1y+Yw=; b=fk57ncAT0npmjQpRlKNPf5EnmriHZwDKSAsiJTPIeTDBmGh0n3N+2qVH5/9r4mJKlf htAy1IHfCqa1hW9ZD/OwJmMTjVM3Wm4KrjhJfBjo/ALssumFZQ2H179Dn9WMMCpdxPJU U43MS8MUvKvAe4IxW3wcfcKwcMdOBzAEnRPm4dXSyrA8vE1PQCsfpV/uy2v/ixa6gz5N lyPHNwLIEwzs8p1n+f0RKsKcBF9Xxwm07uGVfVP95cb87cP/4Pgrl1gltK13xG3NoahB UCXogIeYxFZGvzCOrbRFrVFaNTYVh6erZ8BDy+P3z0WodsevmUcsrSBaQ1meoK5MEZ1J EeQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@toxicpanda-com.20210112.gappssmtp.com header.s=20210112 header.b=piasVfJJ; 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 gf4-20020a170906e20400b006e49b0c9b4csi182213ejb.76.2022.03.31.10.57.44; Thu, 31 Mar 2022 10:58:12 -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=@toxicpanda-com.20210112.gappssmtp.com header.s=20210112 header.b=piasVfJJ; 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 S237304AbiCaOJ2 (ORCPT + 99 others); Thu, 31 Mar 2022 10:09:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237291AbiCaOJ0 (ORCPT ); Thu, 31 Mar 2022 10:09:26 -0400 Received: from mail-qt1-x82b.google.com (mail-qt1-x82b.google.com [IPv6:2607:f8b0:4864:20::82b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3FEF2128C2 for ; Thu, 31 Mar 2022 07:07:38 -0700 (PDT) Received: by mail-qt1-x82b.google.com with SMTP id b18so21442223qtk.13 for ; Thu, 31 Mar 2022 07:07:38 -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=RUo5kwiJz1bXcAqbqhS7EP1tVYXGo0oDgLG0Vt1y+Yw=; b=piasVfJJs0bqvNJ4PSZRAVyjHcXIX+f20OEUWIVbZrN66k1VJSR4dx7gqLu3aayp7Q 270fgEB5o1cj86OnfA4+P3m/Lfik2iBL74oA9pmDfPB358bkLsO6KS1/yi5MrnrxLpqP 2/PmwBHugQKp8Jg+9/HpgKLnulHPVq56TNbJAUJz66lV6aXiI8v31Ors3hXoU1tLa7Vr +vvKGo31JwJiNS8dfwtiBJbipCXMugjSYuBMb3blJcywsgXzbvPlmuO1/KMFZoshZgzN o43bkTuDeIplUupMKNaxvm2swmnVZJnb/pd27kwSPyjYbWW4hlXTR5xvlW+lRYXKQEJn /9dg== 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=RUo5kwiJz1bXcAqbqhS7EP1tVYXGo0oDgLG0Vt1y+Yw=; b=YhHMf909iHpObTmI4fTZlFMIv+4piuvTAYFqVRFpwSPE6t1eEAObd6Yc6WWGi4Jc3a YTMDrNJQu56ue4LOH3wT2R0hmWsR+BBuDTNVFDF3bl2re/vwvdlpFLyUhI95xaijhzpA LY8py21i0IUlqwIYg9bkKpyGfjzB5pzPLDmp7FD7ibOSvpGNqIDKzFFkai00UGsD6dtQ Gq9up2piFqGlgmWeO2n81FMuwW5bDSWwmelVn/B5W+5Wi0l8BfdiBNJfsVQ7+K8io6zI pEf2qom7pus8gzBZMaf5y1EXcNfw9y0SoK65S39VDpPau/WYQ8otXY7JDEx4c/RQ7NXH 6BeA== X-Gm-Message-State: AOAM533aG8j96DBIz7VQtWlublR0Q/TOHectfRHgmCK/oGYEFAIEASjG AEWYywu8iHMPZkY/0sS+FzxhuA== X-Received: by 2002:ac8:5fd2:0:b0:2e1:b346:7505 with SMTP id k18-20020ac85fd2000000b002e1b3467505mr4464103qta.94.1648735657640; Thu, 31 Mar 2022 07:07:37 -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 8-20020ac85948000000b002e1cd3fa142sm20349064qtz.92.2022.03.31.07.07.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Mar 2022 07:07:36 -0700 (PDT) Date: Thu, 31 Mar 2022 10:07:35 -0400 From: Josef Bacik To: Zhang Wensheng Cc: axboe@kernel.dk, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, nbd@other.debian.org, yukuai3@huawei.com Subject: Re: [PATCH -next] nbd: fix possible overflow on 'first_minor' in nbd_dev_add() Message-ID: References: <20220310093224.4002895-1-zhangwensheng5@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220310093224.4002895-1-zhangwensheng5@huawei.com> 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_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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, Mar 10, 2022 at 05:32:24PM +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. > > 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 Reviewed-by: Josef Bacik Thanks, Josef