Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp1120176lqb; Thu, 30 May 2024 00:14:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXZPEhdehhRzqHBGnUxcdMWUlkjCnKHgef4eILzIxEDVWQiKjSTL+qJfKc7P/bPXKvJM9536NbvTmTrfsK3pYJUQCmiaMGm+imQZVE67Q== X-Google-Smtp-Source: AGHT+IFPvwdpqDpxjgi1XjVtcIxTlN15D4j5233ObD+DpcKYYmftCqdydmvXnsz6x4arFoq29u+Y X-Received: by 2002:a05:6870:17a9:b0:24f:c5a6:2985 with SMTP id 586e51a60fabf-25060b00833mr1634446fac.5.1717053258326; Thu, 30 May 2024 00:14:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717053258; cv=pass; d=google.com; s=arc-20160816; b=aia8rukhxuntvyVliZuICkmlojdXQ3hV155kVusg70vFY4TE3v8V1NuarqGtPhMXXa vitVu4UToKemTsuYYPLm766gmSCIRWx0jWAy5BbN7ufwTLeMSxB2AqGbOyBUxoyYLFej XW2vMR/dJ66Z9qpAJnz1FZYGma/gsDqI4dQyM9qAmRRbKvuhY9Y77r3n/NbXKKmi/Iig I5kv6EDOV4mwsv5JMDJnVJaV9IgdfLAeb95JlSS3LRhHLCQBcFQlGCWq6f9EJngET2CS +50T7HET3zgRo+RERt10k9uHKPJY2fkfCwtitc48YdQF0GDWbYiaHvGMH9x4UzhXbiL9 ngEg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=K5EnLnqzbZamD7fUuUVtA3PKgzr9BvthsQfGBKD14p4=; fh=QcLE6uUnOB3T4+Sp4ieaLCr0CupJ3Rz3AcJtMf6ED5w=; b=pL2/H4GiE7htZaZwtS58seV0y8v3RQ2VPXZJScAgprRa8sWLHQk8Z2Z8aBf+pADJSt JTmCMG73VqOUQ1jVuaKNvyJ7xGs9B6bBcizfdjBLoVIBjw9GcjntlINLyLOwErnyzPtu HH0ZUJE2Gca/YuVsACVlX2y1U45RUDZK9y62dfqe7K9piBCE3lXTQnxGvr8UCccABLzM tLvlsUWEhGJCW/MzcErnBGC1AiJkvIY7k/RhKD0UyKZOoU7hlOPipX4T852eYY2iAb3u KTSrY8ZW9shgztZwTXmV9b/2kEw6yZjKsaiuMBNtvL0d95Jezu/rhjZ7sGLai7309d02 qZVw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pTaCa7W0; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-194999-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194999-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 41be03b00d2f7-6bd02f9005csi1947078a12.690.2024.05.30.00.14.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 00:14:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-194999-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pTaCa7W0; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-194999-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194999-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id AC278B242DB for ; Thu, 30 May 2024 07:13:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 780464D8BD; Thu, 30 May 2024 07:13:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pTaCa7W0" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D5504D8B2; Thu, 30 May 2024 07:13:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717053181; cv=none; b=PMRu0X7Eb2F2ZNMNkMJpuXp+6np1vnBZXUQBRdYf2kLM4lPBWEFSBW18Ofr3m3yXb8ZkDcG1NWiTKymyd64BcR4Lc4+feMcVCfsXTknMaglEn2xpt7t7OkMjm+8MOfPYeAdFyy8yuGzDV5RF8hwwSru4NNQc/hKRrBcN3FePLBg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717053181; c=relaxed/simple; bh=8ULP4kKmkBkB8OhdDy2ZgeEvGKgKKr0EOtx31F1eVaM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pLWDBIkYekwTSd6tvKkli20jonLqbo1TKS9AnzhJVmhpxQQtKn0VU44lb92nNdKegAwbjeW1u/lwBLztf4Rc8tadysrYS2ZNRkCs0V/Uu0AIO1escpTW9WTCNEJIJIlKMP3rhZNYD3POLMAANP2mu5pJmHcxpF6tjnVrFqMgNz8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pTaCa7W0; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8915AC2BBFC; Thu, 30 May 2024 07:12:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717053181; bh=8ULP4kKmkBkB8OhdDy2ZgeEvGKgKKr0EOtx31F1eVaM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pTaCa7W00BtA8JKrCNXNmV8d62duYklrrNYmxTy76yVZaPce7bAeoHXBselgNOUpy Xu0seF4pq4Fy9bPD0FZ1cueLOHsGREEKKxwpMhB+1pfoW7K+u0Z3jLme6JjLkdVY0i g7iTq63PGO/LRmtPUW+U+qFaOSpHmlNqvLXFbZk0E++ldOvaF1FAmFsQrz7fcJP8ZP oOHCqYu+Fz9qBw8BLQJni58bhwM4796Ca5aLHMIhYxaKvTUw9hpChPx9LWSjmm0j9W y39FBcIsnxZxtXtA1eQlwZ028aNJi7vWMVkQ0NbkcHfd/AytDqyGil1oZUjyxuq8c2 W1mE0rmZasYZw== From: Christian Brauner To: Yuntao Wang Cc: Christian Brauner , Alexander Viro , Jan Kara , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH] fs/file: fix the check in find_next_fd() Date: Thu, 30 May 2024 09:12:52 +0200 Message-ID: <20240530-gewichen-herzhaft-afdc69132239@brauner> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240529160656.209352-1-yuntao.wang@linux.dev> References: <20240529160656.209352-1-yuntao.wang@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Developer-Signature: v=1; a=openpgp-sha256; l=1347; i=brauner@kernel.org; h=from:subject:message-id; bh=8ULP4kKmkBkB8OhdDy2ZgeEvGKgKKr0EOtx31F1eVaM=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRFqH05ZvP2WSvLzX9tZ0sWBFYcXlBflqvEwWvWfEcwV lRv9YK0jlIWBjEuBlkxRRaHdpNwueU8FZuNMjVg5rAygQxh4OIUgIm0CTAyXP2V03+aSeerfpVg /T5r24Lfr3sdUvkt+XYc2fJNynDVWYZ/+qtfxDsqTXv/9vyvp7rbW9d2vl8YmfzgAx+zluGafvP 3DAA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Content-Transfer-Encoding: 8bit On Thu, 30 May 2024 00:06:56 +0800, Yuntao Wang wrote: > The maximum possible return value of find_next_zero_bit(fdt->full_fds_bits, > maxbit, bitbit) is maxbit. This return value, multiplied by BITS_PER_LONG, > gives the value of bitbit, which can never be greater than maxfd, it can > only be equal to maxfd at most, so the following check 'if (bitbit > maxfd)' > will never be true. > > Moreover, when bitbit equals maxfd, it indicates that there are no unused > fds, and the function can directly return. > > [...] Comment added as that's really useful in general. --- Applied to the vfs.fixes branch of the vfs/vfs.git tree. Patches in the vfs.fixes branch should appear in linux-next soon. Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it. It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated. Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch. tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git branch: vfs.fixes [1/1] fs/file: fix the check in find_next_fd() https://git.kernel.org/vfs/vfs/c/96998332ac4d