Re: [PATCH v2] ELF: supply userspace with available page shifts (AT_PAGE_SHIFT_MASK)

Alexey Dobriyan
2023-12-09T09:44:57Z

On Fri, Dec 08, 2023 at 10:29:25AM -0800, Kees Cook wrote:
> On Thu, Dec 07, 2023 at 05:57:05PM +0300, Alexey Dobriyan wrote:
> > On Wed, Dec 06, 2023 at 12:47:27PM -0800, Kees Cook wrote:
> > > Can't we have a generic ARCH_AT_PAGE_SHIFT_MASK too? Something like:
> > >
> > > #ifndef ARCH_AT_PAGE_SHIFT_MASK
> > > #define ARCH_AT_PAGE_SHIFT_MASK
> > > NEW_AUX_ENT(AT_PAGE_SHIFT_MASK, 1 << PAGE_SHIFT)
> > > #endif
> > >
> > > Or am I misunderstanding something here?
> >
> > 1) Arch maintainers can opt into this new way to report information at
> > their own pace.
> >
> > 2) AT_PAGE_SHIFT_MASK is about _all_ pagesizes supported by CPU.
> > Reporting just one is missing the point.
> >
> > I'll clarify comment: mmap() support require many things including
> > tests for hugetlbfs being mounted, this is about CPU support.
>
> I significantly prefer APIs not being arch-specific,

It will become arch-independent once all relevant archs opt-in.

I doubt anyone is writing new software for sparc or alpha.

> so I'd prefer we
> always include AT_PAGE_SHIFT_MASK. For an architecture that doesn't
> define its own ARCH_AT_PAGE_SHIFT_MASK, it's not _inaccurate_ to report
> 1 << PAGE_SHIFT, but it might be incomplete.

It is inaccurate if ARCH_AT_PAGE_SHIFT_MASK is defined as "_all_ page
shift CPU supports". Inaccurate version is called AT_PAGESZ which lists
just 1 page size, there is no need for 2 inaccurate APIs.