Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5385626rwb; Mon, 14 Nov 2022 04:03:28 -0800 (PST) X-Google-Smtp-Source: AA0mqf4YfoL1hoEf4C5FWcy1tD6A3FdcNB/PBNlzqFnSmt8aetmed5HDOAUuYi6Sn/z3pbGGfgL0 X-Received: by 2002:a63:5164:0:b0:46f:ec9f:dcb0 with SMTP id r36-20020a635164000000b0046fec9fdcb0mr11491622pgl.202.1668427407830; Mon, 14 Nov 2022 04:03:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668427407; cv=none; d=google.com; s=arc-20160816; b=UXDaZsBaV5scfNGY5L2bfscplXgN4HoADM3H3cE79eWR+Q6pP9Zpdrr6y9QQGlkkVI PJu3U98Jn0gomQzfwxkm2c4xJiPodfMpOKyMeziOIIL+1GdRtEEU3/E7X/ULncoVPeyX SJsTAbF/eFJuePtZ8arJzJqoeVDdq1dCPKTkA85IjdftvIcW85Fkp+Qltqz33k5gs3n/ EXpJ6q/YYi3n8vPC/3WrU8nhdot9LEz9Hw38pafa/HuJ8dage7nhQrv/C/OorzVZUi7t Ozwiu3u74ymQri8Hc2FwxwBcHQrqdLYtExsimPaE4+mwwA7C1gHFMnQE5ZXntOFYu7Sm CihA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BfbFJP9xIxthF4S61VznWCy99JUkc3m8GUdJ+Jei+2g=; b=cMO4Zi6KIwyFGrhhRQ4LUw5tJsLjVqTWDluLUvZ3eSI+bp92N/72qPsFt/4Vdpi97c OitrLaVa52v6teC1TOeeCh8NLg5+lKKz7gM0OogiJVjn+fA+Gvehnvvh8MA1Bd5GhPCW Yi38zN3RyAJRJt+tA4T6K2enNNBKje6Axlt8pE7HY9JDXgw6+uLTuEkQWtSbvFJQY+n8 wup9JJRi3wbGcjKRqh2OtowcS+8+177ATgmDrSrSIrFscKmtpc8xy6VMB7An4NNRj7Mk g4eZZzO1BArGvU+Ovrn2ICMXKSzJJCy9fDRPyMdT69z7DqCyW21TDDYjh4mG7NxnIp9h +c6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ivICbmQi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h185-20020a6383c2000000b0045c59e9a8a9si9693812pge.322.2022.11.14.04.03.08; Mon, 14 Nov 2022 04:03:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ivICbmQi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235929AbiKNLtH (ORCPT + 88 others); Mon, 14 Nov 2022 06:49:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236661AbiKNLsW (ORCPT ); Mon, 14 Nov 2022 06:48:22 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8093C26570 for ; Mon, 14 Nov 2022 03:45:42 -0800 (PST) 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 3E0CDB80E72 for ; Mon, 14 Nov 2022 11:45:41 +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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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_)) -- 2.38.1