From nobody Sun May 24 20:34:04 2026 Received: from mail-wr1-f74.google.com (mail-wr1-f74.google.com [209.85.221.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9DCEB3CAE99 for ; Thu, 21 May 2026 12:27:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779366460; cv=none; b=tU53DDylxeE+R1Cfse/IVx7oPZwGr7zFLvt4k0sVjcHMdL+t6h0aHuP+8c/kFtm/JEhyeUSTnZvKM2iCO8O55NY3vrudoVwtBavlP+A0YIrqWqE+Rv+OkdxdFC3gC0Hsp3uh6fnY8EtmJU1s++1sjVsplOJlIyuyCrrhwe3fQ/Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779366460; c=relaxed/simple; bh=M+Mk7QbXAKpkL60TJYSGOP1LwJIztNUkg4IEWFcJJr0=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=BG0xFi06kxKv4ih5xM2HZJf/nDA/1jVJsFMxNIHkjYtlOURvP+eCS5iliFcgufKrJPRi5+LnOYIDMgSDEc8ClRmWxEOw1PgAykwH2ffuo4gICfa2vFfB4hvZgSF52jgd0vkXc0VKHFvz9bZDarvku9ZLTpkhpcZtaebEAaK+ITw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--elver.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=EUxke5aC; arc=none smtp.client-ip=209.85.221.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--elver.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="EUxke5aC" Received: by mail-wr1-f74.google.com with SMTP id ffacd0b85a97d-43d789cebcfso4649364f8f.1 for ; Thu, 21 May 2026 05:27:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1779366457; x=1779971257; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=BH74M0iFxFJ7OeF2nKs4ve50vTBJ6yjjR8WAtMsTpJ0=; b=EUxke5aCLIxmL87w5YgCejINSSk2CsD/F0c58wucB2ZDAaPfp83+T3eXirOCfmWnIB Z3Cbwjkx7prACsALwXWzCtCGQFyOtMEM4UypGx53JrFKBxEDIfrpx+EMmH+wHr3uCclF vGJeUZIy9FbKInnRLiOqYA/e1ZQ6twJIkzdn//appyXnI9rxeG/EgeI9wEGwlWv+/eHo pvzYZvGH0fbeyZBlt9h4V7mnypV0xKumaJ8qzVkZgE8HONTifax3L15gvcB1KiJ6atjU nUVMnKMOwJ7Eg/w4n5515B0s7mUfczBCLfp2A6hYisEWpl/DidN+B1rT9+UW1z/CYqJZ zjLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779366457; x=1779971257; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=BH74M0iFxFJ7OeF2nKs4ve50vTBJ6yjjR8WAtMsTpJ0=; b=Homb3vq7fuydNnb6PtLDf376gC+oXsBZTL//8qWL1h1+hEKgvXi7Y8i7/J/DThUrHD WCPuqH/ixkr+gduSBdiUFm4isUrupZFlr+wr+GmGpeoYK+vNyM3pnRdd3hm0tcysOADC MnKXGEOGD6P3/Y7w+7mBxQ71sI7Wv2/PZm+o9khTA5m1csGAyKxe8WugPLXiSuCjfJ12 RmzdpstsK1Hka4gS5AOSWk3TKHJJAldTx2iFTjiMic0hRppvN/UcYzykKbVj/iCj3sq2 SG/M5iR4/xKYUITrkWOZIqqiIEPmtdtnjfIRplzUVYpSear509Esymas6kes0lwu6tBO Tfsg== X-Forwarded-Encrypted: i=1; AFNElJ9TKh3T+c/gI6NfVIvua4Nlwz5oJhlKa5Ie/SwA3OpcxjSHKNoS1xlBHGO/oAsCMzMFIEy6kePDrYiTdHo=@vger.kernel.org X-Gm-Message-State: AOJu0YzmbfPZiu+TU2HCkEdzNt3tlYkXGKS+b5Qoa8LK1tJkpCvfXSX9 jtnN9WGg65yIcuOvpxcAi9xmAsvscFr7aJeO7IhcCjt44+TpMhwo/ZZg6oHNvWUrIQ18c1bxOGG +gQ== X-Received: from wmbhn25.prod.google.com ([2002:a05:600c:a399:b0:490:3e3f:8c8d]) (user=elver job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:490f:b0:48a:5339:a46 with SMTP id 5b1f17b1804b1-49036090799mr19423255e9.9.1779366456918; Thu, 21 May 2026 05:27:36 -0700 (PDT) Date: Thu, 21 May 2026 14:27:23 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.54.0.746.g67dd491aae-goog Message-ID: <20260521122727.142280-1-elver@google.com> Subject: [PATCH] s390: Implement _THIS_IP_ using inline asm From: Marco Elver To: elver@google.com Cc: Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Both GCC [1] and Clang [2] consider the generic version of _THIS_IP_ to be broken: #define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__= here; }) In particular, the address of a label is only expected to be used with a computed goto. While the generic version more or less works today, it is known to be brittle and may break with current and future optimizations. For example, Clang -O2 always returns 1 when this function is inlined: static inline unsigned long get_ip(void) { return ({ __label__ __here; __here: (unsigned long)&&__here; }); } Fix it by overriding _THIS_IP_ in (which is included by ) using an architecture-specific inline asm version. Additionally, avoiding taking the address of a label prevents compilers from emitting spurious indirect branch targets (e.g. ENDBR or BTI) under control-flow integrity schemes. Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D120071 [1] Link: https://github.com/llvm/llvm-project/issues/138272 [2] Signed-off-by: Marco Elver --- arch/s390/include/asm/linkage.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/s390/include/asm/linkage.h b/arch/s390/include/asm/linkag= e.h index df3fb7d8227b..1b3ac553a642 100644 --- a/arch/s390/include/asm/linkage.h +++ b/arch/s390/include/asm/linkage.h @@ -7,4 +7,6 @@ #define __ALIGN .balign CONFIG_FUNCTION_ALIGNMENT, 0x07 #define __ALIGN_STR __stringify(__ALIGN) =20 +#define _THIS_IP_ ({ unsigned long __ip; asm volatile("larl %0, ." : "=3Dd= " (__ip)); __ip; }) + #endif --=20 2.54.0.746.g67dd491aae-goog