Re: [PATCH 2/2] libselinux: fix infinite loop and missing errno in partial <<none>> lookup
Stephen Smalley <[email protected]> Thu, 30 Jul 2026 12:22:37 -0400
| Newsgroups | org.kernel.vger.selinux |
|---|---|
| Message-ID | <CAEjxPJ7J17x42hiG=58dm7cSEedxK_k0nJqst-_zuZFb8XGC0A@mail.gmail.com> |
On Wed, Jul 29, 2026 at 11:55=E2=80=AFAM Stephen Smalley <[email protected]> wrote: > > On Wed, Jul 29, 2026 at 9:40=E2=80=AFAM Petr Matyas <[email protected]= > wrote: > > > > lookup_check_node() has a do-while loop that iterates over matching > > literal specs. When partial=3Dtrue and a matching spec has <<none>> > > context the loop body used `continue` to skip to the next entry. > > In a do-while, `continue` jumps to the condition rather than the > > loop increment, so `literal_idx` was never advanced and the loop > > spun forever. > > > > Fix by explicitly incrementing literal_idx before the continue so > > the loop moves to the next literal spec as intended. > > > > Additionally, set errno =3D ENOENT before continuing so that callers > > which test errno after a NULL return (such as the selabel_file_text > > fuzzer) see a valid error code. Without this, lookup_all() returned > > NULL with errno still 0, violating the expected contract that a NULL > > result is always accompanied by a non-zero errno. > > > > Signed-off-by: Petr Matyas <[email protected]> > > Acked-by: Stephen Smalley <[email protected]> This patch is merged.