]> git.hungrycats.org Git - linux/commit
[PATCH] Fix nobh_prepare_write() race
authorAndrew Morton <akpm@osdl.org>
Sat, 6 Mar 2004 16:51:13 +0000 (08:51 -0800)
committerJaroslav Kysela <perex@suse.cz>
Sat, 6 Mar 2004 16:51:13 +0000 (08:51 -0800)
commitb12088bf8bc61c1871fb42c70a99886d8ba659d8
treedaa688bb278d54031ab06191fafd9f8358a4b2fd
parentd67c0fd5d3fb182288cb29bbba6913eedd9a7dc6
[PATCH] Fix nobh_prepare_write() race

Dave Kleikamp <shaggy@austin.ibm.com> points out a race between
nobh_prepare_write() and end_buffer_read_sync().  end_buffer_read_sync()
calls unlock_buffer(), waking the nobh_prepare_write() thread, which
immediately frees the buffer_head.  end_buffer_read_sync() then calls
put_bh() which decrements b_count for the already freed structure.  The
SLAB_DEBUG code detects the slab corruption.

We fix this by giving nobh_prepare_write() a private buffer_head end_o
handler which doesn't touch the buffer's contents after unlocking it.
fs/buffer.c