Re: [PATCH 1/5] arm64: vdso: don't free unallocated pages

Will Deacon
2020-04-14T15:10:45Z

On Tue, Apr 14, 2020 at 03:53:45PM +0100, Vincenzo Frascino wrote:
> On 4/14/20 2:27 PM, Mark Rutland wrote:
> > On Tue, Apr 14, 2020 at 01:50:38PM +0100, Vincenzo Frascino wrote:
> >> On 4/14/20 11:42 AM, Mark Rutland wrote:
> >>> The aarch32_vdso_pages[] array never has entries allocated in the C_VVAR
> >>> or C_VDSO slots, and as the array is zero initialized these contain
> >>> NULL.
> >>>
> >>> However in __aarch32_alloc_vdso_pages() when
> >>> aarch32_alloc_kuser_vdso_page() fails we attempt to free the page whose
> >>> struct page is at NULL, which is obviously nonsensical.
> >>
> >> Could you please explain why do you think that free(NULL) is "nonsensical"?
> >
> > Regardless of the below, can you please explain why it is sensical? I'm
> > struggling to follow your argument here.
>
> free(NULL) is a no-operation ("no action occurs") according to the C standard
> (ISO-IEC 9899 paragraph 7.20.3.2). Hence this should not cause any bug if the
> allocator is correctly implemented. From what I can see the implementation of
> the page allocator honors this assumption.
>
> Since you say it is a bug (providing evidence), we might have to investigate
> because probably there is an issue somewhere else.

Not sure why you feel the need to throw the C standard around -- the patch
from Mark looks obviously like the right thing to do to me, so:

Acked-by: Will Deacon <will@kernel.org>

Catalin -- please take this one as a fix so that I can queue the rest of
the patches for 5.8 once it's hit mainline.

Will