From nobody Sun Feb 8 23:41:20 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 D8EEC21C17B for ; Wed, 30 Apr 2025 09:20:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746004819; cv=none; b=Feg1Pul4KLYts3QQj3GLg5cutmuPLBg2vgPf0lXlmh98xshquaFKFc9I1YRSA2h/+dC5T0FtI4dFQMFWSNc1w/cYXk61iV/8BlZ+ChMT4a0zSmYsggOKCyuFv09KXp/2DRmZVW9G9IR6cnNx4HsJlgK2eHiLPbGHT9ASjxBJzfM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746004819; c=relaxed/simple; bh=wPiVAyb4i0INmlrU5d1yJoYnmvXNkJvqm5DWeZRgR8w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SHzeSd1hrTbah2J1/OzODWOoMet9WfDeDLgDSqQk9FLJFZYTbLezLTAMv4mPwqv1pa2n+QrP6WIvBUulOvX9dJNTfWUrC5JBUGmXFOAXd6sqVZTtPuzIKBXNrvVX2gQshsbUeNMuxIKevNjlPdILvM1XonVSLRUWurmkaJjwydE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=TlV2k7Hj; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=6o6yeKl2; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="TlV2k7Hj"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="6o6yeKl2" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1746004815; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Tdw8tH4FhSz345Xupp3UnovvlZsLVACqjoY1xoiC/XI=; b=TlV2k7HjEyUtI111dsE8HdMprDL8k8ChNFqGvZZgGQg5RSs1dNwn7D4/yRXcTOMXqFWVjF gXX4LZhlK6lfTIwtqQzamEYSHqrpaVHq+4I6YdtXGUsJ2OH4+H/95dnj2v934vCKX05Ysr X1NziDjXAgXJ8NJ4dtRiBiQU5nKZrptXTxeP7oJyQX+81UArqmE1KwIcM6OARtKfCwbvWi vBCQVB56SyH7vz9DJ7ldbVmhpe6HJikB5gdRK7aiYgDwdJXHB25aQTkjACsDRcjZaW659p VEGypwiZ1x1CTyb5kvWdlDustiZnSZe6jxDQZVoNQOxJzp1RUr91g+bj+A/tNA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1746004815; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Tdw8tH4FhSz345Xupp3UnovvlZsLVACqjoY1xoiC/XI=; b=6o6yeKl2GNoHSR63/A4JZRNlkRy1NlvQuK+afR0NPgbHOONIBm3YfS26FUtfSM91EYAB1L 7KYJ8WToW5yI3sBg== Date: Wed, 30 Apr 2025 11:20:13 +0200 Subject: [PATCH v2 1/2] arm64: vdso: Work around invalid absolute relocations from GCC 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="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250430-vdso-absolute-reloc-v2-1-5efcc3bc4b26@linutronix.de> References: <20250430-vdso-absolute-reloc-v2-0-5efcc3bc4b26@linutronix.de> In-Reply-To: <20250430-vdso-absolute-reloc-v2-0-5efcc3bc4b26@linutronix.de> To: Catalin Marinas , Will Deacon , Nam Cao , Anna-Maria Behnsen , Thomas Gleixner , Andy Lutomirski , Vincenzo Frascino Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Jan Stancek , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1746004814; l=1869; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=wPiVAyb4i0INmlrU5d1yJoYnmvXNkJvqm5DWeZRgR8w=; b=OjSnD9IkRXm7nMcxWypWAcqqSkKe9ShzBQuKcW5bcMFfpvC3AHuQDqr8Masw4P8vEGYwKl1sd t1dW5bq6bkUCHEYe4JaHZmqp51QRvnIBf/DI/VUZn6OGmSayc6j8mUj X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= All vDSO code needs to be completely position independent. Symbol references are marked as hidden so the compiler emits PC-relative relocations. However GCC emits absolute relocations for symbol-relative references with an offset >=3D 64KiB. After recent refactorings in the vDSO code this is the case in __arch_get_vdso_u_timens_data() with a page size of 64KiB. Work around the issue by preventing the optimizer from seeing the offsets. Reported-by: Jan Stancek Closes: https://lore.kernel.org/lkml/aApGPAoctq_eoE2g@t14ultra/ Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D120002 Fixes: 83a2a6b8cfc5 ("vdso/gettimeofday: Prepare do_hres_timens() for intro= duction of struct vdso_clock") Signed-off-by: Thomas Wei=C3=9Fschuh Acked-by: Catalin Marinas Tested-by: Jan Stancek --- arch/arm64/include/asm/vdso/gettimeofday.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arch/arm64/include/asm/vdso/gettimeofday.h b/arch/arm64/includ= e/asm/vdso/gettimeofday.h index 92a2b59a9f3df4d20feb483e6d8ebd1d813b7932..3322c7047d84fecae316a2904f1= adec0cb458f6f 100644 --- a/arch/arm64/include/asm/vdso/gettimeofday.h +++ b/arch/arm64/include/asm/vdso/gettimeofday.h @@ -99,6 +99,19 @@ static __always_inline u64 __arch_get_hw_counter(s32 clo= ck_mode, return res; } =20 +#if IS_ENABLED(CONFIG_CC_IS_GCC) && IS_ENABLED(CONFIG_PAGE_SIZE_64KB) +static __always_inline const struct vdso_time_data *__arch_get_vdso_u_time= _data(void) +{ + const struct vdso_time_data *ret =3D &vdso_u_time_data; + + /* Work around invalid absolute relocations */ + OPTIMIZER_HIDE_VAR(ret); + + return ret; +} +#define __arch_get_vdso_u_time_data __arch_get_vdso_u_time_data +#endif /* IS_ENABLED(CONFIG_CC_IS_GCC) && IS_ENABLED(CONFIG_PAGE_SIZE_64KB= ) */ + #endif /* !__ASSEMBLY__ */ =20 #endif /* __ASM_VDSO_GETTIMEOFDAY_H */ --=20 2.49.0 From nobody Sun Feb 8 23:41:20 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 A976021CFE0 for ; Wed, 30 Apr 2025 09:20:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746004820; cv=none; b=pVPqN+Ft9bDRVyBWlWcTFb9HxLx9zXwyFZVdx9vlUuAfAPVKYGbCWZDKcM2PReXui8nx5q9jk6MIbReYO4OXOKNEUyONbKLeFgaiGXJiYrK+AcMpU28C0CizHbY50b3ichhWheencJiLxwTac4S7q0n8StmwnCg4XaHweHtejSg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746004820; c=relaxed/simple; bh=4XMu6PmWiKJtEbyVlX4KrB4GS+s4XTABtUWp9SpHQiQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=X2gCg01FRhE+A6jhG9cPfpaOexGV2OZh5nXsI4CnIbUahX4cbxUeENXRl3bxNbZr0HIDyri9OnvSfkgk4vwu48B7WUbD8OMGDtp7Btzixh/RuHL6ElBgON1T/ZDgAPr7eQBfuh3zQpqSSxt/FF6MqKEspqo7hrMdpAyUM0jWe5s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=odcvcYZn; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=kquq+QO1; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="odcvcYZn"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="kquq+QO1" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1746004816; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=d925zDAc2kwfRYjdGcNdtwZzRyVS9rKiVQOcUxxA/Rg=; b=odcvcYZnuikNZQL0qcN0xJ5CtI02ZNWkKxiWWPa0Ad7N18LkC3CQ+FetrC+UdScYC//i5U mCL7lk/8CRdvYdd4YjL1sb5d5hM3LHEAdngRZk67EXt8S40C77f180yRkk4GG4QH+cgmF4 DEcIsEuKyxXxG6apDTwGtyUdpk8UqKr38z553TQO9tPRqm4zesGaPIbpOr1bgbngNcc31O 5QlShvanxG2utzLJmJHyFXTh2Fibee6CawliBrKfHUpCwg3zBGLibEAC/r75KRxzDBlNy5 aDEcljcmJiHauNHdz5tBfZZUBdZuOOZ7U5buJENEl/B5XcEi3YGxJQr67wB74Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1746004816; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=d925zDAc2kwfRYjdGcNdtwZzRyVS9rKiVQOcUxxA/Rg=; b=kquq+QO1AjUAsdKV+uxn/kzOsqePcd0L/V0SsrHjdlllIgJyjm459NiDdDAo4lmWXoLQnf L90sE0YSHNjk0BBQ== Date: Wed, 30 Apr 2025 11:20:14 +0200 Subject: [PATCH v2 2/2] vdso: Reject absolute relocations during build 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="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250430-vdso-absolute-reloc-v2-2-5efcc3bc4b26@linutronix.de> References: <20250430-vdso-absolute-reloc-v2-0-5efcc3bc4b26@linutronix.de> In-Reply-To: <20250430-vdso-absolute-reloc-v2-0-5efcc3bc4b26@linutronix.de> To: Catalin Marinas , Will Deacon , Nam Cao , Anna-Maria Behnsen , Thomas Gleixner , Andy Lutomirski , Vincenzo Frascino Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Jan Stancek , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1746004814; l=2113; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=4XMu6PmWiKJtEbyVlX4KrB4GS+s4XTABtUWp9SpHQiQ=; b=Cqd1NFTPQfdv48z6vCZlhE04UKM1O0irx1jjUv8xwS3PLV6Of9e/QUlOWgHhTkT7jW2dZRCDI 52v/1nA3ol5BBV5d+MbucP1kLfF+rFw3wczVF8rUcdcblECAskVVrgd X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= All vDSO code needs to be completely position independent. Symbol references are marked as hidden so the compiler emits PC-relative relocations. However there are cases where the compiler may still emit absolute relocations, as they are valid in regular PIC DSO code. These would be resolved by the linker and will break at runtime. Introduce a build-time check for absolute relocations. The check is done on the object files as the relocations will not exist anymore in the final DSO. As there is no extension point for the compilation of each object file, perform the validation in vdso_check. Debug information can contain legal absolute relocations and readelf can not print relocations from the .text section only. Make use of the fact that all global vDSO symbols follow the naming pattern "vdso_u_". Link: https://lore.kernel.org/lkml/aApGPAoctq_eoE2g@t14ultra/ Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D120002 Signed-off-by: Thomas Wei=C3=9Fschuh Tested-by: Jan Stancek --- lib/vdso/Makefile.include | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/vdso/Makefile.include b/lib/vdso/Makefile.include index cedbf15f80874d4bb27c097244bc5b11272f261c..04257d0f28c0ed324e31adbb684= 97181085752f8 100644 --- a/lib/vdso/Makefile.include +++ b/lib/vdso/Makefile.include @@ -12,7 +12,13 @@ c-getrandom-$(CONFIG_VDSO_GETRANDOM) :=3D $(addprefix $(= GENERIC_VDSO_DIR), getrand # # As a workaround for some GNU ld ports which produce unneeded R_*_NONE # dynamic relocations, ignore R_*_NONE. +# +# Also validate that no absolute relocations against global symbols are pr= esent +# in the object files. quiet_cmd_vdso_check =3D VDSOCHK $@ cmd_vdso_check =3D if $(READELF) -rW $@ | grep -v _NONE | grep -q " = R_\w*_"; \ then (echo >&2 "$@: dynamic relocations are not supported"; \ + rm -f $@; /bin/false); fi && \ + if $(READELF) -rW $(filter %.o, $(real-prereqs)) | grep -q " R_\w= *_ABS.*vdso_u_"; \ + then (echo >&2 "$@: absolute relocations are not supported"; \ rm -f $@; /bin/false); fi --=20 2.49.0