Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1377329
| From | Kamal Mostafa <kamal@canonical.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 4.2.y-ckt 18/70] btrfs: fix crash/invalid memory access on fsync when using overlayfs |
| Date | 2016-04-12 23:40 +0200 |
| Message-ID | <rnecs-5Ws-53@gated-at.bofh.it> (permalink) |
| References | <rndzH-5be-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
4.2.8-ckt8 -stable review patch. If anyone has any objections, please let me know.
---8<------------------------------------------------------------
From: Filipe Manana <fdmanana@suse.com>
commit de17e793b104d690e1d007dfc5cb6b4f649598ca upstream.
If the lower or upper directory of an overlayfs mount belong to a btrfs
file system and we fsync the file through the overlayfs' merged directory
we ended up accessing an inode that didn't belong to btrfs as if it were
a btrfs inode at btrfs_sync_file() resulting in a crash like the following:
[ 7782.588845] BUG: unable to handle kernel NULL pointer dereference at 0000000000000544
[ 7782.590624] IP: [<ffffffffa030b7ab>] btrfs_sync_file+0x11b/0x3e9 [btrfs]
[ 7782.591931] PGD 4d954067 PUD 1e878067 PMD 0
[ 7782.592016] Oops: 0002 [#6] PREEMPT SMP DEBUG_PAGEALLOC
[ 7782.592016] Modules linked in: btrfs overlay ppdev crc32c_generic evdev xor raid6_pq psmouse pcspkr sg serio_raw acpi_cpufreq parport_pc parport tpm_tis i2c_piix4 tpm i2c_core processor button loop autofs4 ext4 crc16 mbcache jbd2 sr_mod cdrom sd_mod ata_generic virtio_scsi ata_piix virtio_pci libata virtio_ring virtio scsi_mod e1000 floppy [last unloaded: btrfs]
[ 7782.592016] CPU: 10 PID: 16437 Comm: xfs_io Tainted: G D 4.5.0-rc6-btrfs-next-26+ #1
[ 7782.592016] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS by qemu-project.org 04/01/2014
[ 7782.592016] task: ffff88001b8d40c0 ti: ffff880137488000 task.ti: ffff880137488000
[ 7782.592016] RIP: 0010:[<ffffffffa030b7ab>] [<ffffffffa030b7ab>] btrfs_sync_file+0x11b/0x3e9 [btrfs]
[ 7782.592016] RSP: 0018:ffff88013748be40 EFLAGS: 00010286
[ 7782.592016] RAX: 0000000080000000 RBX: ffff880133b30c88 RCX: 0000000000000001
[ 7782.592016] RDX: 0000000000000001 RSI: ffffffff8148fec0 RDI: 00000000ffffffff
[ 7782.592016] RBP: ffff88013748bec0 R08: 0000000000000001 R09: 0000000000000000
[ 7782.624248] R10: ffff88013748be40 R11: 0000000000000246 R12: 0000000000000000
[ 7782.624248] R13: 0000000000000000 R14: 00000000009305a0 R15: ffff880015e3be40
[ 7782.624248] FS: 00007fa83b9cb700(0000) GS:ffff88023ed40000(0000) knlGS:0000000000000000
[ 7782.624248] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 7782.624248] CR2: 0000000000000544 CR3: 00000001fa652000 CR4: 00000000000006e0
[ 7782.624248] Stack:
[ 7782.624248] ffffffff8108b5cc ffff88013748bec0 0000000000000246 ffff8800b005ded0
[ 7782.624248] ffff880133b30d60 8000000000000000 7fffffffffffffff 0000000000000246
[ 7782.624248] 0000000000000246 ffffffff81074f9b ffffffff8104357c ffff880015e3be40
[ 7782.624248] Call Trace:
[ 7782.624248] [<ffffffff8108b5cc>] ? arch_local_irq_save+0x9/0xc
[ 7782.624248] [<ffffffff81074f9b>] ? ___might_sleep+0xce/0x217
[ 7782.624248] [<ffffffff8104357c>] ? __do_page_fault+0x3c0/0x43a
[ 7782.624248] [<ffffffff811a2351>] vfs_fsync_range+0x8c/0x9e
[ 7782.624248] [<ffffffff811a237f>] vfs_fsync+0x1c/0x1e
[ 7782.624248] [<ffffffff811a24d6>] do_fsync+0x31/0x4a
[ 7782.624248] [<ffffffff811a2700>] SyS_fsync+0x10/0x14
[ 7782.624248] [<ffffffff81493617>] entry_SYSCALL_64_fastpath+0x12/0x6b
[ 7782.624248] Code: 85 c0 0f 85 e2 02 00 00 48 8b 45 b0 31 f6 4c 29 e8 48 ff c0 48 89 45 a8 48 8d 83 d8 00 00 00 48 89 c7 48 89 45 a0 e8 fc 43 18 e1 <f0> 41 ff 84 24 44 05 00 00 48 8b 83 58 ff ff ff 48 c1 e8 07 83
[ 7782.624248] RIP [<ffffffffa030b7ab>] btrfs_sync_file+0x11b/0x3e9 [btrfs]
[ 7782.624248] RSP <ffff88013748be40>
[ 7782.624248] CR2: 0000000000000544
[ 7782.661994] ---[ end trace 721e14960eb939bc ]---
This started happening since commit 4bacc9c9234 (overlayfs: Make f_path
always point to the overlay and f_inode to the underlay) and even though
after this change we could still access the btrfs inode through
struct file->f_mapping->host or struct file->f_inode, we would end up
resulting in more similar issues later on at check_parent_dirs_for_sync()
because the dentry we got (from struct file->f_path.dentry) was from
overlayfs and not from btrfs, that is, we had no way of getting the dentry
that belonged to btrfs (we always got the dentry that belonged to
overlayfs).
The new patch from Miklos Szeredi, titled "vfs: add file_dentry()" and
recently submitted to linux-fsdevel, adds a file_dentry() API that allows
us to get the btrfs dentry from the input file and therefore being able
to fsync when the upper and lower directories belong to btrfs filesystems.
This issue has been reported several times by users in the mailing list
and bugzilla. A test case for xfstests is being submitted as well.
Fixes: 4bacc9c9234c ("overlayfs: Make f_path always point to the overlay and f_inode to the underlay")
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=101951
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=109791
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Chris Mason <clm@fb.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
fs/btrfs/file.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 5e31485..dfb6609 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1869,7 +1869,7 @@ static int start_ordered_ops(struct inode *inode, loff_t start, loff_t end)
*/
int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
{
- struct dentry *dentry = file->f_path.dentry;
+ struct dentry *dentry = file_dentry(file);
struct inode *inode = d_inode(dentry);
struct btrfs_root *root = BTRFS_I(inode)->root;
struct btrfs_trans_handle *trans;
--
2.7.4
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[4.2.y-ckt stable] Linux 4.2.8-ckt8 stable review Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:00 +0200 [PATCH 4.2.y-ckt 69/70] mwifiex: fix corner case association failure Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:00 +0200 [PATCH 4.2.y-ckt 35/70] ext4: ignore quota mount options if the quota feature is enabled Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:00 +0200 [PATCH 4.2.y-ckt 64/70] lib/ucs2_string: Correct ucs2 -> utf8 conversion Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:00 +0200 [PATCH 4.2.y-ckt 63/70] efi: Add pstore variables to the deletion whitelist Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:00 +0200 [PATCH 4.2.y-ckt 65/70] ipr: Fix out-of-bounds null overwrite Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:00 +0200 [PATCH 4.2.y-ckt 22/70] USB: cypress_m8: add endpoint sanity check Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:00 +0200 [PATCH 4.2.y-ckt 62/70] efi: Make efivarfs entries immutable by default Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:00 +0200 [PATCH 4.2.y-ckt 61/70] efi: Make our variable validation list include the guid Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:00 +0200 [PATCH 4.2.y-ckt 09/70] hwmon: (max1111) Return -ENODEV from max1111_read_channel if not instantiated Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:00 +0200 [PATCH 4.2.y-ckt 70/70] net: phy: at803x: Request 'reset' GPIO only for AT8030 PHY Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:00 +0200 [PATCH 4.2.y-ckt 42/70] USB: serial: ftdi_sio: Add support for ICP DAS I-756xU devices Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:30 +0200 [PATCH 4.2.y-ckt 49/70] parisc: Fix kernel crash with reversed copy_from_user() Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:30 +0200 [PATCH 4.2.y-ckt 55/70] pinctrl: nomadik: fix pull debug print inversion Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:30 +0200 [PATCH 4.2.y-ckt 38/70] mac80211: properly deal with station hashtable insert errors Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:30 +0200 [PATCH 4.2.y-ckt 39/70] compiler-gcc: disable -ftracer for __noclone functions Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:30 +0200 [PATCH 4.2.y-ckt 47/70] gpio: pca953x: Use correct u16 value for register word write Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:30 +0200 [PATCH 4.2.y-ckt 36/70] xen/events: Mask a moving irq Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:30 +0200 [PATCH 4.2.y-ckt 43/70] USB: serial: cp210x: Adding GE Healthcare Device ID Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:30 +0200 [PATCH 4.2.y-ckt 41/70] Btrfs: fix file/data loss caused by fsync after rename and new inode Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:30 +0200 [PATCH 4.2.y-ckt 33/70] mm: fix invalid node in alloc_migrate_target() Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:30 +0200 [PATCH 4.2.y-ckt 57/70] KVM: x86: move steal time initialization to vcpu entry time Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:30 +0200 [PATCH 4.2.y-ckt 37/70] usb: renesas_usbhs: fix to avoid using a disabled ep in usbhsg_queue_done() Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:30 +0200 [PATCH 4.2.y-ckt 40/70] rbd: use GFP_NOIO consistently for request allocations Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:30 +0200 [PATCH 4.2.y-ckt 50/70] parisc: Unbreak handling exceptions from kernel modules Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:30 +0200 [PATCH 4.2.y-ckt 52/70] net: bcmgenet: fix dev->stats.tx_bytes accounting Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:30 +0200 [PATCH 4.2.y-ckt 31/70] KVM: x86: Inject pending interrupt even if pending nmi exist Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:30 +0200 [PATCH 4.2.y-ckt 34/70] iio: st_magn: always define ST_MAGN_TRIGGER_SET_STATE Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:30 +0200 [PATCH 4.2.y-ckt 48/70] parisc: Avoid function pointers for kernel exception routines Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:30 +0200 [PATCH 4.2.y-ckt 56/70] ip6_tunnel: set rtnl_link_ops before calling register_netdevice Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:30 +0200 [PATCH 4.2.y-ckt 45/70] virtio: virtio 1.0 cs04 spec compliance for reset Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:30 +0200 [PATCH 4.2.y-ckt 54/70] ipv6: udp: fix UDP_MIB_IGNOREDMULTI updates Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:30 +0200 [PATCH 4.2.y-ckt 44/70] USB: option: add "D-Link DWM-221 B1" device id Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:30 +0200 [PATCH 4.2.y-ckt 30/70] ALSA: hda - fix front mic problem for a HP desktop Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:40 +0200 [PATCH 4.2.y-ckt 27/70] drm/dp: move hw_mutex up the call stack Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:40 +0200 [PATCH 4.2.y-ckt 08/70] nfs: use file_dentry() Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:40 +0200 [PATCH 4.2.y-ckt 24/70] [media] au0828: fix au0828_v4l2_close() dev_state race condition Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:40 +0200 [PATCH 4.2.y-ckt 02/70] PKCS#7: pkcs7_validate_trust(): initialize the _trusted output argument Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:40 +0200 [PATCH 4.2.y-ckt 16/70] usb: renesas_usbhs: avoid NULL pointer derefernce in usbhsf_pkt_handler() Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:40 +0200 [PATCH 4.2.y-ckt 10/70] drm/radeon: add another R7 370 quirk Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:40 +0200 [PATCH 4.2.y-ckt 20/70] ALSA: usb-audio: Fix double-free in error paths after snd_usb_add_audio_stream() call Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:40 +0200 [PATCH 4.2.y-ckt 05/70] ALSA: hda - Apply fix for white noise on Asus N550JV, too Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:40 +0200 [PATCH 4.2.y-ckt 26/70] sd: Fix excessive capacity printing on devices with blocks bigger than 512 bytes Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:40 +0200 [PATCH 4.2.y-ckt 23/70] USB: digi_acceleport: do sanity checking for the number of ports Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:40 +0200 [PATCH 4.2.y-ckt 32/70] ALSA: timer: Use mod_timer() for rearming the system timer Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:40 +0200 [PATCH 4.2.y-ckt 14/70] pinctrl: pistachio: fix mfio84-89 function description and pinmux. Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:40 +0200 [PATCH 4.2.y-ckt 15/70] pinctrl: sunxi: Fix A33 external interrupts not working Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:40 +0200 [PATCH 4.2.y-ckt 28/70] drm/udl: Use unlocked gem unreferencing Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:40 +0200 [PATCH 4.2.y-ckt 03/70] ALSA: hda - Asus N750JV external subwoofer fixup Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:40 +0200 [PATCH 4.2.y-ckt 12/70] powerpc/mm: Fixup preempt underflow with huge pages Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:40 +0200 [PATCH 4.2.y-ckt 04/70] ALSA: hda - Fix white noise on Asus N750JV headphone Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:40 +0200 [PATCH 4.2.y-ckt 18/70] btrfs: fix crash/invalid memory access on fsync when using overlayfs Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:40 +0200 [PATCH 4.2.y-ckt 29/70] ext4: add lockdep annotations for i_data_sem Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:40 +0200 [PATCH 4.2.y-ckt 11/70] drm/radeon: add a dpm quirk for all R7 370 parts Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:40 +0200 [PATCH 4.2.y-ckt 13/70] pinctrl: sh-pfc: only use dummy states for non-DT platforms Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:40 +0200 [PATCH 4.2.y-ckt 17/70] usb: renesas_usbhs: disable TX IRQ before starting TX DMAC transfer Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:40 +0200 [PATCH 4.2.y-ckt 21/70] USB: mct_u232: add sanity checking in probe Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:40 +0200 [PATCH 4.2.y-ckt 25/70] [media] au0828: Fix dev_state handling Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:40 +0200 [PATCH 4.2.y-ckt 07/70] fs: add file_dentry() Kamal Mostafa <kamal@canonical.com> - 2016-04-12 23:40 +0200
csiph-web