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.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 5427DC433ED for ; Wed, 21 Apr 2021 17:43:01 +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 027046140D for ; Wed, 21 Apr 2021 17:43:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 027046140D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.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:In-Reply-To:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=NxVLRjY/dNSGZtBS4Hn53fntm/clLl1DUitnJFPxmxs=; b=WvWoogWPUGX8mj93WeXsjkTJL +hRo7hX1hksfra7ElgQIBRlfAhbsjxDZcSFVi6TUuEMFv/Day9xVpHHKXV0ryRDcew7LRDd/4x5dr bd3D911pSpsRSA1AMYs4y9+1fAibtTGQffFOPCYwevB1N7Nu2CZuVv/QwlOQFe3Mrkn/PogtwUNy8 gDhNvUCiJIK0ERAxgPaXNYZ/MTB2tiNbFwloxm7l6ClvdmcyEqDpKI+ODUTYAINZ1sePwES33VCWR xnX1CN83nt45WfK/+JMIv2B0HisTp+UimFpdQIXdsSwq6YUTk7jobeTNrerbHz3VwQEOXT6RJpGlM 8bZlkSmxg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lZGqo-00Etha-M4; Wed, 21 Apr 2021 17:41:22 +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 1lZGql-00Eth2-WE for linux-arm-kernel@desiato.infradead.org; Wed, 21 Apr 2021 17:41:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=vcAeU2wpPOao18ZQw7/EHhBQrQgIbca79hBD+xyC5yg=; b=zJ6/YwYbDzqcW9ifPKjsNQlimT oJNphgs171y59GI0J/WSp5TGppvgGzxPXOcjEJ+HevlapI9/maawPOEqfCFghHZZ72I+j559wyvua ixCYlSFQgzNxq8wyoOGP/ovJkdodBksi0HcBpepooaTTjsAu3q8IKCDM2n5zr2jT9Zir0ezUwkeuh MROnerQXNEJpVeyo1BIHiqU04UUv34MbRNIeLnuMKSOJxvmljPw3JzaDvyjpGqAFL9NpHzGtMCdaA WE6SYszyQo8n6myUzvMjaCugEQEwBxxJglBH/3zgbSoS5LBGppsGfpR1kcMgrLZh9Z24Uri/qUtz+ XxB1jr4g==; Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lZGqj-00D4Qd-3Q for linux-arm-kernel@lists.infradead.org; Wed, 21 Apr 2021 17:41:18 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A92E311FB; Wed, 21 Apr 2021 10:41:11 -0700 (PDT) Received: from C02TD0UTHF1T.local (unknown [10.57.3.41]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B1FBB3F694; Wed, 21 Apr 2021 10:41:08 -0700 (PDT) Date: Wed, 21 Apr 2021 18:41:05 +0100 From: Mark Rutland To: He Zhe Cc: 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 Subject: Re: [PATCH 2/3] arm64: syscall.h: Add sign extension handling in syscall_get_return_value for compat Message-ID: <20210421174105.GB52940@C02TD0UTHF1T.local> References: <20210416075533.7720-1-zhe.he@windriver.com> <20210416075533.7720-2-zhe.he@windriver.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210416075533.7720-2-zhe.he@windriver.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210421_104117_209033_BE2CCFAE X-CRM114-Status: GOOD ( 17.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Apr 16, 2021 at 03:55:32PM +0800, He Zhe wrote: > 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. If a compat syscall can ever legitimately return a non-error value with bit 31 set, and this sign-extends it, is that ever going to reach userspace as a 64-bit value? IIUC things like mmap() can return pointers above 2GiB for a compat task, so I'm a bit uneasy that we'd handle those wrong. I can't see a way of preventing that unless we keep the upper 32 bits for errors. Mark. > > 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, > -- > 2.17.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel