Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp624150rwp; Wed, 12 Jul 2023 20:37:37 -0700 (PDT) X-Google-Smtp-Source: APBJJlHXBSsF197i2YQoPN6wPcjNhSng+sZ3Mmf2FhLKYge+CGkuONMThUTqPIxRZNr6I9QzNXKj X-Received: by 2002:a05:6358:419e:b0:134:ca8a:748b with SMTP id w30-20020a056358419e00b00134ca8a748bmr913309rwc.28.1689219457611; Wed, 12 Jul 2023 20:37:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689219457; cv=none; d=google.com; s=arc-20160816; b=Rb9RI+ri6MqHQowH74u7sXYoDDfDsC2Llm6xY4FEVMEM9LJkUByUFgUJp1cYKBE4An sNHfL7QtMIKFBOzB6EXE0r7fkjVeBYM0O4N0BdCDGrd6xdKPt/3IFoI6VAXQub7Y2I6N dIt32c4sDg8q2LtL1lbSavSuIfVvi9mlfoC8WdJ+jR6sh9Wc9r7yQ0JT3lAa+gbS8P1a 9Wt68c0fn5CYQgIjFANp6nga8VM0tzXTaL5od0kEKiK2qUClZWXKoBcw8e8Zyg0nmUhW z1X5qsRCE6x5BjruKf6OPw9xXc/yOIps4bCPQL0HwVNhox+h9HPcSy9i8ldRhrNz1JQc KRzw== 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 :message-id:date:subject:cc:to:from; bh=FQlQIoJTKxVaBgn+EiSyLLdyxkkcXrk7qi9/ZIQie3o=; fh=qZgBFIh4LJZek7JPqnomvY/9UiEqcYMgEtT8j/5QB/k=; b=klEonoF4QAJqh80sF3B0ErbBmHEZmVcveNJ0pM3p7AQvfunPQ0gZ74FwmR3bGOlBUu 4H7ppz8UIFJOMC8jNZlWswtauzXBRfrX3PfUvsPInjOZ80sAgvU7W7mBhuCTEDH9dFat 4gjjwOYKnBzIkMliW68oQ+XqjbYQBCqGpTmo0WQzskJuKcARzS+CWB3dhUVFiEnEcaX+ PqKCIVPVaa84t3pVHjc0B3VhZ1TaLjqZS/Zl/AkGmwOQlFiFwfPuc1jIAll88LO5QaA4 i8igy+L7r0TbGeGYdp98uMCfIbvDveWjbheCaYR4ApWMcXtq1eOTbOeTRwyWWtbTO2Ev cilg== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r10-20020a170902e3ca00b001a1e0fd406csi4369354ple.217.2023.07.12.20.37.25; Wed, 12 Jul 2023 20:37:37 -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 S233446AbjGMDFd (ORCPT + 99 others); Wed, 12 Jul 2023 23:05:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231592AbjGMDFc (ORCPT ); Wed, 12 Jul 2023 23:05:32 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E0DED2113; Wed, 12 Jul 2023 20:05:22 -0700 (PDT) Received: from loongson.cn (unknown [117.82.195.59]) by gateway (Coremail) with SMTP id _____8BxHOvwaa9k0EEEAA--.6757S3; Thu, 13 Jul 2023 11:05:21 +0800 (CST) Received: from localhost.localdomain (unknown [117.82.195.59]) by localhost.localdomain (Coremail) with SMTP id AQAAf8CxriPuaa9kSZ4rAA--.16906S2; Thu, 13 Jul 2023 11:05:20 +0800 (CST) From: WANG Rui To: Huacai Chen , WANG Xuerui Cc: Jun Yi , Tiezhu Yang , loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, WANG Rui , stable@vger.kernel.org, Weihao Li Subject: [PATCH] LoongArch: Fix return value underflow in exception path Date: Thu, 13 Jul 2023 11:04:53 +0800 Message-ID: <20230713030453.7404-1-wangrui@loongson.cn> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8CxriPuaa9kSZ4rAA--.16906S2 X-CM-SenderInfo: pzdqw2txl6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBj93XoW7CrWxZFW3KFW3tw45Gw47WrX_yoW8Zw4fpr y7Arn7KF48WFyfZa4YvF9YqrWrXF47Ww17uF4xAryrGa4DZFn5uryrGasxXFs0q395Xr10 qr1rKF4rCF48JwbCm3ZEXasCq-sJn29KB7ZKAUJUUUUr529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUU9Yb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r106r15M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVW8Jr0_Cr1UM2kKe7AKxVWUXVWUAwAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07 AIYIkI8VC2zVCFFI0UMc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWU XVWUAwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7V AKI48JMxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMxCIbckI1I0E14v2 6r1Y6r17MI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17 CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF 0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIx AIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVWUJVW8JbIYCTnIWIev Ja73UjIFyTuYvjxU2G-eUUUUU X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 This patch fixes an underflow issue in the return value within the exception path, specifically at .Llt8 when the remaining length is less than 8 bytes. Cc: stable@vger.kernel.org Fixes: 8941e93ca590 ("LoongArch: Optimize memory ops (memset/memcpy/memmove)") Reported-by: Weihao Li Signed-off-by: WANG Rui --- arch/loongarch/lib/clear_user.S | 3 ++- arch/loongarch/lib/copy_user.S | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/loongarch/lib/clear_user.S b/arch/loongarch/lib/clear_user.S index fd1d62b244f2..9dcf71719387 100644 --- a/arch/loongarch/lib/clear_user.S +++ b/arch/loongarch/lib/clear_user.S @@ -108,6 +108,7 @@ SYM_FUNC_START(__clear_user_fast) addi.d a3, a2, -8 bgeu a0, a3, .Llt8 15: st.d zero, a0, 0 + addi.d a0, a0, 8 .Llt8: 16: st.d zero, a2, -8 @@ -188,7 +189,7 @@ SYM_FUNC_START(__clear_user_fast) _asm_extable 13b, .L_fixup_handle_0 _asm_extable 14b, .L_fixup_handle_1 _asm_extable 15b, .L_fixup_handle_0 - _asm_extable 16b, .L_fixup_handle_1 + _asm_extable 16b, .L_fixup_handle_0 _asm_extable 17b, .L_fixup_handle_s0 _asm_extable 18b, .L_fixup_handle_s0 _asm_extable 19b, .L_fixup_handle_s0 diff --git a/arch/loongarch/lib/copy_user.S b/arch/loongarch/lib/copy_user.S index b21f6d5d38f5..fecd08cad702 100644 --- a/arch/loongarch/lib/copy_user.S +++ b/arch/loongarch/lib/copy_user.S @@ -136,6 +136,7 @@ SYM_FUNC_START(__copy_user_fast) bgeu a1, a4, .Llt8 30: ld.d t0, a1, 0 31: st.d t0, a0, 0 + addi.d a0, a0, 8 .Llt8: 32: ld.d t0, a3, -8 @@ -246,7 +247,7 @@ SYM_FUNC_START(__copy_user_fast) _asm_extable 30b, .L_fixup_handle_0 _asm_extable 31b, .L_fixup_handle_0 _asm_extable 32b, .L_fixup_handle_0 - _asm_extable 33b, .L_fixup_handle_1 + _asm_extable 33b, .L_fixup_handle_0 _asm_extable 34b, .L_fixup_handle_s0 _asm_extable 35b, .L_fixup_handle_s0 _asm_extable 36b, .L_fixup_handle_s0 -- 2.41.0