Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Wed, 15 May 2019 12:27:22 +0000
From: "zhaohang (F)" <zhaohang14@...wei.com>
To: "musl@...ts.openwall.com" <musl@...ts.openwall.com>
Subject: 答复: src/thread/__timedwait.c: Clock type

Thank you Rich for the analysis.

Bests,
Zhao Hang

-----邮件原件-----
发件人: Rich Felker [mailto:dalias@...ifal.cx] 代表 Rich Felker
发送时间: 2019年5月13日 20:41
收件人: musl@...ts.openwall.com
主题: Re: [musl] src/thread/__timedwait.c: Clock type

On Mon, May 13, 2019 at 01:36:15AM +0000, zhaohang (F) wrote:
> In the function _timedwait_cp, 'clk' indicates the type of clock used, CLOCK_REALTIME or CLOCK_MONOTONIC.
> 
> when we call __syscall_cp in this function, the fifth parameter 'top' is calculated based on the clock type.
> 
> However, the third parameter is not set according to the clock type. CLOCK_MONOTONIC is used by default.
> 
> Is this a bug? Or other considerations?

The timeout argument to the FUTEX_WAIT operation is always relative, and does not support choosing a clock. To support the more exotic clocks (e.g. cputime for a given thread) it would need explicit support here, but for just realtime and monotonic, it suffices to compute the relative sleep based on the argument and the current time in the given clock.

The behavior is of course different under non-continuous changes to the clock. This is a fundamental limitation of the FUTEX_WAIT operation; using the FUTEX_WAIT_BITSET operation if available would avoid this, but seems less likely to be able to support arbitrary other clocks in the future, and the behavior distinction only appears when you do something fundamentally broken (setting the clock wrong) and half the time it's worse rather than better...

Rich

Powered by blists - more mailing lists

Your e-mail address:

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.