Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp576559iog; Mon, 13 Jun 2022 08:26:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTJTvDjiUjUC19wedxiX5K7oAawOqXvNWmtAqV7I+4zDFh0/14WGgLG3zsIoZ5BDEAJTdi X-Received: by 2002:a17:906:7a5e:b0:6fe:d93d:21a3 with SMTP id i30-20020a1709067a5e00b006fed93d21a3mr357801ejo.596.1655134019033; Mon, 13 Jun 2022 08:26:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655134019; cv=none; d=google.com; s=arc-20160816; b=FERR/PxqIKCyfKDbv2y7nbO8mMOqYcX/WUpKQQqweS/+BI+rFPM2o0HZLV/Wk6OsTX gc2HIpc/54O7tKpmfU6zkdvyIiSYG4t0lY4DISHL+gVBSh3SSLavZqrdN52Vwxva98qB PrUMVRGNg1PrV0EvuxZtaiipzj0w5jgNeLBuYYnfA+437vQ6dcWi5ajp6bJny1fwl34r vf1BRpJMdy8QyMNPwEmpaU5tYttxk4BvI62rbtqsS7ZhQ/SftdRaXE3jM3egLTuVd5ux DyEood/Pf25jCWxdUkPZC/6whxh+Em1FZFLwbjbdyKIhvMeN3gu7FMqg0fESX9Lh9HpE iB5w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=stZB0ZOVnWSE08X3sd8uLT2YOd21b8d7qL+81Djzzio=; b=RKYh92HHwBdksRZs+kthDdYX0aJLh3LGvYVTN5bcGB0dI+L+JDcMsCyF16YpCzm6p3 +N/r69SkIQFhQlk78TwksIDkGZr3YFqUP4QKsrhiqgkuxSHeRWavMIyqVXpEj8bStiOR PtwkHrEdqknDUjSQ/qoLybqVA/vVO7D3ZZKfxdHm7OXjlzmuja9bD94rW+akl6vVcdhM VFukFCQN2+vz1JR3ZYKRTnp/0gZPQ7md1p8pnAtC3uoJyVb7YoSCONJfbUrM9GzlDAOV YgOKknEJ8G31haIVoHWE8i9zIJ/E1hlUwBWhd/lD5wWVmz9o/SsA+f7fnXF18mB3PRol 7Rcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WAOfOock; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j30-20020a170906535e00b00715785bb696si6056062ejo.447.2022.06.13.08.26.33; Mon, 13 Jun 2022 08:26:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WAOfOock; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242226AbiFMKTs (ORCPT + 99 others); Mon, 13 Jun 2022 06:19:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242906AbiFMKSx (ORCPT ); Mon, 13 Jun 2022 06:18:53 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DFC520F48; Mon, 13 Jun 2022 03:16:28 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 1A9D2CE1173; Mon, 13 Jun 2022 10:16:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 06659C34114; Mon, 13 Jun 2022 10:16:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655115385; bh=F2yAfrnatgMjdwrZbg2V8vHGdPEi+gb8YFtfCAaM1uA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WAOfOockpp7QUei5PYAhKzznU503MGkcgL/MLVd4Xx0fQlmggoCMqqrbU6yHvheTJ Bm2d43+nJY5BLDIgKWGqJrZ+7UAv62Yl+YVb401Or0K2P9O/2NWjcBqieMbpU4R2CI lvWARU9zPLrv07Lc9VPEh7VeZqY6MCqgyWQD6PDM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Amir Goldstein , Jan Kara , Sasha Levin Subject: [PATCH 4.9 045/167] inotify: show inotify mask flags in proc fdinfo Date: Mon, 13 Jun 2022 12:08:39 +0200 Message-Id: <20220613094851.500091359@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094840.720778945@linuxfoundation.org> References: <20220613094840.720778945@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Amir Goldstein [ Upstream commit a32e697cda27679a0327ae2cafdad8c7170f548f ] The inotify mask flags IN_ONESHOT and IN_EXCL_UNLINK are not "internal to kernel" and should be exposed in procfs fdinfo so CRIU can restore them. Fixes: 6933599697c9 ("inotify: hide internal kernel bits from fdinfo") Link: https://lore.kernel.org/r/20220422120327.3459282-2-amir73il@gmail.com Signed-off-by: Amir Goldstein Signed-off-by: Jan Kara Signed-off-by: Sasha Levin --- fs/notify/fdinfo.c | 11 ++--------- fs/notify/inotify/inotify.h | 12 ++++++++++++ fs/notify/inotify/inotify_user.c | 2 +- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/fs/notify/fdinfo.c b/fs/notify/fdinfo.c index fd98e5100cab..317b7e7eb2e7 100644 --- a/fs/notify/fdinfo.c +++ b/fs/notify/fdinfo.c @@ -83,16 +83,9 @@ static void inotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark) inode_mark = container_of(mark, struct inotify_inode_mark, fsn_mark); inode = igrab(mark->inode); if (inode) { - /* - * IN_ALL_EVENTS represents all of the mask bits - * that we expose to userspace. There is at - * least one bit (FS_EVENT_ON_CHILD) which is - * used only internally to the kernel. - */ - u32 mask = mark->mask & IN_ALL_EVENTS; - seq_printf(m, "inotify wd:%x ino:%lx sdev:%x mask:%x ignored_mask:%x ", + seq_printf(m, "inotify wd:%x ino:%lx sdev:%x mask:%x ignored_mask:0 ", inode_mark->wd, inode->i_ino, inode->i_sb->s_dev, - mask, mark->ignored_mask); + inotify_mark_user_mask(mark)); show_mark_fhandle(m, inode); seq_putc(m, '\n'); iput(inode); diff --git a/fs/notify/inotify/inotify.h b/fs/notify/inotify/inotify.h index ed855ef6f077..b0440287d7dd 100644 --- a/fs/notify/inotify/inotify.h +++ b/fs/notify/inotify/inotify.h @@ -20,6 +20,18 @@ static inline struct inotify_event_info *INOTIFY_E(struct fsnotify_event *fse) return container_of(fse, struct inotify_event_info, fse); } +/* + * INOTIFY_USER_FLAGS represents all of the mask bits that we expose to + * userspace. There is at least one bit (FS_EVENT_ON_CHILD) which is + * used only internally to the kernel. + */ +#define INOTIFY_USER_MASK (IN_ALL_EVENTS | IN_ONESHOT | IN_EXCL_UNLINK) + +static inline __u32 inotify_mark_user_mask(struct fsnotify_mark *fsn_mark) +{ + return fsn_mark->mask & INOTIFY_USER_MASK; +} + extern void inotify_ignored_and_remove_idr(struct fsnotify_mark *fsn_mark, struct fsnotify_group *group); extern int inotify_handle_event(struct fsnotify_group *group, diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c index 69d1ea3d292a..bb60bf1527e4 100644 --- a/fs/notify/inotify/inotify_user.c +++ b/fs/notify/inotify/inotify_user.c @@ -97,7 +97,7 @@ static inline __u32 inotify_arg_to_mask(u32 arg) mask = (FS_IN_IGNORED | FS_EVENT_ON_CHILD | FS_UNMOUNT); /* mask off the flags used to open the fd */ - mask |= (arg & (IN_ALL_EVENTS | IN_ONESHOT | IN_EXCL_UNLINK)); + mask |= (arg & INOTIFY_USER_MASK); return mask; } -- 2.35.1