Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1746637ybl; Sat, 11 Jan 2020 02:00:45 -0800 (PST) X-Google-Smtp-Source: APXvYqz3c4ZcjB3U2wM3QQ5yiDXnFFIPbTm/bb2i/O3seYIEP55UYvc8OsXC2bS9dKtBM9ZhO3/A X-Received: by 2002:a9d:60c4:: with SMTP id b4mr6341298otk.166.1578736844950; Sat, 11 Jan 2020 02:00:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578736844; cv=none; d=google.com; s=arc-20160816; b=WyGawZ+99xraJ3cIM0ygP1zVl9fUGx7UVOSIgca/TbmQXjAFzIzioPRg5bMur87y76 FOGK4hDosIdoS/ek5XW+CNqeIyM8KZVPLNRSrKoY1w92RLjcG6URCy/FehTOue72iyDy PU+Re9nX6C57I8uXXQPYhibhF9NB0wlP7DkjAYBv7wK54dNh9O48ZednjKGccKn06RcZ aKXFKtikQpR3lDZxax7jdIEzSZ/sRvWy9H3zgJNBaTtCxHiqf67CArUlfjEbk7P+2H8d vdIvxfPUofbg1SVFMcx+a2dwSh186CTNj2bR88xO89gDIw4uzcaNL/E9oxW2z3yxOvwp tfow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=sjPGfi14gZkVsjqEvqplfUDsQtrRZywxGrjy4yyY/Nw=; b=D24nIdZZJdVP7Xw8NJ5hZJHzfObksjhfaViaIvndZ0ARX57jYJl+MdTqhp0E7h/oeJ SxxWEnaCtIlRw8HEmeJ9ihaeponuK9vQYCk++vHbky6u5Etp7gEcDPeKWHI/xTvZzDkm 9i1e+UuoFtqDvSZ5NIqmo1FKjSZi3i4fNf9CAG+iFn0HerrNOKuKc2QiSUvT1UAtqaFE uD4elzhAjx2eGnWXtiLT4BuhHgOx29CuHmJOCEU9R0Uq5em2PlTVYoNj5Qdnnc7CFNYf 4RQcW1FhXBIkb9qY+eg86Px/ZfK5vcHvZYJOZrYuk5w0lakBiddhBsoydbLJb0teTY6r 9GIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iRVMtXJV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a205si2910909oii.95.2020.01.11.02.00.33; Sat, 11 Jan 2020 02:00:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iRVMtXJV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729234AbgAKJ7j (ORCPT + 99 others); Sat, 11 Jan 2020 04:59:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:54432 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728768AbgAKJ7i (ORCPT ); Sat, 11 Jan 2020 04:59:38 -0500 Received: from localhost (unknown [62.119.166.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5648D2084D; Sat, 11 Jan 2020 09:59:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578736777; bh=V+O5gXI50UZr9RiSdJTgPSb6wN43+H/8XMVH3x8sdWY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iRVMtXJV3OA7FmIhvZq21OPW7DZx4zF4Pz9aVLY41eknF8QZ3DLjtM6kzhfdcFX22 2e0a3xldr6RJPfJACC+SapUMMl5MXdE7mb9az/wESAiiYt477pV90Omouc44/HE8iW XnI2qBcbWAghBDbZYRozFdrun55z8QvPj55gd2fM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shakeel Butt , Chris Down , Roman Gushchin , Michal Hocko , Johannes Weiner , Andrew Morton , Linus Torvalds Subject: [PATCH 4.9 22/91] memcg: account security cred as well to kmemcg Date: Sat, 11 Jan 2020 10:49:15 +0100 Message-Id: <20200111094852.213118498@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200111094844.748507863@linuxfoundation.org> References: <20200111094844.748507863@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Shakeel Butt 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 Acked-by: Chris Down Reviewed-by: Roman Gushchin Acked-by: Michal Hocko Cc: Johannes Weiner Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- 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);