All of lore.kernel.org
 help / color / mirror / Atom feed
* Question about libselinux *_with_level functions
@ 2026-03-12 18:10 Filippo Bonazzi
  2026-05-27 17:46 ` Stephen Smalley
  0 siblings, 1 reply; 6+ messages in thread
From: Filippo Bonazzi @ 2026-03-12 18:10 UTC (permalink / raw)
  To: selinux; +Cc: selinux

[-- Attachment #1: Type: text/plain, Size: 1986 bytes --]

Hi all,

While looking into an openSUSE SELinux bug report[0] I ended up looking at the
*with_level functions of libselinux:

     int get_ordered_context_list_with_level(const char *user, const char *level, const char *fromcon, char ***list);
     int get_default_context_with_level(const char *user, const char *level, const char *fromcon, char **newcon);

The function names and the man page seem to suggest that these functions should
apply the provided level parameter to the context. However, in my testing with
libselinux-3.10, this does not happen: both functions return the context without
an applied level.

Simple example:

     char *seuser = "unconfined_u";
     char *level = "s0-s0:c0.c1023";
     char *newcon_with_level = NULL;
     char *newcon_without_level = NULL;
     get_default_context_with_level(seuser, level, NULL, &newcon_with_level);
     get_default_context(seuser, NULL, &newcon_without_level);
     printf("With: %s\n", newcon_with_level);
     printf("Without: %s\n", newcon_without_level);

> With:    unconfined_u:unconfined_r:unconfined_t:s0
> Without: unconfined_u:unconfined_r:unconfined_t:s0

newcon_with_level and newcon_without_level should be different, but they are
identical.

It looks to me like the implementation of get_ordered_context_list_with_level()
is just not fully handling the level parameter. The parameter is only used to
get to define the newfromcon parameter, but the level information is then
stripped anyway by the call to get_ordered_context_list().

Am I misunderstanding something?

Thank you,

Filippo

P.S. I previously reported this issue on Github [1] in a bit less detail, but I
hope to get better answers asking this directly here.

[0] https://bugzilla.suse.com/show_bug.cgi?id=1259191
[1] https://github.com/SELinuxProject/selinux/issues/508

-- 
Filippo Bonazzi
Security Engineer                        suse.com
8257 4398 947A 2DBE F21D 76E6 937A 63F0 5B36 46D9

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 525 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-11-05 14:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-12 18:10 Question about libselinux *_with_level functions Filippo Bonazzi
2026-05-27 17:46 ` Stephen Smalley
2026-11-05 11:03   ` Filippo Bonazzi
2026-11-05 14:18     ` Stephen Smalley
2026-11-05 14:25       ` Stephen Smalley
2026-11-05 14:45         ` Filippo Bonazzi

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.