Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4848853pxj; Wed, 9 Jun 2021 03:28:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8XRMnjnJZ78G6NkECA0JUO/sWdKiArweeIS7o/OejhZytWfMfIqN9FNfW6zz8TIDY2rS0 X-Received: by 2002:a17:906:640c:: with SMTP id d12mr26814144ejm.70.1623234483566; Wed, 09 Jun 2021 03:28:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623234483; cv=none; d=google.com; s=arc-20160816; b=EIG3n4Fm9nvHtLx9IVow1I7ZvveSZPON8gC+ctq7/j7Rkf2bHvdyCFOoqmqf/R2oBs etQfffdmWaFMLf+ONSf0whPCtCeYKZR+B5dQR11vxCXCxFUVWTeKkKHAK0hlZxXrwCEr GIDony81GjKIhK25p/Aw4Dm1mooniIhuz+cZQligxcHts7a1rBh+DOjNPCtfowYnT+dN DwEE1TbYHyXtyBfsg0I8pYCsa87QkzNhzTa44ifktQamlukGuKBhtGFpOwbBLTFmmKtV TSLRZLHh3l6lUcMZyOt1/qF1hr9IowyxZ75vxFy4gbSYN6y4TU5dBG/+ptW3TsOv6nG3 C+9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=TzqzHGcrcmXj5PwSUx2DgBy+aNu3NW6ySAVkEojDliA=; b=ON9twTcGLPXM4DYQVA5KDz3/UULNkSchWpPYGqpoL2SH11olG3Zsw2NqFLCgN3xwdV +89mNM4mYjqYBEfEH8vJ89NdOyrbv+YHESpbG2gQ+mXDxxkCgPtJkCYaYwXBWYuaBDwT MmU/pu9v354OLkDU42gVrJNsoA5j73YVgfotYIzumxDCdW6VX4p8GrEucUcCCkAx4n6T cA6tp7PXF2l8jRYq75aLxRqK9NjuE0eGctp9BVG/EVVjPrU/7L+c/+XanymCqw11F9F7 tDvt10OyEsZqmi1oDrkZ8WVjWX731agGq8SO6VRAw7//RNw1y30q3V8ftBD9u6yDBP/7 uaMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RbBmY5Fp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d12si2091522edo.215.2021.06.09.03.27.40; Wed, 09 Jun 2021 03:28:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RbBmY5Fp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235997AbhFHS7P (ORCPT + 99 others); Tue, 8 Jun 2021 14:59:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:49558 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235505AbhFHSwO (ORCPT ); Tue, 8 Jun 2021 14:52:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 674F86147F; Tue, 8 Jun 2021 18:40:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623177619; bh=Sl3LgPsHXAwzziHw42C4BhP3eSx1q5+MQHXdHP1UgMM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RbBmY5Fpyj9jrIhJzZkTytNi+urH5+V8eNiEqjpDt7i2deK/OM2dYc41nLATzaosa /3N+fj9dKax4LeZ0+hBfaIMJIN5mSSgFY6CphjHM2qRbuhS0bNI1BkN46hCwSxBXOD q+G8WZRaWUUueWX9c8fmtEha0CmiZ1w/iGB7zQpM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tobias Klauser , Daniel Borkmann , Sasha Levin Subject: [PATCH 5.10 037/137] bpf: Simplify cases in bpf_base_func_proto Date: Tue, 8 Jun 2021 20:26:17 +0200 Message-Id: <20210608175943.669860800@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210608175942.377073879@linuxfoundation.org> References: <20210608175942.377073879@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tobias Klauser [ Upstream commit 61ca36c8c4eb3bae35a285b1ae18c514cde65439 ] !perfmon_capable() is checked before the last switch(func_id) in bpf_base_func_proto. Thus, the cases BPF_FUNC_trace_printk and BPF_FUNC_snprintf_btf can be moved to that last switch(func_id) to omit the inline !perfmon_capable() checks. Signed-off-by: Tobias Klauser Signed-off-by: Daniel Borkmann Link: https://lore.kernel.org/bpf/20210127174615.3038-1-tklauser@distanz.ch Signed-off-by: Sasha Levin --- kernel/bpf/helpers.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c index c489430cac78..d0fc091d2ab4 100644 --- a/kernel/bpf/helpers.c +++ b/kernel/bpf/helpers.c @@ -707,14 +707,6 @@ bpf_base_func_proto(enum bpf_func_id func_id) return &bpf_spin_lock_proto; case BPF_FUNC_spin_unlock: return &bpf_spin_unlock_proto; - case BPF_FUNC_trace_printk: - if (!perfmon_capable()) - return NULL; - return bpf_get_trace_printk_proto(); - case BPF_FUNC_snprintf_btf: - if (!perfmon_capable()) - return NULL; - return &bpf_snprintf_btf_proto; case BPF_FUNC_jiffies64: return &bpf_jiffies64_proto; case BPF_FUNC_per_cpu_ptr: @@ -729,6 +721,8 @@ bpf_base_func_proto(enum bpf_func_id func_id) return NULL; switch (func_id) { + case BPF_FUNC_trace_printk: + return bpf_get_trace_printk_proto(); case BPF_FUNC_get_current_task: return &bpf_get_current_task_proto; case BPF_FUNC_probe_read_user: @@ -739,6 +733,8 @@ bpf_base_func_proto(enum bpf_func_id func_id) return &bpf_probe_read_user_str_proto; case BPF_FUNC_probe_read_kernel_str: return &bpf_probe_read_kernel_str_proto; + case BPF_FUNC_snprintf_btf: + return &bpf_snprintf_btf_proto; default: return NULL; } -- 2.30.2