From patchwork Sat Oct 21 13:36:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Belouin X-Patchwork-Id: 10021419 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 769A660234 for ; Sat, 21 Oct 2017 14:01:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C3B7285A4 for ; Sat, 21 Oct 2017 14:01:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4DC6D28BCD; Sat, 21 Oct 2017 14:01:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 54AFC285A4 for ; Sat, 21 Oct 2017 14:01:23 +0000 (UTC) Received: (qmail 11708 invoked by uid 550); 21 Oct 2017 14:01:21 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Delivered-To: moderator for kernel-hardening@lists.openwall.com Received: (qmail 21971 invoked from network); 21 Oct 2017 13:37:12 -0000 From: Nicolas Belouin To: Alexander Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, kernel-hardening@lists.openwall.com Cc: Nicolas Belouin Date: Sat, 21 Oct 2017 15:36:06 +0200 Message-Id: <20171021133606.18866-1-nicolas@belouin.fr> X-Mailer: git-send-email 2.14.2 X-Antivirus: Dr.Web (R) for Unix mail servers drweb plugin ver.6.0.2.8 X-Antivirus-Code: 0x100000 Subject: [kernel-hardening] [PATCH] fs: check for CAP_SYS_RESOURCE instead of CAP_SYS_ADMIN X-Virus-Scanned: ClamAV using ClamSMTP This check is meant to allow a privileged process to go above max_files, such a check must be done against CAP_SYS_RESOURCE as its role is to allow resources limits override. Signed-off-by: Nicolas Belouin --- fs/file_table.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/file_table.c b/fs/file_table.c index 61517f57f8ef..4bc74fd50838 100644 --- a/fs/file_table.c +++ b/fs/file_table.c @@ -111,7 +111,8 @@ struct file *get_empty_filp(void) /* * Privileged users can go above max_files */ - if (get_nr_files() >= files_stat.max_files && !capable(CAP_SYS_ADMIN)) { + if (get_nr_files() >= files_stat.max_files && !capable(CAP_SYS_ADMIN) && + !capable(CAP_SYS_RESOURCE)) { /* * percpu_counters are inaccurate. Do an expensive check before * we go and fail.