From: Thomas Gleixner <tglx@linutronix.de>
To: Sasha Levin <sasha.levin@oracle.com>
Cc: linux-kernel@vger.kernel.org, John Stultz <john.stultz@linaro.org>
Subject: Re: [PATCH] time: settimeofday: validate the values of tv fomr user
Date: Tue, 2 Dec 2014 12:16:43 +0100 (CET) [thread overview]
Message-ID: <alpine.DEB.2.11.1412021209020.3961@nanos> (raw)
In-Reply-To: <1417493050-13594-5-git-send-email-sasha.levin@oracle.com>
On Mon, 1 Dec 2014, Sasha Levin wrote:
> An unvalidated user input is multiplied by a constant, which can result in
> an undefined behaviour for large values. While this is validated later,
> we should avoid triggering undefined behaviour.
>
> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
> ---
> kernel/time/time.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/kernel/time/time.c b/kernel/time/time.c
> index 9ec4fa5..6f53df7 100644
> --- a/kernel/time/time.c
> +++ b/kernel/time/time.c
> @@ -200,6 +200,10 @@ SYSCALL_DEFINE2(settimeofday, struct timeval __user *, tv,
> if (tv) {
> if (copy_from_user(&user_tv, tv, sizeof(*tv)))
> return -EFAULT;
> +
> + if (user_tv.tv_usec > USEC_PER_SEC || user_tv.tv_usec < 0)
> + return -EINVAL;
We should create timeval_valid() for this with the same logic as
timespec_valid().
Thanks,
tglx
next prev parent reply other threads:[~2014-12-02 11:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-02 4:04 [PATCH] time: do a safe overflow check in ktime_add_safe Sasha Levin
2014-12-02 4:04 ` [PATCH] time: make sure tz_minuteswest is set to a valid value when setting time Sasha Levin
2014-12-02 4:04 ` [PATCH] vfs: calculate seek offsets using unsigned variables Sasha Levin
2014-12-02 4:04 ` [PATCH] mm: fadvise: avoid signed integer overflow calculating offset Sasha Levin
2014-12-02 4:04 ` [PATCH] time: settimeofday: validate the values of tv fomr user Sasha Levin
2014-12-02 11:16 ` Thomas Gleixner [this message]
2014-12-02 4:04 ` [PATCH] fs: sync_file_range: avoid overflowing signed calculation Sasha Levin
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=alpine.DEB.2.11.1412021209020.3961@nanos \
--to=tglx@linutronix.de \
--cc=john.stultz@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sasha.levin@oracle.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®