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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C647CC43334 for ; Sat, 2 Jul 2022 05:59:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231880AbiGBF7S (ORCPT ); Sat, 2 Jul 2022 01:59:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231866AbiGBF7R (ORCPT ); Sat, 2 Jul 2022 01:59:17 -0400 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60B4E2AC57 for ; Fri, 1 Jul 2022 22:59:16 -0700 (PDT) Received: by mail-pg1-x536.google.com with SMTP id s27so4222193pga.13 for ; Fri, 01 Jul 2022 22:59:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=uZ0xpOFi19oX2NSsd7/3TN5SKlTWmXFBnbfZWWRN3+o=; b=Eu9CyMWbZ5r0wWq/2vWTdeuHvjbq3lzLM8qxdfhYgWOlhTU3MWYNiq/nGjZEwwyBqj kt5fJLzpcRS9wANXNgnufo+3+D9iPaKhZDdh6g9SctqqdRGgeM3ToZvsZzY1vIHP2siD hrfkXnBpdFTsvmN54NqOpVB/gbVypEYkTCLHrMnyL7qQq57xSbavAvJPXK5ALm/BUdmi WuM+iDyHOGhXuJWR8gKfBmeOTjfJSrrMimjdLG68m+YjQrxw78bbSUO0T6vEtZVjhzPA 0TicxE3MVeJG/jrq0LrViJKPCE8QGNMab5y2b+CFME+lBd0JFnDsv61myJust/1BQU47 AjoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=uZ0xpOFi19oX2NSsd7/3TN5SKlTWmXFBnbfZWWRN3+o=; b=W1yyhUke+zHU8VMldGPPCJ24wpCgctmVKrqFbOHMEr+Bcaq0plOKCElE9hOsD3T5fZ 2FMMf1qYPO7BxY/c6acjN+zJwrditx95rTS3Es2Oi1iyHhhAZEWIW3BO7g+6jXPmwtzK Sv/ZpNdbL51TtMT0j42Zh09pQ8Ovf9qSdx6AxMcPlsDBt5xGgZCXqoyOQu6/0uJdScZ1 YtzLF1OM5P06Bn5hzj3bzEctok7068uEeCyyByfad6Cdz68k7fbmXw26CJJNvNlGlbqJ WdKxNp6ao7TOD/oxTCoS3X5XZjY9PTJZFYTf+G2oBhxoYsBz7kaptvC2qaE4eTkjZgvN 86Xg== X-Gm-Message-State: AJIora+Ojjf29Pq8GtbFKRSG50xKzR5XpMW7+r282TPpchp7aa0BjOmI qw8NWh66sjzaKo+W9ui6ZUUKZIhXQNB5Qw== X-Google-Smtp-Source: AGRyM1spqZVUMiNenqn9cV3q+dhQ3e3Wwj4F9jDGqOmaq/Sk154X2lfHcqo1SDMuZaB0s1dyC5Y4Mg== X-Received: by 2002:a05:6a00:451c:b0:525:b802:bc3d with SMTP id cw28-20020a056a00451c00b00525b802bc3dmr24626944pfb.43.1656741555709; Fri, 01 Jul 2022 22:59:15 -0700 (PDT) Received: from google.com ([2401:fa00:9:211:4b84:6be1:8a0a:44c9]) by smtp.gmail.com with ESMTPSA id l12-20020a17090a49cc00b001ec9f9fe028sm5147656pjm.46.2022.07.01.22.59.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Jul 2022 22:59:15 -0700 (PDT) Date: Sat, 2 Jul 2022 15:59:04 +1000 From: Matthew Bobrowski To: Amir Goldstein Cc: Jan Kara , linux-fsdevel , Linux API Subject: Re: [PATCH] fanotify: refine the validation checks on non-dir inode mask Message-ID: References: <20220627174719.2838175-1-amir73il@gmail.com> <20220628092725.mfwvdu4sk72jov5x@quack3> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-api@vger.kernel.org On Tue, Jun 28, 2022 at 08:22:28PM +0300, Amir Goldstein wrote: > On Tue, Jun 28, 2022 at 12:27 PM Jan Kara wrote: > > > > On Mon 27-06-22 20:47:19, Amir Goldstein wrote: > > > Commit ceaf69f8eadc ("fanotify: do not allow setting dirent events in > > > mask of non-dir") added restrictions about setting dirent events in the > > > mask of a non-dir inode mark, which does not make any sense. > > > > > > For backward compatibility, these restictions were added only to new > > > (v5.17+) APIs. > > > > > > It also does not make any sense to set the flags FAN_EVENT_ON_CHILD or > > > FAN_ONDIR in the mask of a non-dir inode. Add these flags to the > > > dir-only restriction of the new APIs as well. > > > > > > Move the check of the dir-only flags for new APIs into the helper > > > fanotify_events_supported(), which is only called for FAN_MARK_ADD, > > > because there is no need to error on an attempt to remove the dir-only > > > flags from non-dir inode. > > > > > > Fixes: ceaf69f8eadc ("fanotify: do not allow setting dirent events in mask of non-dir") > > > Link: https://lore.kernel.org/linux-fsdevel/20220627113224.kr2725conevh53u4@quack3.lan/ > > > Signed-off-by: Amir Goldstein > > > > Thanks! I've taken the patch to my tree. > > > > Honza > > > > > [1] https://github.com/amir73il/ltp/commits/fan_enotdir > > > [2] https://github.com/amir73il/man-pages/commits/fanotify_target_fid > > Mathew and Jan, > > Please let me know if I can keep your RVB on the man page patch for > FAN_REPORT_TARGET_FID linked above. > > The only change is an update to the ENOTDIR section which ends up like this: > > ENOTDIR > flags contains FAN_MARK_ONLYDIR, and dirfd and pathname > do not specify a directory. > > ENOTDIR > mask contains FAN_RENAME, and dirfd and pathname do not > specify a directory. > > ENOTDIR > flags contains FAN_MARK_IGNORE, or the fanotify group > was initialized with > flag FAN_REPORT_TARGET_FID, and mask contains directory > entry modification > events (e.g., FAN_CREATE, FAN_DELETE), or directory event flags > (e.g., FAN_ONDIR, FAN_EVENT_ON_CHILD), > and dirfd and pathname do not specify a directory. Sorry for the delay. This looks fine to me. /M