Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1493505lqm; Thu, 2 May 2024 17:43:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXfrV5xwCy+mHsYe5K4Cc+Cb41koa46IdRw4XlODzqfoqfDFClxAMHvbZMgHxB1xaCAlrRhhdRn4i3NCy896PeAPA8V6zAnjxNXPDs+3A== X-Google-Smtp-Source: AGHT+IGa96j0+hGes9WTfRgeGQ20DNE1wi9H5FuIstD/ZbDrn86evOF3VoFC3EBc5lNLYf64f68T X-Received: by 2002:a05:6871:8086:b0:23c:58fe:5d90 with SMTP id sl6-20020a056871808600b0023c58fe5d90mr1815788oab.14.1714697007327; Thu, 02 May 2024 17:43:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714697007; cv=pass; d=google.com; s=arc-20160816; b=GPyUi6Nm6lJ1qn0cYC6yDpMBQqKZnTJ4J2hnNXepj7sI8LIML1gaFC/9z7UYxKqRIX y4UCrdMLJNrWgqN97z98GpB2zEcvk309o3RtYykO8sZ/OIIGfNNoECuwlGKDPJtYTjxH RJVa5LG50p394wnhLUuGXsYV2S1Ed1ZTIXvL8cHw+UmNcZdlYe1jRrwfEUFaNhCxBDbl 88L7enYPTugsmrx19zKs74FaNyZO0r6mkMudEv25Cbk37jNh18AkfJllrnowkhFjXdmO T5R51bkHfqpZXlPVGx8HIch/k46Nzjfc8eY4k7iUQL5uiZ/0Ym+q2VGWX/U9Jo06bmrx /YUw== 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=Ag+GJVh/sQYDPGeOkIngGB4bIRPX939JLId/QM0OSvU=; fh=NRVYZfviTzx6BaybaDetYw88H8ADNlo6omULLdH8USs=; b=uRQY7jp4JlL1KiXSu7mocbVjjWYOgWXQ8pPq15dRg4rlyXhHgsbTjEkNqiHRRFxal0 7f1SVGJ4KFuNVUhpn7d6bF+tbnIlr1yofiQXSArTgUlvaJ5eciUmtnJGOiAW/qHiqfuy oxtXJLpkcpHi0eFT+Cxy2MylLGTg0Rb0gEL3kb86Kzv3qHuwTVf3m6B5vb0cQxza/uEC rlxnzP32FJbbleteOLptKIPBpVibRhgRFF23584E+EYBWp06Vc0VEzfe++1lfJsq4YO+ X32n4VcqauMzP1JTMh98KzuMjuDf6AmjF0wcPzYpOi5JnKAi7Mlb8X/DUOzK2Fta+TFG AedA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="E62hMc/S"; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-167114-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167114-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id i27-20020a63541b000000b0060f19c72b33si1839255pgb.197.2024.05.02.17.43.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 17:43:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-167114-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=@chromium.org header.s=google header.b="E62hMc/S"; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-167114-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167114-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.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 B08A9B229EA for ; Fri, 3 May 2024 00:41:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 554A3DDB8; Fri, 3 May 2024 00:41:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="E62hMc/S" Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3016B8F47 for ; Fri, 3 May 2024 00:41:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714696887; cv=none; b=WtQRFdyX5bR68pvx3DPZRwLM0TKIlPGKlP3zXYziyRzfaPj51NTfUIjJP6a4entoov+kC+yJ77engun2HXwFXiWgCZTDMojoq8tTNQgi5lPT04Froi7x/tr9eI/da8I/X1MQDtvjgHryJpAgrwLBxhZ8kFh/CQ7c0hS6vZHLNes= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714696887; c=relaxed/simple; bh=pbSDQnfcM9BD+einzGGOUVd3T1E36CfJlU1tKpjCybU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=GaTf9qZfHkzqwW3cuLTG70+UbhNMxbIcx0BBKBaayF0oUJ/tfMYE6y4jSADUenEjVtZRdZWZJfsHxzJ0tubmoKWWAhtvhvBd/TIItY/Dt05Hd+GD/a7fkl9Z/pdWdPI5UhwAOoz8hgdz1IPBPa/0V0XHeXv4pZMJy/0kjkwwHJw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=E62hMc/S; arc=none smtp.client-ip=209.85.214.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-1ed41eb3382so277985ad.0 for ; Thu, 02 May 2024 17:41:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714696885; x=1715301685; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Ag+GJVh/sQYDPGeOkIngGB4bIRPX939JLId/QM0OSvU=; b=E62hMc/SHto+4x+x0c/d1GGFMi2XNcRny4gL6X4LtWZe5jdWibBTZzsCHv45Year5g mGraw44ODS3o1xSHCSKlcpIYVrRUtr194f+Cx9fXOw3sCFMxLRoJ/mmcVveRbRS0KEzp 0ps9cvxit1qKIDf7kSeohas7Hi8DlsCrb894Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714696885; x=1715301685; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Ag+GJVh/sQYDPGeOkIngGB4bIRPX939JLId/QM0OSvU=; b=rW4WLBxARY6fc1MwgcUeyRAz+JKvkalauFs2pB3IDKOR5AUvcZ6A3veOouj15sp37A sgvZ2eZWoEJ8nC9ISYaOaaFjHMk6FK7i5f0hR5NiHZpYA0PShK8rv1yMO7+zUD1ShKS7 L4t/TbYofGAem7TizyvOJO2Nuexg8Uc9atrBqXQQJQDQwS6u8K71ujxajTikl+QWXv63 z4GAbqXqcF+UxKsPql7/ZMI5tCld653dP6u3Alluy6N0hO4UGpvdq4BTGTJBMV2aNTu7 KoW25RUBJ4j0rUuw72aAgIOTDGVHR8xMX6idyoASJA083smYWCtyBLITuC5CIEKdlaQr GHDA== X-Forwarded-Encrypted: i=1; AJvYcCVb2fgSuSz3c2cT+Jn51Pkd1wr/P4WgIPrcRBUjjJR8TcebNsK/qoDeZD22rJaJqFeoxbMI6USuX37GQwh/gMmKnLB8bzmbWgUtNoaR X-Gm-Message-State: AOJu0YxyPl53JpXE4aKnwIxhK2JDi83XdPCD5M0AFtyorIk4GZRU2lst VwgLe/utYZNtTKeDYEr3gOOuve/TAQ2JrH8bbs9t3cmGG3wynzMoQKn5K/K0mg== X-Received: by 2002:a17:902:f648:b0:1e4:19e3:56cb with SMTP id m8-20020a170902f64800b001e419e356cbmr1772102plg.12.1714696885501; Thu, 02 May 2024 17:41:25 -0700 (PDT) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id f2-20020a170902ce8200b001ecf865a019sm1958663plg.224.2024.05.02.17.41.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 17:41:25 -0700 (PDT) Date: Thu, 2 May 2024 17:41:23 -0700 From: Kees Cook To: Al Viro Cc: Christian Brauner , 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: <202405021736.574A688@keescook> 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> 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=us-ascii Content-Disposition: inline In-Reply-To: <20240503001445.GR2118490@ZenIV> 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? -- Kees Cook