From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7A2E0C433FE for ; Mon, 20 Dec 2021 22:53:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=/8Ct2772hq72H5IoViQfUuEZEkMyhpSREjEtoDM24AU=; b=uGMqXvO7gFHhqo fdzqR7bdDP4wWE+x3jtrBZH4VpcKc7E+nPyJgle5a2VhF9/w8bMDoL5UqRAnxOiDO4Vl1HYkHG7UA 9tdaPLlwRgsPtsjVwLPxuN+yTeFISL6xsCRihv9yVuK7u4jaJcJJpye37PN2CvaxA/2YkiUv3EsUO 5o1bHmcWi57tIko9mTIA2BlqyyIcXLsmo4do+QYj1WkshxL/98BKsQ4OdWI/XwYNaeD3iWYZwmfwj bIsCbRNNJ3vZrBerxktsc0QCZEIo30k/orzALYJ0SFTHw+cXZZv9gMnAoZ7w8iMd50xkUpIMA9y+z bueePksUvGkitCfXFghQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mzRWG-004tqE-Gi; Mon, 20 Dec 2021 22:52:36 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mzRWC-004tpc-57 for linux-arm-kernel@lists.infradead.org; Mon, 20 Dec 2021 22:52:33 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 8142EB810A5; Mon, 20 Dec 2021 22:52:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C9A5C36AE9; Mon, 20 Dec 2021 22:52:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1640040749; bh=xAfHTmDMaogwSyCDWwINv/XqJ79rd0dwLrpn1v7hL6M=; h=From:To:Cc:Subject:Date:From; b=LEVznOkbM0EgroJV8wxr9J7LCMqAFCCxEFJx5VF/rVt4ywDVgtHINg2gQKWbsxTCP SZJmrGotlLylkrvnJNC5U6CUYyKulJvQcc4GtUgv3P43tf50lJx94/nNy2ODVymnGQ DqP4p8tEK42DRJngyKUy76Ia/YR0fHulIje0gJqalG6mDhV47ev1u4PdOLgzaCIiHD /F87Th1Xc7H4lmwKR86/tmrxa9p2MB82zbm+3Dy3I3xIVQyXK2JqrirObnnNwy4AaV eIfy4rq5UtfQxDZCSTqvcpjRorPkQBM7kGX0dYmNexCRU6cwKOZFcDRdIO+Zda9IqO g3vZmZnc6RdyQ== From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: arnd@arndb.de, linux@armlinux.org.uk, Ard Biesheuvel , Nathan Chancellor Subject: [PATCH] ARM: current: prevent literal references from going out of range Date: Mon, 20 Dec 2021 23:52:17 +0100 Message-Id: <20211220225217.458335-1-ardb@kernel.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2114; h=from:subject; bh=xAfHTmDMaogwSyCDWwINv/XqJ79rd0dwLrpn1v7hL6M=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBhwQkgJlUVeQelShvHPs1cPEoD/5wN5wnY8bI4oXu7 PQMJMQ2JAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCYcEJIAAKCRDDTyI5ktmPJFNqC/ 4r9f9WWyAn33MGVp7fkxWawlZg+qPkSr5wXMT0e+AH2DjRzIkQULmYJysCf5iGv02uVeqo4WiEF1m7 Gp2CxmacrO/04QdqVteRHLdumR8+1j2J48xTbqFvaUx1PlcdQV0xFMTKPEOWQZbqfeJb4oRuZsJqZm oqejBxd7gnEXXXaEoi4Lhrgp8h1Gs72tI0NUx9jEiIzD6sCb69c3BZgidUf5ua+qh7wZHQOXlZ6iu9 KEPmx94wS2/mLzPaAcSx+OjhLRYx7o1h438qUq63Sei9SH4TswjkrmfwNqOZZ0C3PymBgscQylqj2s degx4imEFWpeK8gk8yg1XBWnejy5D+pzyeWma2S51WPIWfih3ThxrjavlJz7iiMtXcAX7Z7JbiweM1 hlw7F+e4TWvcYc7p+dmOYGKbpLqc3H2HYq4IkfzVo1dcdUJFZA03g6b0MabPybKjJz0rDvh+PWktJy +YH69rF6q854YwB6mOI5dy2xf7I23nJet0ONcDyJhDKKg= X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211220_145232_494106_3DE986EE X-CRM114-Status: GOOD ( 13.68 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Nathan reports that the new get_current() accessor may cause problems at build time due to the use of a literal to hold the address of the variable that stores the 'current' pointer. This is due to the fact that LLD before v14 does not support the PC-relative group relocations that are normally used for this, and the fallback relies on literals without emitting the literal pools explictly using the .ltorg directive. Since emitting a literal pool in this particular case is not possible, avoid the LOAD_SYM_ARMV6() entirely, and use the ordinary C assigment instead. While at it, add a .ltorg directive to the other instantiation of LOAD_SYM_ARMV6(), which could potentially suffer from the same issue, but can be fixed by an .ltorg directive due to the existence of an unconditional branch right after it. Fixes: 9c46929e7989 ("ARM: implement THREAD_INFO_IN_TASK for uniprocessor systems") Reported-by: Nathan Chancellor Link: https://github.com/ClangBuiltLinux/linux/issues/1551 Signed-off-by: Ard Biesheuvel --- arch/arm/include/asm/current.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm/include/asm/current.h b/arch/arm/include/asm/current.h index 69ecf4c6c725..6b2e4c9fae35 100644 --- a/arch/arm/include/asm/current.h +++ b/arch/arm/include/asm/current.h @@ -39,6 +39,7 @@ static inline __attribute_const__ struct task_struct *get_current(void) " .subsection 1 \n\t" "2: " LOAD_SYM_ARMV6(%0, __current) " \n\t" " b 1b \n\t" + " .ltorg \n\t" " .previous \n\t" " .pushsection \".alt.smp.init\", \"a\" \n\t" " .long 0b - . \n\t" @@ -46,7 +47,8 @@ static inline __attribute_const__ struct task_struct *get_current(void) " .popsection \n\t" #endif : "=r"(cur)); -#elif __LINUX_ARM_ARCH__>=7 || \ +#elif __LINUX_ARM_ARCH__>= 7 || \ + (defined(CONFIG_LD_IS_LLD) && CONFIG_LLD_VERSION < 140000) || \ (defined(MODULE) && defined(CONFIG_ARM_MODULE_PLTS)) cur = __current; #else -- 2.30.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel