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 68946C433ED for ; Fri, 23 Apr 2021 10:52:08 +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 B435C61452 for ; Fri, 23 Apr 2021 10:52:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B435C61452 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-176-voDnvZ01OYiBkf21C9hLOw-1; Fri, 23 Apr 2021 06:52:05 -0400 X-MC-Unique: voDnvZ01OYiBkf21C9hLOw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2D23E8189CA; Fri, 23 Apr 2021 10:52:02 +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 157605C3FD; Fri, 23 Apr 2021 10:52:02 +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 DA03F89DA; Fri, 23 Apr 2021 10:52:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13NAa3Ii003906 for ; Fri, 23 Apr 2021 06:36:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4B79211301DC; Fri, 23 Apr 2021 10:36:03 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 469291055DB0 for ; Fri, 23 Apr 2021 10:35:59 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (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 B872C104D9A0 for ; Fri, 23 Apr 2021 10:35:59 +0000 (UTC) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2043.outbound.protection.outlook.com [40.107.237.43]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-526-bsmOkJmrNQebDCALrrmvIg-1; Fri, 23 Apr 2021 06:35:55 -0400 X-MC-Unique: bsmOkJmrNQebDCALrrmvIg-1 Received: from MWHPR1101MB2351.namprd11.prod.outlook.com (2603:10b6:300:74::18) by MWHPR1101MB2192.namprd11.prod.outlook.com (2603:10b6:301:59::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.23; Fri, 23 Apr 2021 10:35: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.4065.024; Fri, 23 Apr 2021 10:35:52 +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 v2 1/3] arm64: ptrace: Add is_syscall_success to handle compat Date: Fri, 23 Apr 2021 18:35:31 +0800 Message-Id: <20210423103533.30121-1-zhe.he@windriver.com> X-Originating-IP: [60.247.85.82] X-ClientProxiedBy: CY4PR19CA0041.namprd19.prod.outlook.com (2603:10b6:903:103::27) 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 CY4PR19CA0041.namprd19.prod.outlook.com (2603:10b6:903:103::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Fri, 23 Apr 2021 10:35:49 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: db8ceb0e-bd69-48f7-481b-08d906439150 X-MS-TrafficTypeDiagnostic: MWHPR1101MB2192: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: vL5iQSq4zXJcl10VQTbg1Bz/swL4hIKeFSiTGgTEmQvnjTVrHHXINbDpW/zfXI5NCWblVi9AnahfpcN/ElwMfc/Ct92q8ENZveUFNLufcZbCHk774ZTDVldJHtUAbk4gXdUr3oXdgypBiBkxJaeU0WrQW9VTZI7JwUQZXbg55KI94iLNe6Ht74+IkemW+fTdpeLuxlGE0eX1U5eXhWYvGd72aLd14Q63ZNpJ7SgHcOY25mCbGoiQzxwlyRtOgyrgHi7Sbi07qCVIzSAL6CkUnnZ2IG2caAUb49iZrUr5uqlpDV/IiAMkwa11OOn/lWBE/pGEp/8nWV0MvG8VeMINZ/GJ+j2LbfR6lySFXU8cKpiAwsuNo2Ufbza8f8/7A6a62UKZfXFrwKuNLNVBTVx0ULNxpAS9rY2MyIz6tAqR7vHf/pYI+K1iX5n3efE92+66mZ8rdOwX1QdsaUANHzmmwRUan/lfG9eNKAOFiGNur07hvwejroAisTnj762EVvirkxug0DcNxRAYQMtAoaJVI8jQUgZAJKiL7zg+e7HkbcYJAAPLBOnP71E7WDOiGlZlkrN6h5cn5lnQF//7Q0P/c78ub2qS4gfUzPyPxH1i00dayfTwz2fe0YQ5JqR4V/QXhWxhrVL+a2F3Pr2WFRHKMQ== 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)(346002)(376002)(39850400004)(396003)(136003)(366004)(52116002)(38100700002)(86362001)(38350700002)(8676002)(6486002)(8936002)(6512007)(26005)(186003)(16526019)(316002)(6666004)(1076003)(6506007)(478600001)(2906002)(5660300002)(66946007)(2616005)(83380400001)(956004)(66476007)(66556008)(36756003); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?Nz3qcKZm6CymuGWcTXKruAd/4IralKfsbddB8KiiWzQ8hhWL8I7X+odAeDuz?= =?us-ascii?Q?7u6kDr64ptM4+fMsucoAQYroe4qRtWAsnWxCjhFiUn52pHLUGn4aY/wfbDQH?= =?us-ascii?Q?5KEWlfsDauFSiN4YVqRSR2tTgpbZJ24ftIDVnQo2rM3c2tOij/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j4AI07tv7epd4SrJCIBXsRspF/LnnEz8erB00pWZLCK?= =?us-ascii?Q?VsrnsgVtXL3VsHCV32Fn+xN+1PkKdCDpqYpIlhvYfVHxIShclV480x12lhvn?= =?us-ascii?Q?dfD23d1PX3PL+VVK/wYEfOyA4tRY54mWpqZzlL6AlVtmhubDNea0QJRATDcT?= =?us-ascii?Q?syjSKoeSMo/YeNbgVVAASdWWUOrcxzckoSbPa8ujHtNydKSy8mNhDsy5c70+?= =?us-ascii?Q?pVgNpH95BbhinYz+OJlKYkwC+h1sffB8/M35tRIvASpJJGyFnc5g6NSDhiwr?= =?us-ascii?Q?nHuXoYc8jEKIEWrNO0DCMzS4?= X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: db8ceb0e-bd69-48f7-481b-08d906439150 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1101MB2351.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Apr 2021 10:35:52.5616 (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: AyrUejYoTuSFnQ4qned/MChnyBE5mnwsvqPH4/UFgVxcZ3+LWaEKCRmjj3N8AT2e2FrsTneM1GkYlOUJCct1+Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1101MB2192 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.3 X-loop: linux-audit@redhat.com X-Mailman-Approved-At: Fri, 23 Apr 2021 06:50:23 -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.16 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 syscall_get_return_value is defined in syscall.h, implementing is_syscall_success in ptrace.h would introduce build failure due to recursive inclusion of some basic headers like mutex.h. Let's put the implementation to ptrace.c Signed-off-by: He Zhe --- v1 to v2: Call syscall_get_return_value to reduce code duplication arch/arm64/include/asm/ptrace.h | 3 +++ arch/arm64/kernel/ptrace.c | 5 +++++ 2 files changed, 8 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..2c84255e1e41 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -1909,3 +1909,8 @@ 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) +{ + return !IS_ERR_VALUE(syscall_get_return_value(current, regs)); +} -- 2.17.1 -- Linux-audit mailing list Linux-audit@redhat.com https://listman.redhat.com/mailman/listinfo/linux-audit