All of lore.kernel.org
 help / color / mirror / Atom feed
* [added to the 3.18 stable tree] blk-mq: fix buffer overflow when reading sysfs file of 'pending'
@ 2015-10-28  5:21 Sasha Levin
  2015-10-28  5:21 ` [added to the 3.18 stable tree] unshare: Unsharing a thread does not require unsharing a vm Sasha Levin
                   ` (50 more replies)
  0 siblings, 51 replies; 52+ messages in thread
From: Sasha Levin @ 2015-10-28  5:21 UTC (permalink / raw)
  To: stable, stable-commits; +Cc: Ming Lei, Jens Axboe, Sasha Levin

From: Ming Lei <ming.lei@canonical.com>

This patch has been added to the 3.18 stable tree. If you have any
objections, please let us know.

===============

[ Upstream commit 596f5aad2a704b72934e5abec1b1b4114c16f45b ]

There may be lots of pending requests so that the buffer of PAGE_SIZE
can't hold them at all.

One typical example is scsi-mq, the queue depth(.can_queue) of
scsi_host and blk-mq is quite big but scsi_device's queue_depth
is a bit small(.cmd_per_lun), then it is quite easy to have lots
of pending requests in hw queue.

This patch fixes the following warning and the related memory
destruction.

[  359.025101] fill_read_buffer: blk_mq_hw_sysfs_show+0x0/0x7d returned bad count^M
[  359.055595] irq event stamp: 15537^M
[  359.055606] general protection fault: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC ^M
[  359.055614] Dumping ftrace buffer:^M
[  359.055660]    (ftrace buffer empty)^M
[  359.055672] Modules linked in: nbd ipv6 kvm_intel kvm serio_raw^M
[  359.055678] CPU: 4 PID: 21631 Comm: stress-ng-sysfs Not tainted 4.2.0-rc5-next-20150805 #434^M
[  359.055679] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011^M
[  359.055682] task: ffff8802161cc000 ti: ffff88021b4a8000 task.ti: ffff88021b4a8000^M
[  359.055693] RIP: 0010:[<ffffffff811541c5>]  [<ffffffff811541c5>] __kmalloc+0xe8/0x152^M

Cc: <stable@vger.kernel.org>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 block/blk-mq-sysfs.c | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/block/blk-mq-sysfs.c b/block/blk-mq-sysfs.c
index 1630a20..d477f83 100644
--- a/block/blk-mq-sysfs.c
+++ b/block/blk-mq-sysfs.c
@@ -141,15 +141,26 @@ static ssize_t blk_mq_sysfs_completed_show(struct blk_mq_ctx *ctx, char *page)
 
 static ssize_t sysfs_list_show(char *page, struct list_head *list, char *msg)
 {
-	char *start_page = page;
 	struct request *rq;
+	int len = snprintf(page, PAGE_SIZE - 1, "%s:\n", msg);
+
+	list_for_each_entry(rq, list, queuelist) {
+		const int rq_len = 2 * sizeof(rq) + 2;
+
+		/* if the output will be truncated */
+		if (PAGE_SIZE - 1 < len + rq_len) {
+			/* backspacing if it can't hold '\t...\n' */
+			if (PAGE_SIZE - 1 < len + 5)
+				len -= rq_len;
+			len += snprintf(page + len, PAGE_SIZE - 1 - len,
+					"\t...\n");
+			break;
+		}
+		len += snprintf(page + len, PAGE_SIZE - 1 - len,
+				"\t%p\n", rq);
+	}
 
-	page += sprintf(page, "%s:\n", msg);
-
-	list_for_each_entry(rq, list, queuelist)
-		page += sprintf(page, "\t%p\n", rq);
-
-	return page - start_page;
+	return len;
 }
 
 static ssize_t blk_mq_sysfs_rq_list_show(struct blk_mq_ctx *ctx, char *page)
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 52+ messages in thread

end of thread, other threads:[~2015-10-28  5:28 UTC | newest]

Thread overview: 52+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-28  5:21 [added to the 3.18 stable tree] blk-mq: fix buffer overflow when reading sysfs file of 'pending' Sasha Levin
2015-10-28  5:21 ` [added to the 3.18 stable tree] unshare: Unsharing a thread does not require unsharing a vm Sasha Levin
2015-10-28  5:21 ` [added to the 3.18 stable tree] tg3: Fix temperature reporting Sasha Levin
2015-10-28  5:21 ` [added to the 3.18 stable tree] mac80211: enable assoc check for mesh interfaces Sasha Levin
2015-10-28  5:21 ` [added to the 3.18 stable tree] arm64: kconfig: Move LIST_POISON to a safe value Sasha Levin
2015-10-28  5:21 ` [added to the 3.18 stable tree] arm64: compat: fix vfp save/restore across signal handlers in big-endian Sasha Levin
2015-10-28  5:21 ` [added to the 3.18 stable tree] arm64: head.S: initialise mdcr_el2 in el2_setup Sasha Levin
2015-10-28  5:21 ` [added to the 3.18 stable tree] arm64: errata: add module build workaround for erratum #843419 Sasha Levin
2015-10-28  5:21 ` [added to the 3.18 stable tree] arm64: KVM: Disable virtual timer even if the guest is not using it Sasha Levin
2015-10-28  5:21 ` [added to the 3.18 stable tree] Input: evdev - do not report errors form flush() Sasha Levin
2015-10-28  5:21 ` [added to the 3.18 stable tree] ALSA: hda - Enable headphone jack detect on old Fujitsu laptops Sasha Levin
2015-10-28  5:21 ` [added to the 3.18 stable tree] ALSA: hda - Use ALC880_FIXUP_FUJITSU for FSC Amilo M1437 Sasha Levin
2015-10-28  5:21 ` [added to the 3.18 stable tree] powerpc/mm: Fix pte_pagesize_index() crash on 4K w/64K hash Sasha Levin
2015-10-28  5:21 ` [added to the 3.18 stable tree] powerpc/rtas: Introduce rtas_get_sensor_fast() for IRQ handlers Sasha Levin
2015-10-28  5:21 ` [added to the 3.18 stable tree] powerpc/mm: Recompute hash value after a failed update Sasha Levin
2015-10-28  5:21 ` [added to the 3.18 stable tree] CIFS: fix type confusion in copy offload ioctl Sasha Levin
2015-10-28  5:21 ` [added to the 3.18 stable tree] Add radeon suspend/resume quirk for HP Compaq dc5750 Sasha Levin
2015-10-28  5:21 ` [added to the 3.18 stable tree] x86/mm: Initialize pmd_idx in page_table_range_init_count() Sasha Levin
2015-10-28  5:21 ` [added to the 3.18 stable tree] [media] rc-core: fix remove uevent generation Sasha Levin
2015-10-28  5:21 ` [added to the 3.18 stable tree] [media] v4l: omap3isp: Fix sub-device power management code Sasha Levin
2015-10-28  5:21 ` [added to the 3.18 stable tree] Btrfs: check if previous transaction aborted to avoid fs corruption Sasha Levin
2015-10-28  5:21 ` [added to the 3.18 stable tree] NFSv4: don't set SETATTR for O_RDONLY|O_EXCL Sasha Levin
2015-10-28  5:21 ` [added to the 3.18 stable tree] NFS: Fix a NULL pointer dereference of migration recovery ops for v4.2 client Sasha Levin
2015-10-28  5:22 ` [added to the 3.18 stable tree] NFS: nfs_set_pgio_error sometimes misses errors Sasha Levin
2015-10-28  5:22 ` [added to the 3.18 stable tree] parisc: Use double word condition in 64bit CAS operation Sasha Levin
2015-10-28  5:22 ` [added to the 3.18 stable tree] parisc: Filter out spurious interrupts in PA-RISC irq handler Sasha Levin
2015-10-28  5:22 ` [added to the 3.18 stable tree] vmscan: fix increasing nr_isolated incurred by putback unevictable pages Sasha Levin
2015-10-28  5:22 ` [added to the 3.18 stable tree] fs: if a coredump already exists, unlink and recreate with O_EXCL Sasha Levin
2015-10-28  5:22 ` [added to the 3.18 stable tree] mmc: core: fix race condition in mmc_wait_data_done Sasha Levin
2015-10-28  5:22 ` [added to the 3.18 stable tree] md/raid10: always set reshape_safe when initializing reshape_position Sasha Levin
2015-10-28  5:22 ` [added to the 3.18 stable tree] hfs: fix B-tree corruption after insertion at position 0 Sasha Levin
2015-10-28  5:22 ` [added to the 3.18 stable tree] IB/qib: Change lkey table allocation to support more MRs Sasha Levin
2015-10-28  5:22 ` [added to the 3.18 stable tree] IB/uverbs: reject invalid or unknown opcodes Sasha Levin
2015-10-28  5:22 ` [added to the 3.18 stable tree] IB/uverbs: Fix race between ib_uverbs_open and remove_one Sasha Levin
2015-10-28  5:22 ` [added to the 3.18 stable tree] IB/mlx4: Forbid using sysfs to change RoCE pkeys Sasha Levin
2015-10-28  5:22 ` [added to the 3.18 stable tree] IB/mlx4: Use correct SL on AH query under RoCE Sasha Levin
2015-10-28  5:22 ` [added to the 3.18 stable tree] hfs,hfsplus: cache pages correctly between bnode_create and bnode_free Sasha Levin
2015-10-28  5:22 ` [added to the 3.18 stable tree] if_link: Add an additional parameter to ifla_vf_info for RSS querying Sasha Levin
2015-10-28  5:22 ` [added to the 3.18 stable tree] rtnetlink: verify IFLA_VF_INFO attributes before passing them to driver Sasha Levin
2015-10-28  5:22 ` [added to the 3.18 stable tree] ip6_gre: release cached dst on tunnel removal Sasha Levin
2015-10-28  5:22 ` [added to the 3.18 stable tree] usbnet: Get EVENT_NO_RUNTIME_PM bit before it is cleared Sasha Levin
2015-10-28  5:22 ` [added to the 3.18 stable tree] ipv6: fix exthdrs offload registration in out_rt path Sasha Levin
2015-10-28  5:22 ` [added to the 3.18 stable tree] net/ipv6: Correct PIM6 mrt_lock handling Sasha Levin
2015-10-28  5:22 ` [added to the 3.18 stable tree] netlink, mmap: transform mmap skb into full skb on taps Sasha Levin
2015-10-28  5:22 ` [added to the 3.18 stable tree] sctp: fix race on protocol/netns initialization Sasha Levin
2015-10-28  5:22 ` [added to the 3.18 stable tree] openvswitch: Zero flows on allocation Sasha Levin
2015-10-28  5:22 ` [added to the 3.18 stable tree] fib_rules: fix fib rule dumps across multiple skbs Sasha Levin
2015-10-28  5:22 ` [added to the 3.18 stable tree] packet: missing dev_put() in packet_do_bind() Sasha Levin
2015-10-28  5:22 ` [added to the 3.18 stable tree] udp: fix dst races with multicast early demux Sasha Levin
2015-10-28  5:22 ` [added to the 3.18 stable tree] bna: fix interrupts storm caused by erroneous packets Sasha Levin
2015-10-28  5:22 ` [added to the 3.18 stable tree] x86/nmi/64: Improve nested NMI comments Sasha Levin
2015-10-28  5:22 ` [added to the 3.18 stable tree] x86/nmi/64: Reorder nested NMI checks Sasha Levin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.