All of lore.kernel.org
 help / color / mirror / Atom feed
From: linuxtestproject.agent@gmail.com
To: Edvard Conrad <edvard@tuta.io>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] syscalls/fanotify26: Add test for nested permission events
Date: Tue, 27 Oct 2026 23:20:28 +0000	[thread overview]
Message-ID: <20261027232028.5693-1-linuxtestproject.agent@gmail.com> (raw)
In-Reply-To: <P4yrQBp--N-9@tuta.io>

Hi Edvard,

On Tue, Oct 27, 2026 at 08:37:01PM +0100, Edvard Conrad wrote:
> syscalls/fanotify26: Add test for nested permission events

> --- /dev/null
> +++ b/testcases/kernel/syscalls/fanotify/fanotify26.c
> @@ -0,0 +1,185 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*\
> + * Check that a permission event on a stacked filesystem does not deadlock the

A copyright header block ("/* Copyright (c) 2026 Edvard Conrad
<edvard@tuta.io> */") is missing after the SPDX license identifier.

> +	if (tc->mark_backing && filesystem_mark_unsupported) {
> +		tst_res(TCONF, "FAN_MARK_FILESYSTEM not supported");
> +		return;
> +	}
> +
> +	fd_notify = SAFE_FANOTIFY_INIT(FAN_CLASS_CONTENT, O_RDONLY);
> +
> +	SAFE_FANOTIFY_MARK(fd_notify, FAN_MARK_ADD | FAN_MARK_FILESYSTEM,
> +			   FAN_OPEN_PERM, AT_FDCWD, OVL_MNT);

Both test cases use FAN_MARK_FILESYSTEM on OVL_MNT, so gating
filesystem_mark_unsupported on tc->mark_backing causes the first test case to
fail with TBROK when FAN_MARK_FILESYSTEM is unsupported on overlayfs or in
the kernel. Use REQUIRE_MARK_TYPE_SUPPORTED_ON_FS(FAN_MARK_FILESYSTEM,
OVL_MNT) and REQUIRE_MARK_TYPE_SUPPORTED_ON_FS(FAN_MARK_FILESYSTEM,
BACKING_MNT) in setup() and drop filesystem_mark_unsupported.

> +		fd = open(OVL_FILE, O_RDONLY);
> +		if (fd >= 0)
> +			SAFE_CLOSE(fd);
> +		exit(0);
> +	}
> +
> +	/* The opener sleeps in the kernel once its event is queued. */
> +	if (TST_PROCESS_STATE_WAIT(opener, 'D', WAIT_MSEC)) {
> +		SAFE_CLOSE(fd_notify);
> +		tst_brk(TBROK, "Open generated no permission event");
> +	}

Use "if (fd != -1)" to check file descriptor validity in opener. Also,
SAFE_CLOSE(fd_notify) before tst_brk() is redundant because cleanup() already
closes fd_notify.

> +	reader = SAFE_FORK();
> +	if (!reader) {
> +		answer_one_event();
> +		exit(0);
> +	}
> +
> +	if (TST_PROCESS_STATE_WAIT(reader, 'Z', WAIT_MSEC)) {
> +		tst_res(TFAIL,
> +			"Listener blocked in read() by a nested event");
> +		SAFE_KILL(reader, SIGKILL);
> +	} else {
> +		tst_res(TPASS, "Listener answered the event");
> +	}
> +
> +	SAFE_WAITPID(reader, NULL, 0);

Inferring TPASS from the child reaching 'Z' state and reaping it with
SAFE_WAITPID(reader, NULL, 0) hides abnormal child termination. Call
tst_res(TPASS, "Listener answered the event") at the end of
answer_one_event() in the child, and only call SAFE_WAITPID(reader, NULL, 0)
after SAFE_KILL(reader, SIGKILL), letting the library reap the children on
the normal path.

> +	/* Releases whatever is still queued, so the opener can finish. */
> +	SAFE_CLOSE(fd_notify);
> +	fd_notify = -1;

Setting fd_notify = -1 is redundant because SAFE_CLOSE() already resets its
argument to -1.

> +static void cleanup(void)
> +{
> +	if (fd_notify >= 0)
> +		SAFE_CLOSE(fd_notify);
> +}

Use "if (fd_notify != -1)" instead of "if (fd_notify >= 0)".

Verdict - Needs revision

---
Note:

The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.

Regards,
LTP AI Reviewer

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

  reply	other threads:[~2026-10-27 23:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-27 19:37 [LTP] [PATCH][STAGING] syscalls/fanotify26: Add test for nested permission events Edvard Conrad via ltp
2026-10-27 23:20 ` linuxtestproject.agent [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-10-28  6:48 [LTP] [PATCH v2][STAGING] " Edvard Conrad via ltp
2026-10-28  9:15 ` [LTP] " linuxtestproject.agent
2026-10-28 21:06   ` Edvard Conrad via ltp

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=20261027232028.5693-1-linuxtestproject.agent@gmail.com \
    --to=linuxtestproject.agent@gmail.com \
    --cc=edvard@tuta.io \
    --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.