Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1661904lqm; Fri, 3 May 2024 02:37:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVlAwpJ20jJo4G1HhK43n8AhAPsvT42kVTjHIo4zYJKAACP79az27byiYOwHolMvi5JvG3LkReo5Gc7FgNJXlTOpAWA/zM0B1CyzoMuNg== X-Google-Smtp-Source: AGHT+IEuqd2QG0II6DhUpRVzBqBr4hyeZ4UfuzvI0yY/sSSuNN1b0kjTvnpne8FvHhTEsqjV+BLQ X-Received: by 2002:a05:6808:394e:b0:3c7:fda:2043 with SMTP id en14-20020a056808394e00b003c70fda2043mr2322250oib.48.1714729068789; Fri, 03 May 2024 02:37:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714729068; cv=pass; d=google.com; s=arc-20160816; b=TbYS+GI7hUIY/tQabZ3TuCZiXNnJT+W8GjNzzF9FQiCQ8CEJNUErrPqSkGwWBwf+jf 264GHL6h+/sZYyDAVn0GOfqYnJ3/J6LCfI4OEweCup5ndHrHCO4oXSZVtAzQIZOjAZTe ch6IPOQ0ohzlxDf46HCVC2cjolQ66m3xu8kpmmEXw9DzO889YkulvfBtwJgpH8tVmfRy aASzhiTtIv7ez5F2ALh6TKUA81coKdUvGChq1rKYsTZl7efGru3XiVOZ7Lh6BI677/bi 5oQnf8PcuBhFbNlcle4I5gXEZfOum2/6BT0UoktvhToEaHQMwqHFmq71+EZSHbPTVlJI lXww== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=OylbgKETjfMcol8+SqhwJMA400Oe69bydBvVmcg1GRs=; fh=dROks0l/c2IxgxcB7POJUHZxYB5tjHvuJSIy/m0zd58=; b=Ylcs9VpgDBbNP28POJPi19/G5XgTxUNPaNWoOu4GPTGPO1V7ky/BCsdKhao+oQUB/Q A8MrAt7GyKeFvCHThH679fILi/QXHZFFWcOZc6LcIH4cNEOJSqp8iYQcUu1/rwJ70cwB nRLY74iiLHHpgjOhQF2lr5XWaomrnrdrZXXZMxTXcmgVVy2IiC/+854PdkAUlMzwkGVN PoBpxpj4I1PefW8bJ13wKKoNvOUJsg+o6/702AwNTfnJmuC3vMxA7h2xATFAmZbS2DYH AHhW2foT6BVu/GWHMOm6IbfQwYD1OO74kBW8j3ZWqofS6uD5JLSxbJk5LPnKfddrvyXW H3kg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bbvW7QrS; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-167471-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167471-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id dt2-20020a05620a478200b007927f5f65c3si854591qkb.736.2024.05.03.02.37.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 02:37:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-167471-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bbvW7QrS; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-167471-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167471-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 7FFDF1C2132A for ; Fri, 3 May 2024 09:37:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C5C0314F9D2; Fri, 3 May 2024 09:37:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bbvW7QrS" 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 DDB2E42078; Fri, 3 May 2024 09:37:36 +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=1714729057; cv=none; b=VUZVEGwxUNTWFQ5fxp/3uGigSObcOItlbo8iEkfwkgvuA5GJlwVBGQuvpMre4O5NiM6oxlX0Gk5NO01OLMZJF3Q61tHCScujcGwkk+XLdWsw/4XpcoJw/1iWF0KwPyr3krJjlqn0NlHFnZdbmCuTt0cAnAYw3Sv17IMxMWoENSw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714729057; c=relaxed/simple; bh=EY1m386ze5p5efmGezaRioeyr4xQQNVljq2tWo0fXlY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=BdiwK+fdeT2SjE/BFBGkMcVFdVuGXDRb/QZtVSapnT/9PDKZXB6ujR+Qv4MovHDxrFoJHI5I6IrSbyFEt4W1FPuYFt2aEc/DjKVrm65TKyRuPNPmzyltd4j6IWynZbqRjTOMtcJyhtCrJKAuJ1YvRFvxorx6W3IQG+OOwkMqgXg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bbvW7QrS; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96E47C116B1; Fri, 3 May 2024 09:37:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714729056; bh=EY1m386ze5p5efmGezaRioeyr4xQQNVljq2tWo0fXlY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bbvW7QrSUYaP7ll/nGqB8pNM3bYN8sV9MkSKBUePESxJ5x8/Vn3Y+PwKBz/X+x19y 2v9TnIRi6ivEtcarof8Y685DmLp3CJlXXRGXdMdiwLqyZr4o5yM2aLqSRa9Nj4+59K REDZ7vgd6608hUHudlZ/ac9mJUabY8+yduLtuNKbgWn2X9VYbzEplRFVv64ePQExSt 0AatHid8re8GR7Rofi9O+SJql98nf+mvKZwcX0rW10J6LFM7g+ZifZQ9PfKVL6TLCO KWOixJUGNN5Lgl6iDEJ3WHBgZ+Y7vSVu6PLRZ4olHsDGeO+Cysql0pUbhEl3HXE1mf 5crSWWJpt/jrQ== Date: Fri, 3 May 2024 11:37:25 +0200 From: Christian Brauner To: Kees Cook Cc: Al Viro , Jan Kara , linux-fsdevel@vger.kernel.org, Zack Rusin , Broadcom internal kernel review list , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , Andi Shyti , Lucas De Marchi , Matt Atwood , Matthew Auld , Nirmoy Das , Jonathan Cavitt , Will Deacon , Peter Zijlstra , Boqun Feng , Mark Rutland , Kent Overstreet , Masahiro Yamada , Nathan Chancellor , Nicolas Schier , Andrew Morton , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kbuild@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH 5/5] fs: Convert struct file::f_count to refcount_long_t Message-ID: <20240503-inventar-braut-c82e15e56a32@brauner> References: <20240502222252.work.690-kees@kernel.org> <20240502223341.1835070-5-keescook@chromium.org> <20240502224250.GM2118490@ZenIV> <202405021548.040579B1C@keescook> <20240502231228.GN2118490@ZenIV> <202405021620.C8115568@keescook> <20240502234152.GP2118490@ZenIV> <202405021708.267B02842@keescook> <20240503001445.GR2118490@ZenIV> <202405021736.574A688@keescook> 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 Content-Disposition: inline In-Reply-To: <202405021736.574A688@keescook> On Thu, May 02, 2024 at 05:41:23PM -0700, Kees Cook wrote: > On Fri, May 03, 2024 at 01:14:45AM +0100, Al Viro wrote: > > On Thu, May 02, 2024 at 05:10:18PM -0700, Kees Cook wrote: > > > > > But anyway, there needs to be a general "oops I hit 0"-aware form of > > > get_file(), and it seems like it should just be get_file() itself... > > > > ... which brings back the question of what's the sane damage mitigation > > for that. Adding arseloads of never-exercised failure exits is generally > > a bad idea - it's asking for bitrot and making the thing harder to review > > in future. > > Linus seems to prefer best-effort error recovery to sprinkling BUG()s > around. But if that's really the solution, then how about get_file() > switching to to use inc_not_zero and BUG on 0? Making get_file() return an error is not an option. For all current callers that's pointless churn for a condition that's not supposed to happen at all. Additionally, iirc *_inc_not_zero() variants are implemented with try_cmpxchg() which scales poorly under contention for a condition that's not supposed to happen.