Received: by 10.213.65.68 with SMTP id h4csp871179imn; Tue, 27 Mar 2018 10:17:59 -0700 (PDT) X-Google-Smtp-Source: AIpwx482VvlCavDprUvjdaygRro4HLvA2SLZkaD4PeArSgUeObqg0znMIqv5KJlDa9vrA+GV6HMl X-Received: by 2002:a17:902:51ce:: with SMTP id y72-v6mr159475plh.157.1522171079544; Tue, 27 Mar 2018 10:17:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522171079; cv=none; d=google.com; s=arc-20160816; b=u2OXHcn4wzT5fHoGIEXoCzk2izIW1QljnaO8M9ikW9DgF14qOKJeI9Bznu7N02q7ge iP9f/tlyM0dsYAOQJ1Ud0d08+az5J9kFLJYW6PFr/CR+wfNUpyxyA8nh60kh3tPim1J3 hbSX+QomzWr3Alfz8qq8/gDeKUUtFZV4He5yW5xBhqblyBwYRgE5hiaz6PAP4iBB7gUx F2Qhl5hkW0d6z6XjbZ1cqEGI6Dyf+3K1BPVVsMBOW73R1akgceXEAdANFh4lavOGlGRP p7vkiUbVutYBgymjW5fZ8xXNb/cWbs5IbsuRLVEH0qr6rHGUyHXEbPmowvScDEWNIbhV Z3KA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=NQOSA+QVtseqejgjj/f2homDwyVBNfmp7W5CTvNelcU=; b=GkX/OwjXMTk+kAMFSDVY6LMjlZKqUMm3B/7AzXPAvxkNZj3BikgaLvF+5XNiWHLSSm l3rxADwUYJolaJxKyKAMHIa23xV9quEjneVq8f09ZoptAa+TOcmSEmJE4EUAyQA0eBPu +x9T2rAQdulWs8BwFAJ5A45YQbJMRF94kwhXlRufyKISEDZbWcwRjqr8OOkfNQ6ELGsK DVWvrQbNsUTHjzIu38URYzq7a6pYGiC5XKFmnIf/e/UUp3dehRwN8beNeyU5GHIXiVeM Qphzt8VsUKuJVfP9pdG9G7RucjR/abSIFecphy7g48YgQU2Vwjh7ZR0OtFVtP/tJgf9s UopQ== ARC-Authentication-Results: i=1; mx.google.com; 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 69-v6si1595024pla.390.2018.03.27.10.17.45; Tue, 27 Mar 2018 10:17:59 -0700 (PDT) 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; 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 S1755262AbeC0Qig (ORCPT + 99 others); Tue, 27 Mar 2018 12:38:36 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:46834 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755249AbeC0Qif (ORCPT ); Tue, 27 Mar 2018 12:38:35 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 4CF04102D; Tue, 27 Mar 2018 16:38:34 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chenbo Feng , Lorenzo Colitti , Daniel Borkmann Subject: [PATCH 4.14 100/101] bpf: skip unnecessary capability check Date: Tue, 27 Mar 2018 18:28:12 +0200 Message-Id: <20180327162756.124069050@linuxfoundation.org> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180327162749.993880276@linuxfoundation.org> References: <20180327162749.993880276@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chenbo Feng commit 0fa4fe85f4724fff89b09741c437cbee9cf8b008 upstream. The current check statement in BPF syscall will do a capability check for CAP_SYS_ADMIN before checking sysctl_unprivileged_bpf_disabled. This code path will trigger unnecessary security hooks on capability checking and cause false alarms on unprivileged process trying to get CAP_SYS_ADMIN access. This can be resolved by simply switch the order of the statement and CAP_SYS_ADMIN is not required anyway if unprivileged bpf syscall is allowed. Signed-off-by: Chenbo Feng Acked-by: Lorenzo Colitti Signed-off-by: Daniel Borkmann Signed-off-by: Greg Kroah-Hartman --- kernel/bpf/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -1455,7 +1455,7 @@ SYSCALL_DEFINE3(bpf, int, cmd, union bpf union bpf_attr attr = {}; int err; - if (!capable(CAP_SYS_ADMIN) && sysctl_unprivileged_bpf_disabled) + if (sysctl_unprivileged_bpf_disabled && !capable(CAP_SYS_ADMIN)) return -EPERM; err = check_uarg_tail_zero(uattr, sizeof(attr), size);