Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2367825lqp; Sun, 24 Mar 2024 16:06:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU/MDFDyTdlg1RIhs1h6EhL1o96yA94j56f2ZkIGNZ/I3RX7ug8jbqc3HsMnzMqa8v2SE1CFLToZ8ZfSmbTtIIbx6WZomqsC3kpNmzDwQ== X-Google-Smtp-Source: AGHT+IEuJ9mabW/LKC1iCiVFCXlKp0ihU2/dO4A8B1HK93OqkPo/5HMS++kBqWjsAH5wXC0aRYgZ X-Received: by 2002:a17:902:c409:b0:1d9:6de3:9980 with SMTP id k9-20020a170902c40900b001d96de39980mr6721893plk.48.1711321602819; Sun, 24 Mar 2024 16:06:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711321602; cv=pass; d=google.com; s=arc-20160816; b=n8Tog7hOnhQzj/xM4UxCzBOh2mGkEG7mvXYg+lXalGIrqiI6zRbh7QlQrAh9vLo/qz GmDpMWcymaF03Sr8Rz/5FDvl4hsUh+k2JrpOimIUvbpohGFmK+8w4rkx55D8d/XMdBvT 5s19iT3U90qbJVoJGT6qF1heeSsktFj21qzZhqIBja5h6WlgNnBMIkUwGCpe+iT/51Hd p4sXi4VkVw404VNzRstDLRr4yn2hPFYA1+P1CoQ/ycC53ijHFkDoq3RhTAh6sXxYdRav WOZqxtWmZ05IcJwHuxxZ3/feAb67VDafG+0iOw6cIgCOhWvj6PxLR3Zp7kNx09wL3xVN +pQw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=+PiUR97ELkulzgQUVHLhq0k3uyic7WWeoDFYy5vRbtY=; fh=sX1mvPcb8upXE2LYs1XcIe9h/WsmPb8e2WJZhaezzmA=; b=wG/gEhGg5x+JpYfX9bTlM2iLm6szChr3pxjPa9dxTZsV77vi9c+0/MEWQWooMOy4Lm aYTLyPl1M+okymqNIFEKiuzsezge1W4Ni4vrEwRZRdiwGI+lqun8lyQfrXPGxyjrCxJu qeZiVEEUvszlAfhkcnfh/O+dCJrBzhLydd+u7lFBFl/3mU68oy2GpgVmdsWttf9+jy2v eG7w0coHyXjmR/R/LAAMSNqSLvAqa7iTnFY7J5rP/eqzY5R1en37zCUtV8mdVDhihhI5 G+ePIs8te8WCAFidVDpwTNpJs1fAqoQDDbvepcLpf4X2pYLfI8D40uAXiEntqXsUDMry ZHDA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qLtzu5Y4; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113023-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113023-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id i1-20020a170902cf0100b001e0b60dbc8csi1828735plg.174.2024.03.24.16.06.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 16:06:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113023-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qLtzu5Y4; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113023-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113023-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 734A1281ADE for ; Sun, 24 Mar 2024 23:06:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D45771386AF; Sun, 24 Mar 2024 22:37:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qLtzu5Y4" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DFE6D1384AB; Sun, 24 Mar 2024 22:37:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711319834; cv=none; b=OszU8U5myae8IcmvaB+f8OTDnLtSM8q9cjp2XCRADr74y8lMngu+H5+EwGLChVxGsM8kMRvThXqrLPMNMUqIRgTa/AVPvKteOVwre12HkH13TWsUhs8K2Y4WRFchecU6PFX96cuNrtVM9qDi/aQO1n6kahNr9tElXcNQC427SfM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711319834; c=relaxed/simple; bh=suxZku+fuSyERt5pEGR0WhhSb5rTWiSWM7+czOYqsSI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WRqzSyNnCk7Y+jjlUp1mllx4bGE6XMTuyXliwlU2PK+Euxdruthy1/LUQsJ3GTtVpofeRQOWQjE1fWaiRxK5osPudAJ8vbNja/2ydt33vRoD4bXvAXKRrJ8EozqOLZeQBpiGmdohUxSr7rGwtieJcEj7UbO47KfBcYUhpA17Xlo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qLtzu5Y4; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16541C433A6; Sun, 24 Mar 2024 22:37:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711319833; bh=suxZku+fuSyERt5pEGR0WhhSb5rTWiSWM7+czOYqsSI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qLtzu5Y4qhA97ExDx+hkGQWitIHvExMBwl6leRxRqSpaaPROM3SwGYtjcqSvoU0H1 ZVUZpmQ42BUTHwY5KXg8Kdslrhb6Zfc4/YM7QrC8GVmNYJGZyKlQpXgzGmSgWcTAap GpphYLzLSY8cJ7bzuqCi9j6Mb7kQttVRj19579BY3i+4l9Vck5xzHlS02gSGjCHzAD Sdkn0s8PRYaTNmmte3ks+O5/Dvujj9hwgT2mWIDXzJAsm9BNHvnEXpWWgRFhr5mowC 62zIg7KJ46/P3Vz9VYIBPn9NDMbO5JYl5RX2c77FdE2k+N+p/0bGNof0LwNcpbVVX5 wRu7Dr73T2TcA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Andrii Nakryiko , Eduard Zingerman , Alexei Starovoitov , Sasha Levin Subject: [PATCH 6.8 136/715] bpf: make sure scalar args don't accept __arg_nonnull tag Date: Sun, 24 Mar 2024 18:25:15 -0400 Message-ID: <20240324223455.1342824-137-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Andrii Nakryiko [ Upstream commit 18810ad3929ff6b5d8e67e3adc40d690bd780fd6 ] Move scalar arg processing in btf_prepare_func_args() after all pointer arg processing is done. This makes it easier to do validation. One example of unintended behavior right now is ability to specify __arg_nonnull for integer/enum arguments. This patch fixes this. Signed-off-by: Andrii Nakryiko Acked-by: Eduard Zingerman Link: https://lore.kernel.org/r/20240105000909.2818934-3-andrii@kernel.org Signed-off-by: Alexei Starovoitov Stable-dep-of: 1eb986746a67 ("bpf: don't emit warnings intended for global subprogs for static subprogs") Signed-off-by: Sasha Levin --- kernel/bpf/btf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c index 5964711891767..dbe7a590f565a 100644 --- a/kernel/bpf/btf.c +++ b/kernel/bpf/btf.c @@ -7058,10 +7058,6 @@ int btf_prepare_func_args(struct bpf_verifier_env *env, int subprog) while (btf_type_is_modifier(t)) t = btf_type_by_id(btf, t->type); - if (btf_type_is_int(t) || btf_is_any_enum(t)) { - sub->args[i].arg_type = ARG_ANYTHING; - continue; - } if (btf_type_is_ptr(t) && btf_get_prog_ctx_type(log, btf, t, prog_type, i)) { sub->args[i].arg_type = ARG_PTR_TO_CTX; continue; @@ -7091,6 +7087,10 @@ int btf_prepare_func_args(struct bpf_verifier_env *env, int subprog) bpf_log(log, "arg#%d marked as non-null, but is not a pointer type\n", i); return -EINVAL; } + if (btf_type_is_int(t) || btf_is_any_enum(t)) { + sub->args[i].arg_type = ARG_ANYTHING; + continue; + } bpf_log(log, "Arg#%d type %s in %s() is not supported yet.\n", i, btf_type_str(t), tname); return -EINVAL; -- 2.43.0