Re: [PATCH 4.19 089/114] hrtimer: Annotate lockless access to timer->state

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi!

> From: Eric Dumazet <edumazet@xxxxxxxxxx>
> 
> commit 56144737e67329c9aaed15f942d46a6302e2e3d8 upstream.
> 
> syzbot reported various data-race caused by hrtimer_is_queued() reading
> timer->state. A READ_ONCE() is required there to silence the warning.
> 
> Also add the corresponding WRITE_ONCE() when timer->state is set.
> 
> In remove_hrtimer() the hrtimer_is_queued() helper is open coded to avoid
> loading timer->state twice.

Is there a reason why READ_ONCE is not neccessary in remove_hrtimer?

Should there be comment there explaining it?

Best regards,
								Pavel

> @@ -1002,8 +1004,9 @@ static void __remove_hrtimer(struct hrti
>  static inline int
>  remove_hrtimer(struct hrtimer *timer, struct hrtimer_clock_base *base, bool restart)
>  {
> -	if (hrtimer_is_queued(timer)) {
> -		u8 state = timer->state;
> +	u8 state = timer->state;
> +
> +	if (state & HRTIMER_STATE_ENQUEUED) {
>  		int reprogram;
>  
>  		/*
> 

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

Attachment: signature.asc
Description: Digital signature


[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux