Received: by 10.213.65.68 with SMTP id h4csp895182imn; Tue, 27 Mar 2018 10:44:45 -0700 (PDT) X-Google-Smtp-Source: AIpwx49GaqTYlH9KDU9vVQF7Fx35Otd3BE/jH8jHOt7yeqJrVG3ddtdg/F1XFZqeop2AJsf78sNk X-Received: by 10.101.69.198 with SMTP id m6mr183356pgr.244.1522172685840; Tue, 27 Mar 2018 10:44:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522172685; cv=none; d=google.com; s=arc-20160816; b=rFDwawaux86ZuZ+NangZW2qFnMFQcDrCxsfp063QAuc+m4flhXHhnVneS7ev2r67c4 ro8B38WhHLZ9c/03AccQISV2cyiRzDTKk5ozfkmboPqjQ3m8YpIipDmN9sFeohMeRopC FpJsPx3d2fTeUwX0NethpLBgzW6LoSRv6qUHphobfxpoHT9ItuQKRJuq0DyIx9sOvraY 8tCimelG6Mgp9HDOt6Dhg0sUugnH9cMoojwObz5tMxIskXi5ZN9C5V+Sl6C+/Qmurldg qh931AAD+BoHTZt9EKuMjfYX1emlDvFjJuySUF3JP4aWkBYA44i/ls/KXbiTbOWD6bJV JZYQ== 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=9xt1FKvniYTxZjWd4cchBsgCcKb76myOAO5T97f5GYg=; b=D8Zi6l6zpYFwH4s2tIjQclI7EYCykoQgD/yJHVlH1/PG6smgaejz9OIMN8fCUjVJuN u1fmBSoHtQfH7t/R6VWm041v62jqymPw+8GxtPRg4IkNBGDD9pSRoFUqr5/su4nfUOaJ m3+4S8p0z8i/1xPopy6/g3TVd5eCkvKhY7sPn0rSgS3pw0fOM77G4gYDv1dmXurqewZB 3QHSA938DC4U2ayPZ3OQ38PbfHyl8UxMBBXNwZ3BZj4BZ27zrCHMslVMv7FlipawHUFD GKuE6D5hi6oAv2wkQvDpThL7Ij9tvFDSzXgjiCQcBgGAhn6PxOOl2R6QHlF3cYvH57aR o4xw== 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 o69si1221539pfj.329.2018.03.27.10.44.31; Tue, 27 Mar 2018 10:44:45 -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 S1754041AbeC0Qdn (ORCPT + 99 others); Tue, 27 Mar 2018 12:33:43 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:43986 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753090AbeC0Qdk (ORCPT ); Tue, 27 Mar 2018 12:33:40 -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 E0950113B; Tue, 27 Mar 2018 16:33:39 +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.9 66/67] bpf: skip unnecessary capability check Date: Tue, 27 Mar 2018 18:27:58 +0200 Message-Id: <20180327162731.414763377@linuxfoundation.org> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180327162726.702411083@linuxfoundation.org> References: <20180327162726.702411083@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.9-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 @@ -801,7 +801,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; if (!access_ok(VERIFY_READ, uattr, 1))