Re: [PATCH v5 bpf-next 01/10] lib/buildid: harden build ID parsing logic

Andrii Nakryiko
2024-08-13T03:06:43Z

On Mon, Aug 12, 2024 at 5:52 PM Andi Kleen <ak@linux.intel.com> wrote:
>
> > @@ -152,6 +160,10 @@ int build_id_parse(struct vm_area_struct *vma, unsigned char *build_id,
> > page = find_get_page(vma->vm_file->f_mapping, 0);
> > if (!page)
> > return -EFAULT; /* page not mapped */
> > + if (!PageUptodate(page)) {
> > + put_page(page);
> > + return -EFAULT;
> > + }
>
> That change is not described. As I understand it might prevent reading
> previous data in the page or maybe junk under an IO error? Anyways I guess it's a
> good change.

From what I understood, one can get a valid page from the
find_get_page() (same for folio), but it might not be yet completely
filled out. PageUptodate() is supposed to detect this and prevent the
use of incomplete page data.

>
> Reviewed-by: Andi Kleen <ak@linux.intel.com>
>
> -Andi