From patchwork Fri Feb 9 04:05:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexei Starovoitov X-Patchwork-Id: 13550842 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 70AA2C48297 for ; Fri, 9 Feb 2024 04:06:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 08C6D6B0078; Thu, 8 Feb 2024 23:06:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 015096B007E; Thu, 8 Feb 2024 23:06:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DFA306B0080; Thu, 8 Feb 2024 23:06:20 -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 C73BE6B0078 for ; Thu, 8 Feb 2024 23:06:20 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 70B4C16016D for ; Fri, 9 Feb 2024 04:06:20 +0000 (UTC) X-FDA: 81770928120.15.9466682 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by imf29.hostedemail.com (Postfix) with ESMTP id 9ED1512000E for ; Fri, 9 Feb 2024 04:06:18 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ePLHTjce; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf29.hostedemail.com: domain of alexei.starovoitov@gmail.com designates 209.85.214.176 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=1707451578; 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=HiZXvAtRKK8jkFx0ziwixfKGMxiAC5XovXkV04D0O98=; b=BggN3NeaphuQzqYCPUcpBCNwH+kZXpXG6WS4Gs/CgTGFyFpyFVTk/NZ5lLlQX5Iinw4Q/3 rf9vgIWTqoadrICBKRMbNrWMY/BcTunvoGuEDYjGVSWv6GBuWAxmkJCM7nYIt1er5yiS2l jfw6yoxEMwbsCcDYZlNxGFu5+KWU+YY= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ePLHTjce; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf29.hostedemail.com: domain of alexei.starovoitov@gmail.com designates 209.85.214.176 as permitted sender) smtp.mailfrom=alexei.starovoitov@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707451578; a=rsa-sha256; cv=none; b=RwQC6P4j1JBy2DuNcjy88mHogwIEOyZg9H8q3NgAoelZMONlyfV00SF+cCeNX3Obcux7VK 205n6olBta4eZnVPQ9aNi0QCIzBEKgoOuWJnH9xeWyG2gO9H9HjaGyKoyqkrSGSNENI/FL +VUZUR2k0KNmhSrkVpUMwHjPcuwOOQc= Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-1d72f71f222so4490505ad.1 for ; Thu, 08 Feb 2024 20:06:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707451577; x=1708056377; 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=HiZXvAtRKK8jkFx0ziwixfKGMxiAC5XovXkV04D0O98=; b=ePLHTjceC5eeNhevJc8+sDXcBgwJ0bJTH2aZUqpGMcdSOFbgjbDLZtK87FCjyYCvQy +FeY8ttxdwSigFXaQugfmW76VJf3557sGYA9Quh5c6aQdOq5IXlqk3vaoJNRtt5Y4jq8 FalyBQkYs2dCmlEtlx6D5stqa7GX6h/zlUGBzBXssiRMx++zAzgkoRjN93EBmlLtEH6v BN6JAiXI/LpEDhndAuxy+rkwpJCZhrIvu4nX9JTfA9nj6VKqFPSJFBKcm+HIzfwy6ED7 S2NTzc+33hzqPfUi8oaDK19rwMjN7GyOrcu1gD1H0nV7PBWsEwjt0PDPcYS38wrahI5L JbqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707451577; x=1708056377; 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=HiZXvAtRKK8jkFx0ziwixfKGMxiAC5XovXkV04D0O98=; b=Qmj/whvmKaZMG1nsOOgDlSJkJv3RvOeh1Zdc3FHonDP263Yyp0cU/HVhsVMUS34SGg MINSh2JfP7eC7u6eb/pGp7JAzvcAmfIzqqMA3eSQDgNKj/M1GsIs7FuJMOzMYG4uXIkS U8EwMDgUysP8rmG7N4saxYrkjArpcGZgcHb1McrJRz/Ufq0zW8mFiIyXtksFj/NLwNt1 oG1c9XRx9xZO1OmuF9bbRml1SYoKHPssv+Q8ZGNJ2ZShEnYXie0K1O0Xeta571qtRq0O 1VyAhDvSHvbewAu0Oc2/rwcHRJYBd6ttah1+n9CGucOVB+mG5JmwvI3QMmwghOYsgcUp iYRQ== X-Gm-Message-State: AOJu0YyXl1btnRk234dRCDy/48HS2Y5FLoE9awb2jq25xyxd8wLvmZLn HPK/mkntxdBDTDx148FcGOlHZ1RPzJHH2kjXfNQxgCAYw96jAs5b X-Google-Smtp-Source: AGHT+IH0qd7DUNWL2d1Urm49Tarwt8Y7vlvkifg1t+rPqEzlKKds4sNBaEDojklBlzOW65EyuN84oQ== X-Received: by 2002:a17:902:d512:b0:1d9:cc68:19c6 with SMTP id b18-20020a170902d51200b001d9cc6819c6mr505956plg.43.1707451577482; Thu, 08 Feb 2024 20:06:17 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCW0PSDSVSrkv+MnkyI+/hIYocwwt2ruGu8w0QAeQbBnRSNdSiWSEkbUIE0BAXyb5Zg9Ii4TSozKKj1jxxKcrHkZkTO0DaUSIlKkZtOh6JNQ36oXTkCUzMAX4yMunEMiwp3ti9w3FRrGlWp5IUZloJgZyY9JqybOu8LCa4fyoIMPi3oxP7rXgATE/KrV1IYoYtHNxPVCOE9ctb5w8jhL8M+66f6h0UCln/TA1zrEC55iEka/PM0Pl2LQsdp714N5FuoTkqyOpR7eEsHj8Kl1nmymCmhFm2o7SJ3zpjLN6vSGYhbm6ybyG83M8i1dSN/5Sz7UClBMTTVQu6Yl7l4iU8Sx1HbZa4/un5ZV0lD5c226Y0vpra+y0w== Received: from macbook-pro-49.dhcp.thefacebook.com ([2620:10d:c090:400::4:a894]) by smtp.gmail.com with ESMTPSA id mf3-20020a170902fc8300b001d9edac54b2sm544084plb.205.2024.02.08.20.06.15 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 08 Feb 2024 20:06:17 -0800 (PST) From: Alexei Starovoitov To: bpf@vger.kernel.org Cc: daniel@iogearbox.net, andrii@kernel.org, memxor@gmail.com, eddyz87@gmail.com, tj@kernel.org, brho@google.com, hannes@cmpxchg.org, lstoakes@gmail.com, akpm@linux-foundation.org, urezki@gmail.com, hch@infradead.org, linux-mm@kvack.org, kernel-team@fb.com Subject: [PATCH v2 bpf-next 01/20] bpf: Allow kfuncs return 'void *' Date: Thu, 8 Feb 2024 20:05:49 -0800 Message-Id: <20240209040608.98927-2-alexei.starovoitov@gmail.com> X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: <20240209040608.98927-1-alexei.starovoitov@gmail.com> References: <20240209040608.98927-1-alexei.starovoitov@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 9ED1512000E X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: j1utkywicpd1m4itxt7hezejjgq5cdha X-HE-Tag: 1707451578-272578 X-HE-Meta: U2FsdGVkX1+7ksV2bsu1f7hxq5ycx1cCDmZljdM5ADPLfAxeLQ8dYdGFMUPgq3vAU7+3wKKPE+SpM6i8pMxngGIhL18UADmlnZMxr09aYYMtPWkxPUfFerr0VEwlOTclFSr7OIDFZKAl7J9HMrrz/BI+0LANTiiHuViXrbKZVLob6UUSvD8EpGQR9DUwcdzCk0ln+k7pBDGC/eQPNejog7V43XiOemxfHPbGU5n8koxRGyIAzax1DvlPAwdjH1smzBv4fLX848EkWsXpaI0HsCyOH9/SdTiunJjBNUNPPo3+12VP1BQsDMUN5m1wv52KeIKXK3yxzFHsLfn9u6itD1r6gPiM2qsAIBhdqLnd5ov4gR25lnxlCTAU2sk9uB4Y1sEKBqVgF7LrfIZTaeuEcuLkxzXKxo3Fmny2RFn99zJ7R3ePcgBJ7Su4IPoan1NPqX+vEYn+N+rY0sMbv/lSDNlWHa2DfmHcSXO5xKhyTGMY1D+5cEQP2CwLIy5AHJklV7/aR41ubp5ImltOjxXh+pG9XwqVt4SUNP5WO0iixXooHILDk1vgHzo5tkuC569yruE9W2d/o7kO1R+sS6KKzCqUWMETo0gEwjDlAfb3hA9A7tbpmsyllZXPDiOiY7CNtOlF2AGt6f0QBEhqfGggcGAJ10tBoMTS8VQuLM6kvltXUXM8DI4zpFC4v2+nCxcN3wzLMhGfY1CjB6Jw55kFIVMoMk/ldVRsZmPq1pIwY7Mv6WHPKvnBwwmFLZVpSTvqeifNU8+BDhxSVRR+nd84DiM1bh53TzQvZ+dMhONvn4dFnxnjYGOMZC6y9So6AAiATRUo+qedZyKH4Ddwht728ntG720VTvb+ctjRs0FPjMdC7wbThn4/t3J6tPLhnDsASAc+H3Xj49UaKKfnrW939vA2VzuX02jjkl7eK16LtVXVDcHu96ZqCMkntsISFHmn8nRUPKEwDcIvxnEac2Y C7Bg/SVX 8turES+L9l+lxFN/afbH9zVi0IzuDIQT9Rg/+aISV/nziVuSWGUU3Oe3fT36gkhIEnNDptxDlnqKuPt7Ie1DkrC3CbgUMmY0xAc+KOApJIh8pqijC84j0CVNps0u4RFP53Ab+wiww10KkZ+DFN5BAwitdA7c/JA+ex0f4Mo4xCp3WfdxE8fhcj8UEV5+J6pDp4eJwhnPfqWKiQGykj9PDOTTZUbMgvLb/jsdp0RDjzuOyI3Au5ra2cUrqZTOGbGWn232AA1Wp1jEvIsQCeKnZavfZWvfln1N5sCoffbHVW7IMd9+Cza+DPriZYDbPOWA3d/Xs+mjNiGYHmcFRhWHsu+ZY87P4QfUtySX/xjpKHS1yftXk5foPdSwdEgAG3jVuyeAhe8TOSbb1WDzC3k97IjsAWI5GKKesN65SZBoyN0IT6Jae8it+V2JduJxWG2FpshFC0RK44teSTK77wO6UOOQgXjtdj6bWdPMCpFx1YmmXmiAZ1DMadlZeOxLA0jCimhPoyNzC5+VpEZA8F3ahIHkSvK5AF1KiZO++w9gd54g9l/w= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, 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. Acked-by: Andrii Nakryiko Signed-off-by: Alexei Starovoitov Acked-by: Kumar Kartikeya Dwivedi --- 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;