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 X-Spam-Level: X-Spam-Status: No, score=-18.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10F12C6377D for ; Thu, 22 Jul 2021 06:08:58 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id C1D7F61283 for ; Thu, 22 Jul 2021 06:08:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C1D7F61283 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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=2bY9uHyuAg6R8Ecn3DcEMYJ5AJpKQgSZkAazzxiTPfc=; b=lhz7d01ukoEz5V 7JyNtdg/uvUEppRZDwzUPVGvcwU2X9+h1M7TPnUJWxiXSXJ9HDTevDHVabQViSY2PzwjFxkVjdeoX MyFvC82fXyijzWuBM7NqjSwX92ivub6OYopHBncHtvuYtjSHajFCvzmhZ/bwE6PCT+3CMW5I93QTH NBFKO3VSgCV7CsykXE+lqZToN6xDhb3QgAIlj0uSUSW2liX6/ItVk+dTKH8ZC2TZ952+os0Kbxwqa MnCEQi5gE+/jifdYdhw0aRNpqN8tCAoEFVx5RBBKGoTA0yaDRfk7jawsA5SdAYVVFEoIssgwb4LQ3 nhUC0ICuQ0hl5nqxTKSg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m6Rrb-000JOx-Hq; Thu, 22 Jul 2021 06:07:19 +0000 Received: from szxga03-in.huawei.com ([45.249.212.189]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m6RrX-000JNr-D3 for linux-arm-kernel@lists.infradead.org; Thu, 22 Jul 2021 06:07:17 +0000 Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4GVhgX4YFVz7vf1; Thu, 22 Jul 2021 14:02:32 +0800 (CST) Received: from dggpemm500016.china.huawei.com (7.185.36.25) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Thu, 22 Jul 2021 14:07:09 +0800 Received: from DESKTOP-2MIM39K.china.huawei.com (10.67.101.83) by dggpemm500016.china.huawei.com (7.185.36.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Thu, 22 Jul 2021 14:07:09 +0800 From: Yuchen Wei To: , CC: , , , , , , Subject: [PATCH] arm64: audit: fix return value high 32bit truncation problem Date: Thu, 22 Jul 2021 14:07:07 +0800 Message-ID: <20210722060707.531-1-weiyuchen3@huawei.com> X-Mailer: git-send-email 2.31.1.windows.1 MIME-Version: 1.0 X-Originating-IP: [10.67.101.83] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500016.china.huawei.com (7.185.36.25) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210721_230715_744501_2329B6C3 X-CRM114-Status: GOOD ( 10.54 ) 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 From: weiyuchen Add error code judgment in invoke_syscall() to prevent kernel components such as audit and tracepoint from obtaining incorrect return values. For example: type=SYSCALL msg=audit(342.780:69): arch=40000028 syscall=235 success=yes exit=4294967235 The syscall return value is -61, but due to the following process in invoke_syscall(): if (is_compat_task()) ret = lower_32_bits(ret); regs->regs[0] = ret; The return value audit or tracepoint get from regs[0] is 4294967235, which is an incorrect return value. Signed-off-by: weiyuchen --- arch/arm64/kernel/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kernel/syscall.c b/arch/arm64/kernel/syscall.c index 263d6c1a525f..f9f042d9a088 100644 --- a/arch/arm64/kernel/syscall.c +++ b/arch/arm64/kernel/syscall.c @@ -54,7 +54,7 @@ static void invoke_syscall(struct pt_regs *regs, unsigned int scno, ret = do_ni_syscall(regs, scno); } - if (is_compat_task()) + if (is_compat_task() && !IS_ERR_VALUE(ret)) ret = lower_32_bits(ret); regs->regs[0] = ret; -- 2.12.3 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel