Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2152251iof; Tue, 7 Jun 2022 21:30:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwupnkGbV7MVJd58n8PrhCLYzHG1MMnjnCUDOPeJAyPXjC0W5bbuzhbLo0jsz5dGdjOzM8O X-Received: by 2002:a65:4149:0:b0:3fb:1476:d0dc with SMTP id x9-20020a654149000000b003fb1476d0dcmr28012054pgp.373.1654662626237; Tue, 07 Jun 2022 21:30:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654662626; cv=none; d=google.com; s=arc-20160816; b=LFh4CGJgEq6jKNpR1nqs0FWdjNfDlTZmqr0DJWaNlilVbMz38okOJtr7tN7GITcAym aoAT4q/BQ27KV6aaIZrsVcRnwz9PqK4GFcu4FLwLSYmcVbZxqRTV7vFDa9cexnLgwwSS vTBy2pIOAvDF8tD4tLtsGrA2vLogfx4tGo+hvxBzTlVcsPzIH53TRKowI1glktHm80La Ygsx69TsE2uMlBEMhBRHCPJxBN/cBHgITC+JyxPIM+cEREPsyTZ4PmO2VCV19FDDt3hs s4JyHzkWZI5KAZAyvgGd2ljF7C5GYLNGyR9n9XfuP3pM+eOUiIB7kJbXTs6tbcK817Xo acfg== 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=VeZGLy6zYf2gubDgS64xHp586a0OEkRjwF8fdxzK/1U=; b=JtoGsUK+WmGnwNuVFL+x36GB9Xu9AtEWeDdDzTlvzIORG/5k42WrgAatfEPVfg6ipA kEisXNQeWudQln84/9e/OjWey44JzHTbN6XnXHECkqpZtIVaVPEsue2OGhXWd8Xp2Hb6 EirT/ZEtRqyJogLSOZee/HMfCkFTC9GGlNHud+4xKXkHguFzpF12Y+LkF7/BxEq8OgG5 s14qBWfvPYAZi5z+LLJ1GdDNfag0MrUJ78lkK8+mMDtXnZ/k5NRpVa624cBUeGibx9rL UOPIBawA1oI6PhgNNaOp8y+VrFCckaS2f6Z/XUEWF24XS3MtdKgPjx77DpMYez3DhReD n3XQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XbpO4iT2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id q2-20020a056a00088200b0050ab6783001si30905156pfj.152.2022.06.07.21.30.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:30:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XbpO4iT2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 43C591F0A4D; Tue, 7 Jun 2022 20:59:05 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348052AbiFGRkd (ORCPT + 99 others); Tue, 7 Jun 2022 13:40:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347487AbiFGRas (ORCPT ); Tue, 7 Jun 2022 13:30:48 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FB00113A3D; Tue, 7 Jun 2022 10:27:07 -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 ams.source.kernel.org (Postfix) with ESMTPS id 20C02B822B7; Tue, 7 Jun 2022 17:27:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7095EC385A5; Tue, 7 Jun 2022 17:27:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654622824; bh=xDbiBhnCqp6Zqc4b6hJexotsYBtBCxZDUl1ChaiEnI8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XbpO4iT2YSntpj6vX8CE+lIhmMZ0lKkQD6fEwF16YkQib4MiGj4sB/2Nq3UxhIA34 QVYA3NjskEpZ13ND7o/faznl72pBg3vBxl0Qh0Rbira7FxPrNm5ixzQnBguI6UD4Fk UcThvoVkwg+a7K0GXEoVfV5aieXIbuuEmYLWjqas= 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 5.10 159/452] inotify: show inotify mask flags in proc fdinfo Date: Tue, 7 Jun 2022 19:00:16 +0200 Message-Id: <20220607164913.298602024@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164908.521895282@linuxfoundation.org> References: <20220607164908.521895282@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=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 f0d6b54be412..765b50aeadd2 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(fsnotify_conn_inode(mark->connector)); 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 2007e3711916..8f00151eb731 100644 --- a/fs/notify/inotify/inotify.h +++ b/fs/notify/inotify/inotify.h @@ -22,6 +22,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_inode_event(struct fsnotify_mark *inode_mark, diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c index 5f6c6bf65909..32b6b97021be 100644 --- a/fs/notify/inotify/inotify_user.c +++ b/fs/notify/inotify/inotify_user.c @@ -88,7 +88,7 @@ static inline __u32 inotify_arg_to_mask(struct inode *inode, u32 arg) mask |= FS_EVENT_ON_CHILD; /* 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