* [musl] [PATCH] fix coredump when sched_rr_get_interval parameter ts is NULL [not found] <20200508143931.5165-1-zhuyan34@huawei.com> @ 2020-05-08 14:46 ` zhuyan (M) 2020-05-08 15:47 ` Markus Wichmann 0 siblings, 1 reply; 3+ messages in thread From: zhuyan (M) @ 2020-05-08 14:46 UTC (permalink / raw) To: musl; +Cc: Zengweilin, liucheng (G), zhuyan (M) In function sched_rr_get_interval, there is a risk of null pointer reference. On line 12, when ts is NULL, dereferencing the null pointer will cause the program coredump. Therefore, it must ensure that ts is not empty before use. Signed-off-by: Yan Zhu <zhuyan34@huawei.com> --- src/sched/sched_rr_get_interval.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/sched/sched_rr_get_interval.c b/src/sched/sched_rr_get_interval.c index 33a3d1a..3577291 100644 --- a/src/sched/sched_rr_get_interval.c +++ b/src/sched/sched_rr_get_interval.c @@ -9,6 +9,8 @@ int sched_rr_get_interval(pid_t pid, struct timespec *ts) long ts32[2]; int r = __syscall(SYS_sched_rr_get_interval, pid, ts32); if (!r) { + if (ts == NULL) + return -1; ts->tv_sec = ts32[0]; ts->tv_nsec = ts32[1]; } -- 2.24.0 ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [musl] [PATCH] fix coredump when sched_rr_get_interval parameter ts is NULL 2020-05-08 14:46 ` [musl] [PATCH] fix coredump when sched_rr_get_interval parameter ts is NULL zhuyan (M) @ 2020-05-08 15:47 ` Markus Wichmann 2020-05-08 18:45 ` Rich Felker 0 siblings, 1 reply; 3+ messages in thread From: Markus Wichmann @ 2020-05-08 15:47 UTC (permalink / raw) To: musl On Fri, May 08, 2020 at 02:46:56PM +0000, zhuyan (M) wrote: > In function sched_rr_get_interval, there is a risk of null pointer reference. On line 12, when ts is NULL, dereferencing the null pointer will cause the program coredump. > > Therefore, it must ensure that ts is not empty before use. > Is calling this function with a NULL pointer sensible? The manpage certainly doesn't say so. Usually policy in musl is to not fix application bugs, but to dereference pointers without NULL pointer check unless there is an explicit requirement in the relevant standards that a NULL pointer be accepted. Ciao, Markus ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [musl] [PATCH] fix coredump when sched_rr_get_interval parameter ts is NULL 2020-05-08 15:47 ` Markus Wichmann @ 2020-05-08 18:45 ` Rich Felker 0 siblings, 0 replies; 3+ messages in thread From: Rich Felker @ 2020-05-08 18:45 UTC (permalink / raw) To: Markus Wichmann; +Cc: musl, zhuyan (M) On Fri, May 08, 2020 at 05:47:37PM +0200, Markus Wichmann wrote: > On Fri, May 08, 2020 at 02:46:56PM +0000, zhuyan (M) wrote: > > In function sched_rr_get_interval, there is a risk of null pointer > > reference. On line 12, when ts is NULL, dereferencing the null > > pointer will cause the program coredump. > > > > Therefore, it must ensure that ts is not empty before use. > > > > Is calling this function with a NULL pointer sensible? The manpage > certainly doesn't say so. Usually policy in musl is to not fix > application bugs, but to dereference pointers without NULL pointer check > unless there is an explicit requirement in the relevant standards that a > NULL pointer be accepted. Indeed, sched_rr_get_interval has no contract to accept a null pointer, and doesn't even have a plausible reason to want to call it with one (the only output is in the pointed-to memory). Rich ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-05-08 18:46 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <20200508143931.5165-1-zhuyan34@huawei.com> 2020-05-08 14:46 ` [musl] [PATCH] fix coredump when sched_rr_get_interval parameter ts is NULL zhuyan (M) 2020-05-08 15:47 ` Markus Wichmann 2020-05-08 18:45 ` Rich Felker
Code repositories for project(s) associated with this public inbox https://git.vuxu.org/mirror/musl/ 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 NNTP newsgroup(s).