From patchwork Fri Apr 23 10:35: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: 12220081 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 C227CC433B4 for ; Fri, 23 Apr 2021 10:38:26 +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 297BD613D7 for ; Fri, 23 Apr 2021 10:38:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 297BD613D7 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=5YtT0s55aGLGskbhSVsZEZ4fNx2pctJIstjl4llcD/w=; b=aAod7icKpIFk2h 4hDc6YhaMVMForPAqpvzYsDBK0ZE5f1hBSLjDtySOt+KewzlLyxsrsJ11uFicZSgnLV1FCmP325dQ lT68SIOh0DT7gdOfBH0kBkixhoPKqft6gX4blgBklEcA1jL+lztNDdJqm/7jjtBCDSh8/7Exr86KG cAE6qlHQtXNyO3eKvuxabHYGZ955krr4F5O+thE3LSnyEXymEuf0slGLYFwxFqhWWDfs980OhdsqN csGvRjF+sWKudEBcNduddIckuSIVzuvP3/5NFL/MoNgoo3VhkODzYkKeJuJ6RVwmqoE9MOG8fCv5j 2mSuUxYel97+a3LlM8GA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lZtAK-001Jwn-VC; Fri, 23 Apr 2021 10:36:05 +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 1lZtAG-001JwH-GI for linux-arm-kernel@desiato.infradead.org; Fri, 23 Apr 2021 10:36: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=s5ULuJNq832Bw0rukmRVELOKgATbQUbAU5kBZW8Vc2o=; b=NqgrNeEGqBs0y1SfcNp4NvxONq H2vXqElvkhAfpG6xYBrGtCvLQ2whqBTB/HYG+ycnkZzhCNcnwo+a/nT9LOeZxjguISQoFxlGIqKAd oS+j5e59+i2FEzf3J4W+QHPpq8nbaGUsD2am2Q9a6M9b62ofQL9DTRTC6XOOdbvyUHKxVAg4TZSIi YxU55CmSIpdQ6Ik8w43M52AmSB5MIDPHkwTePBNiSELq+7klxuISwL9gzGCeMcU8yWu1GULCUvVeD 6aSMPpqhsuGC17NMo8AqBuf7TO+W3AvTjojmMUQ2UEM/wPMTAeUFyFpO+BauFbSXg/Izezx23LuSD wSYTxE6g==; Received: from mail-bn8nam12on2066.outbound.protection.outlook.com ([40.107.237.66] helo=NAM12-BN8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZtAD-00EKdZ-DE for linux-arm-kernel@lists.infradead.org; Fri, 23 Apr 2021 10:35:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fNYgWSOcmDeDcsSaTqStZjAYiqfloG0iP4CVJ8Re0CJYlfO4ZUfzGWZBIOV8sBL+uRoKIPuOQX7clVaejgGmDHEGbABoL+RxRRXNIQsdr74qcfAr5nWp42WjF9cD+YnlbHm0dMtXUDvr0JEbojrmsW1w162TZIuMF9lnmQhEvBSY9mtqUgmlpRM1L3/Mdeudu2JgK0dBj6s4hrg0Y58yMBAoZo9hVHLS+nVOx/Qnor6OkDhsq1hK3OUIpFt36JlfSoaESRjl4aLGq6b/364vVN6HjsBGZwWA9MvDtWGqUDSnyPr+FRB+8Jba3e4KoqA7JDdknHle2eO3N7Ff5exuhA== 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=s5ULuJNq832Bw0rukmRVELOKgATbQUbAU5kBZW8Vc2o=; b=cLAvaqp7PAfdYBorgmUV6qBKNdkDWtDAauF7HKIkGlU7IpxEY1JnA2RV9hsk0wWqyg7VuloSXnKR1foLm4d3HmgjfPXZAnEfcV8loQwH315CiHxMVVlTVib1OsfQvAqS7fkR3vVe/z183DHdkuqfmflII3Idymadl3/KqVIZe87SB1m1HfzQdrichaIGeC+KEgXpWnf9NKnGJ9eGsYlqCxGyi9CV818feHIli17rRrRJi5rUdF0sDdwbSwEPG+vW6oNw6fHtvZ6s94Ut53LIs+Dj9Ws7X0jiNXAEG83Y7nXs1EBVi/ux6niCiRI9akF3EI88Ol5D7sf12A7SCwYbkQ== 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=s5ULuJNq832Bw0rukmRVELOKgATbQUbAU5kBZW8Vc2o=; b=a4dQddrb08DYngSrdW0lVfI9lvsciLcggc/UaTkgiMoGFbKaaMxP1IaCe0gXkBq+6Fz8kmJfTXFqra8ozz6OkPnPO4qSwGNGll/IwESg0lZfaReFBquR8atkgWVP/w5dQvZKZDTAOEL4A1Lu92u1lq0gBia2z6W+ntmvRtzyi4k= 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 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-Mailer: git-send-email 2.17.1 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: Nz3qcKZm6CymuGWcTXKruAd/4IralKfsbddB8KiiWzQ8hhWL8I7X+odAeDuz7u6kDr64ptM4+fMsucoAQYroe4qRtWAsnWxCjhFiUn52pHLUGn4aY/wfbDQH5KEWlfsDauFSiN4YVqRSR2tTgpbZJ24ftIDVnQo2rM3c2tOij/ZGX/9TCUtaLbFqVbLHKLeAedcH7iEMWskA++Z4Sn7NJtvSABIoxCSAAFOkaOHEmyiLx7VTHb0QYbEnRDCTQ+XS/ozJOTH5+2IPDLnetDGsSIDX1OE7wlB9mHpBlE9InE4uVsHsZ3bLOcllMgRcsFpVR0FtSBOxmvBiU/7o8p2FI5FOOMhoF1i8xv0wlXP+C1sMXnv6i4OyPy3z0IQcK9T4/U1dNB+MVh80plXx7n4qcX8+JHP1Df93LmMA4f1yFvtqCJsWTWOj/9GtuKo2sxTawiOSaz5IS24I9bDXOke/k6k+fvliOJ6vdWnBNVmbt/oTs0yTkSxKMsle2dzoZksHcIfHzOGXu27U5cA47T685+akswHyUO75juFMJ0EYu1391lachnnyLOJdg3DPbX6s50EqrbfRr9/s7lsZFVADEYMQIwxa/tH3Rt92c+1UrTHmdiDq1/a3Wp18f1OXsV4NL630O41P8vuI42QkJCuwpdsQVxrfhbf86pi1hSqOwdx7LCzpJcGw/HbZoT/V1kkUClzvM6hPVAtuh+u5LxsS0jxO/dQRc1QNTRYgyFR16P60dE1JhmT0P99Q+TsC72TlP0QT4Zj6Ox8/pJ08Jexs/eVa8F+ft3OrWtRVmIOSwKl7QCtuQ/uIUGnwRg3cKJZeWr2qInWz2ccRMN9XFYgkFbjBxJgP1bWEgimoDqOiAO7QPXpMCql9W01N2u01Jg9iwbk0PW99upG8eZtWC/6PqhWpx70zSAc840a2igJq7vONJ3yfF/cWWH6zWfby2YRXSMTbqJU8PIf1AGQeoC+KdZO3dMXN1FtuXC5rwC7RWGxEvYq1/BgZGYQhfaj9nyu4JDLsFuRJS/xxuj4AI07tv7epd4SrJCIBXsRspF/LnnEz8erB00pWZLCKVsrnsgVtXL3VsHCV32Fn+xN+1PkKdCDpqYpIlhvYfVHxIShclV480x12lhvndfD23d1PX3PL+VVK/wYEfOyA4tRY54mWpqZzlL6AlVtmhubDNea0QJRATDcTsyjSKoeSMo/YeNbgVVAASdWWUOrcxzckoSbPa8ujHtNydKSy8mNhDsy5c70+pVgNpH95BbhinYz+OJlKYkwC+h1sffB8/M35tRIvASpJJGyFnc5g6NSDhiwrnHuXoYc8jEKIEWrNO0DCMzS4 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210423_033557_520926_93469E18 X-CRM114-Status: UNSURE ( 8.57 ) 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 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)); +} From patchwork Fri Apr 23 10:35: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: 12220083 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 8D60DC433ED for ; Fri, 23 Apr 2021 10:38:27 +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 E3C2D613D7 for ; Fri, 23 Apr 2021 10:38:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E3C2D613D7 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=p5OjKkRye5zjuWWHboOYvf1crfGandQD0XcBQ/Zl1Ss=; b=G+AFKWRZYQqqcWPPv080U0UtZ TaUYyWv+8FQ0DVj/L+ur2CRNL5wxAGngKSrpCYrZ+vM7OvGEt0IMm15gUbTwJY/VyOoPGq1zNFnXR iB09T/lA1bdJkpHfK/B5OlYyuEW2r0HjTvTWH5hJBaLsnwXppzlXCoKJTv72+qIyGzZ97OkHd4qfu XEy28NunS+MtS74mnBekIkwpHNZiKktkTk/yeCYtjP2SFTLd378k3Bo9bkz0h11P9WjWJns4eqM4O KpPanswNrBilLsUhTezGuAAJ0aWeTaMX7h/jyY9GxIpVXaUKGPZol2TRG1m5THgEqdEXbZ1Nrttg8 gzBrSZWQg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lZtAV-001JzJ-QU; Fri, 23 Apr 2021 10:36:16 +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 1lZtAH-001JwO-FC for linux-arm-kernel@desiato.infradead.org; Fri, 23 Apr 2021 10:36: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:References: In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description; bh=EH5wqHUN9VDLDKFW3Rv5PrsNRB/SD0EOsVwV5A//cdk=; b=VHGmoXsSnvTS+86OTWueYqKYVM hChX3a9ESdgcEKpkh8OzLhpAYT+VIqvM0v+RJCpSgBx0GaWwWw63WxY7unuVer2OTuHVqRffQrC+w sls8vYnm5gKGjKpNtDhAzbKfFoBw6gCAs5dHk5UeRIh5Y1Z0mMPZu/260IIJ63l1mPZGjTvYohoEZ Up5wLwIhKahxFbTExUGXv59ZsXAoXKjAz0VgNqSEOvamPb1CJgwtp/cArWSWf/HifJ7a9gD8MStUB WwEGMEW+ClO/wZB8tm3TR74LYAcQz6s+ffLenM8SwhJ9RfF54zyi2Cs8GCOA4dw6+4uxX8ldKN0xd PfUNFn6g==; Received: from mail-bn8nam12on2066.outbound.protection.outlook.com ([40.107.237.66] helo=NAM12-BN8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZtAF-00EKdZ-2K for linux-arm-kernel@lists.infradead.org; Fri, 23 Apr 2021 10:36:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I3beXnUMwXZKO9QWvKf0hHw6WeRx63XEkm9V9LMxztyfif8Gs7kSy01D0ku0iiAuX/dkQMi5G3TGHp7MCeSEbMmY1n6hHLAv9JXZkEToDpcuRGqPr20qqknDoyiDB9Dc7a/Hhe5NGJ9GZXbOW6H60kGlu6P8316p1p++UFtMGeD5tvImdC/MbOMkVOOvn33Tl+2oBCGtSRUblG+dztyI4lRH6FMg1KNsl83dmoyPvVU5hVpWen8XS6SFX4YWnVnL3smQXaP9aHeJv7Z+0By2nKi2kGzRUys2MRFOLq1u9FMWXtCG99VT6nDImObL0qKiNFabRShfc2CdUlbGkwQDVQ== 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=EH5wqHUN9VDLDKFW3Rv5PrsNRB/SD0EOsVwV5A//cdk=; b=DUic4RALXyXfa90HHrMiXmF8dkC7XYXdJonkualn7Av2jmgM+9aC0GCoT7tGOxI0vImxaFhR0nu99Ldr/3jOD/PNgkV3XainyvH0DXGPjBsrPqfCUT9uhhY2ODps3vwP3avaXFGTnjdgctYIR3j9VRhnPnf/QTkqsXn7yJnBg7kAx/cIOJ8JZlxFbi78ucJg4NxqsT9uted8k/JkkRtimgPN4UtJm90zNYGzfgDgZsCXZyrUVyGTY+3Vnjt8pxeLSu36hwVH9ltn1PIzaHv8+I+ttnb0dOp/8gyc1dQ96uyXL2JLu0wnfAcA35TyHtRj33J7acuYNvaZ26fGwsxVZg== 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=EH5wqHUN9VDLDKFW3Rv5PrsNRB/SD0EOsVwV5A//cdk=; b=jAHaqbG10UaI/BJmgTNM3OZ/+9XM4X9QcBTXXyYBZid83N8e7Dxh5UkLwLdDE9nsocDGr9HhLafOznVxVZUSFVoJStpaPwY5+pi3jXRjYJ8uvtCAzUpP7qY5cSo+oX05a21SAqb0+03a6J7LKS2+H8+D1PKwCAEIKy/D39fzqNI= 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 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:58 +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:58 +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 2/3] arm64: syscall.h: Add sign extension handling in syscall_get_return_value for compat Date: Fri, 23 Apr 2021 18:35:32 +0800 Message-Id: <20210423103533.30121-2-zhe.he@windriver.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210423103533.30121-1-zhe.he@windriver.com> References: <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:53 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0f28e30c-dbb0-4d32-afd3-08d90643939e 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: OQb4Xtc3URswsbP0UHi73MaMObWyT5y1UWASUG3g7fuhwEL4EYMstfjAEbR02MTSjoE1t17toiZALySrkdRnM4ReMMasnl94xz77TdNOmdsXDi2CyKYvqpRSIQiFlrQfrM2vQwONsteEUGPNMbp/YqVVNrlES8TIcKhwxohEyYzckmuy/3S7gGee8DNDIOvj9TU6ZMcdDHY7mmZgN22kVTTTf+Jsvk2ru7Fm+d7TH1T94N8B7u+R3A2Gp3iR6yyoyFsDIuDz/8qvAOapWxyAUSw6Zeu4QKvRBL10/vjAjwGcomI9E7SQLoYEd0fhruUr8D5CxGPIR/u/JjmYukbPmjT1U32uzXHyD4MC9g5YUwKSBqGt78kwVzp2OnebIzAVJC1KW9vlLV/KvmSQjVto87Y+2Io95llw+VM7aSiCUZmEi/UPHOSRti1tWKm6C0GgEPArhyGbT6lcvYG3lAWZPSEm2vu+5EZOszhKRCZO1UK2Yg70SVTACDX3yoYbEL/bZQ8rToD5h9JZnUXvgT0Y6IqaLyNJH1YasoMu9WaRY9RlAgwQHX5cX5kvJjRsEcMNbonNUh58MpjJYlUcs4yXgSaWWz4ezkfLkixz89MqGjptjVtip7+b2JeZG8Ot3XFoojysb3148Tvp1whT9ikeEWMK85Dw235Ww5pZCzOpdMs= 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: caomrY6hgNAKBbvoXixZHPre/wmowBpTGRWkh0DkadTgIBDXSJtUcbRGEhX/GgX1ODnjOCNEeHKXLBifmgK4n1FgfDN5447Oowvq4s7fUOqxGDFsJsbEZo673dLePjhPgpLowtcx9qIXbSkYZ8K1YN/OkoIoGR5zlsKx+sP28sF6aJogIaSXyzELnJtZV7zjVoxhpjBeDjKaGJq6Q659Bog3S2avu4m9GZ/EEeBnPxU/DbpaeJz2otYVEd3Map6IUZNlZornPgFg9ElL+oYipRKIVFqzsE7M4ENdYzOnQbx45D/KMmvEvM9/zR8/zlBDtfGWQehqyBasv8YNLMOItxijoLPQrGbXEl96OWGyD0FsetQJ7s9NhOcvpmDr3K/GU8e8tO8WPQ+iDa9e+N6WeL/Aq+Aj42POCSgJUd388i/nKJp/d/44Yl0+a4mBoGpQlORlbmAi7Upc0W4RdrnyD7Vtm1+HY6HEc9nmUHh80mREkoCA6ASUMJEEhn0BNV26+2hfczd7YaeUuQQWnIYr0eUerDUX+N8LPdijcpZ9uWtzdQ5kn9oV/l2w2LmB/8Pt5UlK55eq+8jvzPO0rS3gTH4J5HWxnLnGEE2ThuZtKcXxhjUptPDMau9XESHROF6xl5RS7Wanxbsb2UFVYpuLZr4KR3U0nw0kWreaq9uuNspWiP4LvcNUL2FsXT54tSCPD15fm/ImTRfIlhgPB+xysCgbSfn7qiOXdd7kwzTtsCYxHahkZAFiGHQHrebYjzo/JHArxryBppCi5i87At/SXBYUvJL4f66fO5KT72gJKkl2ZImrIvBcR28UI9goefrzkndlp9LyLaD4QUMqylktqgu93Nkvq104ETKxYzrvTtfvBnbDzJ9ztIXivtyEphWi3IXfuf98aW/SvvSc3a10UM7mIEqBJwrToWNqgml8jLtpJ/B3lzfim8gzzDAYvcb3Wv9zsPaFANmTQSTsaFAlikXtNgHQskY9VuCDL+lK0t8HUntopc6MBNEu5JpYq7tfrHSRmmXt4U/98jTjGVFza6x0Tip2JhJ5ns/MDBwyJkxOLDCmqED2F5dUguYQ2V861SPwWqquf/lIBWj6LIGahI85clwvh/QGF3F14Urug+uuDWzLiHiTqksx9l39CHPl1AbEIFx8tHVmp0Kue2BWNenlxFvon4TY6MnhGxoN8Dy762ZPepoxK9845Ux2AZxLoKzQZkpHYXyaq0q5KiEpy06ps+ih/0MzCRs7jtDpUGaFFlKOzFShmdA7S/Z7Y63uJngIT+lm3KooIzgm3gkif414gcXPhDC76llcHcZajIfkFzCb2Fi6VcjPBwVLbKoE X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0f28e30c-dbb0-4d32-afd3-08d90643939e 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:58.0672 (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: GfBm4xr20QaNeidFkyp8vSIbKrXJuxQ/z22S6gDQM4TihvtS1/IEcGB0LxRIsRq+dZ3heaALeppvLDTmfWOMVA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1101MB2192 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210423_033559_132001_0556B99B X-CRM114-Status: GOOD ( 11.24 ) 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. Suggested-by: Mark Rutland Signed-off-by: He Zhe --- v1 to v2: Improve error code check suggested by Mark arch/arm64/include/asm/syscall.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/syscall.h b/arch/arm64/include/asm/syscall.h index cfc0672013f6..c3b5fca82ff4 100644 --- a/arch/arm64/include/asm/syscall.h +++ b/arch/arm64/include/asm/syscall.h @@ -44,7 +44,20 @@ 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]; + long error = val; + + if (compat_user_mode(regs)) + error = sign_extend64(error, 31); + + /* + * Return codes with bit 31 set may or may not be an error code. + * For example, mmap may return a legal 32 bit address with bit 31 set + * for 32 bit thread, in which case the untouched val should be + * returned. Otherwise, the sign-extended error should be returned if + * it still falls in error number range. + */ + return IS_ERR_VALUE(error) ? error : val; } static inline void syscall_set_return_value(struct task_struct *task, From patchwork Fri Apr 23 10:35: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: 12220085 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 73FA5C433B4 for ; Fri, 23 Apr 2021 10:38:35 +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 D33D3613D7 for ; Fri, 23 Apr 2021 10:38:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D33D3613D7 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=VN0GZOlr8pW6loHwvMDMWWt9Of+9HM1ZwPBIkrWNUGY=; b=iZz1p3ViBwniAs36w8UJvuKmK RznujlOvlkjLPYki2lBtAN6YBiCwjrDcdj8TxazCoHblMdWvqgfIlxZhglAKRBJqmmwTB5N3UDhxA b+lNQqwr5EUfwfGIWPdaXwWnd0ss9shrDh+44yKBpu/lrqHmfDVjIsxx5lNy48bMyEWCoZlLBdciR 95snhd+5XE3BfLy5kSuU4BOJviwwBcLLvB8lW4+gHJeRO+S1lKJBUCMmmScBA5Zay3L2AwGvtBet0 sNEZ5LFxeFnBemFpEVYRpGBNchktSCjmejXWYPCi0e9ZbdJ/367IV0uywn6ixX+zXs60uU0VUu60z 5XfmXo/gQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lZtAj-001K1e-RD; Fri, 23 Apr 2021 10:36:30 +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 1lZtAN-001Jwv-4d for linux-arm-kernel@desiato.infradead.org; Fri, 23 Apr 2021 10:36:07 +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=oVXb/jfniKHAVt8fXpI4qKsIk++ZFmOxGm4V/kx+xmc=; b=jB+hg95JfS5wnb1bKTRIPvufRO 2ddGjj4Bv22LChAgBsjbBqNiaUN+4aPVmd3TTLzzeNeHoQeci0Ob75nf1ayYnbsUH+cwZ0vU80YXu Zpa6SftpZJxsbJO6P4vxChl4SpgBtFypms98IvH6jGJaAu4P/7GC7bMYfzwEL9Vud+nyPC1xXSZZL /ITfke/z9+ko/rZh960dKKjVjDSVtqfPm9+BarmZQLJftPsOGzqsAUaEbBcsDjHAYD9a/f9xnstTk ea4CvDnNRR3D5OfW7UPXIld1GHqh1TUnr/HBThDMOSg8wM0cBNBEs0kRHjZDFmeComj2Df8wZMRRD sF8FGC9Q==; Received: from mail-bn8nam12on2079.outbound.protection.outlook.com ([40.107.237.79] helo=NAM12-BN8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZtAK-00EKeI-Lx for linux-arm-kernel@lists.infradead.org; Fri, 23 Apr 2021 10:36:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eUZf7vXy5Z0gML+2uT7PUpQpmKRtg9xGT3RPiKs+7xsJQ5lnMZEdqsiqM97On+PaX2yI+5eIZ9ezX20wsr6hpeychf8S++TZHWG4HCBEEQJ/oSRgvkqAS0eUKvBQbnPO8gcnNqxfr9tw5lNu2HiSRABPLmfleKri7HyZfbrkInsezgIy86TA8ktvn1E/MBRgy5gaMnDRJ52ZAyYn8luEy/javpmzS0hAjgzxY40QC5d69TtKVCo03rVKP6ygFcoGGN2gPmsRZYnClG98zT31V3ny4HIPX/qHBtcQhlVNHo4UFAB31jQ2DtnVN6TNvstHtiVMv52LcUu2g0tvAhJjLw== 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=oVXb/jfniKHAVt8fXpI4qKsIk++ZFmOxGm4V/kx+xmc=; b=i3DykTmsCFAvRMz5s/4t0VxsOgNsMxSPlDwlozx4VxAQweSQGjBfwmjGaH4NsQ5G/XxW7/E5iGVQbYcQdQbh/JiX6Q/gp821r8uQoqwnRAUA8+hpP1IUjvQYYogt3lsRX4ef4KKoHMqyBb+L1M5Pc9EnY0yMnF1EdooyjnjXbPuIaXNsrmna9BMWJq3LuVFyqkevSQwMGv4PtXv9GaFPAllFas7CWnxqK8bI9a8kIazSWjn29tHbIHwrACR2QB1W5m7RG+bMqe4uwWcVCG750vFUxuYb4vwrL5j7KatqZuGMEwEFQXfKUB2YxELFCjBRTOAP387H7cEeFs40Rr/lOg== 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=oVXb/jfniKHAVt8fXpI4qKsIk++ZFmOxGm4V/kx+xmc=; b=UB2Yn/jiUA56ZrdOblsN8P5F3R+Im9aM0JxyRfVCIr6TJRRkVkcFPPsDXYYPKbc/cSa89oT7IRgX+dhFPYeWE0QYRtRXgfoTEdlTO/Dd3SH9J+AuhYXI/nHY1eUr6QHKozboB+9UWvOigY+HFLPkqBp1vD1LftsATDs0G87Ju00= 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 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:36: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.4065.024; Fri, 23 Apr 2021 10:36: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 v2 3/3] audit: Use syscall_get_return_value to get syscall return code in audit_syscall_exit Date: Fri, 23 Apr 2021 18:35:33 +0800 Message-Id: <20210423103533.30121-3-zhe.he@windriver.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210423103533.30121-1-zhe.he@windriver.com> References: <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:58 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 921bf59d-fabe-4092-ba5c-08d9064396bf X-MS-TrafficTypeDiagnostic: MWHPR1101MB2192: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4941; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Is8jUvCqnbR3C9XWtNccKw6oF0RlgPFOn28/74fbuAaEtvBE4e+igvMMebr4MF5wb+GxTf/Nkz/nLvieNImGPye+hzfFz0oyKZhmCYJsWzx1lKqHukMfeZLtm2BSva0pL5F1zfrUD0kqah4iH6VLd2a334L40NT39++6hJtPbNn0Up7xrSKHkkKHHrbDuFW7ZiPnWfjiO+kOehvn1MhnMsQXnLoc5/v5UoyycqKMjb7+C4s36BHmeERvgqL6dOXXzJ62/Gh1uV7Ax61JqKz+l1Oi1tfjAKLqNvQlcsO+3wvBW3NTJq9JbC4SxLjYBPZN5f8tjgUwrwkbO1XwzMw0+idYriXPTr+BkeFtn6JsPEHNYNNNLjfjgPehWRIHaZONH3hJkXoyxe+Dmqbhy3TtSJrSbYwzueq+lrQ8TZRtgIH1GlsqcglxbHWpUW1EZk7J/j7EGUjit/f4xyunW2BkNuBsbVEbz+BlsbC9x7jfGED0STk2VqtSYZ/Ccetn3i8RPyBQeQHlt/kVTMJNmMi85/PrO5X+gAECJf34Ax2gPcWmRVAwl/dlIiiuY1EGOvNY213rdXDIghCyvETtquoISzVBu9M+OjWoTXuD0UpG9TpLOgnvEVVA6lLAmg2LubQZQghosT8yeQmTsJ9jMKOVWg== 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: 07XBfvUSdKahtoPPECYmjAYmn9mBZ3ptoxBx0YSoMXAygONKBKjxutZyjH1QeQKOgfGz49vQ6aLW1fJGPPS5e41WlCpXYBezFj8wYEQbb4bDdNHjVJj4VKnUIweIM+i9ucdmZ41wFe88ec/o3CieI5oY2exZ2zwmx/nqmZO5e8fg7CUAUW9bQK0gOxTS7no0GHE06qq/mr113+V87t4ngu2ddwXWEkZKrO0c7k+zJJyCWWRKJXVRfYjq62u2bYDypaCFpI2zRFbsnENSp+XQp1RjzXSM0ZpM5d/BxdEZPtcTJPAMTUwgOdr/QnOcF8Y9TlBAr3STU2rqwG9fHl5MD1aI1Ew5Lc0nK/dper7/mtCzkwRqZTgKc+ijxiFU/WSfoOdZkrsRaghJYdXZSTmWIq08v3n0mMHDR4Gw6Dl6p0HvTQTK4aoAN3xTlyr+pLR9+7vQn8vWd6HUUuXDN0RI33NeXl6FHOj0jlaQqKoUmXkiXbJ2/ZZ8bH/P/A0nwT/4Ik38PAQFdlVncmanu1ZGbkBlemiDqoeD7r8e7hloeJHb1jHw22Y5BfN0TIMCCAna2qpIsmH3svc1rrOhPUuz3O2PY5lyuyxs7VnSv/I9A+Mv6Qra2XwrUN30YRmmLj3uGk9w9+mRjoYOlwPi/0j3wsPdAdf/VOaUvNsCv9nxSy6qIirvHO4yYmCJsgoMzuwSJkYVBql27B8K0lmOqv6jIxj1J3Up5z5w2PJRSQ2ocG117SOHEJG5fZGefW3h06JC9+zDSpzIK9LlSlJF3qHmdg+ZCTUeIA4UiGtSmlQCaMKO5YdN5W1wxYeFwzXbOT2iaSzfLLE2uZU3qzyyUZk7feDSjbN89GCR94lz9eI1pXfpTWlSF+2m6mtNYG0UQkeSgBTxuRLAkrpjxPb2SqlnB8DFAqJIAkIUwtjl7wlTOgM7f2pXSomDxg7oANJg6Pc06NrxBRrcEOYlSqSxG6ULd04mQstdHJmyRp4ELxg/i4HzVkUd2Y+c7aF2a+O2t6BX60qhU6D+cLkuC2b5S/LGR/GlL7BYS9E+JxSFn3gq+s8hfVy28bdILcwEqBQ7b6znlNl1Ws/EhHApuSMBqs+3JAkIqnOrqQ0EmGUAqACObJFOplzIHhGRB40dZ5wyur9z1pE4u7g3mQ6j9+PHZjqJfimrwLqDO4Y9e6cbvKsXSeaNBmE+yOpZqDmf3rxepb3s9swbTg9z/E49i04OafxsP5T7yA1Sirfqa8RUVerwhED28wnjf3OErUVzF4CV71p9qQ1jEyem0HaWD81TaCA07gYq1TrkcCSTwy7+NUmU+cyltcJNlH+Z7xNcgmPOezWk X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 921bf59d-fabe-4092-ba5c-08d9064396bf 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:36:01.5486 (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: xqazgfDpZ+/85GbbQb2VFIU6kn2bvhD+EcvwMIHT/8uEB4eh9ADupV8uGBMmNSpzZFoDmb06pFOZI6AeHMYgtw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1101MB2192 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210423_033604_738921_A524C103 X-CRM114-Status: GOOD ( 10.51 ) 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 --- v1 to v2: No change 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); }