From: Lukasz Majewski <lukma@denx.de>
To: Joseph Myers <joseph@codesourcery.com>, Paul Eggert <eggert@cs.ucla.edu>
Cc: Alistair Francis <alistair23@gmail.com>,
Alistair Francis <alistair.francis@wdc.com>,
GNU C Library <libc-alpha@sourceware.org>,
Adhemerval Zanella <adhemerval.zanella@linaro.org>,
Florian Weimer <fweimer@redhat.com>,
Florian Weimer <fw@deneb.enyo.de>,
Zack Weinberg <zackw@panix.com>,
Carlos O'Donell <carlos@redhat.com>,
Lukasz Majewski <lukma@denx.de>
Subject: [PATCH 2/2] linux: clock_settime: Return proper value when passing NULL pointer
Date: Fri, 8 Nov 2019 16:33:44 +0100 [thread overview]
Message-ID: <20191108153344.10949-2-lukma@denx.de> (raw)
In-Reply-To: <20191108153344.10949-1-lukma@denx.de>
When in __clock_settime function (__TIMESIZE != 64) the const struct
timespec's *tp pointer is NULL, the Linux kernel syscall returns
-EFAULT.
Without this patch the glibc crashes (when dereferencing NULL pointer)
as the Linux kernel syscall is not reached at all.
There is no need for such check in the __clock_settime64, as this
pointer either goes directly to Linux kernel or the pointer to local
copy is used (ts64).
---
sysdeps/unix/sysv/linux/clock_settime.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/sysdeps/unix/sysv/linux/clock_settime.c b/sysdeps/unix/sysv/linux/clock_settime.c
index 6706dbb31f..e358a18998 100644
--- a/sysdeps/unix/sysv/linux/clock_settime.c
+++ b/sysdeps/unix/sysv/linux/clock_settime.c
@@ -51,7 +51,14 @@ __clock_settime64 (clockid_t clock_id, const struct __timespec64 *tp)
int
__clock_settime (clockid_t clock_id, const struct timespec *tp)
{
- struct __timespec64 ts64 = valid_timespec_to_timespec64 (*tp);
+ struct __timespec64 ts64;
+
+ if (tp == NULL)
+ {
+ __set_errno (EFAULT);
+ return -1;
+ }
+ ts64 = valid_timespec_to_timespec64 (*tp);
return __clock_settime64 (clock_id, &ts64);
}
--
2.20.1
next prev parent reply other threads:[~2019-11-08 15:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-08 15:33 [PATCH 1/2] linux: clock_settime: Remove check for nanoseconds validity Lukasz Majewski
2019-11-08 15:33 ` Lukasz Majewski [this message]
2019-11-08 16:56 ` [PATCH 2/2] linux: clock_settime: Return proper value when passing NULL pointer Alistair Francis
2019-11-08 17:00 ` Joseph Myers
2019-11-08 16:20 ` [PATCH 1/2] linux: clock_settime: Remove check for nanoseconds validity Alistair Francis
2019-11-11 15:45 ` Lukasz Majewski
2019-11-27 17:04 ` Lukasz Majewski
2019-11-27 19:27 ` Paul Eggert
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
List information: https://www.gnu.org/software/libc/involved.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191108153344.10949-2-lukma@denx.de \
--to=lukma@denx.de \
--cc=adhemerval.zanella@linaro.org \
--cc=alistair.francis@wdc.com \
--cc=alistair23@gmail.com \
--cc=carlos@redhat.com \
--cc=eggert@cs.ucla.edu \
--cc=fw@deneb.enyo.de \
--cc=fweimer@redhat.com \
--cc=joseph@codesourcery.com \
--cc=libc-alpha@sourceware.org \
--cc=zackw@panix.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).