Message ID | 20230918123217.932179-3-max.kellermann@ionos.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2885675vqi; Mon, 18 Sep 2023 12:03:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IErbHx5+fMvTR76AT9WgDD82A6NGEN3kutnrFM0ieLpLwsSwlEo5LHuDm3+L5McoVzUDV6L X-Received: by 2002:a05:6a20:4322:b0:133:1d62:dcbd with SMTP id h34-20020a056a20432200b001331d62dcbdmr424834pzk.28.1695063781449; Mon, 18 Sep 2023 12:03:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695063781; cv=none; d=google.com; s=arc-20160816; b=QtBZv60YKRZWYA2QjWBPw5YfClkSbdV8zFEqTX80MznK0ldBe0tQb3jfUj4Q9h0Ej/ qNe8eGw2RmmB2PZjFu7wSG8CFiNtszqJVIr+T55dkMeUWiEjSEY7yF8zFkPMvY46z5Vf noSoKj1ORjo1MCdVVklcUFJ8EKwgEA0YJutxjWkIRjZSjj1LMbo8QMIseHgH4auhCWOT lB2j4Tr7jducjpaesYH4hNJGbTxSDU1KYHWEn2eGF3SpfEgTJQAYiB7LHnWUdWZNjduB k/KkVVANe3WjSlIWD+csXHWca40NXbRiTyD0c0x+Hrj+jESBXgUD5MW7OF0t76mDz3Bw OseQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iVQUJ/L8+afXKT69wRIL26IHsJ0vcphHTUN9uWpD+6k=; fh=wd7qOuYAeNqOqTJ3FnCoYa4/XxYdErzLkNb6cLbRrzw=; b=tRsBGf1hITZ8H3dPxjusSOeZjjS/QUdptrhE/PblFUQyFMCDvtF82F09tFhQ4mSR+6 Lqga18ZEFlDdfWqWp3VXmZ6RTZnMSUhb9ywyVf6gWba1Ys1O89+laPlfx2vC54XjwdmV dQYlZN0WsEU65m5j0YYHnvGrjR7CX6tgmDMVG73Rm64z9GArgRIKWvWBQGo1HAV7fKWw 19uKdWm9W53rpzIDddsIJwejR5dWcFIBrjUUoa+QMesYppE5Vu5q4JvgKShdXfkEJYTY mp5dZI2IwvrXDi484rMKoyiR4C2ravU40QWo6v2JCXP+jRzCJpapOZwCpJ/VdXs4RdwA xtYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=ZVJDUei0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id o66-20020a634145000000b005777bea0b5esi8082527pga.901.2023.09.18.12.03.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 12:03:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=ZVJDUei0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id CEC7C802923D; Mon, 18 Sep 2023 05:33:55 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241362AbjIRMdX (ORCPT <rfc822;kernel.ruili@gmail.com> + 27 others); Mon, 18 Sep 2023 08:33:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241330AbjIRMc4 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 18 Sep 2023 08:32:56 -0400 Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0264BC7 for <linux-kernel@vger.kernel.org>; Mon, 18 Sep 2023 05:32:36 -0700 (PDT) Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2bfed7c4e6dso31780671fa.1 for <linux-kernel@vger.kernel.org>; Mon, 18 Sep 2023 05:32:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1695040354; x=1695645154; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iVQUJ/L8+afXKT69wRIL26IHsJ0vcphHTUN9uWpD+6k=; b=ZVJDUei0T8xfdtWX15tKcApO5DRgqvWossHyS/Yo7okNpQcav0LIfkrrJ/dRxgUtoS dMbR5D4WEUPreV7wBLTlKjgC7dtk35RGPlh2PVFlIfMDntYOfK/E81js+s0ZonC3rg1I 1HD3KVIWrjTxMGDjGor7LqciO2j6GqTk03MS44Ojh+pz/omTEf/GWwnZlsQsQR/ljbtA NF/fyLltWyB4hnvTKdEqgWtjiXyU/8lnwAxzcuDESpZ89rXQ0saDf2oE+/lVAIw1Hwi/ V6AgiaGj6W+9mljljF+gJWWeHZYBb6MvNOFyntHkdDF1zqjJRpIJIMmD0yJdP1E77rZX UA7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695040354; x=1695645154; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iVQUJ/L8+afXKT69wRIL26IHsJ0vcphHTUN9uWpD+6k=; b=vRfx78iiIGx1Z7rIuYpFW5uCQSQJJqAIB+mxckxJ6rIWV40K/yRZWB5ddCN69dZ8F+ zg9vaD4WTvIajFBwIJ9ILJdN1/9lB9Uml0SxMjDo02rDinMmseQnSDpsFhj1B6aKAwY7 UqKyqODGNCnZmPMmAJxh4SJUhzmT3SFqHY5d6j8Q/rdQc/Stqw/YF0Ft0lr1oI8biSZV Ufkm+fYQfsDoJ4/in4uiYy25ahmalxGBtYDJkRFfJyfSArLDzVI9llTtXkpnzOOzBH6j PdRWYx2Z28IRDsjiGXiW93XXkaFvMx/Au75+qCeMIiIoNG/SUYhdBSijbhPoF245pf/Y 16LA== X-Gm-Message-State: AOJu0Yxp154QtULx21yXxKyPISsMvjbD1Em3Vh4k4YoudxnEMwJtupG4 qN+h60BhX+itoLesVLnXZrTimw== X-Received: by 2002:a2e:80d7:0:b0:2bc:ff80:f639 with SMTP id r23-20020a2e80d7000000b002bcff80f639mr7962895ljg.7.1695040354219; Mon, 18 Sep 2023 05:32:34 -0700 (PDT) Received: from heron.intern.cm-ag (p200300dc6f209c00529a4cfffe3dd983.dip0.t-ipconnect.de. [2003:dc:6f20:9c00:529a:4cff:fe3d:d983]) by smtp.gmail.com with ESMTPSA id sd5-20020a170906ce2500b00992a8a54f32sm6328834ejb.139.2023.09.18.05.32.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 05:32:33 -0700 (PDT) From: Max Kellermann <max.kellermann@ionos.com> To: jack@suse.cz, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: amir73il@gmail.com, max.kellermann@ionos.com Subject: [PATCH 3/4] inotify_user: add system call inotify_add_watch_at() Date: Mon, 18 Sep 2023 14:32:16 +0200 Message-Id: <20230918123217.932179-3-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230918123217.932179-1-max.kellermann@ionos.com> References: <20230918123217.932179-1-max.kellermann@ionos.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 18 Sep 2023 05:33:55 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777400033300350220 X-GMAIL-MSGID: 1777403199669237692 |
Series |
[1/4] inotify_user: pass directory fd to inotify_find_inode()
|
|
Commit Message
Max Kellermann
Sept. 18, 2023, 12:32 p.m. UTC
This implements a missing piece in the inotify API: referring to a
file by a directory file descriptor and a path name. This can be
solved in userspace currently only by doing something similar to:
int old = open(".");
fchdir(dfd);
inotify_add_watch(....);
fchdir(old);
Support for LOOKUP_EMPTY is still missing. We could add another IN_*
flag for that (which would clutter the IN_* flags list further) or
add a "flags" parameter to the new system call (which would however
duplicate features already present via special IN_* flags).
To: Jan Kara <jack@suse.cz>
Cc: Amir Goldstein <amir73il@gmail.com>
To: linux-fsdevel@vger.kernel.org
To: linux-kernel@vger.kernel.org
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
---
fs/notify/inotify/inotify_user.c | 6 ++++++
1 file changed, 6 insertions(+)
Comments
On Mon, Sep 18, 2023 at 2:40 PM Jan Kara <jack@suse.cz> wrote: > Note that since kernel 5.13 you > don't need CAP_SYS_ADMIN capability for fanotify functionality that is > more-or-less equivalent to what inotify provides. Oh, I missed that change - I remember fanotify as being inaccessible for unprivileged processes, and fanotify being designed for things like virus scanners. Indeed I should migrate my code to fanotify. If fanotify has now become the designated successor of inotify, that should be hinted in the inotify manpage, and if inotify is effectively feature-frozen, maybe that should be an extra status in the MAINTAINERS file? Max
On Mon, Sep 18, 2023 at 5:23 PM Jan Kara <jack@suse.cz> wrote: > > On Mon 18-09-23 15:57:43, Max Kellermann wrote: > > On Mon, Sep 18, 2023 at 2:40 PM Jan Kara <jack@suse.cz> wrote: > > > Note that since kernel 5.13 you > > > don't need CAP_SYS_ADMIN capability for fanotify functionality that is > > > more-or-less equivalent to what inotify provides. > > > > Oh, I missed that change - I remember fanotify as being inaccessible > > for unprivileged processes, and fanotify being designed for things > > like virus scanners. Indeed I should migrate my code to fanotify. > > > > If fanotify has now become the designated successor of inotify, that > > should be hinted in the inotify manpage, and if inotify is effectively > > feature-frozen, maybe that should be an extra status in the > > MAINTAINERS file? > > The manpage update is a good idea. I'm not sure about the MAINTAINERS > status - we do have 'Obsolete' but I'm reluctant to mark inotify as > obsolete as it's perfectly fine for existing users, we fully maintain it > and support it but we just don't want to extend the API anymore. Amir, what > are your thoughts on this? I think that the mention of inotify vs. fanotify features in fanotify.7 man page is decent - if anyone wants to improve it I won't mind. A mention of fanotify as successor in inotify.7 man page is not a bad idea - patches welcome. As to MAINTAINERS, I think that 'Maintained' feels right. We may consider 'Odd Fixes' for inotify and certainly for 'dnotify', but that sounds a bit too harsh for the level of maintenance they get. I'd like to point out that IMO, man-page is mainly aimed for the UAPI users and MAINTAINERS is mostly aimed at bug reporters and drive-by developers who submit small fixes. When developers wish to add a feature/improvement to a subsystem, they are advised to send an RFC with their intentions to the subsystem maintainers/list to get feedback on their design before starting to implement. Otherwise, the feature could be NACKed for several reasons other than "we would rather invest in the newer API". Bottom line - I don't see a strong reason to change anything, but I also do not object to improving man page nor to switching to 'Odd Fixes' status. Thanks, Amir.
On Mon, Sep 18, 2023 at 2:40 PM Jan Kara <jack@suse.cz> wrote:
> Is there any problem with using fanotify for you?
Turns out fanotify is unusable for me, unfortunately.
I have been using inotify to get notifications of cgroup events, but
the cgroup filesystem appears to be unsupported by fanotify: all
attempts to use fanotify_mark() on cgroup event files fail with
ENODEV. I think that comes from fanotify_test_fsid(). Filesystems
without a fsid work just fine with inotify, but fail with fanotify.
Since fanotify lacks important features, is it really a good idea to
feature-freeze inotify?
(By the way, what was not documented is that fanotify_init() can only
be used by unprivileged processes if the FAN_REPORT_FID flag was
specified. I had to read the kernel sources to figure that out - I
have no idea why this limitation exists - the code comment in the
kernel source doesn't explain it.)
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c index b6e6f6ab21f8..8a9096c5ebb1 100644 --- a/fs/notify/inotify/inotify_user.c +++ b/fs/notify/inotify/inotify_user.c @@ -797,6 +797,12 @@ SYSCALL_DEFINE3(inotify_add_watch, int, fd, const char __user *, pathname, return do_inotify_add_watch(fd, AT_FDCWD, pathname, mask); } +SYSCALL_DEFINE4(inotify_add_watch_at, int, fd, int, dfd, const char __user *, pathname, + u32, mask) +{ + return do_inotify_add_watch(fd, dfd, pathname, mask); +} + SYSCALL_DEFINE2(inotify_rm_watch, int, fd, __s32, wd) { struct fsnotify_group *group;