Find a file
Darrick J. Wong 4183e4f27f xfs: share xattr name and value buffers when logging xattr updates
While running xfs/297 and generic/642, I noticed a crash in
xfs_attri_item_relog when it tries to copy the attr name to the new
xattri log item.  I think what happened here was that we called
->iop_commit on the old attri item (which nulls out the pointers) as
part of a log force at the same time that a chained attr operation was
ongoing.  The system was busy enough that at some later point, the defer
ops operation decided it was necessary to relog the attri log item, but
as we've detached the name buffer from the old attri log item, we can't
copy it to the new one, and kaboom.

I think there's a broader refcounting problem with LARP mode -- the
setxattr code can return to userspace before the CIL actually formats
and commits the log item, which results in a UAF bug.  Therefore, the
xattr log item needs to be able to retain a reference to the name and
value buffers until the log items have completely cleared the log.
Furthermore, each time we create an intent log item, we allocate new
memory and (re)copy the contents; sharing here would be very useful.

Solve the UAF and the unnecessary memory allocations by having the log
code create a single refcounted buffer to contain the name and value
contents.  This buffer can be passed from old to new during a relog
operation, and the logging code can (optionally) attach it to the
xfs_attr_item for reuse when LARP mode is enabled.

This also fixes a problem where the xfs_attri_log_item objects weren't
being freed back to the same cache where they came from.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2022-05-23 08:43:46 +10:00
arch Driver core changes for 5.18-rc2 2022-04-10 09:55:09 -10:00
block
certs
crypto
Documentation linux-kselftest-kunit-fixes-5.18-rc2 2022-04-08 15:06:11 -10:00
drivers Serial driver fix for 5.18-rc2 2022-04-10 10:08:50 -10:00
fs xfs: share xattr name and value buffers when logging xattr updates 2022-05-23 08:43:46 +10:00
include Driver core changes for 5.18-rc2 2022-04-10 09:55:09 -10:00
init
ipc
kernel - A couple of fixes to cgroup-related handling of perf events 2022-04-10 07:08:22 -10:00
lib Driver core changes for 5.18-rc2 2022-04-10 09:55:09 -10:00
LICENSES
mm - Allow the compiler to optimize away unused percpu accesses and change 2022-04-10 06:56:46 -10:00
net NFS client bugfixes for Linux 5.18 2022-04-08 07:39:17 -10:00
samples
scripts
security
sound
tools - Fix the MSI message data struct definition 2022-04-10 07:12:27 -10:00
usr
virt
.clang-format
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap mailmap: update Vasily Averin's email address 2022-04-08 14:20:36 -10:00
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS MAINTAINERS: update IOMAP FILESYSTEM LIBRARY and XFS FILESYSTEM 2022-04-21 08:45:14 +10:00
Makefile Linux 5.18-rc2 2022-04-10 14:21:36 -10:00
README

Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the Restructured Text markup notation.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.