Re: [PATCH] libsepol: check for overflow in put_entry()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jul 11, 2023 at 3:16 PM James Carter <jwcart2@xxxxxxxxx> wrote:
>
> On Thu, Jul 6, 2023 at 10:03 AM Christian Göttsche
> <cgzones@xxxxxxxxxxxxxx> wrote:
> >
> > put_entry() is used during writing binary policies.  Avoid short writes
> > due to an overflow.
> >
> > Signed-off-by: Christian Göttsche <cgzones@xxxxxxxxxxxxxx>
>
> Acked-by: James Carter <jwcart2@xxxxxxxxx>
>

Merged.
Thanks,
Jim

> > ---
> >  libsepol/src/services.c | 5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/libsepol/src/services.c b/libsepol/src/services.c
> > index 062510ab..07ae051b 100644
> > --- a/libsepol/src/services.c
> > +++ b/libsepol/src/services.c
> > @@ -1708,7 +1708,10 @@ int next_entry(void *buf, struct policy_file *fp, size_t bytes)
> >  size_t put_entry(const void *ptr, size_t size, size_t n,
> >                         struct policy_file *fp)
> >  {
> > -       size_t bytes = size * n;
> > +       size_t bytes;
> > +
> > +       if (__builtin_mul_overflow(size, n, &bytes))
> > +               return 0;
> >
> >         switch (fp->type) {
> >         case PF_USE_STDIO:
> > --
> > 2.40.1
> >




[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux