Re: [PATCH v2 1/2] mm: add GFP mask param to strndup_user
From: Pascal Bouchareine
Date: Sat Aug 22 2020 - 15:37:05 EST
Thanks for taking a look!
On Fri, Aug 21, 2020 at 8:51 PM Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
> Why change all existing callsites so that one callsite can pass in a
> different gfp_t?
My initial thought was to change strndup_user to use
GFP_KERNEL_ACCOUNT (or GFP_USER | __GFP_ACCOUNT ?) unconditionally.
(Would that work? that would be a simpler change for sure)
In the case it was not wanted, I assumed a good proportion of callers
might do the same on a case-by-case basis (esp. with regards to
enabling accounting).
> Also...
>
> why does strndup_user() use GFP_USER? Nobody will be mapping the
> resulting strings into user pagetables (will they?). This was done by
> Al's 6c2c97a24f096e32, which doesn't have a changelog :(
FWIW, I believe related to this: https://lkml.org/lkml/2018/1/6/333
It's a bit over my head (is GFP_USER cheaper?) if strndup_user needs
to follow memdup_user
> In [patch 2/2],
>
> + desc = strndup_user(user_desc, SK_MAX_DESC_SIZE, GFP_KERNEL_ACCOUNT);
>
> if GFP_USER is legit then shouldn't this be GFP_USER_ACCOUNT (ie,
> GFP_USER|__GFP_ACCOUNT)?
Yes! I'll see clearer if I manage to wrap my head around what
strndup_user should do
Thanks!