linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Andi Kleen <ak@linux.intel.com>
Cc: Andrii Nakryiko <andrii@kernel.org>,
	bpf@vger.kernel.org, linux-mm@kvack.org,
	 akpm@linux-foundation.org, adobriyan@gmail.com,
	shakeel.butt@linux.dev,  hannes@cmpxchg.org, osandov@osandov.com,
	song@kernel.org, jannh@google.com,
	 linux-fsdevel@vger.kernel.org, willy@infradead.org,
	stable@vger.kernel.org
Subject: Re: [PATCH v4 bpf-next 01/10] lib/buildid: harden build ID parsing logic
Date: Thu, 8 Aug 2024 15:44:44 -0700	[thread overview]
Message-ID: <CAEf4Bzawbs-hTzurU1pNu30=U=2V84_OsW62PiKpFS-2Ayz5KQ@mail.gmail.com> (raw)
In-Reply-To: <ZrVFkWQU5qpP2yUh@tassilo>

On Thu, Aug 8, 2024 at 3:24 PM Andi Kleen <ak@linux.intel.com> wrote:
>
> > +             name_sz = READ_ONCE(nhdr->n_namesz);
> > +             desc_sz = READ_ONCE(nhdr->n_descsz);
> > +             new_offs = note_offs + sizeof(Elf32_Nhdr) + ALIGN(name_sz, 4) + ALIGN(desc_sz, 4);
>
> Don't you need to check the name_sz and desc_sz overflows separately?
>
> Otherwise name_sz could be ~0 and desc_sz small (or reversed) and the check
> below wouldn't trigger, but still bad things could happen.

Yes, both sizes are full u32, so yes, they could technically both
overflow resulting in final non-overflown new_offs. I'll switch the
additions to be done step by step.

>
>
> > +             if (new_offs <= note_offs /* overflow */ || new_offs > note_size)
> > +                     break;
>
> -Andi


      reply	other threads:[~2024-08-08 22:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20240807234029.456316-1-andrii@kernel.org>
     [not found] ` <20240807234029.456316-3-andrii@kernel.org>
2024-08-08 18:33   ` [PATCH v4 bpf-next 02/10] lib/buildid: add single folio-based file reader abstraction Shakeel Butt
     [not found] ` <20240807234029.456316-7-andrii@kernel.org>
2024-08-08 18:40   ` [PATCH v4 bpf-next 06/10] lib/buildid: implement sleepable build_id_parse() API Shakeel Butt
2024-08-08 20:15     ` Andrii Nakryiko
2024-08-08 20:57       ` Jann Horn
2024-08-08 21:23         ` Andrii Nakryiko
2024-08-08 21:02       ` Shakeel Butt
2024-08-08 21:21         ` Andrii Nakryiko
     [not found] ` <20240807234029.456316-2-andrii@kernel.org>
2024-08-08 22:24   ` [PATCH v4 bpf-next 01/10] lib/buildid: harden build ID parsing logic Andi Kleen
2024-08-08 22:44     ` Andrii Nakryiko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAEf4Bzawbs-hTzurU1pNu30=U=2V84_OsW62PiKpFS-2Ayz5KQ@mail.gmail.com' \
    --to=andrii.nakryiko@gmail.com \
    --cc=adobriyan@gmail.com \
    --cc=ak@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=andrii@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=jannh@google.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=osandov@osandov.com \
    --cc=shakeel.butt@linux.dev \
    --cc=song@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox