mailing list of musl libc
 help / color / mirror / Atom feed
* [musl] [PATCH] fix segfault in getitimer when old argument is NULL
       [not found] <20210112074221.58076-1-zhuyan34@huawei.com>
@ 2021-01-12  7:56 ` zhuyan (M)
  2021-01-12  8:58   ` Fangrui Song
  0 siblings, 1 reply; 2+ messages in thread
From: zhuyan (M) @ 2021-01-12  7:56 UTC (permalink / raw)
  To: musl; +Cc: Zengweilin, liucheng (G), chenzefeng (A)


When old is NULL, call old->it_interval.tv_sec to dereference a null pointer in getitimer.

The commit 558c01338b0b635632e70af6ec8a484ca70b0328 introduces this problem.

Signed-off-by: Qing Wu <wuqing30@huawei.com>
Signed-off-by: Yan Zhu <zhuyan34@huawei.com>
---
 src/signal/getitimer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/signal/getitimer.c b/src/signal/getitimer.c index 36d1eb9d..f6fde204 100644
--- a/src/signal/getitimer.c
+++ b/src/signal/getitimer.c
@@ -6,7 +6,7 @@ int getitimer(int which, struct itimerval *old)
 	if (sizeof(time_t) > sizeof(long)) {
 		long old32[4];
 		int r = __syscall(SYS_getitimer, which, old32);
-		if (!r) {
+		if (!r && old) {
 			old->it_interval.tv_sec = old32[0];
 			old->it_interval.tv_usec = old32[1];
 			old->it_value.tv_sec = old32[2];
--
2.12.3


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [musl] [PATCH] fix segfault in getitimer when old argument is NULL
  2021-01-12  7:56 ` [musl] [PATCH] fix segfault in getitimer when old argument is NULL zhuyan (M)
@ 2021-01-12  8:58   ` Fangrui Song
  0 siblings, 0 replies; 2+ messages in thread
From: Fangrui Song @ 2021-01-12  8:58 UTC (permalink / raw)
  To: musl; +Cc: Zengweilin, liucheng (G), chenzefeng (A)

On Mon, Jan 11, 2021 at 11:57 PM zhuyan (M) <zhuyan34@huawei.com> wrote:
>
>
> When old is NULL, call old->it_interval.tv_sec to dereference a null pointer in getitimer.
>
> The commit 558c01338b0b635632e70af6ec8a484ca70b0328 introduces this problem.
>
> Signed-off-by: Qing Wu <wuqing30@huawei.com>
> Signed-off-by: Yan Zhu <zhuyan34@huawei.com>
> ---
>  src/signal/getitimer.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/signal/getitimer.c b/src/signal/getitimer.c index 36d1eb9d..f6fde204 100644
> --- a/src/signal/getitimer.c
> +++ b/src/signal/getitimer.c
> @@ -6,7 +6,7 @@ int getitimer(int which, struct itimerval *old)
>         if (sizeof(time_t) > sizeof(long)) {
>                 long old32[4];
>                 int r = __syscall(SYS_getitimer, which, old32);
> -               if (!r) {
> +               if (!r && old) {
>                         old->it_interval.tv_sec = old32[0];
>                         old->it_interval.tv_usec = old32[1];
>                         old->it_value.tv_sec = old32[2];
> --
> 2.12.3
>

Null old is not sensible. POSIX and the Linux manpage say "The
getitimer() function shall store the current value of the timer
specified by which into the structure pointed to by value."
NULL is not a valid structure. musl does not need to work around
application bugs.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-12  8:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20210112074221.58076-1-zhuyan34@huawei.com>
2021-01-12  7:56 ` [musl] [PATCH] fix segfault in getitimer when old argument is NULL zhuyan (M)
2021-01-12  8:58   ` Fangrui Song

mailing list of musl libc

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.vuxu.org/musl

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 musl musl/ http://inbox.vuxu.org/musl \
		musl@inbox.vuxu.org
	public-inbox-index musl

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.musl


code repositories for the project(s) associated with this inbox:

	https://git.vuxu.org/mirror/musl/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git