From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751296AbdJCCPh (ORCPT ); Mon, 2 Oct 2017 22:15:37 -0400 Received: from mail-pf0-f171.google.com ([209.85.192.171]:46428 "EHLO mail-pf0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751188AbdJCCPf (ORCPT ); Mon, 2 Oct 2017 22:15:35 -0400 X-Google-Smtp-Source: AOwi7QCS+dMXRAhhvnSvt0v5VfmPHJEqpi2R8uMwZ4biCejMw5c9mAlGzJeX0VE0A9ue54+Q95aptQ== From: Shakeel Butt To: Alexander Viro , Vladimir Davydov , Johannes Weiner , Michal Hocko , Greg Thelen Cc: Andrew Morton , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Shakeel Butt Subject: [PATCH] epoll: account epitem and eppoll_entry to kmemcg Date: Mon, 2 Oct 2017 19:15:19 -0700 Message-Id: <20171003021519.23907-1-shakeelb@google.com> X-Mailer: git-send-email 2.14.2.822.g60be5d43e6-goog Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The user space application can directly trigger the allocations from eventpoll_epi and eventpoll_pwq slabs. A buggy or malicious application can consume a significant amount of system memory by triggering such allocations. Indeed we have seen in production where a buggy application was leaking the epoll references and causing a burst of eventpoll_epi and eventpoll_pwq slab allocations. This patch opt-in the charging of eventpoll_epi and eventpoll_pwq slabs. Signed-off-by: Shakeel Butt --- fs/eventpoll.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 2fabd19cdeea..a45360444895 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -2329,11 +2329,11 @@ static int __init eventpoll_init(void) /* Allocates slab cache used to allocate "struct epitem" items */ epi_cache = kmem_cache_create("eventpoll_epi", sizeof(struct epitem), - 0, SLAB_HWCACHE_ALIGN | SLAB_PANIC, NULL); + 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_ACCOUNT, NULL); /* Allocates slab cache used to allocate "struct eppoll_entry" */ pwq_cache = kmem_cache_create("eventpoll_pwq", - sizeof(struct eppoll_entry), 0, SLAB_PANIC, NULL); + sizeof(struct eppoll_entry), 0, SLAB_PANIC|SLAB_ACCOUNT, NULL); return 0; } -- 2.14.2.822.g60be5d43e6-goog