From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E580D78793 for ; Thu, 21 Nov 2024 16:36:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 933CD6B0082; Thu, 21 Nov 2024 11:36:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8E4AC6B0088; Thu, 21 Nov 2024 11:36:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 783A86B0089; Thu, 21 Nov 2024 11:36:27 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 5AB586B0082 for ; Thu, 21 Nov 2024 11:36:27 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 02A971C6195 for ; Thu, 21 Nov 2024 16:36:26 +0000 (UTC) X-FDA: 82810654626.02.721042E Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf22.hostedemail.com (Postfix) with ESMTP id BA226C0005 for ; Thu, 21 Nov 2024 16:35:18 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=gV1e8WjL; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=c5L0hCOC; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=akyTH1yr; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=FdsfhEJ6; dmarc=none; spf=pass (imf22.hostedemail.com: domain of jack@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=jack@suse.cz ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1732206892; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=owpYThB1H3Ar3OZ3shQAJEwqjDt1Pg/S0sw5HXZq9co=; b=Lr5Q9l62zHli02XsWVfwU6l52dPQl2J1mRzpAi2ByZiEaX/D9UN6Z3Cas2gmTbig27NeVe 722+uG67N2NjiB1kmIq6h8egSJxYdKQAwfouSqHlHL2qYIpMjNwzPjay9ccFTxM0gBacUO Rm9hppQrWIVXD6Nugb6WpkVrxb1tX3s= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=gV1e8WjL; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=c5L0hCOC; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=akyTH1yr; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=FdsfhEJ6; dmarc=none; spf=pass (imf22.hostedemail.com: domain of jack@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=jack@suse.cz ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732206892; a=rsa-sha256; cv=none; b=N8O8q9Mdc6LJeGd0wodemEJpBPzD94OKr8COxGEmvliDJAScSldPeQm2qm7x6oqeWSeNpd zmAQekWhhBl6IMc2B4J9hQc7Fr2+vwx1qQ2IHmefElYQCwbOfXewB/vpHD6pAb2SU1O+nz 2uDOaqzdVWQM0cxjwxbvaVNahQ5K1k4= Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id DDAD521A1F; Thu, 21 Nov 2024 16:36:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1732206983; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=owpYThB1H3Ar3OZ3shQAJEwqjDt1Pg/S0sw5HXZq9co=; b=gV1e8WjLDrReA1TaAazvauUv8Rz3sgBIfrIq2XafYUXJYD+Se4EPBMJB2jqgmY8yOX6/JW Yjd6u37CPz/2Q1Uiq1qcEDYPW1NT4bVzQcD3sZ1SNXq12tVIRNPPsRSJnJdI65ul080L0/ GCNAMOCYMIcjXUjY2p3wNoF5HhQ5PL0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1732206983; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=owpYThB1H3Ar3OZ3shQAJEwqjDt1Pg/S0sw5HXZq9co=; b=c5L0hCOCVD+j/6pVnFCMS1fcdvvW5F0Xq+olEN0wdnh674K69Dm5nTr8H2L6GyMKhvPONA A/zZHvCW4BztszAg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1732206982; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=owpYThB1H3Ar3OZ3shQAJEwqjDt1Pg/S0sw5HXZq9co=; b=akyTH1yrjt4uURPAMj2Opr2QAlOEezzScxIKcbBlpEveqglKW+s0SvZfeKzZIGZDGd1ha3 5QniWYnxtGpq6y7mtxhgObnX5tfO8dSTFTy7HwhLOOCrT0KzoHbpAplk0TOt45T8RpTkbf ZTWl3s5X+5Ma2W1UYLWvFTQdfqmTknE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1732206982; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=owpYThB1H3Ar3OZ3shQAJEwqjDt1Pg/S0sw5HXZq9co=; b=FdsfhEJ6AfFetOsQMF3Wm205FH1c6YuxDgs3g0gLrz9RTFrBxj46EZG7WNfzx8T/Tjc7PB o/IDLVpHiCHd4lAQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id CC924137CF; Thu, 21 Nov 2024 16:36:22 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id MqTSMYZhP2d8YwAAD6G6ig (envelope-from ); Thu, 21 Nov 2024 16:36:22 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 47071A08A2; Thu, 21 Nov 2024 17:36:18 +0100 (CET) Date: Thu, 21 Nov 2024 17:36:18 +0100 From: Jan Kara To: Amir Goldstein Cc: Jan Kara , Josef Bacik , kernel-team@fb.com, linux-fsdevel@vger.kernel.org, brauner@kernel.org, torvalds@linux-foundation.org, viro@zeniv.linux.org.uk, linux-xfs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-mm@kvack.org, linux-ext4@vger.kernel.org Subject: Re: [PATCH v8 10/19] fanotify: introduce FAN_PRE_ACCESS permission event Message-ID: <20241121163618.ubz7zplrnh66aajw@quack3> References: <20241121104428.wtlrfhadcvipkjia@quack3> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspamd-Action: no action X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: BA226C0005 X-Stat-Signature: ngocehj4e4zx3b3tyw6ubsmx7gqjsg7q X-HE-Tag: 1732206918-208250 X-HE-Meta: U2FsdGVkX18NJ46bXsqOh7NP+lq8feij4Ueyl2t6KZFePzFpikgFp5DfJvACFyaHj9cva1+GnHB4aypt5JF0zuYVAQNjrfJ3rg+Imnxlj5gl+YU3xevMJMEPRKhz2oVOSvOpwzxX9NfqOBFLRDjYuwl1aQw6ZYahyf53UFU0fqolKmu90zIpbGYKbjEAkJH0KjqNuLPmAAQWomlckAR0g65sanCURQpitolk5iFfmd0Fd7atfG65AIktaGB6UxX08jhp+5cgMPkYLXbHciBQY65D+rNJ8fKbcVrwyzurqJQPCb6ciGFbGAJhSQWachbCLN/dTyeuWnJS0z33PP7rNThmYprBvh6kCU1WvG0X0/r4z95shWs1r7DcjGPXOQOj4n0/gNQ8TjUCAHMmNPWpuLeCkqT3MI3YnYZSDvZlQv/8m5NC1/wm2Xg2L+luvkuK5uuCETl+6GGJh2y4sy3V6on3Oe3NzFeF18DZlXqamIKBm5D27CwF2bFvvoyu2vTzUCXXKbK7bEx1AOdLlTEaGPIehlRtKCYnNbw1Y/2djQtQmsVB7/SadxYrii3sQuNhUb69gk/cZEPt3lAzMpUNNrxBLJQLxKUvO1MwNLWFeRMqwWmukM1O3zNu4BH3s7juORM/TzMz0Po+1yaX8NR4e3vVW4VymCAw9yJFBvsF02gyCpl32FxmcdAN6Fk1yxUQM8JgmVrmWJfHFkLup/rUXGlrVwPGX/lGXbVAdLiFtvAVM1tqipVWm1+A+m4B/fmfPVEAfPRuwkK2S6148cOMIdlAisZJBgGLVgQxYZJsb6lDLt4MMr7wsPllHQxzBxp0Zz5mgn8at3sIJGg9AmdVtWK12p3Xa5A4jQdAq9bp1ATAES9Rk5QXeDO6laipR26A9qw5YGWC/rPR5xvpe54a3xVabctcRS0maO/k6xrYhPhTMO/IWF7fEOc7GRqMFFwREQ9smxtIcLxMcJ8qaJz /znvnwE4 7pVbilygy/prE3t9860Orjs9A4GfPO755L8MjIc198Hn1dT7YgKIJb0u8TNk+2zXYmclYVwqK9txUWAFvJVyXs5FrGI2uep3MaPVsIbgg3mpJ1AMH0PA4trAX/9ZXgfWYEwelar7xIxkKtpvyw5j/BQVvokCleqUIQfCSLMzdo5+EDG61ePp4RkpeSTnOUROMk4imGXt65CT2e8O2A0FvWR5TUONg3pwfrpfRm6x9UoRTJquAlMy6dsSOq1h3yjOOkzR4bF/V2Mo+qENscai1yC3vGGQJXJIxJcZ4f6e+3gJG0fmA5hms91mCcvGuZS2t3rjgJqXJZ2AzZ19uiOurPmM+IrHcQtsnVVgg00Pu1WHpJYz7MVM7aZNmZnsQbDwGfpKOHNeo+zBMUHMBuJXqQI6857GUOTz5N5j0D0PcksL9KhYw0WW/qaQKxQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Thu 21-11-24 15:18:36, Amir Goldstein wrote: > On Thu, Nov 21, 2024 at 11:44 AM Jan Kara wrote: > > > > On Fri 15-11-24 10:30:23, Josef Bacik wrote: > > > From: Amir Goldstein > > > > > > Similar to FAN_ACCESS_PERM permission event, but it is only allowed with > > > class FAN_CLASS_PRE_CONTENT and only allowed on regular files and dirs. > > > > > > Unlike FAN_ACCESS_PERM, it is safe to write to the file being accessed > > > in the context of the event handler. > > > > > > This pre-content event is meant to be used by hierarchical storage > > > managers that want to fill the content of files on first read access. > > > > > > Signed-off-by: Amir Goldstein > > > > Here I was wondering about one thing: > > > > > + /* > > > + * Filesystems need to opt-into pre-content evnets (a.k.a HSM) > > > + * and they are only supported on regular files and directories. > > > + */ > > > + if (mask & FANOTIFY_PRE_CONTENT_EVENTS) { > > > + if (!(path->mnt->mnt_sb->s_iflags & SB_I_ALLOW_HSM)) > > > + return -EINVAL; > > > + if (!is_dir && !d_is_reg(path->dentry)) > > > + return -EINVAL; > > > + } > > > > AFAICS, currently no pre-content events are generated for directories. So > > perhaps we should refuse directories here as well for now? I'd like to > > readdir() does emit PRE_ACCESS (without a range) Ah, right. > and also always emitted ACCESS_PERM. I know that and it's one of those mostly useless events AFAICT. > my POC is using that PRE_ACCESS to populate > directories on-demand, although the functionality is incomplete without the > "populate on lookup" event. Exactly. Without "populate on lookup" doing "populate on readdir" is ok for a demo but not really usable in practice because you can get spurious ENOENT from a lookup. > > avoid the mistake of original fanotify which had some events available on > > directories but they did nothing and then you have to ponder hard whether > > you're going to break userspace if you actually start emitting them... > > But in any case, the FAN_ONDIR built-in filter is applicable to PRE_ACCESS. Well, I'm not so concerned about filtering out uninteresting events. I'm more concerned about emitting the event now and figuring out later that we need to emit it in different places or with some other info when actual production users appear. But I've realized we must allow pre-content marks to be placed on dirs so that such marks can be placed on parents watching children. What we'd need to forbid is a combination of FAN_ONDIR and FAN_PRE_ACCESS, wouldn't we? Honza -- Jan Kara SUSE Labs, CR