From: yangyingliang@huawei.com (Yang Yingliang)
To: linux-arm-kernel@lists.infradead.org
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 [thread overview]
Message-ID: <1464750362-14188-5-git-send-email-yangyingliang@huawei.com> (raw)
In-Reply-To: <1464750362-14188-1-git-send-email-yangyingliang@huawei.com>
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 <yangyingliang@huawei.com>
---
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)
--
2.5.0
next prev parent reply other threads:[~2016-06-01 3:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-01 3:05 [RFC PATCH 0/4] arm64: vdso: check whether the params is invalid address Yang Yingliang
2016-06-01 3:05 ` [RFC PATCH 1/4] arm64: vdso: introdce a macro for checking the address Yang Yingliang
2016-06-01 3:06 ` [RFC PATCH 2/4] arm64: vdso: check whether the params of gettimeofday() is valid Yang Yingliang
2016-06-01 3:06 ` [RFC PATCH 3/4] arm64: vdso: check whether the tp pointer is valid in clock_gettime() Yang Yingliang
2016-06-01 3:06 ` Yang Yingliang [this message]
2016-06-06 17:12 ` [RFC PATCH 0/4] arm64: vdso: check whether the params is invalid address Will Deacon
2016-06-08 9:18 ` Yang Yingliang
2016-06-08 9:33 ` Will Deacon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1464750362-14188-5-git-send-email-yangyingliang@huawei.com \
--to=yangyingliang@huawei.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.