From: yangyingliang@huawei.com (Yang Yingliang)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 2/4] arm64: vdso: check whether the params of gettimeofday() is valid
Date: Wed, 1 Jun 2016 11:06:00 +0800 [thread overview]
Message-ID: <1464750362-14188-3-git-send-email-yangyingliang@huawei.com> (raw)
In-Reply-To: <1464750362-14188-1-git-send-email-yangyingliang@huawei.com>
When the params of gettimeofday() is an invalid addr(E.g.
gettimeofday(-1, -1)), it will get segment fault. To avoid
this fault, use RANGE_OK to test whether a block of memory
is valid. Returns -EFAULT if the range is invalid, 0 otherwise.
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
arch/arm64/kernel/vdso/gettimeofday.S | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/kernel/vdso/gettimeofday.S b/arch/arm64/kernel/vdso/gettimeofday.S
index 05ccaca..43ec321 100644
--- a/arch/arm64/kernel/vdso/gettimeofday.S
+++ b/arch/arm64/kernel/vdso/gettimeofday.S
@@ -22,6 +22,7 @@
#include <asm/asm-offsets.h>
#include <asm/unistd.h>
#include <asm/memory.h>
+#include <asm-generic/errno-base.h>
#define NSEC_PER_SEC_LO16 0xca00
#define NSEC_PER_SEC_HI16 0x3b9a
@@ -78,10 +79,12 @@ ENTRY(__kernel_gettimeofday)
/* Acquire the sequence counter and get the timespec. */
adr vdso_data, _vdso_data
1: seqcnt_acquire
- cbnz use_syscall, 4f
+ cbnz use_syscall, 5f
/* If tv is NULL, skip to the timezone code. */
cbz x0, 2f
+ RANGE_OK(0, #TVAL_SZ)
+ cbz x4, 4f
bl __do_get_tspec
seqcnt_check w9, 1b
@@ -93,12 +96,18 @@ ENTRY(__kernel_gettimeofday)
2:
/* If tz is NULL, return 0. */
cbz x1, 3f
+ RANGE_OK(1, #TZ_SZ)
+ cbz x4, 4f
ldp w4, w5, [vdso_data, #VDSO_TZ_MINWEST]
stp w4, w5, [x1, #TZ_MINWEST]
3:
mov x0, xzr
ret x2
4:
+ /* tz is invalid */
+ mov x0, #-EFAULT
+ ret x2
+5:
/* Syscall fallback. */
mov x8, #__NR_gettimeofday
svc #0
--
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 ` Yang Yingliang [this message]
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 ` [RFC PATCH 4/4] arm64: vdso: check whether the res pointer is valid in clock_getres() Yang Yingliang
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-3-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.