* [PATCH] libselinux: selinux_restorecon(): fstat() if skip_multilink set
@ 2026-06-28 0:41 Stephen Smalley
2026-07-01 15:40 ` Petr Lautrbach
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Smalley @ 2026-06-28 0:41 UTC (permalink / raw)
To: selinux; +Cc: jwcart2, Stephen Smalley
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>
---
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] libselinux: selinux_restorecon(): fstat() if skip_multilink set
2026-06-28 0:41 [PATCH] libselinux: selinux_restorecon(): fstat() if skip_multilink set Stephen Smalley
@ 2026-07-01 15:40 ` Petr Lautrbach
2026-07-01 16:02 ` Petr Lautrbach
0 siblings, 1 reply; 3+ messages in thread
From: Petr Lautrbach @ 2026-07-01 15:40 UTC (permalink / raw)
To: Stephen Smalley, selinux; +Cc: jwcart2, Stephen Smalley
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] libselinux: selinux_restorecon(): fstat() if skip_multilink set
2026-07-01 15:40 ` Petr Lautrbach
@ 2026-07-01 16:02 ` Petr Lautrbach
0 siblings, 0 replies; 3+ messages in thread
From: Petr Lautrbach @ 2026-07-01 16:02 UTC (permalink / raw)
To: Stephen Smalley, selinux; +Cc: jwcart2, Stephen Smalley
Petr Lautrbach <lautrbach@redhat.com> writes:
> 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>
Merged, thanks!
>
>> ---
>> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-07-01 16:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-28 0:41 [PATCH] libselinux: selinux_restorecon(): fstat() if skip_multilink set Stephen Smalley
2026-07-01 15:40 ` Petr Lautrbach
2026-07-01 16:02 ` Petr Lautrbach
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.