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=-13.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 83F44C433B4 for ; Fri, 16 Apr 2021 12:09:11 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 CB657610FA for ; Fri, 16 Apr 2021 12:09:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CB657610FA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=windriver.com Authentication-Results: mail.kernel.org; spf=tempfail smtp.mailfrom=linux-audit-bounces@redhat.com Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-526-WJhnMV9TNr6yk2fayKimuw-1; Fri, 16 Apr 2021 08:09:07 -0400 X-MC-Unique: WJhnMV9TNr6yk2fayKimuw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AB379802B78; Fri, 16 Apr 2021 12:09:04 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5641D7129A; Fri, 16 Apr 2021 12:09:04 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 42B7565D08; Fri, 16 Apr 2021 12:09:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13G7u1Ls025135 for ; Fri, 16 Apr 2021 03:56:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7ABCD21111CA; Fri, 16 Apr 2021 07:56:01 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7500421111CD for ; Fri, 16 Apr 2021 07:55:59 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3EF3285A5A8 for ; Fri, 16 Apr 2021 07:55:59 +0000 (UTC) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2070.outbound.protection.outlook.com [40.107.243.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-594-DFLnM0EPOSCGCTFaMf29zw-1; Fri, 16 Apr 2021 03:55:56 -0400 X-MC-Unique: DFLnM0EPOSCGCTFaMf29zw-1 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-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: =?us-ascii?Q?Ko2oklAoGkkYlNJkhDR29XFt13f16YjUdrRpEtG1hWLdZWZvSLifZdTjsZad?= =?us-ascii?Q?bmsP/4941Gm5JNvNCJ4b4avkjYJKzAC2ci1ga82cGW+C955i5cKEEsRcbs6a?= =?us-ascii?Q?OHTB+FYnrOF8XB/AwkaVPW43sbnA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ascii?Q?2js87Enwj0RGxa7ItDYzsKdW1P7fmqhtEPI5uqXxFCiNO9Z9G5TwMi85R4zW?= =?us-ascii?Q?cvsHtpZpsgMTWMLVUMrCUo/ykI3EcQYUGvg0QwhEnyJw1XuevPBowLQW9cSY?= =?us-ascii?Q?xZn3F1/D0QGsCoeMJj5YKPiSot5ioypG2Xmmq/bHNjT2d0V0YmoED1Xf5J1k?= =?us-ascii?Q?WXiq/FKt4uHddUgB4Q4Fm3nzOfQHH/l3wKONI04htx50Dcw8Q3ITjZ+Tbiqg?= =?us-ascii?Q?15QTOBGEskgSqmLLoMKalWTnpAaMNGhGjshsIHKR8ZI2kSddRp4MqdoDYibn?= =?us-ascii?Q?l6qWbmgSTyXwpHGL2G4HbF88?= 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-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: linux-audit@redhat.com X-Mailman-Approved-At: Fri, 16 Apr 2021 08:09:01 -0400 X-BeenThere: linux-audit@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Linux Audit Discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-audit-bounces@redhat.com Errors-To: linux-audit-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=linux-audit-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 --- 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); +} -- 2.17.1 -- Linux-audit mailing list Linux-audit@redhat.com https://listman.redhat.com/mailman/listinfo/linux-audit