mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@kernel.org
Cc: stable-review@kernel.org, torvalds@linux-foundation.org,
	akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk,
	Dave Hansen <dave@linux.vnet.ibm.com>,
	Rik van Riel <riel@redhat.com>, <arunabal@in.ibm.com>,
	<sbest@us.ibm.com>, Christoph Hellwig <hch@lst.de>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Minchan Kim <minchan.kim@gmail.com>
Subject: [056/127] mm/vfs: revalidate page->mapping in do_generic_file_read()
Date: Tue, 07 Dec 2010 16:44:02 -0800	[thread overview]
Message-ID: <20101208004429.911496603@clark.site> (raw)
In-Reply-To: <20101208004456.GA23578@kroah.com>

2.6.32-stable review patch.  If anyone has any objections, please let us know.

------------------

From: Dave Hansen <dave@linux.vnet.ibm.com>

commit 8d056cb965b8fb7c53c564abf28b1962d1061cd3 upstream.

70 hours into some stress tests of a 2.6.32-based enterprise kernel, we
ran into a NULL dereference in here:

	int block_is_partially_uptodate(struct page *page, read_descriptor_t *desc,
	                                        unsigned long from)
	{
---->		struct inode *inode = page->mapping->host;

It looks like page->mapping was the culprit.  (xmon trace is below).
After closer examination, I realized that do_generic_file_read() does a
find_get_page(), and eventually locks the page before calling
block_is_partially_uptodate().  However, it doesn't revalidate the
page->mapping after the page is locked.  So, there's a small window
between the find_get_page() and ->is_partially_uptodate() where the page
could get truncated and page->mapping cleared.

We _have_ a reference, so it can't get reclaimed, but it certainly
can be truncated.

I think the correct thing is to check page->mapping after the
trylock_page(), and jump out if it got truncated.  This patch has been
running in the test environment for a month or so now, and we have not
seen this bug pop up again.

xmon info:

  1f:mon> e
  cpu 0x1f: Vector: 300 (Data Access) at [c0000002ae36f770]
      pc: c0000000001e7a6c: .block_is_partially_uptodate+0xc/0x100
      lr: c000000000142944: .generic_file_aio_read+0x1e4/0x770
      sp: c0000002ae36f9f0
     msr: 8000000000009032
     dar: 0
   dsisr: 40000000
    current = 0xc000000378f99e30
    paca    = 0xc000000000f66300
      pid   = 21946, comm = bash
  1f:mon> r
  R00 = 0025c0500000006d   R16 = 0000000000000000
  R01 = c0000002ae36f9f0   R17 = c000000362cd3af0
  R02 = c000000000e8cd80   R18 = ffffffffffffffff
  R03 = c0000000031d0f88   R19 = 0000000000000001
  R04 = c0000002ae36fa68   R20 = c0000003bb97b8a0
  R05 = 0000000000000000   R21 = c0000002ae36fa68
  R06 = 0000000000000000   R22 = 0000000000000000
  R07 = 0000000000000001   R23 = c0000002ae36fbb0
  R08 = 0000000000000002   R24 = 0000000000000000
  R09 = 0000000000000000   R25 = c000000362cd3a80
  R10 = 0000000000000000   R26 = 0000000000000002
  R11 = c0000000001e7b60   R27 = 0000000000000000
  R12 = 0000000042000484   R28 = 0000000000000001
  R13 = c000000000f66300   R29 = c0000003bb97b9b8
  R14 = 0000000000000001   R30 = c000000000e28a08
  R15 = 000000000000ffff   R31 = c0000000031d0f88
  pc  = c0000000001e7a6c .block_is_partially_uptodate+0xc/0x100
  lr  = c000000000142944 .generic_file_aio_read+0x1e4/0x770
  msr = 8000000000009032   cr  = 22000488
  ctr = c0000000001e7a60   xer = 0000000020000000   trap =  300
  dar = 0000000000000000   dsisr = 40000000
  1f:mon> t
  [link register   ] c000000000142944 .generic_file_aio_read+0x1e4/0x770
  [c0000002ae36f9f0] c000000000142a14 .generic_file_aio_read+0x2b4/0x770 (unreliable)
  [c0000002ae36fb40] c0000000001b03e4 .do_sync_read+0xd4/0x160
  [c0000002ae36fce0] c0000000001b153c .vfs_read+0xec/0x1f0
  [c0000002ae36fd80] c0000000001b1768 .SyS_read+0x58/0xb0
  [c0000002ae36fe30] c00000000000852c syscall_exit+0x0/0x40
  --- Exception: c00 (System Call) at 00000080a840bc54
  SP (fffca15df30) is in userspace
  1f:mon> di c0000000001e7a6c
  c0000000001e7a6c  e9290000      ld      r9,0(r9)
  c0000000001e7a70  418200c0      beq     c0000000001e7b30        # .block_is_partially_uptodate+0xd0/0x100
  c0000000001e7a74  e9440008      ld      r10,8(r4)
  c0000000001e7a78  78a80020      clrldi  r8,r5,32
  c0000000001e7a7c  3c000001      lis     r0,1
  c0000000001e7a80  812900a8      lwz     r9,168(r9)
  c0000000001e7a84  39600001      li      r11,1
  c0000000001e7a88  7c080050      subf    r0,r8,r0
  c0000000001e7a8c  7f805040      cmplw   cr7,r0,r10
  c0000000001e7a90  7d6b4830      slw     r11,r11,r9
  c0000000001e7a94  796b0020      clrldi  r11,r11,32
  c0000000001e7a98  419d00a8      bgt     cr7,c0000000001e7b40    # .block_is_partially_uptodate+0xe0/0x100
  c0000000001e7a9c  7fa55840      cmpld   cr7,r5,r11
  c0000000001e7aa0  7d004214      add     r8,r0,r8
  c0000000001e7aa4  79080020      clrldi  r8,r8,32
  c0000000001e7aa8  419c0078      blt     cr7,c0000000001e7b20    # .block_is_partially_uptodate+0xc0/0x100

Signed-off-by: Dave Hansen <dave@linux.vnet.ibm.com>
Reviewed-by: Minchan Kim <minchan.kim@gmail.com>
Reviewed-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Rik van Riel <riel@redhat.com>
Cc: <arunabal@in.ibm.com>
Cc: <sbest@us.ibm.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Minchan Kim <minchan.kim@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 mm/filemap.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1030,6 +1030,9 @@ find_page:
 				goto page_not_up_to_date;
 			if (!trylock_page(page))
 				goto page_not_up_to_date;
+			/* Did it get truncated before we got the lock? */
+			if (!page->mapping)
+				goto page_not_up_to_date_locked;
 			if (!mapping->a_ops->is_partially_uptodate(page,
 								desc, offset))
 				goto page_not_up_to_date_locked;



  parent reply	other threads:[~2010-12-08  2:09 UTC|newest]

Thread overview: 138+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-08  0:44 [000/127] 2.6.32.27-stable review Greg KH
2010-12-08  0:43 ` [001/127] block: Ensure physical block size is unsigned int Greg KH
2010-12-08  0:43 ` [002/127] block: limit vec count in bio_kmalloc() and bio_alloc_map_data() Greg KH
2010-12-08  0:43 ` [003/127] block: take care not to overflow when calculating total iov length Greg KH
2010-12-08  0:43 ` [004/127] block: check for proper length of iov entries in blk_rq_map_user_iov() Greg KH
2010-12-08  0:43 ` [005/127] jme: Fix PHY power-off error Greg KH
2010-12-08  0:43 ` [006/127] irda: Fix parameter extraction stack overflow Greg KH
2010-12-08  0:43 ` [007/127] irda: Fix heap memory corruption in iriap.c Greg KH
2010-12-08  0:43 ` [008/127] i2c-pca-platform: Change device name of request_irq Greg KH
2010-12-08  0:43 ` [009/127] microblaze: Fix build with make 3.82 Greg KH
2010-12-08  0:43 ` [010/127] net: clear heap allocation for ETHTOOL_GRXCLSRLALL Greg KH
2010-12-08  0:43 ` [011/127] Staging: asus_oled: fix up some sysfs attribute permissions Greg KH
2010-12-08  0:43 ` [012/127] Staging: asus_oled: fix up my fixup for " Greg KH
2010-12-08  0:43 ` [013/127] Staging: line6: fix up " Greg KH
2010-12-08  0:43 ` [014/127] hpet: fix unwanted interrupt due to stale irq status bit Greg KH
2010-12-08  0:43 ` [015/127] hpet: unmap unused I/O space Greg KH
2010-12-08  0:43 ` [016/127] olpc_battery: Fix endian neutral breakage for s16 values Greg KH
2010-12-08  0:43 ` [017/127] percpu: fix list_head init bug in __percpu_counter_init() Greg KH
2010-12-08  0:43 ` [018/127] um: remove PAGE_SIZE alignment in linker script causing kernel segfault Greg KH
2010-12-08  0:43 ` [019/127] um: fix global timer issue when using CONFIG_NO_HZ Greg KH
2010-12-08  0:43 ` [020/127] numa: fix slab_node(MPOL_BIND) Greg KH
2010-12-08  0:43 ` [021/127] hwmon: (lm85) Fix ADT7468 frequency table Greg KH
2010-12-08  0:43 ` [022/127] mm: fix return value of scan_lru_pages in memory unplug Greg KH
2010-12-08  0:43 ` [023/127] mm: fix is_mem_section_removable() page_order BUG_ON check Greg KH
2010-12-08  0:43 ` [024/127] ahci,ata_generic: let ata_generic handle new MBP w/ MCP89 Greg KH
2010-12-08  0:43 ` [025/127] ata_generic: implement ATA_GEN_* flags and force enable DMA on MBP 7,1 Greg KH
2010-12-08  0:43 ` [026/127] ssb: b43-pci-bridge: Add new vendor for BCM4318 Greg KH
2010-12-08  0:43 ` [027/127] sgi-xpc: XPC fails to discover partitions with all nasids above 128 Greg KH
2010-12-08  0:43 ` [028/127] xen: ensure that all event channels start off bound to VCPU 0 Greg KH
2010-12-08  0:43 ` [029/127] xen: dont bother to stop other cpus on shutdown/reboot Greg KH
2010-12-08  0:43 ` [030/127] ipc: initialize structure memory to zero for compat functions Greg KH
2010-12-08  0:43 ` [031/127] ipc: shm: fix information leak to userland Greg KH
2010-12-08  0:43 ` [032/127] sys_semctl: fix kernel stack leakage Greg KH
2010-12-08  0:43 ` [033/127] net: NETIF_F_HW_CSUM does not imply FCoE CRC offload Greg KH
2010-12-08  0:43 ` [034/127] drivers/char/vt_ioctl.c: fix VT_OPENQRY error value Greg KH
2010-12-08  0:43 ` [035/127] viafb: use proper register for colour when doing fill ops Greg KH
2010-12-08  0:43 ` [036/127] eCryptfs: Clear LOOKUP_OPEN flag when creating lower file Greg KH
2010-12-08  0:43 ` [037/127] md/raid1: really fix recovery looping when single good device fails Greg KH
2010-12-08  0:43 ` [038/127] md: fix return value of rdev_size_change() Greg KH
2010-12-08  0:43 ` [039/127] x86: AMD Northbridge: Verify NBs node is online Greg KH
2010-12-08  0:43 ` [040/127] tty: prevent DOS in the flush_to_ldisc Greg KH
2010-12-08  0:43 ` [041/127] TTY: restore tty_ldisc_wait_idle Greg KH
2010-12-08  0:43 ` [042/127] tty_ldisc: Fix BUG() on hangup Greg KH
2010-12-08  0:43 ` [043/127] TTY: ldisc, fix open flag handling Greg KH
2010-12-08  6:24   ` Jiri Slaby
2010-12-08 15:02     ` Greg KH
2010-12-08 15:09       ` Jiri Slaby
2010-12-08 15:50         ` Greg KH
2010-12-08  0:43 ` [044/127] KVM: VMX: fix vmx null pointer dereference on debug register access Greg KH
2010-12-08  0:43 ` [045/127] KVM: x86: fix information leak to userland Greg KH
2010-12-08  0:43 ` [046/127] KVM: VMX: Fix host userspace gsbase corruption Greg KH
2010-12-08  2:12   ` [Stable-review] " Ben Hutchings
2010-12-08  3:58     ` Greg KH
2010-12-08  0:43 ` [047/127] firewire: cdev: fix information leak Greg KH
2010-12-08  0:43 ` [048/127] firewire: core: fix an " Greg KH
2010-12-08  0:43 ` [049/127] firewire: ohci: fix buffer overflow in AR split packet handling Greg KH
2010-12-08  0:43 ` [050/127] firewire: ohci: fix race " Greg KH
2010-12-08  0:43 ` [051/127] ALSA: ac97: Apply quirk for Dell Latitude D610 binding Master and Headphone controls Greg KH
2010-12-08  0:43 ` [052/127] ALSA: HDA: Add an extra DAC for Realtek ALC887-VD Greg KH
2010-12-08  0:43 ` [053/127] ALSA: hda: Use "alienware" model quirk for another SSID Greg KH
2010-12-08  0:44 ` [054/127] netfilter: nf_conntrack: allow nf_ct_alloc_hashtable() to get highmem pages Greg KH
2010-12-08  0:44 ` [055/127] latencytop: fix per task accumulator Greg KH
2010-12-08  0:44 ` Greg KH [this message]
2010-12-08  0:44 ` [057/127] bio: take care not overflow page count when mapping/copying user data Greg KH
2010-12-08  0:44 ` [058/127] drm/ttm: Clear the ghost cpu_writers flag on ttm_buffer_object_transfer Greg KH
2010-12-08  0:44 ` [059/127] libata-scsi passthru: fix bug which truncated LBA48 return values Greg KH
2010-12-08  0:44 ` [060/127] libata: fix NULL sdev dereference race in atapi_qc_complete() Greg KH
2010-12-08  0:44 ` [061/127] PCI: fix size checks for mmap() on /proc/bus/pci files Greg KH
2010-12-08  0:44 ` [062/127] PCI: fix offset check for sysfs mmapped files Greg KH
2010-12-08  0:44 ` [063/127] efifb: check that the base address is plausible on pci systems Greg KH
2010-12-08  0:44 ` [064/127] USB: gadget: AT91: fix typo in atmel_usba_udc driver Greg KH
2010-12-08  0:44 ` [065/127] USB: ftdi_sio: add device IDs for Milkymist One JTAG/serial Greg KH
2010-12-08  0:44 ` [066/127] USB: option: fix when the driver is loaded incorrectly for some Huawei devices Greg KH
2010-12-08  0:44 ` [067/127] usb: misc: sisusbvga: fix information leak to userland Greg KH
2010-12-08  0:44 ` [068/127] usb: misc: iowarrior: " Greg KH
2010-12-08  0:44 ` [069/127] usb: core: " Greg KH
2010-12-08  0:44 ` [070/127] USB: EHCI: fix obscure race in ehci_endpoint_disable Greg KH
2010-12-08  0:44 ` [071/127] USB: storage: sierra_ms: fix sysfs file attribute Greg KH
2010-12-08  0:44 ` [072/127] USB: atm: ueagle-atm: fix up some permissions on the sysfs files Greg KH
2010-12-08  0:44 ` [073/127] USB: misc: cypress_cy7c63: fix up some sysfs attribute permissions Greg KH
2010-12-08  0:44 ` [074/127] USB: misc: usbled: " Greg KH
2010-12-08  0:44 ` [075/127] USB: ftdi_sio: revert "USB: ftdi_sio: fix DTR/RTS line modes" Greg KH
2010-12-08  0:44 ` [076/127] USB: misc: trancevibrator: fix up a sysfs attribute permission Greg KH
2010-12-08  0:44 ` [077/127] USB: misc: usbsevseg: fix up some sysfs attribute permissions Greg KH
2010-12-08  0:44 ` [078/127] USB: ftdi_sio: Add ID for RT Systems USB-29B radio cable Greg KH
2010-12-08  0:44 ` [079/127] USB: serial: ftdi_sio: Vardaan USB RS422/485 converter PID added Greg KH
2010-12-08  0:44 ` [080/127] acpi-cpufreq: fix a memleak when unloading driver Greg KH
2010-12-08  0:44 ` [081/127] ACPI: EC: add Vista incompatibility DMI entry for Toshiba Satellite L355 Greg KH
2010-12-08  0:44 ` [082/127] fuse: fix attributes after open(O_TRUNC) Greg KH
2010-12-08  0:44 ` [083/127] do_exit(): make sure that we run with get_fs() == USER_DS Greg KH
2010-12-08  0:44 ` [084/127] uml: disable winch irq before freeing handler data Greg KH
2010-12-08  0:44 ` [085/127] backlight: grab ops_lock before testing bd->ops Greg KH
2010-12-08  0:44 ` [086/127] nommu: yield CPU while disposing VM Greg KH
2010-12-08  0:44 ` [087/127] DECnet: dont leak uninitialized stack byte Greg KH
2010-12-08  0:44 ` [088/127] perf_events: Fix perf_counter_mmap() hook in mprotect() Greg KH
2010-12-08  0:44 ` [089/127] ARM: 6489/1: thumb2: fix incorrect optimisation in usracc Greg KH
2010-12-08  0:44 ` [090/127] ARM: 6482/2: Fix find_next_zero_bit and related assembly Greg KH
2010-12-08  0:44 ` [091/127] Staging: frontier: fix up some sysfs attribute permissions Greg KH
2010-12-08  0:44 ` [092/127] staging: rtl8187se: Change panic to warn when RF switch turned off Greg KH
2010-12-08  0:44 ` [093/127] net sched: fix kernel leak in act_police Greg KH
2010-12-08  0:44 ` [094/127] HID: hidraw, fix a NULL pointer dereference in hidraw_ioctl Greg KH
2010-12-08  0:44 ` [095/127] HID: hidraw, fix a NULL pointer dereference in hidraw_write Greg KH
2010-12-08  0:44 ` [096/127] gianfar: Fix crashes on RX path (Was Re: [Bugme-new] [Bug 19692] New: linux-2.6.36-rc5 crash with gianfar ethernet at full line rate traffic) Greg KH
2010-12-08  0:44 ` [097/127] Limit sysctl_tcp_mem and sysctl_udp_mem initializers to prevent integer overflows Greg KH
2010-12-08  0:44 ` [098/127] sparc64: Fix race in signal instruction flushing Greg KH
2010-12-08  0:44 ` [099/127] sparc: Dont mask signal when we cant setup signal frame Greg KH
2010-12-08  0:44 ` [100/127] sparc: Prevent no-handler signal syscall restart recursion Greg KH
2010-12-08  0:44 ` [101/127] x86, UV: Delete unneeded boot messages Greg KH
2010-12-08  0:44 ` [102/127] x86, UV: Fix initialization of max_pnode Greg KH
2010-12-08  0:44 ` [103/127] drivers/video/efifb.c: support framebuffer for NVIDIA 9400M in MacBook Pro 5,1 Greg KH
2010-12-08  0:44 ` [104/127] efifb: support the EFI framebuffer on more Apple hardware Greg KH
2010-12-08  0:44 ` [105/127] V4L/DVB (13154): uvcvideo: Handle garbage at the end of streaming interface descriptors Greg KH
2010-12-08  0:44 ` [106/127] Input: i8042 - add Sony VAIO VPCZ122GX to nomux list Greg KH
2010-12-08  0:44 ` [107/127] x25: Patch to fix bug 15678 - x25 accesses fields beyond end of packet Greg KH
2010-12-08  0:44 ` [108/127] memory corruption in X.25 facilities parsing Greg KH
2010-12-08  0:44 ` [109/127] can-bcm: fix minor heap overflow Greg KH
2010-12-08  0:44 ` [110/127] V4L/DVB: ivtvfb: prevent reading uninitialized stack memory Greg KH
2010-12-08  0:44 ` [111/127] x25: Prevent crashing when parsing bad X.25 facilities Greg KH
2010-12-08  0:44 ` [112/127] crypto: padlock - Fix AES-CBC handling on odd-block-sized input Greg KH
2010-12-08  0:44 ` [113/127] x86-32: Separate 1:1 pagetables from swapper_pg_dir Greg KH
2010-12-08  0:45 ` [114/127] x86, mm: Fix CONFIG_VMSPLIT_1G and 2G_OPT trampoline Greg KH
2010-12-08  0:45 ` [115/127] x86-32: Fix dummy trampoline-related inline stubs Greg KH
2010-12-08  0:45 ` [116/127] econet: disallow NULL remote addr for sendmsg(), fixes CVE-2010-3849 Greg KH
2010-12-08  0:45 ` [117/127] econet: fix CVE-2010-3850 Greg KH
2010-12-08  0:45 ` [118/127] rds: Integer overflow in RDS cmsg handling Greg KH
2010-12-08  0:45 ` [119/127] net: Truncate recvfrom and sendto length to INT_MAX Greg KH
2010-12-08  0:45 ` [120/127] net: Limit socket I/O iovec total " Greg KH
2010-12-08  0:45 ` [121/127] [S390] nmi: fix clock comparator revalidation Greg KH
2010-12-08  8:04   ` Heiko Carstens
2010-12-08 17:13     ` Greg KH
2010-12-09  6:23       ` Heiko Carstens
2010-12-08 23:10     ` Greg KH
2010-12-08  0:45 ` [122/127] act_nat: use stack variable Greg KH
2010-12-08  0:45 ` [123/127] net sched: fix some kernel memory leaks Greg KH
2010-12-08  0:45 ` [124/127] UV - XPC: pass nasid instead of nid to gru_create_message_queue Greg KH
2010-12-08  0:45 ` [125/127] x86: uv: XPC receive message reuse triggers invalid BUG_ON() Greg KH
2010-12-08  0:45 ` [126/127] X86: uv: xpc_make_first_contact hang due to not accepting ACTIVE state Greg KH
2010-12-08  0:45 ` [127/127] x86: uv: xpc NULL deref when mesq becomes empty Greg KH

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=20101208004429.911496603@clark.site \
    --to=gregkh@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=arunabal@in.ibm.com \
    --cc=dave@linux.vnet.ibm.com \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=minchan.kim@gmail.com \
    --cc=riel@redhat.com \
    --cc=sbest@us.ibm.com \
    --cc=stable-review@kernel.org \
    --cc=stable@kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    /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

all inboxes | Powered by JetHome®