Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp184534lqo; Tue, 7 May 2024 17:07:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX0xWLqXTxYHRDepOGI8/trrdUfj9c2uTJ567h5jbS0mSjZcSTop7r1+fuUqny1q1uoHa1T6V/QGnxMs8dPER6nkDAIP7GjMSkdBwLhgQ== X-Google-Smtp-Source: AGHT+IH06s8ILhMKscBdOkB5k/h6Vuyi4JSyFdSYiUUg3zT+MmeadmOa8AjIMYTXlJNVNBYpXMyz X-Received: by 2002:a05:622a:1492:b0:43a:d7b9:6d8d with SMTP id d75a77b69052e-43dbf73a2f6mr13698421cf.47.1715126852961; Tue, 07 May 2024 17:07:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715126852; cv=pass; d=google.com; s=arc-20160816; b=D4poV8EKQAkMv+nveC2J/1uZLMBXOGDoUO0AD4mNvLINJYKFUvmMciZq51XKSQCIHU TgVLlrt24Dhk7b7Wnrn6mQrCPDT3pNyi4Np/5tAoKePjrr16yr7j8HiHmPVsVV7G6UPB AW9CIy8Wf60CDdlBLlPkZzpG3bpC8cjLbGlZXeEgEfcV4sDftqYyVMx+baUFwnLrWH59 7xNPzHf8IL6tZK3wUpn6d3Ggn7xTQz+Sjk+EAmNFpOWGcvzEIlnRlGUryuTxmjzGZTrm ofZQXdfpINLKeBzk7+Zg5fkSlrIkBiU+6Oec27LftvOegbCfcSlNOxQa6dN5HDMa23cv p4pA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=FdxN5qFp6MoVErrH5QHe3LkBFgBJ9NheMIyMy9pry2s=; fh=WZJcZH7sBU4S766SDb6xq+L1U2+OSq8ORpBkalYnGEk=; b=P1VrDr20OUQo9EK+naDxe4TffMefFeLto8KOCRF46JZ3aADiSD2z0RObpLTWj9eFeZ im3zYl3k7G5J0jVwOH98DyWQOxXHykkjpubiTzR6WuhYTNM9IoPN1C/ATdhNwQbfwrPp qUFUTiJfih4X7YTI3VI0UIEsCmBl9gy/P/ZAf4wbiu35/jKtNNAaq5JX3Pk+iEhtyHHp PtZ3uZdQIRZH0oAKvOmUrZWPa3e68MjIofpGY5COdgcrFhlo5R1fBe0zmT5zcMebESzm wliJX/r3bexGwvOfirPVG1oWwuYajIyFdNB3ecY/Hy7xl+Zgfp6vLlpKkAs6SI2Mom1x Fdyg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@motorola.com header.s=DKIM202306 header.b=iT6AKPTN; arc=pass (i=1 spf=pass spfdomain=motorola.com dkim=pass dkdomain=motorola.com dmarc=pass fromdomain=motorola.com); spf=pass (google.com: domain of linux-kernel+bounces-172533-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172533-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=motorola.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d6-20020ac85d86000000b0043ca4942c7dsi13502470qtx.447.2024.05.07.17.07.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 17:07:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-172533-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@motorola.com header.s=DKIM202306 header.b=iT6AKPTN; arc=pass (i=1 spf=pass spfdomain=motorola.com dkim=pass dkdomain=motorola.com dmarc=pass fromdomain=motorola.com); spf=pass (google.com: domain of linux-kernel+bounces-172533-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172533-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=motorola.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id A2BDE1C2139E for ; Wed, 8 May 2024 00:07:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1324613666A; Tue, 7 May 2024 23:48:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=motorola.com header.i=@motorola.com header.b="iT6AKPTN" Received: from mx0a-00823401.pphosted.com (mx0a-00823401.pphosted.com [148.163.148.104]) (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 C4698136657; Tue, 7 May 2024 23:48:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.148.104 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715125692; cv=none; b=P3VbFlW+wbv0NwXBAFK6UHEzTcUHGi8P3XFNCtqtd+kmFPJu/5a3KwVvOpkEscKGqL1gcI08RzPpzyGJFeY5vZV1MHkUq13zk+4PvP6tyMsKLopx+S5ySWlqcRAr1SOm7LHyQkMuIZNKkGB15JwBuxpDEhtpJwnPIxUgcXh1bBs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715125692; c=relaxed/simple; bh=33erqRfm50dy4WDDGbSJahdMBXSmjtcQRIZ3HCaaYI4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=bKfc0BwgZZuIkk4q6snsP404JjYODPvV/GNiYfCENehWfdfoOcBoKiQLf7wQmVI5lv+2wY3twE9wYH8LjykGMXDiqYxusAn+Cr2j+kFLVQq9htacqHa3hVZOXWiQOr9WdKe3qR7ek7YfvfB9BNdWwZaLm4CP0Z+WhmmmNSBe9gE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=motorola.com; spf=pass smtp.mailfrom=motorola.com; dkim=pass (2048-bit key) header.d=motorola.com header.i=@motorola.com header.b=iT6AKPTN; arc=none smtp.client-ip=148.163.148.104 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=motorola.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=motorola.com Received: from pps.filterd (m0355086.ppops.net [127.0.0.1]) by mx0a-00823401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 447IK5Ia013400; Tue, 7 May 2024 23:47:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=motorola.com; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=DKIM202306; bh=FdxN5qFp6MoVErrH5QHe 3LkBFgBJ9NheMIyMy9pry2s=; b=iT6AKPTNdEk+A0JNaqgm3fEsSDUBO8uEPpiz xlf81+kxn/PjLJIq9pwYhgFIMR2+1OjyGmIAplgekyGVU7vaiq6bQ9yyLzfFMcbs gr7FKl9XIf/Q9myelYIhqz4y/l/ePzfy4ZXeeOyjhTzOT8fb2o/MJ+7YwdWgq+mR IEbltpC9tImOwH5p+znYHz2SPNonoYrEHwZjUXt7jRq7VoqTmHxV4ShULj6qhA4Q +EBDbxGinmdBGFirGvqKQIK0Zp3vElkByrjsK8j9RAdndyuD0veyr5XWKzrPpvrA ORlLwakgpnnR31aAMs7VdKtkaOIC4+JUDvG+hMt3GSuvexx00Q== Received: from ilclpfpp02.lenovo.com ([144.188.128.68]) by mx0a-00823401.pphosted.com (PPS) with ESMTPS id 3xysg2res6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 May 2024 23:47:48 +0000 (GMT) Received: from ilclmmrp02.lenovo.com (ilclmmrp02.mot.com [100.65.83.26]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ilclpfpp02.lenovo.com (Postfix) with ESMTPS id 4VYw1v4yRHzc3Hg; Tue, 7 May 2024 23:47:47 +0000 (UTC) Received: from ilclasset02 (ilclasset02.mot.com [100.64.49.13]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: mbland) by ilclmmrp02.lenovo.com (Postfix) with ESMTPSA id 4VYw1v4Lv1z3p6jp; Tue, 7 May 2024 23:47:47 +0000 (UTC) Date: Tue, 7 May 2024 18:47:46 -0500 From: Maxwell Bland To: "open list:BPF [GENERAL] (Safe Dynamic Programs and Tools)" Cc: Catalin Marinas , Will Deacon , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Zi Shen Lim , Mark Rutland , Suzuki K Poulose , Mark Brown , linux-arm-kernel@lists.infradead.org, open list , Puranjay Mohan , Josh Poimboeuf Subject: [PATCH bpf-next v3 3/3] arm64/cfi,bpf: Use DEFINE_CFI_TYPE in arm64 Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Proofpoint-GUID: 49LzqQaurmamECirz3wumR8bOIVMTJGG X-Proofpoint-ORIG-GUID: 49LzqQaurmamECirz3wumR8bOIVMTJGG X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-07_15,2024-05-06_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 suspectscore=0 mlxlogscore=999 malwarescore=0 spamscore=0 phishscore=0 clxscore=1015 lowpriorityscore=0 adultscore=0 impostorscore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405010000 definitions=main-2405070167 Corrects Puranjay Mohan's commit to adopt Mark Rutland's suggestion of using a C CFI type macro in kCFI+BPF. Signed-off-by: Maxwell Bland --- arch/arm64/kernel/alternative.c | 46 ++++----------------------------- 1 file changed, 5 insertions(+), 41 deletions(-) diff --git a/arch/arm64/kernel/alternative.c b/arch/arm64/kernel/alternative.c index 1715da7df137..d7a58eca7665 100644 --- a/arch/arm64/kernel/alternative.c +++ b/arch/arm64/kernel/alternative.c @@ -8,6 +8,7 @@ #define pr_fmt(fmt) "alternatives: " fmt +#include #include #include #include @@ -302,53 +303,16 @@ EXPORT_SYMBOL(alt_cb_patch_nops); #ifdef CONFIG_CFI_CLANG struct bpf_insn; - /* Must match bpf_func_t / DEFINE_BPF_PROG_RUN() */ extern unsigned int __bpf_prog_runX(const void *ctx, const struct bpf_insn *insn); - -/* - * Force a reference to the external symbol so the compiler generates - * __kcfi_typid. - */ -__ADDRESSABLE(__bpf_prog_runX); - -/* u32 __ro_after_init cfi_bpf_hash = __kcfi_typeid___bpf_prog_runX; */ -asm ( -" .pushsection .data..ro_after_init,\"aw\",@progbits \n" -" .type cfi_bpf_hash,@object \n" -" .globl cfi_bpf_hash \n" -" .p2align 2, 0x0 \n" -"cfi_bpf_hash: \n" -" .word __kcfi_typeid___bpf_prog_runX \n" -" .size cfi_bpf_hash, 4 \n" -" .popsection \n" -); - +DEFINE_CFI_TYPE(cfi_bpf_hash, __bpf_prog_runX); /* Must match bpf_callback_t */ extern u64 __bpf_callback_fn(u64, u64, u64, u64, u64); - -__ADDRESSABLE(__bpf_callback_fn); - -/* u32 __ro_after_init cfi_bpf_subprog_hash = __kcfi_typeid___bpf_callback_fn; */ -asm ( -" .pushsection .data..ro_after_init,\"aw\",@progbits \n" -" .type cfi_bpf_subprog_hash,@object \n" -" .globl cfi_bpf_subprog_hash \n" -" .p2align 2, 0x0 \n" -"cfi_bpf_subprog_hash: \n" -" .word __kcfi_typeid___bpf_callback_fn \n" -" .size cfi_bpf_subprog_hash, 4 \n" -" .popsection \n" -); - +DEFINE_CFI_TYPE(cfi_bpf_subprog_hash, __bpf_callback_fn); u32 cfi_get_func_hash(void *func) { - u32 hash; - - if (get_kernel_nofault(hash, func - cfi_get_offset())) - return 0; - - return hash; + u32 *hashp = func - cfi_get_offset(); + return READ_ONCE(*hashp); } #endif -- 2.34.1