On Dec 16, 2024 =?UTF-8?q?Christian=20G=C3=B6ttsche?= <cgoettsche@xxxxxxxxxxxxx> wrote: > > Avoid using nontransitive comparison to prevent unexpected sorting > results due to (well-defined) overflows. > See https://www.qualys.com/2024/01/30/qsort.txt for a related issue in > glibc's qsort(3). > > Signed-off-by: Christian Göttsche <cgzones@xxxxxxxxxxxxxx> > --- > security/selinux/ss/policydb.c | 18 ++++++++++-------- > 1 file changed, 10 insertions(+), 8 deletions(-) > > diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c > index 3ba5506a3fff..eb944582d7a6 100644 > --- a/security/selinux/ss/policydb.c > +++ b/security/selinux/ss/policydb.c > @@ -37,6 +37,8 @@ > #include "mls.h" > #include "services.h" > > +#define spaceship_cmp(a, b) (((a) > (b)) - ((a) < (b))) I'll admit that it took me a while to figure out why you decided to name this macro "spaceship_cmp", and then I had a little laugh when I realized why it was called the "spaceship" operator :) Anyway, while the spaceship operator is likely familiar to people who have a Perl background, the kernel is still mostly a C project so I don't think we can expect a base understanding of Perl, especially these days as Perl isn't as popular as in the past. Can we rename this to something else that makes more sense in the context of C? -- paul-moore.com