Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2074696lqo; Mon, 13 May 2024 07:15:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVxPv+3+CHlvpwiX0oYoPPtmkFAIvDkU9tmT84FTN6iXMYbT9hl32cBPVkhh7xTPH5ayPnCj1aFTmLB737UQaMyRQNIHXEJTAkeP1++Rw== X-Google-Smtp-Source: AGHT+IE7BTQDSkKXOJSlgjNKyQxHTg8OXwEBz7AoMWfqbaLb5PvIpty7vwnPGTGI6PKS+SmI8vsi X-Received: by 2002:a05:6a21:9985:b0:1af:8106:e046 with SMTP id adf61e73a8af0-1afde191e41mr13788211637.20.1715609718768; Mon, 13 May 2024 07:15:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715609718; cv=pass; d=google.com; s=arc-20160816; b=vOGpEMFsFtx8GJJcPJmhRrBrOZ1jqmH6brlZmtYOLO59Vdc+RKh0a18cR74MX+Uglc a0zCZm3EiPcafMifqhQvoMkKEpDCYdTpbBeRctWohMwK5lo5iZff5tYTFhkjLKbPFZQD 1XiZrEbR+D5N5OXW41UPHq9wfoKFJbM92DfgHb2CGzvLoJy6tOd9LEwxDoG0uX6Jhuw1 Hzo3bRHK/73h4Lnkx2agMv8uL7QCuBox1ifmwWqpOoFuWPJUWT9t9SaXabQLhBffp4md emtfv3BhiBAn+TWChn6sQZobCMncekR2tfYCqiZkKQTgJVYVkGaU7ehiVNb3X0DAHCFl gV7g== 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=6T1cn+zZISETfkSQY+ffbsWoINvS+CfK4zu/XnbAny8=; b=And5jq5Hw5Ok+6kDpcbycp6k/XmKVVP69FyJv8mx+OlIaHdz9rNmojsUwGrJRUj5dZ 4DeIv0z59aJRValeatYHdoqaIm05Ia/Mcphk4U2YOOOtUpW8Tv7q5k9c/lsSqtQfvwzx BJ6t4WdXDHarKzC1PK+/3QU9kFbQ4hJH7I2pGNUrvE63v+eBf6g2VKrwxJVv6LINZznY 1n4Pa7x3Ik93lJj8x6h09Ae9znVTGTvq4/5HEXqfJKl7MZpOOLTUuA6+HRYvPXgrB/oN CndfWm6WBxcwB7lq2qFIgAJljUzwKmDDO/yNeIqDYgli9Ko3Urh1YraowaCqxMWjGi33 wkDg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@motorola.com header.s=DKIM202306 header.b=TACf0VYb; 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-177684-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177684-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=motorola.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6341020c762si9506859a12.302.2024.05.13.07.15.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 07:15:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-177684-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=@motorola.com header.s=DKIM202306 header.b=TACf0VYb; 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-177684-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177684-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id BFD6D2826E6 for ; Mon, 13 May 2024 14:15:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 21A37153BEE; Mon, 13 May 2024 14:14:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=motorola.com header.i=@motorola.com header.b="TACf0VYb" Received: from mx0b-00823401.pphosted.com (mx0b-00823401.pphosted.com [148.163.152.46]) (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 BD532153819; Mon, 13 May 2024 14:14:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.152.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715609698; cv=none; b=XULjaHfVfQVMEvSoJAdBXR1M0EleYJQ85ArpBrAxxpExIN0ArBuhQeCXfpKBQ0mAu/lyrpowRt6b8TP7VkZQdeDJWDyV11ukQLFj+HcLrmapv6AzJTQ/D2ciFtijr3m2VmhAoDJ+5/MwL+06erBR/1V9GfuJnGZ9PzC9+mLlyGA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715609698; c=relaxed/simple; bh=33erqRfm50dy4WDDGbSJahdMBXSmjtcQRIZ3HCaaYI4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=sblQaTUbqWUB6tam1JtJm8G3ael3KuM7DAD87dGMSMfrIfSKQBJZ7/Cu1tBwoOCpLdN54Jnn9xQmeaeJbu5dbEiVqGbbsFCk1Zv2nBk1zfPKLsc0mw1XAE1W7FWhflte0WWnLwzKq6zHBH+X2sfgmc3uVqXxpCyNd4qEgK1zod8= 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=TACf0VYb; arc=none smtp.client-ip=148.163.152.46 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 (m0355091.ppops.net [127.0.0.1]) by mx0b-00823401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 44D8L2M2009106; Mon, 13 May 2024 14:14:36 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=TACf0VYbDPMCX0OE4JNy0nGlAviTf3TODoMQ XP17gE708/pc0ygl58pjCramAzizQUd5xc8XxQW2KR0cksdUOTm2nzAis+fj/8os C6gDfWWwYj2UE1UmNEKsMQ4OIzh16ZeTndbeJj+eVasZ/FedduLL3nmdsCyPN5us cKxjftxyS0VwQX90xMoMmlE3Kn1ea/HKBCkSIDH4IWtvsemL8UB8uPrWRVodHm7N s9QOnH+DGI7pdt6nOAlhZq70m/QoK3Z/F7qBANobywZ7MoDosD3z0IhxUAUPzhZ8 vfywqGUch3U41uBly1gcNd0DgP/SqEbEE5KrMTrniydxT3jjuw== Received: from va32lpfpp02.lenovo.com ([104.232.228.22]) by mx0b-00823401.pphosted.com (PPS) with ESMTPS id 3y30gh9tfw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 May 2024 14:14:35 +0000 (GMT) Received: from va32lmmrp01.lenovo.com (va32lmmrp01.mot.com [10.62.177.113]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by va32lpfpp02.lenovo.com (Postfix) with ESMTPS id 4VdM1l1TmPz50TkW; Mon, 13 May 2024 14:14:35 +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 va32lmmrp01.lenovo.com (Postfix) with ESMTPSA id 4VdM1k536Nz2VZRw; Mon, 13 May 2024 14:14:34 +0000 (UTC) Date: Mon, 13 May 2024 09:14:33 -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 , Josh Poimboeuf , Puranjay Mohan Subject: [PATCH bpf-next v4 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: ejn-Tuy6x7RGGoUP3mZrfDZYJKj-CR2c X-Proofpoint-ORIG-GUID: ejn-Tuy6x7RGGoUP3mZrfDZYJKj-CR2c 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-13_09,2024-05-10_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 phishscore=0 clxscore=1015 mlxlogscore=999 priorityscore=1501 mlxscore=0 spamscore=0 impostorscore=0 bulkscore=0 lowpriorityscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405010000 definitions=main-2405130089 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