From: Petr Lautrbach <lautrbach@redhat.com>
To: Stephen Smalley <stephen.smalley.work@gmail.com>,
selinux@vger.kernel.org
Cc: jwcart2@gmail.com, Stephen Smalley <stephen.smalley.work@gmail.com>
Subject: Re: [PATCH] libselinux: selinux_restorecon(): fstat() if skip_multilink set
Date: Wed, 01 Jul 2026 17:40:54 +0200 [thread overview]
Message-ID: <87tsqisoop.fsf@redhat.com> (raw)
In-Reply-To: <20260628004130.28649-1-stephen.smalley.work@gmail.com>
Stephen Smalley <stephen.smalley.work@gmail.com> writes:
> selinux_restorecon() must call fstat() on every entry if skip_multilink
> is set to fetch the st_nlink value.
>
> Signed-off-by: Stephen Smalley <stephen.smalley.work@gmail.com>
Acked-by: Petr Lautrbach <lautrbach@redhat.com>
> ---
> libselinux/src/selinux_restorecon.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/libselinux/src/selinux_restorecon.c b/libselinux/src/selinux_restorecon.c
> index 0159fb7f..b34d8e60 100644
> --- a/libselinux/src/selinux_restorecon.c
> +++ b/libselinux/src/selinux_restorecon.c
> @@ -1271,13 +1271,15 @@ static int walk_next(struct rest_state *state, int *ent_fd, int *rd_fd,
>
> /*
> * Skip fstat() when d_type already gives the file type and
> - * neither xdev (st_dev) nor add_assoc (st_ino) is needed.
> + * none of xdev (st_dev), add_assoc (st_ino), or
> + * skip_multilink (st_nlink) are needed.
> * Directories always fstat for cycle detection and walk_push().
> */
> mode_t mode_from_dtype = d_type_to_mode(de->d_type);
> bool need_fstat =
> mode_from_dtype == 0 || S_ISDIR(mode_from_dtype) ||
> - state->flags.set_xdev || state->flags.add_assoc;
> + state->flags.set_xdev || state->flags.add_assoc ||
> + state->flags.skip_multilink;
>
> if (need_fstat) {
> if (fstat(fd, ent_sb) < 0) {
> --
> 2.54.0
next prev parent reply other threads:[~2026-07-01 15:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-28 0:41 [PATCH] libselinux: selinux_restorecon(): fstat() if skip_multilink set Stephen Smalley
2026-07-01 15:40 ` Petr Lautrbach [this message]
2026-07-01 16:02 ` Petr Lautrbach
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=87tsqisoop.fsf@redhat.com \
--to=lautrbach@redhat.com \
--cc=jwcart2@gmail.com \
--cc=selinux@vger.kernel.org \
--cc=stephen.smalley.work@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox