Re: [PATCH] sigqueue_free: fix the race with collect_signal()

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Oleg Nesterov
Date: Friday, August 24, 2007 - 1:23 pm

On 08/24, Sukadev Bhattiprolu wrote:

Yes. They both will call __sigqueue_free(). But please note that __sigqueue_free()
checks SIGQUEUE_PREALLOC, which is cleared by sigqueue_free().

IOW, when sigqueue_free() unlocks ->siglock, we know that it can't be used
by collect_signal() from another thread. So we can clear SIGQUEUE_PREALLOC
and free sigqueue. We don't need this lock around sigqueue_free() to prevent
the race. collect_signal() can "see" only those sigqueues which are on list.

IOW, when sigqueue_free() takes ->siglock, colect_signal() can't run, because
it needs the same lock. Now we delete this sigqueue from list, nobody can
see it, it can't have other references. So we can unlock ->siglock, mark
sigqueue as freeable (clear SIGQUEUE_PREALLOC), and free it.

Do you agree?

Oleg.

-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [PATCH] sigqueue_free: fix the race with collect_signal(), Sukadev Bhattiprolu, (Fri Aug 24, 1:03 pm)
Re: [PATCH] sigqueue_free: fix the race with collect_signal(), Oleg Nesterov, (Fri Aug 24, 1:23 pm)
Re: [PATCH] sigqueue_free: fix the race with collect_signal(), Sukadev Bhattiprolu, (Sat Aug 25, 10:24 am)