linux/fs/hfsplus
Simon Gander 3151839ff4 hfsplus: fix crash and filesystem corruption when deleting files
commit 25efb2ffdf upstream.

When removing files containing extended attributes, the hfsplus driver may
remove the wrong entries from the attributes b-tree, causing major
filesystem damage and in some cases even kernel crashes.

To remove a file, all its extended attributes have to be removed as well.
The driver does this by looking up all keys in the attributes b-tree with
the cnid of the file.  Each of these entries then gets deleted using the
key used for searching, which doesn't contain the attribute's name when it
should.  Since the key doesn't contain the name, the deletion routine will
not find the correct entry and instead remove the one in front of it.  If
parent nodes have to be modified, these become corrupt as well.  This
causes invalid links and unsorted entries that not even macOS's fsck_hfs
is able to fix.

To fix this, modify the search key before an entry is deleted from the
attributes b-tree by copying the found entry's key into the search key,
therefore ensuring that the correct entry gets removed from the tree.

Signed-off-by: Simon Gander <simon@tuxera.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Anton Altaparmakov <anton@tuxera.com>
Cc: <stable@vger.kernel.org>
Link: http://lkml.kernel.org/r/20200327155541.1521-1-simon@tuxera.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-04-17 10:48:52 +02:00
..
attributes.c hfsplus: fix crash and filesystem corruption when deleting files 2020-04-17 10:48:52 +02:00
bfind.c
bitmap.c
bnode.c hfs/hfsplus: clean up unused variables in bnode.c 2017-11-17 16:10:03 -08:00
brec.c hfsplus: fix BUG on bnode parent update 2019-12-01 09:17:08 +01:00
btree.c hfsplus: prevent btree data loss on ENOSPC 2019-12-01 09:17:08 +01:00
catalog.c hfsplus: prevent btree data loss on ENOSPC 2019-12-01 09:17:08 +01:00
dir.c hfsplus: fix NULL dereference in hfsplus_lookup() 2018-08-23 18:48:42 -07:00
extents.c hfsplus: fix return value of hfsplus_get_block() 2019-12-01 09:17:09 +01:00
hfsplus_fs.h hfsplus: prevent btree data loss on ENOSPC 2019-12-01 09:17:08 +01:00
hfsplus_raw.h
inode.c hfsplus: update timestamps on truncate() 2019-12-01 09:17:09 +01:00
ioctl.c
Kconfig hfsplus: drop ACL support 2018-08-22 10:52:50 -07:00
Makefile hfsplus: drop ACL support 2018-08-22 10:52:50 -07:00
options.c
part_tbl.c
super.c hfsplus: drop ACL support 2018-08-22 10:52:50 -07:00
tables.c
unicode.c hfsplus: fix decomposition of Hangul characters 2018-08-22 10:52:50 -07:00
wrapper.c
xattr_security.c hfsplus: drop ACL support 2018-08-22 10:52:50 -07:00
xattr_trusted.c
xattr_user.c
xattr.c hfsplus: drop ACL support 2018-08-22 10:52:50 -07:00
xattr.h hfsplus: drop ACL support 2018-08-22 10:52:50 -07:00