* [PATCH] libsepol: Use spaceship comparison operator when comparing ibpkeys
@ 2026-08-12 18:28 James Carter
2026-08-12 19:18 ` Stephen Smalley
0 siblings, 1 reply; 3+ messages in thread
From: James Carter @ 2026-08-12 18:28 UTC (permalink / raw)
To: selinux; +Cc: stephen.smalley.work, James Carter
The comparsion function for ibpkeys in kernel_to_common subtracts
the subnet_prefixes of the two ibpkeys which are unsigned 64-bit
values and stores the result in an int which might not be able
to contain the result.
Use the spaceship comparison operator to compare the subnet_prefxes
to avoid any issues.
Signed-off-by: James Carter <jwcart2@gmail.com>
---
libsepol/src/kernel_to_common.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libsepol/src/kernel_to_common.c b/libsepol/src/kernel_to_common.c
index 338dcef6..f338b588 100644
--- a/libsepol/src/kernel_to_common.c
+++ b/libsepol/src/kernel_to_common.c
@@ -585,7 +585,8 @@ static int ibpkey_data_cmp(const void *a, const void *b)
struct ocontext *const *aa = a;
struct ocontext *const *bb = b;
- rc = (*aa)->u.ibpkey.subnet_prefix - (*bb)->u.ibpkey.subnet_prefix;
+ rc = spaceship_cmp((*aa)->u.ibpkey.subnet_prefix,
+ (*bb)->u.ibpkey.subnet_prefix);
if (rc)
return rc;
--
2.55.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] libsepol: Use spaceship comparison operator when comparing ibpkeys
2026-08-12 18:28 [PATCH] libsepol: Use spaceship comparison operator when comparing ibpkeys James Carter
@ 2026-08-12 19:18 ` Stephen Smalley
2026-08-12 19:38 ` Stephen Smalley
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Smalley @ 2026-08-12 19:18 UTC (permalink / raw)
To: James Carter; +Cc: selinux
On Wed, Aug 12, 2026 at 2:28 PM James Carter <jwcart2@gmail.com> wrote:
>
> The comparsion function for ibpkeys in kernel_to_common subtracts
> the subnet_prefixes of the two ibpkeys which are unsigned 64-bit
> values and stores the result in an int which might not be able
> to contain the result.
>
> Use the spaceship comparison operator to compare the subnet_prefxes
> to avoid any issues.
>
> Signed-off-by: James Carter <jwcart2@gmail.com>
Acked-by: Stephen Smalley <stephen.smalley.work@gmail.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] libsepol: Use spaceship comparison operator when comparing ibpkeys
2026-08-12 19:18 ` Stephen Smalley
@ 2026-08-12 19:38 ` Stephen Smalley
0 siblings, 0 replies; 3+ messages in thread
From: Stephen Smalley @ 2026-08-12 19:38 UTC (permalink / raw)
To: James Carter; +Cc: selinux
On Wed, Aug 12, 2026 at 3:18 PM Stephen Smalley
<stephen.smalley.work@gmail.com> wrote:
>
> On Wed, Aug 12, 2026 at 2:28 PM James Carter <jwcart2@gmail.com> wrote:
> >
> > The comparsion function for ibpkeys in kernel_to_common subtracts
> > the subnet_prefixes of the two ibpkeys which are unsigned 64-bit
> > values and stores the result in an int which might not be able
> > to contain the result.
> >
> > Use the spaceship comparison operator to compare the subnet_prefxes
> > to avoid any issues.
> >
> > Signed-off-by: James Carter <jwcart2@gmail.com>
>
> Acked-by: Stephen Smalley <stephen.smalley.work@gmail.com>
Thanks, merged.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-08-12 19:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-12 18:28 [PATCH] libsepol: Use spaceship comparison operator when comparing ibpkeys James Carter
2026-08-12 19:18 ` Stephen Smalley
2026-08-12 19:38 ` Stephen Smalley
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.