linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, stable@kernel.org,
	syzbot+13146364637c7363a7de@syzkaller.appspotmail.com,
	Theodore Tso <tytso@mit.edu>
Subject: [PATCH 5.14 01/14] ext4: fix race writing to an inline_data file while its xattrs are changing
Date: Mon,  6 Sep 2021 14:55:47 +0200	[thread overview]
Message-ID: <20210906125448.209079113@linuxfoundation.org> (raw)
In-Reply-To: <20210906125448.160263393@linuxfoundation.org>

From: Theodore Ts'o <tytso@mit.edu>

commit a54c4613dac1500b40e4ab55199f7c51f028e848 upstream.

The location of the system.data extended attribute can change whenever
xattr_sem is not taken.  So we need to recalculate the i_inline_off
field since it mgiht have changed between ext4_write_begin() and
ext4_write_end().

This means that caching i_inline_off is probably not helpful, so in
the long run we should probably get rid of it and shrink the in-memory
ext4 inode slightly, but let's fix the race the simple way for now.

Cc: stable@kernel.org
Fixes: f19d5870cbf72 ("ext4: add normal write support for inline data")
Reported-by: syzbot+13146364637c7363a7de@syzkaller.appspotmail.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/ext4/inline.c |    6 ++++++
 1 file changed, 6 insertions(+)

--- a/fs/ext4/inline.c
+++ b/fs/ext4/inline.c
@@ -750,6 +750,12 @@ int ext4_write_inline_data_end(struct in
 	ext4_write_lock_xattr(inode, &no_expand);
 	BUG_ON(!ext4_has_inline_data(inode));
 
+	/*
+	 * ei->i_inline_off may have changed since ext4_write_begin()
+	 * called ext4_try_to_write_inline_data()
+	 */
+	(void) ext4_find_inline_data_nolock(inode);
+
 	kaddr = kmap_atomic(page);
 	ext4_write_inline_data(inode, &iloc, kaddr, pos, len);
 	kunmap_atomic(kaddr);



  reply	other threads:[~2021-09-06 13:00 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-06 12:55 [PATCH 5.14 00/14] 5.14.2-rc1 review Greg Kroah-Hartman
2021-09-06 12:55 ` Greg Kroah-Hartman [this message]
2021-09-06 12:55 ` [PATCH 5.14 02/14] ext4: fix e2fsprogs checksum failure for mounted filesystem Greg Kroah-Hartman
2021-09-06 12:55 ` [PATCH 5.14 03/14] xtensa: fix kconfig unmet dependency warning for HAVE_FUTEX_CMPXCHG Greg Kroah-Hartman
2021-09-06 12:55 ` [PATCH 5.14 04/14] USB: serial: pl2303: fix GL type detection Greg Kroah-Hartman
2021-09-06 12:55 ` [PATCH 5.14 05/14] USB: serial: cp210x: fix control-characters error handling Greg Kroah-Hartman
2021-09-06 12:55 ` [PATCH 5.14 06/14] USB: serial: cp210x: fix flow-control " Greg Kroah-Hartman
2021-09-06 12:55 ` [PATCH 5.14 07/14] HID: usbhid: Fix flood of "control queue full" messages Greg Kroah-Hartman
2021-09-06 12:55 ` [PATCH 5.14 08/14] HID: usbhid: Fix warning caused by 0-length input reports Greg Kroah-Hartman
2021-09-06 12:55 ` [PATCH 5.14 09/14] ALSA: hda/realtek: Quirk for HP Spectre x360 14 amp setup Greg Kroah-Hartman
2021-09-06 12:55 ` [PATCH 5.14 10/14] ALSA: usb-audio: Fix regression on Sony WALKMAN NW-A45 DAC Greg Kroah-Hartman
2021-09-06 12:55 ` [PATCH 5.14 11/14] ALSA: hda/realtek: Workaround for conflicting SSID on ASUS ROG Strix G17 Greg Kroah-Hartman
2021-09-06 12:55 ` [PATCH 5.14 12/14] ALSA: pcm: fix divide error in snd_pcm_lib_ioctl Greg Kroah-Hartman
2021-09-06 12:55 ` [PATCH 5.14 13/14] ALSA: usb-audio: Work around for XRUN with low latency playback Greg Kroah-Hartman
2021-09-06 12:56 ` [PATCH 5.14 14/14] media: stkwebcam: fix memory leak in stk_camera_probe Greg Kroah-Hartman
2021-09-06 15:49 ` [PATCH 5.14 00/14] 5.14.2-rc1 review Fox Chen
2021-09-07  6:21 ` Naresh Kamboju
2021-09-07 16:30 ` Florian Fainelli
2021-09-07 20:06 ` Shuah Khan
2021-09-07 23:06 ` Justin Forbes
2021-09-08  1:20 ` Guenter Roeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210906125448.209079113@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=syzbot+13146364637c7363a7de@syzkaller.appspotmail.com \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).