Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp3827552rdh; Fri, 29 Sep 2023 03:43:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFsJKQ5CzOrHEivHVrYGNIm9TZk/+9JnyKRY22CeyU6oqibO2R1qacA4tGCZswGle7F6Brx X-Received: by 2002:a17:902:d34b:b0:1bb:9b29:20d9 with SMTP id l11-20020a170902d34b00b001bb9b2920d9mr4243130plk.20.1695984205893; Fri, 29 Sep 2023 03:43:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695984205; cv=none; d=google.com; s=arc-20160816; b=ZwApysIYfO2kzT2Zy0bOwYLitEmSbiI4Z95lnyD72HeB/TWGF+ykpIx2lbCx0f7eUp DCOV9OEv3K9oWE3MPVHEXSZgSPbiHEPwObuslWN9rtjjXAZfGDAdu4NmAJdKAQeeHGGo cRghdBefOT8YQ6GvOXlI7xILqoOYCNMoN8uZR2OrYFCtgM3RnASGQcdjP9qNurS264ev EYKjyiSU6uXP/YOUUkmd3RPG4UxAJoaDiISN5+R0SKdrhAfUOuSw91I4N1I9qczjdBmg csU94n6I/wAFaZ2+pcTUfZCqeCXXtUax4CMc4KMUEuTmILzYZWvYIMxRg6TB8H75jyaI Yrhg== 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=ixqemPBH+Yg3YxK8N4iZBEZPhv5OujAqEu9rexAdDbQ=; fh=niBFMMI1tlN3AjLTQi5g+zaErYdYdI9q5qblkgEDZQk=; b=iH3GzpfGg1XGmt+QnoO4ZCzPl9Wb69IUTDQ6p6IxBHfx9EeTxRzx8xuFn31dhU9HLJ lhSMGeDgnOAafTF/zYSIzdIFyboGB3BNKZK2Zpf9RykR3lH3J8ysJw1k0yTESx74FcUq 71Oi6SpPi+vHKICvvXZu3Z+WygpcpEyc/4wUwuXAQxmSPrYEY3zvhQG28HJUCA5RkcSV t53WhfICaJep75V+4LV82kf0khJ7CGtBHj/0CdqFCBwAnujSHrYd/0LklQI4eVMNypf1 vf4do91wBY46jEn3eljYHwYxrDOlA5pHFoMPPUUWmArXhSQSxIXTLHmBLYfQFZikmozY klWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GIMtzk+H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id s1-20020a170902ea0100b001c4660cd474si22483891plg.634.2023.09.29.03.43.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 03:43:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GIMtzk+H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 806248286EB0; Fri, 29 Sep 2023 02:21:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232919AbjI2JU7 (ORCPT + 99 others); Fri, 29 Sep 2023 05:20:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232490AbjI2JU6 (ORCPT ); Fri, 29 Sep 2023 05:20:58 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E8E019F; Fri, 29 Sep 2023 02:20:56 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CCD19C433C8; Fri, 29 Sep 2023 09:20:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695979255; bh=ixqemPBH+Yg3YxK8N4iZBEZPhv5OujAqEu9rexAdDbQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=GIMtzk+H6WnoeyiP7YtkRG5RIlr6lMjdgpmFCmotRRSzhFSHDrnxt4AxfFTAxNYqn wNuolRwkNNjaj2CqIEO2Ie20qub2K2zBxKnWbIpQ2RVPPri/JcDTBUxel/gwj6UlJj xxWoeeQ2Y+AkyS8iwQ+klD7M9fIFbRNKcvqgRpKJu8JT2kTIaiEQGlBhanuf23D7KU i6kLzgntHi9U0Q+ISvpVhh0l0dqtgxmN7fdvREQem0GoGwxHaoa1ICU9Ndida6u2Hf TymisZxBVP1BDxajl2hVFG0NtME0Ljg8T4VZxEnr3dttIGRQOUUtNt3Stra5W8ZQDt lyjU/Koh6J4vQ== Date: Fri, 29 Sep 2023 11:20:48 +0200 From: Christian Brauner To: Linus Torvalds Cc: Jann Horn , Mateusz Guzik , viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v2] vfs: shave work on failed file open Message-ID: <20230929-kerzen-fachjargon-ca17177e9eeb@brauner> References: <20230927-kosmetik-babypuppen-75bee530b9f0@brauner> <20230928-kulleraugen-restaurant-dd14e2a9c0b0@brauner> <20230928-themen-dilettanten-16bf329ab370@brauner> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Fri, 29 Sep 2023 02:21:09 -0700 (PDT) > But yes, that protection would be broken by SLAB_TYPESAFE_BY_RCU, > since then the "f_count is zero" is no longer a final thing. I've tried coming up with a patch that is simple enough so the pattern is easy to follow and then converting all places to rely on a pattern that combine lookup_fd_rcu() or similar with get_file_rcu(). The obvious thing is that we'll force a few places to now always acquire a reference when they don't really need one right now and that already may cause performance issues. We also can't fully get rid of plain get_file_rcu() uses itself because of users such as mm->exe_file. They don't go from one of the rcu fdtable lookup helpers to the struct file obviously. They rcu replace the file pointer in their struct ofc so we could change get_file_rcu() to take a struct file __rcu **f and then comparing that the passed in pointer hasn't changed before we managed to do atomic_long_inc_not_zero(). Which afaict should work for such cases. But overall we would introduce a fairly big and at the same time subtle semantic change. The idea is pretty neat and it was fun to do but I'm just not convinced we should do it given how ubiquitous struct file is used and now to make the semanics even more special by allowing refcounts. I've kept your original release_empty_file() proposal in vfs.misc which I think is a really nice change. Let me know if you all passionately disagree. ;)