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 72726E7717F for ; Tue, 10 Dec 2024 11:20:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 03F5B6B0181; Tue, 10 Dec 2024 06:20:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F38846B0182; Tue, 10 Dec 2024 06:20:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DD0556B0183; Tue, 10 Dec 2024 06:20:34 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id BE7D56B0181 for ; Tue, 10 Dec 2024 06:20:34 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 76C731C7280 for ; Tue, 10 Dec 2024 11:20:34 +0000 (UTC) X-FDA: 82878805548.06.80AE473 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf17.hostedemail.com (Postfix) with ESMTP id 84B3740003 for ; Tue, 10 Dec 2024 11:20:15 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=lxMiDObz; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=4b1A4urR; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=lxMiDObz; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=4b1A4urR; spf=pass (imf17.hostedemail.com: domain of jack@suse.cz designates 195.135.223.130 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=1733829622; 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=qXIYdd1xilEItOpeyjB9DIhvgYLJ1k/6/oDli3Wzspc=; b=zbFc/MegN+VKc+43GTKRpBgXFw4F0IgxcDGBU6fmE9YrIXqsv6ugAsg3qYpYBem424Wemv F8Nm+hZGknVu4loD2i9AKRHpL1tKgkcGCLy6mmGO+dVV8h6ugyU895WZ5yUFYvvVSPtJP5 LNBN/weI04r6l0mBItJnzIm+5apZgSg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733829622; a=rsa-sha256; cv=none; b=2lljo7CM3JHtGdCSmSgCT3zUn/kTOEV2HuQdu+INhUjPAUaSsY8UhEpD6aEcoxkdVkocqN 3acAaxv6+0C/f6JsKsJ55/wRKu+2dA6yjO/sY0G+78ncs+yaDvjurEYDCfjvQoRr9eoBXZ n6tSP8/ksdhOMdlK3UkS5pVIDFkfF4s= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=lxMiDObz; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=4b1A4urR; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=lxMiDObz; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=4b1A4urR; spf=pass (imf17.hostedemail.com: domain of jack@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none Received: from imap1.dmz-prg2.suse.org (unknown [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 7CCE821169; Tue, 10 Dec 2024 11:20:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1733829630; 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=qXIYdd1xilEItOpeyjB9DIhvgYLJ1k/6/oDli3Wzspc=; b=lxMiDObz/akn552DWKSmNgmdCvP87NzFjjKc/sQJZaGV8bTE5FWKJ/mO25nsnkvFWi8pJH xKL9QxDySFXJJbyGK67YRBUlbUeJL+jNRukK214YlXjYOPo1ZCD0WFMG9GMGKSYLari2z+ kXAHThlAE72rwR8jpF8sWSFl69Qhj7s= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1733829630; 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=qXIYdd1xilEItOpeyjB9DIhvgYLJ1k/6/oDli3Wzspc=; b=4b1A4urRXXpm1KHmAbttwD3PnWozrLLeK2MhPrMFixz1XVtO1iYp9YMs9FFMVAKS47AzuW g3h5DCHlj0dephAQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1733829630; 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=qXIYdd1xilEItOpeyjB9DIhvgYLJ1k/6/oDli3Wzspc=; b=lxMiDObz/akn552DWKSmNgmdCvP87NzFjjKc/sQJZaGV8bTE5FWKJ/mO25nsnkvFWi8pJH xKL9QxDySFXJJbyGK67YRBUlbUeJL+jNRukK214YlXjYOPo1ZCD0WFMG9GMGKSYLari2z+ kXAHThlAE72rwR8jpF8sWSFl69Qhj7s= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1733829630; 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=qXIYdd1xilEItOpeyjB9DIhvgYLJ1k/6/oDli3Wzspc=; b=4b1A4urRXXpm1KHmAbttwD3PnWozrLLeK2MhPrMFixz1XVtO1iYp9YMs9FFMVAKS47AzuW g3h5DCHlj0dephAQ== 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 6F556138D2; Tue, 10 Dec 2024 11:20:30 +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 PMAiG/4jWGfGVgAAD6G6ig (envelope-from ); Tue, 10 Dec 2024 11:20:30 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 3222CA0B0D; Tue, 10 Dec 2024 12:20:26 +0100 (CET) Date: Tue, 10 Dec 2024 12:20:26 +0100 From: Jan Kara To: Amir Goldstein Cc: Jan Kara , Bert Karwatzki , Josef Bacik , linux-kernel@vger.kernel.org, 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: commit 0790303ec869 leads to cpu stall without CONFIG_FANOTIFY_ACCESS_PERMISSIONS=y Message-ID: <20241210112026.7v74ig2rrmceam5o@quack3> References: <20241208152520.3559-1-spasswolf@web.de> <20241209121104.j6zttbqod3sh3qhr@quack3> <20241209122648.dpptugrol4p6ikmm@quack3> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 84B3740003 X-Stat-Signature: 5jkb9qwrucjeqqhe4mfpg8aadikm9b4f X-Rspam-User: X-HE-Tag: 1733829615-878254 X-HE-Meta: U2FsdGVkX1/XLfj0ri0U+g12PXoXrG5Xq/agPIf98Pa+QgA3hD6mxNftXQMUM6QkSl2GjRupJ6xjrreh0Xgc+0oDMvQsB2fSGkXK5epXoHXTmwUHKcxoznK0ZF2i0VFHQFe/JqjXJr8UZG9DAEpLF/m+S47veEl9U+q5auBcsBLTc7Y8DWFjLjZgxqITvtzeyKyv6fGGMO8PrmLM3DdZFnW6gL+PDMvG8zXCUjOgrbsI9dXvBup3MBqa1lUdY0omMh7hAdkrNX/2YQWFI0Fwx/kVflcm0SCOyMben6NaP5W4SxxPz5kxnsUhkys1tJM6PpLe9bVxSvBfEBLcKcChYRWnwPFJNv2IOe0PUuToEf7NO2gbk27yHS7Bt90EHy6U9gbWZ8TEN+lGlgJccFMe9x0YECMKuDNDAaZGfVw36WKPwM3Nwm1nPEpdOnl1NPx1TFjxyiFw0HUQkOqhCpTLfnkDgBe2w55YWLQyZcGNbnRqL+NadiyzWRrCmHKdrtCtwVv6QOPtEHkk6gpQK1L6JyhHV0qy6vbpe4AD63b687u3nzTfLWwrOmhn2PzyNu5eelHKzcTnPcFASPmU0VesNaJJ4LUTDF2qqNhv5worJ4bVaA02wxMKC4bOOa95vGa880akyVKhlLEuBuuvuzFU7zHfu9qnlDU8LMIXYZHZrFRkfV0wFoBpkfSJYMlLC0L/mAFv/DbeaERyZJmRd+T88QJ5D6T/MBZiE5wiMeKTinvGevb1GbKGewpWQiMgOcqgJzCtytQ9uDXwFkMIlWc1aTXR6rCiO53ORawpQ/UULqYOf2Kq/D/1pxYNDo2XbUQVg1G7K9wEhpzarNnQPlo4/PFppMHvatx61AqJoBNeC+0EduR29fUGgCMuI4q28C9VQ4Nm0o3ujtmjBxl1G4GlnMU/HU5xqZpyr/WBmbO/NNgTub4+GsZCHrkL6YZi9FK4UyeZ+qZbqklyUrhH/Lj Jx8YO+j9 SB5K8gmnCDlcoY+ao0ZAO9lx4yftmDkLd+NowjRXYgRlkqjGpBri6bGAF21rt+o0040oKbczC4Fo8iMAocMUIhEJu7B5wJQC3j3fam9kGAtO690R56erFlPIxgxqS9sIq44XRCHpobRfDOwvTY7uSGHFUxiCqiAUBSlsi/BlwDZLwRNzLXGd7waolmMgyVSPRVLPqcYOcZCyFOXt+3OWDCzYNkLty4IBMv/t6fMKEDXZgVrfFO6GggcGc+9mvDQNLmEf8xDywdrqpApZvCYQZruQ3io+8EblWNG7OhnYWtQA5y5hnsksavYQ2+z1onGZ2geziaYBm5SFz520NetWeGYmUEJxPzNa+ii5p1AB6DEWtkXz8rVvgq6CNuGnAnG1ja8momiFllaYsJdHuPaasIXDfrRBQMpKOvuEooHObeZknRREvplc6Srs5PTB5EGyegVZn X-Bogosity: Ham, tests=bogofilter, spamicity=0.000007, 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 Mon 09-12-24 17:23:24, Amir Goldstein wrote: > On Mon, Dec 9, 2024 at 1:26 PM Jan Kara wrote: > > > > On Mon 09-12-24 13:11:04, Jan Kara wrote: > > > > Then I took a closer look at the function called in the problematic code > > > > and noticed that fsnotify_file_area_perm(), is a NOOP when > > > > CONFIG_FANOTIFY_ACCESS_PERMISSIONS is not set (which was the case in my > > > > .config). This also explains why this was not found before, as > > > > distributional .config file have this option enabled. Setting the option > > > > to y solves the issue, too > > > > > > Well, I agree with you on all the points but the real question is, how come > > > the test FMODE_FSNOTIFY_HSM(file->f_mode) was true on our kernel when you > > > clearly don't run HSM software, even more so with > > > CONFIG_FANOTIFY_ACCESS_PERMISSIONS disabled. That's the real cause of this > > > problem. Something fishy is going on here... checking... > > > > > > Ah, because I've botched out file_set_fsnotify_mode() in case > > > CONFIG_FANOTIFY_ACCESS_PERMISSIONS is disabled. This should fix the > > > problem: > > > > > > index 1a9ef8f6784d..778a88fcfddc 100644 > > > --- a/include/linux/fsnotify.h > > > +++ b/include/linux/fsnotify.h > > > @@ -215,6 +215,7 @@ static inline int fsnotify_open_perm(struct file *file) > > > #else > > > static inline void file_set_fsnotify_mode(struct file *file) > > > { > > > + file->f_mode |= FMODE_NONOTIFY_PERM; > > > } > > > > > > I'm going to test this with CONFIG_FANOTIFY_ACCESS_PERMISSIONS disabled and > > > push out a fixed version. Thanks again for the report and analysis! > > > > So this was not enough, What we need is: > > index 1a9ef8f6784d..778a88fcfddc 100644 > > --- a/include/linux/fsnotify.h > > +++ b/include/linux/fsnotify.h > > @@ -215,6 +215,10 @@ static inline int fsnotify_open_perm(struct file *file) > > #else > > static inline void file_set_fsnotify_mode(struct file *file) > > { > > + /* Is it a file opened by fanotify? */ > > + if (FMODE_FSNOTIFY_NONE(file->f_mode)) > > + return; > > + file->f_mode |= FMODE_NONOTIFY_PERM; > > } > > > > This passes testing for me so I've pushed it out and the next linux-next > > build should have this fix. > > This fix is not obvious to the code reviewer (especially when that is > reviewer Linus...) > Perhaps it would be safer and less hidden to do: > > --- a/include/linux/fs.h > +++ b/include/linux/fs.h > @@ -211,11 +211,16 @@ typedef int (dio_iodone_t)(struct kiocb *iocb, > loff_t offset, > > #define FMODE_FSNOTIFY_NONE(mode) \ > ((mode & FMODE_FSNOTIFY_MASK) == FMODE_NONOTIFY) > +#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS > #define FMODE_FSNOTIFY_PERM(mode) \ > ((mode & FMODE_FSNOTIFY_MASK) == 0 || \ > (mode & FMODE_FSNOTIFY_MASK) == (FMODE_NONOTIFY | FMODE_NONOTIFY_PERM)) > #define FMODE_FSNOTIFY_HSM(mode) \ > ((mode & FMODE_FSNOTIFY_MASK) == 0) > +#else > +#define FMODE_FSNOTIFY_PERM(mode) 0 > +#define FMODE_FSNOTIFY_HSM(mode) 0 > +#endif I agree this is a nicer way to achieve the same. Updated, tested & pushed out. Honza -- Jan Kara SUSE Labs, CR