lkml.org 
[lkml]   [2020]   [Jan]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.9 22/91] memcg: account security cred as well to kmemcg
    Date
    From: Shakeel Butt <shakeelb@google.com>

    commit 84029fd04c201a4c7e0b07ba262664900f47c6f5 upstream.

    The cred_jar kmem_cache is already memcg accounted in the current kernel
    but cred->security is not. Account cred->security to kmemcg.

    Recently we saw high root slab usage on our production and on further
    inspection, we found a buggy application leaking processes. Though that
    buggy application was contained within its memcg but we observe much
    more system memory overhead, couple of GiBs, during that period. This
    overhead can adversely impact the isolation on the system.

    One source of high overhead we found was cred->security objects, which
    have a lifetime of at least the life of the process which allocated
    them.

    Link: http://lkml.kernel.org/r/20191205223721.40034-1-shakeelb@google.com
    Signed-off-by: Shakeel Butt <shakeelb@google.com>
    Acked-by: Chris Down <chris@chrisdown.name>
    Reviewed-by: Roman Gushchin <guro@fb.com>
    Acked-by: Michal Hocko <mhocko@suse.com>
    Cc: Johannes Weiner <hannes@cmpxchg.org>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    ---
    kernel/cred.c | 6 +++---
    1 file changed, 3 insertions(+), 3 deletions(-)

    --- a/kernel/cred.c
    +++ b/kernel/cred.c
    @@ -219,7 +219,7 @@ struct cred *cred_alloc_blank(void)
    new->magic = CRED_MAGIC;
    #endif

    - if (security_cred_alloc_blank(new, GFP_KERNEL) < 0)
    + if (security_cred_alloc_blank(new, GFP_KERNEL_ACCOUNT) < 0)
    goto error;

    return new;
    @@ -278,7 +278,7 @@ struct cred *prepare_creds(void)
    new->security = NULL;
    #endif

    - if (security_prepare_creds(new, old, GFP_KERNEL) < 0)
    + if (security_prepare_creds(new, old, GFP_KERNEL_ACCOUNT) < 0)
    goto error;
    validate_creds(new);
    return new;
    @@ -653,7 +653,7 @@ struct cred *prepare_kernel_cred(struct
    #ifdef CONFIG_SECURITY
    new->security = NULL;
    #endif
    - if (security_prepare_creds(new, old, GFP_KERNEL) < 0)
    + if (security_prepare_creds(new, old, GFP_KERNEL_ACCOUNT) < 0)
    goto error;

    put_cred(old);

    \
     
     \ /
      Last update: 2020-01-11 11:00    [W:3.090 / U:0.812 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site