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 B5219D75E37 for ; Fri, 22 Nov 2024 12:42:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 36BA66B00A2; Fri, 22 Nov 2024 07:42:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 31BFE6B00A4; Fri, 22 Nov 2024 07:42:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 195526B00BE; Fri, 22 Nov 2024 07:42:21 -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 EF1316B00A2 for ; Fri, 22 Nov 2024 07:42:20 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id A43671412BF for ; Fri, 22 Nov 2024 12:42:20 +0000 (UTC) X-FDA: 82813692402.23.B184862 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf17.hostedemail.com (Postfix) with ESMTP id D14DF40009 for ; Fri, 22 Nov 2024 12:41:36 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=wg83j0e3; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=EhtrLo1t; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=wg83j0e3; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=EhtrLo1t; spf=pass (imf17.hostedemail.com: domain of jack@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1732279090; 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=m1y1r4sHVpVio90pxvAPQyjpbXtCbYSZFBXxevcolao=; b=6rMFFXtjCKBM4wFEQARuzZFHU1SWfXpSb+qg8VZR1MIMpQZjczMuYFCEIj7sd3KIwuNR5b DegbYI1qwSSaLYZcgp+jgfwPq1VtPHq3CmF6+fhyO3ohtSCPqXqltQpnQHIkUut2zfn7fn kPJpovveu6agMbJQmJEDL22jM5/VljE= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=wg83j0e3; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=EhtrLo1t; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=wg83j0e3; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=EhtrLo1t; spf=pass (imf17.hostedemail.com: domain of jack@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732279090; a=rsa-sha256; cv=none; b=NaGlqatmp/tG9ZNWtv81a8/cXZWvDlRRYcJhjUMfY5q6jcCpAGLmjiID3s+4rCNvegROn6 jPsbYyHwiHy2MxCAMM551yxvMHS3Z78bML8DzhjeXGddXB9Px1tOC2Yoqki1txXg5Fullz F+ulCm+FUA7gvFeT0c2rk8N35pQXpeA= 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-out2.suse.de (Postfix) with ESMTPS id 617291F37E; Fri, 22 Nov 2024 12:42:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1732279336; 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=m1y1r4sHVpVio90pxvAPQyjpbXtCbYSZFBXxevcolao=; b=wg83j0e3hSLltgYOUYSZN0jS+angV9uQghS0LenqzGPk3qbp86odk05SMKk4+Mhf7hpfyf ZGXYH/3G/sfodnI38ZtqnQgEILuFBVGJ2Jn7orHyVjxfX72HC9xs791LbYgebWr2bl8+GC Kl50ZHoiD2FMC5bHwsPy4ZPIL706+ug= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1732279336; 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=m1y1r4sHVpVio90pxvAPQyjpbXtCbYSZFBXxevcolao=; b=EhtrLo1t6LF9G4YWEqQr33i346haGUJHbJcFmU1TT4kt9Aw5LnX1axDrQOr5+bwEGLVchz qVZB81zTxia51PBQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1732279336; 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=m1y1r4sHVpVio90pxvAPQyjpbXtCbYSZFBXxevcolao=; b=wg83j0e3hSLltgYOUYSZN0jS+angV9uQghS0LenqzGPk3qbp86odk05SMKk4+Mhf7hpfyf ZGXYH/3G/sfodnI38ZtqnQgEILuFBVGJ2Jn7orHyVjxfX72HC9xs791LbYgebWr2bl8+GC Kl50ZHoiD2FMC5bHwsPy4ZPIL706+ug= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1732279336; 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=m1y1r4sHVpVio90pxvAPQyjpbXtCbYSZFBXxevcolao=; b=EhtrLo1t6LF9G4YWEqQr33i346haGUJHbJcFmU1TT4kt9Aw5LnX1axDrQOr5+bwEGLVchz qVZB81zTxia51PBQ== 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 5134A138A7; Fri, 22 Nov 2024 12:42:16 +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 wOrMEyh8QGdOSQAAD6G6ig (envelope-from ); Fri, 22 Nov 2024 12:42:16 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 00DB1A08B5; Fri, 22 Nov 2024 13:42:15 +0100 (CET) Date: Fri, 22 Nov 2024 13:42:15 +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: <20241122124215.3k3udv5o6eys6ffy@quack3> References: <20241121104428.wtlrfhadcvipkjia@quack3> <20241121163618.ubz7zplrnh66aajw@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-Rspamd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qUnYmDiTEZrRP7cgFrzX 6iEAH/xm Tyd9a3/M1XJsNfd3Y2byfAVuyhMaeDJ8JC1bNg/ghQ9BH3K1QBCTJUqZVKGGJeJzv/y89lmpawXTTdrKDe9neNW6u9HzLao2KKalTO5CYIEzVZNTD2trVjSUgf09R7CF7c60AkHH8ybV/cMzgoMRqB3xWfqEizQpJfGbS3HksSCuwr6hBt773UBig5DwQB8nYcSGjpTEFCmEuy04LNZ6pwWocSgS3Leq4j3Rprht20fzZGHNBFZYUabPUY8HVfwE9IZLCB+Cfqqw5MjlnlAm+N1GTxp7oS9unicBO+eMIFRYNkjBi76nQr1LqnGW6v3qf4Uiqcy/cSCXmh1bDJfVmocPFLE3igZQZAVQW24s7H+a16o7zw1Z6gcIVkvePwLxK5KcvprOeGoyGfFJ4umv/jXWKcMS5pGbf45w0Nq9yYdDkxJcvffvhESskPA== 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 19:37:43, Amir Goldstein wrote: > On Thu, Nov 21, 2024 at 7:31 PM Amir Goldstein wrote: > > On Thu, Nov 21, 2024 at 5:36 PM Jan Kara wrote: > > > On Thu 21-11-24 15:18:36, Amir Goldstein wrote: > > > > On Thu, Nov 21, 2024 at 11:44 AM Jan Kara wrote: > > > > 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? > > > > Yes, I think that can work well for now. > > > > Only it does not require only check at API time that both flags are not > set, because FAN_ONDIR can be set earlier and then FAN_PRE_ACCESS > can be added later and vice versa, so need to do this in > fanotify_may_update_existing_mark() AFAICT. I have now something like: @@ -1356,7 +1356,7 @@ static int fanotify_group_init_error_pool(struct fsnotify_group *group) } static int fanotify_may_update_existing_mark(struct fsnotify_mark *fsn_mark, - unsigned int fan_flags) + __u32 mask, unsigned int fan_flags) { /* * Non evictable mark cannot be downgraded to evictable mark. @@ -1383,6 +1383,11 @@ static int fanotify_may_update_existing_mark(struct fsnotify_mark *fsn_mark, fsn_mark->flags & FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY) return -EEXIST; + /* For now pre-content events are not generated for directories */ + mask |= fsn_mark->mask; + if (mask & FANOTIFY_PRE_CONTENT_EVENTS && mask & FAN_ONDIR) + return -EEXIST; + return 0; } So far only compile tested... Honza -- Jan Kara SUSE Labs, CR