3.2.91-rc1 review
Subsystems (3)
cover 3.2.91-rc1 review
This is the start of the stable review cycle for the 3.2.91 release. There are 95 patches in this series, which will be posted as responses to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Tue Jul 18 13:56:34 UTC 2017. Anything received after that time might be too late.
A combined patch relative to 3.2.90 will be posted as an additional response to this. A shortlog and diffstat can be found below.
Ben.
-------------
Adrian Hunter (1):
mmc: sdhci: Do not disable interrupts while waiting for clock
[e2ebfb2142acefecc2496e71360f50d25726040b]
Al Viro (1):
p9_client_readdir() fix
[71d6ad08379304128e4bdfaf0b4185d54375423e]Alexey Kodanev (1):
udp: avoid ufo handling on IP payload compression packets
[4b3b45edba9222e518a1ec72df841eba3609fe34]
Andrey Ulanov (1):
net: unix: properly re-increment inflight counter of GC discarded candidates
[7df9c24625b9981779afb8fcdbe2bb4765e61147]
Anton Blanchard (1):
scsi: lpfc: Add shutdown method for kexec
[85e8a23936ab3442de0c42da97d53b29f004ece1]
Arnd Bergmann (4):
ACPI / power: Avoid maybe-uninitialized warning
[fe8c470ab87d90e4b5115902dd94eced7e3305c3]
IB/qib: fix false-postive maybe-uninitialized warning
[f6aafac184a3e46e919769dd4faa8bf0dc436534]
hwmon: (asus_atk0110) fix uninitialized data access
[a2125d02443e9a4e68bcfd9f8004fa23239e8329]
virtio_balloon: prevent uninitialized variable use
[f0bb2d50dfcc519f06f901aac88502be6ff1df2c]
Ben Hutchings (1):
cpupower: Fix turbo frequency reporting for pre-Sandy Bridge cores
[4cca0457686e4ee1677d69469e4ddfd94d389a80]
[email protected] (1):
ptrace: fix PTRACE_LISTEN race corrupting task->state
[5402e97af667e35e54177af8f6575518bf251d51]Dan Carpenter (1):
net: tc35815: move free after the dereference
[11faa7b0359aaf7efd406b7a6a077fda2b037d8e]
Dan Streetman (1):
xen: do not re-use pirq number cached in pci device msi msg data
[c74fd80f2f41d05f350bb478151021f88551afe8]
Dan Williams (1):
USB: serial: option: add Quectel UC15, UC20, EC21, and EC25 modems
[6e9f44eaaef0df7b846e9316fa9ca72a02025d44]
Daniel Borkmann (2):
bpf: try harder on clones when writing into skb
[3697649ff29e0f647565eed04b27a7779c646a22]
perf symbols: Fix symbols__fixup_end heuristic for corner cases
[e7ede72a6d40cb3a30c087142d79381ca8a31dab]
David Ahern (1):
net: ipv6: set route type for anycast routes
[4ee39733fbecf04cf9f346de2d64788c35028079]
David Howells (1):
KEYS: Change the name of the dead type to ".dead" to prevent user access
[c1644fe041ebaf6519f6809146a77c3ead9193af]
Dmitry Torokhov (1):
Input: i8042 - add Clevo P650RS to the i8042 reset list
[7c5bb4ac2b76d2a09256aec8a7d584bf3e2b0466]
Eric Dumazet (3):
cx82310_eth: use skb_cow_head() to deal with cloned skbs
[a9e840a2081ed28c2b7caa6a9a0041c950b3c37d]
sch_dsmark: fix invalid skb_cow() usage
[aea92fb2e09e29653b023d4254ac9fbf94221538]
smsc75xx: use skb_cow_head() to deal with cloned skbs
[b7c6d2675899cfff0180412c63fc9cbd5bacdb4d]
Felipe Balbi (1):
usb: dwc3: gadget: make Set Endpoint Configuration macros safe
[7369090a9fb57c3fc705ce355d2e4523a5a24716]
Gao Feng (1):
netfilter: nf_nat_snmp: Fix panic when snmp_trap_helper fails to register
[75c689dca98851d65ef5a27e5ce26b625b68751c]
Guillaume Nault (7):
l2tp: don't mask errors in pppol2tp_getsockopt()
[321a52a39189d5e4af542f7dcdc07bba4545cf5d]
l2tp: don't mask errors in pppol2tp_setsockopt()
[364700cf8fd54f54ad08313464105a414e3bccb7]
l2tp: ensure session can't get removed during pppol2tp_session_ioctl()
[57377d63547861919ee634b845c7caa38de4a452]
l2tp: fix duplicate session creation
[dbdbc73b44782e22b3b4b6e8b51e7a3d245f3086]
l2tp: fix race in l2tp_recv_common()
[61b9a047729bb230978178bca6729689d0c50ca2]
l2tp: take a reference on sessions used in genetlink handlers
[2777e2ab5a9cf2b4524486c6db1517a6ded25261]
l2tp: take reference on sessions being dumped
[e08293a4ccbcc993ded0fdc46f1e57926b833d63]
Hans de Goede (1):
mmc: sdhci: Disable runtime pm when the sdio_irq is enabled
[923713b357455cfb9aca2cd3429cb0806a724ed2]
James Hogan (1):
MIPS: KGDB: Use kernel context for sleeping threads
[162b270c664dca2e0944308e92f9fcc887151a72]
James Morse (1):
ACPI / APEI: Add missing synchronize_rcu() on NOTIFY_SCI removal
[7d64f82cceb21e6d95db312d284f5f195e120154]
Jan Beulich (1):
xen-blkback: don't leak stack data via response ring
[089bc0143f489bd3a4578bdff5f4ca68fb26f341]
Johan Hovold (17):
Input: cm109 - validate number of endpoints before using them
[ac2ee9ba953afe88f7a673e1c0c839227b1d7891]
Input: hanwang - validate number of endpoints before using them
[ba340d7b83703768ce566f53f857543359aa1b98]
Input: iforce - validate number of endpoints before using them
[59cf8bed44a79ec42303151dd014fdb6434254bb]
Input: kbtab - validate number of endpoints before using them
[cb1b494663e037253337623bf1ef2df727883cb7]
Input: yealink - validate number of endpoints before using them
[5cc4a1a9f5c179795c8a1f2b0f4361829d6a070e]
USB: idmouse: fix NULL-deref at probe
[b0addd3fa6bcd119be9428996d5d4522479ab240]
USB: iowarrior: fix NULL-deref in write
[de46e56653de7b3b54baa625bd582635008b8d05]
USB: serial: io_ti: fix NULL-deref in interrupt callback
[0b1d250afb8eb9d65afb568bac9b9f9253a82b49]
USB: serial: safe_serial: fix information leak in completion handler
[8c76d7cd520ebffc1ea9ea0850d87a224a50c7f2]
USB: usbtmc: add missing endpoint sanity check
[687e0687f71ec00e0132a21fef802dee88c2f1ad]
USB: uss720: fix NULL-deref at probe
[f259ca3eed6e4b79ac3d5c5c9fb259fb46e86217]
USB: wusbcore: fix NULL-deref at probe
[03ace948a4eb89d1cf51c06afdfc41ebca5fdb27]
isdn/gigaset: fix NULL-deref at probe
[68c32f9c2a36d410aa242e661506e5b2c2764179]
mmc: ushc: fix NULL-deref at probe
[181302dc7239add8ab1449c23ecab193f52ee6ab]
net: wimax/i2400m: fix NULL-deref at probe
[6e526fdff7be4f13b24f929a04c0e9ae6761291e]
uwb: hwa-rc: fix NULL-deref at probe
[daf229b15907fbfdb6ee183aac8ca428cb57e361]
uwb: i1480-dfu: fix NULL-deref at probe
[4ce362711d78a4999011add3115b8f4b0bc25e8c]
Johannes Berg (1):
mac80211: reject ToDS broadcast data frames
[3018e947d7fd536d57e2b550c33e456d921fff8c]
John Garry (1):
scsi: libsas: fix ata xfer length
[9702c67c6066f583b629cf037d2056245bb7a8e6]
Josh Poimboeuf (2):
ACPI: Fix incompatibility with mcount-based function graph tracing
[61b79e16c68d703dde58c25d3935d67210b7d71b]
ftrace/x86: Fix triple fault with graph tracing and suspend-to-ram
[34a477e5297cbaa6ecc6e17c042a866e1cbe80d6]
Juergen Gross (1):
xen, fbfront: fix connecting to backend
[9121b15b5628b38b4695282dc18c553440e0f79b]
Kai-Heng Feng (1):
Input: i8042 - add noloop quirk for Dell Embedded Box PC 3000
[45838660e34d90db8d4f7cbc8fd66e8aff79f4fe]
Kees Cook (2):
fs/exec.c: account for argv/envp pointers
[98da7d08850fb8bdeb395d6368ed15753304aa0c]
mm: Tighten x86 /dev/mem with zeroing reads
[a4866aa812518ed1a37d8ea0c881dc946409de94]
Ladi Prosek (1):
virtio_balloon: init 1st buffer in stats vq
[fc8653228c8588a120f6b5dad6983b7b61ff669e]
Marcelo Henrique Cerri (1):
s390/decompressor: fix initrd corruption caused by bss clear
[d82c0d12c92705ef468683c9b7a8298dd61ed191]
Martin K. Petersen (2):
scsi: sd: Fix capacity calculation with 32-bit sector_t
[7c856152cb92f8eee2df29ef325a1b1f43161aff]
scsi: sr: Sanity check returned mode data
[a00a7862513089f17209b732f230922f1942e0b9]
Mathias Nyman (1):
xhci: Manually give back cancelled URB if we can't queue it for cancel
[d3519b9d9606991a1305596348b6d690bfa3eb27]
Matt Fleming (1):
sched/loadavg: Avoid loadavg spikes caused by delayed NO_HZ accounting
[6e5f32f7a43f45ee55c401c0b9585eb01f9629a8]
Mauro Carvalho Chehab (1):
[media] dvb-usb: don't use stack for firmware load
[43fab9793c1f44e665b4f98035a14942edf03ddc]
Murray McAllister (1):
drm/vmwgfx: avoid calling vzalloc with a 0 size in vmw_get_cap_3d_ioctl()
[63774069d9527a1aeaa4aa20e929ef5e8e9ecc38]
Nathan Sullivan (1):
net: phy: handle state correctly in phy_stop_machine
[49d52e8108a21749dc2114b924c907db43358984]
Nicholas Bellinger (1):
iscsi-target: Drop work-around for legacy GlobalSAN initiator
[1c99de981f30b3e7868b8d20ce5479fa1c0fea46]
Oliver Neukum (1):
ACM gadget: fix endianness in notifications
[cdd7928df0d2efaa3270d711963773a08a4cc8ab]
Paul Mackerras (1):
powerpc: Don't try to fix up misaligned load-with-reservation instructions
[48fe9e9488743eec9b7c1addd3c93f12f2123d54]
Peter Zijlstra (3):
futex: Add missing error handling to FUTEX_REQUEUE_PI
[9bbb25afeb182502ca4f2c4f3f88af0681b34cae]
futex: Fix potential use-after-free in FUTEX_REQUEUE_PI
[c236c8e95a3d395b0494e7108f0d41cf36ec107c]
perf/core: Fix event inheritance on fork()
[e7cc4865f0f31698ef2f7aac01a50e78968985b7]
Raghava Aditya Renukunta (1):
scsi: aacraid: Fix typo in blink status
[934767c56b0d9dbb95a40e9e6e4d9dcdc3a165ad]
Rik van Riel (1):
tracing: Add #undef to fix compile error
[bf7165cfa23695c51998231c4efa080fe1d3548d]
Samuel Thibault (1):
usb-core: Add LINEAR_FRAME_INTR_BINTERVAL USB quirk
[3243367b209faed5c320a4e5f9a565ee2a2ba958]
Sebastian Siewior (1):
ubi/upd: Always flush after prepared for an update
[9cd9a21ce070be8a918ffd3381468315a7a76ba6]
Stefan Brüns (1):
[media] dvb-usb-firmware: don't do DMA on stack
[67b0503db9c29b04eadfeede6bebbfe5ddad94ef]
Stefan Wahren (1):
serial: mxs-auart: fix baud rate range
[df57cf6a879502cd6e5559c1f2d6db12128e074f]
Steven Rostedt (1):
ring-buffer: Have ring_buffer_iter_empty() return true when empty
[78f7a45dac2a2d2002f98a3a95f7979867868d73]
T Makphaibulchoke (1):
x86/mm/init.c: Fix devmem_is_allowed() off by one
[73e8f3d7e2cb23614d5115703d76d8e54764b641]
Takashi Iwai (6):
ALSA: ctxfi: Fix the incorrect check of dma_set_mask() call
[f363a06642f28caaa78cb6446bbad90c73fe183c]
ALSA: seq: Don't break snd_use_lock_sync() loop by timeout
[4e7655fd4f47c23e5249ea260dc802f909a64611]
ALSA: seq: Fix race during FIFO resize
[2d7d54002e396c180db0c800c1046f0a3c471597]
ALSA: seq: Fix racy cell insertions during snd_seq_pool_done()
[c520ff3d03f0b5db7146d9beed6373ad5d2a5e0e]
ALSA: timer: Fix missing queue indices reset at SNDRV_TIMER_IOCTL_SELECT
[ba3021b2c79b2fa9114f92790a99deb27a65b728]
ALSA: timer: Fix race between read and ioctl
[d11662f4f798b50d8c8743f433842c3e40fe3378]
Thomas Gleixner (1):
x86/vdso: Plug race between mapping and ELF header setup
[6fdc6dd90272ce7e75d744f71535cfbd8d77da81]
Thomas Hellstrom (2):
drm/vmwgfx: Remove getparam error message
[53e16798b0864464c5444a204e1bb93ae246c429]
drm/vmwgfx: Type-check lookups of fence objects
[f7652afa8eadb416b23eb57dec6f158529942041]
Uwe Kleine-König (1):
serial: mxs-auart: Fix baudrate calculation
[a6040bc610554c66088fda3608ae5d6307c548e4]
Willy Tarreau (1):
char: lp: fix possible integer overflow in lp_setup()
[3e21f4af170bebf47c187c1ff8bf155583c9f3b1]
Yuejie Shi (1):
af_key: Add lock to key dump
[89e357d83c06b6fac581c3ca7f0ee3ae7e67109e]
Makefile | 4 +- arch/mips/kernel/kgdb.c | 48 +++++--- arch/powerpc/kernel/align.c | 27 +++-- arch/s390/boot/compressed/misc.c | 35 +++--- arch/x86/include/asm/elf.h | 2 +- arch/x86/kernel/ftrace.c | 12 ++ arch/x86/mm/init.c | 41 +++++-- arch/x86/pci/xen.c | 23 ++-- drivers/acpi/Makefile | 1 - drivers/acpi/apei/ghes.c | 1 + drivers/acpi/power.c | 2 +- drivers/block/xen-blkback/blkback.c | 23 ++-- drivers/block/xen-blkback/common.h | 19 +-- drivers/char/lp.c | 6 +- drivers/char/mem.c | 82 ++++++++----- drivers/gpu/drm/vmwgfx/vmwgfx_fence.c | 74 +++++++---- drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c | 4 +- drivers/hwmon/asus_atk0110.c | 3 + drivers/infiniband/hw/qib/qib_iba7322.c | 2 +- drivers/input/joystick/iforce/iforce-usb.c | 3 + drivers/input/misc/cm109.c | 4 + drivers/input/misc/yealink.c | 4 + drivers/input/serio/i8042-x86ia64io.h | 14 +++ drivers/input/tablet/hanwang.c | 3 + drivers/input/tablet/kbtab.c | 3 + drivers/isdn/gigaset/bas-gigaset.c | 3 + drivers/media/dvb/dvb-usb/dvb-usb-firmware.c | 33 +++-- drivers/mmc/host/sdhci.c | 10 +- drivers/mmc/host/ushc.c | 3 + drivers/mtd/ubi/upd.c | 8 +- drivers/net/ethernet/toshiba/tc35815.c | 2 +- drivers/net/phy/phy.c | 2 +- drivers/net/usb/cx82310_eth.c | 7 +- drivers/net/usb/smsc75xx.c | 8 +- drivers/net/wimax/i2400m/usb.c | 3 + drivers/scsi/aacraid/src.c | 2 +- drivers/scsi/libsas/sas_ata.c | 2 +- drivers/scsi/lpfc/lpfc_init.c | 1 + drivers/scsi/sd.c | 20 ++- drivers/scsi/sr.c | 6 +- drivers/target/iscsi/iscsi_target_parameters.c | 16 --- drivers/tty/serial/mxs-auart.c | 10 +- drivers/usb/class/usbtmc.c | 9 +- drivers/usb/core/config.c | 10 ++ drivers/usb/core/quirks.c | 8 ++ drivers/usb/dwc3/gadget.h | 14 +-- drivers/usb/gadget/f_acm.c | 4 +- drivers/usb/host/xhci.c | 56 +++++---- drivers/usb/misc/idmouse.c | 3 + drivers/usb/misc/iowarrior.c | 8 ++ drivers/usb/misc/uss720.c | 5 + drivers/usb/serial/io_ti.c | 6 + drivers/usb/serial/option.c | 17 ++- drivers/usb/serial/safe_serial.c | 5 + drivers/usb/wusbcore/wa-hc.c | 3 + drivers/uwb/hwa-rc.c | 3 + drivers/uwb/i1480/dfu/usb.c | 3 + drivers/video/xen-fbfront.c | 4 +- drivers/virtio/virtio_balloon.c | 4 + fs/exec.c | 28 ++++- include/linux/skbuff.h | 7 ++ include/linux/usb/quirks.h | 6 + include/trace/events/syscalls.h | 1 + kernel/events/core.c | 5 +- kernel/futex.c | 22 ++-- kernel/ptrace.c | 14 ++- kernel/sched.c | 4 +- kernel/trace/ring_buffer.c | 16 ++- net/9p/client.c | 4 + net/ipv4/ip_output.c | 2 +- net/ipv4/netfilter/nf_nat_snmp_basic.c | 19 +-- net/ipv6/ip6_output.c | 2 +- net/ipv6/route.c | 2 + net/key/af_key.c | 42 +++++-- net/l2tp/l2tp_core.c | 162 +++++++++++++++++++------ net/l2tp/l2tp_core.h | 9 +- net/l2tp/l2tp_debugfs.c | 10 +- net/l2tp/l2tp_eth.c | 10 +- net/l2tp/l2tp_ip.c | 17 ++- net/l2tp/l2tp_netlink.c | 46 ++++--- net/l2tp/l2tp_ppp.c | 94 +++++++------- net/mac80211/rx.c | 24 ++++ net/sched/act_csum.c | 8 +- net/sched/act_nat.c | 18 +-- net/sched/sch_dsmark.c | 10 +- net/unix/garbage.c | 18 +-- security/keys/gc.c | 2 +- sound/core/seq/seq_clientmgr.c | 1 + sound/core/seq/seq_fifo.c | 7 ++ sound/core/seq/seq_lock.c | 9 +- sound/core/seq/seq_memory.c | 17 ++- sound/core/seq/seq_memory.h | 1 + sound/core/timer.c | 7 +- sound/pci/ctxfi/cthw20k1.c | 2 +- tools/perf/util/symbol.c | 2 +- tools/power/cpupower/utils/helpers/cpuid.c | 1 + 96 files changed, 934 insertions(+), 453 deletions(-)
Signature · 2 lines
Ben Hutchings If the facts do not conform to your theory, they must be disposed of.
PATCH 1/95 xen: do not re-use pirq number cached in pci device msi msg data
3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dan Streetman <[email protected]>
commit c74fd80f2f41d05f350bb478151021f88551afe8 upstream.
Revert the main part of commit:af42b8d12f8a ("xen: fix MSI setup and teardown for PV on HVM guests")
That commit introduced reading the pci device's msi message data to see if a pirq was previously configured for the device's msi/msix, and re-use that pirq. At the time, that was the correct behavior. However, a later change to Qemu caused it to call into the Xen hypervisor to unmap all pirqs for a pci device, when the pci device disables its MSI/MSIX vectors; specifically the Qemu commit:c976437c7dba9c7444fb41df45468968aaa326ad
("qemu-xen: free all the pirqs for msi/msix when driver unload")
Once Qemu added this pirq unmapping, it was no longer correct for the kernel to re-use the pirq number cached in the pci device msi message data. All Qemu releases since 2.1.0 contain the patch that unmaps the pirqs when the pci device disables its MSI/MSIX vectors.
This bug is causing failures to initialize multiple NVMe controllers under Xen, because the NVMe driver sets up a single MSIX vector for each controller (concurrently), and then after using that to talk to the controller for some configuration data, it disables the single MSIX vector and re-configures all the MSIX vectors it needs. So the MSIX setup code tries to re-use the cached pirq from the first vector for each controller, but the hypervisor has already given away that pirq to another controller, and its initialization fails.
This is discussed in more detail at:
https://lists.xen.org/archives/html/xen-devel/2017-01/msg00447.html
--- arch/x86/pci/xen.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-)
arch/x86/pci/xen.c +7 -16
@@ -227,23 +227,14 @@ static int xen_hvm_setup_msi_irqs(structreturn 1 ;list_for_each_entry (msidesc, &dev->msi_list, list) { -__read_msi_msg (msidesc, &msg); - pirq =MSI_ADDR_EXT_DEST_ID (msg.address_hi) | - ((msg.address_lo >>MSI_ADDR_DEST_ID_SHIFT ) &0xff ); -if (msg.data !=XEN_PIRQ_MSI_DATA || -xen_irq_from_pirq (pirq) <0 ) { - pirq =xen_allocate_pirq_msi (dev, msidesc); -if (pirq <0 ) { - irq = -ENODEV ; - goto error; - } -xen_msi_compose_msg (dev, pirq, &msg); -__write_msi_msg (msidesc, &msg); -dev_dbg (&dev->dev,"xen: msi bound to pirq=%d\n" , pirq); - }else { -dev_dbg (&dev->dev, -"xen: msi already bound to pirq=%d\n" , pirq); + pirq =xen_allocate_pirq_msi (dev, msidesc); +if (pirq <0 ) { + irq = -ENODEV ; + goto error; } +xen_msi_compose_msg (dev, pirq, &msg); +__write_msi_msg (msidesc, &msg); +dev_dbg (&dev->dev,"xen: msi bound to pirq=%d\n" , pirq); irq = xen_bind_pirq_msi_to_irq(dev, msidesc, pirq, 0, (type == PCI_CAP_ID_MSIX) ? "msi-x" : "msi",
PATCH 2/95 tracing: Add #undef to fix compile error
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Rik van Riel <[email protected]>
commit bf7165cfa23695c51998231c4efa080fe1d3548d upstream.
There are several trace include files that define TRACE_INCLUDE_FILE.
Include several of them in the same .c file (as I currently have in some code I am working on), and the compile will blow up with a "warning: "TRACE_INCLUDE_FILE" redefined #define TRACE_INCLUDE_FILE syscalls"
Every other include file in include/trace/events/ avoids that issue by having a #undef TRACE_INCLUDE_FILE before the #define; syscalls.h should have one, too.
--- include/trace/events/syscalls.h | 1 + 1 file changed, 1 insertion(+)
include/trace/events/syscalls.h +1 -0
@@ -1,5 +1,6 @@#undef TRACE_SYSTEM#define TRACE_SYSTEM raw_syscalls +#undef TRACE_INCLUDE_FILE#define TRACE_INCLUDE_FILE syscalls#if !defined(_TRACE_EVENTS_SYSCALLS_H) || defined(TRACE_HEADER_MULTI_READ )
PATCH 3/95 usb: dwc3: gadget: make Set Endpoint Configuration macros safe
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Felipe Balbi <[email protected]>
commit 7369090a9fb57c3fc705ce355d2e4523a5a24716 upstream.
Some gadget drivers are bad, bad boys. We notice that ADB was passing bad Burst Size which caused top bits of param0 to be overwritten which confused DWC3 when running this command.
In order to avoid future issues, we're going to make sure values passed by macros are always safe for the controller. Note that ADB still needs a fix to *not* pass bad values.
--- drivers/usb/dwc3/gadget.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/usb/dwc3/gadget.h +7 -7
@@ -48,23 +48,23 @@ struct dwc3;#define gadget_to_dwc (g) (container_of(g, struct dwc3, gadget))/* DEPCFG parameter 1 */ -#define DWC3_DEPCFG_INT_NUM (n) ((n) << 0) +#define DWC3_DEPCFG_INT_NUM (n) (((n) & 0x1f) << 0)#define DWC3_DEPCFG_XFER_COMPLETE_EN (1 << 8)#define DWC3_DEPCFG_XFER_IN_PROGRESS_EN (1 << 9)#define DWC3_DEPCFG_XFER_NOT_READY_EN (1 << 10)#define DWC3_DEPCFG_FIFO_ERROR_EN (1 << 11)#define DWC3_DEPCFG_STREAM_EVENT_EN (1 << 13) -#define DWC3_DEPCFG_BINTERVAL_M1 (n) ((n) << 16) +#define DWC3_DEPCFG_BINTERVAL_M1 (n) (((n) & 0xff) << 16)#define DWC3_DEPCFG_STREAM_CAPABLE (1 << 24) -#define DWC3_DEPCFG_EP_NUMBER (n) ((n) << 25) +#define DWC3_DEPCFG_EP_NUMBER (n) (((n) & 0x1f) << 25)#define DWC3_DEPCFG_BULK_BASED (1 << 30)#define DWC3_DEPCFG_FIFO_BASED (1 << 31)/* DEPCFG parameter 0 */ -#define DWC3_DEPCFG_EP_TYPE (n) ((n) << 1) -#define DWC3_DEPCFG_MAX_PACKET_SIZE (n) ((n) << 3) -#define DWC3_DEPCFG_FIFO_NUMBER (n) ((n) << 17) -#define DWC3_DEPCFG_BURST_SIZE (n) ((n) << 22) +#define DWC3_DEPCFG_EP_TYPE (n) (((n) & 0x3) << 1) +#define DWC3_DEPCFG_MAX_PACKET_SIZE (n) (((n) & 0x7ff) << 3) +#define DWC3_DEPCFG_FIFO_NUMBER (n) (((n) & 0x1f) << 17) +#define DWC3_DEPCFG_BURST_SIZE (n) (((n) & 0xf) << 22)#define DWC3_DEPCFG_DATA_SEQ_NUM (n) ((n) << 26)#define DWC3_DEPCFG_IGN_SEQ_NUM (1 << 31)
PATCH 4/95 scsi: aacraid: Fix typo in blink status
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Raghava Aditya Renukunta <[email protected]>
commit 934767c56b0d9dbb95a40e9e6e4d9dcdc3a165ad upstream.
The return status of the adapter check on KERNEL_PANIC is supposed to be the upper 16 bits of the OMR status register.
--- drivers/scsi/aacraid/src.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/aacraid/src.c +1 -1
@@ -348,7 +348,7 @@ err_out:return -1 ; err_blink: -return (status >16 ) &0xFF ; +return (status >>16 ) &0xFF ; }/**
PATCH 5/95 Input: i8042 - add noloop quirk for Dell Embedded Box PC 3000
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Kai-Heng Feng <[email protected]>
commit 45838660e34d90db8d4f7cbc8fd66e8aff79f4fe upstream.
The aux port does not get detected without noloop quirk, so external PS/2 mouse cannot work as result.
The PS/2 mouse can work with this quirk.
--- drivers/input/serio/i8042-x86ia64io.h | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/input/serio/i8042-x86ia64io.h +7 -0
@@ -120,6 +120,13 @@ static const struct dmi_system_id __init }, }, { +/* Dell Embedded Box PC 3000 */ + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Dell Inc." ), + DMI_MATCH(DMI_PRODUCT_NAME, "Embedded Box PC 3000"), + }, + }, + {/* OQO Model 01 */ .matches = { DMI_MATCH(DMI_SYS_VENDOR, "OQO"),
PATCH 6/95 scsi: lpfc: Add shutdown method for kexec
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Anton Blanchard <[email protected]>
commit 85e8a23936ab3442de0c42da97d53b29f004ece1 upstream.
We see lpfc devices regularly fail during kexec. Fix this by adding a shutdown method which mirrors the remove method.
--- drivers/scsi/lpfc/lpfc_init.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/lpfc/lpfc_init.c +1 -0
@@ -10002,6 +10002,7 @@ static struct pci_driver lpfc_driver = { .id_table = lpfc_id_table, .probe = lpfc_pci_probe_one, .remove = __devexit_p(lpfc_pci_remove_one), + .shutdown = lpfc_pci_remove_one, .suspend = lpfc_pci_suspend_one, .resume = lpfc_pci_resume_one, .err_handler = &lpfc_err_handler,
PATCH 7/95 USB: serial: io_ti: fix NULL-deref in interrupt callback
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 0b1d250afb8eb9d65afb568bac9b9f9253a82b49 upstream.
Fix a NULL-pointer dereference in the interrupt callback should a malicious device send data containing a bad port number by adding the missing sanity check.
[bwh: Backported to 3.2:
- Use &urb->dev->dev instead of local dev variable
- Adjust context]
--- drivers/usb/serial/io_ti.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/usb/serial/io_ti.c +6 -0
@@ -1681,6 +1681,12 @@ static void edge_interrupt_callback(stru function =TIUMP_GET_FUNC_FROM_CODE (data[0 ]);dbg ("%s - port_number %d, function %d, info 0x%x" , __func__, port_number, function, data[1 ]); + +if (port_number >= edge_serial->serial->num_ports) { +dev_err (&urb->dev->dev,"bad port number %d\n" , port_number); + goto exit; + } + port = edge_serial->serial->port[port_number]; edge_port =usb_get_serial_port_data (port);if (!edge_port) {
PATCH 8/95 USB: serial: safe_serial: fix information leak in completion handler
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 8c76d7cd520ebffc1ea9ea0850d87a224a50c7f2 upstream.
Add missing sanity check to the bulk-in completion handler to avoid an integer underflow that could be triggered by a malicious device.
This avoids leaking up to 56 bytes from after the URB transfer buffer to user space.
--- drivers/usb/serial/safe_serial.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/usb/serial/safe_serial.c +5 -0
@@ -232,6 +232,11 @@ static void safe_process_read_urb(structif (!safe) goto out; +if (length <2 ) { +dev_err (&port->dev,"malformed packet\n" ); +return ; + } + fcs =fcs_compute10 (data, length,CRC10_INITFCS );if (fcs) {dev_err (&port->dev,"%s - bad CRC %x\n" , __func__, fcs);
PATCH 9/95 dvb-usb: don't use stack for firmware load
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Mauro Carvalho Chehab <[email protected]>
commit 43fab9793c1f44e665b4f98035a14942edf03ddc upstream.
As reported by Marc Duponcheel <[email protected]>, firmware load on dvb-usb is using the stack, with is not allowed anymore on default Kernel configurations:
[ 1025.958836] dvb-usb: found a 'WideView WT-220U PenType Receiver (based on ZL353)' in cold state, will try to load a firmware [ 1025.958853] dvb-usb: downloading firmware from file 'dvb-usb-wt220u-zl0353-01.fw' [ 1025.958855] dvb-usb: could not stop the USB controller CPU. [ 1025.958856] dvb-usb: error while transferring firmware (transferred size: -11, block size: 3) [ 1025.958856] dvb-usb: firmware download failed at 8 with -22 [ 1025.958867] usbcore: registered new interface driver dvb_usb_dtt200u
[ 2.789902] dvb-usb: downloading firmware from file 'dvb-usb-wt220u-zl0353-01.fw' [ 2.789905] ------------[ cut here ]------------ [ 2.789911] WARNING: CPU: 3 PID: 2196 at drivers/usb/core/hcd.c:1584 usb_hcd_map_urb_for_dma+0x430/0x560 [usbcore] [ 2.789912] transfer buffer not dma capable [ 2.789912] Modules linked in: btusb dvb_usb_dtt200u(+) dvb_usb_af9035(+) btrtl btbcm dvb_usb dvb_usb_v2 btintel dvb_core bluetooth rc_core rfkill x86_pkg_temp_thermal intel_powerclamp coretemp crc32_pclmul aesni_intel aes_x86_64 glue_helper lrw gf128mul ablk_helper cryptd drm_kms_helper syscopyarea sysfillrect pcspkr i2c_i801 sysimgblt fb_sys_fops drm i2c_smbus i2c_core r8169 lpc_ich mfd_core mii thermal fan rtc_cmos video button acpi_cpufreq processor snd_hda_codec_realtek snd_hda_codec_generic snd_hda_intel snd_hda_codec snd_hwdep snd_hda_core snd_pcm snd_timer snd crc32c_intel ahci libahci libata xhci_pci ehci_pci xhci_hcd ehci_hcd usbcore usb_common dm_mirror dm_region_hash dm_log dm_mod [ 2.789936] CPU: 3 PID: 2196 Comm: systemd-udevd Not tainted 4.9.0-gentoo #1 [ 2.789937] Hardware name: ASUS All Series/H81I-PLUS, BIOS 0401 07/23/2013 [ 2.789938] ffffc9000339b690 ffffffff812bd397 ffffc9000339b6e0 0000000000000000 [ 2.789939] ffffc9000339b6d0 ffffffff81055c86 000006300339b6a0 ffff880116c0c000 [ 2.789941] 0000000000000000 0000000000000000 0000000000000001 ffff880116c08000 [ 2.789942] Call Trace: [ 2.789945] [<ffffffff812bd397>] dump_stack+0x4d/0x66 [ 2.789947] [<ffffffff81055c86>] __warn+0xc6/0xe0 [ 2.789948] [<ffffffff81055cea>] warn_slowpath_fmt+0x4a/0x50 [ 2.789952] [<ffffffffa006d460>] usb_hcd_map_urb_for_dma+0x430/0x560 [usbcore] [ 2.789954] [<ffffffff814ed5a8>] ? io_schedule_timeout+0xd8/0x110 [ 2.789956] [<ffffffffa006e09c>] usb_hcd_submit_urb+0x9c/0x980 [usbcore] [ 2.789958] [<ffffffff812d0ebf>] ? copy_page_to_iter+0x14f/0x2b0 [ 2.789960] [<ffffffff81126818>] ? pagecache_get_page+0x28/0x240 [ 2.789962] [<ffffffff8118c2a0>] ? touch_atime+0x20/0xa0 [ 2.789964] [<ffffffffa006f7c4>] usb_submit_urb+0x2c4/0x520 [usbcore] [ 2.789967] [<ffffffffa006feca>] usb_start_wait_urb+0x5a/0xe0 [usbcore] [ 2.789969] [<ffffffffa007000c>] usb_control_msg+0xbc/0xf0 [usbcore] [ 2.789970] [<ffffffffa067903d>] usb_cypress_writemem+0x3d/0x40 [dvb_usb] [ 2.789972] [<ffffffffa06791cf>] usb_cypress_load_firmware+0x4f/0x130 [dvb_usb] [ 2.789973] [<ffffffff8109dbbe>] ? console_unlock+0x2fe/0x5d0 [ 2.789974] [<ffffffff8109e10c>] ? vprintk_emit+0x27c/0x410 [ 2.789975] [<ffffffff8109e40a>] ? vprintk_default+0x1a/0x20 [ 2.789976] [<ffffffff81124d76>] ? printk+0x43/0x4b [ 2.789977] [<ffffffffa0679310>] dvb_usb_download_firmware+0x60/0xd0 [dvb_usb] [ 2.789979] [<ffffffffa0679898>] dvb_usb_device_init+0x3d8/0x610 [dvb_usb] [ 2.789981] [<ffffffffa069e302>] dtt200u_usb_probe+0x92/0xd0 [dvb_usb_dtt200u] [ 2.789984] [<ffffffffa007420c>] usb_probe_interface+0xfc/0x270 [usbcore] [ 2.789985] [<ffffffff8138bf95>] driver_probe_device+0x215/0x2d0 [ 2.789986] [<ffffffff8138c0e6>] __driver_attach+0x96/0xa0 [ 2.789987] [<ffffffff8138c050>] ? driver_probe_device+0x2d0/0x2d0 [ 2.789988] [<ffffffff81389ffb>] bus_for_each_dev+0x5b/0x90 [ 2.789989] [<ffffffff8138b7b9>] driver_attach+0x19/0x20 [ 2.789990] [<ffffffff8138b33c>] bus_add_driver+0x11c/0x220 [ 2.789991] [<ffffffff8138c91b>] driver_register+0x5b/0xd0 [ 2.789994] [<ffffffffa0072f6c>] usb_register_driver+0x7c/0x130 [usbcore] [ 2.789994] [<ffffffffa06a5000>] ? 0xffffffffa06a5000 [ 2.789996] [<ffffffffa06a501e>] dtt200u_usb_driver_init+0x1e/0x20 [dvb_usb_dtt200u] [ 2.789997] [<ffffffff81000408>] do_one_initcall+0x38/0x140 [ 2.789998] [<ffffffff8116001c>] ? __vunmap+0x7c/0xc0 [ 2.789999] [<ffffffff81124fb0>] ? do_init_module+0x22/0x1d2 [ 2.790000] [<ffffffff81124fe8>] do_init_module+0x5a/0x1d2 [ 2.790002] [<ffffffff810c96b1>] load_module+0x1e11/0x2580 [ 2.790003] [<ffffffff810c68b0>] ? show_taint+0x30/0x30 [ 2.790004] [<ffffffff81177250>] ? kernel_read_file+0x100/0x190 [ 2.790005] [<ffffffff810c9ffa>] SyS_finit_module+0xba/0xc0 [ 2.790007] [<ffffffff814f13e0>] entry_SYSCALL_64_fastpath+0x13/0x94 [ 2.790008] ---[ end trace c78a74e78baec6fc ]---
So, allocate the structure dynamically.
--- drivers/media/dvb/dvb-usb/dvb-usb-firmware.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
drivers/media/dvb/dvb-usb/dvb-usb-firmware.c +13 -6
@@ -35,29 +35,34 @@ static int usb_cypress_writemem(struct uint usb_cypress_load_firmware (struct usb_device *udev,const struct firmware *fw,int type) { -struct hexline hx; +struct hexline *hx;u8 reset;int ret,pos=0 ; + hx =kmalloc (sizeof (*hx),GFP_KERNEL ); +if (!hx) +return -ENOMEM ; +/* stop the CPU */ reset =1 ;if ((ret =usb_cypress_writemem (udev,cypress[type].cpu_cs_register,&reset,1 )) !=1 )err ("could not stop the USB controller CPU." ); -while ((ret =dvb_usb_get_hexline (fw,&hx,&pos)) >0 ) { -deb_fw ("writing to address 0x%04x (buffer: 0x%02x %02x)\n" ,hx.addr,hx.len,hx.chk); - ret =usb_cypress_writemem (udev,hx.addr,hx.data,hx.len); +while ((ret =dvb_usb_get_hexline (fw, hx, &pos)) >0 ) { +deb_fw ("writing to address 0x%04x (buffer: 0x%02x %02x)\n" , hx->addr, hx->len, hx->chk); + ret =usb_cypress_writemem (udev, hx->addr, hx->data, hx->len); -if (ret != hx.len) { +if (ret != hx->len) {err ("error while transferring firmware " "(transferred size: %d, block size: %d)" , - ret,hx.len); + ret, hx->len); ret = -EINVAL ;break ; } }if (ret <0 ) {err ("firmware download failed at %d with %d" ,pos,ret); +kfree (hx);return ret; }
@@ -71,6 +76,8 @@ int usb_cypress_load_firmware(struct usb }else ret = -EIO ; +kfree (hx); +return ret; }EXPORT_SYMBOL (usb_cypress_load_firmware);
PATCH 10/95 dvb-usb-firmware: don't do DMA on stack
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Brüns <[email protected]>
commit 67b0503db9c29b04eadfeede6bebbfe5ddad94ef upstream.
The buffer allocation for the firmware data was changed in commit 43fab9793c1f ("[media] dvb-usb: don't use stack for firmware load") but the same applies for the reset value.
--- drivers/media/dvb/dvb-usb/dvb-usb-firmware.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
drivers/media/dvb/dvb-usb/dvb-usb-firmware.c +12 -10
@@ -36,16 +36,18 @@ static int usb_cypress_writemem(struct uint usb_cypress_load_firmware (struct usb_device *udev,const struct firmware *fw,int type) {struct hexline *hx; -u8 reset; -int ret,pos=0 ; +u8 *buf; +int ret, pos =0 ; +u16 cpu_cs_register = cypress[type].cpu_cs_register; - hx =kmalloc (sizeof (*hx),GFP_KERNEL ); -if (!hx) + buf =kmalloc (sizeof (*hx),GFP_KERNEL ); +if (!buf)return -ENOMEM ; + hx = (struct hexline *)buf;/* stop the CPU */ - reset =1 ; -if ((ret =usb_cypress_writemem (udev,cypress[type].cpu_cs_register,&reset,1 )) !=1 ) + buf[0 ] =1 ; +if (usb_cypress_writemem (udev, cpu_cs_register, buf,1 ) !=1 )err ("could not stop the USB controller CPU." );while ((ret =dvb_usb_get_hexline (fw, hx, &pos)) >0 ) {
@@ -62,21 +64,21 @@ int usb_cypress_load_firmware(struct usb }if (ret <0 ) {err ("firmware download failed at %d with %d" ,pos,ret); -kfree (hx); +kfree (buf);return ret; }if (ret ==0 ) {/* restart the CPU */ - reset =0 ; -if (ret ||usb_cypress_writemem (udev,cypress[type].cpu_cs_register,&reset,1 ) !=1 ) { + buf[0 ] =0 ; +if (usb_cypress_writemem (udev, cpu_cs_register, buf,1 ) !=1 ) {err ("could not restart the USB controller CPU." ); ret = -EINVAL ; } }else ret = -EIO ; -kfree (hx); +kfree (buf);return ret; }
PATCH 11/95 USB: iowarrior: fix NULL-deref in write
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit de46e56653de7b3b54baa625bd582635008b8d05 upstream.
Make sure to verify that we have the required interrupt-out endpoint for IOWarrior56 devices to avoid dereferencing a NULL-pointer in write should a malicious device lack such an endpoint.
--- drivers/usb/misc/iowarrior.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/usb/misc/iowarrior.c +8 -0
@@ -809,6 +809,14 @@ static int iowarrior_probe(struct usb_in goto error; } +if (dev->product_id ==USB_DEVICE_ID_CODEMERCS_IOW56 ) { +if (!dev->int_out_endpoint) { +dev_err (&interface->dev,"no interrupt-out endpoint found\n" ); + retval = -ENODEV ; + goto error; + } + } +/* we have to check the report_size often, so remember it in the endianess suitable for our machine */ dev->report_size =usb_endpoint_maxp (dev->int_in_endpoint); if ((dev->interface->cur_altsetting->desc.bInterfaceNumber == 0) &&
PATCH 12/95 udp: avoid ufo handling on IP payload compression packets
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Alexey Kodanev <[email protected]>
commit 4b3b45edba9222e518a1ec72df841eba3609fe34 upstream.
commit c146066ab802 ("ipv4: Don't use ufo handling on later transformed packets") and commit f89c56ce710a ("ipv6: Don't use ufo handling on later transformed packets") added a check that 'rt->dst.header_len' isn't zero in order to skip UFO, but it doesn't include IPcomp in transport mode where it equals zero.
Packets, after payload compression, may not require further fragmentation, and if original length exceeds MTU, later compressed packets will be transmitted incorrectly. This can be reproduced with LTP udp_ipsec.sh test on veth device with enabled UFO, MTU is 1500 and UDP payload is 2000:
* IPv4 case, offset is wrong + unnecessary fragmentation
udp_ipsec.sh -p comp -m transport -s 2000 &
tcpdump -ni ltp_ns_veth2
...
IP (tos 0x0, ttl 64, id 45203, offset 0, flags [+],
proto Compressed IP (108), length 49)
10.0.0.2 > 10.0.0.1: IPComp(cpi=0x1000)
IP (tos 0x0, ttl 64, id 45203, offset 1480, flags [none],
proto UDP (17), length 21) 10.0.0.2 > 10.0.0.1: ip-proto-17* IPv6 case, sending small fragments
udp_ipsec.sh -6 -p comp -m transport -s 2000 &
tcpdump -ni ltp_ns_veth2
...
IP6 (flowlabel 0x6b9ba, hlim 64, next-header Compressed IP (108)
payload length: 37) fd00::2 > fd00::1: IPComp(cpi=0x1000)
IP6 (flowlabel 0x6b9ba, hlim 64, next-header Compressed IP (108)
payload length: 21) fd00::2 > fd00::1: IPComp(cpi=0x1000)Fix it by checking 'rt->dst.xfrm' pointer to 'xfrm_state' struct, skip UFO if xfrm is set. So the new check will include both cases: IPcomp and IPsec.
--- net/ipv4/ip_output.c | 2 +- net/ipv6/ip6_output.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
net/ipv4/ip_output.c +1 -1
@@ -834,7 +834,7 @@ static int __ip_append_data(struct sock cork->length += length;if (((length > mtu) || (skb &&skb_has_frags (skb))) && (sk->sk_protocol ==IPPROTO_UDP ) && - (rt->dst.dev->features &NETIF_F_UFO ) && !rt->dst.header_len && + (rt->dst.dev->features &NETIF_F_UFO ) && !dst_xfrm (&rt->dst) && (sk->sk_type ==SOCK_DGRAM )) { err = ip_ufo_append_data(sk, queue, getfrag, from, length, hh_len, fragheaderlen, transhdrlen,
net/ipv6/ip6_output.c +1 -1
@@ -1343,7 +1343,7 @@ int ip6_append_data(struct sock *sk, intif (((length > mtu) || (skb &&skb_has_frags (skb))) && (sk->sk_protocol ==IPPROTO_UDP ) && - (rt->dst.dev->features &NETIF_F_UFO ) && !rt->dst.header_len && + (rt->dst.dev->features &NETIF_F_UFO ) && !dst_xfrm (&rt->dst) && (sk->sk_type ==SOCK_DGRAM )) { err = ip6_ufo_append_data(sk, getfrag, from, length, hh_len, fragheaderlen, exthdrlen,
PATCH 13/95 isdn/gigaset: fix NULL-deref at probe
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 68c32f9c2a36d410aa242e661506e5b2c2764179 upstream.
Make sure to check the number of endpoints to avoid dereferencing a NULL-pointer should a malicious device lack endpoints.
direct USB connection")
Cc: Hansjoerg Lipp <[email protected]>
--- drivers/isdn/gigaset/bas-gigaset.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/isdn/gigaset/bas-gigaset.c +3 -0
@@ -2314,6 +2314,9 @@ static int gigaset_probe(struct usb_intereturn -ENODEV ; } +if (hostif->desc.bNumEndpoints <1 ) +return -ENODEV ; + dev_info(&udev->dev, "%s: Device matched (Vendor: 0x%x, Product: 0x%x)\n", __func__, le16_to_cpu(udev->descriptor.idVendor),
PATCH 14/95 net: wimax/i2400m: fix NULL-deref at probe
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 6e526fdff7be4f13b24f929a04c0e9ae6761291e upstream.
Make sure to check the number of endpoints to avoid dereferencing a NULL-pointer or accessing memory beyond the endpoint array should a malicious device lack the expected endpoints.
The endpoints are specifically dereferenced in the i2400m_bootrom_init path during probe (e.g. in i2400mu_tx_bulk_out).
and reset backends")
Cc: Inaky Perez-Gonzalez <[email protected]>
--- drivers/net/wimax/i2400m/usb.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wimax/i2400m/usb.c +3 -0
@@ -449,6 +449,9 @@ int i2400mu_probe(struct usb_interface *struct i2400mu *i2400mu;struct usb_device *usb_dev =interface_to_usbdev (iface); +if (iface->cur_altsetting->desc.bNumEndpoints <4 ) +return -ENODEV ; +if (usb_dev->speed !=USB_SPEED_HIGH )dev_err (dev,"device not connected as high speed\n" );
PATCH 15/95 USB: idmouse: fix NULL-deref at probe
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit b0addd3fa6bcd119be9428996d5d4522479ab240 upstream.
Make sure to check the number of endpoints to avoid dereferencing a NULL-pointer should a malicious device lack endpoints.
--- drivers/usb/misc/idmouse.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/misc/idmouse.c +3 -0
@@ -346,6 +346,9 @@ static int idmouse_probe(struct usb_inteif (iface_desc->desc.bInterfaceClass !=0x0A )return -ENODEV ; +if (iface_desc->desc.bNumEndpoints <1 ) +return -ENODEV ; +/* allocate memory for our device state and initialize it */ dev =kzalloc (sizeof (*dev),GFP_KERNEL );if (dev ==NULL )
PATCH 16/95 USB: uss720: fix NULL-deref at probe
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit f259ca3eed6e4b79ac3d5c5c9fb259fb46e86217 upstream.
Make sure to check the number of endpoints to avoid dereferencing a NULL-pointer or accessing memory beyond the endpoint array should a malicious device lack the expected endpoints.
Note that the endpoint access that causes the NULL-deref is currently only used for debugging purposes during probe so the oops only happens when dynamic debugging is enabled. This means the driver could be rewritten to continue to accept device with only two endpoints, should such devices exist.
--- drivers/usb/misc/uss720.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/usb/misc/uss720.c +5 -0
@@ -704,6 +704,11 @@ static int uss720_probe(struct usb_inter interface = intf->cur_altsetting; +if (interface->desc.bNumEndpoints <3 ) { +usb_put_dev (usbdev); +return -ENODEV ; + } +/* * Allocate parport interface */
PATCH 17/95 USB: wusbcore: fix NULL-deref at probe
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 03ace948a4eb89d1cf51c06afdfc41ebca5fdb27 upstream.
Make sure to check the number of endpoints to avoid dereferencing a NULL-pointer or accessing memory beyond the endpoint array should a malicious device lack the expected endpoints.
This specifically fixes the NULL-pointer dereference when probing HWA HC devices.
--- drivers/usb/wusbcore/wa-hc.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/wusbcore/wa-hc.c +3 -0
@@ -38,6 +38,9 @@ int wa_create(struct wahc *wa, struct usint result;struct device *dev = &iface->dev; +if (iface->cur_altsetting->desc.bNumEndpoints <3 ) +return -ENODEV ; + result =wa_rpipes_create (wa);if (result <0 ) goto error_rpipes_create;
PATCH 18/95 uwb: hwa-rc: fix NULL-deref at probe
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit daf229b15907fbfdb6ee183aac8ca428cb57e361 upstream.
Make sure to check the number of endpoints to avoid dereferencing a NULL-pointer should a malicious device lack endpoints.
Note that the dereference happens in the start callback which is called during probe.
--- drivers/uwb/hwa-rc.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/uwb/hwa-rc.c +3 -0
@@ -811,6 +811,9 @@ static int hwarc_probe(struct usb_interfstruct hwarc *hwarc;struct device *dev = &iface->dev; +if (iface->cur_altsetting->desc.bNumEndpoints <1 ) +return -ENODEV ; + result = -ENOMEM ; uwb_rc =uwb_rc_alloc ();if (uwb_rc ==NULL ) {
PATCH 19/95 uwb: i1480-dfu: fix NULL-deref at probe
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 4ce362711d78a4999011add3115b8f4b0bc25e8c upstream.
Make sure to check the number of endpoints to avoid dereferencing a NULL-pointer should a malicious device lack endpoints.
Note that the dereference happens in the cmd and wait_init_done callbacks which are called during probe.
--- drivers/uwb/i1480/dfu/usb.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/uwb/i1480/dfu/usb.c +3 -0
@@ -362,6 +362,9 @@ int i1480_usb_probe(struct usb_interface result); } +if (iface->cur_altsetting->desc.bNumEndpoints <1 ) +return -ENODEV ; + result = -ENOMEM ; i1480_usb =kzalloc (sizeof (*i1480_usb),GFP_KERNEL );if (i1480_usb ==NULL ) {
PATCH 20/95 usb-core: Add LINEAR_FRAME_INTR_BINTERVAL USB quirk
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Samuel Thibault <[email protected]>
commit 3243367b209faed5c320a4e5f9a565ee2a2ba958 upstream.
Some USB 2.0 devices erroneously report millisecond values in bInterval. The generic config code manages to catch most of them, but in some cases it's not completely enough.
The case at stake here is a USB 2.0 braille device, which wants to announce 10ms and thus sets bInterval to 10, but with the USB 2.0 computation that yields to 64ms. It happens that one can type fast enough to reach this interval and get the device buffers overflown, leading to problematic latencies. The generic config code does not catch this case because the 64ms is considered a sane enough value.
This change thus adds a USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL quirk to mark devices which actually report milliseconds in bInterval, and marks Vario Ultra devices as needing it.
--- drivers/usb/core/config.c | 10 ++++++++++ drivers/usb/core/quirks.c | 8 ++++++++ include/linux/usb/quirks.h | 6 ++++++ 3 files changed, 24 insertions(+)
drivers/usb/core/config.c +10 -0
@@ -247,6 +247,16 @@ static int usb_parse_endpoint(struct dev/* * Adjust bInterval for quirked devices. +*/ +/* +* This quirk fixes bIntervals reported in ms. +*/ +if (to_usb_device (ddev)->quirks & +USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL ) { + n =clamp (fls (d->bInterval) +3 , i, j); + i = j = n; + } +/* * This quirk fixes bIntervals reported in * linear microframes. */
drivers/usb/core/quirks.c +8 -0
@@ -147,6 +147,14 @@ static const struct usb_device_id usb_qu/* M-Systems Flash Disk Pioneers */ { USB_DEVICE(0x08ec, 0x1000), .driver_info = USB_QUIRK_RESET_RESUME }, + /* Baum Vario Ultra */ + { USB_DEVICE(0x0904, 0x6101), .driver_info = + USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL }, + { USB_DEVICE(0x0904, 0x6102), .driver_info = + USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL }, + { USB_DEVICE(0x0904, 0x6103), .driver_info = + USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL }, + /* Keytouch QWERTY Panel keyboard */ { USB_DEVICE(0x0926, 0x3333), .driver_info = USB_QUIRK_CONFIG_INTF_STRINGS },
include/linux/usb/quirks.h +6 -0
@@ -44,4 +44,10 @@/* device generates spurious wakeup, ignore remote wakeup capability */ #define USB_QUIRK_IGNORE_REMOTE_WAKEUP 0x00000200 +/* +* Device reports its bInterval as linear frames instead of the +* USB 2.0 calculation. +*/ +#define USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL BIT(11) +#endif /* __LINUX_USB_QUIRKS_H */
PATCH 21/95 USB: serial: option: add Quectel UC15, UC20, EC21, and EC25 modems
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dan Williams <[email protected]>
commit 6e9f44eaaef0df7b846e9316fa9ca72a02025d44 upstream.
Add Quectel UC15, UC20, EC21, and EC25. The EC20 is handled by qcserial due to a USB VID/PID conflict with an existing Acer device.
--- drivers/usb/serial/option.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/usb/serial/option.c +16 -1
@@ -234,6 +234,14 @@ static void option_instat_callback(struc#define BANDRICH_PRODUCT_1012 0x1012#define QUALCOMM_VENDOR_ID 0x05C6 +/* These Quectel products use Qualcomm's vendor ID */ +#define QUECTEL_PRODUCT_UC20 0x9003 +#define QUECTEL_PRODUCT_UC15 0x9090 + +#define QUECTEL_VENDOR_ID 0x2c7c +/* These Quectel products use Quectel's vendor ID */ +#define QUECTEL_PRODUCT_EC21 0x0121 +#define QUECTEL_PRODUCT_EC25 0x0125#define CMOTECH_VENDOR_ID 0x16d8#define CMOTECH_PRODUCT_6001 0x6001
@@ -1147,7 +1155,14 @@ static const struct usb_device_id option { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */ { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x0023)}, /* ONYX 3G device */ { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x9000)}, /* SIMCom SIM5218 */ - { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x9003), /* Quectel UC20 */ +/* Quectel products using Qualcomm vendor ID */ + { USB_DEVICE(QUALCOMM_VENDOR_ID, QUECTEL_PRODUCT_UC15)}, + { USB_DEVICE(QUALCOMM_VENDOR_ID, QUECTEL_PRODUCT_UC20), + .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, +/* Quectel products using Quectel vendor ID */ + { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC21), + .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, + { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC25), .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6001) }, { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CMU_300) },
PATCH 22/95 futex: Fix potential use-after-free in FUTEX_REQUEUE_PI
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Peter Zijlstra <[email protected]>
commit c236c8e95a3d395b0494e7108f0d41cf36ec107c upstream.
While working on the futex code, I stumbled over this potential use-after-free scenario. Dmitry triggered it later with syzkaller.
pi_mutex is a pointer into pi_state, which we drop the reference on in unqueue_me_pi(). So any access to that pointer after that is bad.
Since other sites already do rt_mutex_unlock() with hb->lock held, see for example futex_lock_pi(), simply move the unlock before unqueue_me_pi().
--- kernel/futex.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
kernel/futex.c +11 -9
@@ -2410,7 +2410,6 @@ static int futex_wait_requeue_pi(u32 __u {struct hrtimer_sleeper timeout, *to =NULL ;struct rt_mutex_waiter rt_waiter; -struct rt_mutex *pi_mutex =NULL ;struct futex_hash_bucket *hb;union futex_key key2 =FUTEX_KEY_INIT ;struct futex_q q = futex_q_init;
@@ -2500,6 +2499,8 @@ static int futex_wait_requeue_pi(u32 __uspin_unlock (q.lock_ptr); } }else { +struct rt_mutex *pi_mutex; +/* * We have been woken up by futex_unlock_pi(), a timeout, or a * signal. futex_unlock_pi() will not destroy the lock_ptr nor
@@ -2523,18 +2524,19 @@ static int futex_wait_requeue_pi(u32 __uif (res) ret = (res <0 ) ? res :0 ; +/* +* If fixup_pi_state_owner() faulted and was unable to handle +* the fault, unlock the rt_mutex and return the fault to +* userspace. +*/ +if (ret &&rt_mutex_owner (pi_mutex) == current) +rt_mutex_unlock (pi_mutex); +/* Unqueue and drop the lock. */ unqueue_me_pi (&q); } -/* -* If fixup_pi_state_owner() faulted and was unable to handle the -* fault, unlock the rt_mutex and return the fault to userspace. -*/ -if (ret == -EFAULT ) { -if (pi_mutex &&rt_mutex_owner (pi_mutex) == current) -rt_mutex_unlock (pi_mutex); - }else if (ret == -EINTR ) { +if (ret == -EINTR ) {/* * We've already been requeued, but cannot restart by calling * futex_lock_pi() directly. We could restart this syscall, but
PATCH 23/95 futex: Add missing error handling to FUTEX_REQUEUE_PI
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Peter Zijlstra <[email protected]>
commit 9bbb25afeb182502ca4f2c4f3f88af0681b34cae upstream.
Thomas spotted that fixup_pi_state_owner() can return errors and we fail to unlock the rt_mutex in that case.
--- kernel/futex.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/futex.c +2 -0
@@ -2491,6 +2491,8 @@ static int futex_wait_requeue_pi(u32 __uif (q.pi_state && (q.pi_state->owner != current)) {spin_lock (q.lock_ptr); ret =fixup_pi_state_owner (uaddr2, &q, current); +if (ret &&rt_mutex_owner (&q.pi_state->pi_mutex) == current) +rt_mutex_unlock (&q.pi_state->pi_mutex);/* * Drop the reference to the pi state which * the requeue_pi() code acquired for us.
PATCH 24/95 sched/loadavg: Avoid loadavg spikes caused by delayed NO_HZ accounting
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Matt Fleming <[email protected]>
commit 6e5f32f7a43f45ee55c401c0b9585eb01f9629a8 upstream.
If we crossed a sample window while in NO_HZ we will add LOAD_FREQ to the pending sample window time on exit, setting the next update not one window into the future, but two.
This situation on exiting NO_HZ is described by:
this_rq->calc_load_update < jiffies < calc_load_update
In this scenario, what we should be doing is:
this_rq->calc_load_update = calc_load_update [ next window ]
But what we actually do is:
this_rq->calc_load_update = calc_load_update + LOAD_FREQ [ next+1 window ]
This has the effect of delaying load average updates for potentially up to ~9seconds.
This can result in huge spikes in the load average values due to per-cpu uninterruptible task counts being out of sync when accumulated across all CPUs.
It's safe to update the per-cpu active count if we wake between sample windows because any load that we left in 'calc_load_idle' will have been zero'd when the idle load was folded in calc_global_load().
This issue is easy to reproduce before,
commit 9d89c257dfb9 ("sched/fair: Rewrite runnable load and utilization average tracking")
just by forking short-lived process pipelines built from ps(1) and grep(1) in a loop. I'm unable to reproduce the spikes after that commit, but the bug still seems to be present from code review.
--- kernel/sched.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/sched.c +2 -2
@@ -3617,8 +3617,9 @@ void calc_load_exit_idle(void)struct rq *this_rq =this_rq ();/* -* If we're still before the sample window, we're done. +* If we're still before the pending sample window, we're done. */ + this_rq->calc_load_update = calc_load_update;if (time_before (jiffies, this_rq->calc_load_update))return ;
@@ -3627,7 +3628,6 @@ void calc_load_exit_idle(void)* accounted through the nohz accounting, so skip the entire deal and * sync up for the next window. */ - this_rq->calc_load_update = calc_load_update;if (time_before (jiffies, this_rq->calc_load_update +10 )) this_rq->calc_load_update +=LOAD_FREQ ; }
PATCH 25/95 perf/core: Fix event inheritance on fork()
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Peter Zijlstra <[email protected]>
commit e7cc4865f0f31698ef2f7aac01a50e78968985b7 upstream.
While hunting for clues to a use-after-free, Oleg spotted that perf_event_init_context() can loose an error value with the result that fork() can succeed even though we did not fully inherit the perf event context.
--- kernel/events/core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/events/core.c +3 -2
@@ -7273,7 +7273,7 @@ int perf_event_init_context(struct task_ ret =inherit_task_group (event, parent, parent_ctx, child, ctxn, &inherited_all);if (ret) -break ; + goto out_unlock; }/*
@@ -7289,7 +7289,7 @@ int perf_event_init_context(struct task_ ret =inherit_task_group (event, parent, parent_ctx, child, ctxn, &inherited_all);if (ret) -break ; + goto out_unlock; }raw_spin_lock_irqsave (&parent_ctx->lock, flags);
@@ -7317,6 +7317,7 @@ int perf_event_init_context(struct task_ }raw_spin_unlock_irqrestore (&parent_ctx->lock, flags); +out_unlock:mutex_unlock (&parent_ctx->mutex);perf_unpin_context (parent_ctx);
PATCH 26/95 mmc: ushc: fix NULL-deref at probe
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 181302dc7239add8ab1449c23ecab193f52ee6ab upstream.
Make sure to check the number of endpoints to avoid dereferencing a NULL-pointer should a malicious device lack endpoints.
--- drivers/mmc/host/ushc.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/mmc/host/ushc.c +3 -0
@@ -426,6 +426,9 @@ static int ushc_probe(struct usb_interfastruct ushc_data *ushc;int ret; +if (intf->cur_altsetting->desc.bNumEndpoints <1 ) +return -ENODEV ; + mmc =mmc_alloc_host (sizeof (struct ushc_data ), &intf->dev);if (mmc ==NULL )return -ENOMEM ;
PATCH 27/95 Input: iforce - validate number of endpoints before using them
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 59cf8bed44a79ec42303151dd014fdb6434254bb upstream.
Make sure to check the number of endpoints to avoid dereferencing a NULL-pointer or accessing memory that lie beyond the end of the endpoint array should a malicious device lack the expected endpoints.
--- drivers/input/joystick/iforce/iforce-usb.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/input/joystick/iforce/iforce-usb.c +3 -0
@@ -138,6 +138,9 @@ static int iforce_usb_probe(struct usb_i interface = intf->cur_altsetting; +if (interface->desc.bNumEndpoints <2 ) +return -ENODEV ; + epirq = &interface->endpoint[0 ].desc; epout = &interface->endpoint[1 ].desc;
PATCH 28/95 Input: cm109 - validate number of endpoints before using them
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit ac2ee9ba953afe88f7a673e1c0c839227b1d7891 upstream.
Make sure to check the number of endpoints to avoid dereferencing a NULL-pointer should a malicious device lack endpoints.
--- drivers/input/misc/cm109.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/input/misc/cm109.c +4 -0
@@ -663,6 +663,10 @@ static int cm109_usb_probe(struct usb_inint error = -ENOMEM ; interface = intf->cur_altsetting; + +if (interface->desc.bNumEndpoints <1 ) +return -ENODEV ; + endpoint = &interface->endpoint[0 ].desc;if (!usb_endpoint_is_int_in (endpoint))
PATCH 29/95 Input: yealink - validate number of endpoints before using them
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 5cc4a1a9f5c179795c8a1f2b0f4361829d6a070e upstream.
Make sure to check the number of endpoints to avoid dereferencing a NULL-pointer should a malicious device lack endpoints.
--- drivers/input/misc/yealink.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/input/misc/yealink.c +4 -0
@@ -867,6 +867,10 @@ static int usb_probe(struct usb_interfacint ret, pipe, i; interface = intf->cur_altsetting; + +if (interface->desc.bNumEndpoints <1 ) +return -ENODEV ; + endpoint = &interface->endpoint[0 ].desc;if (!usb_endpoint_is_int_in (endpoint))return -ENODEV ;
PATCH 30/95 Input: hanwang - validate number of endpoints before using them
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit ba340d7b83703768ce566f53f857543359aa1b98 upstream.
Make sure to check the number of endpoints to avoid dereferencing a NULL-pointer should a malicious device lack endpoints.
--- drivers/input/tablet/hanwang.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/input/tablet/hanwang.c +3 -0
@@ -314,6 +314,9 @@ static int hanwang_probe(struct usb_inteint error;int i; +if (intf->cur_altsetting->desc.bNumEndpoints <1 ) +return -ENODEV ; + hanwang =kzalloc (sizeof (struct hanwang ),GFP_KERNEL ); input_dev =input_allocate_device ();if (!hanwang || !input_dev) {
PATCH 31/95 Input: kbtab - validate number of endpoints before using them
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit cb1b494663e037253337623bf1ef2df727883cb7 upstream.
Make sure to check the number of endpoints to avoid dereferencing a NULL-pointer should a malicious device lack endpoints.
--- drivers/input/tablet/kbtab.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/input/tablet/kbtab.c +3 -0
@@ -117,6 +117,9 @@ static int kbtab_probe(struct usb_interfstruct input_dev *input_dev;int error = -ENOMEM ; +if (intf->cur_altsetting->desc.bNumEndpoints <1 ) +return -ENODEV ; + kbtab =kzalloc (sizeof (struct kbtab ),GFP_KERNEL ); input_dev =input_allocate_device ();if (!kbtab || !input_dev)
PATCH 32/95 net: ipv6: set route type for anycast routes
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: David Ahern <[email protected]>
commit 4ee39733fbecf04cf9f346de2d64788c35028079 upstream.
Anycast routes have the RTF_ANYCAST flag set, but when dumping routes for userspace the route type is not set to RTN_ANYCAST. Make it so.
--- net/ipv6/route.c | 2 ++ 1 file changed, 2 insertions(+)
net/ipv6/route.c +2 -0
@@ -2384,6 +2384,8 @@ static int rt6_fill_node(struct net *net rtm->rtm_type =RTN_UNREACHABLE ; else if (rt->rt6i_flags&RTF_LOCAL) rtm->rtm_type = RTN_LOCAL; + else if (rt->rt6i_flags & RTF_ANYCAST) + rtm->rtm_type = RTN_ANYCAST; else if (rt->rt6i_dev && (rt->rt6i_dev->flags&IFF_LOOPBACK)) rtm->rtm_type = RTN_LOCAL; else
PATCH 33/95 USB: usbtmc: add missing endpoint sanity check
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 687e0687f71ec00e0132a21fef802dee88c2f1ad upstream.
USBTMC devices are required to have a bulk-in and a bulk-out endpoint, but the driver failed to verify this, something which could lead to the endpoint addresses being taken from uninitialised memory.
Make sure to zero all private data as part of allocation, and add the missing endpoint sanity check.
Note that this also addresses a more recently introduced issue, where the interrupt-in-presence flag would also be uninitialised whenever the optional interrupt-in endpoint is not present. This in turn could lead to an interrupt urb being allocated, initialised and submitted based on uninitialised values.
--- drivers/usb/class/usbtmc.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/usb/class/usbtmc.c +8 -1
@@ -1007,7 +1007,7 @@ static int usbtmc_probe(struct usb_interdev_dbg (&intf->dev,"%s called\n" , __func__); - data =kmalloc (sizeof (struct usbtmc_device_data ),GFP_KERNEL ); + data =kzalloc (sizeof (struct usbtmc_device_data ),GFP_KERNEL );if (!data) {dev_err (&intf->dev,"Unable to allocate kernel memory\n" );return -ENOMEM ;
@@ -1053,6 +1053,12 @@ static int usbtmc_probe(struct usb_inter } } +if (!data->bulk_out || !data->bulk_in) { +dev_err (&intf->dev,"bulk endpoints not found\n" ); + retcode = -ENODEV ; + goto err_put; + } + retcode =get_capabilities (data);if (retcode)dev_err (&intf->dev,"can't read capabilities\n" );
@@ -1076,6 +1082,7 @@ static int usbtmc_probe(struct usb_inter error_register:sysfs_remove_group (&intf->dev.kobj, &capability_attr_grp);sysfs_remove_group (&intf->dev.kobj, &data_attr_grp); +err_put:kref_put (&data->kref, usbtmc_delete);return retcode; }
PATCH 34/95 ACM gadget: fix endianness in notifications
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
commit cdd7928df0d2efaa3270d711963773a08a4cc8ab upstream.
The gadget code exports the bitfield for serial status changes over the wire in its internal endianness. The fix is to convert to little endian before sending it over the wire.
--- drivers/usb/gadget/f_acm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/gadget/f_acm.c +3 -1
@@ -497,13 +497,15 @@ static int acm_notify_serial_state(struc {struct usb_composite_dev *cdev = acm->port.func.config->cdev;int status; +__le16 serial_state;spin_lock (&acm->lock);if (acm->notify_req) {DBG (cdev,"acm ttyGS%d serial state %04x\n" , acm->port_num, acm->serial_state); + serial_state =cpu_to_le16 (acm->serial_state); status =acm_cdc_notify (acm,USB_CDC_NOTIFY_SERIAL_STATE , -0 , &acm->serial_state,sizeof (acm->serial_state)); +0 , &serial_state,sizeof (acm->serial_state)); }else { acm->pending = true; status =0 ;
PATCH 35/95 perf symbols: Fix symbols__fixup_end heuristic for corner cases
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Borkmann <[email protected]>
commit e7ede72a6d40cb3a30c087142d79381ca8a31dab upstream.
The current symbols__fixup_end() heuristic for the last entry in the rb tree is suboptimal as it leads to not being able to recognize the symbol in the call graph in a couple of corner cases, for example:
i) If the symbol has a start address (f.e. exposed via kallsyms)
that is at a page boundary, then the roundup(curr->start, 4096)
for the last entry will result in curr->start == curr->end with
a symbol length of zero.ii) If the symbol has a start address that is shortly before a page
boundary, then also here, curr->end - curr->start will just be very few bytes, where it's unrealistic that we could perform a match against.
Instead, change the heuristic to roundup(curr->start, 4096) + 4096, so that we can catch such corner cases and have a better chance to find that specific symbol. It's still just best effort as the real end of the symbol is unknown to us (and could even be at a larger offset than the current range), but better than the current situation.
Alexei reported that he recently run into case i) with a JITed eBPF program (these are all page aligned) as the last symbol which wasn't properly shown in the call graph (while other eBPF program symbols in the rb tree were displayed correctly). Since this is a generic issue, lets try to improve the heuristic a bit.
--- tools/perf/util/symbol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/symbol.c +1 -1
@@ -193,7 +193,7 @@ static void symbols__fixup_end(struct rb/* Last entry */ if (curr->end == curr->start) - curr->end =roundup (curr->start,4096 ); + curr->end =roundup (curr->start,4096 ) +4096 ; }static void __map_groups__fixup_end (struct map_groups *mg,enum map_type type)
PATCH 36/95 ALSA: ctxfi: Fix the incorrect check of dma_set_mask() call
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit f363a06642f28caaa78cb6446bbad90c73fe183c upstream.
In the commit [15c75b09f8d1: ALSA: ctxfi: Fallback DMA mask to 32bit], I forgot to put "!" at dam_set_mask() call check in cthw20k1.c (while cthw20k2.c is OK). This patch fixes that obvious bug.
(As a side note: although the original commit was completely wrong,
it's still working for most of machines, as it sets to 32bit DMA mask in the end. So the bug severity is low.)
--- sound/pci/ctxfi/cthw20k1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/pci/ctxfi/cthw20k1.c +1 -1
@@ -1904,7 +1904,7 @@ static int hw_card_start(struct hw *hw)return err;/* Set DMA transfer mask */ -if (dma_set_mask (&pci->dev,DMA_BIT_MASK (dma_bits))) { +if (!dma_set_mask (&pci->dev,DMA_BIT_MASK (dma_bits))) {dma_set_coherent_mask (&pci->dev,DMA_BIT_MASK (dma_bits)); }else {dma_set_mask (&pci->dev,DMA_BIT_MASK (32 ));
PATCH 37/95 scsi: libsas: fix ata xfer length
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: John Garry <[email protected]>
commit 9702c67c6066f583b629cf037d2056245bb7a8e6 upstream.
The total ata xfer length may not be calculated properly, in that we do not use the proper method to get an sg element dma length.
According to the code comment, sg_dma_len() should be used after dma_map_sg() is called.
This issue was found by turning on the SMMUv3 in front of the hisi_sas controller in hip07. Multiple sg elements were being combined into a single element, but the original first element length was being use as the total xfer length.
--- drivers/scsi/libsas/sas_ata.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/libsas/sas_ata.c +1 -1
@@ -205,7 +205,7 @@ static unsigned int sas_ata_qc_issue(str task->num_scatter = qc->n_elem; }else {for_each_sg (qc->sg, sg, qc->n_elem, si) - xfer += sg->length; + xfer +=sg_dma_len (sg); task->total_xfer_len = xfer; task->num_scatter = si;
PATCH 38/95 ALSA: seq: Fix racy cell insertions during snd_seq_pool_done()
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit c520ff3d03f0b5db7146d9beed6373ad5d2a5e0e upstream.
When snd_seq_pool_done() is called, it marks the closing flag to refuse the further cell insertions. But snd_seq_pool_done() itself doesn't clear the cells but just waits until all cells are cleared by the caller side. That is, it's racy, and this leads to the endless stall as syzkaller spotted.
This patch addresses the racy by splitting the setup of pool->closing flag out of snd_seq_pool_done(), and calling it properly before snd_seq_pool_done().
--- sound/core/seq/seq_clientmgr.c | 1 + sound/core/seq/seq_fifo.c | 3 +++ sound/core/seq/seq_memory.c | 17 +++++++++++++---- sound/core/seq/seq_memory.h | 1 + 4 files changed, 18 insertions(+), 4 deletions(-)
sound/core/seq/seq_clientmgr.c +1 -0
@@ -1909,6 +1909,7 @@ static int snd_seq_ioctl_set_client_pool info.output_pool != client->pool->size)) {if (snd_seq_write_pool_allocated (client)) {/* remove all existing cells */ +snd_seq_pool_mark_closing (client->pool);snd_seq_queue_client_leave_cells (client->number);snd_seq_pool_done (client->pool); }
sound/core/seq/seq_fifo.c +3 -0
@@ -72,6 +72,9 @@ void snd_seq_fifo_delete(struct snd_seq_return ; *fifo =NULL ; +if (f->pool) +snd_seq_pool_mark_closing (f->pool); +snd_seq_fifo_clear (f);/* wake up clients if any */
sound/core/seq/seq_memory.c +13 -4
@@ -416,6 +416,18 @@ int snd_seq_pool_init(struct snd_seq_pooreturn 0 ; } +/* refuse the further insertion to the pool */ +void snd_seq_pool_mark_closing (struct snd_seq_pool *pool) +{ +unsigned long flags; + +if (snd_BUG_ON (!pool)) +return ; +spin_lock_irqsave (&pool->lock, flags); + pool->closing =1 ; +spin_unlock_irqrestore (&pool->lock, flags); +} +/* remove events */ int snd_seq_pool_done (struct snd_seq_pool *pool) {
@@ -426,10 +438,6 @@ int snd_seq_pool_done(struct snd_seq_pooreturn -EINVAL ;/* wait for closing all threads */ -spin_lock_irqsave (&pool->lock, flags); - pool->closing =1 ; -spin_unlock_irqrestore (&pool->lock, flags); -if (waitqueue_active (&pool->output_sleep))wake_up (&pool->output_sleep);
@@ -488,6 +496,7 @@ int snd_seq_pool_delete(struct snd_seq_p *ppool =NULL ;if (pool ==NULL )return 0 ; +snd_seq_pool_mark_closing (pool);snd_seq_pool_done (pool);kfree (pool);return 0 ;
sound/core/seq/seq_memory.h +1 -0
@@ -84,6 +84,7 @@ static inline int snd_seq_total_cells(stint snd_seq_pool_init (struct snd_seq_pool *pool);/* done pool - free events */ +void snd_seq_pool_mark_closing (struct snd_seq_pool *pool);int snd_seq_pool_done (struct snd_seq_pool *pool);/* create pool */
PATCH 39/95 net: unix: properly re-increment inflight counter of GC discarded candidates
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Andrey Ulanov <[email protected]>
commit 7df9c24625b9981779afb8fcdbe2bb4765e61147 upstream.
Dmitry has reported that a BUG_ON() condition in unix_notinflight() may be triggered by a simple code that forwards unix socket in an SCM_RIGHTS message.
That is caused by incorrect unix socket GC implementation in unix_gc().
The GC first collects list of candidates, then (a) decrements their "children's" inflight counter, (b) checks which inflight counters are now 0, and then (c) increments all inflight counters back.
(a) and (c) are done by calling scan_children() with inc_inflight or dec_inflight as the second argument.
Commit 6209344f5a37 ("net: unix: fix inflight counting bug in garbage collector") changed scan_children() such that it no longer considers sockets that do not have UNIX_GC_CANDIDATE flag. It also added a block of code that that unsets this flag _before_ invoking scan_children(, dec_iflight, ). This may lead to incorrect inflight counters for some sockets.
This change fixes this bug by changing order of operations:UNIX_GC_CANDIDATE is now unset only after all inflight counters are restored to the original state.
kernel BUG at net/unix/garbage.c:149!
RIP: 0010:[<ffffffff8717ebf4>] [<ffffffff8717ebf4>] unix_notinflight+0x3b4/0x490 net/unix/garbage.c:149 Call Trace: [<ffffffff8716cfbf>] unix_detach_fds.isra.19+0xff/0x170 net/unix/af_unix.c:1487 [<ffffffff8716f6a9>] unix_destruct_scm+0xf9/0x210 net/unix/af_unix.c:1496 [<ffffffff86a90a01>] skb_release_head_state+0x101/0x200 net/core/skbuff.c:655 [<ffffffff86a9808a>] skb_release_all+0x1a/0x60 net/core/skbuff.c:668 [<ffffffff86a980ea>] __kfree_skb+0x1a/0x30 net/core/skbuff.c:684 [<ffffffff86a98284>] kfree_skb+0x184/0x570 net/core/skbuff.c:705 [<ffffffff871789d5>] unix_release_sock+0x5b5/0xbd0 net/unix/af_unix.c:559 [<ffffffff87179039>] unix_release+0x49/0x90 net/unix/af_unix.c:836 [<ffffffff86a694b2>] sock_release+0x92/0x1f0 net/socket.c:570 [<ffffffff86a6962b>] sock_close+0x1b/0x20 net/socket.c:1017 [<ffffffff81a76b8e>] __fput+0x34e/0x910 fs/file_table.c:208 [<ffffffff81a771da>] ____fput+0x1a/0x20 fs/file_table.c:244 [<ffffffff81483ab0>] task_work_run+0x1a0/0x280 kernel/task_work.c:116 [< inline >] exit_task_work include/linux/task_work.h:21 [<ffffffff8141287a>] do_exit+0x183a/0x2640 kernel/exit.c:828 [<ffffffff8141383e>] do_group_exit+0x14e/0x420 kernel/exit.c:931 [<ffffffff814429d3>] get_signal+0x663/0x1880 kernel/signal.c:2307 [<ffffffff81239b45>] do_signal+0xc5/0x2190 arch/x86/kernel/signal.c:807 [<ffffffff8100666a>] exit_to_usermode_loop+0x1ea/0x2d0 arch/x86/entry/common.c:156 [< inline >] prepare_exit_to_usermode arch/x86/entry/common.c:190 [<ffffffff81009693>] syscall_return_slowpath+0x4d3/0x570 arch/x86/entry/common.c:259 [<ffffffff881478e6>] entry_SYSCALL_64_fastpath+0xc4/0xc6
--- net/unix/garbage.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
net/unix/garbage.c +9 -9
@@ -150,6 +150,7 @@ void unix_notinflight(struct user_structif (s) {struct unix_sock *u =unix_sk (s); +BUG_ON (!atomic_long_read (&u->inflight));BUG_ON (list_empty (&u->link));if (atomic_long_dec_and_test (&u->inflight))list_del_init (&u->link);
@@ -356,6 +357,14 @@ void unix_gc(void) }list_del (&cursor); +/* Now gc_candidates contains only garbage. Restore original +* inflight counters for these as well, and remove the skbuffs +* which are creating the cycle(s). +*/ +skb_queue_head_init (&hitlist); +list_for_each_entry (u, &gc_candidates, link) +scan_children (&u->sk, inc_inflight, &hitlist); +/* * not_cycle_list contains those sockets which do not make up a * cycle. Restore these to the inflight list.
@@ -366,15 +375,6 @@ void unix_gc(void)list_move_tail (&u->link, &gc_inflight_list); } -/* -* Now gc_candidates contains only garbage. Restore original -* inflight counters for these as well, and remove the skbuffs -* which are creating the cycle(s). -*/ -skb_queue_head_init (&hitlist); -list_for_each_entry (u, &gc_candidates, link) -scan_children (&u->sk, inc_inflight, &hitlist); -spin_unlock (&unix_gc_lock);/* Here we are. Hitlist is filled. Die. */
PATCH 40/95 bpf: try harder on clones when writing into skb
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Borkmann <[email protected]>
commit 3697649ff29e0f647565eed04b27a7779c646a22 upstream.
When we're dealing with clones and the area is not writeable, try harder and get a copy via pskb_expand_head(). Replace also other occurences in tc actions with the new skb_try_make_writable().
---
include/linux/skbuff.h +7 -0
@@ -1926,6 +1926,13 @@ static inline int skb_clone_writable(conskb_headroom (skb) + len <= skb->hdr_len; } +static inline int skb_try_make_writable (struct sk_buff *skb, +unsigned int write_len) +{ +return skb_cloned (skb) && !skb_clone_writable (skb, write_len) && +pskb_expand_head (skb,0 ,0 ,GFP_ATOMIC ); +} +static inline int __skb_cow (struct sk_buff *skb,unsigned int headroom,int cloned) {
net/sched/act_csum.c +2 -6
@@ -122,9 +122,7 @@ static void *tcf_csum_skb_nextlayer(struint hl = ihl + jhl;if (!pskb_may_pull (skb, ipl + ntkoff) || (ipl < hl) || - (skb_cloned (skb) && - !skb_clone_writable (skb, hl + ntkoff) && -pskb_expand_head (skb,0 ,0 ,GFP_ATOMIC ))) +skb_try_make_writable (skb, hl + ntkoff))return NULL ;else return (void *)(skb_network_header (skb) + ihl);
@@ -372,9 +370,7 @@ static int tcf_csum_ipv4(struct sk_buff }if (update_flags &TCA_CSUM_UPDATE_FLAG_IPV4HDR ) { -if (skb_cloned (skb) && - !skb_clone_writable (skb,sizeof (*iph) + ntkoff) && -pskb_expand_head (skb,0 ,0 ,GFP_ATOMIC )) +if (skb_try_make_writable (skb,sizeof (*iph) + ntkoff)) goto fail;ip_send_check (iph);
net/sched/act_nat.c +5 -13
@@ -144,9 +144,7 @@ static int tcf_nat(struct sk_buff *skb, addr = iph->daddr;if (!((old_addr ^ addr) & mask)) { -if (skb_cloned (skb) && - !skb_clone_writable (skb,sizeof (*iph) + noff) && -pskb_expand_head (skb,0 ,0 ,GFP_ATOMIC )) +if (skb_try_make_writable (skb,sizeof (*iph) + noff)) goto drop; new_addr &= mask;
@@ -174,9 +172,7 @@ static int tcf_nat(struct sk_buff *skb,struct tcphdr *tcph;if (!pskb_may_pull (skb, ihl +sizeof (*tcph) + noff) || - (skb_cloned (skb) && - !skb_clone_writable (skb, ihl +sizeof (*tcph) + noff) && -pskb_expand_head (skb,0 ,0 ,GFP_ATOMIC ))) +skb_try_make_writable (skb, ihl +sizeof (*tcph) + noff)) goto drop; tcph = (void *)(skb_network_header (skb) + ihl);
@@ -188,9 +184,7 @@ static int tcf_nat(struct sk_buff *skb,struct udphdr *udph;if (!pskb_may_pull (skb, ihl +sizeof (*udph) + noff) || - (skb_cloned (skb) && - !skb_clone_writable (skb, ihl +sizeof (*udph) + noff) && -pskb_expand_head (skb,0 ,0 ,GFP_ATOMIC ))) +skb_try_make_writable (skb, ihl +sizeof (*udph) + noff)) goto drop; udph = (void *)(skb_network_header (skb) + ihl);
@@ -230,10 +224,8 @@ static int tcf_nat(struct sk_buff *skb,if ((old_addr ^ addr) & mask)break ; -if (skb_cloned (skb) && - !skb_clone_writable (skb, ihl +sizeof (*icmph) + -sizeof (*iph) + noff) && -pskb_expand_head (skb,0 ,0 ,GFP_ATOMIC )) +if (skb_try_make_writable (skb, ihl +sizeof (*icmph) + +sizeof (*iph) + noff)) goto drop; icmph = (void *)(skb_network_header (skb) + ihl);
PATCH 41/95 sch_dsmark: fix invalid skb_cow() usage
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
commit aea92fb2e09e29653b023d4254ac9fbf94221538 upstream.
skb_cow(skb, sizeof(ip header)) is not very helpful in this context.
First we need to use pskb_may_pull() to make sure the ip header is in skb linear part, then use skb_try_make_writable() to address clones issues.
--- net/sched/sch_dsmark.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
net/sched/sch_dsmark.c +8 -2
@@ -202,9 +202,13 @@ static int dsmark_enqueue(struct sk_buffpr_debug ("dsmark_enqueue(skb %p,sch %p,[qdisc %p])\n" , skb, sch, p);if (p->set_tc_index) { +int wlen =skb_network_offset (skb); +switch (skb->protocol) {case htons (ETH_P_IP ): -if (skb_cow_head (skb,sizeof (struct iphdr ))) + wlen +=sizeof (struct iphdr ); +if (!pskb_may_pull (skb, wlen) || +skb_try_make_writable (skb, wlen)) goto drop; skb->tc_index =ipv4_get_dsfield (ip_hdr (skb))
@@ -212,7 +216,9 @@ static int dsmark_enqueue(struct sk_buffbreak ;case htons (ETH_P_IPV6 ): -if (skb_cow_head (skb,sizeof (struct ipv6hdr ))) + wlen +=sizeof (struct ipv6hdr ); +if (!pskb_may_pull (skb, wlen) || +skb_try_make_writable (skb, wlen)) goto drop; skb->tc_index =ipv6_get_dsfield (ipv6_hdr (skb))
PATCH 42/95 s390/decompressor: fix initrd corruption caused by bss clear
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Marcelo Henrique Cerri <[email protected]>
commit d82c0d12c92705ef468683c9b7a8298dd61ed191 upstream.
Reorder the operations in decompress_kernel() to ensure initrd is moved to a safe location before the bss section is zeroed.
During decompression bss can overlap with the initrd and this can corrupt the initrd contents depending on the size of the compressed kernel (which affects where the initrd is placed by the bootloader) and the size of the bss section of the decompressor.
Also use the correct initrd size when checking for overlaps with parmblock.
--- arch/s390/boot/compressed/misc.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-)
arch/s390/boot/compressed/misc.c +19 -16
@@ -135,31 +135,34 @@ static void check_ipl_parmblock(void *stunsigned long decompress_kernel (void ) { -unsigned long output_addr; -unsigned char *output; +void *output, *kernel_end; - output_addr = ((unsigned long ) &_end +HEAP_SIZE +4095UL ) &-4096UL ; -check_ipl_parmblock ((void *)0 , output_addr + SZ__bss_start); -memset (&_bss,0 , &_ebss - &_bss); - free_mem_ptr = (unsigned long )&_end; - free_mem_end_ptr = free_mem_ptr +HEAP_SIZE ; - output = (unsigned char *) output_addr; + output = (void *)ALIGN ((unsigned long ) &_end +HEAP_SIZE ,PAGE_SIZE ); + kernel_end = output + SZ__bss_start; +check_ipl_parmblock ((void *)0 , (unsigned long ) kernel_end);#ifdef CONFIG_BLK_DEV_INITRD /* * Move the initrd right behind the end of the decompressed -* kernel image. +* kernel image. This also prevents initrd corruption caused by +* bss clearing since kernel_end will always be located behind the +* current bss section.. */ -if (INITRD_START &&INITRD_SIZE && -INITRD_START < (unsigned long ) output + SZ__bss_start) { -check_ipl_parmblock (output + SZ__bss_start, -INITRD_START +INITRD_SIZE ); -memmove (output + SZ__bss_start, - (void *)INITRD_START ,INITRD_SIZE ); -INITRD_START = (unsigned long ) output + SZ__bss_start; +if (INITRD_START &&INITRD_SIZE && kernel_end > (void *)INITRD_START ) { +check_ipl_parmblock (kernel_end,INITRD_SIZE ); +memmove (kernel_end, (void *)INITRD_START ,INITRD_SIZE ); +INITRD_START = (unsigned long ) kernel_end; }#endif +/* +* Clear bss section. free_mem_ptr and free_mem_end_ptr need to be +* initialized afterwards since they reside in bss. +*/ +memset (&_bss,0 , &_ebss - &_bss); + free_mem_ptr = (unsigned long ) &_end; + free_mem_end_ptr = free_mem_ptr +HEAP_SIZE ; +puts ("Uncompressing Linux... " );decompress (input_data, input_len,NULL ,NULL , output,NULL , error);puts ("Ok, booting the kernel.\n" );
PATCH 43/95 mmc: sdhci: Do not disable interrupts while waiting for clock
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
commit e2ebfb2142acefecc2496e71360f50d25726040b upstream.
Disabling interrupts for even a millisecond can cause problems for some devices. That can happen when sdhci changes clock frequency because it waits for the clock to become stable under a spin lock.
The spin lock is not necessary here. Anything that is racing with changes to the I/O state is already broken. The mmc core already provides synchronization via "claiming" the host.
Although the spin lock probably should be removed from the code paths that lead to this point, such a patch would touch too much code to be suitable for stable trees. Consequently, for this patch, just drop the spin lock while waiting.
--- drivers/mmc/host/sdhci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci.c +3 -1
@@ -1150,7 +1150,9 @@ static void sdhci_set_clock(struct sdhcireturn ; } timeout--; -mdelay (1 ); +spin_unlock_irq (&host->lock); +usleep_range (900 ,1100 ); +spin_lock_irq (&host->lock); } clk |=SDHCI_CLOCK_CARD_EN ;
PATCH 44/95 hwmon: (asus_atk0110) fix uninitialized data access
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
commit a2125d02443e9a4e68bcfd9f8004fa23239e8329 upstream.
The latest gcc-7 snapshot adds a warning to point out that when atk_read_value_old or atk_read_value_new fails, we copy uninitialized data into sensor->cached_value:
drivers/hwmon/asus_atk0110.c: In function 'atk_input_show':drivers/hwmon/asus_atk0110.c:651:26: error: 'value' may be used uninitialized in this function [-Werror=maybe-uninitialized]
Adding an error check avoids this. All versions of the driver are affected.
--- drivers/hwmon/asus_atk0110.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/hwmon/asus_atk0110.c +3 -0
@@ -645,6 +645,9 @@ static int atk_read_value(struct atk_senelse err =atk_read_value_new (sensor, value); +if (err) +return err; + sensor->is_valid = true; sensor->last_updated = jiffies; sensor->cached_value = *value;
PATCH 45/95 ALSA: seq: Fix race during FIFO resize
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 2d7d54002e396c180db0c800c1046f0a3c471597 upstream.
When a new event is queued while processing to resize the FIFO in snd_seq_fifo_clear(), it may lead to a use-after-free, as the old pool that is being queued gets removed. For avoiding this race, we need to close the pool to be deleted and sync its usage before actually deleting it.
The issue was spotted by syzkaller.
--- sound/core/seq/seq_fifo.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/core/seq/seq_fifo.c +4 -0
@@ -267,6 +267,10 @@ int snd_seq_fifo_resize(struct snd_seq_f/* NOTE: overflow flag is not cleared */ spin_unlock_irqrestore (&f->lock, flags); +/* close the old pool and wait until all users are gone */ +snd_seq_pool_mark_closing (oldpool); +snd_use_lock_sync (&f->use_lock); +/* release cells in old pool */ for (cell = oldhead; cell; cell = next) { next = cell->next;
PATCH 46/95 net: phy: handle state correctly in phy_stop_machine
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Sullivan <[email protected]>
commit 49d52e8108a21749dc2114b924c907db43358984 upstream.
If the PHY is halted on stop, then do not set the state to PHY_UP. This ensures the phy will be restarted later in phy_start when the machine is started again.
--- drivers/net/phy/phy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/phy.c +1 -1
@@ -453,7 +453,7 @@ void phy_stop_machine(struct phy_devicecancel_delayed_work_sync (&phydev->state_queue);mutex_lock (&phydev->lock); -if (phydev->state >PHY_UP ) +if (phydev->state >PHY_UP && phydev->state !=PHY_HALTED ) phydev->state =PHY_UP ;mutex_unlock (&phydev->lock);
PATCH 47/95 IB/qib: fix false-postive maybe-uninitialized warning
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
commit f6aafac184a3e46e919769dd4faa8bf0dc436534 upstream.
aarch64-linux-gcc-7 complains about code it doesn't fully understand:
drivers/infiniband/hw/qib/qib_iba7322.c: In function 'qib_7322_txchk_change':include/asm-generic/bitops/non-atomic.h:105:35: error: 'shadow' may be used uninitialized in this function [-Werror=maybe-uninitialized]
The code is right, and despite trying hard, I could not come up with a version that I liked better than just adding a fake initialization here to shut up the warning.
--- drivers/infiniband/hw/qib/qib_iba7322.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/qib/qib_iba7322.c +1 -1
@@ -6614,7 +6614,7 @@ static void qib_7322_txchk_change(structunsigned long flags;while (wait) { -unsigned long shadow; +unsigned long shadow =0 ;int cstart, previ =-1 ;/*
PATCH 48/95 netfilter: nf_nat_snmp: Fix panic when snmp_trap_helper fails to register
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Gao Feng <[email protected]>
commit 75c689dca98851d65ef5a27e5ce26b625b68751c upstream.
In the commit 93557f53e1fb ("netfilter: nf_conntrack: nf_conntrack snmp helper"), the snmp_helper is replaced by nf_nat_snmp_hook. So the snmp_helper is never registered. But it still tries to unregister the snmp_helper, it could cause the panic.
Now remove the useless snmp_helper and the unregister call in the error handler.
--- net/ipv4/netfilter/nf_nat_snmp_basic.c | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-)
net/ipv4/netfilter/nf_nat_snmp_basic.c +1 -18
@@ -1261,16 +1261,6 @@ static const struct nf_conntrack_expect_ .timeout = 180, }; -static struct nf_conntrack_helper snmp_helper__read_mostly = { - .me =THIS_MODULE , - .help = help, - .expect_policy = &snmp_exp_policy, - .name ="snmp" , - .tuple.src.l3num =AF_INET , - .tuple.src.u.udp.port =cpu_to_be16 (SNMP_PORT ), - .tuple.dst.protonum =IPPROTO_UDP , -}; -static struct nf_conntrack_helper snmp_trap_helper__read_mostly = { .me =THIS_MODULE , .help = help,
@@ -1289,17 +1279,10 @@ static struct nf_conntrack_helper snmp_tstatic int __init nf_nat_snmp_basic_init (void ) { -int ret =0 ; -BUG_ON (nf_nat_snmp_hook !=NULL );RCU_INIT_POINTER (nf_nat_snmp_hook, help); - ret =nf_conntrack_helper_register (&snmp_trap_helper); -if (ret <0 ) { -nf_conntrack_helper_unregister (&snmp_helper); -return ret; - } -return ret; +return nf_conntrack_helper_register (&snmp_trap_helper); } static void __exit nf_nat_snmp_basic_fini(void)
PATCH 49/95 virtio_balloon: init 1st buffer in stats vq
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ladi Prosek <[email protected]>
commit fc8653228c8588a120f6b5dad6983b7b61ff669e upstream.
When init_vqs runs, virtio_balloon.stats is either uninitialized or contains stale values. The host updates its state with garbage data because it has no way of knowing that this is just a marker buffer used for signaling.
This patch updates the stats before pushing the initial buffer.
Alternative fixes:
* Push an empty buffer in init_vqs. Not easily done with the current virtio implementation and violates the spec "Driver MUST supply the same subset of statistics in all buffers submitted to the statsq".
* Push a buffer with invalid tags in init_vqs. Violates the same spec clause, plus "invalid tag" is not really defined.
Note: the spec says:
When using the legacy interface, the device SHOULD ignore all values in the first buffer in the statsq supplied by the driver after device initialization. Note: Historically, drivers supplied an uninitialized buffer in the first buffer.
Unfortunately QEMU does not seem to implement the recommendation even for the legacy interface.
--- drivers/virtio/virtio_balloon.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/virtio/virtio_balloon.c +2 -0
@@ -320,6 +320,8 @@ static int virtballoon_probe(struct virt* Prime this virtqueue with one buffer so the hypervisor can * use it to signal us later. */ +update_balloon_stats (vb); +sg_init_one (&sg, vb->stats,sizeof vb->stats);if (virtqueue_add_buf (vb->stats_vq, &sg,1 ,0 , vb) <0 )BUG ();
PATCH 50/95 virtio_balloon: prevent uninitialized variable use
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
commit f0bb2d50dfcc519f06f901aac88502be6ff1df2c upstream.
The latest gcc-7.0.1 snapshot reports a new warning:
virtio/virtio_balloon.c: In function 'update_balloon_stats':virtio/virtio_balloon.c:258:26: error: 'events[2]' is used uninitialized in this function [-Werror=uninitialized] virtio/virtio_balloon.c:260:26: error: 'events[3]' is used uninitialized in this function [-Werror=uninitialized] virtio/virtio_balloon.c:261:56: error: 'events[18]' is used uninitialized in this function [-Werror=uninitialized] virtio/virtio_balloon.c:262:56: error: 'events[17]' is used uninitialized in this function [-Werror=uninitialized]
This seems absolutely right, so we should add an extra check to prevent copying uninitialized stack data into the statistics.
Quoted 1 line
Quoted 1 line
From all I can tell, this has been broken since the statistics code
was originally added in 2.6.34.
--- drivers/virtio/virtio_balloon.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/virtio/virtio_balloon.c +2 -0
@@ -180,12 +180,14 @@ static void update_balloon_stats(structall_vm_events (events);si_meminfo (&i); +#ifdef CONFIG_VM_EVENT_COUNTERS update_stat (vb, idx++,VIRTIO_BALLOON_S_SWAP_IN ,pages_to_bytes (events[PSWPIN ]));update_stat (vb, idx++,VIRTIO_BALLOON_S_SWAP_OUT ,pages_to_bytes (events[PSWPOUT ]));update_stat (vb, idx++,VIRTIO_BALLOON_S_MAJFLT , events[PGMAJFAULT ]);update_stat (vb, idx++,VIRTIO_BALLOON_S_MINFLT , events[PGFAULT ]); +#endif update_stat (vb, idx++,VIRTIO_BALLOON_S_MEMFREE ,pages_to_bytes (i.freeram)); update_stat(vb, idx++, VIRTIO_BALLOON_S_MEMTOT,
PATCH 51/95 ACPI / APEI: Add missing synchronize_rcu() on NOTIFY_SCI removal
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: James Morse <[email protected]>
commit 7d64f82cceb21e6d95db312d284f5f195e120154 upstream.
When removing a GHES device notified by SCI, list_del_rcu() is used, ghes_remove() should call synchronize_rcu() before it goes on to call kfree(ghes), otherwise concurrent RCU readers may still hold this list entry after it has been freed.
--- drivers/acpi/apei/ghes.c | 1 + 1 file changed, 1 insertion(+)
drivers/acpi/apei/ghes.c +1 -0
@@ -953,6 +953,7 @@ static int __devexit ghes_remove(structif (list_empty (&ghes_sci))unregister_acpi_hed_notifier (&ghes_notifier_sci);mutex_unlock (&ghes_list_mutex); +synchronize_rcu ();break ;case ACPI_HEST_NOTIFY_NMI :mutex_lock (&ghes_list_mutex);
PATCH 52/95 ACPI: Fix incompatibility with mcount-based function graph tracing
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Josh Poimboeuf <[email protected]>
commit 61b79e16c68d703dde58c25d3935d67210b7d71b upstream.
Paul Menzel reported a warning:
WARNING: CPU: 0 PID: 774 at /build/linux-ROBWaj/linux-4.9.13/kernel/trace/trace_functions_graph.c:233 ftrace_return_to_handler+0x1aa/0x1e0
Bad frame pointer: expected f6919d98, received f6919db0
from func acpi_pm_device_sleep_wake return to c43b6f9dThe warning means that function graph tracing is broken for the acpi_pm_device_sleep_wake() function. That's because the ACPI Makefile unconditionally sets the '-Os' gcc flag to optimize for size. That's an issue because mcount-based function graph tracing is incompatible with '-Os' on x86, thanks to the following gcc bug:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42109
I have another patch pending which will ensure that mcount-based function graph tracing is never used with CONFIG_CC_OPTIMIZE_FOR_SIZE on x86.
But this patch is needed in addition to that one because the ACPI Makefile overrides that config option for no apparent reason. It has had this flag since the beginning of git history, and there's no related comment, so I don't know why it's there. As far as I can tell, there's no reason for it to be there. The appropriate behavior is for it to honor CONFIG_CC_OPTIMIZE_FOR_{SIZE,PERFORMANCE} like the rest of the kernel.
--- drivers/acpi/Makefile | 1 - 1 file changed, 1 deletion(-)
drivers/acpi/Makefile +0 -1
@@ -2,7 +2,6 @@ # Makefile for the Linux ACPI interpreter # -ccflags-y := -Os ccflags-$(CONFIG_ACPI_DEBUG) += -DACPI_DEBUG_OUTPUT #
PATCH 53/95 xhci: Manually give back cancelled URB if we can't queue it for cancel
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Mathias Nyman <[email protected]>
commit d3519b9d9606991a1305596348b6d690bfa3eb27 upstream.
xhci needs to take care of four scenarios when asked to cancel a URB.
1 URB is not queued or already given back.
usb_hcd_check_unlink_urb() will return an error, we pass the error on
2 We fail to find xhci internal structures from urb private data such as
virtual device and endpoint ring.
Give back URB immediately, can't do anything about internal structures.
3 URB private data has valid pointers to xhci internal data, but host is
not responding.
give back URB immedately and remove the URB from the endpoint lists.
4 Everyting is working
add URB to cancel list, queue a command to stop the endpoint, after which the URB can be turned to no-op or skipped, removed from lists, and given back.
We failed to give back the urb in case 2 where the correct device and endpoint pointers could not be retrieved from URB private data.
This caused a hang on Dell Inspiron 5558/0VNM2T at resume from suspend as urb was never returned.
[ 245.270505] INFO: task rtsx_usb_ms_1:254 blocked for more than 120 seconds. [ 245.272244] Tainted: G W 4.11.0-rc3-ARCH #2 [ 245.273983] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. [ 245.275737] rtsx_usb_ms_1 D 0 254 2 0x00000000 [ 245.277524] Call Trace: [ 245.279278] __schedule+0x2d3/0x8a0 [ 245.281077] schedule+0x3d/0x90 [ 245.281961] usb_kill_urb.part.3+0x6c/0xa0 [usbcore] [ 245.282861] ? wake_atomic_t_function+0x60/0x60 [ 245.283760] usb_kill_urb+0x21/0x30 [usbcore] [ 245.284649] usb_start_wait_urb+0xe5/0x170 [usbcore] [ 245.285541] ? try_to_del_timer_sync+0x53/0x80 [ 245.286434] usb_bulk_msg+0xbd/0x160 [usbcore] [ 245.287326] rtsx_usb_send_cmd+0x63/0x90 [rtsx_usb]
[bwh: Backported to 3.2:
- Move debug logging along with endpoint lookup
- Adjust context]
--- drivers/usb/host/xhci.c | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-)
drivers/usb/host/xhci.c +31 -25
@@ -1522,19 +1522,38 @@ int xhci_urb_dequeue(struct usb_hcd *hcdunsigned int ep_index;struct xhci_ring *ep_ring;struct xhci_virt_ep *ep; +struct xhci_virt_device *vdev; xhci =hcd_to_xhci (hcd);spin_lock_irqsave (&xhci->lock, flags);/* Make sure the URB hasn't completed or been unlinked already */ ret =usb_hcd_check_unlink_urb (hcd, urb, status); -if (ret || !urb->hcpriv) +if (ret) goto done; + +/* give back URB now if we can't queue it for cancel */ + vdev = xhci->devs[urb->dev->slot_id]; + urb_priv = urb->hcpriv; +if (!vdev || !urb_priv) + goto err_giveback; + +xhci_dbg (xhci,"Cancel URB %p\n" , urb); +xhci_dbg (xhci,"Event ring:\n" ); +xhci_debug_ring (xhci, xhci->event_ring); + ep_index =xhci_get_endpoint_index (&urb->ep->desc); + ep = &vdev->eps[ep_index]; + ep_ring =xhci_urb_to_transfer_ring (xhci, urb); +if (!ep || !ep_ring) + goto err_giveback; + +xhci_dbg (xhci,"Endpoint ring:\n" ); +xhci_debug_ring (xhci, ep_ring); + temp =xhci_readl (xhci, &xhci->op_regs->status);if (temp ==0xffffffff || (xhci->xhc_state &XHCI_STATE_HALTED )) {xhci_dbg (xhci,"HW died, freeing TD.\n" ); - urb_priv = urb->hcpriv;for (i = urb_priv->td_cnt; - i < urb_priv->length && xhci->devs[urb->dev->slot_id]; + i < urb_priv->length; i++) { td = urb_priv->td[i];if (!list_empty (&td->td_list))
@@ -1542,30 +1561,9 @@ int xhci_urb_dequeue(struct usb_hcd *hcdif (!list_empty (&td->cancelled_td_list))list_del_init (&td->cancelled_td_list); } - -usb_hcd_unlink_urb_from_ep (hcd, urb); -spin_unlock_irqrestore (&xhci->lock, flags); -usb_hcd_giveback_urb (hcd, urb, -ESHUTDOWN ); -xhci_urb_free_priv (xhci, urb_priv); -return ret; + goto err_giveback; } -xhci_dbg (xhci,"Cancel URB %p\n" , urb); -xhci_dbg (xhci,"Event ring:\n" ); -xhci_debug_ring (xhci, xhci->event_ring); - ep_index =xhci_get_endpoint_index (&urb->ep->desc); - ep = &xhci->devs[urb->dev->slot_id]->eps[ep_index]; - ep_ring =xhci_urb_to_transfer_ring (xhci, urb); -if (!ep_ring) { - ret = -EINVAL ; - goto done; - } - -xhci_dbg (xhci,"Endpoint ring:\n" ); -xhci_debug_ring (xhci, ep_ring); - - urb_priv = urb->hcpriv; -for (i = urb_priv->td_cnt; i < urb_priv->length; i++) { td = urb_priv->td[i];list_add_tail (&td->cancelled_td_list, &ep->cancelled_td_list);
@@ -1586,6 +1584,14 @@ int xhci_urb_dequeue(struct usb_hcd *hcd done:spin_unlock_irqrestore (&xhci->lock, flags);return ret; + +err_giveback: +if (urb_priv) +xhci_urb_free_priv (xhci, urb_priv); +usb_hcd_unlink_urb_from_ep (hcd, urb); +spin_unlock_irqrestore (&xhci->lock, flags); +usb_hcd_giveback_urb (hcd, urb, -ESHUTDOWN ); +return ret; }/* Drop an endpoint from a new bandwidth configuration for this device.
PATCH 54/95 ubi/upd: Always flush after prepared for an update
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Siewior <[email protected]>
commit 9cd9a21ce070be8a918ffd3381468315a7a76ba6 upstream.
In commit 6afaf8a484cb ("UBI: flush wl before clearing update marker") I managed to trigger and fix a similar bug. Now here is another version of which I assumed it wouldn't matter back then but it turns out UBI has a check for it and will error out like this:
|ubi0 warning: validate_vid_hdr: inconsistent used_ebs |ubi0 error: validate_vid_hdr: inconsistent VID header at PEB 592
All you need to trigger this is? "ubiupdatevol /dev/ubi0_0 file" + a powercut in the middle of the operation.ubi_start_update() sets the update-marker and puts all EBs on the erase list. After that userland can proceed to write new data while the old EB aren't erased completely. A powercut at this point is usually not that much of a tragedy. UBI won't give read access to the static volume because it has the update marker. It will most likely set the corrupted flag because it misses some EBs.
So we are all good. Unless the size of the image that has been written differs from the old image in the magnitude of at least one EB. In that case UBI will find two different values for `used_ebs' and refuse to attach the image with the error message mentioned above.
So in order not to get in the situation, the patch will ensure that we wait until everything is removed before it tries to write any data. The alternative would be to detect such a case and remove all EBs at the attached time after we processed the volume-table and see the update-marker set. The patch looks bigger and I doubt it is worth it since usually the write() will wait from time to time for a new EB since usually there not that many spare EB that can be used.
--- drivers/mtd/ubi/upd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/mtd/ubi/upd.c +4 -4
@@ -150,11 +150,11 @@ int ubi_start_update(struct ubi_device *return err; } -if (bytes ==0 ) { - err =ubi_wl_flush (ubi); -if (err) -return err; + err =ubi_wl_flush (ubi); +if (err) +return err; +if (bytes ==0 ) { err =clear_update_marker (ubi, vol,0 );if (err)return err;
PATCH 55/95 drm/vmwgfx: Type-check lookups of fence objects
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Hellstrom <[email protected]>
commit f7652afa8eadb416b23eb57dec6f158529942041 upstream.
A malicious caller could otherwise hand over handles to other objects causing all sorts of interesting problems.
Testing done: Ran a Fedora 25 desktop using both Xorg and gnome-shell/Wayland.
--- drivers/gpu/drm/vmwgfx/vmwgfx_fence.c | 77 +++++++++++++++++++++++------------ 1 file changed, 50 insertions(+), 27 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_fence.c +49 -25
@@ -493,7 +493,7 @@ int vmw_fence_create(struct vmw_fence_ma struct vmw_fence_obj **p_fence) {struct vmw_fence_obj *fence; -int ret; +int ret; fence =kzalloc (sizeof (*fence),GFP_KERNEL );if (unlikely (fence ==NULL ))
@@ -661,6 +661,41 @@ void vmw_fence_fifo_up(struct vmw_fence_ } +/** +* vmw_fence_obj_lookup - Look up a user-space fence object +* +* @tfile: A struct ttm_object_file identifying the caller. +* @handle: A handle identifying the fence object. +* @return: A struct vmw_user_fence base ttm object on success or +* an error pointer on failure. +* +* The fence object is looked up and type-checked. The caller needs +* to have opened the fence object first, but since that happens on +* creation and fence objects aren't shareable, that's not an +* issue currently. +*/ +static struct ttm_base_object * +vmw_fence_obj_lookup (struct ttm_object_file *tfile,u32 handle) +{ +struct ttm_base_object *base =ttm_base_object_lookup (tfile, handle); + +if (!base) { +pr_err ("Invalid fence object handle 0x%08lx.\n" , + (unsigned long )handle); +return ERR_PTR (-EINVAL ); + } + +if (base->refcount_release != vmw_user_fence_base_release) { +pr_err ("Invalid fence object handle 0x%08lx.\n" , + (unsigned long )handle); +ttm_base_object_unref (&base); +return ERR_PTR (-EINVAL ); + } + +return base; +} + +int vmw_fence_obj_wait_ioctl (struct drm_device *dev,void *data,struct drm_file *file_priv) {
@@ -686,13 +721,9 @@ int vmw_fence_obj_wait_ioctl(struct drm_ arg->kernel_cookie = jiffies + wait_timeout; } - base =ttm_base_object_lookup (tfile, arg->handle); -if (unlikely (base ==NULL )) { -printk (KERN_ERR "Wait invalid fence object handle " -"0x%08lx.\n" , - (unsigned long )arg->handle); -return -EINVAL ; - } + base =vmw_fence_obj_lookup (tfile, arg->handle); +if (IS_ERR (base)) +return PTR_ERR (base); fence = &(container_of(base, struct vmw_user_fence, base)->fence);
@@ -731,13 +762,9 @@ int vmw_fence_obj_signaled_ioctl(structstruct ttm_object_file *tfile =vmw_fpriv (file_priv)->tfile;struct vmw_private *dev_priv =vmw_priv (dev); - base =ttm_base_object_lookup (tfile, arg->handle); -if (unlikely (base ==NULL )) { -printk (KERN_ERR "Fence signaled invalid fence object handle " -"0x%08lx.\n" , - (unsigned long )arg->handle); -return -EINVAL ; - } + base =vmw_fence_obj_lookup (tfile, arg->handle); +if (IS_ERR (base)) +return PTR_ERR (base); fence = &(container_of(base, struct vmw_user_fence, base)->fence); fman = fence->fman;
@@ -987,6 +1014,7 @@ int vmw_fence_event_ioctl(struct drm_dev (struct drm_vmw_fence_event_arg *) data;struct vmw_fence_obj *fence =NULL ;struct vmw_fpriv *vmw_fp =vmw_fpriv (file_priv); +struct ttm_object_file *tfile = vmw_fp->tfile;struct drm_vmw_fence_rep __user *user_fence_rep = (struct drm_vmw_fence_rep __user *)(unsigned long ) arg->fence_rep;
@@ -1002,14 +1030,11 @@ int vmw_fence_event_ioctl(struct drm_dev*/ if (arg->handle) {struct ttm_base_object *base = -ttm_base_object_lookup (vmw_fp->tfile, arg->handle); +vmw_fence_obj_lookup (tfile, arg->handle); + +if (IS_ERR (base)) +return PTR_ERR (base); -if (unlikely (base ==NULL )) { -DRM_ERROR ("Fence event invalid fence object handle " -"0x%08lx.\n" , - (unsigned long )arg->handle); -return -EINVAL ; - } fence = &(container_of(base, struct vmw_user_fence, base)->fence); (void )vmw_fence_obj_reference (fence);
@@ -1017,7 +1042,7 @@ int vmw_fence_event_ioctl(struct drm_devif (user_fence_rep !=NULL ) {bool existed; - ret =ttm_ref_object_add (vmw_fp->tfile, base, + ret =ttm_ref_object_add (tfile, base,TTM_REF_USAGE , &existed);if (unlikely (ret !=0 )) { DRM_ERROR("Failed to reference a fence "
@@ -1099,8 +1124,7 @@ out_no_event:spin_unlock_irqrestore (&dev->event_lock, irq_flags); out_no_event_space:if (user_fence_rep !=NULL ) -ttm_ref_object_base_unref (vmw_fpriv (file_priv)->tfile, - handle,TTM_REF_USAGE ); +ttm_ref_object_base_unref (tfile, handle,TTM_REF_USAGE ); out_no_ref_obj:vmw_fence_obj_unreference (&fence);return ret;
PATCH 56/95 drm/vmwgfx: avoid calling vzalloc with a 0 size in vmw_get_cap_3d_ioctl()
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Murray McAllister <[email protected]>
commit 63774069d9527a1aeaa4aa20e929ef5e8e9ecc38 upstream.
In vmw_get_cap_3d_ioctl(), a user can supply 0 for a size that is used in vzalloc(). This eventually calls dump_stack() (in warn_alloc()), which can leak useful addresses to dmesg.
Add check to avoid a size of 0.
--- drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c +1 -1
@@ -90,7 +90,7 @@ int vmw_get_cap_3d_ioctl(struct drm_devivoid *bounce;int ret; -if (unlikely (arg->pad64 !=0 )) { +if (unlikely (arg->pad64 !=0 || arg->max_size ==0 )) {DRM_ERROR ("Illegal GET_3D_CAP argument.\n" );return -EINVAL ; }
PATCH 57/95 drm/vmwgfx: Remove getparam error message
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Hellstrom <[email protected]>
commit 53e16798b0864464c5444a204e1bb93ae246c429 upstream.
The mesa winsys sometimes uses unimplemented parameter requests to check for features. Remove the error message to avoid bloating the kernel log.
--- drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c +0 -2
@@ -69,8 +69,6 @@ int vmw_getparam_ioctl(struct drm_devicebreak ; }default : -DRM_ERROR ("Illegal vmwgfx get param request: %d\n" , - param->param);return -EINVAL ; }
PATCH 58/95 mmc: sdhci: Disable runtime pm when the sdio_irq is enabled
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit 923713b357455cfb9aca2cd3429cb0806a724ed2 upstream.
SDIO cards may need clock to send the card interrupt to the host.
On a cherrytrail tablet with a RTL8723BS wifi chip, without this patch pinging the tablet results in:
PING 192.168.1.14 (192.168.1.14) 56(84) bytes of data. 64 bytes from 192.168.1.14: icmp_seq=1 ttl=64 time=78.6 ms 64 bytes from 192.168.1.14: icmp_seq=2 ttl=64 time=1760 ms 64 bytes from 192.168.1.14: icmp_seq=3 ttl=64 time=753 ms 64 bytes from 192.168.1.14: icmp_seq=4 ttl=64 time=3.88 ms 64 bytes from 192.168.1.14: icmp_seq=5 ttl=64 time=795 ms 64 bytes from 192.168.1.14: icmp_seq=6 ttl=64 time=1841 ms 64 bytes from 192.168.1.14: icmp_seq=7 ttl=64 time=810 ms 64 bytes from 192.168.1.14: icmp_seq=8 ttl=64 time=1860 ms 64 bytes from 192.168.1.14: icmp_seq=9 ttl=64 time=812 ms 64 bytes from 192.168.1.14: icmp_seq=10 ttl=64 time=48.6 ms
Where as with this patch I get:
PING 192.168.1.14 (192.168.1.14) 56(84) bytes of data. 64 bytes from 192.168.1.14: icmp_seq=1 ttl=64 time=3.96 ms 64 bytes from 192.168.1.14: icmp_seq=2 ttl=64 time=1.97 ms 64 bytes from 192.168.1.14: icmp_seq=3 ttl=64 time=17.2 ms 64 bytes from 192.168.1.14: icmp_seq=4 ttl=64 time=2.46 ms 64 bytes from 192.168.1.14: icmp_seq=5 ttl=64 time=2.83 ms 64 bytes from 192.168.1.14: icmp_seq=6 ttl=64 time=1.40 ms 64 bytes from 192.168.1.14: icmp_seq=7 ttl=64 time=2.10 ms 64 bytes from 192.168.1.14: icmp_seq=8 ttl=64 time=1.40 ms 64 bytes from 192.168.1.14: icmp_seq=9 ttl=64 time=2.04 ms 64 bytes from 192.168.1.14: icmp_seq=10 ttl=64 time=1.40 ms
--- drivers/mmc/host/sdhci.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/mmc/host/sdhci.c +6 -0
@@ -1546,9 +1546,15 @@ static void sdhci_enable_sdio_irq(structstruct sdhci_host *host =mmc_priv (mmc);unsigned long flags; +if (enable) +pm_runtime_get_noresume (host->mmc->parent); +spin_lock_irqsave (&host->lock, flags);sdhci_enable_sdio_irq_nolock (host, enable);spin_unlock_irqrestore (&host->lock, flags); + +if (!enable) +pm_runtime_put_noidle (host->mmc->parent); } static int sdhci_do_start_signal_voltage_switch(struct sdhci_host *host,
PATCH 59/95 serial: mxs-auart: fix baud rate range
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Wahren <[email protected]>
commit df57cf6a879502cd6e5559c1f2d6db12128e074f upstream.
Currently mxs-auart doesn't care correctly about the baud rate divisor. According to reference manual the baud rate divisor must be between 0x000000EC and 0x003FFFC0. So calculate the possible baud rate range and use it for uart_get_baud_rate().
--- drivers/tty/serial/mxs-auart.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/tty/serial/mxs-auart.c +6 -2
@@ -76,6 +76,8 @@#define AUART_CTRL2_TXE (1 << 8)#define AUART_CTRL2_UARTEN (1 << 0) +#define AUART_LINECTRL_BAUD_DIV_MAX 0x003fffc0 +#define AUART_LINECTRL_BAUD_DIV_MIN 0x000000ec#define AUART_LINECTRL_BAUD_DIVINT_SHIFT 16#define AUART_LINECTRL_BAUD_DIVINT_MASK 0xffff0000#define AUART_LINECTRL_BAUD_DIVINT (v) (((v) & 0xffff) << 16)
@@ -285,7 +287,7 @@ static void mxs_auart_settermios(struct struct ktermios *old) {u32 bm, ctrl, ctrl2, div; -unsigned int cflag, baud; +unsigned int cflag, baud, baud_min, baud_max; cflag = termios->c_cflag;
@@ -361,7 +363,9 @@ static void mxs_auart_settermios(struct ctrl2 &= ~AUART_CTRL2_CTSEN ;/* set baud rate */ - baud =uart_get_baud_rate (u, termios, old,0 , u->uartclk); + baud_min =DIV_ROUND_UP (u->uartclk *32 ,AUART_LINECTRL_BAUD_DIV_MAX ); + baud_max = u->uartclk *32 /AUART_LINECTRL_BAUD_DIV_MIN ; + baud =uart_get_baud_rate (u, termios, old, baud_min, baud_max); div = u->uartclk *32 / baud; ctrl |=AUART_LINECTRL_BAUD_DIVFRAC (div &0x3F ); ctrl |=AUART_LINECTRL_BAUD_DIVINT (div >>6 );
PATCH 60/95 serial: mxs-auart: Fix baudrate calculation
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
commit a6040bc610554c66088fda3608ae5d6307c548e4 upstream.
The reference manual for the i.MX28 recommends to calculate the divisor as
divisor = (UARTCLK * 32) / baud rate, rounded to the nearest integer
, so let's do this. For a typical setup of UARTCLK = 24 MHz and baud rate = 115200 this changes the divisor from 6666 to 6667 and so the actual baud rate improves from 115211.521 Bd (error ≅ 0.01 %) to 115194.240 Bd (error ≅ 0.005 %).
--- drivers/tty/serial/mxs-auart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/mxs-auart.c +1 -1
@@ -366,7 +366,7 @@ static void mxs_auart_settermios(struct baud_min =DIV_ROUND_UP (u->uartclk *32 ,AUART_LINECTRL_BAUD_DIV_MAX ); baud_max = u->uartclk *32 /AUART_LINECTRL_BAUD_DIV_MIN ; baud =uart_get_baud_rate (u, termios, old, baud_min, baud_max); - div = u->uartclk *32 / baud; + div =DIV_ROUND_CLOSEST (u->uartclk *32 , baud); ctrl |=AUART_LINECTRL_BAUD_DIVFRAC (div &0x3F ); ctrl |=AUART_LINECTRL_BAUD_DIVINT (div >>6 );
PATCH 61/95 l2tp: fix race in l2tp_recv_common()
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Guillaume Nault <[email protected]>
commit 61b9a047729bb230978178bca6729689d0c50ca2 upstream.
Taking a reference on sessions in l2tp_recv_common() is racy; this has to be done by the callers.
To this end, a new function is required (l2tp_session_get()) to atomically lookup a session and take a reference on it. Callers then have to manually drop this reference.
[bwh: Backported to 3.2:
- Drop changes to l2tp_ip6.c
- Add 'pos' parameter to hlist_for_each_entry{,_rcu}() calls
- Adjust context]
---
net/l2tp/l2tp_core.c +61 -13
@@ -225,6 +225,56 @@ struct l2tp_session *l2tp_session_find(s }EXPORT_SYMBOL_GPL (l2tp_session_find); +/* Like l2tp_session_find() but takes a reference on the returned session. +* Optionally calls session->ref() too if do_ref is true. +*/ +struct l2tp_session *l2tp_session_get (struct net *net, +struct l2tp_tunnel *tunnel, +u32 session_id,bool do_ref) +{ +struct hlist_head *session_list; +struct l2tp_session *session; +struct hlist_node *walk; + +if (!tunnel) { +struct l2tp_net *pn =l2tp_pernet (net); + + session_list =l2tp_session_id_hash_2 (pn, session_id); + +rcu_read_lock_bh (); +hlist_for_each_entry_rcu (session, walk, session_list, global_hlist) { +if (session->session_id == session_id) { +l2tp_session_inc_refcount (session); +if (do_ref && session->ref) + session->ref (session); +rcu_read_unlock_bh (); + +return session; + } + } +rcu_read_unlock_bh (); + +return NULL ; + } + + session_list =l2tp_session_id_hash (tunnel, session_id); +read_lock_bh (&tunnel->hlist_lock); +hlist_for_each_entry (session, walk, session_list, hlist) { +if (session->session_id == session_id) { +l2tp_session_inc_refcount (session); +if (do_ref && session->ref) + session->ref (session); +read_unlock_bh (&tunnel->hlist_lock); + +return session; + } + } +read_unlock_bh (&tunnel->hlist_lock); + +return NULL ; +} +EXPORT_SYMBOL_GPL (l2tp_session_get); +struct l2tp_session *l2tp_session_find_nth (struct l2tp_tunnel *tunnel,int nth) {int hash;
@@ -524,6 +574,9 @@ static inline int l2tp_verify_udp_checks* a data (not control) frame before coming here. Fields up to the * session-id have already been parsed and ptr points to the data * after the session-id. +* +* session->ref() must have been called prior to l2tp_recv_common(). +* session->deref() will be called automatically after skb is processed. */ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb, unsigned char *ptr, unsigned char *optr, u16 hdrflags,
@@ -533,14 +586,6 @@ void l2tp_recv_common(struct l2tp_sessioint offset;u32 ns, nr; -/* The ref count is increased since we now hold a pointer to -* the session. Take care to decrement the refcnt when exiting -* this function from now on... -*/ -l2tp_session_inc_refcount (session); -if (session->ref) - (*session->ref)(session); -/* Parse and check optional cookie */ if (session->peer_cookie_len >0 ) {if (memcmp (ptr, &session->peer_cookie[0 ], session->peer_cookie_len)) {
@@ -711,8 +756,6 @@ void l2tp_recv_common(struct l2tp_sessio/* Try to dequeue as many skbs from reorder_q as we can. */ l2tp_recv_dequeue (session); -l2tp_session_dec_refcount (session); -return ; discard:
@@ -721,8 +764,6 @@ discard:if (session->deref) (*session->deref)(session); - -l2tp_session_dec_refcount (session); }EXPORT_SYMBOL (l2tp_recv_common);
@@ -818,8 +859,14 @@ static int l2tp_udp_recv_core(struct l2t }/* Find the session context */ - session =l2tp_session_find (tunnel->l2tp_net, tunnel, session_id); + session =l2tp_session_get (tunnel->l2tp_net, tunnel, session_id, true);if (!session || !session->recv_skb) { +if (session) { +if (session->deref) + session->deref (session); +l2tp_session_dec_refcount (session); + } +/* Not found? Pass to userspace to deal with */ PRINTK(tunnel->debug, L2TP_MSG_DATA, KERN_INFO, "%s: no session found (%u/%u). Passing up.\n",
@@ -828,6 +875,7 @@ static int l2tp_udp_recv_core(struct l2t }l2tp_recv_common (session, skb, ptr, optr, hdrflags, length, payload_hook); +l2tp_session_dec_refcount (session);return 0 ;
net/l2tp/l2tp_core.h +3 -0
@@ -222,6 +222,9 @@ out:return tunnel; } +struct l2tp_session *l2tp_session_get (struct net *net, +struct l2tp_tunnel *tunnel, +u32 session_id,bool do_ref);extern struct l2tp_session *l2tp_session_find (struct net *net,struct l2tp_tunnel *tunnel,u32 session_id);extern struct l2tp_session *l2tp_session_find_nth (struct l2tp_tunnel *tunnel,int nth);extern struct l2tp_session *l2tp_session_find_by_ifname (struct net *net,char *ifname);
net/l2tp/l2tp_ip.c +12 -5
@@ -148,19 +148,19 @@ static int l2tp_ip_recv(struct sk_buff * }/* Ok, this is a data packet. Lookup the session. */ - session =l2tp_session_find (&init_net,NULL , session_id); -if (session ==NULL ) + session =l2tp_session_get (&init_net,NULL , session_id, true); +if (!session) goto discard; tunnel = session->tunnel; -if (tunnel ==NULL ) - goto discard; +if (!tunnel) + goto discard_sess;/* Trace packet contents, if enabled */ if (tunnel->debug &L2TP_MSG_DATA ) { length =min (32u , skb->len);if (!pskb_may_pull (skb, length)) - goto discard; + goto discard_sess;/* Point to L2TP header */ optr = ptr = skb->data;
@@ -176,6 +176,7 @@ static int l2tp_ip_recv(struct sk_buff * }l2tp_recv_common (session, skb, ptr, optr,0 , skb->len, tunnel->recv_payload_hook); +l2tp_session_dec_refcount (session);return 0 ;
@@ -211,6 +212,12 @@ pass_up:return sk_receive_skb (sk, skb,1 ); +discard_sess: +if (session->deref) + session->deref (session); +l2tp_session_dec_refcount (session); + goto discard; + discard_put:sock_put (sk);
PATCH 62/95 l2tp: ensure session can't get removed during pppol2tp_session_ioctl()
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Guillaume Nault <[email protected]>
commit 57377d63547861919ee634b845c7caa38de4a452 upstream.
Holding a reference on session is required before calling pppol2tp_session_ioctl(). The session could get freed while processing the ioctl otherwise. Since pppol2tp_session_ioctl() uses the session's socket, we also need to take a reference on it in l2tp_session_get().
--- net/l2tp/l2tp_ppp.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
net/l2tp/l2tp_ppp.c +11 -4
@@ -1150,11 +1150,18 @@ static int pppol2tp_tunnel_ioctl(structif (stats.session_id !=0 ) {/* resend to session ioctl handler */ struct l2tp_session *session = -l2tp_session_find (sock_net (sk), tunnel, stats.session_id); -if (session !=NULL ) - err =pppol2tp_session_ioctl (session, cmd, arg); -else +l2tp_session_get (sock_net (sk), tunnel, + stats.session_id, true); + +if (session) { + err =pppol2tp_session_ioctl (session, cmd, + arg); +if (session->deref) + session->deref (session); +l2tp_session_dec_refcount (session); + }else { err = -EBADR ; + }break ; }#ifdef CONFIG_XFRM
PATCH 63/95 l2tp: fix duplicate session creation
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Guillaume Nault <[email protected]>
commit dbdbc73b44782e22b3b4b6e8b51e7a3d245f3086 upstream.
l2tp_session_create() relies on its caller for checking for duplicate sessions. This is racy since a session can be concurrently inserted after the caller's verification.
Fix this by letting l2tp_session_create() verify sessions uniqueness upon insertion. Callers need to be adapted to check for l2tp_session_create()'s return code instead of calling l2tp_session_find().
pppol2tp_connect() is a bit special because it has to work on existing sessions (if they're not connected) or to create a new session if none is found. When acting on a preexisting session, a reference must be held or it could go away on us. So we have to use l2tp_session_get() instead of l2tp_session_find() and drop the reference before exiting.
[bwh: Backported to 3.2: add 'pos' parameter to
hlist_for_each_entry{,_rcu}() calls]
--- net/l2tp/l2tp_core.c | 70 +++++++++++++++++++++++++++++++++++++++------------- net/l2tp/l2tp_eth.c | 10 ++------ net/l2tp/l2tp_ppp.c | 60 ++++++++++++++++++++++---------------------- 3 files changed, 84 insertions(+), 56 deletions(-)
net/l2tp/l2tp_core.c +54 -17
@@ -324,6 +324,49 @@ struct l2tp_session *l2tp_session_find_b }EXPORT_SYMBOL_GPL (l2tp_session_find_by_ifname); +static int l2tp_session_add_to_tunnel (struct l2tp_tunnel *tunnel, +struct l2tp_session *session) +{ +struct l2tp_session *session_walk; +struct hlist_head *g_head; +struct hlist_head *head; +struct l2tp_net *pn; +struct hlist_node *walk; + + head =l2tp_session_id_hash (tunnel, session->session_id); + +write_lock_bh (&tunnel->hlist_lock); +hlist_for_each_entry (session_walk, walk, head, hlist) +if (session_walk->session_id == session->session_id) + goto exist; + +if (tunnel->version ==L2TP_HDR_VER_3 ) { + pn =l2tp_pernet (tunnel->l2tp_net); + g_head =l2tp_session_id_hash_2 (l2tp_pernet (tunnel->l2tp_net), + session->session_id); + +spin_lock_bh (&pn->l2tp_session_hlist_lock); +hlist_for_each_entry (session_walk, walk, g_head, global_hlist) +if (session_walk->session_id == session->session_id) + goto exist_glob; + +hlist_add_head_rcu (&session->global_hlist, g_head); +spin_unlock_bh (&pn->l2tp_session_hlist_lock); + } + +hlist_add_head (&session->hlist, head); +write_unlock_bh (&tunnel->hlist_lock); + +return 0 ; + +exist_glob: +spin_unlock_bh (&pn->l2tp_session_hlist_lock); +exist: +write_unlock_bh (&tunnel->hlist_lock); + +return -EEXIST ; +} +/* Lookup a tunnel by id */ struct l2tp_tunnel *l2tp_tunnel_find (struct net *net,u32 tunnel_id)
@@ -1616,6 +1659,7 @@ static void l2tp_session_set_header_len(struct l2tp_session *l2tp_session_create (int priv_size,struct l2tp_tunnel *tunnel,u32 session_id,u32 peer_session_id,struct l2tp_session_cfg *cfg) {struct l2tp_session *session; +int err; session =kzalloc (sizeof (struct l2tp_session ) + priv_size,GFP_KERNEL );if (session !=NULL ) {
@@ -1662,6 +1706,13 @@ struct l2tp_session *l2tp_session_createl2tp_session_set_header_len (session, tunnel->version); + err =l2tp_session_add_to_tunnel (tunnel, session); +if (err) { +kfree (session); + +return ERR_PTR (err); + } +/* Bump the reference count. The session context is deleted * only when this drops to zero. */
@@ -1671,28 +1722,14 @@ struct l2tp_session *l2tp_session_create/* Ensure tunnel socket isn't deleted */ sock_hold (tunnel->sock); -/* Add session to the tunnel's hash list */ -write_lock_bh (&tunnel->hlist_lock); -hlist_add_head (&session->hlist, -l2tp_session_id_hash (tunnel, session_id)); -write_unlock_bh (&tunnel->hlist_lock); - -/* And to the global session list if L2TPv3 */ -if (tunnel->version !=L2TP_HDR_VER_2 ) { -struct l2tp_net *pn =l2tp_pernet (tunnel->l2tp_net); - -spin_lock_bh (&pn->l2tp_session_hlist_lock); -hlist_add_head_rcu (&session->global_hlist, -l2tp_session_id_hash_2 (pn, session_id)); -spin_unlock_bh (&pn->l2tp_session_hlist_lock); - } -/* Ignore management session in session count value */ if (session->session_id !=0 )atomic_inc (&l2tp_session_count); + +return session; } -return session; +return ERR_PTR (-ENOMEM ); }EXPORT_SYMBOL_GPL (l2tp_session_create);
net/l2tp/l2tp_eth.c +2 -8
@@ -200,12 +200,6 @@ static int l2tp_eth_create(struct net *n goto out; } - session =l2tp_session_find (net, tunnel, session_id); -if (session) { - rc = -EEXIST ; - goto out; - } -if (cfg->ifname) { dev =dev_get_by_name (net, cfg->ifname);if (dev) {
@@ -219,8 +213,8 @@ static int l2tp_eth_create(struct net *n session =l2tp_session_create (sizeof (*spriv), tunnel, session_id, peer_session_id, cfg); -if (!session) { - rc = -ENOMEM ; +if (IS_ERR (session)) { + rc =PTR_ERR (session); goto out; }
net/l2tp/l2tp_ppp.c +29 -31
101 lines not on this page · raw message
PATCH 64/95 l2tp: take a reference on sessions used in genetlink handlers
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Guillaume Nault <[email protected]>
commit 2777e2ab5a9cf2b4524486c6db1517a6ded25261 upstream.
Callers of l2tp_nl_session_find() need to hold a reference on the returned session since there's no guarantee that it isn't going to disappear from under them.
Relying on the fact that no l2tp netlink message may be processed concurrently isn't enough: sessions can be deleted by other means (e.g. by closing the PPPOL2TP socket of a ppp pseudowire).
l2tp_nl_cmd_session_delete() is a bit special: it runs a callback function that may require a previous call to session->ref(). In particular, for ppp pseudowires, the callback is l2tp_session_delete(), which then calls pppol2tp_session_close() and dereferences the PPPOL2TP socket. The socket might already be gone at the moment l2tp_session_delete() calls session->ref(), so we need to take a reference during the session lookup. So we need to pass the do_ref variable down to l2tp_session_get() and l2tp_session_get_by_ifname().
Since all callers have to be updated, l2tp_session_find_by_ifname() and l2tp_nl_session_find() are renamed to reflect their new behaviour.
--- net/l2tp/l2tp_core.c | 9 +++++++-- net/l2tp/l2tp_core.h | 3 ++- net/l2tp/l2tp_netlink.c | 39 ++++++++++++++++++++++++++------------- 3 files changed, 35 insertions(+), 16 deletions(-)
net/l2tp/l2tp_core.c +7 -2
@@ -301,7 +301,8 @@ EXPORT_SYMBOL_GPL(l2tp_session_find_nth)/* Lookup a session by interface name. * This is very inefficient but is only used by management interfaces. */ -struct l2tp_session *l2tp_session_find_by_ifname (struct net *net,char *ifname) +struct l2tp_session *l2tp_session_get_by_ifname (struct net *net,char *ifname, +bool do_ref) {struct l2tp_net *pn =l2tp_pernet (net);int hash;
@@ -312,7 +313,11 @@ struct l2tp_session *l2tp_session_find_bfor (hash =0 ; hash <L2TP_HASH_SIZE_2 ; hash++) {hlist_for_each_entry_rcu (session, walk, &pn->l2tp_session_hlist[hash], global_hlist) {if (!strcmp (session->ifname, ifname)) { +l2tp_session_inc_refcount (session); +if (do_ref && session->ref) + session->ref (session);rcu_read_unlock_bh (); +return session; } }
@@ -322,7 +327,7 @@ struct l2tp_session *l2tp_session_find_breturn NULL ; } -EXPORT_SYMBOL_GPL (l2tp_session_find_by_ifname); +EXPORT_SYMBOL_GPL (l2tp_session_get_by_ifname);static int l2tp_session_add_to_tunnel (struct l2tp_tunnel *tunnel,struct l2tp_session *session)
net/l2tp/l2tp_core.h +2 -1
@@ -227,7 +227,8 @@ struct l2tp_session *l2tp_session_get(st u32 session_id, bool do_ref);extern struct l2tp_session *l2tp_session_find (struct net *net,struct l2tp_tunnel *tunnel,u32 session_id);extern struct l2tp_session *l2tp_session_find_nth (struct l2tp_tunnel *tunnel,int nth); -extern struct l2tp_session *l2tp_session_find_by_ifname (struct net *net,char *ifname); +struct l2tp_session *l2tp_session_get_by_ifname (struct net *net,char *ifname, +bool do_ref);extern struct l2tp_tunnel *l2tp_tunnel_find (struct net *net,u32 tunnel_id);extern struct l2tp_tunnel *l2tp_tunnel_find_nth (struct net *net,int nth);
net/l2tp/l2tp_netlink.c +26 -13
@@ -40,7 +40,8 @@ static struct genl_family l2tp_nl_family/* Accessed under genl lock */ static const struct l2tp_nl_cmd_ops *l2tp_nl_cmd_ops[__L2TP_PWTYPE_MAX]; -static struct l2tp_session *l2tp_nl_session_find (struct genl_info *info) +static struct l2tp_session *l2tp_nl_session_get (struct genl_info *info, +bool do_ref) {u32 tunnel_id;u32 session_id;
@@ -51,14 +52,15 @@ static struct l2tp_session *l2tp_nl_sessif (info->attrs[L2TP_ATTR_IFNAME ]) { ifname =nla_data (info->attrs[L2TP_ATTR_IFNAME ]); - session =l2tp_session_find_by_ifname (net, ifname); + session =l2tp_session_get_by_ifname (net, ifname, do_ref); }else if ((info->attrs[L2TP_ATTR_SESSION_ID ]) && (info->attrs[L2TP_ATTR_CONN_ID ])) { tunnel_id =nla_get_u32 (info->attrs[L2TP_ATTR_CONN_ID ]); session_id =nla_get_u32 (info->attrs[L2TP_ATTR_SESSION_ID ]); tunnel =l2tp_tunnel_find (net, tunnel_id);if (tunnel) - session =l2tp_session_find (net, tunnel, session_id); + session =l2tp_session_get (net, tunnel, session_id, + do_ref); }return session;
@@ -495,7 +497,7 @@ static int l2tp_nl_cmd_session_delete(ststruct l2tp_session *session;u16 pw_type; - session =l2tp_nl_session_find (info); + session =l2tp_nl_session_get (info, true);if (session ==NULL ) { ret = -ENODEV ; goto out;
@@ -506,6 +508,10 @@ static int l2tp_nl_cmd_session_delete(stif (l2tp_nl_cmd_ops[pw_type] && l2tp_nl_cmd_ops[pw_type]->session_delete) ret = (*l2tp_nl_cmd_ops[pw_type]->session_delete)(session); +if (session->deref) + session->deref (session); +l2tp_session_dec_refcount (session); + out:return ret; }
@@ -515,7 +521,7 @@ static int l2tp_nl_cmd_session_modify(stint ret =0 ;struct l2tp_session *session; - session =l2tp_nl_session_find (info); + session =l2tp_nl_session_get (info, false);if (session ==NULL ) { ret = -ENODEV ; goto out;
@@ -545,6 +551,8 @@ static int l2tp_nl_cmd_session_modify(stif (info->attrs[L2TP_ATTR_MRU ]) session->mru =nla_get_u16 (info->attrs[L2TP_ATTR_MRU ]); +l2tp_session_dec_refcount (session); + out:return ret; }
@@ -615,29 +623,34 @@ static int l2tp_nl_cmd_session_get(strucstruct sk_buff *msg;int ret; - session =l2tp_nl_session_find (info); + session =l2tp_nl_session_get (info, false);if (session ==NULL ) { ret = -ENODEV ; - goto out; + goto err; } msg =nlmsg_new (NLMSG_GOODSIZE ,GFP_KERNEL );if (!msg) { ret = -ENOMEM ; - goto out; + goto err_ref; } ret =l2tp_nl_session_send (msg, info->snd_pid, info->snd_seq,0 , session);if (ret <0 ) - goto err_out; + goto err_ref_msg; -return genlmsg_unicast (genl_info_net (info), msg, info->snd_pid); + ret =genlmsg_unicast (genl_info_net (info), msg, info->snd_pid); -err_out: -nlmsg_free (msg); +l2tp_session_dec_refcount (session); -out: +return ret; + +err_ref_msg: +nlmsg_free (msg); +err_ref: +l2tp_session_dec_refcount (session); +err:return ret; }
PATCH 65/95 iscsi-target: Drop work-around for legacy GlobalSAN initiator
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Nicholas Bellinger <[email protected]>
commit 1c99de981f30b3e7868b8d20ce5479fa1c0fea46 upstream.
Once upon a time back in 2009, a work-around was added to support the GlobalSAN iSCSI initiator v3.3 for MacOSX, which during login did not propose nor respond to MaxBurstLength, FirstBurstLength, DefaultTime2Wait and DefaultTime2Retain keys.
The work-around in iscsi_check_proposer_for_optional_reply() allowed the missing keys to be proposed, but did not require waiting for a response before moving to full feature phase operation. This allowed GlobalSAN v3.3 to work out-of-the box, and for many years we didn't run into login interopt issues with any other initiators..
Until recently, when Martin tried a QLogic 57840S iSCSI Offload HBA on Windows 2016 which completed login, but subsequently failed with:
Got unknown iSCSI OpCode: 0x43
The issue was QLogic MSFT side did not propose DefaultTime2Wait + DefaultTime2Retain, so LIO proposes them itself, and immediately transitions to full feature phase because of the GlobalSAN hack. However, the QLogic MSFT side still attempts to respond to DefaultTime2Retain + DefaultTime2Wait, even though LIO has set ISCSI_FLAG_LOGIN_NEXT_STAGE3 + ISCSI_FLAG_LOGIN_TRANSIT in last login response.
So while the QLogic MSFT side should have been proposing these two keys to start, it was doing the correct thing per RFC-3720 attempting to respond to proposed keys before transitioning to full feature phase.
All that said, recent versions of GlobalSAN iSCSI (v5.3.0.541) does correctly propose the four keys during login, making the original work-around moot.
So in order to allow QLogic MSFT to run unmodified as-is, go ahead and drop this long standing work-around.
--- drivers/target/iscsi/iscsi_target_parameters.c | 16 ---------------- 1 file changed, 16 deletions(-)
drivers/target/iscsi/iscsi_target_parameters.c +0 -16
@@ -761,22 +761,6 @@ static void iscsi_check_proposer_for_optif (!strcmp (param->name,MAXRECVDATASEGMENTLENGTH ))SET_PSTATE_REPLY_OPTIONAL (param);/* -* The GlobalSAN iSCSI Initiator for MacOSX does -* not respond to MaxBurstLength, FirstBurstLength, -* DefaultTime2Wait or DefaultTime2Retain parameter keys. -* So, we set them to 'reply optional' here, and assume the -* the defaults from iscsi_parameters.h if the initiator -* is not RFC compliant and the keys are not negotiated. -*/ -if (!strcmp (param->name,MAXBURSTLENGTH )) -SET_PSTATE_REPLY_OPTIONAL (param); -if (!strcmp (param->name,FIRSTBURSTLENGTH )) -SET_PSTATE_REPLY_OPTIONAL (param); -if (!strcmp (param->name,DEFAULTTIME2WAIT )) -SET_PSTATE_REPLY_OPTIONAL (param); -if (!strcmp (param->name,DEFAULTTIME2RETAIN )) -SET_PSTATE_REPLY_OPTIONAL (param); -/* * Required for gPXE iSCSI boot client */ if (!strcmp (param->name,MAXCONNECTIONS ))
PATCH 66/95 af_key: Add lock to key dump
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Yuejie Shi <[email protected]>
commit 89e357d83c06b6fac581c3ca7f0ee3ae7e67109e upstream.
A dump may come in the middle of another dump, modifying its dump structure members. This race condition will result in NULL pointer dereference in kernel. So add a lock to prevent that race.
[bwh: Backported to 3.2:
- pfkey_dump() doesn't support filters
- Adjust context]
---
net/key/af_key.c +35 -7
@@ -63,6 +63,7 @@ struct pfkey_sock { } u;struct sk_buff *skb; } dump; +struct mutex dump_lock; };static inline struct pfkey_sock *pfkey_sk (struct sock *sk)
@@ -139,6 +140,7 @@ static int pfkey_create(struct net *net, {struct netns_pfkey *net_pfkey =net_generic (net, pfkey_net_id);struct sock *sk; +struct pfkey_sock *pfk;int err;if (!capable (CAP_NET_ADMIN ))
@@ -153,6 +155,9 @@ static int pfkey_create(struct net *net,if (sk ==NULL ) goto out; + pfk =pfkey_sk (sk); +mutex_init (&pfk->dump_lock); + sock->ops = &pfkey_ops;sock_init_data (sock, sk);
@@ -283,13 +288,23 @@ static int pfkey_do_dump(struct pfkey_sostruct sadb_msg *hdr;int rc; +mutex_lock (&pfk->dump_lock); +if (!pfk->dump.dump) { + rc =0 ; + goto out; + } + rc = pfk->dump.dump (pfk); -if (rc == -ENOBUFS ) -return 0 ; +if (rc == -ENOBUFS ) { + rc =0 ; + goto out; + }if (pfk->dump.skb) { -if (!pfkey_can_dump (&pfk->sk)) -return 0 ; +if (!pfkey_can_dump (&pfk->sk)) { + rc =0 ; + goto out; + } hdr = (struct sadb_msg *) pfk->dump.skb->data; hdr->sadb_msg_seq =0 ;
@@ -300,6 +315,9 @@ static int pfkey_do_dump(struct pfkey_so }pfkey_terminate_dump (pfk); + +out: +mutex_unlock (&pfk->dump_lock);return rc; }
@@ -1791,18 +1809,24 @@ static int pfkey_dump(struct sock *sk, su8 proto;struct pfkey_sock *pfk =pfkey_sk (sk); -if (pfk->dump.dump !=NULL ) +mutex_lock (&pfk->dump_lock); +if (pfk->dump.dump !=NULL ) { +mutex_unlock (&pfk->dump_lock);return -EBUSY ; + } proto =pfkey_satype2proto (hdr->sadb_msg_satype); -if (proto ==0 ) +if (proto ==0 ) { +mutex_unlock (&pfk->dump_lock);return -EINVAL ; + } pfk->dump.msg_version = hdr->sadb_msg_version; pfk->dump.msg_pid = hdr->sadb_msg_pid; pfk->dump.dump = pfkey_dump_sa; pfk->dump.done = pfkey_dump_sa_done;xfrm_state_walk_init (&pfk->dump.u.state, proto); +mutex_unlock (&pfk->dump_lock);return pfkey_do_dump (pfk); }
@@ -2661,14 +2685,18 @@ static int pfkey_spddump(struct sock *sk {struct pfkey_sock *pfk =pfkey_sk (sk); -if (pfk->dump.dump !=NULL ) +mutex_lock (&pfk->dump_lock); +if (pfk->dump.dump !=NULL ) { +mutex_unlock (&pfk->dump_lock);return -EBUSY ; + } pfk->dump.msg_version = hdr->sadb_msg_version; pfk->dump.msg_pid = hdr->sadb_msg_pid; pfk->dump.dump = pfkey_dump_sp; pfk->dump.done = pfkey_dump_sp_done;xfrm_policy_walk_init (&pfk->dump.u.policy,XFRM_POLICY_TYPE_MAIN ); +mutex_unlock (&pfk->dump_lock);return pfkey_do_dump (pfk); }
PATCH 67/95 powerpc: Don't try to fix up misaligned load-with-reservation instructions
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Paul Mackerras <[email protected]>
commit 48fe9e9488743eec9b7c1addd3c93f12f2123d54 upstream.
In the past, there was only one load-with-reservation instruction, lwarx, and if a program attempted a lwarx on a misaligned address, it would take an alignment interrupt and the kernel handler would emulate it as though it was lwzx, which was not really correct, but benign since it is loading the right amount of data, and the lwarx should be paired with a stwcx. to the same address, which would also cause an alignment interrupt which would result in a SIGBUS being delivered to the process.
We now have 5 different sizes of load-with-reservation instruction. Of those, lharx and ldarx cause an immediate SIGBUS by luck since their entries in aligninfo[] overlap instructions which were not fixed up, but lqarx overlaps with lhz and will be emulated as such. lbarx can never generate an alignment interrupt since it only operates on 1 byte.
To straighten this out and fix the lqarx case, this adds code to detect the l[hwdq]arx instructions and return without fixing them up, resulting in a SIGBUS being delivered to the process.
--- arch/powerpc/kernel/align.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-)
arch/powerpc/kernel/align.c +19 -8
@@ -764,14 +764,25 @@ int fix_alignment(struct pt_regs *regs) nb = aligninfo[instr].len; flags = aligninfo[instr].flags; -/* ldbrx/stdbrx overlap lfs/stfs in the DSISR unfortunately */ -if (IS_XFORM (instruction) && ((instruction >>1 ) &0x3ff ) ==532 ) { - nb =8 ; - flags =LD +SW ; - }else if (IS_XFORM (instruction) && - ((instruction >>1 ) &0x3ff ) ==660 ) { - nb =8 ; - flags =ST +SW ; +/* +* Handle some cases which give overlaps in the DSISR values. +*/ +if (IS_XFORM (instruction)) { +switch ((instruction >>1 ) &0x3ff ) { +case 532 :/* ldbrx */ + nb =8 ; + flags =LD +SW ; +break ; +case 660 :/* stdbrx */ + nb =8 ; + flags =ST +SW ; +break ; +case 20 :/* lwarx */ +case 84 :/* ldarx */ +case 116 :/* lharx */ +case 276 :/* lqarx */ +return 0 ;/* not emulated ever */ + } }/* Byteswap little endian loads and stores */
PATCH 68/95 l2tp: take reference on sessions being dumped
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Guillaume Nault <[email protected]>
commit e08293a4ccbcc993ded0fdc46f1e57926b833d63 upstream.
Take a reference on the sessions returned by l2tp_session_find_nth() (and rename it l2tp_session_get_nth() to reflect this change), so that caller is assured that the session isn't going to disappear while processing it.
For procfs and debugfs handlers, the session is held in the .start() callback and dropped in .show(). Given that pppol2tp_seq_session_show() dereferences the associated PPPoL2TP socket and that l2tp_dfs_seq_session_show() might call pppol2tp_show(), we also need to call the session's .ref() callback to prevent the socket from going away from under us.
--- net/l2tp/l2tp_core.c | 8 ++++++-- net/l2tp/l2tp_core.h | 3 ++- net/l2tp/l2tp_debugfs.c | 10 +++++++--- net/l2tp/l2tp_netlink.c | 7 +++++-- net/l2tp/l2tp_ppp.c | 10 +++++++--- 5 files changed, 27 insertions(+), 11 deletions(-)
net/l2tp/l2tp_core.c +6 -2
@@ -275,7 +275,8 @@ struct l2tp_session *l2tp_session_get(st }EXPORT_SYMBOL_GPL (l2tp_session_get); -struct l2tp_session *l2tp_session_find_nth (struct l2tp_tunnel *tunnel,int nth) +struct l2tp_session *l2tp_session_get_nth (struct l2tp_tunnel *tunnel,int nth, +bool do_ref) {int hash;struct hlist_node *walk;
@@ -286,6 +287,9 @@ struct l2tp_session *l2tp_session_find_nfor (hash =0 ; hash <L2TP_HASH_SIZE ; hash++) {hlist_for_each_entry (session, walk, &tunnel->session_hlist[hash], hlist) {if (++count > nth) { +l2tp_session_inc_refcount (session); +if (do_ref && session->ref) + session->ref (session);read_unlock_bh (&tunnel->hlist_lock);return session; }
@@ -296,7 +300,7 @@ struct l2tp_session *l2tp_session_find_nreturn NULL ; } -EXPORT_SYMBOL_GPL (l2tp_session_find_nth); +EXPORT_SYMBOL_GPL (l2tp_session_get_nth);/* Lookup a session by interface name. * This is very inefficient but is only used by management interfaces.
net/l2tp/l2tp_core.h +2 -1
@@ -226,7 +226,8 @@ struct l2tp_session *l2tp_session_get(ststruct l2tp_tunnel *tunnel, u32 session_id, bool do_ref);extern struct l2tp_session *l2tp_session_find (struct net *net,struct l2tp_tunnel *tunnel,u32 session_id); -extern struct l2tp_session *l2tp_session_find_nth (struct l2tp_tunnel *tunnel,int nth); +struct l2tp_session *l2tp_session_get_nth (struct l2tp_tunnel *tunnel,int nth, +bool do_ref);struct l2tp_session *l2tp_session_get_by_ifname (struct net *net,char *ifname,bool do_ref);extern struct l2tp_tunnel *l2tp_tunnel_find (struct net *net,u32 tunnel_id);
net/l2tp/l2tp_debugfs.c +7 -3
@@ -51,7 +51,7 @@ static void l2tp_dfs_next_tunnel(structstatic void l2tp_dfs_next_session (struct l2tp_dfs_seq_data *pd) { - pd->session =l2tp_session_find_nth (pd->tunnel, pd->session_idx); + pd->session =l2tp_session_get_nth (pd->tunnel, pd->session_idx, true); pd->session_idx++;if (pd->session ==NULL ) {
@@ -227,10 +227,14 @@ static int l2tp_dfs_seq_show(struct seq_ }/* Show the tunnel or session context */ -if (pd->session ==NULL ) +if (!pd->session) {l2tp_dfs_seq_tunnel_show (m, pd->tunnel); -else + }else {l2tp_dfs_seq_session_show (m, pd->session); +if (pd->session->deref) + pd->session->deref (pd->session); +l2tp_session_dec_refcount (pd->session); + } out:return 0 ;
net/l2tp/l2tp_netlink.c +5 -2
@@ -669,7 +669,7 @@ static int l2tp_nl_cmd_session_dump(stru goto out; } - session =l2tp_session_find_nth (tunnel, si); + session =l2tp_session_get_nth (tunnel, si, false);if (session ==NULL ) { ti++; tunnel =NULL ;
@@ -679,8 +679,11 @@ static int l2tp_nl_cmd_session_dump(struif (l2tp_nl_session_send (skb,NETLINK_CB (cb->skb).pid, cb->nlh->nlmsg_seq,NLM_F_MULTI , - session) <=0 ) + session) <=0 ) { +l2tp_session_dec_refcount (session);break ; + } +l2tp_session_dec_refcount (session); si++; }
net/l2tp/l2tp_ppp.c +7 -3
@@ -1564,7 +1564,7 @@ static void pppol2tp_next_tunnel(structstatic void pppol2tp_next_session (struct net *net,struct pppol2tp_seq_data *pd) { - pd->session =l2tp_session_find_nth (pd->tunnel, pd->session_idx); + pd->session =l2tp_session_get_nth (pd->tunnel, pd->session_idx, true); pd->session_idx++;if (pd->session ==NULL ) {
@@ -1691,10 +1691,14 @@ static int pppol2tp_seq_show(struct seq_/* Show the tunnel or session context. */ -if (pd->session ==NULL ) +if (!pd->session) {pppol2tp_seq_tunnel_show (m, pd->tunnel); -else + }else {pppol2tp_seq_session_show (m, pd->session); +if (pd->session->deref) + pd->session->deref (pd->session); +l2tp_session_dec_refcount (pd->session); + } out:return 0 ;
PATCH 69/95 xen, fbfront: fix connecting to backend
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Juergen Gross <[email protected]>
commit 9121b15b5628b38b4695282dc18c553440e0f79b upstream.
Connecting to the backend isn't working reliably in xen-fbfront: in case XenbusStateInitWait of the backend has been missed the backend transition to XenbusStateConnected will trigger the connected state only without doing the actions required when the backend has connected.
--- drivers/video/xen-fbfront.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/video/xen-fbfront.c +2 -2
@@ -640,7 +640,6 @@ static void xenfb_backend_changed(structbreak ;case XenbusStateInitWait: -InitWait:xenbus_switch_state (dev, XenbusStateConnected);break ;
@@ -651,7 +650,8 @@ InitWait:* get Connected twice here. */ if (dev->state != XenbusStateConnected) - goto InitWait;/* no InitWait seen yet, fudge it */ +/* no InitWait seen yet, fudge it */ +xenbus_switch_state (dev, XenbusStateConnected);if (xenbus_scanf (XBT_NIL , info->xbdev->otherend,"request-update" ,"%d" , &val) <0 )
PATCH 70/95 scsi: sr: Sanity check returned mode data
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Martin K. Petersen" <[email protected]>
commit a00a7862513089f17209b732f230922f1942e0b9 upstream.
Kefeng Wang discovered that old versions of the QEMU CD driver would return mangled mode data causing us to walk off the end of the buffer in an attempt to parse it. Sanity check the returned mode sense data.
--- drivers/scsi/sr.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/scsi/sr.c +4 -2
@@ -815,6 +815,7 @@ static void get_capabilities(struct scsiunsigned char *buffer;struct scsi_mode_data data;struct scsi_sense_hdr sshdr; +unsigned int ms_len =128 ;int rc, n; static const char *loadmech[] =
@@ -841,10 +842,11 @@ static void get_capabilities(struct scsiscsi_test_unit_ready (cd->device,SR_TIMEOUT ,MAX_RETRIES , &sshdr);/* ask for mode page 0x2a */ - rc =scsi_mode_sense (cd->device,0 ,0x2a , buffer,128 , + rc =scsi_mode_sense (cd->device,0 ,0x2a , buffer, ms_len,SR_TIMEOUT ,3 , &data,NULL ); -if (!scsi_status_is_good (rc)) { +if (!scsi_status_is_good (rc) || data.length > ms_len || + data.header_length + data.block_descriptor_length > data.length) {/* failed, drive doesn't have capabilities mode page */ cd->cdi.speed =1 ; cd->cdi.mask |= (CDC_CD_R | CDC_CD_RW | CDC_DVD_R |
PATCH 71/95 scsi: sd: Fix capacity calculation with 32-bit sector_t
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Martin K. Petersen" <[email protected]>
commit 7c856152cb92f8eee2df29ef325a1b1f43161aff upstream.
We previously made sure that the reported disk capacity was less than 0xffffffff blocks when the kernel was not compiled with large sector_t support (CONFIG_LBDAF). However, this check assumed that the capacity was reported in units of 512 bytes.
Add a sanity check function to ensure that we only enable disks if the entire reported capacity can be expressed in terms of sector_t.
--- drivers/scsi/sd.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
drivers/scsi/sd.c +18 -2
@@ -1648,6 +1648,22 @@ static void read_capacity_error(struct s#define READ_CAPACITY_RETRIES_ON_RESET 10 +/* +* Ensure that we don't overflow sector_t when CONFIG_LBDAF is not set +* and the reported logical block size is bigger than 512 bytes. Note +* that last_sector is a u64 and therefore logical_to_sectors() is not +* applicable. +*/ +static bool sd_addressable_capacity (u64 lba,unsigned int sector_size) +{ +u64 last_sector = (lba +1ULL ) << (ilog2 (sector_size) -9 ); + +if (sizeof (sector_t) ==4 && last_sector >0xffffffffULL ) +return false; + +return true; +} +static int read_capacity_16 (struct scsi_disk *sdkp,struct scsi_device *sdp,unsigned char *buffer) {
@@ -1710,7 +1726,7 @@ static int read_capacity_16(struct scsi_sd_read_protection_type (sdkp, buffer); -if ((sizeof (sdkp->capacity) ==4 ) && (lba >=0xffffffffULL )) { +if (!sd_addressable_capacity (lba, sector_size)) {sd_printk (KERN_ERR , sdkp,"Too big for this kernel. Use a " "kernel compiled with support for large block " "devices.\n" );
@@ -1796,7 +1812,7 @@ static int read_capacity_10(struct scsi_return sector_size; } -if ((sizeof (sdkp->capacity) ==4 ) && (lba ==0xffffffff )) { +if (!sd_addressable_capacity (lba, sector_size)) {sd_printk (KERN_ERR , sdkp,"Too big for this kernel. Use a " "kernel compiled with support for large block " "devices.\n" );
PATCH 72/95 ptrace: fix PTRACE_LISTEN race corrupting task->state
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "[email protected]" <[email protected]>
commit 5402e97af667e35e54177af8f6575518bf251d51 upstream.
In PT_SEIZED + LISTEN mode STOP/CONT signals cause a wakeup against __TASK_TRACED. If this races with the ptrace_unfreeze_traced at the end of a PTRACE_LISTEN, this can wake the task /after/ the check against __TASK_TRACED, but before the reset of state to TASK_TRACED. This causes it to instead clobber TASK_WAKING, allowing a subsequent wakeup against TRACED while the task is still on the rq wake_list, corrupting it.
Oleg said:
"The kernel can crash or this can lead to other hard-to-debug problems.
In short, "task->state = TASK_TRACED" in ptrace_unfreeze_traced() assumes that nobody else can wake it up, but PTRACE_LISTEN breaks the contract. Obviusly it is very wrong to manipulate task->state if this task is already running, or WAKING, or it sleeps again"
--- kernel/ptrace.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
kernel/ptrace.c +10 -4
@@ -148,11 +148,17 @@ static void ptrace_unfreeze_traced(strucWARN_ON (!task->ptrace || task->parent != current); +/* +* PTRACE_LISTEN can allow ptrace_trap_notify to wake us up remotely. +* Recheck state under the lock to close this race. +*/ spin_lock_irq (&task->sighand->siglock); -if (__fatal_signal_pending (task)) -wake_up_state (task, __TASK_TRACED); -else - task->state =TASK_TRACED ; +if (task->state == __TASK_TRACED) { +if (__fatal_signal_pending (task)) +wake_up_state (task, __TASK_TRACED); +else + task->state =TASK_TRACED ; + }spin_unlock_irq (&task->sighand->siglock); }
PATCH 73/95 l2tp: don't mask errors in pppol2tp_setsockopt()
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Guillaume Nault <[email protected]>
commit 364700cf8fd54f54ad08313464105a414e3bccb7 upstream.
pppol2tp_setsockopt() unconditionally overwrites the error value returned by pppol2tp_tunnel_setsockopt() or pppol2tp_session_setsockopt(), thus hiding errors from userspace.
--- net/l2tp/l2tp_ppp.c | 2 -- 1 file changed, 2 deletions(-)
net/l2tp/l2tp_ppp.c +0 -2
@@ -1387,8 +1387,6 @@ static int pppol2tp_setsockopt(struct so }else err =pppol2tp_session_setsockopt (sk, session, optname, val); - err =0 ; - end_put_sess:sock_put (sk); end:
PATCH 74/95 l2tp: don't mask errors in pppol2tp_getsockopt()
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Guillaume Nault <[email protected]>
commit 321a52a39189d5e4af542f7dcdc07bba4545cf5d upstream.
pppol2tp_getsockopt() doesn't take into account the error code returned by pppol2tp_tunnel_getsockopt() or pppol2tp_session_getsockopt(). If error occurs there, pppol2tp_getsockopt() continues unconditionally and reports erroneous values.
--- net/l2tp/l2tp_ppp.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
net/l2tp/l2tp_ppp.c +6 -1
@@ -1509,8 +1509,13 @@ static int pppol2tp_getsockopt(struct so err =pppol2tp_tunnel_getsockopt (sk, tunnel, optname, &val);sock_put (ps->tunnel_sock); - }else +if (err) + goto end_put_sess; + }else { err =pppol2tp_session_getsockopt (sk, session, optname, &val); +if (err) + goto end_put_sess; + } err = -EFAULT ;if (put_user (len, (int __user *) optlen))
PATCH 75/95 x86/vdso: Plug race between mapping and ELF header setup
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
commit 6fdc6dd90272ce7e75d744f71535cfbd8d77da81 upstream.
The vsyscall32 sysctl can racy against a concurrent fork when it switches from disabled to enabled:
arch_setup_additional_pages()
if (vdso32_enabled)
--> No mapping
sysctl.vsysscall32()
--> vdso32_enabled = true
create_elf_tables()
ARCH_DLINFO_IA32
if (vdso32_enabled) {
--> Add VDSO entry with NULL pointerMake ARCH_DLINFO_IA32 check whether the VDSO mapping has been set up for the newly forked process or not.
--- arch/x86/include/asm/elf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/elf.h +1 -1
@@ -298,7 +298,7 @@ do { \#define AT_SYSINFO 32 -#define COMPAT_ARCH_DLINFO ARCH_DLINFO_IA32(sysctl_vsyscall32) +#define COMPAT_ARCH_DLINFO ARCH_DLINFO_IA32(VDSO_CURRENT_BASE)#define COMPAT_ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x1000000)
PATCH 76/95 MIPS: KGDB: Use kernel context for sleeping threads
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: James Hogan <[email protected]>
commit 162b270c664dca2e0944308e92f9fcc887151a72 upstream.
KGDB is a kernel debug stub and it can't be used to debug userland as it can only safely access kernel memory.
On MIPS however KGDB has always got the register state of sleeping processes from the userland register context at the beginning of the kernel stack. This is meaningless for kernel threads (which never enter userland), and for user threads it prevents the user seeing what it is doing while in the kernel:
(gdb) info threads
Id Target Id Frame
...
3 Thread 2 (kthreadd) 0x0000000000000000 in ?? () 2 Thread 1 (init) 0x000000007705c4b4 in ?? () 1 Thread -2 (shadowCPU0) 0xffffffff8012524c in arch_kgdb_breakpoint () at arch/mips/kernel/kgdb.c:201
Get the register state instead from the (partial) kernel register context stored in the task's thread_struct for resume() to restore. All threads now correctly appear to be in context_switch():
(gdb) info threads
Id Target Id Frame
...
3 Thread 2 (kthreadd) context_switch (rq=<optimized out>, cookie=..., next=<optimized out>, prev=0x0) at kernel/sched/core.c:2903 2 Thread 1 (init) context_switch (rq=<optimized out>, cookie=..., next=<optimized out>, prev=0x0) at kernel/sched/core.c:2903 1 Thread -2 (shadowCPU0) 0xffffffff8012524c in arch_kgdb_breakpoint () at arch/mips/kernel/kgdb.c:201
Call clobbered registers which aren't saved and exception registers (BadVAddr & Cause) which can't be easily determined without stack unwinding are reported as 0. The PC is taken from the return address, such that the state presented matches that found immediately after returning from resume().
Patchwork: https://patchwork.linux-mips.org/patch/15829/
--- arch/mips/kernel/kgdb.c | 48 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 15 deletions(-)
arch/mips/kernel/kgdb.c +33 -15
@@ -236,9 +236,6 @@ static int compute_signal(int tt)void sleeping_thread_to_gdb_regs (unsigned long *gdb_regs,struct task_struct *p) {int reg; -struct thread_info *ti =task_thread_info (p); -unsigned long ksp = (unsigned long )ti +THREAD_SIZE -32 ; -struct pt_regs *regs = (struct pt_regs *)ksp -1 ;#if (KGDB_GDB_REG_SIZE ==32 )u32 *ptr = (u32 *)gdb_regs;#else
@@ -246,25 +243,46 @@ void sleeping_thread_to_gdb_regs(unsigne#endif for (reg =0 ; reg <16 ; reg++) - *(ptr++) = regs->regs[reg]; + *(ptr++) =0 ;/* S0 - S7 */ -for (reg =16 ; reg <24 ; reg++) - *(ptr++) = regs->regs[reg]; + *(ptr++) = p->thread.reg16; + *(ptr++) = p->thread.reg17; + *(ptr++) = p->thread.reg18; + *(ptr++) = p->thread.reg19; + *(ptr++) = p->thread.reg20; + *(ptr++) = p->thread.reg21; + *(ptr++) = p->thread.reg22; + *(ptr++) = p->thread.reg23;for (reg =24 ; reg <28 ; reg++) *(ptr++) =0 ;/* GP, SP, FP, RA */ -for (reg =28 ; reg <32 ; reg++) - *(ptr++) = regs->regs[reg]; - - *(ptr++) = regs->cp0_status; - *(ptr++) = regs->lo; - *(ptr++) = regs->hi; - *(ptr++) = regs->cp0_badvaddr; - *(ptr++) = regs->cp0_cause; - *(ptr++) = regs->cp0_epc; + *(ptr++) = (long )p; + *(ptr++) = p->thread.reg29; + *(ptr++) = p->thread.reg30; + *(ptr++) = p->thread.reg31; + + *(ptr++) = p->thread.cp0_status; + +/* lo, hi */ + *(ptr++) =0 ; + *(ptr++) =0 ; + +/* +* BadVAddr, Cause +* Ideally these would come from the last exception frame up the stack +* but that requires unwinding, otherwise we can't know much for sure. +*/ + *(ptr++) =0 ; + *(ptr++) =0 ; + +/* +* PC +* use return address (RA), i.e. the moment after return from resume() +*/ + *(ptr++) = p->thread.reg31; }void kgdb_arch_set_pc (struct pt_regs *regs,unsigned long pc)
PATCH 77/95 ALSA: seq: Don't break snd_use_lock_sync() loop by timeout
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 4e7655fd4f47c23e5249ea260dc802f909a64611 upstream.
The snd_use_lock_sync() (thus its implementation snd_use_lock_sync_helper()) has the 5 seconds timeout to break out of the sync loop. It was introduced from the beginning, just to be "safer", in terms of avoiding the stupid bugs.
However, as Ben Hutchings suggested, this timeout rather introduces a potential leak or use-after-free that was apparently fixed by the commit 2d7d54002e39 ("ALSA: seq: Fix race during FIFO resize"):
for example, snd_seq_fifo_event_in() -> snd_seq_event_dup() -> copy_from_user() could block for a long time, and snd_use_lock_sync() goes timeout and still leaves the cell at releasing the pool.
For fixing such a problem, we remove the break by the timeout while still keeping the warning.
--- sound/core/seq/seq_lock.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
sound/core/seq/seq_lock.c +3 -6
@@ -28,19 +28,16 @@/* wait until all locks are released */ void snd_use_lock_sync_helper (snd_use_lock_t *lockp,const char *file,int line) { -int max_count =5 *HZ ; +int warn_count =5 *HZ ;if (atomic_read (lockp) <0 ) {printk (KERN_WARNING "seq_lock: lock trouble [counter = %d] in %s:%d\n" ,atomic_read (lockp), file, line);return ; }while (atomic_read (lockp) >0 ) { -if (max_count ==0 ) { -snd_printk (KERN_WARNING "seq_lock: timeout [%d left] in %s:%d\n" ,atomic_read (lockp), file, line); -break ; - } +if (warn_count-- ==0 ) +pr_warn ("ALSA: seq_lock: waiting [%d left] in %s:%d\n" ,atomic_read (lockp), file, line);schedule_timeout_uninterruptible (1 ); - max_count--; } }
PATCH 78/95 cpupower: Fix turbo frequency reporting for pre-Sandy Bridge cores
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ben Hutchings <[email protected]>
commit 4cca0457686e4ee1677d69469e4ddfd94d389a80 upstream.
The switch that conditionally sets CPUPOWER_CAP_HAS_TURBO_RATIO and CPUPOWER_CAP_IS_SNB flags is missing a break, so all cores get both flags set and an assumed base clock of 100 MHz for turbo values.
References: https://bugs.debian.org/859978
--- tools/power/cpupower/utils/helpers/cpuid.c | 1 + 1 file changed, 1 insertion(+)
tools/power/cpupower/utils/helpers/cpuid.c +1 -0
@@ -156,6 +156,7 @@ out:*/ case 0x2C :/* Westmere EP - Gulftown */ cpu_info->caps |=CPUPOWER_CAP_HAS_TURBO_RATIO ; +break ;case 0x2A :/* SNB */ case 0x2D :/* SNB Xeon */ cpu_info->caps |=CPUPOWER_CAP_HAS_TURBO_RATIO ;
PATCH 79/95 ftrace/x86: Fix triple fault with graph tracing and suspend-to-ram
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Josh Poimboeuf <[email protected]>
commit 34a477e5297cbaa6ecc6e17c042a866e1cbe80d6 upstream.
On x86-32, with CONFIG_FIRMWARE and multiple CPUs, if you enable function graph tracing and then suspend to RAM, it will triple fault and reboot when it resumes.
The first fault happens when booting a secondary CPU:
startup_32_smp()
load_ucode_ap()
prepare_ftrace_return()
ftrace_graph_is_dead()
(accesses 'kill_ftrace_graph')
The early head_32.S code calls into load_ucode_ap(), which has an an ftrace hook, so it calls prepare_ftrace_return(), which calls ftrace_graph_is_dead(), which tries to access the global 'kill_ftrace_graph' variable with a virtual address, causing a fault because the CPU is still in real mode.
The fix is to add a check in prepare_ftrace_return() to make sure it's running in protected mode before continuing. The check makes sure the stack pointer is a virtual kernel address. It's a bit of a hack, but it's not very intrusive and it works well enough.
For reference, here are a few other (more difficult) ways this could have potentially been fixed:
- Move startup_32_smp()'s call to load_ucode_ap() down to *after* paging is enabled. (No idea what that would break.)
- Track down load_ucode_ap()'s entire callee tree and mark all the functions 'notrace'. (Probably not realistic.)
- Pause graph tracing in ftrace_suspend_notifier_call() or bringup_cpu() or __cpu_up(), and ensure that the pause facility can be queried from real mode.
--- arch/x86/kernel/ftrace.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
arch/x86/kernel/ftrace.c +12 -0
@@ -404,6 +404,18 @@ void prepare_ftrace_return(unsigned longunsigned long return_hooker = (unsigned long ) &return_to_handler; +/* +* When resuming from suspend-to-ram, this function can be indirectly +* called from early CPU startup code while the CPU is in real mode, +* which would fail miserably. Make sure the stack pointer is a +* virtual address. +* +* This check isn't as accurate as virt_addr_valid(), but it should be +* good enough for this purpose, and it's fast. +*/ +if (unlikely ((long )__builtin_frame_address (0 ) >=0 )) +return ; +if (unlikely (atomic_read (¤t->tracing_graph_pause)))return ;
PATCH 80/95 p9_client_readdir() fix
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit 71d6ad08379304128e4bdfaf0b4185d54375423e upstream.
Don't assume that server is sane and won't return more data than asked for.
--- net/9p/client.c | 4 ++++ 1 file changed, 4 insertions(+)
net/9p/client.c +4 -0
@@ -2056,6 +2056,10 @@ int p9_client_readdir(struct p9_fid *fidtrace_9p_protocol_dump (clnt, req->rc); goto free_and_error; } +if (rsize < count) { +pr_err ("bogus RREADDIR count (%d > %d)\n" , count, rsize); + count = rsize; + }P9_DPRINTK (P9_DEBUG_9P ,"<<< RREADDIR count %d\n" , count);
PATCH 81/95 KEYS: Change the name of the dead type to ".dead" to prevent user access
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
commit c1644fe041ebaf6519f6809146a77c3ead9193af upstream.
This fixes CVE-2017-6951.
Userspace should not be able to do things with the "dead" key type as it doesn't have some of the helper functions set upon it that the kernel needs. Attempting to use it may cause the kernel to crash.
Fix this by changing the name of the type to ".dead" so that it's rejected up front on userspace syscalls by key_get_type_from_user().
Though this doesn't seem to affect recent kernels, it does affect older ones, certainly those prior to:
commit c06cfb08b88dfbe13be44a69ae2fdc3a7c902d81 Author: David Howells <[email protected]> Date: Tue Sep 16 17:36:06 2014 +0100 KEYS: Remove key_type::match in favour of overriding default by match_preparse
which went in before 3.18-rc1.
--- security/keys/gc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
security/keys/gc.c +1 -1
@@ -46,7 +46,7 @@ static unsigned long key_gc_flags;* immediately unlinked. */ struct key_type key_type_dead = { - .name ="dead" , + .name =".dead" , };/*
PATCH 82/95 ACPI / power: Avoid maybe-uninitialized warning
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
commit fe8c470ab87d90e4b5115902dd94eced7e3305c3 upstream.
gcc -O2 cannot always prove that the loop in acpi_power_get_inferred_state() is enterered at least once, so it assumes that cur_state might not get initialized:
drivers/acpi/power.c: In function 'acpi_power_get_inferred_state':drivers/acpi/power.c:222:9: error: 'cur_state' may be used uninitialized in this function [-Werror=maybe-uninitialized]
This sets the variable to zero at the start of the loop, to ensure that there is well-defined behavior even for an empty list. This gets rid of the warning.
The warning first showed up when the -Os flag got removed in a bug fix patch in linux-4.11-rc5.
I would suggest merging this addon patch on top of that bug fix to avoid introducing a new warning in the stable kernels.
---
drivers/acpi/power.c +1 -1
@@ -152,7 +152,7 @@ static int acpi_power_get_list_state(strreturn -EINVAL ;/* The state of the list is 'on' IFF all resources are 'on'. */ - + cur_state =0 ;for (i =0 ; i < list->count; i++) {struct acpi_power_resource *resource;acpi_handle handle = list->handles[i];
PATCH 83/95 ring-buffer: Have ring_buffer_iter_empty() return true when empty
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Steven Rostedt (VMware)" <[email protected]>
commit 78f7a45dac2a2d2002f98a3a95f7979867868d73 upstream.
I noticed that reading the snapshot file when it is empty no longer gives a status. It suppose to show the status of the snapshot buffer as well as how to allocate and use it. For example:
Quoted 1 line
# cat snapshot
# tracer: nop
#
#
# * Snapshot is allocated *
#
# Snapshot commands:
# echo 0 > snapshot : Clears and frees snapshot buffer # echo 1 > snapshot : Allocates snapshot buffer, if not already allocated. # Takes a snapshot of the main buffer. # echo 2 > snapshot : Clears snapshot buffer (but does not allocate or free) # (Doesn't have to be '2' works with any number that # is not a '0' or '1')
But instead it just showed an empty buffer:
Quoted 1 line
# cat snapshot
# tracer: nop
#
# entries-in-buffer/entries-written: 0/0 #P:4
#
# _-----=> irqs-off
# / _----=> need-resched
# | / _---=> hardirq/softirq # || / _--=> preempt-depth # ||| / delay # TASK-PID CPU# |||| TIMESTAMP FUNCTION # | | | |||| | |
What happened was that it was using the ring_buffer_iter_empty() function to see if it was empty, and if it was, it showed the status. But that function was returning false when it was empty. The reason was that the iter header page was on the reader page, and the reader page was empty, but so was the buffer itself. The check only tested to see if the iter was on the commit page, but the commit page was no longer pointing to the reader page, but as all pages were empty, the buffer is also.
--- kernel/trace/ring_buffer.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
kernel/trace/ring_buffer.c +14 -2
@@ -2879,11 +2879,23 @@ EXPORT_SYMBOL_GPL(ring_buffer_iter_resetint ring_buffer_iter_empty (struct ring_buffer_iter *iter) {struct ring_buffer_per_cpu *cpu_buffer; +struct buffer_page *reader; +struct buffer_page *head_page; +struct buffer_page *commit_page; +unsigned commit; cpu_buffer = iter->cpu_buffer; -return iter->head_page == cpu_buffer->commit_page && - iter->head ==rb_commit_index (cpu_buffer); +/* Remember, trace recording is off when iterator is in use */ + reader = cpu_buffer->reader_page; + head_page = cpu_buffer->head_page; + commit_page = cpu_buffer->commit_page; + commit =rb_page_commit (commit_page); + +return ((iter->head_page == commit_page && iter->head == commit) || + (iter->head_page == reader && commit_page == head_page && + head_page->read == commit && + iter->head ==rb_page_commit (cpu_buffer->reader_page))); }EXPORT_SYMBOL_GPL (ring_buffer_iter_empty);
PATCH 84/95 mac80211: reject ToDS broadcast data frames
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
commit 3018e947d7fd536d57e2b550c33e456d921fff8c upstream.
AP/AP_VLAN modes don't accept any real 802.11 multicast data frames, but since they do need to accept broadcast management frames the same is currently permitted for data frames. This opens a security problem because such frames would be decrypted with the GTK, and could even contain unicast L3 frames.
Since the spec says that ToDS frames must always have the BSSID as the RA (addr1), reject any other data frames.
The problem was originally reported in "Predicting, Decrypting, and Abusing WPA2/802.11 Group Keys" at usenix
https://www.usenix.org/conference/usenixsecurity16/technical-sessions/presentation/vanhoef
and brought to my attention by Jouni.
--
Dave, I didn't want to send you a new pull request for a single commit yet again - can you apply this one patch as is?
[bwh: Backported to 3.2: Put the new code in an else-block since the
previous if-blocks may or may not return]
--- net/mac80211/rx.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
net/mac80211/rx.c +24 -0
@@ -2842,6 +2842,30 @@ static int prepare_for_handlers(struct i sdata->vif.p2p))return 0 ; status->rx_flags &= ~IEEE80211_RX_RA_MATCH ; + }else { +/* +* 802.11-2016 Table 9-26 says that for data frames, +* A1 must be the BSSID - we've checked that already +* but may have accepted the wildcard +* (ff:ff:ff:ff:ff:ff). +* +* It also says: +* The BSSID of the Data frame is determined as +* follows: +* a) If the STA is contained within an AP or is +* associated with an AP, the BSSID is the +* address currently in use by the STA +* contained in the AP. +* +* So we should not accept data frames with an address +* that's multicast. +* +* Accepting it also opens a security problem because +* stations could encrypt it with the GTK and inject +* traffic that way. +*/ +if (ieee80211_is_data (hdr->frame_control) && multicast) +return 0 ; }break ;case NL80211_IFTYPE_WDS :
PATCH 85/95 smsc75xx: use skb_cow_head() to deal with cloned skbs
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
commit b7c6d2675899cfff0180412c63fc9cbd5bacdb4d upstream.
We need to ensure there is enough headroom to push extra header, but we also need to check if we are allowed to change headers.
skb_cow_head() is the proper helper to deal with this.
--- drivers/net/usb/smsc75xx.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/net/usb/smsc75xx.c +2 -6
@@ -1170,13 +1170,9 @@ static struct sk_buff *smsc75xx_tx_fixup {u32 tx_cmd_a, tx_cmd_b; -if (skb_headroom (skb) <SMSC75XX_TX_OVERHEAD ) { -struct sk_buff *skb2 = -skb_copy_expand (skb,SMSC75XX_TX_OVERHEAD ,0 , flags); +if (skb_cow_head (skb,SMSC75XX_TX_OVERHEAD )) {dev_kfree_skb_any (skb); - skb = skb2; -if (!skb) -return NULL ; +return NULL ; } tx_cmd_a = (u32)(skb->len &TX_CMD_A_LEN ) |TX_CMD_A_FCS ;
PATCH 86/95 cx82310_eth: use skb_cow_head() to deal with cloned skbs
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
commit a9e840a2081ed28c2b7caa6a9a0041c950b3c37d upstream.
We need to ensure there is enough headroom to push extra header, but we also need to check if we are allowed to change headers.
skb_cow_head() is the proper helper to deal with this.
--- drivers/net/usb/cx82310_eth.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/net/usb/cx82310_eth.c +2 -5
@@ -277,12 +277,9 @@ static struct sk_buff *cx82310_tx_fixup( {int len = skb->len; -if (skb_headroom (skb) <2 ) { -struct sk_buff *skb2 =skb_copy_expand (skb,2 ,0 , flags); +if (skb_cow_head (skb,2 )) {dev_kfree_skb_any (skb); - skb = skb2; -if (!skb) -return NULL ; +return NULL ; }skb_push (skb,2 );
PATCH 87/95 net: tc35815: move free after the dereference
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit 11faa7b0359aaf7efd406b7a6a077fda2b037d8e upstream.
We dereference "skb" to get "skb->len" so we should probably do that step before freeing the skb.
--- drivers/net/ethernet/toshiba/tc35815.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/toshiba/tc35815.c +1 -1
@@ -1053,8 +1053,8 @@ tc35815_free_queues(struct net_device *dBUG_ON (lp->tx_skbs[i].skb != skb);#endif if (skb) { -dev_kfree_skb (skb);pci_unmap_single (lp->pci_dev, lp->tx_skbs[i].skb_dma, skb->len,PCI_DMA_TODEVICE ); +dev_kfree_skb (skb); lp->tx_skbs[i].skb =NULL ; lp->tx_skbs[i].skb_dma =0 ; }
PATCH 88/95 Input: i8042 - add Clevo P650RS to the i8042 reset list
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Torokhov <[email protected]>
commit 7c5bb4ac2b76d2a09256aec8a7d584bf3e2b0466 upstream.
Clevo P650RS and other similar devices require i8042 to be reset in order to detect Synaptics touchpad.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=190301
--- drivers/input/serio/i8042-x86ia64io.h | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/input/serio/i8042-x86ia64io.h +7 -0
@@ -580,6 +580,13 @@ static const struct dmi_system_id __init DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 1720"), }, }, + { + /* Clevo P650RS, 650RP6, Sager NP8152-S, and others */ + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Notebook"), + DMI_MATCH(DMI_PRODUCT_NAME, "P65xRP"), + }, + }, { } };
PATCH 89/95 x86/mm/init.c: Fix devmem_is_allowed() off by one
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: T Makphaibulchoke <[email protected]>
commit 73e8f3d7e2cb23614d5115703d76d8e54764b641 upstream.
Fixing an off-by-one error in devmem_is_allowed(), which allows accesses to physical addresses 0x100000-0x100fff, an extra page past 1MB.
--- arch/x86/mm/init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/mm/init.c +1 -1
@@ -326,7 +326,7 @@ unsigned long __init_refok init_memory_m*/ int devmem_is_allowed (unsigned long pagenr) { -if (pagenr <=256 ) +if (pagenr <256 )return 1 ;if (iomem_is_exclusive (pagenr <<PAGE_SHIFT ))return 0 ;
PATCH 90/95 mm: Tighten x86 /dev/mem with zeroing reads
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
commit a4866aa812518ed1a37d8ea0c881dc946409de94 upstream.
Under CONFIG_STRICT_DEVMEM, reading System RAM through /dev/mem is disallowed. However, on x86, the first 1MB was always allowed for BIOS and similar things, regardless of it actually being System RAM. It was possible for heap to end up getting allocated in low 1MB RAM, and then read by things like x86info or dd, which would trip hardened usercopy:
usercopy: kernel memory exposure attempt detected from ffff880000090000 (dma-kmalloc-256) (4096 bytes)
This changes the x86 exception for the low 1MB by reading back zeros for System RAM areas instead of blindly allowing them. More work is needed to extend this to mmap, but currently mmap doesn't go through usercopy, so hardened usercopy won't Oops the kernel.
--- arch/x86/mm/init.c | 41 +++++++++++++++++++-------- drivers/char/mem.c | 82 ++++++++++++++++++++++++++++++++++-------------------- 2 files changed, 82 insertions(+), 41 deletions(-)
arch/x86/mm/init.c +30 -11
@@ -318,21 +318,40 @@ unsigned long __init_refok init_memory_m* devmem_is_allowed() checks to see if /dev/mem access to a certain address * is valid. The argument is a physical page number. * -* -* On x86, access has to be given to the first megabyte of ram because that area -* contains bios code and data regions used by X and dosemu and similar apps. -* Access has to be given to non-kernel-ram areas as well, these contain the PCI -* mmio resources as well as potential bios/acpi data regions. +* On x86, access has to be given to the first megabyte of RAM because that +* area traditionally contains BIOS code and data regions used by X, dosemu, +* and similar apps. Since they map the entire memory range, the whole range +* must be allowed (for mapping), but any areas that would otherwise be +* disallowed are flagged as being "zero filled" instead of rejected. +* Access has to be given to non-kernel-ram areas as well, these contain the +* PCI mmio resources as well as potential bios/acpi data regions. */ int devmem_is_allowed (unsigned long pagenr) { -if (pagenr <256 ) -return 1 ; -if (iomem_is_exclusive (pagenr <<PAGE_SHIFT )) +if (page_is_ram (pagenr)) { +/* +* For disallowed memory regions in the low 1MB range, +* request that the page be shown as all zeros. +*/ +if (pagenr <256 ) +return 2 ; + +return 0 ; + } + +/* +* This must follow RAM test, since System RAM is considered a +* restricted resource under CONFIG_STRICT_IOMEM. +*/ +if (iomem_is_exclusive (pagenr <<PAGE_SHIFT )) { +/* Low 1MB bypasses iomem restrictions. */ +if (pagenr <256 ) +return 1 ; +return 0 ; -if (!page_is_ram (pagenr)) -return 1 ; -return 0 ; + } + +return 1 ; }void free_init_pages (char *what,unsigned long begin,unsigned long end)
drivers/char/mem.c +52 -30
117 lines not on this page · raw message
PATCH 91/95 xen-blkback: don't leak stack data via response ring
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jan Beulich <[email protected]>
commit 089bc0143f489bd3a4578bdff5f4ca68fb26f341 upstream.
Rather than constructing a local structure instance on the stack, fill the fields directly on the shared ring, just like other backends do. Build on the fact that all response structure flavors are actually identical (the old code did make this assumption too).
This is XSA-216.
---
drivers/block/xen-blkback/blkback.c +12 -11
@@ -811,33 +811,34 @@ static int dispatch_rw_block_io(struct xstatic void make_response (struct xen_blkif *blkif,u64 id,unsigned short op,int st) { -struct blkif_response resp; +struct blkif_response *resp;unsigned long flags;union blkif_back_rings *blk_rings = &blkif->blk_rings;int notify; - resp.id = id; - resp.operation = op; - resp.status = st; -spin_lock_irqsave (&blkif->blk_ring_lock, flags);/* Place on the response ring for the relevant domain. */ switch (blkif->blk_protocol) {case BLKIF_PROTOCOL_NATIVE : -memcpy (RING_GET_RESPONSE (&blk_rings->native, blk_rings->native.rsp_prod_pvt), - &resp,sizeof (resp)); + resp =RING_GET_RESPONSE (&blk_rings->native, + blk_rings->native.rsp_prod_pvt);break ;case BLKIF_PROTOCOL_X86_32 : -memcpy (RING_GET_RESPONSE (&blk_rings->x86_32, blk_rings->x86_32.rsp_prod_pvt), - &resp,sizeof (resp)); + resp =RING_GET_RESPONSE (&blk_rings->x86_32, + blk_rings->x86_32.rsp_prod_pvt);break ;case BLKIF_PROTOCOL_X86_64 : -memcpy (RING_GET_RESPONSE (&blk_rings->x86_64, blk_rings->x86_64.rsp_prod_pvt), - &resp,sizeof (resp)); + resp =RING_GET_RESPONSE (&blk_rings->x86_64, + blk_rings->x86_64.rsp_prod_pvt);break ;default :BUG (); } + + resp->id = id; + resp->operation = op; + resp->status = st; + blk_rings->common.rsp_prod_pvt++;RING_PUSH_RESPONSES_AND_CHECK_NOTIFY (&blk_rings->common, notify);spin_unlock_irqrestore (&blkif->blk_ring_lock, flags);
drivers/block/xen-blkback/common.h +3 -16
@@ -56,9 +56,6 @@struct blkif_common_request {char dummy; }; -struct blkif_common_response { -char dummy; -};/* i386 protocol version */ #pragma pack(push, 4)
@@ -83,11 +80,6 @@ struct blkif_x86_32_request {struct blkif_x86_32_request_discard discard; } u; }; -struct blkif_x86_32_response { -uint64_t id;/* copied from request */ -uint8_t operation;/* copied from request */ -int16_t status;/* BLKIF_RSP_??? */ -};#pragma pack(pop)/* x86_64 protocol version */
@@ -112,18 +104,13 @@ struct blkif_x86_64_request {struct blkif_x86_64_request_discard discard; } u; }; -struct blkif_x86_64_response { -uint64_t __attribute__((__aligned__ (8 ))) id; -uint8_t operation;/* copied from request */ -int16_t status;/* BLKIF_RSP_??? */ -}; DEFINE_RING_TYPES(blkif_common, struct blkif_common_request, - struct blkif_common_response); + struct blkif_response); DEFINE_RING_TYPES(blkif_x86_32, struct blkif_x86_32_request, - struct blkif_x86_32_response); + struct blkif_response __packed); DEFINE_RING_TYPES(blkif_x86_64, struct blkif_x86_64_request, - struct blkif_x86_64_response); + struct blkif_response);union blkif_back_rings {struct blkif_back_ring native;
PATCH 92/95 char: lp: fix possible integer overflow in lp_setup()
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Willy Tarreau <[email protected]>
commit 3e21f4af170bebf47c187c1ff8bf155583c9f3b1 upstream.
The lp_setup() code doesn't apply any bounds checking when passing "lp=none", and only in this case, resulting in an overflow of the parport_nr[] array. All versions in Git history are affected.
--- drivers/char/lp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/char/lp.c +5 -1
@@ -858,7 +858,11 @@ static int __init lp_setup (char *str) }else if (!strcmp (str,"auto" )) { parport_nr[0 ] =LP_PARPORT_AUTO ; }else if (!strcmp (str,"none" )) { - parport_nr[parport_ptr++] =LP_PARPORT_NONE ; +if (parport_ptr <LP_NO ) + parport_nr[parport_ptr++] =LP_PARPORT_NONE ; +else +printk (KERN_INFO "lp: too many ports, %s ignored.\n" , + str); }else if (!strcmp (str,"reset" )) { reset =1 ; }
PATCH 93/95 fs/exec.c: account for argv/envp pointers
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
commit 98da7d08850fb8bdeb395d6368ed15753304aa0c upstream.
When limiting the argv/envp strings during exec to 1/4 of the stack limit, the storage of the pointers to the strings was not included. This means that an exec with huge numbers of tiny strings could eat 1/4 of the stack limit in strings and then additional space would be later used by the pointers to the strings.
For example, on 32-bit with a 8MB stack rlimit, an exec with 1677721 single-byte strings would consume less than 2MB of stack, the max (8MB /
4) amount allowed, but the pointers to the strings would consume the remaining additional stack space (1677721 * 4 == 6710884).
The result (1677721 + 6710884 == 8388605) would exhaust stack space entirely. Controlling this stack exhaustion could result in pathological behavior in setuid binaries (CVE-2017-1000365).
--- fs/exec.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-)
fs/exec.c +24 -4
@@ -208,8 +208,26 @@ static struct page *get_arg_page(structif (write) {unsigned long size = bprm->vma->vm_end - bprm->vma->vm_start; +unsigned long ptr_size;struct rlimit *rlim; +/* +* Since the stack will hold pointers to the strings, we +* must account for them as well. +* +* The size calculation is the entire vma while each arg page is +* built, so each time we get here it's calculating how far it +* is currently (rather than each call being just the newly +* added size from the arg page). As a result, we need to +* always add the entire size of the pointers, so that on the +* last call to get_arg_page() we'll actually have the entire +* correct size. +*/ + ptr_size = (bprm->argc + bprm->envc) *sizeof (void *); +if (ptr_size >ULONG_MAX - size) + goto fail; + size += ptr_size; +acct_arg_size (bprm, size /PAGE_SIZE );/*
@@ -227,13 +245,15 @@ static struct page *get_arg_page(struct* to work from. */ rlim = current->signal->rlim; -if (size >ACCESS_ONCE (rlim[RLIMIT_STACK ].rlim_cur) /4 ) { -put_page (page); -return NULL ; - } +if (size >ACCESS_ONCE (rlim[RLIMIT_STACK ].rlim_cur) /4 ) + goto fail; }return page; + +fail: +put_page (page); +return NULL ; }static void put_arg_page (struct page *page)
PATCH 94/95 ALSA: timer: Fix race between read and ioctl
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit d11662f4f798b50d8c8743f433842c3e40fe3378 upstream.
The read from ALSA timer device, the function snd_timer_user_tread(), may access to an uninitialized struct snd_timer_user fields when the read is concurrently performed while the ioctl like snd_timer_user_tselect() is invoked. We have already fixed the races among ioctls via a mutex, but we seem to have forgotten the race between read vs ioctl.
This patch simply applies (more exactly extends the already applied range of) tu->ioctl_lock in snd_timer_user_tread() for closing the race window.
--- sound/core/timer.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
sound/core/timer.c +4 -2
@@ -1930,6 +1930,7 @@ static ssize_t snd_timer_user_read(struc tu = file->private_data; unit = tu->tread ?sizeof (struct snd_timer_tread ) :sizeof (struct snd_timer_read ); +mutex_lock (&tu->ioctl_lock);spin_lock_irq (&tu->qlock);while ((long )count - result >= unit) {while (!tu->qused) {
@@ -1945,7 +1946,9 @@ static ssize_t snd_timer_user_read(strucadd_wait_queue (&tu->qchange_sleep, &wait);spin_unlock_irq (&tu->qlock); +mutex_unlock (&tu->ioctl_lock);schedule (); +mutex_lock (&tu->ioctl_lock);spin_lock_irq (&tu->qlock);remove_wait_queue (&tu->qchange_sleep, &wait);
@@ -1961,7 +1964,6 @@ static ssize_t snd_timer_user_read(struc tu->qused--;spin_unlock_irq (&tu->qlock); -mutex_lock (&tu->ioctl_lock);if (tu->tread) {if (copy_to_user (buffer, &tu->tqueue[qhead],sizeof (struct snd_timer_tread )))
@@ -1971,7 +1973,6 @@ static ssize_t snd_timer_user_read(struc sizeof(struct snd_timer_read))) err = -EFAULT ; } -mutex_unlock (&tu->ioctl_lock);spin_lock_irq (&tu->qlock);if (err <0 )
@@ -1981,6 +1982,7 @@ static ssize_t snd_timer_user_read(struc } _error:spin_unlock_irq (&tu->qlock); +mutex_unlock (&tu->ioctl_lock);return result >0 ? result : err; }
PATCH 95/95 ALSA: timer: Fix missing queue indices reset at SNDRV_TIMER_IOCTL_SELECT
In reply to Ben Hutchings3.2.91-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit ba3021b2c79b2fa9114f92790a99deb27a65b728 upstream.
snd_timer_user_tselect() reallocates the queue buffer dynamically, but it forgot to reset its indices. Since the read may happen concurrently with ioctl and snd_timer_user_tselect() allocates the buffer via kmalloc(), this may lead to the leak of uninitialized kernel-space data, as spotted via KMSAN:
BUG: KMSAN: use of unitialized memory in snd_timer_user_read+0x6c4/0xa10 CPU: 0 PID: 1037 Comm: probe Not tainted 4.11.0-rc5+ #2739 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:16 dump_stack+0x143/0x1b0 lib/dump_stack.c:52 kmsan_report+0x12a/0x180 mm/kmsan/kmsan.c:1007 kmsan_check_memory+0xc2/0x140 mm/kmsan/kmsan.c:1086 copy_to_user ./arch/x86/include/asm/uaccess.h:725 snd_timer_user_read+0x6c4/0xa10 sound/core/timer.c:2004 do_loop_readv_writev fs/read_write.c:716 __do_readv_writev+0x94c/0x1380 fs/read_write.c:864 do_readv_writev fs/read_write.c:894 vfs_readv fs/read_write.c:908 do_readv+0x52a/0x5d0 fs/read_write.c:934 SYSC_readv+0xb6/0xd0 fs/read_write.c:1021 SyS_readv+0x87/0xb0 fs/read_write.c:1018
This patch adds the missing reset of queue indices. Together with the previous fix for the ioctl/read race, we cover the whole problem.
--- sound/core/timer.c | 1 + 1 file changed, 1 insertion(+)
sound/core/timer.c +1 -0
@@ -1590,6 +1590,7 @@ static int snd_timer_user_tselect(structif (err <0 ) goto __err; + tu->qhead = tu->qtail = tu->qused =0 ;kfree (tu->queue); tu->queue =NULL ;kfree (tu->tqueue);
Quoted 8 lines · Ben Hutchings
This is the start of the stable review cycle for the 3.2.91 release. There are 95 patches in this series, which will be posted as responses to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Tue Jul 18 13:56:34 UTC 2017. Anything received after that time might be too late.
Build results:
total: 86 pass: 86 fail: 0 Qemu test results: total: 69 pass: 69 fail: 0
Details are available at http://kerneltests.org/builders.
Guenter
This is the combined diff for 3.2.91-rc1 relative to 3.2.90.
Ben.
Signature · 2 lines
Ben Hutchings If the facts do not conform to your theory, they must be disposed of.
Makefile +2 -2
@@ -1,7 +1,7 @@ VERSION = 3 PATCHLEVEL = 2 -SUBLEVEL = 90 -EXTRAVERSION = +SUBLEVEL = 91 +EXTRAVERSION = -rc1 NAME = Saber-toothed Squirrel # *DOCUMENTATION*
arch/mips/kernel/kgdb.c +33 -15
67 lines not on this page · raw message
arch/powerpc/kernel/align.c +19 -8
@@ -764,14 +764,25 @@ int fix_alignment(struct pt_regs *regs) nb = aligninfo[instr].len; flags = aligninfo[instr].flags; -/* ldbrx/stdbrx overlap lfs/stfs in the DSISR unfortunately */ -if (IS_XFORM (instruction) && ((instruction >>1 ) &0x3ff ) ==532 ) { - nb =8 ; - flags =LD +SW ; - }else if (IS_XFORM (instruction) && - ((instruction >>1 ) &0x3ff ) ==660 ) { - nb =8 ; - flags =ST +SW ; +/* +* Handle some cases which give overlaps in the DSISR values. +*/ +if (IS_XFORM (instruction)) { +switch ((instruction >>1 ) &0x3ff ) { +case 532 :/* ldbrx */ + nb =8 ; + flags =LD +SW ; +break ; +case 660 :/* stdbrx */ + nb =8 ; + flags =ST +SW ; +break ; +case 20 :/* lwarx */ +case 84 :/* ldarx */ +case 116 :/* lharx */ +case 276 :/* lqarx */ +return 0 ;/* not emulated ever */ + } }/* Byteswap little endian loads and stores */
arch/s390/boot/compressed/misc.c +19 -16
@@ -135,31 +135,34 @@ static void check_ipl_parmblock(void *start, unsigned long size)unsigned long decompress_kernel (void ) { -unsigned long output_addr; -unsigned char *output; +void *output, *kernel_end; - output_addr = ((unsigned long ) &_end +HEAP_SIZE +4095UL ) &-4096UL ; -check_ipl_parmblock ((void *)0 , output_addr + SZ__bss_start); -memset (&_bss,0 , &_ebss - &_bss); - free_mem_ptr = (unsigned long )&_end; - free_mem_end_ptr = free_mem_ptr +HEAP_SIZE ; - output = (unsigned char *) output_addr; + output = (void *)ALIGN ((unsigned long ) &_end +HEAP_SIZE ,PAGE_SIZE ); + kernel_end = output + SZ__bss_start; +check_ipl_parmblock ((void *)0 , (unsigned long ) kernel_end);#ifdef CONFIG_BLK_DEV_INITRD /* * Move the initrd right behind the end of the decompressed -* kernel image. +* kernel image. This also prevents initrd corruption caused by +* bss clearing since kernel_end will always be located behind the +* current bss section.. */ -if (INITRD_START &&INITRD_SIZE && -INITRD_START < (unsigned long ) output + SZ__bss_start) { -check_ipl_parmblock (output + SZ__bss_start, -INITRD_START +INITRD_SIZE ); -memmove (output + SZ__bss_start, - (void *)INITRD_START ,INITRD_SIZE ); -INITRD_START = (unsigned long ) output + SZ__bss_start; +if (INITRD_START &&INITRD_SIZE && kernel_end > (void *)INITRD_START ) { +check_ipl_parmblock (kernel_end,INITRD_SIZE ); +memmove (kernel_end, (void *)INITRD_START ,INITRD_SIZE ); +INITRD_START = (unsigned long ) kernel_end; }#endif +/* +* Clear bss section. free_mem_ptr and free_mem_end_ptr need to be +* initialized afterwards since they reside in bss. +*/ +memset (&_bss,0 , &_ebss - &_bss); + free_mem_ptr = (unsigned long ) &_end; + free_mem_end_ptr = free_mem_ptr +HEAP_SIZE ; +puts ("Uncompressing Linux... " );decompress (input_data, input_len,NULL ,NULL , output,NULL , error);puts ("Ok, booting the kernel.\n" );
arch/x86/include/asm/elf.h +1 -1
@@ -298,7 +298,7 @@ do { \#define AT_SYSINFO 32 -#define COMPAT_ARCH_DLINFO ARCH_DLINFO_IA32(sysctl_vsyscall32) +#define COMPAT_ARCH_DLINFO ARCH_DLINFO_IA32(VDSO_CURRENT_BASE)#define COMPAT_ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x1000000)
arch/x86/kernel/ftrace.c +12 -0
@@ -404,6 +404,18 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr,unsigned long return_hooker = (unsigned long ) &return_to_handler; +/* +* When resuming from suspend-to-ram, this function can be indirectly +* called from early CPU startup code while the CPU is in real mode, +* which would fail miserably. Make sure the stack pointer is a +* virtual address. +* +* This check isn't as accurate as virt_addr_valid(), but it should be +* good enough for this purpose, and it's fast. +*/ +if (unlikely ((long )__builtin_frame_address (0 ) >=0 )) +return ; +if (unlikely (atomic_read (¤t->tracing_graph_pause)))return ;
arch/x86/mm/init.c +30 -11
51 lines not on this page · raw message
arch/x86/pci/xen.c +7 -16
@@ -227,23 +227,14 @@ static int xen_hvm_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)return 1 ;list_for_each_entry (msidesc, &dev->msi_list, list) { -__read_msi_msg (msidesc, &msg); - pirq =MSI_ADDR_EXT_DEST_ID (msg.address_hi) | - ((msg.address_lo >>MSI_ADDR_DEST_ID_SHIFT ) &0xff ); -if (msg.data !=XEN_PIRQ_MSI_DATA || -xen_irq_from_pirq (pirq) <0 ) { - pirq =xen_allocate_pirq_msi (dev, msidesc); -if (pirq <0 ) { - irq = -ENODEV ; - goto error; - } -xen_msi_compose_msg (dev, pirq, &msg); -__write_msi_msg (msidesc, &msg); -dev_dbg (&dev->dev,"xen: msi bound to pirq=%d\n" , pirq); - }else { -dev_dbg (&dev->dev, -"xen: msi already bound to pirq=%d\n" , pirq); + pirq =xen_allocate_pirq_msi (dev, msidesc); +if (pirq <0 ) { + irq = -ENODEV ; + goto error; } +xen_msi_compose_msg (dev, pirq, &msg); +__write_msi_msg (msidesc, &msg); +dev_dbg (&dev->dev,"xen: msi bound to pirq=%d\n" , pirq); irq = xen_bind_pirq_msi_to_irq(dev, msidesc, pirq, 0, (type == PCI_CAP_ID_MSIX) ? "msi-x" : "msi",
drivers/acpi/Makefile +0 -1
@@ -2,7 +2,6 @@ # Makefile for the Linux ACPI interpreter # -ccflags-y := -Os ccflags-$(CONFIG_ACPI_DEBUG) += -DACPI_DEBUG_OUTPUT #
drivers/acpi/apei/ghes.c +1 -0
@@ -953,6 +953,7 @@ static int __devexit ghes_remove(struct platform_device *ghes_dev)if (list_empty (&ghes_sci))unregister_acpi_hed_notifier (&ghes_notifier_sci);mutex_unlock (&ghes_list_mutex); +synchronize_rcu ();break ;case ACPI_HEST_NOTIFY_NMI :mutex_lock (&ghes_list_mutex);
drivers/acpi/power.c +1 -1
@@ -152,7 +152,7 @@ static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state)return -EINVAL ;/* The state of the list is 'on' IFF all resources are 'on'. */ - + cur_state =0 ;for (i =0 ; i < list->count; i++) {struct acpi_power_resource *resource;acpi_handle handle = list->handles[i];
drivers/block/xen-blkback/blkback.c +12 -11
@@ -811,33 +811,34 @@ static int dispatch_rw_block_io(struct xen_blkif *blkif,static void make_response (struct xen_blkif *blkif,u64 id,unsigned short op,int st) { -struct blkif_response resp; +struct blkif_response *resp;unsigned long flags;union blkif_back_rings *blk_rings = &blkif->blk_rings;int notify; - resp.id = id; - resp.operation = op; - resp.status = st; -spin_lock_irqsave (&blkif->blk_ring_lock, flags);/* Place on the response ring for the relevant domain. */ switch (blkif->blk_protocol) {case BLKIF_PROTOCOL_NATIVE : -memcpy (RING_GET_RESPONSE (&blk_rings->native, blk_rings->native.rsp_prod_pvt), - &resp,sizeof (resp)); + resp =RING_GET_RESPONSE (&blk_rings->native, + blk_rings->native.rsp_prod_pvt);break ;case BLKIF_PROTOCOL_X86_32 : -memcpy (RING_GET_RESPONSE (&blk_rings->x86_32, blk_rings->x86_32.rsp_prod_pvt), - &resp,sizeof (resp)); + resp =RING_GET_RESPONSE (&blk_rings->x86_32, + blk_rings->x86_32.rsp_prod_pvt);break ;case BLKIF_PROTOCOL_X86_64 : -memcpy (RING_GET_RESPONSE (&blk_rings->x86_64, blk_rings->x86_64.rsp_prod_pvt), - &resp,sizeof (resp)); + resp =RING_GET_RESPONSE (&blk_rings->x86_64, + blk_rings->x86_64.rsp_prod_pvt);break ;default :BUG (); } + + resp->id = id; + resp->operation = op; + resp->status = st; + blk_rings->common.rsp_prod_pvt++;RING_PUSH_RESPONSES_AND_CHECK_NOTIFY (&blk_rings->common, notify);spin_unlock_irqrestore (&blkif->blk_ring_lock, flags);
drivers/block/xen-blkback/common.h +3 -16
@@ -56,9 +56,6 @@struct blkif_common_request {char dummy; }; -struct blkif_common_response { -char dummy; -};/* i386 protocol version */ #pragma pack(push, 4)
@@ -83,11 +80,6 @@ struct blkif_x86_32_request {struct blkif_x86_32_request_discard discard; } u; }; -struct blkif_x86_32_response { -uint64_t id;/* copied from request */ -uint8_t operation;/* copied from request */ -int16_t status;/* BLKIF_RSP_??? */ -};#pragma pack(pop)/* x86_64 protocol version */
@@ -112,18 +104,13 @@ struct blkif_x86_64_request {struct blkif_x86_64_request_discard discard; } u; }; -struct blkif_x86_64_response { -uint64_t __attribute__((__aligned__ (8 ))) id; -uint8_t operation;/* copied from request */ -int16_t status;/* BLKIF_RSP_??? */ -}; DEFINE_RING_TYPES(blkif_common, struct blkif_common_request, - struct blkif_common_response); + struct blkif_response); DEFINE_RING_TYPES(blkif_x86_32, struct blkif_x86_32_request, - struct blkif_x86_32_response); + struct blkif_response __packed); DEFINE_RING_TYPES(blkif_x86_64, struct blkif_x86_64_request, - struct blkif_x86_64_response); + struct blkif_response);union blkif_back_rings {struct blkif_back_ring native;
drivers/char/lp.c +5 -1
@@ -858,7 +858,11 @@ static int __init lp_setup (char *str) }else if (!strcmp (str,"auto" )) { parport_nr[0 ] =LP_PARPORT_AUTO ; }else if (!strcmp (str,"none" )) { - parport_nr[parport_ptr++] =LP_PARPORT_NONE ; +if (parport_ptr <LP_NO ) + parport_nr[parport_ptr++] =LP_PARPORT_NONE ; +else +printk (KERN_INFO "lp: too many ports, %s ignored.\n" , + str); }else if (!strcmp (str,"reset" )) { reset =1 ; }
drivers/char/mem.c +52 -30
117 lines not on this page · raw message
drivers/gpu/drm/vmwgfx/vmwgfx_fence.c +49 -25
123 lines not on this page · raw message
drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c +1 -3
@@ -69,8 +69,6 @@ int vmw_getparam_ioctl(struct drm_device *dev, void *data,break ; }default : -DRM_ERROR ("Illegal vmwgfx get param request: %d\n" , - param->param);return -EINVAL ; }
@@ -90,7 +88,7 @@ int vmw_get_cap_3d_ioctl(struct drm_device *dev, void *data,void *bounce;int ret; -if (unlikely (arg->pad64 !=0 )) { +if (unlikely (arg->pad64 !=0 || arg->max_size ==0 )) {DRM_ERROR ("Illegal GET_3D_CAP argument.\n" );return -EINVAL ; }
drivers/hwmon/asus_atk0110.c +3 -0
@@ -645,6 +645,9 @@ static int atk_read_value(struct atk_sensor_data *sensor, u64 *value)else err =atk_read_value_new (sensor, value); +if (err) +return err; + sensor->is_valid = true; sensor->last_updated = jiffies; sensor->cached_value = *value;
drivers/infiniband/hw/qib/qib_iba7322.c +1 -1
@@ -6614,7 +6614,7 @@ static void qib_7322_txchk_change(struct qib_devdata *dd, u32 start,unsigned long flags;while (wait) { -unsigned long shadow; +unsigned long shadow =0 ;int cstart, previ =-1 ;/*
drivers/input/joystick/iforce/iforce-usb.c +3 -0
@@ -138,6 +138,9 @@ static int iforce_usb_probe(struct usb_interface *intf, interface = intf->cur_altsetting; +if (interface->desc.bNumEndpoints <2 ) +return -ENODEV ; + epirq = &interface->endpoint[0 ].desc; epout = &interface->endpoint[1 ].desc;
drivers/input/misc/cm109.c +4 -0
@@ -663,6 +663,10 @@ static int cm109_usb_probe(struct usb_interface *intf,int error = -ENOMEM ; interface = intf->cur_altsetting; + +if (interface->desc.bNumEndpoints <1 ) +return -ENODEV ; + endpoint = &interface->endpoint[0 ].desc;if (!usb_endpoint_is_int_in (endpoint))
drivers/input/misc/yealink.c +4 -0
@@ -867,6 +867,10 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id)int ret, pipe, i; interface = intf->cur_altsetting; + +if (interface->desc.bNumEndpoints <1 ) +return -ENODEV ; + endpoint = &interface->endpoint[0 ].desc;if (!usb_endpoint_is_int_in (endpoint))return -ENODEV ;
drivers/input/serio/i8042-x86ia64io.h +14 -0
@@ -120,6 +120,13 @@ static const struct dmi_system_id __initconst i8042_dmi_noloop_table[] = { }, }, { +/* Dell Embedded Box PC 3000 */ + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Dell Inc." ), + DMI_MATCH(DMI_PRODUCT_NAME, "Embedded Box PC 3000"), + }, + }, + {/* OQO Model 01 */ .matches = { DMI_MATCH(DMI_SYS_VENDOR, "OQO"),
@@ -573,6 +580,13 @@ static const struct dmi_system_id __initconst i8042_dmi_reset_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 1720"), }, }, + { + /* Clevo P650RS, 650RP6, Sager NP8152-S, and others */ + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Notebook"), + DMI_MATCH(DMI_PRODUCT_NAME, "P65xRP"), + }, + }, { } };
drivers/input/tablet/hanwang.c +3 -0
@@ -314,6 +314,9 @@ static int hanwang_probe(struct usb_interface *intf, const struct usb_device_idint error;int i; +if (intf->cur_altsetting->desc.bNumEndpoints <1 ) +return -ENODEV ; + hanwang =kzalloc (sizeof (struct hanwang ),GFP_KERNEL ); input_dev =input_allocate_device ();if (!hanwang || !input_dev) {
drivers/input/tablet/kbtab.c +3 -0
@@ -117,6 +117,9 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *istruct input_dev *input_dev;int error = -ENOMEM ; +if (intf->cur_altsetting->desc.bNumEndpoints <1 ) +return -ENODEV ; + kbtab =kzalloc (sizeof (struct kbtab ),GFP_KERNEL ); input_dev =input_allocate_device ();if (!kbtab || !input_dev)
drivers/isdn/gigaset/bas-gigaset.c +3 -0
@@ -2314,6 +2314,9 @@ static int gigaset_probe(struct usb_interface *interface,return -ENODEV ; } +if (hostif->desc.bNumEndpoints <1 ) +return -ENODEV ; + dev_info(&udev->dev, "%s: Device matched (Vendor: 0x%x, Product: 0x%x)\n", __func__, le16_to_cpu(udev->descriptor.idVendor),
drivers/media/dvb/dvb-usb/dvb-usb-firmware.c +21 -12
@@ -35,42 +35,51 @@ static int usb_cypress_writemem(struct usb_device *udev,u16 addr,u8 *data, u8 leint usb_cypress_load_firmware (struct usb_device *udev,const struct firmware *fw,int type) { -struct hexline hx; -u8 reset; -int ret,pos=0 ; +struct hexline *hx; +u8 *buf; +int ret, pos =0 ; +u16 cpu_cs_register = cypress[type].cpu_cs_register; + + buf =kmalloc (sizeof (*hx),GFP_KERNEL ); +if (!buf) +return -ENOMEM ; + hx = (struct hexline *)buf;/* stop the CPU */ - reset =1 ; -if ((ret =usb_cypress_writemem (udev,cypress[type].cpu_cs_register,&reset,1 )) !=1 ) + buf[0 ] =1 ; +if (usb_cypress_writemem (udev, cpu_cs_register, buf,1 ) !=1 )err ("could not stop the USB controller CPU." ); -while ((ret =dvb_usb_get_hexline (fw,&hx,&pos)) >0 ) { -deb_fw ("writing to address 0x%04x (buffer: 0x%02x %02x)\n" ,hx.addr,hx.len,hx.chk); - ret =usb_cypress_writemem (udev,hx.addr,hx.data,hx.len); +while ((ret =dvb_usb_get_hexline (fw, hx, &pos)) >0 ) { +deb_fw ("writing to address 0x%04x (buffer: 0x%02x %02x)\n" , hx->addr, hx->len, hx->chk); + ret =usb_cypress_writemem (udev, hx->addr, hx->data, hx->len); -if (ret != hx.len) { +if (ret != hx->len) {err ("error while transferring firmware " "(transferred size: %d, block size: %d)" , - ret,hx.len); + ret, hx->len); ret = -EINVAL ;break ; } }if (ret <0 ) {err ("firmware download failed at %d with %d" ,pos,ret); +kfree (buf);return ret; }if (ret ==0 ) {/* restart the CPU */ - reset =0 ; -if (ret ||usb_cypress_writemem (udev,cypress[type].cpu_cs_register,&reset,1 ) !=1 ) { + buf[0 ] =0 ; +if (usb_cypress_writemem (udev, cpu_cs_register, buf,1 ) !=1 ) {err ("could not restart the USB controller CPU." ); ret = -EINVAL ; } }else ret = -EIO ; +kfree (buf); +return ret; }EXPORT_SYMBOL (usb_cypress_load_firmware);
drivers/mmc/host/sdhci.c +9 -1
@@ -1150,7 +1150,9 @@ static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)return ; } timeout--; -mdelay (1 ); +spin_unlock_irq (&host->lock); +usleep_range (900 ,1100 ); +spin_lock_irq (&host->lock); } clk |=SDHCI_CLOCK_CARD_EN ;
@@ -1544,9 +1546,15 @@ static void sdhci_enable_sdio_irq(struct mmc_host *mmc, int enable)struct sdhci_host *host =mmc_priv (mmc);unsigned long flags; +if (enable) +pm_runtime_get_noresume (host->mmc->parent); +spin_lock_irqsave (&host->lock, flags);sdhci_enable_sdio_irq_nolock (host, enable);spin_unlock_irqrestore (&host->lock, flags); + +if (!enable) +pm_runtime_put_noidle (host->mmc->parent); } static int sdhci_do_start_signal_voltage_switch(struct sdhci_host *host,
drivers/mmc/host/ushc.c +3 -0
@@ -426,6 +426,9 @@ static int ushc_probe(struct usb_interface *intf, const struct usb_device_id *idstruct ushc_data *ushc;int ret; +if (intf->cur_altsetting->desc.bNumEndpoints <1 ) +return -ENODEV ; + mmc =mmc_alloc_host (sizeof (struct ushc_data ), &intf->dev);if (mmc ==NULL )return -ENOMEM ;
drivers/mtd/ubi/upd.c +4 -4
@@ -150,11 +150,11 @@ int ubi_start_update(struct ubi_device *ubi, struct ubi_volume *vol,return err; } -if (bytes ==0 ) { - err =ubi_wl_flush (ubi); -if (err) -return err; + err =ubi_wl_flush (ubi); +if (err) +return err; +if (bytes ==0 ) { err =clear_update_marker (ubi, vol,0 );if (err)return err;
drivers/net/ethernet/toshiba/tc35815.c +1 -1
@@ -1053,8 +1053,8 @@ tc35815_free_queues(struct net_device *dev)BUG_ON (lp->tx_skbs[i].skb != skb);#endif if (skb) { -dev_kfree_skb (skb);pci_unmap_single (lp->pci_dev, lp->tx_skbs[i].skb_dma, skb->len,PCI_DMA_TODEVICE ); +dev_kfree_skb (skb); lp->tx_skbs[i].skb =NULL ; lp->tx_skbs[i].skb_dma =0 ; }
drivers/net/phy/phy.c +1 -1
@@ -453,7 +453,7 @@ void phy_stop_machine(struct phy_device *phydev)cancel_delayed_work_sync (&phydev->state_queue);mutex_lock (&phydev->lock); -if (phydev->state >PHY_UP ) +if (phydev->state >PHY_UP && phydev->state !=PHY_HALTED ) phydev->state =PHY_UP ;mutex_unlock (&phydev->lock);
drivers/net/usb/cx82310_eth.c +2 -5
@@ -277,12 +277,9 @@ static struct sk_buff *cx82310_tx_fixup(struct usbnet *dev, struct sk_buff *skb, {int len = skb->len; -if (skb_headroom (skb) <2 ) { -struct sk_buff *skb2 =skb_copy_expand (skb,2 ,0 , flags); +if (skb_cow_head (skb,2 )) {dev_kfree_skb_any (skb); - skb = skb2; -if (!skb) -return NULL ; +return NULL ; }skb_push (skb,2 );
drivers/net/usb/smsc75xx.c +2 -6
@@ -1170,13 +1170,9 @@ static struct sk_buff *smsc75xx_tx_fixup(struct usbnet *dev, {u32 tx_cmd_a, tx_cmd_b; -if (skb_headroom (skb) <SMSC75XX_TX_OVERHEAD ) { -struct sk_buff *skb2 = -skb_copy_expand (skb,SMSC75XX_TX_OVERHEAD ,0 , flags); +if (skb_cow_head (skb,SMSC75XX_TX_OVERHEAD )) {dev_kfree_skb_any (skb); - skb = skb2; -if (!skb) -return NULL ; +return NULL ; } tx_cmd_a = (u32)(skb->len &TX_CMD_A_LEN ) |TX_CMD_A_FCS ;
drivers/net/wimax/i2400m/usb.c +3 -0
@@ -449,6 +449,9 @@ int i2400mu_probe(struct usb_interface *iface,struct i2400mu *i2400mu;struct usb_device *usb_dev =interface_to_usbdev (iface); +if (iface->cur_altsetting->desc.bNumEndpoints <4 ) +return -ENODEV ; +if (usb_dev->speed !=USB_SPEED_HIGH )dev_err (dev,"device not connected as high speed\n" );
drivers/scsi/aacraid/src.c +1 -1
@@ -348,7 +348,7 @@ static int aac_src_check_health(struct aac_dev *dev)return -1 ; err_blink: -return (status >16 ) &0xFF ; +return (status >>16 ) &0xFF ; }/**
drivers/scsi/libsas/sas_ata.c +1 -1
@@ -205,7 +205,7 @@ static unsigned int sas_ata_qc_issue(struct ata_queued_cmd *qc) task->num_scatter = qc->n_elem; }else {for_each_sg (qc->sg, sg, qc->n_elem, si) - xfer += sg->length; + xfer +=sg_dma_len (sg); task->total_xfer_len = xfer; task->num_scatter = si;
drivers/scsi/lpfc/lpfc_init.c +1 -0
@@ -10002,6 +10002,7 @@ static struct pci_driver lpfc_driver = { .id_table = lpfc_id_table, .probe = lpfc_pci_probe_one, .remove = __devexit_p(lpfc_pci_remove_one), + .shutdown = lpfc_pci_remove_one, .suspend = lpfc_pci_suspend_one, .resume = lpfc_pci_resume_one, .err_handler = &lpfc_err_handler,
drivers/scsi/sd.c +18 -2
@@ -1648,6 +1648,22 @@ static void read_capacity_error(struct scsi_disk *sdkp, struct scsi_device *sdp,#define READ_CAPACITY_RETRIES_ON_RESET 10 +/* +* Ensure that we don't overflow sector_t when CONFIG_LBDAF is not set +* and the reported logical block size is bigger than 512 bytes. Note +* that last_sector is a u64 and therefore logical_to_sectors() is not +* applicable. +*/ +static bool sd_addressable_capacity (u64 lba,unsigned int sector_size) +{ +u64 last_sector = (lba +1ULL ) << (ilog2 (sector_size) -9 ); + +if (sizeof (sector_t) ==4 && last_sector >0xffffffffULL ) +return false; + +return true; +} +static int read_capacity_16 (struct scsi_disk *sdkp,struct scsi_device *sdp,unsigned char *buffer) {
@@ -1710,7 +1726,7 @@ static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp,sd_read_protection_type (sdkp, buffer); -if ((sizeof (sdkp->capacity) ==4 ) && (lba >=0xffffffffULL )) { +if (!sd_addressable_capacity (lba, sector_size)) {sd_printk (KERN_ERR , sdkp,"Too big for this kernel. Use a " "kernel compiled with support for large block " "devices.\n" );
@@ -1796,7 +1812,7 @@ static int read_capacity_10(struct scsi_disk *sdkp, struct scsi_device *sdp,return sector_size; } -if ((sizeof (sdkp->capacity) ==4 ) && (lba ==0xffffffff )) { +if (!sd_addressable_capacity (lba, sector_size)) {sd_printk (KERN_ERR , sdkp,"Too big for this kernel. Use a " "kernel compiled with support for large block " "devices.\n" );
drivers/scsi/sr.c +4 -2
@@ -815,6 +815,7 @@ static void get_capabilities(struct scsi_cd *cd)unsigned char *buffer;struct scsi_mode_data data;struct scsi_sense_hdr sshdr; +unsigned int ms_len =128 ;int rc, n; static const char *loadmech[] =
@@ -841,10 +842,11 @@ static void get_capabilities(struct scsi_cd *cd)scsi_test_unit_ready (cd->device,SR_TIMEOUT ,MAX_RETRIES , &sshdr);/* ask for mode page 0x2a */ - rc =scsi_mode_sense (cd->device,0 ,0x2a , buffer,128 , + rc =scsi_mode_sense (cd->device,0 ,0x2a , buffer, ms_len,SR_TIMEOUT ,3 , &data,NULL ); -if (!scsi_status_is_good (rc)) { +if (!scsi_status_is_good (rc) || data.length > ms_len || + data.header_length + data.block_descriptor_length > data.length) {/* failed, drive doesn't have capabilities mode page */ cd->cdi.speed =1 ; cd->cdi.mask |= (CDC_CD_R | CDC_CD_RW | CDC_DVD_R |
drivers/target/iscsi/iscsi_target_parameters.c +0 -16
@@ -761,22 +761,6 @@ static void iscsi_check_proposer_for_optional_reply(struct iscsi_param *param)if (!strcmp (param->name,MAXRECVDATASEGMENTLENGTH ))SET_PSTATE_REPLY_OPTIONAL (param);/* -* The GlobalSAN iSCSI Initiator for MacOSX does -* not respond to MaxBurstLength, FirstBurstLength, -* DefaultTime2Wait or DefaultTime2Retain parameter keys. -* So, we set them to 'reply optional' here, and assume the -* the defaults from iscsi_parameters.h if the initiator -* is not RFC compliant and the keys are not negotiated. -*/ -if (!strcmp (param->name,MAXBURSTLENGTH )) -SET_PSTATE_REPLY_OPTIONAL (param); -if (!strcmp (param->name,FIRSTBURSTLENGTH )) -SET_PSTATE_REPLY_OPTIONAL (param); -if (!strcmp (param->name,DEFAULTTIME2WAIT )) -SET_PSTATE_REPLY_OPTIONAL (param); -if (!strcmp (param->name,DEFAULTTIME2RETAIN )) -SET_PSTATE_REPLY_OPTIONAL (param); -/* * Required for gPXE iSCSI boot client */ if (!strcmp (param->name,MAXCONNECTIONS ))
drivers/tty/serial/mxs-auart.c +7 -3
@@ -76,6 +76,8 @@#define AUART_CTRL2_TXE (1 << 8)#define AUART_CTRL2_UARTEN (1 << 0) +#define AUART_LINECTRL_BAUD_DIV_MAX 0x003fffc0 +#define AUART_LINECTRL_BAUD_DIV_MIN 0x000000ec#define AUART_LINECTRL_BAUD_DIVINT_SHIFT 16#define AUART_LINECTRL_BAUD_DIVINT_MASK 0xffff0000#define AUART_LINECTRL_BAUD_DIVINT (v) (((v) & 0xffff) << 16)
@@ -285,7 +287,7 @@ static void mxs_auart_settermios(struct uart_port *u, struct ktermios *old) {u32 bm, ctrl, ctrl2, div; -unsigned int cflag, baud; +unsigned int cflag, baud, baud_min, baud_max; cflag = termios->c_cflag;
@@ -361,8 +363,10 @@ static void mxs_auart_settermios(struct uart_port *u, ctrl2 &= ~AUART_CTRL2_CTSEN ;/* set baud rate */ - baud =uart_get_baud_rate (u, termios, old,0 , u->uartclk); - div = u->uartclk *32 / baud; + baud_min =DIV_ROUND_UP (u->uartclk *32 ,AUART_LINECTRL_BAUD_DIV_MAX ); + baud_max = u->uartclk *32 /AUART_LINECTRL_BAUD_DIV_MIN ; + baud =uart_get_baud_rate (u, termios, old, baud_min, baud_max); + div =DIV_ROUND_CLOSEST (u->uartclk *32 , baud); ctrl |=AUART_LINECTRL_BAUD_DIVFRAC (div &0x3F ); ctrl |=AUART_LINECTRL_BAUD_DIVINT (div >>6 );
drivers/usb/class/usbtmc.c +8 -1
@@ -1007,7 +1007,7 @@ static int usbtmc_probe(struct usb_interface *intf,dev_dbg (&intf->dev,"%s called\n" , __func__); - data =kmalloc (sizeof (struct usbtmc_device_data ),GFP_KERNEL ); + data =kzalloc (sizeof (struct usbtmc_device_data ),GFP_KERNEL );if (!data) {dev_err (&intf->dev,"Unable to allocate kernel memory\n" );return -ENOMEM ;
@@ -1053,6 +1053,12 @@ static int usbtmc_probe(struct usb_interface *intf, } } +if (!data->bulk_out || !data->bulk_in) { +dev_err (&intf->dev,"bulk endpoints not found\n" ); + retcode = -ENODEV ; + goto err_put; + } + retcode =get_capabilities (data);if (retcode)dev_err (&intf->dev,"can't read capabilities\n" );
@@ -1076,6 +1082,7 @@ static int usbtmc_probe(struct usb_interface *intf, error_register:sysfs_remove_group (&intf->dev.kobj, &capability_attr_grp);sysfs_remove_group (&intf->dev.kobj, &data_attr_grp); +err_put:kref_put (&data->kref, usbtmc_delete);return retcode; }
drivers/usb/core/config.c +10 -0
@@ -247,6 +247,16 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum,/* * Adjust bInterval for quirked devices. +*/ +/* +* This quirk fixes bIntervals reported in ms. +*/ +if (to_usb_device (ddev)->quirks & +USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL ) { + n =clamp (fls (d->bInterval) +3 , i, j); + i = j = n; + } +/* * This quirk fixes bIntervals reported in * linear microframes. */
drivers/usb/core/quirks.c +8 -0
@@ -147,6 +147,14 @@ static const struct usb_device_id usb_quirk_list[] = {/* M-Systems Flash Disk Pioneers */ { USB_DEVICE(0x08ec, 0x1000), .driver_info = USB_QUIRK_RESET_RESUME }, + /* Baum Vario Ultra */ + { USB_DEVICE(0x0904, 0x6101), .driver_info = + USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL }, + { USB_DEVICE(0x0904, 0x6102), .driver_info = + USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL }, + { USB_DEVICE(0x0904, 0x6103), .driver_info = + USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL }, + /* Keytouch QWERTY Panel keyboard */ { USB_DEVICE(0x0926, 0x3333), .driver_info = USB_QUIRK_CONFIG_INTF_STRINGS },
drivers/usb/dwc3/gadget.h +7 -7
@@ -48,23 +48,23 @@ struct dwc3;#define gadget_to_dwc (g) (container_of(g, struct dwc3, gadget))/* DEPCFG parameter 1 */ -#define DWC3_DEPCFG_INT_NUM (n) ((n) << 0) +#define DWC3_DEPCFG_INT_NUM (n) (((n) & 0x1f) << 0)#define DWC3_DEPCFG_XFER_COMPLETE_EN (1 << 8)#define DWC3_DEPCFG_XFER_IN_PROGRESS_EN (1 << 9)#define DWC3_DEPCFG_XFER_NOT_READY_EN (1 << 10)#define DWC3_DEPCFG_FIFO_ERROR_EN (1 << 11)#define DWC3_DEPCFG_STREAM_EVENT_EN (1 << 13) -#define DWC3_DEPCFG_BINTERVAL_M1 (n) ((n) << 16) +#define DWC3_DEPCFG_BINTERVAL_M1 (n) (((n) & 0xff) << 16)#define DWC3_DEPCFG_STREAM_CAPABLE (1 << 24) -#define DWC3_DEPCFG_EP_NUMBER (n) ((n) << 25) +#define DWC3_DEPCFG_EP_NUMBER (n) (((n) & 0x1f) << 25)#define DWC3_DEPCFG_BULK_BASED (1 << 30)#define DWC3_DEPCFG_FIFO_BASED (1 << 31)/* DEPCFG parameter 0 */ -#define DWC3_DEPCFG_EP_TYPE (n) ((n) << 1) -#define DWC3_DEPCFG_MAX_PACKET_SIZE (n) ((n) << 3) -#define DWC3_DEPCFG_FIFO_NUMBER (n) ((n) << 17) -#define DWC3_DEPCFG_BURST_SIZE (n) ((n) << 22) +#define DWC3_DEPCFG_EP_TYPE (n) (((n) & 0x3) << 1) +#define DWC3_DEPCFG_MAX_PACKET_SIZE (n) (((n) & 0x7ff) << 3) +#define DWC3_DEPCFG_FIFO_NUMBER (n) (((n) & 0x1f) << 17) +#define DWC3_DEPCFG_BURST_SIZE (n) (((n) & 0xf) << 22)#define DWC3_DEPCFG_DATA_SEQ_NUM (n) ((n) << 26)#define DWC3_DEPCFG_IGN_SEQ_NUM (1 << 31)
drivers/usb/gadget/f_acm.c +3 -1
@@ -497,13 +497,15 @@ static int acm_notify_serial_state(struct f_acm *acm) {struct usb_composite_dev *cdev = acm->port.func.config->cdev;int status; +__le16 serial_state;spin_lock (&acm->lock);if (acm->notify_req) {DBG (cdev,"acm ttyGS%d serial state %04x\n" , acm->port_num, acm->serial_state); + serial_state =cpu_to_le16 (acm->serial_state); status =acm_cdc_notify (acm,USB_CDC_NOTIFY_SERIAL_STATE , -0 , &acm->serial_state,sizeof (acm->serial_state)); +0 , &serial_state,sizeof (acm->serial_state)); }else { acm->pending = true; status =0 ;
drivers/usb/host/xhci.c +31 -25
86 lines not on this page · raw message
drivers/usb/misc/idmouse.c +3 -0
@@ -346,6 +346,9 @@ static int idmouse_probe(struct usb_interface *interface,if (iface_desc->desc.bInterfaceClass !=0x0A )return -ENODEV ; +if (iface_desc->desc.bNumEndpoints <1 ) +return -ENODEV ; +/* allocate memory for our device state and initialize it */ dev =kzalloc (sizeof (*dev),GFP_KERNEL );if (dev ==NULL )
drivers/usb/misc/iowarrior.c +8 -0
@@ -809,6 +809,14 @@ static int iowarrior_probe(struct usb_interface *interface, goto error; } +if (dev->product_id ==USB_DEVICE_ID_CODEMERCS_IOW56 ) { +if (!dev->int_out_endpoint) { +dev_err (&interface->dev,"no interrupt-out endpoint found\n" ); + retval = -ENODEV ; + goto error; + } + } +/* we have to check the report_size often, so remember it in the endianess suitable for our machine */ dev->report_size =usb_endpoint_maxp (dev->int_in_endpoint); if ((dev->interface->cur_altsetting->desc.bInterfaceNumber == 0) &&
drivers/usb/misc/uss720.c +5 -0
@@ -704,6 +704,11 @@ static int uss720_probe(struct usb_interface *intf, interface = intf->cur_altsetting; +if (interface->desc.bNumEndpoints <3 ) { +usb_put_dev (usbdev); +return -ENODEV ; + } +/* * Allocate parport interface */
drivers/usb/serial/io_ti.c +6 -0
@@ -1681,6 +1681,12 @@ static void edge_interrupt_callback(struct urb *urb) function =TIUMP_GET_FUNC_FROM_CODE (data[0 ]);dbg ("%s - port_number %d, function %d, info 0x%x" , __func__, port_number, function, data[1 ]); + +if (port_number >= edge_serial->serial->num_ports) { +dev_err (&urb->dev->dev,"bad port number %d\n" , port_number); + goto exit; + } + port = edge_serial->serial->port[port_number]; edge_port =usb_get_serial_port_data (port);if (!edge_port) {
drivers/usb/serial/option.c +16 -1
@@ -234,6 +234,14 @@ static void option_instat_callback(struct urb *urb);#define BANDRICH_PRODUCT_1012 0x1012#define QUALCOMM_VENDOR_ID 0x05C6 +/* These Quectel products use Qualcomm's vendor ID */ +#define QUECTEL_PRODUCT_UC20 0x9003 +#define QUECTEL_PRODUCT_UC15 0x9090 + +#define QUECTEL_VENDOR_ID 0x2c7c +/* These Quectel products use Quectel's vendor ID */ +#define QUECTEL_PRODUCT_EC21 0x0121 +#define QUECTEL_PRODUCT_EC25 0x0125#define CMOTECH_VENDOR_ID 0x16d8#define CMOTECH_PRODUCT_6001 0x6001
@@ -1147,7 +1155,14 @@ static const struct usb_device_id option_ids[] = { { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */ { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x0023)}, /* ONYX 3G device */ { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x9000)}, /* SIMCom SIM5218 */ - { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x9003), /* Quectel UC20 */ +/* Quectel products using Qualcomm vendor ID */ + { USB_DEVICE(QUALCOMM_VENDOR_ID, QUECTEL_PRODUCT_UC15)}, + { USB_DEVICE(QUALCOMM_VENDOR_ID, QUECTEL_PRODUCT_UC20), + .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, +/* Quectel products using Quectel vendor ID */ + { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC21), + .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, + { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC25), .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6001) }, { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CMU_300) },
drivers/usb/serial/safe_serial.c +5 -0
@@ -232,6 +232,11 @@ static void safe_process_read_urb(struct urb *urb)if (!safe) goto out; +if (length <2 ) { +dev_err (&port->dev,"malformed packet\n" ); +return ; + } + fcs =fcs_compute10 (data, length,CRC10_INITFCS );if (fcs) {dev_err (&port->dev,"%s - bad CRC %x\n" , __func__, fcs);
drivers/usb/wusbcore/wa-hc.c +3 -0
@@ -38,6 +38,9 @@ int wa_create(struct wahc *wa, struct usb_interface *iface)int result;struct device *dev = &iface->dev; +if (iface->cur_altsetting->desc.bNumEndpoints <3 ) +return -ENODEV ; + result =wa_rpipes_create (wa);if (result <0 ) goto error_rpipes_create;
drivers/uwb/hwa-rc.c +3 -0
@@ -811,6 +811,9 @@ static int hwarc_probe(struct usb_interface *iface,struct hwarc *hwarc;struct device *dev = &iface->dev; +if (iface->cur_altsetting->desc.bNumEndpoints <1 ) +return -ENODEV ; + result = -ENOMEM ; uwb_rc =uwb_rc_alloc ();if (uwb_rc ==NULL ) {
drivers/uwb/i1480/dfu/usb.c +3 -0
@@ -362,6 +362,9 @@ int i1480_usb_probe(struct usb_interface *iface, const struct usb_device_id *id) result); } +if (iface->cur_altsetting->desc.bNumEndpoints <1 ) +return -ENODEV ; + result = -ENOMEM ; i1480_usb =kzalloc (sizeof (*i1480_usb),GFP_KERNEL );if (i1480_usb ==NULL ) {
drivers/video/xen-fbfront.c +2 -2
@@ -640,7 +640,6 @@ static void xenfb_backend_changed(struct xenbus_device *dev,break ;case XenbusStateInitWait: -InitWait:xenbus_switch_state (dev, XenbusStateConnected);break ;
@@ -651,7 +650,8 @@ static void xenfb_backend_changed(struct xenbus_device *dev,* get Connected twice here. */ if (dev->state != XenbusStateConnected) - goto InitWait;/* no InitWait seen yet, fudge it */ +/* no InitWait seen yet, fudge it */ +xenbus_switch_state (dev, XenbusStateConnected);if (xenbus_scanf (XBT_NIL , info->xbdev->otherend,"request-update" ,"%d" , &val) <0 )
drivers/virtio/virtio_balloon.c +4 -0
@@ -180,12 +180,14 @@ static void update_balloon_stats(struct virtio_balloon *vb)all_vm_events (events);si_meminfo (&i); +#ifdef CONFIG_VM_EVENT_COUNTERS update_stat (vb, idx++,VIRTIO_BALLOON_S_SWAP_IN ,pages_to_bytes (events[PSWPIN ]));update_stat (vb, idx++,VIRTIO_BALLOON_S_SWAP_OUT ,pages_to_bytes (events[PSWPOUT ]));update_stat (vb, idx++,VIRTIO_BALLOON_S_MAJFLT , events[PGMAJFAULT ]);update_stat (vb, idx++,VIRTIO_BALLOON_S_MINFLT , events[PGFAULT ]); +#endif update_stat (vb, idx++,VIRTIO_BALLOON_S_MEMFREE ,pages_to_bytes (i.freeram)); update_stat(vb, idx++, VIRTIO_BALLOON_S_MEMTOT,
@@ -320,6 +322,8 @@ static int virtballoon_probe(struct virtio_device *vdev)* Prime this virtqueue with one buffer so the hypervisor can * use it to signal us later. */ +update_balloon_stats (vb); +sg_init_one (&sg, vb->stats,sizeof vb->stats);if (virtqueue_add_buf (vb->stats_vq, &sg,1 ,0 , vb) <0 )BUG ();
fs/exec.c +24 -4
@@ -208,8 +208,26 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,if (write) {unsigned long size = bprm->vma->vm_end - bprm->vma->vm_start; +unsigned long ptr_size;struct rlimit *rlim; +/* +* Since the stack will hold pointers to the strings, we +* must account for them as well. +* +* The size calculation is the entire vma while each arg page is +* built, so each time we get here it's calculating how far it +* is currently (rather than each call being just the newly +* added size from the arg page). As a result, we need to +* always add the entire size of the pointers, so that on the +* last call to get_arg_page() we'll actually have the entire +* correct size. +*/ + ptr_size = (bprm->argc + bprm->envc) *sizeof (void *); +if (ptr_size >ULONG_MAX - size) + goto fail; + size += ptr_size; +acct_arg_size (bprm, size /PAGE_SIZE );/*
@@ -227,13 +245,15 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,* to work from. */ rlim = current->signal->rlim; -if (size >ACCESS_ONCE (rlim[RLIMIT_STACK ].rlim_cur) /4 ) { -put_page (page); -return NULL ; - } +if (size >ACCESS_ONCE (rlim[RLIMIT_STACK ].rlim_cur) /4 ) + goto fail; }return page; + +fail: +put_page (page); +return NULL ; }static void put_arg_page (struct page *page)
include/linux/skbuff.h +7 -0
@@ -1926,6 +1926,13 @@ static inline int skb_clone_writable(const struct sk_buff *skb, unsigned int lenskb_headroom (skb) + len <= skb->hdr_len; } +static inline int skb_try_make_writable (struct sk_buff *skb, +unsigned int write_len) +{ +return skb_cloned (skb) && !skb_clone_writable (skb, write_len) && +pskb_expand_head (skb,0 ,0 ,GFP_ATOMIC ); +} +static inline int __skb_cow (struct sk_buff *skb,unsigned int headroom,int cloned) {
include/linux/usb/quirks.h +6 -0
@@ -44,4 +44,10 @@/* device generates spurious wakeup, ignore remote wakeup capability */ #define USB_QUIRK_IGNORE_REMOTE_WAKEUP 0x00000200 +/* +* Device reports its bInterval as linear frames instead of the +* USB 2.0 calculation. +*/ +#define USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL BIT(11) +#endif /* __LINUX_USB_QUIRKS_H */
include/trace/events/syscalls.h +1 -0
@@ -1,5 +1,6 @@#undef TRACE_SYSTEM#define TRACE_SYSTEM raw_syscalls +#undef TRACE_INCLUDE_FILE#define TRACE_INCLUDE_FILE syscalls#if !defined(_TRACE_EVENTS_SYSCALLS_H) || defined(TRACE_HEADER_MULTI_READ )
kernel/events/core.c +3 -2
@@ -7273,7 +7273,7 @@ int perf_event_init_context(struct task_struct *child, int ctxn) ret =inherit_task_group (event, parent, parent_ctx, child, ctxn, &inherited_all);if (ret) -break ; + goto out_unlock; }/*
@@ -7289,7 +7289,7 @@ int perf_event_init_context(struct task_struct *child, int ctxn) ret =inherit_task_group (event, parent, parent_ctx, child, ctxn, &inherited_all);if (ret) -break ; + goto out_unlock; }raw_spin_lock_irqsave (&parent_ctx->lock, flags);
@@ -7317,6 +7317,7 @@ int perf_event_init_context(struct task_struct *child, int ctxn) }raw_spin_unlock_irqrestore (&parent_ctx->lock, flags); +out_unlock:mutex_unlock (&parent_ctx->mutex);perf_unpin_context (parent_ctx);
kernel/futex.c +13 -9
@@ -2410,7 +2410,6 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, unsigned int flags, {struct hrtimer_sleeper timeout, *to =NULL ;struct rt_mutex_waiter rt_waiter; -struct rt_mutex *pi_mutex =NULL ;struct futex_hash_bucket *hb;union futex_key key2 =FUTEX_KEY_INIT ;struct futex_q q = futex_q_init;
@@ -2492,6 +2491,8 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, unsigned int flags,if (q.pi_state && (q.pi_state->owner != current)) {spin_lock (q.lock_ptr); ret =fixup_pi_state_owner (uaddr2, &q, current); +if (ret &&rt_mutex_owner (&q.pi_state->pi_mutex) == current) +rt_mutex_unlock (&q.pi_state->pi_mutex);/* * Drop the reference to the pi state which * the requeue_pi() code acquired for us.
@@ -2500,6 +2501,8 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, unsigned int flags,spin_unlock (q.lock_ptr); } }else { +struct rt_mutex *pi_mutex; +/* * We have been woken up by futex_unlock_pi(), a timeout, or a * signal. futex_unlock_pi() will not destroy the lock_ptr nor
@@ -2523,18 +2526,19 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, unsigned int flags,if (res) ret = (res <0 ) ? res :0 ; +/* +* If fixup_pi_state_owner() faulted and was unable to handle +* the fault, unlock the rt_mutex and return the fault to +* userspace. +*/ +if (ret &&rt_mutex_owner (pi_mutex) == current) +rt_mutex_unlock (pi_mutex); +/* Unqueue and drop the lock. */ unqueue_me_pi (&q); } -/* -* If fixup_pi_state_owner() faulted and was unable to handle the -* fault, unlock the rt_mutex and return the fault to userspace. -*/ -if (ret == -EFAULT ) { -if (pi_mutex &&rt_mutex_owner (pi_mutex) == current) -rt_mutex_unlock (pi_mutex); - }else if (ret == -EINTR ) { +if (ret == -EINTR ) {/* * We've already been requeued, but cannot restart by calling * futex_lock_pi() directly. We could restart this syscall, but
kernel/ptrace.c +10 -4
@@ -148,11 +148,17 @@ static void ptrace_unfreeze_traced(struct task_struct *task)WARN_ON (!task->ptrace || task->parent != current); +/* +* PTRACE_LISTEN can allow ptrace_trap_notify to wake us up remotely. +* Recheck state under the lock to close this race. +*/ spin_lock_irq (&task->sighand->siglock); -if (__fatal_signal_pending (task)) -wake_up_state (task, __TASK_TRACED); -else - task->state =TASK_TRACED ; +if (task->state == __TASK_TRACED) { +if (__fatal_signal_pending (task)) +wake_up_state (task, __TASK_TRACED); +else + task->state =TASK_TRACED ; + }spin_unlock_irq (&task->sighand->siglock); }
kernel/sched.c +2 -2
@@ -3617,8 +3617,9 @@ void calc_load_exit_idle(void)struct rq *this_rq =this_rq ();/* -* If we're still before the sample window, we're done. +* If we're still before the pending sample window, we're done. */ + this_rq->calc_load_update = calc_load_update;if (time_before (jiffies, this_rq->calc_load_update))return ;
@@ -3627,7 +3628,6 @@ void calc_load_exit_idle(void)* accounted through the nohz accounting, so skip the entire deal and * sync up for the next window. */ - this_rq->calc_load_update = calc_load_update;if (time_before (jiffies, this_rq->calc_load_update +10 )) this_rq->calc_load_update +=LOAD_FREQ ; }
kernel/trace/ring_buffer.c +14 -2
@@ -2879,11 +2879,23 @@ EXPORT_SYMBOL_GPL(ring_buffer_iter_reset);int ring_buffer_iter_empty (struct ring_buffer_iter *iter) {struct ring_buffer_per_cpu *cpu_buffer; +struct buffer_page *reader; +struct buffer_page *head_page; +struct buffer_page *commit_page; +unsigned commit; cpu_buffer = iter->cpu_buffer; -return iter->head_page == cpu_buffer->commit_page && - iter->head ==rb_commit_index (cpu_buffer); +/* Remember, trace recording is off when iterator is in use */ + reader = cpu_buffer->reader_page; + head_page = cpu_buffer->head_page; + commit_page = cpu_buffer->commit_page; + commit =rb_page_commit (commit_page); + +return ((iter->head_page == commit_page && iter->head == commit) || + (iter->head_page == reader && commit_page == head_page && + head_page->read == commit && + iter->head ==rb_page_commit (cpu_buffer->reader_page))); }EXPORT_SYMBOL_GPL (ring_buffer_iter_empty);
net/9p/client.c +4 -0
@@ -2056,6 +2056,10 @@ int p9_client_readdir(struct p9_fid *fid, char *data, u32 count, u64 offset)trace_9p_protocol_dump (clnt, req->rc); goto free_and_error; } +if (rsize < count) { +pr_err ("bogus RREADDIR count (%d > %d)\n" , count, rsize); + count = rsize; + }P9_DPRINTK (P9_DEBUG_9P ,"<<< RREADDIR count %d\n" , count);
net/ipv4/ip_output.c +1 -1
@@ -834,7 +834,7 @@ static int __ip_append_data(struct sock *sk, cork->length += length;if (((length > mtu) || (skb &&skb_has_frags (skb))) && (sk->sk_protocol ==IPPROTO_UDP ) && - (rt->dst.dev->features &NETIF_F_UFO ) && !rt->dst.header_len && + (rt->dst.dev->features &NETIF_F_UFO ) && !dst_xfrm (&rt->dst) && (sk->sk_type ==SOCK_DGRAM )) { err = ip_ufo_append_data(sk, queue, getfrag, from, length, hh_len, fragheaderlen, transhdrlen,
net/ipv4/netfilter/nf_nat_snmp_basic.c +1 -18
@@ -1261,16 +1261,6 @@ static const struct nf_conntrack_expect_policy snmp_exp_policy = { .timeout = 180, }; -static struct nf_conntrack_helper snmp_helper__read_mostly = { - .me =THIS_MODULE , - .help = help, - .expect_policy = &snmp_exp_policy, - .name ="snmp" , - .tuple.src.l3num =AF_INET , - .tuple.src.u.udp.port =cpu_to_be16 (SNMP_PORT ), - .tuple.dst.protonum =IPPROTO_UDP , -}; -static struct nf_conntrack_helper snmp_trap_helper__read_mostly = { .me =THIS_MODULE , .help = help,
@@ -1289,17 +1279,10 @@ static struct nf_conntrack_helper snmp_trap_helper __read_mostly = {static int __init nf_nat_snmp_basic_init (void ) { -int ret =0 ; -BUG_ON (nf_nat_snmp_hook !=NULL );RCU_INIT_POINTER (nf_nat_snmp_hook, help); - ret =nf_conntrack_helper_register (&snmp_trap_helper); -if (ret <0 ) { -nf_conntrack_helper_unregister (&snmp_helper); -return ret; - } -return ret; +return nf_conntrack_helper_register (&snmp_trap_helper); } static void __exit nf_nat_snmp_basic_fini(void)
net/ipv6/ip6_output.c +1 -1
@@ -1343,7 +1343,7 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,if (((length > mtu) || (skb &&skb_has_frags (skb))) && (sk->sk_protocol ==IPPROTO_UDP ) && - (rt->dst.dev->features &NETIF_F_UFO ) && !rt->dst.header_len && + (rt->dst.dev->features &NETIF_F_UFO ) && !dst_xfrm (&rt->dst) && (sk->sk_type ==SOCK_DGRAM )) { err = ip6_ufo_append_data(sk, getfrag, from, length, hh_len, fragheaderlen, exthdrlen,
net/ipv6/route.c +2 -0
@@ -2384,6 +2384,8 @@ static int rt6_fill_node(struct net *net, rtm->rtm_type =RTN_UNREACHABLE ; else if (rt->rt6i_flags&RTF_LOCAL) rtm->rtm_type = RTN_LOCAL; + else if (rt->rt6i_flags & RTF_ANYCAST) + rtm->rtm_type = RTN_ANYCAST; else if (rt->rt6i_dev && (rt->rt6i_dev->flags&IFF_LOOPBACK)) rtm->rtm_type = RTN_LOCAL; else
net/key/af_key.c +35 -7
104 lines not on this page · raw message
net/l2tp/l2tp_core.c +128 -34
257 lines not on this page · raw message
net/l2tp/l2tp_core.h +7 -2
@@ -222,9 +222,14 @@ static inline struct l2tp_tunnel *l2tp_sock_to_tunnel(struct sock *sk)return tunnel; } +struct l2tp_session *l2tp_session_get (struct net *net, +struct l2tp_tunnel *tunnel, +u32 session_id,bool do_ref);extern struct l2tp_session *l2tp_session_find (struct net *net,struct l2tp_tunnel *tunnel,u32 session_id); -extern struct l2tp_session *l2tp_session_find_nth (struct l2tp_tunnel *tunnel,int nth); -extern struct l2tp_session *l2tp_session_find_by_ifname (struct net *net,char *ifname); +struct l2tp_session *l2tp_session_get_nth (struct l2tp_tunnel *tunnel,int nth, +bool do_ref); +struct l2tp_session *l2tp_session_get_by_ifname (struct net *net,char *ifname, +bool do_ref);extern struct l2tp_tunnel *l2tp_tunnel_find (struct net *net,u32 tunnel_id);extern struct l2tp_tunnel *l2tp_tunnel_find_nth (struct net *net,int nth);
net/l2tp/l2tp_debugfs.c +7 -3
@@ -51,7 +51,7 @@ static void l2tp_dfs_next_tunnel(struct l2tp_dfs_seq_data *pd)static void l2tp_dfs_next_session (struct l2tp_dfs_seq_data *pd) { - pd->session =l2tp_session_find_nth (pd->tunnel, pd->session_idx); + pd->session =l2tp_session_get_nth (pd->tunnel, pd->session_idx, true); pd->session_idx++;if (pd->session ==NULL ) {
@@ -227,10 +227,14 @@ static int l2tp_dfs_seq_show(struct seq_file *m, void *v) }/* Show the tunnel or session context */ -if (pd->session ==NULL ) +if (!pd->session) {l2tp_dfs_seq_tunnel_show (m, pd->tunnel); -else + }else {l2tp_dfs_seq_session_show (m, pd->session); +if (pd->session->deref) + pd->session->deref (pd->session); +l2tp_session_dec_refcount (pd->session); + } out:return 0 ;
net/l2tp/l2tp_eth.c +2 -8
@@ -200,12 +200,6 @@ static int l2tp_eth_create(struct net *net, u32 tunnel_id, u32 session_id, u32 p goto out; } - session =l2tp_session_find (net, tunnel, session_id); -if (session) { - rc = -EEXIST ; - goto out; - } -if (cfg->ifname) { dev =dev_get_by_name (net, cfg->ifname);if (dev) {
@@ -219,8 +213,8 @@ static int l2tp_eth_create(struct net *net, u32 tunnel_id, u32 session_id, u32 p session =l2tp_session_create (sizeof (*spriv), tunnel, session_id, peer_session_id, cfg); -if (!session) { - rc = -ENOMEM ; +if (IS_ERR (session)) { + rc =PTR_ERR (session); goto out; }
net/l2tp/l2tp_ip.c +12 -5
@@ -148,19 +148,19 @@ static int l2tp_ip_recv(struct sk_buff *skb) }/* Ok, this is a data packet. Lookup the session. */ - session =l2tp_session_find (&init_net,NULL , session_id); -if (session ==NULL ) + session =l2tp_session_get (&init_net,NULL , session_id, true); +if (!session) goto discard; tunnel = session->tunnel; -if (tunnel ==NULL ) - goto discard; +if (!tunnel) + goto discard_sess;/* Trace packet contents, if enabled */ if (tunnel->debug &L2TP_MSG_DATA ) { length =min (32u , skb->len);if (!pskb_may_pull (skb, length)) - goto discard; + goto discard_sess;/* Point to L2TP header */ optr = ptr = skb->data;
@@ -176,6 +176,7 @@ static int l2tp_ip_recv(struct sk_buff *skb) }l2tp_recv_common (session, skb, ptr, optr,0 , skb->len, tunnel->recv_payload_hook); +l2tp_session_dec_refcount (session);return 0 ;
@@ -211,6 +212,12 @@ static int l2tp_ip_recv(struct sk_buff *skb)return sk_receive_skb (sk, skb,1 ); +discard_sess: +if (session->deref) + session->deref (session); +l2tp_session_dec_refcount (session); + goto discard; + discard_put:sock_put (sk);
net/l2tp/l2tp_netlink.c +31 -15
122 lines not on this page · raw message
net/l2tp/l2tp_ppp.c +53 -41
169 lines not on this page · raw message
net/mac80211/rx.c +24 -0
@@ -2842,6 +2842,30 @@ static int prepare_for_handlers(struct ieee80211_rx_data *rx, sdata->vif.p2p))return 0 ; status->rx_flags &= ~IEEE80211_RX_RA_MATCH ; + }else { +/* +* 802.11-2016 Table 9-26 says that for data frames, +* A1 must be the BSSID - we've checked that already +* but may have accepted the wildcard +* (ff:ff:ff:ff:ff:ff). +* +* It also says: +* The BSSID of the Data frame is determined as +* follows: +* a) If the STA is contained within an AP or is +* associated with an AP, the BSSID is the +* address currently in use by the STA +* contained in the AP. +* +* So we should not accept data frames with an address +* that's multicast. +* +* Accepting it also opens a security problem because +* stations could encrypt it with the GTK and inject +* traffic that way. +*/ +if (ieee80211_is_data (hdr->frame_control) && multicast) +return 0 ; }break ;case NL80211_IFTYPE_WDS :
net/sched/act_csum.c +2 -6
@@ -122,9 +122,7 @@ static void *tcf_csum_skb_nextlayer(struct sk_buff *skb,int hl = ihl + jhl;if (!pskb_may_pull (skb, ipl + ntkoff) || (ipl < hl) || - (skb_cloned (skb) && - !skb_clone_writable (skb, hl + ntkoff) && -pskb_expand_head (skb,0 ,0 ,GFP_ATOMIC ))) +skb_try_make_writable (skb, hl + ntkoff))return NULL ;else return (void *)(skb_network_header (skb) + ihl);
@@ -372,9 +370,7 @@ static int tcf_csum_ipv4(struct sk_buff *skb, u32 update_flags) }if (update_flags &TCA_CSUM_UPDATE_FLAG_IPV4HDR ) { -if (skb_cloned (skb) && - !skb_clone_writable (skb,sizeof (*iph) + ntkoff) && -pskb_expand_head (skb,0 ,0 ,GFP_ATOMIC )) +if (skb_try_make_writable (skb,sizeof (*iph) + ntkoff)) goto fail;ip_send_check (iph);
net/sched/act_nat.c +5 -13
@@ -144,9 +144,7 @@ static int tcf_nat(struct sk_buff *skb, const struct tc_action *a, addr = iph->daddr;if (!((old_addr ^ addr) & mask)) { -if (skb_cloned (skb) && - !skb_clone_writable (skb,sizeof (*iph) + noff) && -pskb_expand_head (skb,0 ,0 ,GFP_ATOMIC )) +if (skb_try_make_writable (skb,sizeof (*iph) + noff)) goto drop; new_addr &= mask;
@@ -174,9 +172,7 @@ static int tcf_nat(struct sk_buff *skb, const struct tc_action *a,struct tcphdr *tcph;if (!pskb_may_pull (skb, ihl +sizeof (*tcph) + noff) || - (skb_cloned (skb) && - !skb_clone_writable (skb, ihl +sizeof (*tcph) + noff) && -pskb_expand_head (skb,0 ,0 ,GFP_ATOMIC ))) +skb_try_make_writable (skb, ihl +sizeof (*tcph) + noff)) goto drop; tcph = (void *)(skb_network_header (skb) + ihl);
@@ -188,9 +184,7 @@ static int tcf_nat(struct sk_buff *skb, const struct tc_action *a,struct udphdr *udph;if (!pskb_may_pull (skb, ihl +sizeof (*udph) + noff) || - (skb_cloned (skb) && - !skb_clone_writable (skb, ihl +sizeof (*udph) + noff) && -pskb_expand_head (skb,0 ,0 ,GFP_ATOMIC ))) +skb_try_make_writable (skb, ihl +sizeof (*udph) + noff)) goto drop; udph = (void *)(skb_network_header (skb) + ihl);
@@ -230,10 +224,8 @@ static int tcf_nat(struct sk_buff *skb, const struct tc_action *a,if ((old_addr ^ addr) & mask)break ; -if (skb_cloned (skb) && - !skb_clone_writable (skb, ihl +sizeof (*icmph) + -sizeof (*iph) + noff) && -pskb_expand_head (skb,0 ,0 ,GFP_ATOMIC )) +if (skb_try_make_writable (skb, ihl +sizeof (*icmph) + +sizeof (*iph) + noff)) goto drop; icmph = (void *)(skb_network_header (skb) + ihl);
net/sched/sch_dsmark.c +8 -2
@@ -202,9 +202,13 @@ static int dsmark_enqueue(struct sk_buff *skb, struct Qdisc *sch)pr_debug ("dsmark_enqueue(skb %p,sch %p,[qdisc %p])\n" , skb, sch, p);if (p->set_tc_index) { +int wlen =skb_network_offset (skb); +switch (skb->protocol) {case htons (ETH_P_IP ): -if (skb_cow_head (skb,sizeof (struct iphdr ))) + wlen +=sizeof (struct iphdr ); +if (!pskb_may_pull (skb, wlen) || +skb_try_make_writable (skb, wlen)) goto drop; skb->tc_index =ipv4_get_dsfield (ip_hdr (skb))
@@ -212,7 +216,9 @@ static int dsmark_enqueue(struct sk_buff *skb, struct Qdisc *sch)break ;case htons (ETH_P_IPV6 ): -if (skb_cow_head (skb,sizeof (struct ipv6hdr ))) + wlen +=sizeof (struct ipv6hdr ); +if (!pskb_may_pull (skb, wlen) || +skb_try_make_writable (skb, wlen)) goto drop; skb->tc_index =ipv6_get_dsfield (ipv6_hdr (skb))
net/unix/garbage.c +9 -9
@@ -150,6 +150,7 @@ void unix_notinflight(struct user_struct *user, struct file *fp)if (s) {struct unix_sock *u =unix_sk (s); +BUG_ON (!atomic_long_read (&u->inflight));BUG_ON (list_empty (&u->link));if (atomic_long_dec_and_test (&u->inflight))list_del_init (&u->link);
@@ -356,6 +357,14 @@ void unix_gc(void) }list_del (&cursor); +/* Now gc_candidates contains only garbage. Restore original +* inflight counters for these as well, and remove the skbuffs +* which are creating the cycle(s). +*/ +skb_queue_head_init (&hitlist); +list_for_each_entry (u, &gc_candidates, link) +scan_children (&u->sk, inc_inflight, &hitlist); +/* * not_cycle_list contains those sockets which do not make up a * cycle. Restore these to the inflight list.
@@ -366,15 +375,6 @@ void unix_gc(void)list_move_tail (&u->link, &gc_inflight_list); } -/* -* Now gc_candidates contains only garbage. Restore original -* inflight counters for these as well, and remove the skbuffs -* which are creating the cycle(s). -*/ -skb_queue_head_init (&hitlist); -list_for_each_entry (u, &gc_candidates, link) -scan_children (&u->sk, inc_inflight, &hitlist); -spin_unlock (&unix_gc_lock);/* Here we are. Hitlist is filled. Die. */
security/keys/gc.c +1 -1
@@ -46,7 +46,7 @@ static unsigned long key_gc_flags;* immediately unlinked. */ struct key_type key_type_dead = { - .name ="dead" , + .name =".dead" , };/*
sound/core/seq/seq_clientmgr.c +1 -0
@@ -1909,6 +1909,7 @@ static int snd_seq_ioctl_set_client_pool(struct snd_seq_client *client, info.output_pool != client->pool->size)) {if (snd_seq_write_pool_allocated (client)) {/* remove all existing cells */ +snd_seq_pool_mark_closing (client->pool);snd_seq_queue_client_leave_cells (client->number);snd_seq_pool_done (client->pool); }
sound/core/seq/seq_fifo.c +7 -0
@@ -72,6 +72,9 @@ void snd_seq_fifo_delete(struct snd_seq_fifo **fifo)return ; *fifo =NULL ; +if (f->pool) +snd_seq_pool_mark_closing (f->pool); +snd_seq_fifo_clear (f);/* wake up clients if any */
@@ -264,6 +267,10 @@ int snd_seq_fifo_resize(struct snd_seq_fifo *f, int poolsize)/* NOTE: overflow flag is not cleared */ spin_unlock_irqrestore (&f->lock, flags); +/* close the old pool and wait until all users are gone */ +snd_seq_pool_mark_closing (oldpool); +snd_use_lock_sync (&f->use_lock); +/* release cells in old pool */ for (cell = oldhead; cell; cell = next) { next = cell->next;
sound/core/seq/seq_lock.c +3 -6
@@ -28,19 +28,16 @@/* wait until all locks are released */ void snd_use_lock_sync_helper (snd_use_lock_t *lockp,const char *file,int line) { -int max_count =5 *HZ ; +int warn_count =5 *HZ ;if (atomic_read (lockp) <0 ) {printk (KERN_WARNING "seq_lock: lock trouble [counter = %d] in %s:%d\n" ,atomic_read (lockp), file, line);return ; }while (atomic_read (lockp) >0 ) { -if (max_count ==0 ) { -snd_printk (KERN_WARNING "seq_lock: timeout [%d left] in %s:%d\n" ,atomic_read (lockp), file, line); -break ; - } +if (warn_count-- ==0 ) +pr_warn ("ALSA: seq_lock: waiting [%d left] in %s:%d\n" ,atomic_read (lockp), file, line);schedule_timeout_uninterruptible (1 ); - max_count--; } }
sound/core/seq/seq_memory.c +13 -4
@@ -416,6 +416,18 @@ int snd_seq_pool_init(struct snd_seq_pool *pool)return 0 ; } +/* refuse the further insertion to the pool */ +void snd_seq_pool_mark_closing (struct snd_seq_pool *pool) +{ +unsigned long flags; + +if (snd_BUG_ON (!pool)) +return ; +spin_lock_irqsave (&pool->lock, flags); + pool->closing =1 ; +spin_unlock_irqrestore (&pool->lock, flags); +} +/* remove events */ int snd_seq_pool_done (struct snd_seq_pool *pool) {
@@ -426,10 +438,6 @@ int snd_seq_pool_done(struct snd_seq_pool *pool)return -EINVAL ;/* wait for closing all threads */ -spin_lock_irqsave (&pool->lock, flags); - pool->closing =1 ; -spin_unlock_irqrestore (&pool->lock, flags); -if (waitqueue_active (&pool->output_sleep))wake_up (&pool->output_sleep);
@@ -488,6 +496,7 @@ int snd_seq_pool_delete(struct snd_seq_pool **ppool) *ppool =NULL ;if (pool ==NULL )return 0 ; +snd_seq_pool_mark_closing (pool);snd_seq_pool_done (pool);kfree (pool);return 0 ;
sound/core/seq/seq_memory.h +1 -0
@@ -84,6 +84,7 @@ static inline int snd_seq_total_cells(struct snd_seq_pool *pool)int snd_seq_pool_init (struct snd_seq_pool *pool);/* done pool - free events */ +void snd_seq_pool_mark_closing (struct snd_seq_pool *pool);int snd_seq_pool_done (struct snd_seq_pool *pool);/* create pool */
sound/core/timer.c +5 -2
@@ -1590,6 +1590,7 @@ static int snd_timer_user_tselect(struct file *file,if (err <0 ) goto __err; + tu->qhead = tu->qtail = tu->qused =0 ;kfree (tu->queue); tu->queue =NULL ;kfree (tu->tqueue);
@@ -1930,6 +1931,7 @@ static ssize_t snd_timer_user_read(struct file *file, char __user *buffer, tu = file->private_data; unit = tu->tread ?sizeof (struct snd_timer_tread ) :sizeof (struct snd_timer_read ); +mutex_lock (&tu->ioctl_lock);spin_lock_irq (&tu->qlock);while ((long )count - result >= unit) {while (!tu->qused) {
@@ -1945,7 +1947,9 @@ static ssize_t snd_timer_user_read(struct file *file, char __user *buffer,add_wait_queue (&tu->qchange_sleep, &wait);spin_unlock_irq (&tu->qlock); +mutex_unlock (&tu->ioctl_lock);schedule (); +mutex_lock (&tu->ioctl_lock);spin_lock_irq (&tu->qlock);remove_wait_queue (&tu->qchange_sleep, &wait);
@@ -1961,7 +1965,6 @@ static ssize_t snd_timer_user_read(struct file *file, char __user *buffer, tu->qused--;spin_unlock_irq (&tu->qlock); -mutex_lock (&tu->ioctl_lock);if (tu->tread) {if (copy_to_user (buffer, &tu->tqueue[qhead],sizeof (struct snd_timer_tread )))
@@ -1971,7 +1974,6 @@ static ssize_t snd_timer_user_read(struct file *file, char __user *buffer, sizeof(struct snd_timer_read))) err = -EFAULT ; } -mutex_unlock (&tu->ioctl_lock);spin_lock_irq (&tu->qlock);if (err <0 )
@@ -1981,6 +1983,7 @@ static ssize_t snd_timer_user_read(struct file *file, char __user *buffer, } _error:spin_unlock_irq (&tu->qlock); +mutex_unlock (&tu->ioctl_lock);return result >0 ? result : err; }
sound/pci/ctxfi/cthw20k1.c +1 -1
@@ -1904,7 +1904,7 @@ static int hw_card_start(struct hw *hw)return err;/* Set DMA transfer mask */ -if (dma_set_mask (&pci->dev,DMA_BIT_MASK (dma_bits))) { +if (!dma_set_mask (&pci->dev,DMA_BIT_MASK (dma_bits))) {dma_set_coherent_mask (&pci->dev,DMA_BIT_MASK (dma_bits)); }else {dma_set_mask (&pci->dev,DMA_BIT_MASK (32 ));
tools/perf/util/symbol.c +1 -1
@@ -193,7 +193,7 @@ static void symbols__fixup_end(struct rb_root *symbols)/* Last entry */ if (curr->end == curr->start) - curr->end =roundup (curr->start,4096 ); + curr->end =roundup (curr->start,4096 ) +4096 ; }static void __map_groups__fixup_end (struct map_groups *mg,enum map_type type)
tools/power/cpupower/utils/helpers/cpuid.c +1 -0
@@ -156,6 +156,7 @@ int get_cpu_info(unsigned int cpu, struct cpupower_cpu_info *cpu_info)*/ case 0x2C :/* Westmere EP - Gulftown */ cpu_info->caps |=CPUPOWER_CAP_HAS_TURBO_RATIO ; +break ;case 0x2A :/* SNB */ case 0x2D :/* SNB Xeon */ cpu_info->caps |=CPUPOWER_CAP_HAS_TURBO_RATIO ;