From patchwork Fri Apr 16 07:55:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: He Zhe X-Patchwork-Id: 12206909 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=-16.7 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,MSGID_FROM_MTA_HEADER,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 7FAF6C433ED for ; Fri, 16 Apr 2021 08:24:39 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 E79C96115B for ; Fri, 16 Apr 2021 08:24:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E79C96115B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=windriver.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=desiato.20200630; 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:To:From: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=JuMrvlYVQVNG/J6nqHjqZ1W5e5YKxgFeaKi4S8q4OaU=; b=FUPzjVgDUM1g/3 szsEKCEnplYBf7DDXJjgB+oJDshXxbgRV8usu5ekFZ53S8IJ4rcv1Daw6BVJod1zdv5LfbGr6Qdks 2OaG3/eLa62NlCfAyHgX0f+sJk2VsrYloYIhfroLV03gpdGEeNRKTjZ5yUsNNJqoufHp9kHtrxTex +ApRdLreYqXcV3ltkUEFEH8Hr1pM6Im22NjqZLLMMDEGOEhigE4x34JqD56Ei/u0OiogCuZ1c4CKy hnRA7Nn47jEvqIRZzfo55b6hTBVFt4xgJGi1vfdfTsaxz8HhbanVOSsKKG+D5AAACHRd3cBcTJZty uL8ggob0tZlXLwYqBKYQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lXJiz-001K46-Ei; Fri, 16 Apr 2021 08:21:14 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lXJKc-001G57-3j for linux-arm-kernel@desiato.infradead.org; Fri, 16 Apr 2021 07:56:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=MIME-Version:Content-Type:Message-Id: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:In-Reply-To:References; bh=TMX4HDG+uDIZ9Wjj1oVGQqWUFQJSs5aN6Dbo7FarFNo=; b=aelTwnhYnI9qljfltSW+qFk8/o 2sEzicjzJdcNeqCS2JKKKVwUYImujbOrYFrOKabtmCnCeGAAmkEFyE3AvDCklDXmMBIgl5Q4vc+uB bKOnQZHWq1BZM1hTZtZnUQSr/FpDm8HtUcW8FJ09m4hh1gJmafBDHCWiSa8K1jxgLEozbgTh06XRf jk4bn3a/Vg4WsP5M1oogsh1qAb+OWbS0IAxQIMRPx/pZdgQJZ++wWhrVLPIm7V0g3wZPvx7PFtyzy uL0BamjFSqzc1PdUylDPAcDgGVJsf38Ewd55mA8qgX4QlA/1TbVrALkH/I2q+GSQj956cT391pPFx bYEiCy7w==; Received: from mail-bn8nam08on2061.outbound.protection.outlook.com ([40.107.100.61] helo=NAM04-BN8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lXJKZ-009ATq-5P for linux-arm-kernel@lists.infradead.org; Fri, 16 Apr 2021 07:56:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gBeWdnqkQ9pA3ZWD03lOeKL2HLKPMjWaFGV0S+t8/E+NBMPY38iXgpIkZdUdfgqDsaIlqhNn+vwdzue9+neAgg3jcV8bLWPU/HrQ/UCDKnGH57hByytX7occwa8SEhkc//cnzPcZ/+q2vPjanHMHW3W6G+ScWplvsomeFtnJthmqRhNq54otVuiMqH1FJrjYAndICarluN/SIj1LRRK7RogVVOJzaW6FZMqVAgid6He/T6xastQZecLHW/KkfxyhVXH2R7fQiQJd/4c9bAYlyZxP3Xnto34zwIizHGmoc3hWws4QZv3gSfgAAew2XqDkw95n8qEOMAbQ/0gIl4tgLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TMX4HDG+uDIZ9Wjj1oVGQqWUFQJSs5aN6Dbo7FarFNo=; b=RwMs+ZQC8Bxgxtp0idcdu0Ob/hAgQE4b/BZU7k327QD4A2znv1quPzwHXVGMtRW7/lIXSOH4yp8xlKS19Q343VMt1eO5yPjq0LzEHrw/jrz29FgXYifhp986b2J000dziUjQkrKdSi4nsdAdrLRFEmk1pdTc7dRRCqgsNR4wgOiYg6VmJm05KlPBfYI9juW+gtjadtGASmbii/D78O32Of3P+g6XJJ4CrCCO/11BH25uJItagkDnSLWiYlTLKUWbgBaVtmraOUrtgyjbZVnHyTpVHyV7ZXaUx9WRTJri/zYM2roUa2qgOziZjaKlk2ODvwi6XLpRDvOlm2JrK5A0Ng== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriversystems.onmicrosoft.com; s=selector2-windriversystems-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TMX4HDG+uDIZ9Wjj1oVGQqWUFQJSs5aN6Dbo7FarFNo=; b=MUILitxWFkUfqW+ZY+4M9j4Mtkd5MP+5+EsmAeGgIOz2vtGl9nQ+WVrDIkRXT3U5RntYkADlj4J/Nq3NS8NUvFkTjFYfhD6nE/4ASpiCeC8pUnxnL8KZMR6nsSelBXh9Fe/CDo+8joOsRelntOGwajbsx1S81WxP8OMjH/0Taho= Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=windriver.com; Received: from MWHPR1101MB2351.namprd11.prod.outlook.com (2603:10b6:300:74::18) by MW3PR11MB4763.namprd11.prod.outlook.com (2603:10b6:303:2c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.18; Fri, 16 Apr 2021 07:55:53 +0000 Received: from MWHPR1101MB2351.namprd11.prod.outlook.com ([fe80::c156:455d:860e:ba87]) by MWHPR1101MB2351.namprd11.prod.outlook.com ([fe80::c156:455d:860e:ba87%4]) with mapi id 15.20.4042.018; Fri, 16 Apr 2021 07:55:53 +0000 From: He Zhe To: oleg@redhat.com, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, paul@paul-moore.com, eparis@redhat.com, linux-audit@redhat.com, linux-kernel@vger.kernel.org, zhe.he@windriver.com Subject: [PATCH 1/3] arm64: ptrace: Add is_syscall_success to handle compat Date: Fri, 16 Apr 2021 15:55:31 +0800 Message-Id: <20210416075533.7720-1-zhe.he@windriver.com> X-Mailer: git-send-email 2.17.1 X-Originating-IP: [60.247.85.82] X-ClientProxiedBy: HK2PR04CA0064.apcprd04.prod.outlook.com (2603:1096:202:14::32) To MWHPR1101MB2351.namprd11.prod.outlook.com (2603:10b6:300:74::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pek-lpg-core2.corp.ad.wrs.com (60.247.85.82) by HK2PR04CA0064.apcprd04.prod.outlook.com (2603:1096:202:14::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.16 via Frontend Transport; Fri, 16 Apr 2021 07:55:49 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 808f9646-ef10-49fb-a4b9-08d900ad0eb3 X-MS-TrafficTypeDiagnostic: MW3PR11MB4763: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KDazGbaZzFrA2nKTl7qLk5Qo+DshriCVsYtmrR5+1naw8FQonlKCvnaVOpuEqhd3MSXqlphqJ1OmShCwz+1Dcp8ngbGqKKglHC+RnDj83mT+Kyp7UhBrFuA1ol3YaV2HDsikEWmb7wchpSE+iaL8fshDFMc4qELrCqBX3h32LpyCLgkg0mN/EUT50iRXb3Ak2qTF787hk8jwq5/d2kFqB6lFrijDKraFq4Mc5ZTdGk5XFz7b3lBAejTzB1ut9ksz0ifnChw0ybUKj70qhpOXb+EUlfCNyxpyk2QPPbOvCG3RJb9UUhrIQoT9FQVjFgiLl3MpjePdToxxilnem7uvS+nurIo0CC+r7XlVNSnXE/sLw6p4F3OjDHzsCmzHRX6gly8pg8IWS8QvCQNZteGCozPrG+Q1bG0fdTjGHP/n5Bga2PbmQBwNOwXKhP1viajvhyZogDW1KsssQCEuKBCPLFSmg6MdW0WvpefPoORB+JEca5dER1ev3eQQRdmmyecor6wphzzSHWIBOgYTWC33sO2aWcQzFaRQzQXeGuG1KOVEPOUkDW5oomgpjWVKGJ4A0vZgd69ZeWRKaPah7HtZN6ed2QjaQzd0NZcMUD0QmynHaVa9CiFy5JhU1OrOBYyzHZEGo0I+RBzED0z2ei4MnExMUmSt5Rv1P7mMBEe51r8= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR1101MB2351.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(366004)(346002)(396003)(39850400004)(376002)(16526019)(8936002)(38100700002)(316002)(186003)(6512007)(6486002)(8676002)(66556008)(38350700002)(5660300002)(956004)(2616005)(26005)(1076003)(2906002)(6506007)(66946007)(66476007)(36756003)(478600001)(83380400001)(52116002)(86362001)(6666004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Ko2oklAoGkkYlNJkhDR29XFt13f16YjUdrRpEtG1hWLdZWZvSLifZdTjsZadbmsP/4941Gm5JNvNCJ4b4avkjYJKzAC2ci1ga82cGW+C955i5cKEEsRcbs6aOHTB+FYnrOF8XB/AwkaVPW43sbnAR+SWdmq5VAsq1pkd+jLhhV/iJ/ybyLR9ZL919HqYp+jwMoDdrtBZhflIxLMxrWpY3b0w7tikoa93IjrHMTtJRFMfBb8fH8dDsSwh4rcjx6i/YNNGMgyKNb8dVcDcSpMF/RVQ9wLSFKQ4N+kI0Quhhwen9keSn7iwAKh31/EGOFC36cQXDxeC3CFIcYDRfQ8zxbcsmmmBmVKkSAkh79OHrfYfOMTyN7c5o4T+oODCVeblXPZYKpAcxtu5qsi3LCzQQJFyS1y36R8FY0qR3PnpYjiH6C1lGMYs2/YvPQg2g+WxIgNEww23JnxrtLOGxw5tGaRprYoqG/F3rz2EbfkFQfcY+euNVCYpqgrFZqhdqlSIwLu6oj9nmzGA0MptrR923jYEJU9jtLWoToKMduiDJF1qxCYo7jjt6mU2sRJM3Hlmvy7l/kVBWTvWSKrJ8LFG1kg+mK7yq+r1/o07T5Uq8v56E0B20FT99+mvMq1C2Tpz2gl/O0ymMFXtTiIoD7oFYFNyweRHLCb5Dbly8+jfyZ3lB/SNa+PWGGFnupmJjWAheds24eE1xrSYEy8y9F89x8aOxlP/mgvTopK0xFgCa566D8/YcOcGfSv46vP/+tiIeGYKFOS4fqeUnY5Dhr5uXwQmuDihl+TXG0aT7YhqJim7qoMFdmB1LVnntx9eT75u1XeDmHZIbje6BXMoAbtW/jVGVA7Pqi6KaC9cTLpDYys4NBrLh0NkuC/Z1d9zVtPsNL/xxYMhZjg22aUAaQivRUsBj6mXFM+ACSkckAsswfJQVHI4q7iib0vttfgRxymCcYlyYOkke5VVwL/BYWHlbRZPbNOCEWeIGqgHtnzehv+j52/zTZvZ6Qr7UDW92js87Enwj0RGxa7ItDYzsKdW1P7fmqhtEPI5uqXxFCiNO9Z9G5TwMi85R4zWcvsHtpZpsgMTWMLVUMrCUo/ykI3EcQYUGvg0QwhEnyJw1XuevPBowLQW9cSYxZn3F1/D0QGsCoeMJj5YKPiSot5ioypG2Xmmq/bHNjT2d0V0YmoED1Xf5J1kWXiq/FKt4uHddUgB4Q4Fm3nzOfQHH/l3wKONI04htx50Dcw8Q3ITjZ+Tbiqg15QTOBGEskgSqmLLoMKalWTnpAaMNGhGjshsIHKR8ZI2kSddRp4MqdoDYibnl6qWbmgSTyXwpHGL2G4HbF88 X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 808f9646-ef10-49fb-a4b9-08d900ad0eb3 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1101MB2351.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Apr 2021 07:55:53.1839 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: IQ30CzyE9JsDl8fIzzzKK9c0RyDlm2+sQYwkp15ir3l62sv7uC5Nx8c/Csptdj1GpHVmglU9pce0D/r13Iwq7w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR11MB4763 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210416_005559_227520_9275A990 X-CRM114-Status: UNSURE ( 9.39 ) X-CRM114-Notice: Please train this message. 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The general version of is_syscall_success does not handle 32-bit compatible case, which would cause 32-bit negative return code to be recoganized as a positive number later and seen as a "success". Since is_compat_thread is defined in compat.h, implementing is_syscall_success in ptrace.h would introduce build failure due to recursive inclusion of some basic headers like mutex.h. We put the implementation to ptrace.c Signed-off-by: He Zhe Signed-off-by: Mark Rutland --- arch/arm64/include/asm/ptrace.h | 3 +++ arch/arm64/kernel/ptrace.c | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/arch/arm64/include/asm/ptrace.h b/arch/arm64/include/asm/ptrace.h index e58bca832dff..3c415e9e5d85 100644 --- a/arch/arm64/include/asm/ptrace.h +++ b/arch/arm64/include/asm/ptrace.h @@ -328,6 +328,9 @@ static inline void regs_set_return_value(struct pt_regs *regs, unsigned long rc) regs->regs[0] = rc; } +extern inline int is_syscall_success(struct pt_regs *regs); +#define is_syscall_success(regs) is_syscall_success(regs) + /** * regs_get_kernel_argument() - get Nth function argument in kernel * @regs: pt_regs of that context diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index 170f42fd6101..3266201f8c60 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -1909,3 +1909,13 @@ int valid_user_regs(struct user_pt_regs *regs, struct task_struct *task) else return valid_native_regs(regs); } + +inline int is_syscall_success(struct pt_regs *regs) +{ + unsigned long val = regs->regs[0]; + + if (is_compat_thread(task_thread_info(current))) + val = sign_extend64(val, 31); + + return !IS_ERR_VALUE(val); +} From patchwork Fri Apr 16 07:55:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: He Zhe X-Patchwork-Id: 12206911 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=-16.7 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,MSGID_FROM_MTA_HEADER,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 D71FAC433ED for ; Fri, 16 Apr 2021 08:25:49 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 5DC2161166 for ; Fri, 16 Apr 2021 08:25:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5DC2161166 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=windriver.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=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=P/j7IpgUrLLEuWIpfqQMDqd6/MQGw0NJMLavrD5j5jQ=; b=OjF+BE9z7OynC4NJvlfps+QlX d/nnTI+BO+e1OOGYutVtrDlpBmM7QlfXtOuC+p7aQncML5c8XgbVYssKQhkP6sfSF/Cipzw6waRRz c8hsXelu8ltaeMmnl9VID6bOINfgkHtx+ir6YEWTi9oBMNQtWjp42Lhx7tTVVKRMOh6crfPsns3uU 12MB3BfCF+3WuV7r4t63MJ4v5HNsNy5SjdkTPsixwcL4kdLoy0DyugVsr6JI8S2nVZxAjtn+Nokzm +2/vNsIFOq2sjCUpwnUHUh5d712nsMGAXJdz6uUNCcxmuCVsuIzBKbj5LMKjKBLh8DnCkAd2MKdvi bmIy3P+Zg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lXJkd-001KJc-BB; Fri, 16 Apr 2021 08:22:55 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lXJKd-001G5W-BI for linux-arm-kernel@desiato.infradead.org; Fri, 16 Apr 2021 07:56:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=MIME-Version:Content-Type:References: In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description; bh=R5Q7H4W4tToocGKvccHW72K3qZfYpxccSAhc2wz2uKE=; b=Xkp7SdVCjQlKhF82aAyjzc44o/ AlPpzucTm3WempdZbItIbDVml3g3aEkm36LlZmO9QlP7DtAnCk6Ia8oclmXH7haIDV+crzjp9+9xd ZqtNpe0WNVacJdq6a/KMfyFB9Je1JFZga0zBH9EfVG+fw34iB/4oUvriLQj0YWChibcIISyn5qFaE 5SdQjkNwyPqBMUtu7GWmRK3+9tJN1NRs8Y6qk0G8YXU4RnBjSdvlGXSUm21HhrLc7vm14gsFbimsh ECfIEts9Bw8rE5wxgrHcoXDSgeX+GCaEK4Od1BLI6tKLyFr3YeuG7PItcLBy5AYUIJZcO55hy0/gV ToOgLF7w==; Received: from mail-bn8nam08on2061.outbound.protection.outlook.com ([40.107.100.61] helo=NAM04-BN8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lXJKa-009ATq-Np for linux-arm-kernel@lists.infradead.org; Fri, 16 Apr 2021 07:56:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mTvVbusU5XhaqrA7/2lPlUTZuJN/7nKdg+esHhzqd9+f05jDM6nydDtv0Yacphe1Nd0EOktexyzWCtmohTEwaeTqyFcqgeCSSWfWm9s5jakcuVU64E0thkBEGfPRPBLX4KR0xuHPhxGO20DLej+er4p8hxZuiDrd7oDC/uJttlBx34A2cmiqcY6XzKrVdw0UV2ktnvY8PB0+cxk7ESLCQMKGoW1WY4RsxhcV/GvVjnvfqBlH/d9c0LAf9qjpOhuxw7CH1f85Z8jhjBv+zcddATf7H7ubHCqlGC2hPGM1k8t5RA5XQprGEVQU33ZKuNGVaUzer6aJCxf13IJxTRMiXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=R5Q7H4W4tToocGKvccHW72K3qZfYpxccSAhc2wz2uKE=; b=JQyMfAUHnTkpZr3aCSpIs0UoDCxE8c1h3l0dxaVPKQLj8/g3xFyVfjKa34qYxgUmTiDJDIdzb+Eap02U6a5WNbUpej5qmYr+QOjCo+d8O4VUPykC0vXFP/I3kWsTM6j0mF0Ny44VleafcnMzT6A5dppngySFjDSsI6iyL5U641OKfD8kVnUR65kCfme+kgJWRzZ5MtMZBoErVGTcClW+mfaAFOpD0aFExtwD5Mv7NBEaQcIbp27+BFqszocCYA3iLNRtoXsCHnIjfSE08A6RKes8XZhnCaZws0mRsDunHvIdSGZSziZEamzyvdg9PNKwMOqaHynFi9m07x7xkDDFEA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriversystems.onmicrosoft.com; s=selector2-windriversystems-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=R5Q7H4W4tToocGKvccHW72K3qZfYpxccSAhc2wz2uKE=; b=iKI8VGoBhfYGxfbblbieedEbMoG9/7aNBnjNlyI7hmNQAJql0ZUZFANtDno+FboMqiJhkN4freI0xixhXFjrVdou2Wq36ekux9KZdIWTqv60wiVRKmhN6zzx8Qw83XM4KEqLQIZy4ditFOloyi8qJkLq0q1FFEmMyw8qnezjU6M= Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=windriver.com; Received: from MWHPR1101MB2351.namprd11.prod.outlook.com (2603:10b6:300:74::18) by MW3PR11MB4763.namprd11.prod.outlook.com (2603:10b6:303:2c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.18; Fri, 16 Apr 2021 07:55:57 +0000 Received: from MWHPR1101MB2351.namprd11.prod.outlook.com ([fe80::c156:455d:860e:ba87]) by MWHPR1101MB2351.namprd11.prod.outlook.com ([fe80::c156:455d:860e:ba87%4]) with mapi id 15.20.4042.018; Fri, 16 Apr 2021 07:55:57 +0000 From: He Zhe To: oleg@redhat.com, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, paul@paul-moore.com, eparis@redhat.com, linux-audit@redhat.com, linux-kernel@vger.kernel.org, zhe.he@windriver.com Subject: [PATCH 2/3] arm64: syscall.h: Add sign extension handling in syscall_get_return_value for compat Date: Fri, 16 Apr 2021 15:55:32 +0800 Message-Id: <20210416075533.7720-2-zhe.he@windriver.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210416075533.7720-1-zhe.he@windriver.com> References: <20210416075533.7720-1-zhe.he@windriver.com> X-Originating-IP: [60.247.85.82] X-ClientProxiedBy: HK2PR04CA0064.apcprd04.prod.outlook.com (2603:1096:202:14::32) To MWHPR1101MB2351.namprd11.prod.outlook.com (2603:10b6:300:74::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pek-lpg-core2.corp.ad.wrs.com (60.247.85.82) by HK2PR04CA0064.apcprd04.prod.outlook.com (2603:1096:202:14::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.16 via Frontend Transport; Fri, 16 Apr 2021 07:55:53 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a9c2a640-e921-414a-7bf5-08d900ad1128 X-MS-TrafficTypeDiagnostic: MW3PR11MB4763: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3513; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AG/CnU3+8juEWV6lQCKsNEnlDrVBNTjFXB+6rhN1EkJqgRWXTncGGAEPBbEfhe7Z5AX9CQCU8cyScESAzt0eqFogFiAGj1qxypXUGQl5+Z9iW2Q13Bm1dXGnR4YQkkVTvchPndKW+5gFy26LIDI88w+EprjIyDi/K1Dxp93VpJUpsGE/+i8lPvaZbmYMIGBeysYlK+9FdBXGDUFXr3EBRp6lZ5dPVijlEZP6hKDi/49ckSnfn4WyhuFd9Ken6WgUadwyKla1dpJrEx1CRPN9VM+lpuQFwRdpt3zCY2gxH/o+usqBeim7inhag2irqJVEYIPlJc8YxHVNrp1vZlA0kHQwJnQPvTXpTLh4m13CKL8kLvqOtOYlp8FjQCwYYmTnJhPhBWXGlGLYstfnqdmK7PpolVHYbkV4JYX62khTWBV4SwDHDxX3Oj2vYXRZ/TWKtKYBiRpJmZHUluioR5U+fy0tUB8bchP1VVFemyGdf9LhvY+OBeWULStw1JVmVW0PBYRhXJXsyN9Pq8rfFApRl6SiJbqzkjomu4W1/myfn514KsJ11xpL/M2oB2IGoAZ8pvl2YhfIJaAOQaaTrNWwfVNtJAtSieu92znuwOK77tRLhhic5VK2XGXMpdP3+XFu8jFk63U3QGNYk7STkv9xyg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR1101MB2351.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(366004)(346002)(396003)(39850400004)(376002)(16526019)(8936002)(38100700002)(316002)(186003)(6512007)(6486002)(8676002)(66556008)(38350700002)(5660300002)(956004)(4744005)(2616005)(26005)(1076003)(2906002)(6506007)(66946007)(66476007)(36756003)(478600001)(83380400001)(52116002)(86362001)(6666004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: tOiPgk4zDxCwDQKgdtw+xrZ5TaGWRro1ojrXqpcnXdx7R5M9JWmMdfr4d++TBrI7OjKvbyuSdL364moc9CQ58wYeF0uyEVZRChgecXSHHzDbQyVUFzSqM74l+xSarRE+ygMlUA/VntWYAVRnEhhFU7pG9qWoLYknUE8N9bv+PX9quWrLxp65kWVeDOVUDMpRBKHA2ITRJnsCYudJPQ2T6V323S5zlSBRyULGd9j7+M4mC1Q6kpciISviiiF7Trdu89V+Nt7/6TA80pKeOEi83JxqIqpVmAavyhkzOggKdkfztY2Lc3amgSW+4yRzzkTwGRd0iXnK+s55L8jCc15NsocSaGpM7o++n/Ea33o48tf2N4e7qT7ZW+NBSGzXjcupyNbzyQ4G/kOUN/Wgj1+L76xkioHM3zvPOmyCXbRQcpwbjogjKQdSDVE+zg/OaZsengQPWz5u+bAJv91ObjCrdSitrVxAlBDVcgjRr29v7No4aFLQoYEp3V50smJN7uoZRZC184KglzRQNasiSbZD4tmpHo2g0eapXywctb97k7qn/p0alDF574xoVN6sWBKwiu7MmjNHyjfokGts02IVJsfbcv4FWD80UWHuK40KMfGuV2uYF/hGPMOMcytjPte0O20cdKvc0TRuJ6eALI+cL+DUDyO0Nkl+mYTuL3VMiH95cNY/VjAQNtYzR63s73Jm2YEtsdCUsAFShFhHOPFNrd2e9xLf3tFXhmxp8dM+JamNC2H0cAGPV/xocncSWkaZCwkC+s8mn2Zw6Ue6H71WeM8D3jMht3mwwA1ubZ9qq/VRlvTfePQrQ38TZskjEl4lnNC9OYwMaadr5lg2MBL987eghWaJP4dG/nn7InrdjGfT6TNC9qtcz2zDjAGCUAmRpE5C+wYJxo/4bwJjBnzX2jpiYogNbDR7tqY+VClutKzeCpExAKw9fgaOK7MI0fiMsrbYhvPwGz9QBiJc9iEEPvMAEFQf1l6Znvee+xDEo7ZuGuuUQOgpYwtPk5dOaT8yGfGcsZFFBN7MrWKTfmvR73d/iXYkKY0jfa4sk+PxkmLniKmYQGPMpLbHp386vfMajoAkYvZA9h8hI+OUmtq8NMCpLDjccZS8Nwj920xu21mMRXHCs8h+uaSOSQlDct4KhGT9vhKoP9V7qocvOmIqe569iCZ6TUwQ4h7egDaQT3Pr5ozQRfqYwRg1fY9pSLh8bQ/46Gukrbnt7XbG6zqr9LE1bRamzT4T9acWsC/59PKjBTeJpAHhVCsomOML2UzbwQRZ9rGKx00Pby4hlJBBV3+ySWkV0LfiO4WVWNnMXmn+TVVQuooFLDYFdLbnINmA X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: a9c2a640-e921-414a-7bf5-08d900ad1128 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1101MB2351.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Apr 2021 07:55:57.2421 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Dupci3xkHR8tZtYMnVoIZLDgQxZT9rbLhz3bkYxXxMndrgEewpdqbIis5c7a0nMDquTF6ogaNPZtUTMowl+JCA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR11MB4763 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210416_005600_799832_4954DCD4 X-CRM114-Status: UNSURE ( 9.51 ) X-CRM114-Notice: Please train this message. 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add sign extension handling in syscall_get_return_value so that it can handle 32-bit compatible case and can be used by for example audit, just like what syscall_get_error does. Signed-off-by: He Zhe --- arch/arm64/include/asm/syscall.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/syscall.h b/arch/arm64/include/asm/syscall.h index cfc0672013f6..cd7a22787aeb 100644 --- a/arch/arm64/include/asm/syscall.h +++ b/arch/arm64/include/asm/syscall.h @@ -44,7 +44,12 @@ static inline long syscall_get_error(struct task_struct *task, static inline long syscall_get_return_value(struct task_struct *task, struct pt_regs *regs) { - return regs->regs[0]; + long val = regs->regs[0]; + + if (is_compat_thread(task_thread_info(task))) + val = sign_extend64(val, 31); + + return val; } static inline void syscall_set_return_value(struct task_struct *task, From patchwork Fri Apr 16 07:55:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: He Zhe X-Patchwork-Id: 12206913 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=-16.7 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,MSGID_FROM_MTA_HEADER,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 160AFC433ED for ; Fri, 16 Apr 2021 08:26:39 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 7AE4A610CE for ; Fri, 16 Apr 2021 08:26:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7AE4A610CE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=windriver.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=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Go+q/uVos46SZLZZBE9yhtFoX8xk/pqBAkRxdsZC9OA=; b=FVzUblspvOsmd84isqCLgVn4D qbzZNL4oLPuX6WnB1P2UKgCY6LrAvqapaO2JBImKQXtsJ7GzJOsiqtSRQv8httsK3cuuJ7EOpBWf0 zQG7gUTvAn1seeqFShKmlRxqD6wqcQbzOIuOQPd/aGtUv3TxZc68JU16u12DWgfBIwLhNc+yKrRY+ zXwKkY/2TOlmhwy536Sh7MFQ7sYAznqEiIfz86X5Wqe/1ed+1/Ca/4sQfLLihe2pabAh3t++HtHZB xodOuwvKwNjHP9p8zR0bYjaeRb0T1/i4tTyTh7CZyvrJGUdpQBhq2bSAch2ZVgma0BBqBshoRxUKN lOIxIpv2g==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lXJl7-001KPo-H8; Fri, 16 Apr 2021 08:23:26 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lXJKe-001G5h-Rp for linux-arm-kernel@desiato.infradead.org; Fri, 16 Apr 2021 07:56:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=MIME-Version:Content-Type:References: In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description; bh=eZVTrKhkVowLWU9xiLvZT0CxlNRi6H9KXJAaOQMmH+c=; b=rTunwkjgSH72wUNMXGwWx96Ns9 m6mF2tW11c35wA8ByVzY5LLNFn4sG0fMjOwb0LIv2zASNCvwbPxG4ngfwrHuh+12Z/Nib/477nucg zkgVKqv2IY1yiCTeE5BurcbxVrSAn46LU3dETzhHFw9F8ahhHVFOHg760ITz0lw5OKgLLMDMFRDhE T/oMCdjZuceSVLTvuBFY5T43w1exLj9nd0mB6cDC6wTshdlHCULAbSNYfWRORCBtkRr9zn8MvvFiY oCAQa2hPmjpXMebkxsfiz2KJa/JK3GHEMtffJ1LEtdiYW//TXKWfHFyKezKydTVoqcdpgdDkfhtar VnCpplTw==; Received: from mail-bn8nam08on2061.outbound.protection.outlook.com ([40.107.100.61] helo=NAM04-BN8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lXJKc-009ATq-7u for linux-arm-kernel@lists.infradead.org; Fri, 16 Apr 2021 07:56:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OXorA1axn5BcTMo6zPtOI4yxCGTtMuRyfUdChwD6vO290DT7qo5vRL3mXqEDOyw78fJlE9ZzrTASDZCK4DAvYNw9yiqPanj2+1/O0ttjVa+ktRqK1X1TTzD5sYoleoh4T9AT+SxS+gA1QhtACpr7b/l+/6wpvDEbLt26fHypVASuv3mAU4ilZEl/XluC4FqE/t2G18MbwiwSnOsl1vPRNlJknq/+gAYlBQzdNpmvhBVtGzA44IQBKNnYOP2wwS19SGamIM7yOtoShh9EaXn76nvAfjdGYiRNS5WRA3woMVEgY4SYFQx6erBMmNy6CpXrIzAzjhx28eY5wMHeVBL+qA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eZVTrKhkVowLWU9xiLvZT0CxlNRi6H9KXJAaOQMmH+c=; b=DsXNAnS8+OsWJ78W25WC6s55Hk8WEZ+BjZgX0OQmqz4Bu8yylZ2N/0Jqcx7Ndk7ktzsGFl4FOh1Q4U11leUCrni6oCFPG8kW9jZzoR58D8AwB+WD/kWwpWYak4eX/jWjtzaot8xyvbr15xe6NtwkEf77DvpIz95iTheS53bByNDXvoD5Wa6EpIMb41Wgk/hCasEu9rykoNc5yPCpharpCyctIXqEohObHM/pvTA7PDXRv8ZiHLCmY7E2rDy5VobKpYxlRO2bmSRNc+WUNojsipzaWIW6YZY32GmjQOpwwfQSBGR4G7l2gTHHXO0Jy5DBCC37rf9Ex58hx4fGb7S5iA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriversystems.onmicrosoft.com; s=selector2-windriversystems-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eZVTrKhkVowLWU9xiLvZT0CxlNRi6H9KXJAaOQMmH+c=; b=AjLrIdraHcUvH2pUnrpc1Vw3dNLE86ZudRY4j7n3nk1gYxB9WoiQfWtyL8XoL7F/vF2CsJYI50YKqMAhiAHYCfvu/FE8xoIQXMJR5PJWxOY0+arB3EzXJwqgDO0ckr81EXiAVjvvNiwnxKWr2HsODbSlXlFFObJBsSsXu/JXKbY= Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=windriver.com; Received: from MWHPR1101MB2351.namprd11.prod.outlook.com (2603:10b6:300:74::18) by MW3PR11MB4763.namprd11.prod.outlook.com (2603:10b6:303:2c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.18; Fri, 16 Apr 2021 07:56:01 +0000 Received: from MWHPR1101MB2351.namprd11.prod.outlook.com ([fe80::c156:455d:860e:ba87]) by MWHPR1101MB2351.namprd11.prod.outlook.com ([fe80::c156:455d:860e:ba87%4]) with mapi id 15.20.4042.018; Fri, 16 Apr 2021 07:56:01 +0000 From: He Zhe To: oleg@redhat.com, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, paul@paul-moore.com, eparis@redhat.com, linux-audit@redhat.com, linux-kernel@vger.kernel.org, zhe.he@windriver.com Subject: [PATCH 3/3] audit: Use syscall_get_return_value to get syscall return code in audit_syscall_exit Date: Fri, 16 Apr 2021 15:55:33 +0800 Message-Id: <20210416075533.7720-3-zhe.he@windriver.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210416075533.7720-1-zhe.he@windriver.com> References: <20210416075533.7720-1-zhe.he@windriver.com> X-Originating-IP: [60.247.85.82] X-ClientProxiedBy: HK2PR04CA0064.apcprd04.prod.outlook.com (2603:1096:202:14::32) To MWHPR1101MB2351.namprd11.prod.outlook.com (2603:10b6:300:74::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pek-lpg-core2.corp.ad.wrs.com (60.247.85.82) by HK2PR04CA0064.apcprd04.prod.outlook.com (2603:1096:202:14::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.16 via Frontend Transport; Fri, 16 Apr 2021 07:55:57 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: edb0476c-83c6-4d1a-0610-08d900ad1382 X-MS-TrafficTypeDiagnostic: MW3PR11MB4763: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4303; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sV5crO9FTR06zECdFeRSLT4aHABBssOEiAuVNxHLc7WX8lGX7rJAog+nrIXPncrmf8ZosxUJ0LoAsTvFnfGb57JGb1jbHbkehDt0izkCrXRrhMKdPibZygGMegmATGJsHfQ/IWU9qb2d+oHrk38FoRHz7XAAJRmdZQFg82tER06F4zl4mKgeiPLR8WkyU7jM9+H5Nq/qdoI/VVxjkRqldDZu/yxpZOixiP5giAQBNlAMWtzjXfpx9qlhEdC139+HQxnxpeH5xYisMAJK7AmhpMWNJq/A8HzY76RYUz67SwKv+W6JOn1CCIywZqHAiy9Q/x80M+Sw9q9jmt1cpHxsOJGHTsLcAJpYaNWZVqGFa8cRAIug+yREMW1JGevjFDm/r8z/DzKH5Y1zqbGDBsv9K7qyP8jDLXEQ4yfMtaf9ZtABmm/4Zgf9V9V5oh3PTzuZMyFVOBHKmtLl4RGpIUf1Q1b7LWYfidBnJa833Vw6oWnmK4ZZPmQ0+qIG6n902RoBABv3/zT5cmdzagraz5sAURNs7R8EvpYuMcj4MlPUtvvsN2qeYF/1INAo9Bu5bb8yTiP3nKeIdLqETja+ucGn3nx3f4NhRBC7onkaoeMknSL+9S8y/wkpnL85VT9VsgLLk/ns/3G2VI/OySOacPnoLg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR1101MB2351.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(366004)(346002)(396003)(39850400004)(376002)(16526019)(8936002)(38100700002)(316002)(186003)(6512007)(6486002)(8676002)(66556008)(38350700002)(5660300002)(956004)(2616005)(26005)(1076003)(2906002)(6506007)(66946007)(66476007)(36756003)(478600001)(83380400001)(52116002)(86362001)(6666004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: N02V4nSZszpMWwEcVGeiCzHvo/IOI1RQHBUo5NZ3UAiDCpNMzIq73Oi83ejearE8OyYufe01xCW3/WEhKF5lM1+RGRpG+/Sa+fX/tmNazyilrynN2nDJfqCiCiJo2rjb4wQ8g0X6O5gFVyzoZTZ8Ab1Vtzn31qtmfpZUpZtFManfgXawugjWvewUC6jTecy8h0bAhC1pOerQ+JCfFNGlBtzTRwUQ52sWJjVJN1YsrEm9ZKIuK67zp4Tu9MDOgCWzMVLxehSYhDU/Qak5eMDZyzhOqbXchVJ8dJi9vCw85SkBjoSDnIQY5pjVMbKs8oH1f4UuOoV7Pq2bYwaTh7eTv/BDgbp6VjxTh57PiQwGFmHvElujNlkRKl7Gi4smaelPgltgElrSXiF4m2Pw/n52VvsbApvujpu/UuHHt1JPCPxyZzAuWLjPEMyivTseF07Qxf02CkyxNiUH1DFjpgEGTjPj8dYfFXhHaYyPe9j1ATGrDstGfZKu8173HhTLPLvfbQAEsqsh/2hkUNdYhIui+ladnCofhpCSbRow5/K8qGQE4e2yi0+hMfS0WgE84YBY0bluqdRpD7K4mcGOQnQH1orv3L7GSMs0G1Iz/I+gbHT0K3Fg/HrtwiWmxwOv/CSE2SuM/x7jXfs0pfO4ou4odgMphiCebIZDMVkFagA+RD2mm9W06z4RresW4rjVWku9gd+GjWmo88IOJbSDlEuw760HejpPjVTDO0PmpEptwso8eazX2RwXg/VCNQXWeWGy0bjHNjqT5+/QS8pkSDY3qH7CvJEaXlCyKszSSAt5EWJbaWZPfhQOjZBQu94s2JC1FGeSHx3ub4AiUlJkrEC14egFDSPqpmU+ZruJkDbycwpNn4Zf87bNbhOa1faRxLl0lE2NPtamrLS+Y3gRkmH7dFlEJ6VLh5CeHkrqaSbxXVVzezayctRuaSz9gg1GOOBd4IOTqWbNknbRULgX6iqkl0NwF1uGxeF7HEHRfPm8hdoX/w/Zryon0VattWEg3KmGNv5rzauugSphJlQPg8fFOP5KyktGtq5tZTffPVnf8TYWDZXvrsAosRDP+sbLbGZtQG9wPQ3usEQYpEd/2KJ77jOOWaAK7dggIMN//RxLcIdS1d003WPxGVtokrcEcova/YYkoKVWmxFTj1Q/LgZd1YubVLlU47/gWe5WV5ex+nN4mal5zlMkpuWy7NxY9CDNxtrO3dglXR03hSbc7otKzlhPpqD53fRJj3bHHSZClUXJKIqwqV0DUOL1amXdRdFxwJW4LEHY7Y4CcdICKulNplSIQzn4hawXMD/oxIlWq3EdQGB+TXR8y2i+9jOQNIIw X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: edb0476c-83c6-4d1a-0610-08d900ad1382 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1101MB2351.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Apr 2021 07:56:00.9285 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Y0WOdpcGQCz2rL3kor2VcmxYLODquTr7rzr2bftT5HO7GuTxNFM9oZO6H23hEcgziW4IrDU6II6v0JEXnb8H3g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR11MB4763 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210416_005602_304434_CB0EE353 X-CRM114-Status: GOOD ( 10.86 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org regs_return_value for some architectures like arm64 simply retrieve register value from pt_regs without sign extension in 32-bit compatible case and cause audit to have false syscall return code. For example, 32-bit -13 would be treated as 4294967283 below. type=SYSCALL msg=audit(1611110715.887:582): arch=40000028 syscall=322 success=yes exit=4294967283 We just added proper sign extension in syscall_get_return_value which should be used instead. Signed-off-by: He Zhe --- include/linux/audit.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/audit.h b/include/linux/audit.h index 82b7c1116a85..135adbe22c19 100644 --- a/include/linux/audit.h +++ b/include/linux/audit.h @@ -334,7 +334,7 @@ static inline void audit_syscall_exit(void *pt_regs) { if (unlikely(audit_context())) { int success = is_syscall_success(pt_regs); - long return_code = regs_return_value(pt_regs); + long return_code = syscall_get_return_value(current, pt_regs); __audit_syscall_exit(success, return_code); }