All of lore.kernel.org
 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,
	"BjÞrn Mork" <bjorn@mork.no>,
	"Michael Benz" <Michael.Benz@lsi.com>,
	"James Bottomley" <James.Bottomley@suse.de>
Subject: [65/71] [SCSI] megaraid_sas: Sanity check user supplied length before passing it to dma_alloc_coherent()
Date: Thu, 19 May 2011 11:05:33 -0700	[thread overview]
Message-ID: <20110519180600.495911032@clark.kroah.org> (raw)
In-Reply-To: <20110519180626.GA16555@kroah.com>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 4531 bytes --]

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

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

From: =?UTF-8?q?Bj=C3=B8rn=20Mork?= <bjorn@mork.no>

commit 98cb7e4413d189cd2b54daf993a4667d9788c0bb upstream.

The ioc->sgl[i].iov_len value is supplied by the ioctl caller, and can be
zero in some cases.  Assume that's valid and continue without error.

Fixes (multiple individual reports of the same problem for quite a while):

http://marc.info/?l=linux-ide&m=128941801715301
http://bugs.debian.org/604627
http://www.mail-archive.com/linux-poweredge@dell.com/msg02575.html

megasas: Failed to alloc kernel SGL buffer for IOCTL

and

[   69.162538] ------------[ cut here ]------------
[   69.162806] kernel BUG at /build/buildd/linux-2.6.32/lib/swiotlb.c:368!
[   69.163134] invalid opcode: 0000 [#1] SMP
[   69.163570] last sysfs file: /sys/devices/system/cpu/cpu3/cache/index2/shared_cpu_map
[   69.163975] CPU 0
[   69.164227] Modules linked in: fbcon tileblit font bitblit softcursor vga16fb vgastate ioatdma radeon ttm drm_kms_helper shpchp drm i2c_algo_bit lp parport floppy pata_jmicron megaraid_sas igb dca
[   69.167419] Pid: 1206, comm: smartctl Tainted: G        W  2.6.32-25-server #45-Ubuntu X8DTN
[   69.167843] RIP: 0010:[<ffffffff812c4dc5>]  [<ffffffff812c4dc5>] map_single+0x255/0x260
[   69.168370] RSP: 0018:ffff88081c0ebc58  EFLAGS: 00010246
[   69.168655] RAX: 000000000003bffc RBX: 00000000ffffffff RCX: 0000000000000002
[   69.169000] RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff88001dffe000
[   69.169346] RBP: ffff88081c0ebcb8 R08: 0000000000000000 R09: ffff880000030840
[   69.169691] R10: 0000000000100000 R11: 0000000000000000 R12: 0000000000000000
[   69.170036] R13: 00000000ffffffff R14: 0000000000000001 R15: 0000000000200000
[   69.170382] FS:  00007fb8de189720(0000) GS:ffff88001de00000(0000) knlGS:0000000000000000
[   69.170794] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   69.171094] CR2: 00007fb8dd59237c CR3: 000000081a790000 CR4: 00000000000006f0
[   69.171439] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[   69.171784] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
[   69.172130] Process smartctl (pid: 1206, threadinfo ffff88081c0ea000, task ffff88081a760000)
[   69.194513] Stack:
[   69.205788]  0000000000000034 00000002817e3390 0000000000000000 ffff88081c0ebe00
[   69.217739] <0> 0000000000000000 000000000003bffc 0000000000000000 0000000000000000
[   69.241250] <0> 0000000000000000 00000000ffffffff ffff88081c5b4080 ffff88081c0ebe00
[   69.277310] Call Trace:
[   69.289278]  [<ffffffff812c52ac>] swiotlb_alloc_coherent+0xec/0x130
[   69.301118]  [<ffffffff81038b31>] x86_swiotlb_alloc_coherent+0x61/0x70
[   69.313045]  [<ffffffffa002d0ce>] megasas_mgmt_fw_ioctl+0x1ae/0x690 [megaraid_sas]
[   69.336399]  [<ffffffffa002d748>] megasas_mgmt_ioctl_fw+0x198/0x240 [megaraid_sas]
[   69.359346]  [<ffffffffa002f695>] megasas_mgmt_ioctl+0x35/0x50 [megaraid_sas]
[   69.370902]  [<ffffffff81153b12>] vfs_ioctl+0x22/0xa0
[   69.382322]  [<ffffffff8115da2a>] ? alloc_fd+0x10a/0x150
[   69.393622]  [<ffffffff81153cb1>] do_vfs_ioctl+0x81/0x410
[   69.404696]  [<ffffffff8155cc13>] ? do_page_fault+0x153/0x3b0
[   69.415761]  [<ffffffff811540c1>] sys_ioctl+0x81/0xa0
[   69.426640]  [<ffffffff810121b2>] system_call_fastpath+0x16/0x1b
[   69.437491] Code: fe ff ff 48 8b 3d 74 38 76 00 41 bf 00 00 20 00 e8 51 f5 d7 ff 83 e0 ff 48 05 ff 07 00 00 48 c1 e8 0b 48 89 45 c8 e9 13 fe ff ff <0f> 0b eb fe 0f 1f 80 00 00 00 00 55 48 89 e5 48 83 ec 20 4c 89
[   69.478216] RIP  [<ffffffff812c4dc5>] map_single+0x255/0x260
[   69.489668]  RSP <ffff88081c0ebc58>
[   69.500975] ---[ end trace 6a2181b634e2abc7 ]---

Reported-by: Bokhan Artem <aptem@ngs.ru>
Reported by: Marc-Christian Petersen <m.c.p@gmx.de>
Signed-off-by: Bjørn Mork <bjorn@mork.no>
Cc: Michael Benz <Michael.Benz@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 drivers/scsi/megaraid/megaraid_sas_base.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -4611,6 +4611,9 @@ megasas_mgmt_fw_ioctl(struct megasas_ins
 	 * For each user buffer, create a mirror buffer and copy in
 	 */
 	for (i = 0; i < ioc->sge_count; i++) {
+		if (!ioc->sgl[i].iov_len)
+			continue;
+
 		kbuff_arr[i] = dma_alloc_coherent(&instance->pdev->dev,
 						    ioc->sgl[i].iov_len,
 						    &buf_handle, GFP_KERNEL);



  parent reply	other threads:[~2011-05-19 18:09 UTC|newest]

Thread overview: 81+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-19 18:06 [00/71] 2.6.38.7-stable review Greg KH
2011-05-19 18:04 ` [01/71] cifs: change bleft in decode_unicode_ssetup back to signed type Greg KH
2011-05-19 18:04 ` [02/71] cifs: check for bytes_remaining going to zero in CIFS_SessSetup Greg KH
2011-05-19 18:04 ` [03/71] cifs: sanitize length checking in coalesce_t2 (try #3) Greg KH
2011-05-19 18:04 ` [04/71] cifs: refactor mid finding loop in cifs_demultiplex_thread Greg KH
2011-05-19 18:04 ` [05/71] cifs: handle errors from coalesce_t2 Greg KH
2011-05-19 18:04 ` [06/71] Validate size of EFI GUID partition entries Greg KH
2011-05-19 18:04 ` [07/71] drm/radeon/kms: add pci id to acer travelmate quirk for 5730 Greg KH
2011-05-19 18:04 ` [08/71] thinkpad-acpi: module autoloading for newer Lenovo ThinkPads Greg KH
2011-05-20  0:58   ` Henrique de Moraes Holschuh
2011-05-19 18:04 ` [09/71] x86, hw_breakpoints: Fix racy access to ptrace breakpoints Greg KH
2011-05-19 18:04 ` [10/71] ptrace: Prepare to fix racy accesses on task breakpoints Greg KH
2011-05-19 18:04 ` [11/71] hw_breakpoints, powerpc: Fix CONFIG_HAVE_HW_BREAKPOINT off-case in ptrace_set_debugreg() Greg KH
2011-05-19 18:04   ` Greg KH
2011-05-19 18:04 ` [12/71] iwlwifi: add {ack, plpc}_check module parameters Greg KH
2011-05-19 18:04 ` [13/71] [stable] [PATCH] drm/radeon/kms: fix gart setup on fusion parts (v2) backport Greg KH
2011-05-19 18:04 ` [14/71] vm: fix vm_pgoff wrap in upward expansion Greg KH
2011-05-19 18:04 ` [15/71] Dont lock guardpage if the stack is growing up Greg KH
2011-05-19 18:04 ` [16/71] drm/i915/dp: Be paranoid in case we disable a DP before it is attached Greg KH
2011-05-19 18:04 ` [17/71] drm/i915/lvds: Only act on lid notify when the device is on Greg KH
2011-05-19 18:04 ` [18/71] drm/i915: Release object along create user fb error path Greg KH
2011-05-19 18:04 ` [19/71] dccp: handle invalid feature options length Greg KH
2011-05-19 18:04 ` [20/71] CIFS: Fix memory over bound bug in cifs_parse_mount_options Greg KH
2011-05-19 18:04 ` [21/71] drivers/rtc/rtc-s3c.c: fixup wake support for rtc Greg KH
2011-05-19 18:04 ` [22/71] mm: use alloc_bootmem_node_nopanic() on really needed path Greg KH
2011-05-19 18:04 ` [23/71] tmpfs: fix race between umount and swapoff Greg KH
2011-05-21  4:48   ` Hugh Dickins
2011-05-21 21:43     ` Greg KH
2011-05-19 18:04 ` [24/71] ARM: zImage: make sure the stack is 64-bit aligned Greg KH
2011-05-19 18:04 ` [25/71] PM: Fix warning in pm_restrict_gfp_mask() during SNAPSHOT_S2RAM ioctl Greg KH
2011-05-19 18:04 ` [26/71] PM / Hibernate: Make snapshot_release() restore GFP mask Greg KH
2011-05-19 18:04 ` [27/71] PM / Hibernate: Fix ioctl SNAPSHOT_S2RAM Greg KH
2011-05-19 18:04 ` [28/71] net: ip_expire() must revalidate route Greg KH
2011-05-19 18:04 ` [29/71] can: fix SJA1000 dlc for RTR packets Greg KH
2011-05-19 20:17   ` Kurt Van Dijck
2011-05-19 18:04 ` [30/71] ipheth: Properly distinguish length and alignment in URBs and skbs Greg KH
2011-05-19 18:04 ` [31/71] vmxnet3: Consistently disable irqs when taking adapter->cmd_lock Greg KH
2011-05-19 18:05 ` [32/71] ehea: fix wrongly reported speed and port Greg KH
2011-05-19 18:05 ` [33/71] NET: slip, fix ldisc->open retval Greg KH
2011-05-19 18:05 ` [34/71] PCH_GbE : Fixed the issue of collision detection Greg KH
2011-05-19 18:05 ` [35/71] PCH_GbE : Fixed the issue of checksum judgment Greg KH
2011-05-19 18:05 ` [36/71] pch_gbe: support ML7223 IOH Greg KH
2011-05-19 18:05 ` [37/71] net: dev_close() should check IFF_UP Greg KH
2011-05-19 18:05 ` [38/71] slcan: fix ldisc->open retval Greg KH
2011-05-19 18:05 ` [39/71] ASoC: UDA134x: Remove POWER_OFF_ON_STANDBY define Greg KH
2011-05-19 18:05 ` [40/71] ASoC: SSM2602: Fix Mic Boost2 control Greg KH
2011-05-19 18:05 ` [41/71] ne-h8300: Fix regression caused during net_device_ops conversion Greg KH
2011-05-19 18:05 ` [42/71] hydra: " Greg KH
2011-05-19 18:05 ` [43/71] ehea: Fix memory hotplug oops Greg KH
2011-05-19 18:05 ` [44/71] libertas: fix cmdpendingq locking Greg KH
2011-05-19 18:05 ` [45/71] zorro8390: Fix regression caused during net_device_ops conversion Greg KH
2011-05-19 18:05 ` [46/71] tmpfs: fix race between umount and writepage Greg KH
2011-05-19 18:05 ` [47/71] tmpfs: fix race between swapoff " Greg KH
2011-05-19 18:05 ` [48/71] tmpfs: fix off-by-one in max_blocks checks Greg KH
2011-05-19 18:05 ` [49/71] tmpfs: fix spurious ENOSPC when racing with unswap Greg KH
2011-05-19 18:05 ` [50/71] libata: fix oops when LPM is used with PMP Greg KH
2011-05-19 18:05 ` [51/71] drm/radeon/kms: fix extended lvds info parsing Greg KH
2011-05-19 18:05 ` [52/71] Revert "mmc: fix a race between card-detect rescan and clock-gate work instances" Greg KH
2011-05-19 18:05 ` [53/71] cifs: add fallback in is_path_accessible for old servers Greg KH
2011-05-19 18:05 ` [54/71] rapidio: fix default routing initialization Greg KH
2011-05-19 18:05 ` [55/71] Revert "x86, AMD: Fix APIC timer erratum 400 affecting K8 Rev.A-E processors" Greg KH
2011-05-19 18:05 ` [56/71] x86, AMD: Fix ARAT feature setting again Greg KH
2011-05-19 18:05 ` [57/71] block: rescan partitions on invalidated devices on -ENOMEDIA too Greg KH
2011-05-19 18:12   ` Tejun Heo
2011-05-19 18:18     ` Greg KH
2011-05-25  9:09       ` Tejun Heo
2011-05-30  0:01         ` [stable] " Greg KH
2011-05-19 18:05 ` [58/71] clocksource: Install completely before selecting Greg KH
2011-05-19 18:05 ` [59/71] tick: Clear broadcast active bit when switching to oneshot Greg KH
2011-05-19 18:05 ` [60/71] x86, apic: Fix spurious error interrupts triggering on all non-boot APs Greg KH
2011-05-19 18:05 ` [61/71] [media] Fix cx88 remote control input Greg KH
2011-05-19 18:05 ` [62/71] [media] v4l: Release module if subdev registration fails Greg KH
2011-05-19 18:05 ` [63/71] x86: Fix UV BAU for non-consecutive nasids Greg KH
2011-05-19 18:05 ` [64/71] x86, mce, AMD: Fix leaving freed data in a list Greg KH
2011-05-19 18:05 ` Greg KH [this message]
2011-05-19 18:05 ` [66/71] cdrom: always check_disk_change() on open Greg KH
2011-05-19 18:05 ` [67/71] vmxnet3: Fix inconsistent LRO state after initialization Greg KH
2011-05-19 18:05 ` [68/71] [SCSI] Revert "[SCSI] Retrieve the Caching mode page" Greg KH
2011-05-19 18:05 ` [69/71] cifs: clean up various nits in unicode routines (try #2) Greg KH
2011-05-19 18:05 ` [70/71] cifs: fix cifsConvertToUCS() for the mapchars case Greg KH
2011-05-19 18:05 ` [71/71] iwlegacy: fix IBSS mode crashes 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=20110519180600.495911032@clark.kroah.org \
    --to=gregkh@suse.de \
    --cc=James.Bottomley@suse.de \
    --cc=Michael.Benz@lsi.com \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=bjorn@mork.no \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable-review@kernel.org \
    --cc=stable@kernel.org \
    --cc=torvalds@linux-foundation.org \
    /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 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.