From patchwork Wed Jun 1 03:06:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yingliang X-Patchwork-Id: 9145963 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C841D60777 for ; Wed, 1 Jun 2016 03:08:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BCA6425EF7 for ; Wed, 1 Jun 2016 03:08:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B0CDC2693F; Wed, 1 Jun 2016 03:08:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4F39B25EF7 for ; Wed, 1 Jun 2016 03:08:53 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1b7wVR-0008AO-4k; Wed, 01 Jun 2016 03:07:41 +0000 Received: from szxga01-in.huawei.com ([58.251.152.64]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1b7wUq-0007e1-Hg for linux-arm-kernel@lists.infradead.org; Wed, 01 Jun 2016 03:07:06 +0000 Received: from 172.24.1.47 (EHLO szxeml427-hub.china.huawei.com) ([172.24.1.47]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DLM72220; Wed, 01 Jun 2016 11:06:15 +0800 (CST) Received: from localhost (10.177.19.219) by szxeml427-hub.china.huawei.com (10.82.67.182) with Microsoft SMTP Server id 14.3.235.1; Wed, 1 Jun 2016 11:06:04 +0800 From: Yang Yingliang To: Subject: [RFC PATCH 4/4] arm64: vdso: check whether the res pointer is valid in clock_getres() Date: Wed, 1 Jun 2016 11:06:02 +0800 Message-ID: <1464750362-14188-5-git-send-email-yangyingliang@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1464750362-14188-1-git-send-email-yangyingliang@huawei.com> References: <1464750362-14188-1-git-send-email-yangyingliang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.19.219] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020204.574E512D.00A5, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 343f31565d92c1fe4ea86014ea74cc2a X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160531_200705_270162_A5096081 X-CRM114-Status: UNSURE ( 9.56 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: will.deacon@arm.com, linuxarm@huawei.com, guohanjun@huawei.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Use RANGE_OK to check whether the res pointer is valid. Returns -EINVAL if the it's NULL, returns -EFAULT if it's invalid, otherwise return 0. Signed-off-by: Yang Yingliang --- arch/arm64/kernel/vdso/gettimeofday.S | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/arch/arm64/kernel/vdso/gettimeofday.S b/arch/arm64/kernel/vdso/gettimeofday.S index 1e377ac..d7e4341 100644 --- a/arch/arm64/kernel/vdso/gettimeofday.S +++ b/arch/arm64/kernel/vdso/gettimeofday.S @@ -217,28 +217,36 @@ ENTRY(__kernel_clock_getres) ccmp w0, #CLOCK_MONOTONIC, #0x4, ne b.ne 1f - ldr x2, 5f + ldr x2, 6f b 2f 1: cmp w0, #CLOCK_REALTIME_COARSE ccmp w0, #CLOCK_MONOTONIC_COARSE, #0x4, ne - b.ne 4f - ldr x2, 6f + b.ne 5f + ldr x2, 7f 2: cbz w1, 3f + RANGE_OK(1, #TSPEC_SZ) + cbz x4, 4f stp xzr, x2, [x1] + mov w0, wzr + ret 3: /* res == NULL. */ - mov w0, wzr + mov x0, #-EINVAL ret -4: /* Syscall fallback. */ +4: /* res is invalid. */ + mov x0, #-EFAULT + ret + +5: /* Syscall fallback. */ mov x8, #__NR_clock_getres svc #0 ret -5: - .quad CLOCK_REALTIME_RES 6: + .quad CLOCK_REALTIME_RES +7: .quad CLOCK_COARSE_RES .cfi_endproc ENDPROC(__kernel_clock_getres)