ocfs2-devel.oss.oracle.com archive mirror
 help / color / mirror / Atom feed
* [Ocfs2-devel] BUG? a racy code at o2hb_heartbeat_group_drop_item()
@ 2010-08-17 12:51 홍신 shin hong
  2010-08-17 17:31 ` Sunil Mushran
  0 siblings, 1 reply; 2+ messages in thread
From: 홍신 shin hong @ 2010-08-17 12:51 UTC (permalink / raw)
  To: ocfs2-devel

Hello. I am reporting an atomic instructions usage
which seem be racy at fs/ocfs2/cluster/heartbeat.c in Linux 2.6.35.

I am reporting this issue while I read the recent code.
Since I do not have much background, I am not certain whether it is
correct or not.
But I hope this report is helpful. Please examine the code.

In o2hb_heartbeat_group_drop_item(),  there are following codes:

1626        if (atomic_read(&reg->hr_steady_iterations) != 0) {
1627                atomic_set(&reg->hr_steady_iterations, 0);


It first checks &reg->hr_steady_iterations and then updates its value.

In the case where other threads manipulate the same
&reg->hr_steady_iterations concurrently,
race condition might be possible.

I think it would be better to guarantee consecutive executions of
read and write by special purposed atomic operations (e.g. atomic_xchg)

Please examine the issue and let me know your opinion. Thank you.

Sincerely
Shin Hong

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

* [Ocfs2-devel] BUG? a racy code at o2hb_heartbeat_group_drop_item()
  2010-08-17 12:51 [Ocfs2-devel] BUG? a racy code at o2hb_heartbeat_group_drop_item() 홍신 shin hong
@ 2010-08-17 17:31 ` Sunil Mushran
  0 siblings, 0 replies; 2+ messages in thread
From: Sunil Mushran @ 2010-08-17 17:31 UTC (permalink / raw)
  To: ocfs2-devel

On 08/17/2010 05:51 AM, ?? shin hong wrote:
> Hello. I am reporting an atomic instructions usage
> which seem be racy at fs/ocfs2/cluster/heartbeat.c in Linux 2.6.35.
>
> I am reporting this issue while I read the recent code.
> Since I do not have much background, I am not certain whether it is
> correct or not.
> But I hope this report is helpful. Please examine the code.
>
> In o2hb_heartbeat_group_drop_item(),  there are following codes:
>
> 1626        if (atomic_read(&reg->hr_steady_iterations) != 0) {
> 1627                atomic_set(&reg->hr_steady_iterations, 0);
>
>
> It first checks&reg->hr_steady_iterations and then updates its value.
>
> In the case where other threads manipulate the same
> &reg->hr_steady_iterations concurrently,
> race condition might be possible.
>
> I think it would be better to guarantee consecutive executions of
> read and write by special purposed atomic operations (e.g. atomic_xchg)
>
> Please examine the issue and let me know your opinion. Thank you.
>    

This should be safe. The only thread that could be decrementing
hr_steady_iterations is stopped before this check.

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

end of thread, other threads:[~2010-08-17 17:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-17 12:51 [Ocfs2-devel] BUG? a racy code at o2hb_heartbeat_group_drop_item() 홍신 shin hong
2010-08-17 17:31 ` Sunil Mushran

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).