From patchwork Tue Apr 4 08:43:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qing Zhang X-Patchwork-Id: 78930 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2871033vqo; Tue, 4 Apr 2023 01:48:05 -0700 (PDT) X-Google-Smtp-Source: AKy350ag0W2GiZoyW98vx6ccqgqeLVrP70KlQVxKP+a2KQX3pWVbo8Mr+uNG5E7jwf85tlj64H8O X-Received: by 2002:a50:ec91:0:b0:4fd:c5e:79b8 with SMTP id e17-20020a50ec91000000b004fd0c5e79b8mr1722150edr.32.1680598084842; Tue, 04 Apr 2023 01:48:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680598084; cv=none; d=google.com; s=arc-20160816; b=TX+nLFzzmnKo08sVBJ9x5KYxANmmA7SUm3s42jsZ+WiOQS+5qVMJMycDAmDVN6vTCi y/OH9eSAoew0a4kBkA78BoURDP0aabBtKwzx4ZBd3/t3rGTGF4XDz1icRj+yAhmcUD7I 99Tjfkub2kL2FItmSkzZfzwP44BbHC8AUBJ1eCKEfG7kZ3oYvvFqO9YbKMIMTtZKnIzF 7TW1cZTw1y/iqIP/w3HY6Io8dPGOXj738kJfic/4/0leqsZh81qg9uI+ulCftLD2/5N5 u6pfQMVtNtEI+gfRwi93dtjXSSMGUAsJQAeUbMRmN3fL6n7QiuujMmHfq8A548a/4uY1 1DDQ== 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; bh=ojSUF8/qqXE/bnfEFAt+zRgTWbIStxDciISKhrAb4TM=; b=SOjZLa1kS5JGhG0h+fU5M15tmZYYDs7oo9tWTCbf0qLh7lh0+5B2Ck///+fgHCm78p TKhPkbrIzIDces2T6MO20UBvwliokX8tRwXkq6ackT1Wnqdl+oFcKOACbAWpr8f0++3o 7zS+Dpbp1MKbjNUUscDiRqvZtmBhk6diJSELqOJu2YM9TbqjWYensenWP8Jhd5Sv/asg /nSA6H5PHb/M9YVRHi8lvsGkvhtJ+jCGB4CW83k9ZgQcpn0JgRaVfC1tljWNIWpO3VbW dmSKMQDEXS7/E1so3a3T8R90Rb28npBJPNu13P23Eo98G8bg+zMcs6AzYYyLoEw5+FQF TilA== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v14-20020a056402184e00b004c5a8aa02fcsi272899edy.435.2023.04.04.01.47.41; Tue, 04 Apr 2023 01:48:04 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234037AbjDDInf (ORCPT + 99 others); Tue, 4 Apr 2023 04:43:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233983AbjDDInZ (ORCPT ); Tue, 4 Apr 2023 04:43:25 -0400 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B6733211D; Tue, 4 Apr 2023 01:43:14 -0700 (PDT) Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8AxYeUh4ytkx10WAA--.34733S3; Tue, 04 Apr 2023 16:43:13 +0800 (CST) Received: from localhost.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8AxT+Qc4ytkChcVAA--.55041S4; Tue, 04 Apr 2023 16:43:12 +0800 (CST) From: Qing Zhang To: Andrey Ryabinin , Jonathan Corbet , Huacai Chen , Andrew Morton Cc: Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Vincenzo Frascino , WANG Xuerui , Jiaxun Yang , kasan-dev@googlegroups.com, linux-doc@vger.kernel.org, linux-mm@kvack.org, loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH v2 6/6] LoongArch: Add ARCH_HAS_FORTIFY_SOURCE Date: Tue, 4 Apr 2023 16:43:08 +0800 Message-Id: <20230404084308.813-3-zhangqing@loongson.cn> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230404084308.813-1-zhangqing@loongson.cn> References: <20230404084308.813-1-zhangqing@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8AxT+Qc4ytkChcVAA--.55041S4 X-CM-SenderInfo: x2kd0wptlqwqxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBjvJXoW7uF1xtF18KFW5Gr1ktw4DXFb_yoW8WFyrpF nrA3s5Jr48CFn7AFWjy34UWryUWF97Kr42gFyYya48AFy3XryDXrs2q3Z0vFy5Za1rG3yx uFyfWa4aqF4DX37anT9S1TB71UUUUb7qnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU b6xYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s 1l1IIY67AEw4v_Jrv_JF1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UM2 8EF7xvwVC2z280aVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gr1j6F4U JwAaw2AFwI0_Jw0_GFyle2I262IYc4CY6c8Ij28IcVAaY2xG8wAqjxCEc2xF0cIa020Ex4 CE44I27wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_ZF0_GryDMcIj 6I8E87Iv67AKxVWxJVW8Jr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JMx kF7I0En4kS14v26r1q6r43MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4U MxCIbckI1I0E14v26r1q6r43MI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI 0_JrI_JrWlx4CE17CEb7AF67AKxVW8ZVWrXwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE 14v26w1j6s0DMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UMIIF0xvE42xK8VAvwI 8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWxJVW8Jr1lIxAIcVC2z280aVCY1x0267AK xVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x07jDjjDUUUUU= X-Spam-Status: No, score=-0.0 required=5.0 tests=SPF_HELO_PASS,SPF_PASS autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762234817246622369?= X-GMAIL-MSGID: =?utf-8?q?1762234817246622369?= FORTIFY_SOURCE could detect various overflows at compile and run time. ARCH_HAS_FORTIFY_SOURCE means that the architecture can be built and run with CONFIG_FORTIFY_SOURCE. Select it in LoongArch. See more about this feature from commit 6974f0c4555e ("include/linux/string.h: add the option of fortified string.h functions"). Signed-off-by: Qing Zhang --- arch/loongarch/Kconfig | 1 + arch/loongarch/include/asm/string.h | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig index 61f883c51045..6c525e50bb7c 100644 --- a/arch/loongarch/Kconfig +++ b/arch/loongarch/Kconfig @@ -11,6 +11,7 @@ config LOONGARCH select ARCH_ENABLE_MEMORY_HOTPLUG select ARCH_ENABLE_MEMORY_HOTREMOVE select ARCH_HAS_ACPI_TABLE_UPGRADE if ACPI + select ARCH_HAS_FORTIFY_SOURCE select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS select ARCH_HAS_PTE_SPECIAL select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST diff --git a/arch/loongarch/include/asm/string.h b/arch/loongarch/include/asm/string.h index a6482abdc8b3..5bb5a90d2681 100644 --- a/arch/loongarch/include/asm/string.h +++ b/arch/loongarch/include/asm/string.h @@ -28,6 +28,10 @@ extern void *__memmove(void *__dest, __const__ void *__src, size_t __n); #define memcpy(dst, src, len) __memcpy(dst, src, len) #define memmove(dst, src, len) __memmove(dst, src, len) +#ifndef __NO_FORTIFY +#define __NO_FORTIFY /* FORTIFY_SOURCE uses __builtin_memcpy, etc. */ +#endif + #endif #endif /* _ASM_STRING_H */