]> git.baikalelectronics.ru Git - kernel.git/commit
xfs: fix potential log item leak
authorDave Chinner <dchinner@redhat.com>
Wed, 4 May 2022 01:45:11 +0000 (11:45 +1000)
committerDave Chinner <david@fromorbit.com>
Wed, 4 May 2022 01:45:11 +0000 (11:45 +1000)
commit1f5ca82fe7f2f72c6ada4f6a69a823c7a0060f31
treea4af7219fbf72c0350d6c08eea91825c20cfde9e
parent1cb3f387222e14c96cb6e8576f35a6e602372efd
xfs: fix potential log item leak

Ever since we added shadown format buffers to the log items, log
items need to handle the item being released with shadow buffers
attached. Due to the fact this requirement was added at the same
time we added new rmap/reflink intents, we missed the cleanup of
those items.

In theory, this means shadow buffers can be leaked in a very small
window when a shutdown is initiated. Testing with KASAN shows this
leak does not happen in practice - we haven't identified a single
leak in several years of shutdown testing since ~v4.8 kernels.

However, the intent whiteout cleanup mechanism results in every
cancelled intent in exactly the same state as this tiny race window
creates and so if intents down clean up shadow buffers on final
release we will leak the shadow buffer for just about every intent
we create.

Hence we start with this patch to close this condition off and
ensure that when whiteouts start to be used we don't leak lots of
memory.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
fs/xfs/xfs_bmap_item.c
fs/xfs/xfs_icreate_item.c
fs/xfs/xfs_refcount_item.c
fs/xfs/xfs_rmap_item.c