Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp613425iog; Mon, 13 Jun 2022 09:09:31 -0700 (PDT) X-Google-Smtp-Source: AGRyM1szHW0eMhG+LVE49NoVj60aLgDZ2y2nVh5HAJymCo/2iEWrsElB2UziD1YGFwcoXPhNygv/ X-Received: by 2002:a17:903:c3:b0:163:bfde:eec3 with SMTP id x3-20020a17090300c300b00163bfdeeec3mr505585plc.152.1655136571439; Mon, 13 Jun 2022 09:09:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655136571; cv=none; d=google.com; s=arc-20160816; b=Q0l979/KYIQTMmkVoWFLShUhSVrGRWSyrPVINAaB5p6lCKVMr59obG16JG4Zw5kWdI 7HlToGbPqpwCG7qX6tiv4/KYJ1K3dDAToIK2sZzCMlL3wA5ATy/qmHE9whoo12X2RMjL cOkGpxJKb6o//lBbMPZ4uBcoArFS2f+VgxcNr/4y6tJOM/Jt0i5vKtO/kZMw8IX1r77H vNQUeT9o3yur7NlncqcI3hge9ADuGdB8H+wcCUl7VcL1QGjZs8bt0ERLn94akmY7a4IJ bLdkZW66RaWm8LqV2zTSYCwIuN9+Oghtc4ufgA3/igfIMXM10Y+dGDvW3UQ65z9TQPju Ne+Q== 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=lGm7+Cu9P/xVFpbaHHPQxglyp7llvD7sBto9ot+73bw=; b=RSVYUGguvgcCWUOheyMRNqXn3bTut71ZOkzXojpjAett258LHMO5hfIgJIwhHdq4rz lmpYvmJSkp/UrYR46+Xg9eNjznYCITFAjgPk4dUUVVWTY50OGxpN1GMuRrJF2EiZd94Q /XDQ2Jqmqrdgvy+MFNybjn7FgfjovuusMe9vFTSJdCwuuf7KwUIn9DDfxiamLY4SJ3OA B7bGlsmRAnpVok/yEAoeFZW7ZPgZjpxmmbjlTqsUVAWiK3fRgF2vYyr+RYSff7gdX/Gd XVj7+Bi5tvqw2knQLnvSuq9P0BrzlBPyN9G8wbP56+5DSD8/K6ucjut2FItpLlbXaTJI gWwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Enm905kJ; 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 c3-20020a637243000000b003fe25580540si10462111pgn.476.2022.06.13.09.09.16; Mon, 13 Jun 2022 09:09:31 -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=Enm905kJ; 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 S1352661AbiFMLUg (ORCPT + 99 others); Mon, 13 Jun 2022 07:20:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352637AbiFMLOJ (ORCPT ); Mon, 13 Jun 2022 07:14:09 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C64603668B; Mon, 13 Jun 2022 03:36:39 -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 9D588B80EA3; Mon, 13 Jun 2022 10:36:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EBC9FC34114; Mon, 13 Jun 2022 10:36:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655116596; bh=Tfe30r3AL3i3dD2u9nHkAnXiuJJGjyaUuysKtWURYiE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Enm905kJ9ITA6M1KAA0diLaZwQ1ze/eurdxlE3Gq05X/ImtfpwP+Kefq/RiDyiaCk oCUzT5yhcQfxBEuBYGxfkpzN+d6HBc34Zy6jOaB/P9dO2lXOeCKik5IPxWKOVPMRVA YGTtFkKDMIPbvKWry8uilVdw/dV92yO3xZUOT+uY= 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.4 105/411] inotify: show inotify mask flags in proc fdinfo Date: Mon, 13 Jun 2022 12:06:18 +0200 Message-Id: <20220613094931.825519088@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094928.482772422@linuxfoundation.org> References: <20220613094928.482772422@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 1e2bfd26b352..7df9ad4d8433 100644 --- a/fs/notify/fdinfo.c +++ b/fs/notify/fdinfo.c @@ -84,16 +84,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 3f246f7b8a92..8b8bf52dd08b 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_event(struct fsnotify_group *group, diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c index 81ffc8629fc4..b949b2c02f4b 100644 --- a/fs/notify/inotify/inotify_user.c +++ b/fs/notify/inotify/inotify_user.c @@ -86,7 +86,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