linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* BUG? misused atomic instructions in mm/swapfile.c
@ 2009-09-03  5:55 홍신 shin hong
  2009-09-03  6:14 ` Minchan Kim
  2009-09-03 11:51 ` Hugh Dickins
  0 siblings, 2 replies; 3+ messages in thread
From: 홍신 shin hong @ 2009-09-03  5:55 UTC (permalink / raw)
  To: linux-mm

Hello. I am reporting atomic instructions usages
which are suspected to be misused in mm/swapfile.c
of Linux 2.6.30.5.

I do not have much background on mm
so that I am not certain whether it is correct or not.
But I hope this report is helpful. Please examine the code.

In try_to_use(), setup_swap_extents(), and SYSCALL_DEFINE2(),
there are following codes:

    if (atomic_read(&start_mm->mm_users) == 1) {
        mmput(start_mm) ;
        start_mm = &init_mm ;
        atomic_inc(&init_mm.mm_users) ;
    }

It first checks start_mm->mm_users and then increments its value by one.

If one of these functions is executed in two different threads
for the same start_mm concurrently,
mmput(start_mm) can be executed twice as result of race.

I think it would be better to combine two atomic operations
into one atomic operation (e.g. atomic_cmpxchg).

Thank you.

Sincerely
Shin Hong

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2009-09-03 11:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-03  5:55 BUG? misused atomic instructions in mm/swapfile.c 홍신 shin hong
2009-09-03  6:14 ` Minchan Kim
2009-09-03 11:51 ` Hugh Dickins

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox