From patchwork Tue Feb 6 22:04:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexei Starovoitov X-Patchwork-Id: 13547836 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69D9AC48297 for ; Tue, 6 Feb 2024 22:04:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E6C8B6B0081; Tue, 6 Feb 2024 17:04:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DF5B76B0082; Tue, 6 Feb 2024 17:04:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C98876B0083; Tue, 6 Feb 2024 17:04:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id B4D3C6B0081 for ; Tue, 6 Feb 2024 17:04:52 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 7B65D1406FA for ; Tue, 6 Feb 2024 22:04:52 +0000 (UTC) X-FDA: 81762759624.09.77DF762 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) by imf19.hostedemail.com (Postfix) with ESMTP id C7FE21A0015 for ; Tue, 6 Feb 2024 22:04:50 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="lK/B2/00"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf19.hostedemail.com: domain of alexei.starovoitov@gmail.com designates 209.85.210.171 as permitted sender) smtp.mailfrom=alexei.starovoitov@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707257090; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=vTdQC2aUXQJJJCr+aCpdI86HWrK6Y2hTgBNTwS7bp1E=; b=K+fEv0DPC5gDt4xWzGYPJaDst7VcBk5gcPUdgZSArkXPRNv2sfFkP5E7x0zP4rWnkPw7nR nrpjP2i99x0NIgqfu6LnHOvkLHzk+qWkUUZ+1vesiWyUzK4+jpGiCmalRpjaPwX1H+A7N0 q8wUvj5Yi887Nj2GMBmD4moxZjsOyK0= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="lK/B2/00"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf19.hostedemail.com: domain of alexei.starovoitov@gmail.com designates 209.85.210.171 as permitted sender) smtp.mailfrom=alexei.starovoitov@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707257090; a=rsa-sha256; cv=none; b=xWcpljE4ibxQhGVibRpQ7owBN/YSe9UDrW3Iz4Qp7BRTTHqISszMQIei5RrBFccGlwg4EA MOTvKis6sPzlN7GScPBGCBEpU5sImM3nAiCVaY54brfOw3WZZviOlCAzKI9PL46rK5O6m7 aiKVLyXTg4F95MlKlV2PeKac04ifjrI= Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-6da4a923b1bso5959b3a.2 for ; Tue, 06 Feb 2024 14:04:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707257089; x=1707861889; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vTdQC2aUXQJJJCr+aCpdI86HWrK6Y2hTgBNTwS7bp1E=; b=lK/B2/00R925DPJt9xHF6XX5Ko9f2UeChXoyF4tXon1K5kea8OxT1sY0WZghiTXols woptO8cxpTHl1lx4RRDDZrAce24yF6hSyw26zp9lQoqfCLvwpI0dyzBi1dUNpZJmxdst Cd0PQvypJLWE58na2iRfuckgbW489Vaj6hGiCHcyGEXfKhvjzc68IUcwUhZGn4bUZvEx 2rgXbzjKQhsTee7bJFx4o+cIXGJP1fWUJm238pAu1ip1bx+XpZvAEuXxzZB3hMySCVUs 7YAMwHfLwlMKZqwq7/6t5aa74AWAxqsaohedoWp0CfFt3SyuV4tO7iw1BBwCwMfslAhC 7cZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707257089; x=1707861889; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vTdQC2aUXQJJJCr+aCpdI86HWrK6Y2hTgBNTwS7bp1E=; b=jsfDw2JGX9e3T1zNnMsrZWqOCGv6IbuTma7SRBUJ2W1vZlwitkxIrd/24XDhTtuX7N hD8yFSqLovEBqqrIrMfNIVgIrfJMrdyC0183OE3adcelTjylKphXF1p/Fq/ZlzjxdnCP 5RWmefWb6OWuLtrZsufaP1Vn65aLShoh2Srrszg+bz9ONiOFCMxc5tKvKv4pX1pMgU3Y zUQYQ2ZnBlJzoO8/o0hyBSzok/hAXaUW/HckQf/jroe1MgiCsWfX2nrb9GAxfJW3iNPD 5LR7uni7rK79Zo7wFbW4S/gd0TgNLm9axEHi6RmVuay3i4pUUybPFvtwU8ts7vpk3xdI Ulsg== X-Gm-Message-State: AOJu0YzUAjrlg/pu6D7WEh31cGJIwr65E5otl0kza7BL345qGBY7IIZI TkgY1gYaa5Q7TPPPswjM6tAEDHwla9ilZ4gzKvIUzBktFJXZxkRR X-Google-Smtp-Source: AGHT+IEOBWDdHBSn6MYZcDsMAjg06YN4MswMauxkUU1AohdAC2pdYdWD/fKtCiGD2UT6AxSc8zBdng== X-Received: by 2002:a05:6a20:9687:b0:19b:56f0:c880 with SMTP id hp7-20020a056a20968700b0019b56f0c880mr3151794pzc.39.1707257089523; Tue, 06 Feb 2024 14:04:49 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWKAdt7d7meDWiqsPZBETrzTMdLFa3A8xeHxysTX4BnJCCUBehTYcyFmzK/mu5UhvwvCiGftMYGrDP47TFLDjE660wuY1T5GY0wrbXx4X1S03zWbWSXrOQ+tdSlnAu5YJXkDcgBFW2A3CDYdLKDKBnFqYTMtQA2EY6Myv9mLdg8OuDd+rL3sbhg2fdft6PrbNQoJEP1c/MrDfcTHtSmtmEH1NCKjDvOzx4UtVeD0UtYuEuc0aiQfVw/iVuyTncavF/YiNn57WBDn7q1VeXkmEMUcE3rFGnER8Ry Received: from localhost.localdomain ([2620:10d:c090:400::4:27bf]) by smtp.gmail.com with ESMTPSA id y192-20020a62cec9000000b006e02ce964b7sm2560051pfg.184.2024.02.06.14.04.47 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 06 Feb 2024 14:04:49 -0800 (PST) From: Alexei Starovoitov To: bpf@vger.kernel.org Cc: daniel@iogearbox.net, andrii@kernel.org, martin.lau@kernel.org, memxor@gmail.com, eddyz87@gmail.com, tj@kernel.org, brho@google.com, hannes@cmpxchg.org, linux-mm@kvack.org, kernel-team@fb.com Subject: [PATCH bpf-next 01/16] bpf: Allow kfuncs return 'void *' Date: Tue, 6 Feb 2024 14:04:26 -0800 Message-Id: <20240206220441.38311-2-alexei.starovoitov@gmail.com> X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: <20240206220441.38311-1-alexei.starovoitov@gmail.com> References: <20240206220441.38311-1-alexei.starovoitov@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: C7FE21A0015 X-Stat-Signature: rmtgq8wxc1a5oadarqyganawn8gsmhdh X-Rspam-User: X-HE-Tag: 1707257090-670767 X-HE-Meta: U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QiKaTMRPb8ZoucnHDSrWgtq6G6EAuBvxaVLLl+ShaVtvEIj4TxrQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000089, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Alexei Starovoitov Recognize return of 'void *' from kfunc as returning unknown scalar. Signed-off-by: Alexei Starovoitov Acked-by: Andrii Nakryiko Acked-by: David Vernet --- kernel/bpf/verifier.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index ddaf09db1175..d9c2dbb3939f 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -12353,6 +12353,9 @@ static int check_kfunc_call(struct bpf_verifier_env *env, struct bpf_insn *insn, meta.func_name); return -EFAULT; } + } else if (btf_type_is_void(ptr_type)) { + /* kfunc returning 'void *' is equivalent to returning scalar */ + mark_reg_unknown(env, regs, BPF_REG_0); } else if (!__btf_type_is_struct(ptr_type)) { if (!meta.r0_size) { __u32 sz;