Received: by 10.213.65.68 with SMTP id h4csp908465imn; Tue, 27 Mar 2018 11:00:27 -0700 (PDT) X-Google-Smtp-Source: AIpwx48NLxh4fvq21uf+EqFAAyhvl6nzXFVXlVMRBW7Z27eo4NQV8AX7jsSpKAa9XLEokz5b9jwb X-Received: by 10.99.143.30 with SMTP id n30mr197957pgd.213.1522173627510; Tue, 27 Mar 2018 11:00:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522173627; cv=none; d=google.com; s=arc-20160816; b=so9c7YRkS26yJl9FMYOxf2LwWZPhxNBeO8mJ202ZXHktxbYM1xTeNW6HzL4EWExAT8 gSDu6ZcCT37/y5EVryDOf8wGKNBdIzgm2JiB951mOpFG/yS8q2R/DnY6naiTqUHrj3m1 JzyP/x8XVtSLdvpZ0lvhep42Byt+WSXMR3ze8Gb4K4mvaxcvbF+E1enrfUmt51/t8CkA K1iPkKeMgO5ViuQiDu1v6VBd9oWPL3m5OiAkqL9edH2PI5LZdzOPYQNNaIhudzrx4TsP GwmSdBj5PCJCwqFdcWXyGSLQjNjzoF74puLuttIWc6hZKW/AZ16jHD9PaU2Xc+ztWyzw W9LA== 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=QfkhsSbC2ozTI2aSZVcOj/zGRPtLzYKl+NJi2po1Ov0=; b=g9qGZ3uGmKdrCefTvEhJ4prfHugkAGCaLlYPCRy5Cvnc7imHvBDoefILgpWAU6PSBh BjWj1lEi9wf+63S5KL3B/BeC9icBs/HpJufqY4FDkBwg7uhRIP3BW5ZPweEjsTbErEaN kR/sSOCZWUDx9fEU2IePXBsjke49KcKPQ38Cqqh4eijuh8K0XXU8TEQq5eoW66621YA6 w0Ts4Wa5riJx2oj4ZP8TiF6X0GnCefbLfDDJvEnITYuRWzwu/B6SlsYsAfGsndT7kSbm q69zuQ60UNRKPu7aQcm4BcH+uCEoMDlEkbcFM8cgFPe049yn2j8nKkXL1g5PReC/oZow swJg== 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 f64-v6si1606232plf.624.2018.03.27.11.00.07; Tue, 27 Mar 2018 11:00:27 -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 S1753112AbeC0Qaf (ORCPT + 99 others); Tue, 27 Mar 2018 12:30:35 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:41982 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753090AbeC0Qad (ORCPT ); Tue, 27 Mar 2018 12:30:33 -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 6032511E6; Tue, 27 Mar 2018 16:30:32 +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.4 42/43] bpf: skip unnecessary capability check Date: Tue, 27 Mar 2018 18:27:46 +0200 Message-Id: <20180327162718.745862535@linuxfoundation.org> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180327162716.407986916@linuxfoundation.org> References: <20180327162716.407986916@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.4-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 @@ -673,7 +673,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))