All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heiko Carstens <hca@linux.ibm.com>
To: Amir Goldstein <amir73il@gmail.com>
Cc: Jan Kara <jack@suse.cz>, ltp@lists.linux.it
Subject: Re: [LTP] [PATCH 3/4] fanotify24: Add test for FAN_PRE_ACCESS and FAN_DENY_ERRNO
Date: Fri, 28 Feb 2025 21:11:17 +0100	[thread overview]
Message-ID: <20250228201117.11519A64-hca@linux.ibm.com> (raw)
In-Reply-To: <20250210151316.246079-4-amir73il@gmail.com>

On Mon, Feb 10, 2025 at 04:13:15PM +0100, Amir Goldstein wrote:
> Fork the test fanotify24 from test fanotify03, replacing the
> permission event FAN_ACCESS_PERM with the new pre-content event
> FAN_PRE_ACCESS.
> 
> The test is changed to use class FAN_CLASS_PRE_CONTENT, which is
> required for FAN_PRE_ACCESS and this class also enabled the response
> with cutomer error code FAN_DENY_ERRNO.
> 
> Unlike FAN_ACCESS_PERM, FAN_PRE_ACCESS is also created on write()
> system call.  The test case expected results are adjusted to
> respond with the default error (EPERM) to open() and write() and
> to respond with custom errors (EIO, EBUSY) to read() and execve().
> 
> Not all fs support pre-content events, so run on all filesystems
> to excercise FAN_PRE_ACCESS on all supported filesystems.
> 
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> ---
>  include/lapi/fanotify.h                       |   7 +
>  runtest/syscalls                              |   1 +
>  testcases/kernel/syscalls/fanotify/.gitignore |   1 +
>  testcases/kernel/syscalls/fanotify/fanotify.h |   3 +
>  .../kernel/syscalls/fanotify/fanotify24.c     | 433 ++++++++++++++++++
>  5 files changed, 445 insertions(+)
>  create mode 100644 testcases/kernel/syscalls/fanotify/fanotify24.c
> 
> diff --git a/include/lapi/fanotify.h b/include/lapi/fanotify.h
> index e5b930f4e..9076685e8 100644
> --- a/include/lapi/fanotify.h
> +++ b/include/lapi/fanotify.h
> @@ -124,6 +124,13 @@
>  #define FAN_EPIDFD		-2
>  #endif
>  
> +/* errno other than EPERM can specified in upper byte of deny response */
> +#ifndef FAN_DENY_ERRNO
> +#define FAN_ERRNO(err) (((((__u32)(err)) & 0xff) << 24))
> +#define FAN_DENY_ERRNO(err) (FAN_DENY | FAN_ERRNO(err))
> +#define FAN_RESPONSE_ERRNO(res) ((int)((res) >> 24))
> +#endif
> +

This does not work with latest+greatest kernel headers since there
FAN_DENY_ERRNO is defined but FAN_RESPONSE_ERRNO is not. Therefore
this ends up in a compile error:

fanotify24.c: In function ‘expected_errno’:
fanotify24.c:166:24: error: implicit declaration of function ‘FAN_RESPONSE_ERRNO’; did you mean ‘FAN_DENY_ERRNO’? [-Wimplicit-function-declaration]
  166 |                 return FAN_RESPONSE_ERRNO(response);
      |                        ^~~~~~~~~~~~~~~~~~
      |                        FAN_DENY_ERRNO

FWIW, converting the above to:

/* errno other than EPERM can specified in upper byte of deny response */
#ifndef FAN_DENY_ERRNO
#define FAN_ERRNO(err) (((((__u32)(err)) & 0xff) << 24))
#define FAN_DENY_ERRNO(err) (FAN_DENY | FAN_ERRNO(err))
#endif

#ifndef FAN_RESPONSE_ERRNO
#define FAN_RESPONSE_ERRNO(res) ((int)((res) >> 24))
#endif

works for me.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  parent reply	other threads:[~2025-02-28 20:11 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-10 15:13 [LTP] [PATCH 0/4] New tests for fanotify pre-content events Amir Goldstein
2025-02-10 15:13 ` [LTP] [PATCH 1/4] fanotify14: Test invalid init flags with permission and " Amir Goldstein
2025-02-10 15:19   ` Jan Kara
2025-02-11 17:55     ` Petr Vorel
2025-02-10 15:13 ` [LTP] [PATCH 2/4] fanotify03: Add test cases for permission events on children Amir Goldstein
2025-02-10 15:24   ` Jan Kara
2025-02-10 16:55     ` Amir Goldstein
2025-02-11 17:56       ` Petr Vorel
2025-02-12 12:35         ` Jan Kara
2025-02-13  7:54           ` Petr Vorel
2025-02-10 15:13 ` [LTP] [PATCH 3/4] fanotify24: Add test for FAN_PRE_ACCESS and FAN_DENY_ERRNO Amir Goldstein
2025-02-10 15:43   ` Jan Kara
2025-02-10 17:06     ` Amir Goldstein
2025-02-11 19:09       ` Petr Vorel
2025-02-11 20:12         ` Amir Goldstein
2025-02-20 20:42           ` Petr Vorel
2025-02-21 13:26             ` Petr Vorel
2025-02-21 13:37               ` Amir Goldstein
2025-02-28 20:11   ` Heiko Carstens [this message]
2025-02-10 15:13 ` [LTP] [PATCH 4/4] fanotify24: Test open for write of executable files with pre-content watch Amir Goldstein
2025-02-10 15:59   ` Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250228201117.11519A64-hca@linux.ibm.com \
    --to=hca@linux.ibm.com \
    --cc=amir73il@gmail.com \
    --cc=jack@suse.cz \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.