Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1531104lqm; Thu, 2 May 2024 19:48:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXkK9vo2Bw7PCfQIfbLmQeUH/MCoVjlX4vPDJ/JK7jgXzUNho/4EHI2/jUFlwIuYV2x1au5mWPLUqqCzsSgZsNDIzeYQwdkvMrSAlq4DA== X-Google-Smtp-Source: AGHT+IHhPSVfZacB+S+DJwgBMHnmosWn5Yd6d7avnDBj+CyuneW6acWCjzuxjnTciYX8LbTfaxep X-Received: by 2002:a05:6a20:1019:b0:1ad:7f1e:eac9 with SMTP id gs25-20020a056a20101900b001ad7f1eeac9mr5405472pzc.30.1714704506751; Thu, 02 May 2024 19:48:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714704506; cv=pass; d=google.com; s=arc-20160816; b=BGLagfojWGnG6pTrrF4RNlBkkwr0tbIXzJ2W3KHPRnKqawhwph3VpB1aUCflvSftZx dGR8F514x1haf5hb+Kk80x1qar4PBsw316khJkLJhUbbdR+79eo5MWwqRLZ7RRy9eyVB vdx6kCbnc7mZn5dl3GNRFFMm2143UfjlshKJJIkhKAGpCwXEc5Lmm4GNBTCyqyALpUGv vGtd4y+g+pGukJnZrKrlUhv9O8dHFKA7TBFkIzMgH/1PYYPSfgdQ80Qdwm59KUjAYDPF sOYfcyrxvdTSZAcO5o4rPH7AP734Z/0iahpjLRu/iqOFjswHTHypCBNf3dLlVmlZkury kbRg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender: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=O+ovtRI+qjFoRKgW6PbWKtfCDqZHsyNloCpeAE5jAfE=; fh=4ju/sbQ98gwaxGjZBNIZUzZfMrxGD5BSlxjcUF57YM4=; b=dV2FS/fqNepJ1KJF6d5lgRArpFdMrD8q9zP+aYuH6OPYiX5WoE/1SnraVvmJEQewlk 8ccUbF3i+5pl2CYvDc3cD/bYbgbnLF40AGXNLpsOirUveD9rCR3iiyrdeUEhCZ2vYVmR JOtogYyLyLPzr9I+bKQHooTqYHfVlMX84AiJJ9MfihhRZnBiEXON7YxH1gnYNTQQTrmu NqMKpCwYzx+vpvRug/IKOR/NQvJ+h8XJ8dH7glF8KTjCzGcCfli2LNNRhMbYy5fJdtn8 5qPbNc9pvn3F6CCzvvztNxGk4rw50dFBLpbGJhzutgQE0Gsbnz11ENgbaJ3TZkyALRhT hYzw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=nLUBYPMO; arc=pass (i=1 dkim=pass dkdomain=linux.org.uk dmarc=pass fromdomain=zeniv.linux.org.uk); spf=pass (google.com: domain of linux-kernel+bounces-167046-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167046-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id t26-20020a63535a000000b005f7f7612dbdsi2045414pgl.834.2024.05.02.19.48.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 19:48:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-167046-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=nLUBYPMO; arc=pass (i=1 dkim=pass dkdomain=linux.org.uk dmarc=pass fromdomain=zeniv.linux.org.uk); spf=pass (google.com: domain of linux-kernel+bounces-167046-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167046-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 11DBE2857FF for ; Thu, 2 May 2024 23:12:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0821F1D55D; Thu, 2 May 2024 23:12:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="nLUBYPMO" Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) (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 81EB257C8D; Thu, 2 May 2024 23:12:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.89.141.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714691556; cv=none; b=BnPO6MoUISALxjZP+L0TupndpHZQb/O6QAxMIrcg1mAk50BnAK4yVv56hhmTRwGvF3a+Sz4XbheOaolzXPQm01FwGlJ4+eQO+IGa5nDFyC39vW2/zf+a3hykuNlpGiT1ZSo2ygiRa7P+2vNKokKOvjS5633ZcGqZZ715N1xts5c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714691556; c=relaxed/simple; bh=OHJgZc/CMoZ0g/v11+eBa6RC+qi9mLY2VwKjaQ/LrEE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ubGuRoAvCK4qlLdIa+Ya8bj6uqT1qHXFcNDSz+Rym5co2NJ6TdeH50G9VZuHn5/VWgV4apZqPKPiILCCl38kb7vdLFLKse+g3TqHfNXzZsZcJWbldoEF9+pviZ40IYOqcQ0+GnVi/zvagb+M4z284tQA/GwD+6cW2QEGBoR0ZNY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk; spf=none smtp.mailfrom=ftp.linux.org.uk; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b=nLUBYPMO; arc=none smtp.client-ip=62.89.141.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ftp.linux.org.uk DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=O+ovtRI+qjFoRKgW6PbWKtfCDqZHsyNloCpeAE5jAfE=; b=nLUBYPMOxAkFlz7J3+shxAx8uh 9sx8gN2/C/59+EGGOXikIkpjCG85w8YVO5UrIBPF6YZxW18luIXpfopq1JRvQO9oRKMhCPdFbUqCy AG2C+Q/fTic5lf6IymQNB/RBRnQWBiiEbFiUv+p8WPpggILEUV4isEa76TxgHiClmGqQqy+vUV+98 GY2WS1jkLAYEjOUUH1CuxEjTwvyVy6AYdg5Ad/AYDlpxql0gyNAyDNfPyKQDxYI7xb49Y+7QRiubk GJzJusN31jWemm9+PTjKpw09m+qztnOzgZXzOsxUo7cj6ndTvtPQWu/RCxI5dzesVbQ4Z/azyCNWR OtxWt1fg==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1s2fbI-009qeI-1T; Thu, 02 May 2024 23:12:28 +0000 Date: Fri, 3 May 2024 00:12:28 +0100 From: Al Viro To: Kees Cook 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: <20240502231228.GN2118490@ZenIV> References: <20240502222252.work.690-kees@kernel.org> <20240502223341.1835070-5-keescook@chromium.org> <20240502224250.GM2118490@ZenIV> <202405021548.040579B1C@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=us-ascii Content-Disposition: inline In-Reply-To: <202405021548.040579B1C@keescook> Sender: Al Viro On Thu, May 02, 2024 at 03:52:21PM -0700, Kees Cook wrote: > As for semantics, what do you mean? Detecting dec-below-zero means we > catch underflow, and detected inc-from-zero means we catch resurrection > attempts. In both cases we avoid double-free, but we have already lost > to a potential dangling reference to a freed struct file. But just > letting f_count go bad seems dangerous. Detected inc-from-zero can also mean an RCU lookup detecting a descriptor in the middle of getting closed. And it's more subtle than that, actually, thanks to SLAB_TYPESAFE_BY_RCU for struct file.