From patchwork Mon Nov 14 11:43:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 13042175 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2922AC433FE for ; Mon, 14 Nov 2022 11:45:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A7D046B0073; Mon, 14 Nov 2022 06:45:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A2C736B0074; Mon, 14 Nov 2022 06:45:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8F56E6B0075; Mon, 14 Nov 2022 06:45:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 80CC16B0073 for ; Mon, 14 Nov 2022 06:45:42 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 5C4061C6654 for ; Mon, 14 Nov 2022 11:45:42 +0000 (UTC) X-FDA: 80131868124.02.F9486A7 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf08.hostedemail.com (Postfix) with ESMTP id 011CA160006 for ; Mon, 14 Nov 2022 11:45:40 +0000 (UTC) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 1983361090; Mon, 14 Nov 2022 11:45:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E91DC43470; Mon, 14 Nov 2022 11:45:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668426339; bh=88jaPx4iCX4zMvSz58mQ2Zj5p3k63uCxoL6FcunYz3s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ivICbmQi7wHzNyqcXXy2gBkoVBoBCTmkhvCzCikjByib4s8RaoY1lW4WmY9i9fJB5 fYZtyMMcxvFxBADEGFKQdsa3WruxjgLmBiWGmXivBeRy8kLTjLOmEAweToWxhQ6yz+ x0LdG1T+pvu8StRDeYlGH0Tdyy/ePWCQ/Sv+rDu7l45RUSDts6OddVrDlDVLJAdfl8 +GmcClU8zPprpmtMhRrIPMLXfJ8PvLzwBu49jJzmOaY+cmjBFdgkwJ1Rc5viBYm/GK /AbTQVDinVxn/OvJ40QkgSYd9IXHHQ9KE/H5v6KLBpoVlHLMGb92iJ1uONOwOTZGtC 5+9YnP17R7gUg== From: "Jiri Slaby (SUSE)" To: linux-kernel@vger.kernel.org Cc: Martin Liska , Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Vincenzo Frascino , Andrew Morton , kasan-dev@googlegroups.com, linux-mm@kvack.org, Jiri Slaby Subject: [PATCH 42/46] mm/kasan, lto: Mark kasan mem{cpy,move,set} as __used Date: Mon, 14 Nov 2022 12:43:40 +0100 Message-Id: <20221114114344.18650-43-jirislaby@kernel.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221114114344.18650-1-jirislaby@kernel.org> References: <20221114114344.18650-1-jirislaby@kernel.org> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668426341; a=rsa-sha256; cv=none; b=LqLB18ED6L0JWCRWZ+L7ligMxBilhcS7M2LqAFthyetHTBljUPegKHUCaGwqzqRNy6d319 k5kMk3Xavf2CKNNVnzdPc7LflO/NmUcVquAFABWsjr1MfIWfQrmY0TsFkViGg1R28s+x6S LrKJ10/wWqPLJ58WC9b8gZ5e5tcWVOk= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ivICbmQi; spf=pass (imf08.hostedemail.com: domain of jirislaby@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jirislaby@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668426341; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=BfbFJP9xIxthF4S61VznWCy99JUkc3m8GUdJ+Jei+2g=; b=7Pr1QTs67s4sHY3PojHHb5tHaxG7tloTK314Y84CVZfzHNP4MfZCmgHP8nVvl/NgLxcemO N/eU/uhtwFP9sOO+zOF08W1K+8nYoi2gPVOH1LhB0cJ7CiTgEON9/0QbyryNTELyor5zIZ 2UV/wobVBUFC1Z7tfZqDavB1DDB6riE= X-Stat-Signature: jkohn1bq6ky5a3knna1csuakbwsznqqe Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ivICbmQi; spf=pass (imf08.hostedemail.com: domain of jirislaby@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jirislaby@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Rspamd-Server: rspam10 X-Rspam-User: X-Rspamd-Queue-Id: 011CA160006 X-HE-Tag: 1668426340-380167 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Martin Liska gcc doesn't always recognize that memcpy/set/move called through __builtins are referenced because the reference happens too late in the RTL expansion phase. This can make LTO to drop them, leading to undefined symbols. Mark them as __used to avoid that. Cc: Andrey Ryabinin Cc: Alexander Potapenko Cc: Andrey Konovalov Cc: Dmitry Vyukov Cc: Vincenzo Frascino Cc: Andrew Morton Cc: kasan-dev@googlegroups.com Cc: linux-mm@kvack.org Signed-off-by: Martin Liska Signed-off-by: Jiri Slaby --- mm/kasan/shadow.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/kasan/shadow.c b/mm/kasan/shadow.c index 0e3648b603a6..94c98feea9c8 100644 --- a/mm/kasan/shadow.c +++ b/mm/kasan/shadow.c @@ -39,7 +39,7 @@ bool __kasan_check_write(const volatile void *p, unsigned int size) EXPORT_SYMBOL(__kasan_check_write); #undef memset -void *memset(void *addr, int c, size_t len) +__used void *memset(void *addr, int c, size_t len) { if (!kasan_check_range((unsigned long)addr, len, true, _RET_IP_)) return NULL; @@ -49,7 +49,7 @@ void *memset(void *addr, int c, size_t len) #ifdef __HAVE_ARCH_MEMMOVE #undef memmove -void *memmove(void *dest, const void *src, size_t len) +__used void *memmove(void *dest, const void *src, size_t len) { if (!kasan_check_range((unsigned long)src, len, false, _RET_IP_) || !kasan_check_range((unsigned long)dest, len, true, _RET_IP_)) @@ -60,7 +60,7 @@ void *memmove(void *dest, const void *src, size_t len) #endif #undef memcpy -void *memcpy(void *dest, const void *src, size_t len) +__used void *memcpy(void *dest, const void *src, size_t len) { if (!kasan_check_range((unsigned long)src, len, false, _RET_IP_) || !kasan_check_range((unsigned long)dest, len, true, _RET_IP_))