3.8.6-stable review
Subsystems (70)
Greg Kroah-Hartman
maintainercover 3.8.6-stable review
This is the start of the stable review cycle for the 3.8.6 release. There are 124 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu Apr 4 22:09:55 UTC 2013. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
kernel.org/pub/linux/kernel/v3.0/stable-review/patch-3.8.6-rc1.gz
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 3.8.6-rc1
Steve Glendinning <[email protected]>
smsc75xx: fix jumbo frame support
Veaceslav Falico <[email protected]>
pch_gbe: fix ip_summed checksum reporting on rx
Vijay Subramanian <[email protected]>
net: fq_codel: Fix off-by-one error
Li RongQing <[email protected]>
net: fix the use of this_cpu_ptr
Lothar Waßmann <[email protected]>
net: ethernet: cpsw: fix erroneous condition in error check
Eric Dumazet <[email protected]>
net: add a synchronize_net() in netdev_rx_handler_unregister()
[email protected] <[email protected]>
ks8851: Fix interpretation of rxlen field.
Hannes Frederic Sowa <[email protected]>
ipv6: don't accept node local multicast traffic from the wire
Hannes Frederic Sowa <[email protected]>
ipv6: don't accept multicast traffic with scope 0
Hong Zhiguo <[email protected]>
ipv6: fix bad free of addrconf_init_net
Fabio Estevam <[email protected]>
fec: Fix the build as module
Joseph CHANG <[email protected]>
DM9000B: driver initialization upgrade
Hannes Frederic Sowa <[email protected]>
atl1e: drop pci-msi support because of packet corruption
Eric Dumazet <[email protected]>
aoe: reserve enough headroom on skbs
Andrey Vagin <[email protected]>
net: fix *_DIAG_MAX constants
Mugunthan V N <[email protected]>
drivers: net: ethernet: cpsw: use netif_wake_queue() while restarting tx queue
Mugunthan V N <[email protected]>
drivers: net: ethernet: davinci_emac: use netif_wake_queue() while restarting tx queue
[email protected] <[email protected]>
bonding: fix disabling of arp_interval and miimon
Veaceslav Falico <[email protected]>
bonding: remove already created master sysfs link on failure
dingtianhong <[email protected]>
af_unix: dont send SCM_CREDENTIAL when dest socket is NULL
Paul Moore <[email protected]>
unix: fix a race condition in unix_release()
Masatake YAMATO <[email protected]>
thermal: shorten too long mcast group name
Cong Wang <[email protected]>
8021q: fix a potential use-after-free
Yuchung Cheng <[email protected]>
tcp: undo spurious timeout after SACK reneging
Eric Dumazet <[email protected]>
tcp: preserve ACK clocking in TSO
Mirko Lindner <[email protected]>
sky2: Threshold for Pause Packet is set wrong
Mirko Lindner <[email protected]>
sky2: Receive Overflows not counted
Eric Dumazet <[email protected]>
net: remove a WARN_ON() in net_enable_timestamp()
Russ Dill <[email protected]>
regulator: Fix memory garbage dev_err printout.
Matt Fleming <[email protected]>
efivars: Handle duplicate names from get_next_variable()
Matt Fleming <[email protected]>
efivars: explicitly calculate length of VariableName
Steven Rostedt (Red Hat) <[email protected]>
tracing: Prevent buffer overwrite disabled for latency tracers
David Vrabel <[email protected]>
xen/events: avoid race with raising an event in unmask_evtchn()
Josef Bacik <[email protected]>
Btrfs: fix space leak when we fail to reserve metadata space
Emmanuel Grumbach <[email protected]>
iwlwifi: dvm: don't send HCMD in restart flow
Ville Syrjälä <[email protected]>
drm/i915: Don't clobber crtc->fb when queue_flip fails
Takashi Iwai <[email protected]>
drm/i915: Use the fixed pixel clock for eDP in intel_dp_set_m_n()
J. Bruce Fields <[email protected]>
nfsd4: reject "negative" acl lengths
Amit Shah <[email protected]>
virtio: console: add locking around c_ovq operations
Amit Shah <[email protected]>
virtio: console: rename cvq_lock to c_ivq_lock
Rajendra Nayak <[email protected]>
ARM: OMAP: clocks: Delay clk inits atleast until slab is initialized
Eric Hutter <[email protected]>
ARM: kirkwood: Fix chip-delay for GoFlex Net
Shawn Guo <[email protected]>
ARM: imx: fix sync issue between imx_cpu_die and imx_cpu_kill
Mac Lin <[email protected]>
ARM: cns3xxx: fix mapping of private memory region
Anatol Pomozov <[email protected]>
loop: prevent bdev freeing while device in use
Andrew Morton <[email protected]>
kernel/signal.c: use __ARCH_HAS_SA_RESTORER instead of SA_RESTORER
Ben Hutchings <[email protected]>
signal: Define __ARCH_HAS_SA_RESTORER so we know whether to clear sa_restorer
Alan Stern <[email protected]>
usb: gadget: udc-core: fix a regression during gadget driver unbinding
Johan Hovold <[email protected]>
USB: ti_usb_3410_5052: fix use-after-free in TIOCMIWAIT
Johan Hovold <[email protected]>
USB: cypress_m8: fix use-after-free in TIOCMIWAIT
Johan Hovold <[email protected]>
USB: mct_u232: fix use-after-free in TIOCMIWAIT
Johan Hovold <[email protected]>
USB: ark3116: fix use-after-free in TIOCMIWAIT
Johan Hovold <[email protected]>
USB: f81232: fix use-after-free in TIOCMIWAIT
Johan Hovold <[email protected]>
USB: io_edgeport: fix use-after-free in TIOCMIWAIT
Johan Hovold <[email protected]>
USB: ch341: fix use-after-free in TIOCMIWAIT
Johan Hovold <[email protected]>
USB: ssu100: fix use-after-free in TIOCMIWAIT
Johan Hovold <[email protected]>
USB: spcp8x5: fix use-after-free in TIOCMIWAIT
Johan Hovold <[email protected]>
USB: mos7840: fix use-after-free in TIOCMIWAIT
Johan Hovold <[email protected]>
USB: pl2303: fix use-after-free in TIOCMIWAIT
Johan Hovold <[email protected]>
USB: ftdi_sio: fix use-after-free in TIOCMIWAIT
Johan Hovold <[email protected]>
USB: oti6858: fix use-after-free in TIOCMIWAIT
Johan Hovold <[email protected]>
USB: io_ti: fix use-after-free in TIOCMIWAIT
Johan Hovold <[email protected]>
USB: mos7840: fix broken TIOCMIWAIT
Johan Hovold <[email protected]>
USB: quatech2: fix use-after-free in TIOCMIWAIT
Ming Lei <[email protected]>
USB: serial: fix hang when opening port
Johan Hovold <[email protected]>
USB: serial: add modem-status-change wait queue
Josef Bacik <[email protected]>
Btrfs: don't drop path when printing out tree errors in scrub
Josef Bacik <[email protected]>
Btrfs: limit the global reserve to 512mb
Chris Mason <[email protected]>
Btrfs: fix race between mmap writes and compression
Jan Schmidt <[email protected]>
Btrfs: fix locking on ROOT_REPLACE operations in tree mod log
Josef Bacik <[email protected]>
Btrfs: use set_nlink if our i_nlink is 0
Eric W. Biederman <[email protected]>
userns: Restrict when proc and sysfs can be mounted
Eric W. Biederman <[email protected]>
ipc: Restrict mounting the mqueue filesystem
Eric W. Biederman <[email protected]>
vfs: Carefully propogate mounts across user namespaces
Eric W. Biederman <[email protected]>
vfs: Add a mount flag to lock read only bind mounts
Eric W. Biederman <[email protected]>
userns: Don't allow creation if the user is chrooted
Eric W. Biederman <[email protected]>
pid: Handle the exit of a multi-threaded init.
Eric W. Biederman <[email protected]>
scm: Require CAP_SYS_ADMIN over the current pidns to spoof pids.
Johannes Berg <[email protected]>
mac80211: prevent spurious HT/VHT downgrade message
Hans de Goede <[email protected]>
media: [REGRESSION] bt8xx: Fix too large height in cropcap
Nicholas Bellinger <[email protected]>
target: Fix RESERVATION_CONFLICT status regression for iscsi-target special case
Vivek Gautam <[email protected]>
usb: xhci: Fix TRB transfer length macro used for Event TRB.
Soeren Moch <[email protected]>
USB: EHCI: fix bug in iTD/siTD DMA pool allocation
Al Viro <[email protected]>
Nest rename_lock inside vfsmount_lock
Kees Cook <[email protected]>
net/irda: add missing error path release_sock call
Trond Myklebust <[email protected]>
NFSv4.1: Always clear the NFS_INO_LAYOUTCOMMIT in layoutreturn
Trond Myklebust <[email protected]>
NFSv4.1: Fix a race in pNFS layoutcommit
Trond Myklebust <[email protected]>
NFSv4: Fix the string length returned by the idmapper
fanchaoting <[email protected]>
pnfs-block: removing DM device maybe cause oops when call dev_remove
Bing Zhao <[email protected]>
mwifiex: cancel cmd timer and free curr_cmd in shutdown process
Bing Zhao <[email protected]>
mwifiex: skip pending commands after function shutdown
Amitkumar Karwar <[email protected]>
mwifiex: fix race when queuing commands
Al Viro <[email protected]>
vt: synchronize_rcu() under spinlock is not nice...
Konstantin Holoborodko <[email protected]>
usb: ftdi_sio: Add support for Mitsubishi FX-USB-AW/-BD
Pawel Wieczorkiewicz <[email protected]>
tty: atmel_serial_probe(): index of atmel_ports[] fix
Roger Pau Monne <[email protected]>
xen-blkfront: switch from llist to list
Jan Beulich <[email protected]>
xen-blkback: fix dispatch_rw_block_io() error path
David Vrabel <[email protected]>
xen/blkback: correctly respond to unknown, non-native requests
Jan Beulich <[email protected]>
xen-pciback: notify hypervisor about devices intended to be assigned to guests
Joerg Roedel <[email protected]>
iommu/amd: Make sure dma_ops are set for hotplug devices
Johannes Berg <[email protected]>
mac80211: always synchronize_net() during station removal
Kees Cook <[email protected]>
tg3: fix length overflow in VPD firmware parsing
Rafał Miłecki <[email protected]>
b43: N-PHY: use more bits for offset in RSSI calibration
Iestyn C. Elfick <[email protected]>
b43: A fix for DMA transmission sequence errors
Rafał Miłecki <[email protected]>
b43: N-PHY: increase initial value of "mind" in RSSI calibration
Emmanuel Grumbach <[email protected]>
iwlwifi: fix length check in multi-TB HCMD
Jussi Kivilinna <[email protected]>
rtlwifi: usb: add missing freeing of skbuff
Jiri Kosina <[email protected]>
HID: usbhid: fix build problem
Josh Boyer <[email protected]>
HID: usbhid: quirk for MSI GX680R led panel
Josh Boyer <[email protected]>
HID: usbhid: quirk for Realtek Multi-card reader
Luis R. Rodriguez <[email protected]>
ath9k: avoid queueing hw check work when suspended
Felix Fietkau <[email protected]>
ath9k: limit tx path hang check to normal data queues
Felix Fietkau <[email protected]>
ath9k_hw: revert chainmask to user configuration after calibration
Marc Kleine-Budde <[email protected]>
can: sja1000: fix define conflict on SH
Ming Lei <[email protected]>
sysfs: handle failure path correctly for readdir()
Ming Lei <[email protected]>
sysfs: fix race between readdir and lseek
Horia Geanta <[email protected]>
Revert "crypto: caam - add IPsec ESN support"
Horia Geanta <[email protected]>
Revert "crypto: talitos - add IPsec ESN support"
Ian Abbott <[email protected]>
staging: comedi: s626: fix continuous acquisition
Ming Lei <[email protected]>
Bluetooth: Add support for Dell[QCA 0cf3:817a]
Ming Lei <[email protected]>
Bluetooth: Add support for Dell[QCA 0cf3:0036]
Vinicius Costa Gomes <[email protected]>
Bluetooth: Fix not closing SCO sockets in the BT_CONNECT2 state
Chris Metcalf <[email protected]>
tile: expect new initramfs name from hypervisor file system
Trond Myklebust <[email protected]>
SUNRPC: Add barriers to ensure read ordering in rpc_wake_up_task_queue_locked
-------------
Diffstat:
Makefile | 4 +- arch/arm/boot/dts/kirkwood-goflexnet.dts | 1 + arch/arm/include/asm/signal.h | 1 + arch/arm/mach-cns3xxx/core.c | 16 +- arch/arm/mach-cns3xxx/include/mach/cns3xxx.h | 16 +- arch/arm/mach-imx/common.h | 2 + arch/arm/mach-imx/hotplug.c | 12 ++ arch/arm/mach-imx/src.c | 12 ++ arch/arm/mach-omap2/common.h | 3 + arch/arm/mach-omap2/io.c | 18 +- arch/arm/mach-omap2/timer.c | 4 + arch/avr32/include/asm/signal.h | 1 + arch/cris/include/asm/signal.h | 1 + arch/h8300/include/asm/signal.h | 1 + arch/m32r/include/asm/signal.h | 1 + arch/m68k/include/asm/signal.h | 1 + arch/mn10300/include/asm/signal.h | 1 + arch/powerpc/include/asm/signal.h | 1 + arch/s390/include/asm/signal.h | 1 + arch/sparc/include/asm/signal.h | 2 + arch/tile/kernel/setup.c | 25 ++- arch/x86/include/asm/signal.h | 3 + arch/x86/include/asm/xen/hypercall.h | 4 +- arch/xtensa/include/asm/signal.h | 1 + drivers/block/aoe/aoecmd.c | 3 +- drivers/block/loop.c | 9 +- drivers/block/xen-blkback/blkback.c | 38 +++- drivers/block/xen-blkback/common.h | 25 +++ drivers/block/xen-blkfront.c | 41 ++-- drivers/bluetooth/ath3k.c | 4 + drivers/bluetooth/btusb.c | 2 + drivers/char/virtio_console.c | 22 ++- drivers/crypto/caam/caamalg.c | 27 +-- drivers/crypto/caam/compat.h | 1 - drivers/crypto/talitos.c | 30 +-- drivers/firmware/efivars.c | 87 +++++++++ drivers/gpu/drm/i915/intel_display.c | 11 +- drivers/gpu/drm/i915/intel_dp.c | 12 +- drivers/hid/hid-ids.h | 6 + drivers/hid/usbhid/hid-quirks.c | 2 + drivers/iommu/amd_iommu.c | 22 +-- drivers/media/pci/bt8xx/bttv-driver.c | 20 +- drivers/net/bonding/bond_sysfs.c | 97 +++++----- drivers/net/can/sja1000/plx_pci.c | 4 +- drivers/net/can/sja1000/sja1000.c | 6 +- drivers/net/can/sja1000/sja1000.h | 2 +- drivers/net/ethernet/atheros/atl1e/atl1e.h | 1 - drivers/net/ethernet/atheros/atl1e/atl1e_main.c | 19 +- drivers/net/ethernet/broadcom/tg3.c | 7 +- drivers/net/ethernet/davicom/dm9000.c | 214 +++++++++++---------- drivers/net/ethernet/davicom/dm9000.h | 11 +- drivers/net/ethernet/freescale/fec_ptp.c | 3 + drivers/net/ethernet/marvell/sky2.c | 2 +- drivers/net/ethernet/marvell/sky2.h | 2 +- drivers/net/ethernet/micrel/ks8851.c | 2 +- .../net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 4 +- drivers/net/ethernet/ti/cpsw.c | 4 +- drivers/net/ethernet/ti/davinci_emac.c | 2 +- drivers/net/usb/smsc75xx.c | 12 +- drivers/net/wireless/ath/ath9k/ar9003_calib.c | 4 + drivers/net/wireless/ath/ath9k/link.c | 29 +-- drivers/net/wireless/b43/dma.c | 65 +++++-- drivers/net/wireless/b43/phy_n.c | 8 +- drivers/net/wireless/iwlwifi/dvm/lib.c | 9 + drivers/net/wireless/iwlwifi/dvm/ucode.c | 4 +- drivers/net/wireless/iwlwifi/pcie/tx.c | 2 +- drivers/net/wireless/mwifiex/cmdevt.c | 22 ++- drivers/net/wireless/mwifiex/init.c | 8 + drivers/net/wireless/mwifiex/main.h | 4 +- drivers/net/wireless/mwifiex/scan.c | 8 +- drivers/net/wireless/mwifiex/sta_ioctl.c | 10 +- drivers/net/wireless/rtlwifi/usb.c | 1 + drivers/regulator/core.c | 4 +- drivers/staging/comedi/drivers/s626.c | 2 +- drivers/target/target_core_transport.c | 4 +- drivers/tty/serial/atmel_serial.c | 11 +- drivers/tty/vt/vc_screen.c | 6 +- drivers/usb/gadget/udc-core.c | 2 +- drivers/usb/host/ehci-sched.c | 2 + drivers/usb/host/xhci-ring.c | 24 +-- drivers/usb/host/xhci.h | 4 + drivers/usb/serial/ark3116.c | 10 +- drivers/usb/serial/ch341.c | 11 +- drivers/usb/serial/cypress_m8.c | 14 +- drivers/usb/serial/f81232.c | 9 +- drivers/usb/serial/ftdi_sio.c | 20 +- drivers/usb/serial/ftdi_sio_ids.h | 7 + drivers/usb/serial/io_edgeport.c | 12 +- drivers/usb/serial/io_ti.c | 12 +- drivers/usb/serial/mct_u232.c | 13 +- drivers/usb/serial/mos7840.c | 16 +- drivers/usb/serial/oti6858.c | 10 +- drivers/usb/serial/pl2303.c | 11 +- drivers/usb/serial/quatech2.c | 12 +- drivers/usb/serial/spcp8x5.c | 9 +- drivers/usb/serial/ssu100.c | 12 +- drivers/usb/serial/ti_usb_3410_5052.c | 10 +- drivers/usb/serial/usb-serial.c | 1 + drivers/xen/events.c | 20 +- drivers/xen/fallback.c | 3 +- drivers/xen/xen-pciback/pci_stub.c | 59 ++++-- fs/block_dev.c | 1 + fs/btrfs/ctree.c | 30 ++- fs/btrfs/extent-tree.c | 49 ++++- fs/btrfs/extent_io.c | 33 ++++ fs/btrfs/extent_io.h | 2 + fs/btrfs/inode.c | 14 ++ fs/btrfs/scrub.c | 3 +- fs/btrfs/tree-log.c | 5 +- fs/dcache.c | 16 +- fs/namespace.c | 54 +++++- fs/nfs/blocklayout/blocklayoutdm.c | 4 +- fs/nfs/idmap.c | 13 +- fs/nfs/nfs4filelayout.c | 1 - fs/nfs/nfs4proc.c | 14 -- fs/nfs/pnfs.c | 54 +++++- fs/nfsd/nfs4xdr.c | 2 +- fs/pnode.c | 6 + fs/pnode.h | 1 + fs/proc/root.c | 4 + fs/sysfs/dir.c | 17 +- fs/sysfs/mount.c | 4 + include/linux/fs_struct.h | 2 + include/linux/mount.h | 2 + include/linux/thermal.h | 2 +- include/linux/usb/serial.h | 2 + include/linux/user_namespace.h | 4 + include/uapi/asm-generic/signal.h | 4 + include/uapi/linux/packet_diag.h | 4 +- include/uapi/linux/unix_diag.h | 4 +- include/xen/interface/io/blkif.h | 10 + include/xen/interface/physdev.h | 6 + ipc/mqueue.c | 12 +- kernel/pid_namespace.c | 3 +- kernel/signal.c | 2 +- kernel/trace/trace.c | 38 +++- kernel/trace/trace.h | 6 + kernel/trace/trace_irqsoff.c | 19 +- kernel/trace/trace_sched_wakeup.c | 18 +- kernel/user.c | 2 + kernel/user_namespace.c | 11 ++ net/8021q/vlan.c | 14 +- net/bluetooth/sco.c | 1 + net/core/dev.c | 7 +- net/core/flow.c | 2 +- net/core/scm.c | 4 +- net/ipv4/tcp_input.c | 7 +- net/ipv4/tcp_output.c | 7 +- net/ipv6/addrconf.c | 26 +-- net/ipv6/ip6_input.c | 21 ++ net/irda/af_irda.c | 6 +- net/mac80211/mlme.c | 4 + net/mac80211/sta_info.c | 12 +- net/netlink/genetlink.c | 1 + net/sched/sch_fq_codel.c | 2 +- net/sunrpc/sched.c | 9 +- net/unix/af_unix.c | 11 +- 157 files changed, 1343 insertions(+), 659 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 1/124 SUNRPC: Add barriers to ensure read ordering in rpc_wake_up_task_queue_locked
3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Trond Myklebust <[email protected]>
commit 1166fde6a923c30f4351515b6a9a1efc513e7d00 upstream.
We need to be careful when testing task->tk_waitqueue in rpc_wake_up_task_queue_locked, because it can be changed while we are holding the queue->lock.
By adding appropriate memory barriers, we can ensure that it is safe to test task->tk_waitqueue for equality if the RPC_TASK_QUEUED bit is set.
--- net/sunrpc/sched.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
net/sunrpc/sched.c +7 -2
@@ -180,6 +180,8 @@ static void __rpc_add_wait_queue(structlist_add_tail (&task->u.tk_wait.list, &queue->tasks[0 ]); task->tk_waitqueue = queue; queue->qlen++; +/* barrier matches the read in rpc_wake_up_task_queue_locked() */ +smp_wmb ();rpc_set_queued (task); dprintk("RPC: %5u added to queue %p \"%s\"\n",
@@ -430,8 +432,11 @@ static void __rpc_do_wake_up_task(struct*/ static void rpc_wake_up_task_queue_locked (struct rpc_wait_queue *queue,struct rpc_task *task) { -if (RPC_IS_QUEUED (task) && task->tk_waitqueue == queue) -__rpc_do_wake_up_task (queue, task); +if (RPC_IS_QUEUED (task)) { +smp_rmb (); +if (task->tk_waitqueue == queue) +__rpc_do_wake_up_task (queue, task); + } }/*
Greg Kroah-Hartman
maintainerPATCH 2/124 tile: expect new initramfs name from hypervisor file system
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Metcalf <[email protected]>
commit ff7f3efb9abf986f4ecd8793a9593f7ca4d6431a upstream.
The current Tilera boot infrastructure now provides the initramfs to Linux as a Tilera-hypervisor file named "initramfs", rather than "initramfs.cpio.gz", as before. (This makes it reasonable to use other compression techniques than gzip on the file without having to worry about the name causing confusion.) Adapt to use the new name, but also fall back to checking for the old name.
Cc'ing to stable so that older kernels will remain compatible with newer Tilera boot infrastructure.
--- arch/tile/kernel/setup.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-)
arch/tile/kernel/setup.c +12 -13
@@ -1004,15 +1004,8 @@ void __cpuinit setup_cpu(int boot)#ifdef CONFIG_BLK_DEV_INITRD -/* -* Note that the kernel can potentially support other compression -* techniques than gz, though we don't do so by default. If we ever -* decide to do so we can either look for other filename extensions, -* or just allow a file with this name to be compressed with an -* arbitrary compressor (somewhat counterintuitively). -*/ static int __initdata set_initramfs_file; -static char __initdata initramfs_file[128 ] ="initramfs.cpio.gz" ; +static char __initdata initramfs_file[128 ] ="initramfs" ;static int __init setup_initramfs_file (char *str) {
@@ -1026,9 +1019,9 @@ static int __init setup_initramfs_file(cearly_param ("initramfs_file" , setup_initramfs_file);/* -* We look for an "initramfs.cpio.gz" file in the hvfs. -* If there is one, we allocate some memory for it and it will be -* unpacked to the initramfs. +* We look for a file called "initramfs" in the hvfs. If there is one, we +* allocate some memory for it and it will be unpacked to the initramfs. +* If it's compressed, the initd code will uncompress it first. */ static void __init load_hv_initrd (void ) {
@@ -1038,10 +1031,16 @@ static void __init load_hv_initrd(void) fd =hv_fs_findfile ((HV_VirtAddr ) initramfs_file);if (fd ==HV_ENOENT ) { -if (set_initramfs_file) +if (set_initramfs_file) {pr_warning ("No such hvfs initramfs file '%s'\n" , initramfs_file); -return ; +return ; + }else { +/* Try old backwards-compatible name. */ + fd =hv_fs_findfile ((HV_VirtAddr )"initramfs.cpio.gz" ); +if (fd ==HV_ENOENT ) +return ; + } }BUG_ON (fd <0 ); stat =hv_fs_fstat (fd);
Greg Kroah-Hartman
maintainerPATCH 3/124 Bluetooth: Fix not closing SCO sockets in the BT_CONNECT2 state
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vinicius Costa Gomes <[email protected]>
commit eb20ff9c91ddcb2d55c1849a87d3db85af5e88a9 upstream.
With deferred setup for SCO, it is possible that userspace closes the socket when it is in the BT_CONNECT2 state, after the Connect Request is received but before the Accept Synchonous Connection is sent.
If this happens the following crash was observed, when the connection is terminated:
[ +0.000003] hci_sync_conn_complete_evt: hci0 status 0x10 [ +0.000005] sco_connect_cfm: hcon ffff88003d1bd800 bdaddr 40:98:4e:32:d7:39 status 16 [ +0.000003] sco_conn_del: hcon ffff88003d1bd800 conn ffff88003cc8e300, err 110 [ +0.000015] BUG: unable to handle kernel NULL pointer dereference at 0000000000000199 [ +0.000906] IP: [<ffffffff810620dd>] __lock_acquire+0xed/0xe82 [ +0.000000] PGD 3d21f067 PUD 3d291067 PMD 0 [ +0.000000] Oops: 0002 [#1] SMP [ +0.000000] Modules linked in: rfcomm bnep btusb bluetooth [ +0.000000] CPU 0 [ +0.000000] Pid: 1481, comm: kworker/u:2H Not tainted 3.9.0-rc1-25019-gad82cdd #1 Bochs Bochs [ +0.000000] RIP: 0010:[<ffffffff810620dd>] [<ffffffff810620dd>] __lock_acquire+0xed/0xe82 [ +0.000000] RSP: 0018:ffff88003c3c19d8 EFLAGS: 00010002 [ +0.000000] RAX: 0000000000000001 RBX: 0000000000000246 RCX: 0000000000000000 [ +0.000000] RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff88003d1be868 [ +0.000000] RBP: ffff88003c3c1a98 R08: 0000000000000002 R09: 0000000000000000 [ +0.000000] R10: ffff88003d1be868 R11: ffff88003e20b000 R12: 0000000000000002 [ +0.000000] R13: ffff88003aaa8000 R14: 000000000000006e R15: ffff88003d1be850 [ +0.000000] FS: 0000000000000000(0000) GS:ffff88003e200000(0000) knlGS:0000000000000000 [ +0.000000] CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b [ +0.000000] CR2: 0000000000000199 CR3: 000000003c1cb000 CR4: 00000000000006b0 [ +0.000000] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ +0.000000] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 [ +0.000000] Process kworker/u:2H (pid: 1481, threadinfo ffff88003c3c0000, task ffff88003aaa8000) [ +0.000000] Stack: [ +0.000000] ffffffff81b16342 0000000000000000 0000000000000000 ffff88003d1be868 [ +0.000000] ffffffff00000000 00018c0c7863e367 000000003c3c1a28 ffffffff8101efbd [ +0.000000] 0000000000000000 ffff88003e3d2400 ffff88003c3c1a38 ffffffff81007c7a [ +0.000000] Call Trace: [ +0.000000] [<ffffffff8101efbd>] ? kvm_clock_read+0x34/0x3b [ +0.000000] [<ffffffff81007c7a>] ? paravirt_sched_clock+0x9/0xd [ +0.000000] [<ffffffff81007fd4>] ? sched_clock+0x9/0xb [ +0.000000] [<ffffffff8104fd7a>] ? sched_clock_local+0x12/0x75 [ +0.000000] [<ffffffff810632d1>] lock_acquire+0x93/0xb1 [ +0.000000] [<ffffffffa0022339>] ? spin_lock+0x9/0xb [bluetooth] [ +0.000000] [<ffffffff8105f3d8>] ? lock_release_holdtime.part.22+0x4e/0x55 [ +0.000000] [<ffffffff814f6038>] _raw_spin_lock+0x40/0x74 [ +0.000000] [<ffffffffa0022339>] ? spin_lock+0x9/0xb [bluetooth] [ +0.000000] [<ffffffff814f6936>] ? _raw_spin_unlock+0x23/0x36 [ +0.000000] [<ffffffffa0022339>] spin_lock+0x9/0xb [bluetooth] [ +0.000000] [<ffffffffa00230cc>] sco_conn_del+0x76/0xbb [bluetooth] [ +0.000000] [<ffffffffa002391d>] sco_connect_cfm+0x2da/0x2e9 [bluetooth] [ +0.000000] [<ffffffffa000862a>] hci_proto_connect_cfm+0x38/0x65 [bluetooth] [ +0.000000] [<ffffffffa0008d30>] hci_sync_conn_complete_evt.isra.79+0x11a/0x13e [bluetooth] [ +0.000000] [<ffffffffa000cd96>] hci_event_packet+0x153b/0x239d [bluetooth] [ +0.000000] [<ffffffff814f68ff>] ? _raw_spin_unlock_irqrestore+0x48/0x5c [ +0.000000] [<ffffffffa00025f6>] hci_rx_work+0xf3/0x2e3 [bluetooth] [ +0.000000] [<ffffffff8103efed>] process_one_work+0x1dc/0x30b [ +0.000000] [<ffffffff8103ef83>] ? process_one_work+0x172/0x30b [ +0.000000] [<ffffffff8103e07f>] ? spin_lock_irq+0x9/0xb [ +0.000000] [<ffffffff8103fc8d>] worker_thread+0x123/0x1d2 [ +0.000000] [<ffffffff8103fb6a>] ? manage_workers+0x240/0x240 [ +0.000000] [<ffffffff81044211>] kthread+0x9d/0xa5 [ +0.000000] [<ffffffff81044174>] ? __kthread_parkme+0x60/0x60 [ +0.000000] [<ffffffff814f75bc>] ret_from_fork+0x7c/0xb0 [ +0.000000] [<ffffffff81044174>] ? __kthread_parkme+0x60/0x60 [ +0.000000] Code: d7 44 89 8d 50 ff ff ff 4c 89 95 58 ff ff ff e8 44 fc ff ff 44 8b 8d 50 ff ff ff 48 85 c0 4c 8b 95 58 ff ff ff 0f 84 7a 04 00 00 <f0> ff 80 98 01 00 00 83 3d 25 41 a7 00 00 45 8b b5 e8 05 00 00 [ +0.000000] RIP [<ffffffff810620dd>] __lock_acquire+0xed/0xe82 [ +0.000000] RSP <ffff88003c3c19d8> [ +0.000000] CR2: 0000000000000199 [ +0.000000] ---[ end trace e73cd3b52352dd34 ]---
--- net/bluetooth/sco.c | 1 + 1 file changed, 1 insertion(+)
net/bluetooth/sco.c +1 -0
@@ -361,6 +361,7 @@ static void __sco_sock_close(struct socksco_chan_del (sk,ECONNRESET );break ; +case BT_CONNECT2 :case BT_CONNECT :case BT_DISCONN :sco_chan_del (sk,ECONNRESET );
Greg Kroah-Hartman
maintainerPATCH 4/124 Bluetooth: Add support for Dell[QCA 0cf3:0036]
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming Lei <[email protected]>
commit d66629c1325399cf080ba8b2fb086c10e5439cdd upstream.
Add support for the AR9462 chip
T: Bus=03 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#= 3 Spd=12 MxCh= 0 D: Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=0cf3 ProdID=0036 Rev= 0.02 C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA A: FirstIf#= 0 IfCount= 2 Cls=e0(wlcon) Sub=01 Prot=01 I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=81(I) Atr=03(Int.) MxPS= 16 Ivl=1ms E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms E: Ad=02(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 0 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 0 Ivl=1ms I: If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 9 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 9 Ivl=1ms I: If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 17 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 17 Ivl=1ms I: If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 25 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 25 Ivl=1ms I: If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 33 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 33 Ivl=1ms I: If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 49 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 49 Ivl=1ms
--- drivers/bluetooth/ath3k.c | 2 ++ drivers/bluetooth/btusb.c | 1 + 2 files changed, 3 insertions(+)
drivers/bluetooth/ath3k.c +2 -0
@@ -73,6 +73,7 @@ static struct usb_device_id ath3k_table[ { USB_DEVICE(0x03F0, 0x311D) },/* Atheros AR3012 with sflash firmware*/ + { USB_DEVICE(0x0CF3, 0x0036) }, { USB_DEVICE(0x0CF3, 0x3004) }, { USB_DEVICE(0x0CF3, 0x311D) }, { USB_DEVICE(0x13d3, 0x3375) },
@@ -105,6 +106,7 @@ MODULE_DEVICE_TABLE(usb, ath3k_table);static struct usb_device_id ath3k_blist_tbl[] = {/* Atheros AR3012 with sflash firmware*/ + {USB_DEVICE (0x0CF3 ,0x0036 ), .driver_info =BTUSB_ATH3012 }, {USB_DEVICE (0x0cf3 ,0x3004 ), .driver_info =BTUSB_ATH3012 }, {USB_DEVICE (0x0cf3 ,0x311D ), .driver_info =BTUSB_ATH3012 }, {USB_DEVICE (0x13d3 ,0x3375 ), .driver_info =BTUSB_ATH3012 },
drivers/bluetooth/btusb.c +1 -0
@@ -131,6 +131,7 @@ static struct usb_device_id blacklist_ta { USB_DEVICE(0x03f0, 0x311d), .driver_info = BTUSB_IGNORE }, /* Atheros 3012 with sflash firmware */ + { USB_DEVICE(0x0cf3, 0x0036), .driver_info = BTUSB_ATH3012 }, { USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_ATH3012 }, { USB_DEVICE(0x0cf3, 0x311d), .driver_info = BTUSB_ATH3012 }, { USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 },
Greg Kroah-Hartman
maintainerPATCH 5/124 Bluetooth: Add support for Dell[QCA 0cf3:817a]
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming Lei <[email protected]>
commit ebaf5795ef57a70a042ea259448a465024e2821d upstream.
Add support for the AR9462 chip
T: Bus=03 Lev=01 Prnt=01 Port=08 Cnt=01 Dev#= 5 Spd=12 MxCh= 0 D: Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=0cf3 ProdID=817a Rev= 0.02 C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=81(I) Atr=03(Int.) MxPS= 16 Ivl=1ms E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms E: Ad=02(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 0 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 0 Ivl=1ms I: If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 9 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 9 Ivl=1ms I: If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 17 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 17 Ivl=1ms I: If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 25 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 25 Ivl=1ms I: If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 33 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 33 Ivl=1ms I: If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 49 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 49 Ivl=1ms
--- drivers/bluetooth/ath3k.c | 2 ++ drivers/bluetooth/btusb.c | 1 + 2 files changed, 3 insertions(+)
drivers/bluetooth/ath3k.c +2 -0
@@ -76,6 +76,7 @@ static struct usb_device_id ath3k_table[ { USB_DEVICE(0x0CF3, 0x0036) }, { USB_DEVICE(0x0CF3, 0x3004) }, { USB_DEVICE(0x0CF3, 0x311D) }, + { USB_DEVICE(0x0CF3, 0x817a) }, { USB_DEVICE(0x13d3, 0x3375) }, { USB_DEVICE(0x04CA, 0x3005) }, { USB_DEVICE(0x04CA, 0x3006) },
@@ -109,6 +110,7 @@ static struct usb_device_id ath3k_blist_ { USB_DEVICE(0x0CF3, 0x0036), .driver_info = BTUSB_ATH3012 }, { USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_ATH3012 }, { USB_DEVICE(0x0cf3, 0x311D), .driver_info = BTUSB_ATH3012 }, + { USB_DEVICE(0x0CF3, 0x817a), .driver_info = BTUSB_ATH3012 }, { USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 }, { USB_DEVICE(0x04ca, 0x3005), .driver_info = BTUSB_ATH3012 }, { USB_DEVICE(0x04ca, 0x3006), .driver_info = BTUSB_ATH3012 },
drivers/bluetooth/btusb.c +1 -0
@@ -134,6 +134,7 @@ static struct usb_device_id blacklist_ta { USB_DEVICE(0x0cf3, 0x0036), .driver_info = BTUSB_ATH3012 }, { USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_ATH3012 }, { USB_DEVICE(0x0cf3, 0x311d), .driver_info = BTUSB_ATH3012 }, + { USB_DEVICE(0x0cf3, 0x817a), .driver_info = BTUSB_ATH3012 }, { USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 }, { USB_DEVICE(0x04ca, 0x3005), .driver_info = BTUSB_ATH3012 }, { USB_DEVICE(0x04ca, 0x3006), .driver_info = BTUSB_ATH3012 },
Greg Kroah-Hartman
maintainerPATCH 6/124 staging: comedi: s626: fix continuous acquisition
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Abbott <[email protected]>
commit e4317ce877a31dbb9d96375391c1c4ad2210d637 upstream.
For the s626 driver, there is a bug in the handling of asynchronous commands on the AI subdevice when the stop source is TRIG_NONE. The command should run continuously until cancelled, but the interrupt handler stops the command running after the first scan.
The command set-up function s626_ai_cmd() contains this code:
switch (cmd->stop_src) {
case TRIG_COUNT:
/* data arrives as one packet */
devpriv->ai_sample_count = cmd->stop_arg;
devpriv->ai_continous = 0;
break;
case TRIG_NONE:
/* continous acquisition */
devpriv->ai_continous = 1;
devpriv->ai_sample_count = 0;
break;
}The interrupt handler s626_irq_handler() contains this code:
if (!(devpriv->ai_continous))
devpriv->ai_sample_count--;
if (devpriv->ai_sample_count <= 0) {
devpriv->ai_cmd_running = 0;
/* ... */
}So devpriv->ai_sample_count is only decremented for the TRIG_COUNT case, but devpriv->ai_cmd_running is set to 0 (and the command stopped) regardless.
Fix this in s626_ai_cmd() by setting devpriv->ai_sample_count = 1 for the TRIG_NONE case. The interrupt handler will not decrement it so it will remain greater than 0 and the check for stopping the acquisition will fail.
--- drivers/staging/comedi/drivers/s626.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/comedi/drivers/s626.c +1 -1
@@ -1482,7 +1482,7 @@ static int s626_ai_cmd(struct comedi_devcase TRIG_NONE :/* continous acquisition */ devpriv->ai_continous =1 ; - devpriv->ai_sample_count =0 ; + devpriv->ai_sample_count =1 ;break ; }
Greg Kroah-Hartman
maintainerPATCH 7/124 Revert "crypto: talitos - add IPsec ESN support"
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Horia Geanta <[email protected]>
commit 991155bacb91c988c45586525771758ddadd44ce upstream.
This reverts commit e763eb699be723fb41af818118068c6b3afdaf8d.
Current IPsec ESN implementation for authencesn(cbc(aes), hmac(sha)) (separate encryption and integrity algorithms) does not conform to RFC4303.
ICV is generated by hashing the sequence
SPI, SeqNum-High, SeqNum-Low, IV, Payload
instead of
SPI, SeqNum-Low, IV, Payload, SeqNum-High.
--- drivers/crypto/talitos.c | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-)
drivers/crypto/talitos.c +2 -28
@@ -38,7 +38,6 @@#include <linux/spinlock.h> #include <linux/rtnetlink.h> #include <linux/slab.h> -#include <linux/string.h> #include <crypto/algapi.h> #include <crypto/aes.h>
@@ -1974,11 +1973,7 @@ struct talitos_alg_template { };static struct talitos_alg_template driver_algs[] = { -/* -* AEAD algorithms. These use a single-pass ipsec_esp descriptor. -* authencesn(*,*) is also registered, although not present -* explicitly here. -*/ +/* AEAD algorithms. These use a single-pass ipsec_esp descriptor */ { .type =CRYPTO_ALG_TYPE_AEAD , .alg.crypto = { .cra_name ="authenc(hmac(sha1),cbc(aes))" ,
@@ -2820,9 +2815,7 @@ static int talitos_probe(struct platformif (hw_supports (dev, driver_algs[i].desc_hdr_template)) {struct talitos_crypto_alg *t_alg;char *name =NULL ; -bool authenc = false; -authencesn: t_alg =talitos_alg_alloc (dev, &driver_algs[i]);if (IS_ERR (t_alg)) { err =PTR_ERR (t_alg);
@@ -2837,8 +2830,6 @@ authencesn: err =crypto_register_alg ( &t_alg->algt.alg.crypto); name = t_alg->algt.alg.crypto.cra_driver_name; - authenc = authenc ? !authenc : - !(bool )memcmp (name,"authenc" ,7 );break ;case CRYPTO_ALG_TYPE_AHASH : err = crypto_register_ahash(
@@ -2851,25 +2842,8 @@ authencesn:dev_err (dev,"%s alg registration failed\n" , name);kfree (t_alg); - }else { + }else list_add_tail (&t_alg->entry, &priv->alg_list); -if (authenc) { -struct crypto_alg *alg = - &driver_algs[i].alg.crypto; - - name = alg->cra_name; -memmove (name +10 , name +7 , -strlen (name) -7 ); -memcpy (name +7 ,"esn" ,3 ); - - name = alg->cra_driver_name; -memmove (name +10 , name +7 , -strlen (name) -7 ); -memcpy (name +7 ,"esn" ,3 ); - - goto authencesn; - } - } } }if (!list_empty (&priv->alg_list))
Greg Kroah-Hartman
maintainerPATCH 8/124 Revert "crypto: caam - add IPsec ESN support"
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Horia Geanta <[email protected]>
commit 246bbedb9aaf27e2207501d93a869023a439fce5 upstream.
This reverts commit 891104ed008e8646c7860fe5bc70b0aac55dcc6c.
Current IPsec ESN implementation for authencesn(cbc(aes), hmac(sha)) (separate encryption and integrity algorithms) does not conform to RFC4303.
ICV is generated by hashing the sequence
SPI, SeqNum-High, SeqNum-Low, IV, Payload
instead of
SPI, SeqNum-Low, IV, Payload, SeqNum-High.
--- drivers/crypto/caam/caamalg.c | 27 ++------------------------- drivers/crypto/caam/compat.h | 1 - 2 files changed, 2 insertions(+), 26 deletions(-)
drivers/crypto/caam/caamalg.c +2 -25
@@ -1650,11 +1650,7 @@ struct caam_alg_template { };static struct caam_alg_template driver_algs[] = { -/* -* single-pass ipsec_esp descriptor -* authencesn(*,*) is also registered, although not present -* explicitly here. -*/ +/* single-pass ipsec_esp descriptor */ { .name ="authenc(hmac(md5),cbc(aes))" , .driver_name ="authenc-hmac-md5-cbc-aes-caam" ,
@@ -2217,9 +2213,7 @@ static int __init caam_algapi_init(void)for (i =0 ; i <ARRAY_SIZE (driver_algs); i++) {/* TODO: check if h/w supports alg */ struct caam_crypto_alg *t_alg; -bool done = false; -authencesn: t_alg =caam_alg_alloc (ctrldev, &driver_algs[i]);if (IS_ERR (t_alg)) { err =PTR_ERR (t_alg);
@@ -2233,25 +2227,8 @@ authencesn:dev_warn (ctrldev,"%s alg registration failed\n" , t_alg->crypto_alg.cra_driver_name);kfree (t_alg); - }else { + }else list_add_tail (&t_alg->entry, &priv->alg_list); -if (driver_algs[i].type ==CRYPTO_ALG_TYPE_AEAD && - !memcmp (driver_algs[i].name,"authenc" ,7 ) && - !done) { -char *name; - - name = driver_algs[i].name; -memmove (name +10 , name +7 ,strlen (name) -7 ); -memcpy (name +7 ,"esn" ,3 ); - - name = driver_algs[i].driver_name; -memmove (name +10 , name +7 ,strlen (name) -7 ); -memcpy (name +7 ,"esn" ,3 ); - - done = true; - goto authencesn; - } - } }if (!list_empty (&priv->alg_list)) dev_info(ctrldev, "%s algorithms registered in /proc/crypto\n",
drivers/crypto/caam/compat.h +0 -1
@@ -23,7 +23,6 @@#include <linux/types.h> #include <linux/debugfs.h> #include <linux/circ_buf.h> -#include <linux/string.h> #include <net/xfrm.h> #include <crypto/algapi.h>
Greg Kroah-Hartman
maintainerPATCH 9/124 sysfs: fix race between readdir and lseek
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming Lei <[email protected]>
commit 991f76f837bf22c5bb07261cfd86525a0a96650c upstream.
While readdir() is running, lseek() may set filp->f_pos as zero, then may leave filp->private_data pointing to one sysfs_dirent object without holding its reference counter, so the sysfs_dirent object may be used after free in next readdir().
This patch holds inode->i_mutex to avoid the problem since the lock is always held in readdir path.
--- fs/sysfs/dir.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
fs/sysfs/dir.c +12 -1
@@ -1058,10 +1058,21 @@ static int sysfs_readdir(struct file * freturn 0 ; } +static loff_t sysfs_dir_llseek (struct file *file,loff_t offset,int whence) +{ +struct inode *inode = file->f_path.dentry->d_inode; +loff_t ret; + +mutex_lock (&inode->i_mutex); + ret =generic_file_llseek (file, offset, whence); +mutex_unlock (&inode->i_mutex); + +return ret; +}const struct file_operations sysfs_dir_operations = { .read = generic_read_dir, .readdir = sysfs_readdir, .release = sysfs_dir_release, - .llseek = generic_file_llseek, + .llseek = sysfs_dir_llseek, };
Greg Kroah-Hartman
maintainerPATCH 10/124 sysfs: handle failure path correctly for readdir()
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming Lei <[email protected]>
commit e5110f411d2ee35bf8d202ccca2e89c633060dca upstream.
In case of 'if (filp->f_pos == 0 or 1)' of sysfs_readdir(), the failure from filldir() isn't handled, and the reference counter of the sysfs_dirent object pointed by filp->private_data will be released without clearing filp->private_data, so use after free bug will be triggered later.
This patch returns immeadiately under the situation for fixing the bug, and it is reasonable to return from readdir() when filldir() fails.
--- fs/sysfs/dir.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/sysfs/dir.c +4 -0
@@ -1020,6 +1020,8 @@ static int sysfs_readdir(struct file * f ino = parent_sd->s_ino;if (filldir (dirent,"." ,1 , filp->f_pos, ino,DT_DIR ) ==0 ) filp->f_pos++; +else +return 0 ; }if (filp->f_pos ==1 ) {if (parent_sd->s_parent)
@@ -1028,6 +1030,8 @@ static int sysfs_readdir(struct file * f ino = parent_sd->s_ino;if (filldir (dirent,".." ,2 , filp->f_pos, ino,DT_DIR ) ==0 ) filp->f_pos++; +else +return 0 ; }mutex_lock (&sysfs_mutex); for (pos = sysfs_dir_pos(ns, parent_sd, filp->f_pos, pos);
Greg Kroah-Hartman
maintainerPATCH 11/124 can: sja1000: fix define conflict on SH
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Kleine-Budde <[email protected]>
commit f901b6bc404b67d96eca739857c097e022727b71 upstream.
Thias patch fixes a define conflict between the SH architecture and the sja1000 driver:
drivers/net/can/sja1000/sja1000.h:59:0: warning:
"REG_SR" redefined [enabled by default]
arch/sh/include/asm/ptrace_32.h:25:0: note:
this is the location of the previous definition
A SJA1000_ prefix is added to the offending sja1000 define only, to make a minimal patch suited for stable. A later patch will add a SJA1000_ prefix to all defines in sja1000.h.
--- drivers/net/can/sja1000/plx_pci.c | 4 ++-- drivers/net/can/sja1000/sja1000.c | 6 +++--- drivers/net/can/sja1000/sja1000.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/can/sja1000/plx_pci.c +2 -2
@@ -348,7 +348,7 @@ static inline int plx_pci_check_sja1000(*/ if ((priv->read_reg (priv,REG_CR ) ®_CR_BASICCAN_INITIAL_MASK ) ==REG_CR_BASICCAN_INITIAL && - (priv->read_reg (priv,REG_SR ) ==REG_SR_BASICCAN_INITIAL ) && + (priv->read_reg (priv,SJA1000_REG_SR ) ==REG_SR_BASICCAN_INITIAL ) && (priv->read_reg (priv,REG_IR ) ==REG_IR_BASICCAN_INITIAL )) flag =1 ;
@@ -360,7 +360,7 @@ static inline int plx_pci_check_sja1000(* See states on p. 23 of the Datasheet. */ if (priv->read_reg (priv,REG_MOD ) ==REG_MOD_PELICAN_INITIAL && - priv->read_reg (priv,REG_SR ) ==REG_SR_PELICAN_INITIAL && + priv->read_reg (priv,SJA1000_REG_SR ) ==REG_SR_PELICAN_INITIAL && priv->read_reg (priv,REG_IR ) ==REG_IR_PELICAN_INITIAL )return flag;
drivers/net/can/sja1000/sja1000.c +3 -3
@@ -91,7 +91,7 @@ static void sja1000_write_cmdreg(struct*/ spin_lock_irqsave (&priv->cmdreg_lock, flags); priv->write_reg (priv,REG_CMR , val); - priv->read_reg (priv,REG_SR ); + priv->read_reg (priv,SJA1000_REG_SR );spin_unlock_irqrestore (&priv->cmdreg_lock, flags); }
@@ -499,7 +499,7 @@ irqreturn_t sja1000_interrupt(int irq, vwhile ((isrc = priv->read_reg (priv,REG_IR )) && (n <SJA1000_MAX_IRQ )) { n++; - status = priv->read_reg (priv,REG_SR ); + status = priv->read_reg (priv,SJA1000_REG_SR );/* check for absent controller due to hw unplug */ if (status ==0xFF &&sja1000_is_absent (priv))return IRQ_NONE ;
@@ -526,7 +526,7 @@ irqreturn_t sja1000_interrupt(int irq, v/* receive interrupt */ while (status &SR_RBS ) {sja1000_rx (dev); - status = priv->read_reg (priv,REG_SR ); + status = priv->read_reg (priv,SJA1000_REG_SR );/* check for absent controller */ if (status ==0xFF &&sja1000_is_absent (priv))return IRQ_NONE ;
drivers/net/can/sja1000/sja1000.h +1 -1
@@ -56,7 +56,7 @@/* SJA1000 registers - manual section 6.4 (Pelican Mode) */ #define REG_MOD 0x00#define REG_CMR 0x01 -#define REG_SR 0x02 +#define SJA1000_REG_SR 0x02#define REG_IR 0x03#define REG_IER 0x04#define REG_ALC 0x0B
Greg Kroah-Hartman
maintainerPATCH 12/124 ath9k_hw: revert chainmask to user configuration after calibration
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Fietkau <[email protected]>
commit 74632d11a133b5baf6b9d622dd19d2f944d93d94 upstream.
The commit 'ath9k_hw: fix calibration issues on chainmask that don't include chain 0' changed the hardware chainmask to the chip chainmask for the duration of the calibration, but the revert to user configuration in the reset path runs too early.
That causes some issues with limiting the number of antennas (including spurious failure in hardware-generated packets).
Fix this by reverting the chainmask after the essential parts of the calibration that need the workaround, and before NF calibration is run.
--- drivers/net/wireless/ath/ath9k/ar9003_calib.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/wireless/ath/ath9k/ar9003_calib.c +4 -0
@@ -976,6 +976,7 @@ static bool ar9003_hw_init_cal(struct atAR_PHY_CL_TAB_1 , AR_PHY_CL_TAB_2 }; +/* Use chip chainmask only for calibration */ ar9003_hw_set_chain_masks (ah, ah->caps.rx_chainmask, ah->caps.tx_chainmask);if (rtt) {
@@ -1131,6 +1132,9 @@ skip_tx_iqcal:ar9003_hw_rtt_disable (ah); } +/* Revert chainmask to runtime parameters */ +ar9003_hw_set_chain_masks (ah, ah->rxchainmask, ah->txchainmask); +/* Initialize list pointers */ ah->cal_list = ah->cal_list_last = ah->cal_list_curr =NULL ; ah->supp_cals =IQ_MISMATCH_CAL ;
Greg Kroah-Hartman
maintainerPATCH 13/124 ath9k: limit tx path hang check to normal data queues
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Fietkau <[email protected]>
commit 01d4ab96d2e7fceaad204e5a8710ce34e229b8c5 upstream.
The beacon and multicast-buffer queues are managed by the beacon tasklet, and the generic tx path hang check does not help in any way here. Running it on those queues anyway can introduce some race conditions leading to unnecessary chip resets.
--- drivers/net/wireless/ath/ath9k/link.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
drivers/net/wireless/ath/ath9k/link.c +13 -13
@@ -28,21 +28,21 @@ void ath_tx_complete_poll_work(struct woint i;bool needreset = false; -for (i =0 ; i <ATH9K_NUM_TX_QUEUES ; i++) -if (ATH_TXQ_SETUP (sc, i)) { - txq = &sc->tx.txq[i]; -ath_txq_lock (sc, txq); -if (txq->axq_depth) { -if (txq->axq_tx_inprogress) { - needreset = true; -ath_txq_unlock (sc, txq); -break ; - }else { - txq->axq_tx_inprogress = true; - } +for (i =0 ; i <IEEE80211_NUM_ACS ; i++) { + txq = sc->tx.txq_map[i]; + +ath_txq_lock (sc, txq); +if (txq->axq_depth) { +if (txq->axq_tx_inprogress) { + needreset = true; +ath_txq_unlock (sc, txq); +break ; + }else { + txq->axq_tx_inprogress = true; } -ath_txq_unlock_complete (sc, txq); } +ath_txq_unlock_complete (sc, txq); + }if (needreset) { ath_dbg(ath9k_hw_common(sc->sc_ah), RESET,
Greg Kroah-Hartman
maintainerPATCH 14/124 ath9k: avoid queueing hw check work when suspended
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Luis R. Rodriguez" <[email protected]>
commit 7fc0357479eeff4ca808c4d8c09bc7631f576b8d upstream.
The following issue was reported.
WARNING: at net/mac80211/util.c:599 ieee80211_can_queue_work.isra.7+0x32/0x40 [mac80211]() Hardware name: iMac12,1 queueing ieee80211 work while going to suspend Pid: 0, comm: swapper/0 Tainted: PF O 3.8.2-206.fc18.x86_64 #1 Call Trace: Mar 16 09:39:17 Parags-iMac kernel: [ 3993.642992] <IRQ> [<ffffffff8105e61f>] warn_slowpath_common+0x7f/0xc0 [<ffffffffa0581420>] ? ath_start_rx_poll+0x70/0x70 [ath9k] <ffffffff8105e716>] warn_slowpath_fmt+0x46/0x50 [<ffffffffa045b542>] ieee80211_can_queue_work.isra.7+0x32/0x40
Fix this by avoiding to queue the work if our device has already been marked as suspended or stopped.
--- drivers/net/wireless/ath/ath9k/link.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath9k/link.c +2 -1
@@ -170,7 +170,8 @@ void ath_rx_poll(unsigned long data) {struct ath_softc *sc = (struct ath_softc *)data; -ieee80211_queue_work (sc->hw, &sc->hw_check_work); +if (!test_bit (SC_OP_INVALID , &sc->sc_flags)) +ieee80211_queue_work (sc->hw, &sc->hw_check_work); }/*
Greg Kroah-Hartman
maintainerPATCH 15/124 HID: usbhid: quirk for Realtek Multi-card reader
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Boyer <[email protected]>
commit 3d464d9b71ef2f2b40a4bc9dcf06794fd1be9d12 upstream.
This device needs to be added to the quirks list with HID_QUIRK_NO_INIT_REPORTS, otherwise it causes 10 seconds timeout during report initialization.
This fixes Red Hat bugzilla https://bugzilla.redhat.com/show_bug.cgi?id=806587
--- drivers/hid/hid-ids.h | 3 +++ drivers/hid/usbhid/hid-quirks.c | 1 + 2 files changed, 4 insertions(+)
drivers/hid/hid-ids.h +3 -0
@@ -678,6 +678,9 @@#define USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3001 0x3001#define USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3008 0x3008 +#define USB_VENDOR_ID_REALTEK 0x0bda +#define USB_DEVICE_ID_REALTEK_READER 0x0152 +#define USB_VENDOR_ID_ROCCAT 0x1e7d#define USB_DEVICE_ID_ROCCAT_ARVO 0x30d4#define USB_DEVICE_ID_ROCCAT_ISKU 0x319c
drivers/hid/usbhid/hid-quirks.c +1 -0
@@ -80,6 +80,7 @@ static const struct hid_blacklist { { USB_VENDOR_ID_PRODIGE, USB_DEVICE_ID_PRODIGE_CORDLESS, HID_QUIRK_NOGET }, { USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3001, HID_QUIRK_NOGET }, { USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3008, HID_QUIRK_NOGET }, + { USB_VENDOR_ID_REALTEK, USB_DEVICE_ID_REALTEK_READER, HID_QUIRK_NO_INIT_REPORTS }, { USB_VENDOR_ID_SENNHEISER, USB_DEVICE_ID_SENNHEISER_BTD500USB, HID_QUIRK_NOGET }, { USB_VENDOR_ID_SIGMATEL, USB_DEVICE_ID_SIGMATEL_STMP3780, HID_QUIRK_NOGET }, { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET },
Greg Kroah-Hartman
maintainerPATCH 16/124 HID: usbhid: quirk for MSI GX680R led panel
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Boyer <[email protected]>
commit 620ae90ed8ca8b6e40cb9e10279b4f5ef9f0ab81 upstream.
This keyboard backlight device causes a 10 second delay to boot. Add it to the quirk list with HID_QUIRK_NO_INIT_REPORTS.
This fixes Red Hat bugzilla https://bugzilla.redhat.com/show_bug.cgi?id=907221
--- drivers/hid/hid-ids.h | 3 +++ drivers/hid/usbhid/hid-quirks.c | 1 + 2 files changed, 4 insertions(+)
drivers/hid/hid-ids.h +3 -0
@@ -587,6 +587,9 @@#define USB_VENDOR_ID_MONTEREY 0x0566#define USB_DEVICE_ID_GENIUS_KB29E 0x3004 +#define USB_VENDOR_ID_MSI 0x1770 +#define USB_DEVICE_ID_MSI_GX680R_LED_PANEL 0xff00 +#define USB_VENDOR_ID_NATIONAL_SEMICONDUCTOR 0x0400#define USB_DEVICE_ID_N_S_HARMONY 0xc359
drivers/hid/usbhid/hid-quirks.c +1 -0
@@ -73,6 +73,7 @@ static const struct hid_blacklist { { USB_VENDOR_ID_FORMOSA, USB_DEVICE_ID_FORMOSA_IR_RECEIVER, HID_QUIRK_NO_INIT_REPORTS }, { USB_VENDOR_ID_FREESCALE, USB_DEVICE_ID_FREESCALE_MX28, HID_QUIRK_NOGET }, { USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS, HID_QUIRK_NOGET }, + { USB_VENDIR_ID_MSI, USB_DEVICE_ID_MSI_GX680R_LED_PANEL, HID_QUIRK_NO_INIT_REPORTS }, { USB_VENDOR_ID_NOVATEK, USB_DEVICE_ID_NOVATEK_MOUSE, HID_QUIRK_NO_INIT_REPORTS }, { USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN, HID_QUIRK_NO_INIT_REPORTS }, { USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN1, HID_QUIRK_NO_INIT_REPORTS },
Greg Kroah-Hartman
maintainerPATCH 17/124 HID: usbhid: fix build problem
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiri Kosina <[email protected]>
commit 570637dc8eeb2faba06228d497ff40bb019bcc93 upstream.
Fix build problem caused by typo introduced by 620ae90ed8 ("HID: usbhid: quirk for MSI GX680R led panel").
--- drivers/hid/usbhid/hid-quirks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/usbhid/hid-quirks.c +1 -1
@@ -73,7 +73,7 @@ static const struct hid_blacklist { { USB_VENDOR_ID_FORMOSA, USB_DEVICE_ID_FORMOSA_IR_RECEIVER, HID_QUIRK_NO_INIT_REPORTS }, { USB_VENDOR_ID_FREESCALE, USB_DEVICE_ID_FREESCALE_MX28, HID_QUIRK_NOGET }, { USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS, HID_QUIRK_NOGET }, - { USB_VENDIR_ID_MSI, USB_DEVICE_ID_MSI_GX680R_LED_PANEL, HID_QUIRK_NO_INIT_REPORTS }, + { USB_VENDOR_ID_MSI, USB_DEVICE_ID_MSI_GX680R_LED_PANEL, HID_QUIRK_NO_INIT_REPORTS }, { USB_VENDOR_ID_NOVATEK, USB_DEVICE_ID_NOVATEK_MOUSE, HID_QUIRK_NO_INIT_REPORTS }, { USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN, HID_QUIRK_NO_INIT_REPORTS }, { USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN1, HID_QUIRK_NO_INIT_REPORTS },
Greg Kroah-Hartman
maintainerPATCH 18/124 rtlwifi: usb: add missing freeing of skbuff
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jussi Kivilinna <[email protected]>
commit 36ef0b473fbf43d5db23eea4616cc1d18cec245f upstream.
--- drivers/net/wireless/rtlwifi/usb.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/rtlwifi/usb.c +1 -0
@@ -854,6 +854,7 @@ static void _rtl_usb_transmit(struct ieeif (unlikely (!_urb)) {RT_TRACE (rtlpriv,COMP_ERR ,DBG_EMERG ,"Can't allocate urb. Drop skb!\n" ); +kfree_skb (skb);return ; } urb_list = &rtlusb->tx_pending[ep_num];
Greg Kroah-Hartman
maintainerPATCH 19/124 iwlwifi: fix length check in multi-TB HCMD
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Emmanuel Grumbach <[email protected]>
commit cc904c7188c29847817f35e6966fec3014c7479b upstream.
As reported by Ben Hutchings, there was a harmless issue in the checks being done on the lengths of the TBs while building the TFD for a multi-TB host command.
--- drivers/net/wireless/iwlwifi/pcie/tx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/iwlwifi/pcie/tx.c +1 -1
@@ -1242,7 +1242,7 @@ static int iwl_pcie_enqueue_hcmd(structfor (i =0 ; i <IWL_MAX_CMD_TFDS ; i++) {int copy =0 ; -if (!cmd->len) +if (!cmd->len[i])continue ;/* need at least IWL_HCMD_MIN_COPY_SIZE copied */
Greg Kroah-Hartman
maintainerPATCH 20/124 b43: N-PHY: increase initial value of "mind" in RSSI calibration
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafał Miłecki <[email protected]>
commit e67dd874e60529dbd2e8232babb1e23479ba2ffa upstream.
We're using "mind" variable to find the VCM that got the best polling results. For each VCM we calculte "currd" which is compared to the "mind". For PHY rev3+ "currd" gets values around 14k-40k. Looking for a value smaller than 40 makes no sense, so increase the initial value.
This fixes a regression introduced in 3.4 by commit:e0c9a0219a8f542e3946fe972a68aacf8c3f906c
(my BCM4322 performance dropped from 18,4Mb/s to 9,26Mb/s)
--- drivers/net/wireless/b43/phy_n.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/b43/phy_n.c +2 -2
@@ -1615,7 +1615,7 @@ static void b43_nphy_rev3_rssi_cal(struc }for (i =0 ; i <4 ; i +=2 ) {s32 curr; -s32 mind =40 ; +s32 mind =0x100000 ;s32 minpoll =249 ;u8 minvcm =0 ;if (2 * core != i)
@@ -1799,7 +1799,7 @@ static void b43_nphy_rev2_rssi_cal(struc }for (i =0 ; i <4 ; i++) { -s32 mind =40 ; +s32 mind =0x100000 ;u8 minvcm =0 ;s32 minpoll =249 ;s32 curr;
Greg Kroah-Hartman
maintainerPATCH 21/124 b43: A fix for DMA transmission sequence errors
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Iestyn C. Elfick" <[email protected]>
commit b251412db99ccd4495ce372fec7daee27bf06923 upstream.
Intermittently, b43 will report "Out of order TX status report on DMA ring". When this happens, the driver must be reset before communication can resume. The cause of the problem is believed to be an error in the closed-source firmware; however, all versions of the firmware are affected.
This change uses the observation that the expected status is always 2 less than the observed value, and supplies a fake status report to skip one header/data pair.
Not all devices suffer from this problem, but it can occur several times per second under heavy load. As each occurence kills the unmodified driver, this patch makes if possible for the affected devices to function. The patch logs only the first instance of the reset operation to prevent spamming the logs.
--- drivers/net/wireless/b43/dma.c | 65 +++++++++++++++++++++++++++++++++-------- 1 file changed, 53 insertions(+), 12 deletions(-)
drivers/net/wireless/b43/dma.c +53 -12
@@ -1487,8 +1487,12 @@ void b43_dma_handle_txstatus(struct b43_const struct b43_dma_ops *ops;struct b43_dmaring *ring;struct b43_dmadesc_meta *meta; +static const struct b43_txstatus fake;/* filled with 0 */ +const struct b43_txstatus *txstat;int slot, firstused;bool frame_succeed; +int skip; +static u8 err_out1, err_out2; ring =parse_cookie (dev, status->cookie, &slot);if (unlikely (!ring))
@@ -1501,13 +1505,36 @@ void b43_dma_handle_txstatus(struct b43_ firstused = ring->current_slot - ring->used_slots +1 ;if (firstused <0 ) firstused = ring->nr_slots + firstused; + + skip =0 ;if (unlikely (slot != firstused)) {/* This possibly is a firmware bug and will result in -* malfunction, memory leaks and/or stall of DMA functionality. */ -b43dbg (dev->wl,"Out of order TX status report on DMA ring %d. " -"Expected %d, but got %d\n" , - ring->index, firstused, slot); -return ; +* malfunction, memory leaks and/or stall of DMA functionality. +*/ +if (slot ==next_slot (ring,next_slot (ring, firstused))) { +/* If a single header/data pair was missed, skip over +* the first two slots in an attempt to recover. +*/ + slot = firstused; + skip =2 ; +if (!err_out1) { +/* Report the error once. */ +b43dbg (dev->wl, +"Skip on DMA ring %d slot %d.\n" , + ring->index, slot); + err_out1 =1 ; + } + }else { +/* More than a single header/data pair were missed. +* Report this error once. +*/ +if (!err_out2) +b43dbg (dev->wl, +"Out of order TX status report on DMA ring %d. Expected %d, but got %d\n" , + ring->index, firstused, slot); + err_out2 =1 ; +return ; + } } ops = ring->ops;
@@ -1522,11 +1549,13 @@ void b43_dma_handle_txstatus(struct b43_ slot, firstused, ring->index);break ; } +if (meta->skb) {struct b43_private_tx_info *priv_info = -b43_get_priv_tx_info (IEEE80211_SKB_CB (meta->skb)); +b43_get_priv_tx_info (IEEE80211_SKB_CB (meta->skb)); -unmap_descbuffer (ring, meta->dmaaddr, meta->skb->len,1 ); +unmap_descbuffer (ring, meta->dmaaddr, + meta->skb->len,1 );kfree (priv_info->bouncebuffer); priv_info->bouncebuffer =NULL ; }else {
@@ -1538,8 +1567,9 @@ void b43_dma_handle_txstatus(struct b43_struct ieee80211_tx_info *info;if (unlikely (!meta->skb)) { -/* This is a scatter-gather fragment of a frame, so -* the skb pointer must not be NULL. */ +/* This is a scatter-gather fragment of a frame, +* so the skb pointer must not be NULL. +*/ b43dbg (dev->wl,"TX status unexpected NULL skb " "at slot %d (first=%d) on ring %d\n" , slot, firstused, ring->index);
@@ -1550,9 +1580,18 @@ void b43_dma_handle_txstatus(struct b43_/* * Call back to inform the ieee80211 subsystem about -* the status of the transmission. +* the status of the transmission. When skipping over +* a missed TX status report, use a status structure +* filled with zeros to indicate that the frame was not +* sent (frame_count 0) and not acknowledged */ - frame_succeed =b43_fill_txstatus_report (dev, info, status); +if (unlikely (skip)) + txstat = &fake; +else + txstat = status; + + frame_succeed =b43_fill_txstatus_report (dev, info, + txstat);#ifdef CONFIG_B43_DEBUG if (frame_succeed) ring->nr_succeed_tx_packets++;
@@ -1580,12 +1619,14 @@ void b43_dma_handle_txstatus(struct b43_/* Everything unmapped and free'd. So it's not used anymore. */ ring->used_slots--; -if (meta->is_last_fragment) { +if (meta->is_last_fragment && !skip) {/* This is the last scatter-gather * fragment of the frame. We are done. */ break ; } slot =next_slot (ring, slot); +if (skip >0 ) + --skip; }if (ring->stopped) {B43_WARN_ON (free_slots (ring) <TX_SLOTS_PER_FRAME );
Greg Kroah-Hartman
maintainerPATCH 22/124 b43: N-PHY: use more bits for offset in RSSI calibration
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafał Miłecki <[email protected]>
commit 2e1253d640eb7f8707d2591c93097c1e9f9c71d5 upstream.
When calculating "offset" for final RSSI calibration we're using numbers bigger than s8 can hold. We have for example:
offset[j] = 232 - poll_results[j];
formula. If poll_results[j] is small enough (it usually is) we treat number's bit as a sign bit. For example 232 - 1 becomes:0xE8 - 0x1 = 0xE7, which is not 231 but -25.
This code was introduced in e0c9a0219a8f542e3946fe972a68aacf8c3f906c and caused stability regression on some cards, for ex. BCM4322.
--- drivers/net/wireless/b43/phy_n.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/b43/phy_n.c +2 -2
@@ -1564,7 +1564,7 @@ static void b43_nphy_rev3_rssi_cal(strucu16 clip_off[2 ] = {0xFFFF ,0xFFFF };u8 vcm_final =0 ; -s8 offset[4 ]; +s32 offset[4 ];s32 results[8 ][4 ] = { };s32 results_min[4 ] = { };s32 poll_results[4 ] = { };
@@ -1732,7 +1732,7 @@ static void b43_nphy_rev2_rssi_cal(strucu8 regs_save_radio[2 ];u16 regs_save_phy[2 ]; -s8 offset[4 ]; +s32 offset[4 ];u8 core;u8 rail;
Greg Kroah-Hartman
maintainerPATCH 23/124 tg3: fix length overflow in VPD firmware parsing
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
commit 715230a44310a8cf66fbfb5a46f9a62a9b2de424 upstream.
Commit 184b89044fb6e2a74611dafa69b1dce0d98612c6 ("tg3: Use VPD fw version when present") introduced VPD parsing that contained a potential length overflow.
Limit the hardware's reported firmware string length (max 255 bytes) to stay inside the driver's firmware string length (32 bytes). On overflow, truncate the formatted firmware string instead of potentially overwriting portions of the tg3 struct.
http://cansecwest.com/slides/2013/PrivateCore%20CSW%202013.pdf
--- drivers/net/ethernet/broadcom/tg3.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/tg3.c +5 -2
@@ -14403,8 +14403,11 @@ static void tg3_read_vpd(struct tg3 *tp)if (j + len > block_end) goto partno; -memcpy (tp->fw_ver, &vpd_data[j], len); -strncat (tp->fw_ver," bc " , vpdlen - len -1 ); +if (len >=sizeof (tp->fw_ver)) + len =sizeof (tp->fw_ver) -1 ; +memset (tp->fw_ver,0 ,sizeof (tp->fw_ver)); +snprintf (tp->fw_ver,sizeof (tp->fw_ver),"%.*s bc " , len, + &vpd_data[j]); } partno:
Greg Kroah-Hartman
maintainerPATCH 24/124 mac80211: always synchronize_net() during station removal
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
commit 27a737ff7cb062fb9cbceba9b44d60aa74862bfa upstream.
If there are keys left during station removal, then a synchronize_net() will be done (for each key, I have a patch to address this for 3.10), otherwise it won't be done at all which causes issues because the station could be used for TX while it's being removed from the driver -- that might confuse the driver.
Fix this by always doing synchronize_net() if no key was present any more.
--- net/mac80211/sta_info.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
net/mac80211/sta_info.c +10 -2
@@ -756,6 +756,7 @@ int __must_check __sta_info_destroy(strustruct ieee80211_local *local;struct ieee80211_sub_if_data *sdata;int ret, i; +bool have_key = false;might_sleep ();
@@ -783,12 +784,19 @@ int __must_check __sta_info_destroy(strulist_del_rcu (&sta->list);mutex_lock (&local->key_mtx); -for (i =0 ; i <NUM_DEFAULT_KEYS ; i++) +for (i =0 ; i <NUM_DEFAULT_KEYS ; i++) {__ieee80211_key_free (key_mtx_dereference (local, sta->gtk[i])); -if (sta->ptk) + have_key = true; + } +if (sta->ptk) {__ieee80211_key_free (key_mtx_dereference (local, sta->ptk)); + have_key = true; + }mutex_unlock (&local->key_mtx); +if (!have_key) +synchronize_net (); + sta->dead = true; local->num_sta--;
Greg Kroah-Hartman
maintainerPATCH 25/124 iommu/amd: Make sure dma_ops are set for hotplug devices
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joerg Roedel <[email protected]>
commit c2a2876e863356b092967ea62bebdb4dd663af80 upstream.
There is a bug introduced with commit 27c2127 that causes devices which are hot unplugged and then hot-replugged to not have per-device dma_ops set. This causes these devices to not function correctly. Fixed with this patch.
--- drivers/iommu/amd_iommu.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)
drivers/iommu/amd_iommu.c +9 -11
@@ -2466,18 +2466,16 @@ static int device_change_notifier(struct/* allocate a protection domain if a device is added */ dma_domain =find_protection_domain (devid); -if (dma_domain) - goto out; - dma_domain =dma_ops_domain_alloc (); -if (!dma_domain) - goto out; - dma_domain->target_dev = devid; +if (!dma_domain) { + dma_domain =dma_ops_domain_alloc (); +if (!dma_domain) + goto out; + dma_domain->target_dev = devid; -spin_lock_irqsave (&iommu_pd_list_lock, flags); -list_add_tail (&dma_domain->list, &iommu_pd_list); -spin_unlock_irqrestore (&iommu_pd_list_lock, flags); - - dev_data =get_dev_data (dev); +spin_lock_irqsave (&iommu_pd_list_lock, flags); +list_add_tail (&dma_domain->list, &iommu_pd_list); +spin_unlock_irqrestore (&iommu_pd_list_lock, flags); + } dev->archdata.dma_ops = &amd_iommu_dma_ops;
Greg Kroah-Hartman
maintainerPATCH 26/124 xen-pciback: notify hypervisor about devices intended to be assigned to guests
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Beulich <[email protected]>
commit 909b3fdb0dd4f3db07b2d75425a00a2adb551383 upstream.
For MSI-X capable devices the hypervisor wants to write protect the MSI-X table and PBA, yet it can't assume that resources have been assigned to their final values at device enumeration time. Thus have pciback do that notification, as having the device controlled by it is a prerequisite to assigning the device to guests anyway.
This is the kernel part of hypervisor side commit 4245d33 ("x86/MSI:
add mechanism to fully protect MSI-X table from PV guest accesses") on the master branch of git://xenbits.xen.org/xen.git.
--- arch/x86/include/asm/xen/hypercall.h | 4 +- drivers/xen/fallback.c | 3 + drivers/xen/xen-pciback/pci_stub.c | 59 ++++++++++++++++++++++++++--------- include/xen/interface/physdev.h | 6 +++ 4 files changed, 54 insertions(+), 18 deletions(-)
arch/x86/include/asm/xen/hypercall.h +2 -2
@@ -382,14 +382,14 @@ HYPERVISOR_console_io(int cmd, int countreturn _hypercall3 (int, console_io, cmd, count, str); } -extern int __must_check HYPERVISOR_physdev_op_compat (int ,void *); +extern int __must_check xen_physdev_op_compat (int ,void *);static inline int HYPERVISOR_physdev_op (int cmd,void *arg) {int rc =_hypercall2 (int, physdev_op, cmd, arg);if (unlikely (rc == -ENOSYS )) - rc =HYPERVISOR_physdev_op_compat (cmd, arg); + rc =xen_physdev_op_compat (cmd, arg);return rc; }
drivers/xen/fallback.c +2 -1
@@ -44,7 +44,7 @@ int xen_event_channel_op_compat(int cmd, }EXPORT_SYMBOL_GPL (xen_event_channel_op_compat); -int HYPERVISOR_physdev_op_compat (int cmd,void *arg) +int xen_physdev_op_compat (int cmd,void *arg) {struct physdev_op op;int rc;
@@ -78,3 +78,4 @@ int HYPERVISOR_physdev_op_compat(int cmdreturn rc; } +EXPORT_SYMBOL_GPL (xen_physdev_op_compat);
drivers/xen/xen-pciback/pci_stub.c +44 -15
93 lines not on this page · raw message
include/xen/interface/physdev.h +6 -0
@@ -251,6 +251,12 @@ struct physdev_pci_device_add {#define PHYSDEVOP_pci_device_remove 26#define PHYSDEVOP_restore_msi_ext 27 +/* +* Dom0 should use these two to announce MMIO resources assigned to +* MSI-X capable devices won't (prepare) or may (release) change. +*/ +#define PHYSDEVOP_prepare_msix 30 +#define PHYSDEVOP_release_msix 31struct physdev_pci_device {/* IN */ uint16_t seg;
Greg Kroah-Hartman
maintainerPATCH 27/124 xen/blkback: correctly respond to unknown, non-native requests
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Vrabel <[email protected]>
commit 0e367ae46503cfe7791460c8ba8434a5d60b2bd5 upstream.
If the frontend is using a non-native protocol (e.g., a 64-bit frontend with a 32-bit backend) and it sent an unrecognized request, the request was not translated and the response would have the incorrect ID. This may cause the frontend driver to behave incorrectly or crash.
Since the ID field in the request is always in the same place, regardless of the request type we can get the correct ID and make a valid response (which will report BLKIF_RSP_EOPNOTSUPP).
This bug affected 64-bit SLES 11 guests when using a 32-bit backend. This guest does a BLKIF_OP_RESERVED_1 (BLKIF_OP_PACKET in the SLES source) and would crash in blkif_int() as the ID in the response would be invalid.
--- drivers/block/xen-blkback/blkback.c | 31 +++++++++++++++++++++++++++---- drivers/block/xen-blkback/common.h | 25 +++++++++++++++++++++++++ include/xen/interface/io/blkif.h | 10 ++++++++++ 3 files changed, 62 insertions(+), 4 deletions(-)
drivers/block/xen-blkback/blkback.c +27 -4
@@ -679,6 +679,16 @@ static int dispatch_discard_io(struct xereturn err; } +static int dispatch_other_io (struct xen_blkif *blkif, +struct blkif_request *req, +struct pending_req *pending_req) +{ +free_req (pending_req); +make_response (blkif, req->u.other.id, req->operation, +BLKIF_RSP_EOPNOTSUPP ); +return -EIO ; +} +static void xen_blk_drain_io (struct xen_blkif *blkif) {atomic_set (&blkif->drain,1 );
@@ -800,17 +810,30 @@ __do_block_io_op(struct xen_blkif *blkif/* Apply all sanity checks to /private copy/ of request. */ barrier (); -if (unlikely (req.operation ==BLKIF_OP_DISCARD )) { + +switch (req.operation) { +case BLKIF_OP_READ : +case BLKIF_OP_WRITE : +case BLKIF_OP_WRITE_BARRIER : +case BLKIF_OP_FLUSH_DISKCACHE : +if (dispatch_rw_block_io (blkif, &req, pending_req)) + goto done; +break ; +case BLKIF_OP_DISCARD :free_req (pending_req);if (dispatch_discard_io (blkif, &req)) -break ; - }else if (dispatch_rw_block_io (blkif, &req, pending_req)) + goto done;break ; +default : +if (dispatch_other_io (blkif, &req, pending_req)) + goto done; +break ; + }/* Yield point for this unbounded loop. */ cond_resched (); } - +done:return more_to_do; }
drivers/block/xen-blkback/common.h +25 -0
@@ -77,11 +77,18 @@ struct blkif_x86_32_request_discard {uint64_t nr_sectors; } __attribute__((__packed__)); +struct blkif_x86_32_request_other { +uint8_t _pad1; +blkif_vdev_t _pad2; +uint64_t id;/* private guest value, echoed in resp */ +} __attribute__((__packed__ )); +struct blkif_x86_32_request {uint8_t operation;/* BLKIF_OP_??? */ union {struct blkif_x86_32_request_rw rw;struct blkif_x86_32_request_discard discard; +struct blkif_x86_32_request_other other; } u; } __attribute__((__packed__ ));
@@ -113,11 +120,19 @@ struct blkif_x86_64_request_discard {uint64_t nr_sectors; } __attribute__((__packed__)); +struct blkif_x86_64_request_other { +uint8_t _pad1; +blkif_vdev_t _pad2; +uint32_t _pad3;/* offsetof(blkif_..,u.discard.id)==8 */ +uint64_t id;/* private guest value, echoed in resp */ +} __attribute__((__packed__ )); +struct blkif_x86_64_request {uint8_t operation;/* BLKIF_OP_??? */ union {struct blkif_x86_64_request_rw rw;struct blkif_x86_64_request_discard discard; +struct blkif_x86_64_request_other other; } u; } __attribute__((__packed__ ));
@@ -278,6 +293,11 @@ static inline void blkif_get_x86_32_req( dst->u.discard.nr_sectors = src->u.discard.nr_sectors;break ;default : +/* +* Don't know how to translate this op. Only get the +* ID so failure can be reported to the frontend. +*/ + dst->u.other.id = src->u.other.id;break ; } }
@@ -309,6 +329,11 @@ static inline void blkif_get_x86_64_req( dst->u.discard.nr_sectors = src->u.discard.nr_sectors;break ;default : +/* +* Don't know how to translate this op. Only get the +* ID so failure can be reported to the frontend. +*/ + dst->u.other.id = src->u.other.id;break ; } }
include/xen/interface/io/blkif.h +10 -0
@@ -138,11 +138,21 @@ struct blkif_request_discard {uint8_t _pad3; } __attribute__((__packed__)); +struct blkif_request_other { +uint8_t _pad1; +blkif_vdev_t _pad2;/* only for read/write requests */ +#ifdef CONFIG_X86_64 +uint32_t _pad3;/* offsetof(blkif_req..,u.other.id)==8*/ +#endif +uint64_t id;/* private guest value, echoed in resp */ +} __attribute__((__packed__ )); +struct blkif_request {uint8_t operation;/* BLKIF_OP_??? */ union {struct blkif_request_rw rw;struct blkif_request_discard discard; +struct blkif_request_other other; } u; } __attribute__((__packed__ ));
Greg Kroah-Hartman
maintainerPATCH 28/124 xen-blkback: fix dispatch_rw_block_io() error path
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Beulich <[email protected]>
commit 0e5e098ac22dae38f957e951b70d3cf73beff0f7 upstream.
Commit 7708992 ("xen/blkback: Seperate the bio allocation and the bio submission") consolidated the pendcnt updates to just a single write, neglecting the fact that the error path relied on it getting set to 1 up front (such that the decrement in __end_block_io_op() would actually drop the count to zero, triggering the necessary cleanup actions).
Also remove a misleading and a stale (after said commit) comment.
--- drivers/block/xen-blkback/blkback.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/block/xen-blkback/blkback.c +1 -6
@@ -1001,13 +1001,7 @@ static int dispatch_rw_block_io(struct x bio->bi_end_io = end_block_io_op; } -/* -* We set it one so that the last submit_bio does not have to call -* atomic_inc. -*/ atomic_set (&pending_req->pendcnt, nbio); - -/* Get a reference count for the disk queue and start sending I/O */ blk_start_plug (&plug);for (i =0 ; i < nbio; i++)
@@ -1035,6 +1029,7 @@ static int dispatch_rw_block_io(struct x fail_put_bio:for (i =0 ; i < nbio; i++)bio_put (biolist[i]); +atomic_set (&pending_req->pendcnt,1 );__end_block_io_op (pending_req, -EINVAL );msleep (1 );/* back off a bit */ return -EIO ;
Greg Kroah-Hartman
maintainerPATCH 29/124 xen-blkfront: switch from llist to list
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Roger Pau Monne <[email protected]>
commit 155b7edb51430a280f86c1e21b7be308b0d219d4 upstream.
The git commit f84adf4921ae3115502f44ff467b04bf2f88cf04 (xen-blkfront: drop the use of llist_for_each_entry_safe)
was a stop-gate to fix a GCC4.1 bug. The appropiate way is to actually use an list instead of using an llist.
As such this patch replaces the usage of llist with an list.
Since we always manipulate the list while holding the io_lock, there's no need for additional locking (llist used previously is safe to use concurrently without additional locking).
--- drivers/block/xen-blkfront.c | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-)
drivers/block/xen-blkfront.c +18 -23
@@ -44,7 +44,7 @@#include <linux/mutex.h> #include <linux/scatterlist.h> #include <linux/bitmap.h> -#include <linux/llist.h> +#include <linux/list.h> #include <xen/xen.h> #include <xen/xenbus.h>
@@ -68,7 +68,7 @@ enum blkif_state {struct grant {grant_ref_t gref;unsigned long pfn; -struct llist_node node; +struct list_head node; };struct blk_shadow {
@@ -105,7 +105,7 @@ struct blkfront_infostruct work_struct work;struct gnttab_free_callback callback;struct blk_shadow shadow[BLK_RING_SIZE ]; -struct llist_head persistent_gnts; +struct list_head persistent_gnts;unsigned int persistent_gnts_c;unsigned long shadow_free;unsigned int feature_flush;
@@ -371,10 +371,11 @@ static int blkif_queue_request(struct re lsect = fsect + (sg->length >>9 ) -1 ;if (info->persistent_gnts_c) { -BUG_ON (llist_empty (&info->persistent_gnts)); - gnt_list_entry =llist_entry ( -llist_del_first (&info->persistent_gnts), - struct grant, node); +BUG_ON (list_empty (&info->persistent_gnts)); + gnt_list_entry =list_first_entry ( + &info->persistent_gnts, + struct grant, node); +list_del (&gnt_list_entry->node); ref = gnt_list_entry->gref; buffer_mfn =pfn_to_mfn (gnt_list_entry->pfn);
@@ -790,9 +791,8 @@ static void blkif_restart_queue(struct wstatic void blkif_free (struct blkfront_info *info,int suspend) { -struct llist_node *all_gnts; -struct grant *persistent_gnt, *tmp; -struct llist_node *n; +struct grant *persistent_gnt; +struct grant *n;/* Prevent new requests being issued until we fix things up. */ spin_lock_irq (&info->io_lock);
@@ -804,20 +804,15 @@ static void blkif_free(struct blkfront_i/* Remove all persistent grants */ if (info->persistent_gnts_c) { - all_gnts =llist_del_all (&info->persistent_gnts); - persistent_gnt =llist_entry (all_gnts,typeof (*(persistent_gnt)), node); -while (persistent_gnt) { +list_for_each_entry_safe (persistent_gnt, n, + &info->persistent_gnts, node) { +list_del (&persistent_gnt->node);gnttab_end_foreign_access (persistent_gnt->gref,0 ,0UL );__free_page (pfn_to_page (persistent_gnt->pfn)); - tmp = persistent_gnt; - n = persistent_gnt->node.next; -if (n) - persistent_gnt =llist_entry (n,typeof (*(persistent_gnt)), node); -else - persistent_gnt =NULL ; -kfree (tmp); +kfree (persistent_gnt); + info->persistent_gnts_c--; } - info->persistent_gnts_c =0 ; +BUG_ON (info->persistent_gnts_c !=0 ); }/* No more gnttab callback work. */
@@ -875,7 +870,7 @@ static void blkif_completion(struct blk_ }/* Add the persistent grant into the list of free grants */ for (i =0 ; i < s->req.u.rw.nr_segments; i++) { -llist_add (&s->grants_used[i]->node, &info->persistent_gnts); +list_add (&s->grants_used[i]->node, &info->persistent_gnts); info->persistent_gnts_c++; } }
@@ -1171,7 +1166,7 @@ static int blkfront_probe(struct xenbus_spin_lock_init (&info->io_lock); info->xbdev = dev; info->vdevice = vdevice; -init_llist_head (&info->persistent_gnts); +INIT_LIST_HEAD (&info->persistent_gnts); info->persistent_gnts_c =0 ; info->connected =BLKIF_STATE_DISCONNECTED ;INIT_WORK (&info->work, blkif_restart_queue);
Greg Kroah-Hartman
maintainerPATCH 30/124 tty: atmel_serial_probe(): index of atmel_ports[] fix
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pawel Wieczorkiewicz <[email protected]>
commit 503bded92da283b2f31d87e054c4c6d30c3c2340 upstream.
Index of atmel_ports[ATMEL_MAX_UART] should be smaller than ATMEL_MAX_UART.
--- drivers/tty/serial/atmel_serial.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/tty/serial/atmel_serial.c +5 -6
@@ -158,7 +158,7 @@ struct atmel_uart_port { };static struct atmel_uart_port atmel_ports[ATMEL_MAX_UART ]; -static unsigned long atmel_ports_in_use; +static DECLARE_BITMAP(atmel_ports_in_use, ATMEL_MAX_UART);#ifdef SUPPORT_SYSRQ static struct console atmel_console;
@@ -1768,15 +1768,14 @@ static int atmel_serial_probe(struct plaif (ret <0 )/* port id not found in platform data nor device-tree aliases: * auto-enumerate it */ - ret =find_first_zero_bit (&atmel_ports_in_use, -sizeof (atmel_ports_in_use)); + ret =find_first_zero_bit (atmel_ports_in_use,ATMEL_MAX_UART ); -if (ret >ATMEL_MAX_UART ) { +if (ret >=ATMEL_MAX_UART ) { ret = -ENODEV ; goto err; } -if (test_and_set_bit (ret, &atmel_ports_in_use)) { +if (test_and_set_bit (ret, atmel_ports_in_use)) {/* port already in use */ ret = -EBUSY ; goto err;
@@ -1856,7 +1855,7 @@ static int atmel_serial_remove(struct pl/* "port" is allocated statically, so we shouldn't free it */ -clear_bit (port->line, &atmel_ports_in_use); +clear_bit (port->line, atmel_ports_in_use);clk_put (atmel_port->clk);
Greg Kroah-Hartman
maintainerPATCH 31/124 usb: ftdi_sio: Add support for Mitsubishi FX-USB-AW/-BD
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konstantin Holoborodko <[email protected]>
commit 482b0b5d82bd916cc0c55a2abf65bdc69023b843 upstream.
It enhances the driver for FTDI-based USB serial adapters to recognize Mitsubishi Electric Corp. USB/RS422 Converters as FT232BM chips and support them.
https://search.meau.com/?q=FX-USB-AW
--- drivers/usb/serial/ftdi_sio.c | 1 + drivers/usb/serial/ftdi_sio_ids.h | 7 +++++++ 2 files changed, 8 insertions(+)
drivers/usb/serial/ftdi_sio.c +1 -0
@@ -642,6 +642,7 @@ static struct usb_device_id id_table_com { USB_DEVICE(FTDI_VID, FTDI_RM_CANVIEW_PID) }, { USB_DEVICE(ACTON_VID, ACTON_SPECTRAPRO_PID) }, { USB_DEVICE(CONTEC_VID, CONTEC_COM1USBH_PID) }, + { USB_DEVICE(MITSUBISHI_VID, MITSUBISHI_FXUSB_PID) }, { USB_DEVICE(BANDB_VID, BANDB_USOTL4_PID) }, { USB_DEVICE(BANDB_VID, BANDB_USTL4_PID) }, { USB_DEVICE(BANDB_VID, BANDB_USO9ML2_PID) },
drivers/usb/serial/ftdi_sio_ids.h +7 -0
@@ -584,6 +584,13 @@#define CONTEC_COM1USBH_PID 0x8311/* COM-1(USB)H */ /* +* Mitsubishi Electric Corp. (http://www.meau.com) +* Submitted by Konstantin Holoborodko +*/ +#define MITSUBISHI_VID 0x06D3 +#define MITSUBISHI_FXUSB_PID 0x0284/* USB/RS422 converters: FX-USB-AW/-BD */ + +/* * Definitions for B&B Electronics products. */ #define BANDB_VID 0x0856/* B&B Electronics Vendor ID */
Greg Kroah-Hartman
maintainerPATCH 32/124 vt: synchronize_rcu() under spinlock is not nice...
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit e8cd81693bbbb15db57d3c9aa7dd90eda4842874 upstream.
vcs_poll_data_free() calls unregister_vt_notifier(), which calls atomic_notifier_chain_unregister(), which calls synchronize_rcu(). Do it *after* we'd dropped ->f_lock.
--- drivers/tty/vt/vc_screen.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/tty/vt/vc_screen.c +4 -2
@@ -93,7 +93,7 @@ vcs_poll_data_free(struct vcs_poll_datastatic struct vcs_poll_data *vcs_poll_data_get (struct file *file) { -struct vcs_poll_data *poll = file->private_data; +struct vcs_poll_data *poll = file->private_data, *kill =NULL ;if (poll)return poll;
@@ -122,10 +122,12 @@ vcs_poll_data_get(struct file *file) file->private_data = poll; }else {/* someone else raced ahead of us */ -vcs_poll_data_free (poll); + kill = poll; poll = file->private_data; }spin_unlock (&file->f_lock); +if (kill) +vcs_poll_data_free (kill);return poll; }
Greg Kroah-Hartman
maintainerPATCH 33/124 mwifiex: fix race when queuing commands
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amitkumar Karwar <[email protected]>
commit 00d7ea11ff0783e24fe70778f3141270b561aaa1 upstream.
Running the following script repeatedly on XO-4 with SD8787 produces command timeout and system lockup.
insmod mwifiex_sdio.ko
sleep 1
ifconfig eth0 up
iwlist eth0 scan &
sleep 0.5
rmmod mwifiex_sdio
mwifiex_send_cmd_async() is called for sync as well as async commands. (mwifiex_send_cmd_sync() internally calls it for sync command.)
"adapter->cmd_queued" gets filled inside mwifiex_send_cmd_async() routine for both types of commands. But it is used only for sync commands in mwifiex_wait_queue_complete(). This could lead to a race when two threads try to queue a sync command with another sync/async command simultaneously.
Get rid of global variable and pass command node as a parameter to mwifiex_wait_queue_complete() to fix the problem.
--- drivers/net/wireless/mwifiex/cmdevt.c | 5 ++--- drivers/net/wireless/mwifiex/main.h | 4 ++-- drivers/net/wireless/mwifiex/scan.c | 8 ++++---- drivers/net/wireless/mwifiex/sta_ioctl.c | 10 ++-------- 4 files changed, 10 insertions(+), 17 deletions(-)
drivers/net/wireless/mwifiex/cmdevt.c +2 -3
@@ -488,8 +488,6 @@ int mwifiex_send_cmd_sync(struct mwifiex ret =mwifiex_send_cmd_async (priv, cmd_no, cmd_action, cmd_oid, data_buf); -if (!ret) - ret =mwifiex_wait_queue_complete (adapter);return ret; }
@@ -592,9 +590,10 @@ int mwifiex_send_cmd_async(struct mwifieif (cmd_no == HostCmd_CMD_802_11_SCAN) {mwifiex_queue_scan_cmd (priv, cmd_node); }else { - adapter->cmd_queued = cmd_node;mwifiex_insert_cmd_to_pending_q (adapter, cmd_node, true);queue_work (adapter->workqueue, &adapter->main_work); +if (cmd_node->wait_q_enabled) + ret =mwifiex_wait_queue_complete (adapter, cmd_node); }return ret;
drivers/net/wireless/mwifiex/main.h +2 -2
@@ -714,7 +714,6 @@ struct mwifiex_adapter {u16 cmd_wait_q_required;struct mwifiex_wait_queue cmd_wait_q;u8 scan_wait_q_woken; -struct cmd_ctrl_node *cmd_queued;spinlock_t queue_lock;/* lock for tx queues */ struct completion fw_load;u8 country_code[IEEE80211_COUNTRY_STRING_LEN ];
@@ -994,7 +993,8 @@ int mwifiex_request_set_multicast_list(s struct mwifiex_multicast_list *mcast_list);int mwifiex_copy_mcast_addr (struct mwifiex_multicast_list *mlist,struct net_device *dev); -int mwifiex_wait_queue_complete (struct mwifiex_adapter *adapter); +int mwifiex_wait_queue_complete (struct mwifiex_adapter *adapter, +struct cmd_ctrl_node *cmd_queued);int mwifiex_bss_start (struct mwifiex_private *priv,struct cfg80211_bss *bss,struct cfg80211_ssid *req_ssid);int mwifiex_cancel_hs (struct mwifiex_private *priv,int cmd_type);
drivers/net/wireless/mwifiex/scan.c +4 -4
@@ -1366,10 +1366,13 @@ int mwifiex_scan_networks(struct mwifiexlist_del (&cmd_node->list);spin_unlock_irqrestore (&adapter->scan_pending_q_lock, flags); - adapter->cmd_queued = cmd_node;mwifiex_insert_cmd_to_pending_q (adapter, cmd_node, true);queue_work (adapter->workqueue, &adapter->main_work); + +/* Perform internal scan synchronously */ +if (!priv->scan_request) +mwifiex_wait_queue_complete (adapter, cmd_node); }else {spin_unlock_irqrestore (&adapter->scan_pending_q_lock, flags);
@@ -1923,9 +1926,6 @@ int mwifiex_request_scan(struct mwifiex_/* Normal scan */ ret =mwifiex_scan_networks (priv,NULL ); -if (!ret) - ret =mwifiex_wait_queue_complete (priv->adapter); -up (&priv->async_sem);return ret;
drivers/net/wireless/mwifiex/sta_ioctl.c +2 -8
@@ -54,16 +54,10 @@ int mwifiex_copy_mcast_addr(struct mwifi* This function waits on a cmd wait queue. It also cancels the pending * request after waking up, in case of errors. */ -int mwifiex_wait_queue_complete (struct mwifiex_adapter *adapter) +int mwifiex_wait_queue_complete (struct mwifiex_adapter *adapter, +struct cmd_ctrl_node *cmd_queued) {int status; -struct cmd_ctrl_node *cmd_queued; - -if (!adapter->cmd_queued) -return 0 ; - - cmd_queued = adapter->cmd_queued; - adapter->cmd_queued =NULL ;dev_dbg (adapter->dev,"cmd pending\n" );atomic_inc (&adapter->cmd_pending);
Greg Kroah-Hartman
maintainerPATCH 34/124 mwifiex: skip pending commands after function shutdown
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bing Zhao <[email protected]>
commit a3e240cacc93a06bff3313e28938e980d01a2160 upstream.
During rmmod mwifiex_sdio processing FUNC_SHUTDOWN command is sent to firmware. Firmware expcets only FUNC_INIT once WLAN function is shut down.
Any command pending in the command queue should be ignored and freed.
--- drivers/net/wireless/mwifiex/cmdevt.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
drivers/net/wireless/mwifiex/cmdevt.c +14 -3
@@ -156,6 +156,20 @@ static int mwifiex_dnld_cmd_to_fw(structreturn -1 ; } + cmd_code =le16_to_cpu (host_cmd->command); + cmd_size =le16_to_cpu (host_cmd->size); + +if (adapter->hw_status ==MWIFIEX_HW_STATUS_RESET && + cmd_code != HostCmd_CMD_FUNC_SHUTDOWN && + cmd_code != HostCmd_CMD_FUNC_INIT) { +dev_err (adapter->dev, +"DNLD_CMD: FW in reset state, ignore cmd %#x\n" , + cmd_code); +mwifiex_complete_cmd (adapter, cmd_node); +mwifiex_insert_cmd_to_free_q (adapter, cmd_node); +return -1 ; + } +/* Set command sequence number */ adapter->seq_num++; host_cmd->seq_num = cpu_to_le16(HostCmd_SET_SEQ_NO_BSS_INFO
@@ -167,9 +181,6 @@ static int mwifiex_dnld_cmd_to_fw(struct adapter->curr_cmd = cmd_node;spin_unlock_irqrestore (&adapter->mwifiex_cmd_lock, flags); - cmd_code =le16_to_cpu (host_cmd->command); - cmd_size =le16_to_cpu (host_cmd->size); -/* Adjust skb length */ if (cmd_node->cmd_skb->len > cmd_size)/*
Greg Kroah-Hartman
maintainerPATCH 35/124 mwifiex: cancel cmd timer and free curr_cmd in shutdown process
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bing Zhao <[email protected]>
commit 084c7189acb3f969c855536166042e27f5dd703f upstream.
curr_cmd points to the command that is in processing or waiting for its command response from firmware. If the function shutdown happens to occur at this time we should cancel the cmd timer and put the command back to free queue.
--- drivers/net/wireless/mwifiex/init.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/net/wireless/mwifiex/init.c +8 -0
@@ -707,6 +707,14 @@ mwifiex_shutdown_drv(struct mwifiex_adapreturn ret; } +/* cancel current command */ +if (adapter->curr_cmd) { +dev_warn (adapter->dev,"curr_cmd is still in processing\n" ); +del_timer (&adapter->cmd_timer); +mwifiex_insert_cmd_to_free_q (adapter, adapter->curr_cmd); + adapter->curr_cmd =NULL ; + } +/* shut down mwifiex */ dev_dbg (adapter->dev,"info: shutdown mwifiex...\n" );
Greg Kroah-Hartman
maintainerPATCH 36/124 pnfs-block: removing DM device maybe cause oops when call dev_remove
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: fanchaoting <[email protected]>
commit 4376c94618c26225e69e17b7c91169c45a90b292 upstream.
when pnfs block using device mapper,if umounting later,it maybe cause oops. we apply "1 + sizeof(bl_umount_request)" memory for msg->data, the memory maybe overflow when we do "memcpy(&dataptr [sizeof(bl_msg)], &bl_umount_request, sizeof(bl_umount_request))", because the size of bl_msg is more than 1 byte.
--- fs/nfs/blocklayout/blocklayoutdm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfs/blocklayout/blocklayoutdm.c +2 -2
@@ -55,7 +55,8 @@ static void dev_remove(struct net *net, bl_pipe_msg.bl_wq = &nn->bl_wq;memset (msg,0 ,sizeof (*msg)); - msg->data =kzalloc (1 +sizeof (bl_umount_request),GFP_NOFS ); + msg->len =sizeof (bl_msg) + bl_msg.totallen; + msg->data =kzalloc (msg->len,GFP_NOFS );if (!msg->data) goto out;
@@ -66,7 +67,6 @@ static void dev_remove(struct net *net,memcpy (msg->data, &bl_msg,sizeof (bl_msg)); dataptr = (uint8_t *) msg->data;memcpy (&dataptr[sizeof (bl_msg)], &bl_umount_request,sizeof (bl_umount_request)); - msg->len =sizeof (bl_msg) + bl_msg.totallen;add_wait_queue (&nn->bl_wq, &wq);if (rpc_queue_upcall (nn->bl_device_pipe, msg) <0 ) {
Greg Kroah-Hartman
maintainerPATCH 37/124 NFSv4: Fix the string length returned by the idmapper
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Trond Myklebust <[email protected]>
commit cf4ab538f1516606d3ae730dce15d6f33d96b7e1 upstream.
Functions like nfs_map_uid_to_name() and nfs_map_gid_to_group() are expected to return a string without any terminating NUL character. Regression introduced by commit 57e62324e469e092ecc6c94a7a86fe4bd6ac5172 (NFS: Store the legacy idmapper result in the keyring).
--- fs/nfs/idmap.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
fs/nfs/idmap.c +8 -5
@@ -725,9 +725,9 @@ out1:return ret; } -static int nfs_idmap_instantiate (struct key *key,struct key *authkey,char *data) +static int nfs_idmap_instantiate (struct key *key,struct key *authkey,char *data,size_t datalen) { -return key_instantiate_and_link (key, data,strlen (data) +1 , +return key_instantiate_and_link (key, data, datalen, id_resolver_cache->thread_keyring, authkey); }
@@ -737,6 +737,7 @@ static int nfs_idmap_read_and_verify_mes struct key *key, struct key *authkey) { char id_str[NFS_UINT_MAXLEN]; +size_t len;int ret = -ENOKEY ;/* ret = -ENOKEY */
@@ -746,13 +747,15 @@ static int nfs_idmap_read_and_verify_mescase IDMAP_CONV_NAMETOID :if (strcmp (upcall->im_name, im->im_name) !=0 )break ; -sprintf (id_str,"%d" , im->im_id); - ret =nfs_idmap_instantiate (key, authkey, id_str); +/* Note: here we store the NUL terminator too */ + len =sprintf (id_str,"%d" , im->im_id) +1 ; + ret =nfs_idmap_instantiate (key, authkey, id_str, len);break ;case IDMAP_CONV_IDTONAME :if (upcall->im_id != im->im_id)break ; - ret =nfs_idmap_instantiate (key, authkey, im->im_name); + len =strlen (im->im_name); + ret =nfs_idmap_instantiate (key, authkey, im->im_name, len);break ;default : ret = -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 38/124 NFSv4.1: Fix a race in pNFS layoutcommit
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Trond Myklebust <[email protected]>
commit a073dbff359f4741013ae4b8395f5364c5e00b48 upstream.
We need to clear the NFS_LSEG_LAYOUTCOMMIT bits atomically with the NFS_INO_LAYOUTCOMMIT bit, otherwise we may end up with situations where the two are out of sync.
The first half of the problem is to ensure that pnfs_layoutcommit_inode clears the NFS_LSEG_LAYOUTCOMMIT bit through pnfs_list_write_lseg. We still need to keep the reference to those segments until the RPC call is finished, so in order to make it clear _where_ those references come from, we add a helper pnfs_list_write_lseg_done() that cleans up after pnfs_list_write_lseg.
--- fs/nfs/nfs4proc.c | 14 -------------- fs/nfs/pnfs.c | 19 ++++++++++++++++++- 2 files changed, 18 insertions(+), 15 deletions(-)
fs/nfs/nfs4proc.c +0 -14
@@ -6366,22 +6366,8 @@ nfs4_layoutcommit_done(struct rpc_task *static void nfs4_layoutcommit_release (void *calldata) {struct nfs4_layoutcommit_data *data = calldata; -struct pnfs_layout_segment *lseg, *tmp; -unsigned long *bitlock = &NFS_I (data->args.inode)->flags;pnfs_cleanup_layoutcommit (data); -/* Matched by references in pnfs_set_layoutcommit */ -list_for_each_entry_safe (lseg, tmp, &data->lseg_list, pls_lc_list) { -list_del_init (&lseg->pls_lc_list); -if (test_and_clear_bit (NFS_LSEG_LAYOUTCOMMIT , - &lseg->pls_flags)) -pnfs_put_lseg (lseg); - } - -clear_bit_unlock (NFS_INO_LAYOUTCOMMITTING , bitlock); -smp_mb__after_clear_bit (); -wake_up_bit (bitlock,NFS_INO_LAYOUTCOMMITTING ); -put_rpccred (data->cred);kfree (data); }
fs/nfs/pnfs.c +18 -1
@@ -1747,11 +1747,27 @@ static void pnfs_list_write_lseg(structlist_for_each_entry (lseg, &NFS_I (inode)->layout->plh_segs, pls_list) {if (lseg->pls_range.iomode ==IOMODE_RW && -test_bit (NFS_LSEG_LAYOUTCOMMIT , &lseg->pls_flags)) +test_and_clear_bit (NFS_LSEG_LAYOUTCOMMIT , &lseg->pls_flags))list_add (&lseg->pls_lc_list, listp); } } +static void pnfs_list_write_lseg_done (struct inode *inode,struct list_head *listp) +{ +struct pnfs_layout_segment *lseg, *tmp; +unsigned long *bitlock = &NFS_I (inode)->flags; + +/* Matched by references in pnfs_set_layoutcommit */ +list_for_each_entry_safe (lseg, tmp, listp, pls_lc_list) { +list_del_init (&lseg->pls_lc_list); +pnfs_put_lseg (lseg); + } + +clear_bit_unlock (NFS_INO_LAYOUTCOMMITTING , bitlock); +smp_mb__after_clear_bit (); +wake_up_bit (bitlock,NFS_INO_LAYOUTCOMMITTING ); +} +void pnfs_set_lo_fail (struct pnfs_layout_segment *lseg) {pnfs_layout_io_set_failed (lseg->pls_layout, lseg->pls_range.iomode);
@@ -1796,6 +1812,7 @@ void pnfs_cleanup_layoutcommit(struct nfif (nfss->pnfs_curr_ld->cleanup_layoutcommit) nfss->pnfs_curr_ld->cleanup_layoutcommit (data); +pnfs_list_write_lseg_done (data->args.inode, &data->lseg_list); }/*
Greg Kroah-Hartman
maintainerPATCH 39/124 NFSv4.1: Always clear the NFS_INO_LAYOUTCOMMIT in layoutreturn
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Trond Myklebust <[email protected]>
commit 24956804349ca0eadcdde032d65e8c00b4214096 upstream.
Note that clearing NFS_INO_LAYOUTCOMMIT is tricky, since it requires you to also clear the NFS_LSEG_LAYOUTCOMMIT bits from the layout segments.
The only two sites that need to do this are the ones that call pnfs_return_layout() without first doing a layout commit.
--- fs/nfs/nfs4filelayout.c | 1 - fs/nfs/pnfs.c | 35 +++++++++++++++++++++++++++-------- 2 files changed, 27 insertions(+), 9 deletions(-)
fs/nfs/nfs4filelayout.c +0 -1
@@ -129,7 +129,6 @@ static void filelayout_fenceme(struct in {if (!test_and_clear_bit (NFS_LAYOUT_RETURN , &lo->plh_flags))return ; -clear_bit (NFS_INO_LAYOUTCOMMIT , &NFS_I (inode)->flags);pnfs_return_layout (inode); }
fs/nfs/pnfs.c +27 -8
@@ -417,6 +417,16 @@ should_free_lseg(struct pnfs_layout_ranglo_seg_intersecting (lseg_range, recall_range); } +static bool pnfs_lseg_dec_and_remove_zero (struct pnfs_layout_segment *lseg, +struct list_head *tmp_list) +{ +if (!atomic_dec_and_test (&lseg->pls_refcount)) +return false; +pnfs_layout_remove_lseg (lseg->pls_layout, lseg); +list_add (&lseg->pls_list, tmp_list); +return true; +} +/* Returns 1 if lseg is removed from list, 0 otherwise */ static int mark_lseg_invalid (struct pnfs_layout_segment *lseg,struct list_head *tmp_list)
@@ -430,11 +440,8 @@ static int mark_lseg_invalid(struct pnfs*/ dprintk ("%s: lseg %p ref %d\n" , __func__, lseg,atomic_read (&lseg->pls_refcount)); -if (atomic_dec_and_test (&lseg->pls_refcount)) { -pnfs_layout_remove_lseg (lseg->pls_layout, lseg); -list_add (&lseg->pls_list, tmp_list); +if (pnfs_lseg_dec_and_remove_zero (lseg, tmp_list)) rv =1 ; - } }return rv; }
@@ -777,6 +784,21 @@ send_layoutget(struct pnfs_layout_hdr *lreturn lseg; } +static void pnfs_clear_layoutcommit (struct inode *inode, +struct list_head *head) +{ +struct nfs_inode *nfsi =NFS_I (inode); +struct pnfs_layout_segment *lseg, *tmp; + +if (!test_and_clear_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->flags)) +return ; +list_for_each_entry_safe (lseg, tmp, &nfsi->layout->plh_segs, pls_list) { +if (!test_and_clear_bit (NFS_LSEG_LAYOUTCOMMIT , &lseg->pls_flags)) +continue ; +pnfs_lseg_dec_and_remove_zero (lseg, head); + } +} +/* * Initiates a LAYOUTRETURN(FILE), and removes the pnfs_layout_hdr * when the layout segment list is empty.
@@ -808,6 +830,7 @@ _pnfs_return_layout(struct inode *ino)/* Reference matched in nfs4_layoutreturn_release */ pnfs_get_layout_hdr (lo); empty =list_empty (&lo->plh_segs); +pnfs_clear_layoutcommit (ino, &tmp_list);pnfs_mark_matching_lsegs_invalid (lo, &tmp_list,NULL );/* Don't send a LAYOUTRETURN if list was initially empty */ if (empty) {
@@ -820,8 +843,6 @@ _pnfs_return_layout(struct inode *ino)spin_unlock (&ino->i_lock);pnfs_free_lseg_list (&tmp_list); -WARN_ON (test_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->flags)); - lrp =kzalloc (sizeof (*lrp),GFP_KERNEL );if (unlikely (lrp ==NULL )) { status = -ENOMEM ;
@@ -1459,7 +1480,6 @@ static void pnfs_ld_handle_write_error(sdprintk ("pnfs write error = %d\n" , hdr->pnfs_error);if (NFS_SERVER (hdr->inode)->pnfs_curr_ld->flags &PNFS_LAYOUTRET_ON_ERROR ) { -clear_bit (NFS_INO_LAYOUTCOMMIT , &NFS_I (hdr->inode)->flags);pnfs_return_layout (hdr->inode); }if (!test_and_set_bit (NFS_IOHDR_REDO , &hdr->flags))
@@ -1614,7 +1634,6 @@ static void pnfs_ld_handle_read_error(stdprintk ("pnfs read error = %d\n" , hdr->pnfs_error);if (NFS_SERVER (hdr->inode)->pnfs_curr_ld->flags &PNFS_LAYOUTRET_ON_ERROR ) { -clear_bit (NFS_INO_LAYOUTCOMMIT , &NFS_I (hdr->inode)->flags);pnfs_return_layout (hdr->inode); }if (!test_and_set_bit (NFS_IOHDR_REDO , &hdr->flags))
Greg Kroah-Hartman
maintainerPATCH 40/124 net/irda: add missing error path release_sock call
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
commit 896ee0eee6261e30c3623be931c3f621428947df upstream.
This makes sure that release_sock is called for all error conditions in irda_getsockopt.
--- net/irda/af_irda.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/irda/af_irda.c +4 -2
@@ -2584,8 +2584,10 @@ bed: NULL, NULL, NULL);/* Check if the we got some results */ -if (!self->cachedaddr) -return -EAGAIN ;/* Didn't find any devices */ +if (!self->cachedaddr) { + err = -EAGAIN ;/* Didn't find any devices */ + goto out; + } daddr = self->cachedaddr;/* Cleanup */ self->cachedaddr =0 ;
Greg Kroah-Hartman
maintainerPATCH 41/124 Nest rename_lock inside vfsmount_lock
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit 7ea600b5314529f9d1b9d6d3c41cb26fce6a7a4a upstream.
... lest we get livelocks between path_is_under() and d_path() and friends.
The thing is, wrt fairness lglocks are more similar to rwsems than to rwlocks; it is possible to have thread B spin on attempt to take lock shared while thread A is already holding it shared, if B is on lower-numbered CPU than A and there's a thread C spinning on attempt to take the same lock exclusive.
As the result, we need consistent ordering between vfsmount_lock (lglock) and rename_lock (seq_lock), even though everything that takes both is going to take vfsmount_lock only shared.
--- fs/dcache.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
fs/dcache.c +11 -5
@@ -2552,7 +2552,6 @@ static int prepend_path(const struct patbool slash = false;int error =0 ; -br_read_lock (&vfsmount_lock);while (dentry != root->dentry || vfsmnt != root->mnt) {struct dentry * parent;
@@ -2582,8 +2581,6 @@ static int prepend_path(const struct patif (!error && !slash) error =prepend (buffer, buflen,"/" ,1 ); -out: -br_read_unlock (&vfsmount_lock);return error; global_root:
@@ -2600,7 +2597,7 @@ global_root: error =prepend (buffer, buflen,"/" ,1 );if (!error) error =is_mounted (vfsmnt) ?1 :2 ; - goto out; +return error; }/**
@@ -2627,9 +2624,11 @@ char *__d_path(const struct path *path,int error;prepend (&res, &buflen,"\0" ,1 ); +br_read_lock (&vfsmount_lock);write_seqlock (&rename_lock); error =prepend_path (path, root, &res, &buflen);write_sequnlock (&rename_lock); +br_read_unlock (&vfsmount_lock);if (error <0 )return ERR_PTR (error);
@@ -2646,9 +2645,11 @@ char *d_absolute_path(const struct pathint error;prepend (&res, &buflen,"\0" ,1 ); +br_read_lock (&vfsmount_lock);write_seqlock (&rename_lock); error =prepend_path (path, &root, &res, &buflen);write_sequnlock (&rename_lock); +br_read_unlock (&vfsmount_lock);if (error >1 ) error = -EINVAL ;
@@ -2712,11 +2713,13 @@ char *d_path(const struct path *path, chreturn path->dentry->d_op->d_dname (path->dentry, buf, buflen);get_fs_root (current->fs, &root); +br_read_lock (&vfsmount_lock);write_seqlock (&rename_lock); error =path_with_deleted (path, &root, &res, &buflen); +write_sequnlock (&rename_lock); +br_read_unlock (&vfsmount_lock);if (error <0 ) res =ERR_PTR (error); -write_sequnlock (&rename_lock);path_put (&root);return res; }
@@ -2871,6 +2874,7 @@ SYSCALL_DEFINE2(getcwd, char __user *, bget_fs_root_and_pwd (current->fs, &root, &pwd); error = -ENOENT ; +br_read_lock (&vfsmount_lock);write_seqlock (&rename_lock);if (!d_unlinked (pwd.dentry)) {unsigned long len;
@@ -2880,6 +2884,7 @@ SYSCALL_DEFINE2(getcwd, char __user *, bprepend (&cwd, &buflen,"\0" ,1 ); error =prepend_path (&pwd, &root, &cwd, &buflen);write_sequnlock (&rename_lock); +br_read_unlock (&vfsmount_lock);if (error <0 ) goto out;
@@ -2900,6 +2905,7 @@ SYSCALL_DEFINE2(getcwd, char __user *, b } }else {write_sequnlock (&rename_lock); +br_read_unlock (&vfsmount_lock); } out:
Greg Kroah-Hartman
maintainerPATCH 42/124 USB: EHCI: fix bug in iTD/siTD DMA pool allocation
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Soeren Moch <[email protected]>
commit 85ecd0322b9a1a9f451d9150e9460ab42fd17219 upstream.
[Description written by Alan Stern]
Soeren tracked down a very difficult bug in ehci-hcd's DMA pool management of iTD and siTD structures. Some background: ehci-hcd gives each isochronous endpoint its own set of active and free itd's (or sitd's for full-speed devices). When a new itd is needed, it is taken from the head of the free list, if possible. However, itd's must not be used twice in a single frame because the hardware continues to access the data structure for the entire duration of a frame. Therefore if the itd at the head of the free list has its "frame" member equal to the current value of ehci->now_frame, it cannot be reused and instead a new itd is allocated from the DMA pool. The entries on the free list are not released back to the pool until the endpoint is no longer in use.
The bug arises from the fact that sometimes an itd can be moved back onto the free list before itd->frame has been set properly. In Soeren's case, this happened because ehci-hcd can allocate one more itd than it actually needs for an URB; the extra itd may or may not be required depending on how the transfer aligns with a frame boundary. For example, an URB with 8 isochronous packets will cause two itd's to be allocated. If the URB is scheduled to start in microframe 3 of frame N then it will require both itds: one for microframes 3 - 7 of frame N and one for microframes 0 - 2 of frame N+1. But if the URB had been scheduled to start in microframe 0 then it would require only the first itd, which could cover microframes 0 - 7 of frame N. The second itd would be returned to the end of the free list.
The itd allocation routine initializes the entire structure to 0, so the extra itd ends up on the free list with itd->frame set to 0 instead of a meaningful value. After a while the itd reaches the head of the list, and occasionally this happens when ehci->now_frame is equal to 0. Then, even though it would be okay to reuse this itd, the driver thinks it must get another itd from the DMA pool.
For as long as the isochronous endpoint remains in use, this flaw in the mechanism causes more and more itd's to be taken slowly from the DMA pool. Since none are released back, the pool eventually becomes exhausted.
This reuslts in memory allocation failures, which typically show up during a long-running audio stream. Video might suffer the same effect.
The fix is very simple. To prevent allocations from the pool when they aren't needed, make sure that itd's sent back to the free list prematurely have itd->frame set to an invalid value which can never be equal to ehci->now_frame.
This should be applied to -stable kernels going back to 3.6.
--- drivers/usb/host/ehci-sched.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/host/ehci-sched.c +2 -0
@@ -1214,6 +1214,7 @@ itd_urb_transaction (memset (itd,0 ,sizeof *itd); itd->itd_dma = itd_dma; + itd->frame =9999 ;/* an invalid value */ list_add (&itd->itd_list, &sched->td_list); }spin_unlock_irqrestore (&ehci->lock, flags);
@@ -1915,6 +1916,7 @@ sitd_urb_transaction (memset (sitd,0 ,sizeof *sitd); sitd->sitd_dma = sitd_dma; + sitd->frame =9999 ;/* an invalid value */ list_add (&sitd->sitd_list, &iso_sched->td_list); }
Greg Kroah-Hartman
maintainerPATCH 43/124 usb: xhci: Fix TRB transfer length macro used for Event TRB.
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vivek Gautam <[email protected]>
commit 1c11a172cb30492f5f6a82c6e118fdcd9946c34f upstream.
Use proper macro while extracting TRB transfer length from Transfer event TRBs. Adding a macro EVENT_TRB_LEN (bits 0:23) for the same, and use it instead of TRB_LEN (bits 0:16) in case of event TRBs.
This patch should be backported to kernels as old as 2.6.31, that contain the commit b10de142119a676552df3f0d2e3a9d647036c26a "USB: xhci:
Bulk transfer support". This patch will have issues applying to older kernels.
--- drivers/usb/host/xhci-ring.c | 24 ++++++++++++------------ drivers/usb/host/xhci.h | 4 ++++ 2 files changed, 16 insertions(+), 12 deletions(-)
drivers/usb/host/xhci-ring.c +12 -12
@@ -2027,8 +2027,8 @@ static int process_ctrl_td(struct xhci_hif (event_trb != ep_ring->dequeue && event_trb != td->last_trb) td->urb->actual_length = - td->urb->transfer_buffer_length - -TRB_LEN (le32_to_cpu (event->transfer_len)); + td->urb->transfer_buffer_length - +EVENT_TRB_LEN (le32_to_cpu (event->transfer_len));else td->urb->actual_length =0 ;
@@ -2060,7 +2060,7 @@ static int process_ctrl_td(struct xhci_h/* Maybe the event was for the data stage? */ td->urb->actual_length = td->urb->transfer_buffer_length - -TRB_LEN (le32_to_cpu (event->transfer_len)); +EVENT_TRB_LEN (le32_to_cpu (event->transfer_len));xhci_dbg (xhci,"Waiting for status " "stage event\n" );return 0 ;
@@ -2096,7 +2096,7 @@ static int process_isoc_td(struct xhci_h/* handle completion code */ switch (trb_comp_code) {case COMP_SUCCESS : -if (TRB_LEN (le32_to_cpu (event->transfer_len)) ==0 ) { +if (EVENT_TRB_LEN (le32_to_cpu (event->transfer_len)) ==0 ) { frame->status =0 ;break ; }
@@ -2141,7 +2141,7 @@ static int process_isoc_td(struct xhci_h len +=TRB_LEN (le32_to_cpu (cur_trb->generic.field[2 ])); } len +=TRB_LEN (le32_to_cpu (cur_trb->generic.field[2 ])) - -TRB_LEN (le32_to_cpu (event->transfer_len)); +EVENT_TRB_LEN (le32_to_cpu (event->transfer_len));if (trb_comp_code !=COMP_STOP_INVAL ) { frame->actual_length = len;
@@ -2199,7 +2199,7 @@ static int process_bulk_intr_td(struct xcase COMP_SUCCESS :/* Double check that the HW transferred everything. */ if (event_trb != td->last_trb || -TRB_LEN (le32_to_cpu (event->transfer_len)) !=0 ) { +EVENT_TRB_LEN (le32_to_cpu (event->transfer_len)) !=0 ) {xhci_warn (xhci,"WARN Successful completion " "on short TX\n" );if (td->urb->transfer_flags &URB_SHORT_NOT_OK )
@@ -2227,18 +2227,18 @@ static int process_bulk_intr_td(struct x"%d bytes untransferred\n" , td->urb->ep->desc.bEndpointAddress, td->urb->transfer_buffer_length, - TRB_LEN(le32_to_cpu(event->transfer_len))); + EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)));/* Fast path - was this the last TRB in the TD for this URB? */ if (event_trb == td->last_trb) { -if (TRB_LEN (le32_to_cpu (event->transfer_len)) !=0 ) { +if (EVENT_TRB_LEN (le32_to_cpu (event->transfer_len)) !=0 ) { td->urb->actual_length = td->urb->transfer_buffer_length - -TRB_LEN (le32_to_cpu (event->transfer_len)); +EVENT_TRB_LEN (le32_to_cpu (event->transfer_len));if (td->urb->transfer_buffer_length < td->urb->actual_length) {xhci_warn (xhci,"HC gave bad length " "of %d bytes left\n" , -TRB_LEN (le32_to_cpu (event->transfer_len))); +EVENT_TRB_LEN (le32_to_cpu (event->transfer_len))); td->urb->actual_length =0 ;if (td->urb->transfer_flags &URB_SHORT_NOT_OK ) *status = -EREMOTEIO ;
@@ -2280,7 +2280,7 @@ static int process_bulk_intr_td(struct xif (trb_comp_code !=COMP_STOP_INVAL ) td->urb->actual_length +=TRB_LEN (le32_to_cpu (cur_trb->generic.field[2 ])) - -TRB_LEN (le32_to_cpu (event->transfer_len)); +EVENT_TRB_LEN (le32_to_cpu (event->transfer_len)); }return finish_td (xhci, td, event_trb, event, ep, status, false);
@@ -2368,7 +2368,7 @@ static int handle_tx_event(struct xhci_h* transfer type */ case COMP_SUCCESS : -if (TRB_LEN (le32_to_cpu (event->transfer_len)) ==0 ) +if (EVENT_TRB_LEN (le32_to_cpu (event->transfer_len)) ==0 )break ;if (xhci->quirks &XHCI_TRUST_TX_LENGTH ) trb_comp_code =COMP_SHORT_TX ;
drivers/usb/host/xhci.h +4 -0
@@ -972,6 +972,10 @@ struct xhci_transfer_event {__le32 flags; }; +/* Transfer event TRB length bit mask */ +/* bits 0:23 */ +#define EVENT_TRB_LEN (p) ((p) & 0xffffff) +/** Transfer Event bit fields **/ #define TRB_TO_EP_ID (p) (((p) >> 16) & 0x1f)
Greg Kroah-Hartman
maintainerPATCH 44/124 target: Fix RESERVATION_CONFLICT status regression for iscsi-target special case
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicholas Bellinger <[email protected]>
commit f85eda8d75d37a3796cee7f5a906e50e3f13d9e1 upstream.
This patch fixes a regression introduced in v3.8-rc1 code where a failed target_check_reservation() check in target_setup_cmd_from_cdb() was causing an incorrect SAM_STAT_GOOD status to be returned during a WRITE operation performed by an unregistered / unreserved iscsi initiator port.
This regression is only effecting iscsi-target due to a special case check for TCM_RESERVATION_CONFLICT within iscsi_target_erl1.c:iscsit_execute_cmd(), and was still correctly disallowing WRITE commands from backend submission for unregistered / unreserved initiator ports, while returning the incorrect SAM_STAT_GOOD status due to the missing SAM_STAT_RESERVATION_CONFLICT assignment.
This regression was first introduced with:
commit de103c93aff0bed0ae984274e5dc8b95899badab
Author: Christoph Hellwig <[email protected]> Date: Tue Nov 6 12:24:09 2012 -0800
target: pass sense_reason as a return value
Go ahead and re-add the missing SAM_STAT_RESERVATION_CONFLICT assignment during a target_check_reservation() failure, so that iscsi-target code sends the correct SCSI status.
All other fabrics using target_submit_cmd_*() with a RESERVATION_CONFLICT call to transport_generic_request_failure() are not effected by this bug.
--- drivers/target/target_core_transport.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/target/target_core_transport.c +3 -1
@@ -1136,8 +1136,10 @@ target_setup_cmd_from_cdb(struct se_cmdreturn ret; ret =target_check_reservation (cmd); -if (ret) +if (ret) { + cmd->scsi_status =SAM_STAT_RESERVATION_CONFLICT ;return ret; + } ret = dev->transport->parse_cdb (cmd);if (ret)
Greg Kroah-Hartman
maintainerPATCH 45/124 media: [REGRESSION] bt8xx: Fix too large height in cropcap
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit 35ccecef6ed48a5602755ddf580c45a026a1dc05 upstream.
Since commit a1fd287780c8e91fed4957b30c757b0c93021162:
"[media] bttv-driver: fix two warnings"
cropcap.defrect.height and cropcap.bounds.height for the PAL entry are 32
resp 30 pixels too large, if a userspace app (ie xawtv) actually tries to use
the full advertised height, the resulting image is broken in ways only a
screenshot can describe.
The cause of this is the fix for this warning:drivers/media/pci/bt8xx/bttv-driver.c:308:3: warning: initialized field overwritten [-Woverride-init] In this chunk of the commit:
@@ -301,11 +301,10 @@ const struct bttv_tvnorm bttv_tvnorms[] = {
/* totalwidth */ 1135,
/* sqwidth */ 944,
/* vdelay */ 0x20,- /* sheight */ 576,
- /* videostart0 */ 23)
/* bt878 (and bt848?) can capture another
line below active video. */
- .cropcap.bounds.height = (576 + 2) + 0x20 - 2,
+ /* sheight */ (576 + 2) + 0x20 - 2,
+ /* videostart0 */ 23)
},{
.v4l2_id = V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_KR,
.name = "NTSC",Which replaces the overriding of cropcap.bounds.height initialization outside of the CROPCAP macro (which also initializes it), with passing a different sheight value to the CROPCAP macro.
There are 2 problems with this warning fix:
1) The sheight value is used twice in the CROPCAP macro, and the old code only changed one resulting value.
2) The old code increased the .cropcap.bounds.height value (and did not touch the .cropcap.defrect.height value at all) by 2, where as the fixed code increases it by 32, as the fixed code passes (576 + 2) + 0x20 - 2 to the CROPCAP macro, but the + 0x20 - 2 is already done by the macro so now is done twice for .cropcap.bounds.height, and also is applied to .cropcap.defrect.height where it should not be applied at all.
This patch fixes this by adding an extraheight parameter to the CROPCAP entry and using it for the PAL entry.
--- drivers/media/pci/bt8xx/bttv-driver.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
drivers/media/pci/bt8xx/bttv-driver.c +15 -5
@@ -250,17 +250,19 @@ static u8 SRAM_Table[][60] =vdelay start of active video in 2 * field lines relative to trailing edge of /VRESET pulse (VDELAY register). sheight height of active video in 2 * field lines. +extraheight Added to sheight for cropcap.bounds.height only videostart0 ITU-R frame line number of the line corresponding to vdelay in the first field. */ #define CROPCAP(minhdelayx1, hdelayx1, swidth, totalwidth, sqwidth, \ - vdelay, sheight, videostart0) \ + vdelay, sheight, extraheight, videostart0) \ .cropcap.bounds.left = minhdelayx1, \ /* * 2 because vertically we count field lines times two, */ \ /* e.g. 23 * 2 to 23 * 2 + 576 in PAL-BGHI defrect. */ \ .cropcap.bounds.top = (videostart0) * 2 - (vdelay) + MIN_VDELAY, \ /* 4 is a safety margin at the end of the line. */ \ .cropcap.bounds.width = (totalwidth) - (minhdelayx1) - 4, \ - .cropcap.bounds.height = (sheight) + (vdelay) - MIN_VDELAY, \ + .cropcap.bounds.height = (sheight) + (extraheight) + (vdelay) - \ + MIN_VDELAY, \ .cropcap.defrect.left = hdelayx1, \ .cropcap.defrect.top = (videostart0) * 2, \ .cropcap.defrect.width = swidth, \
@@ -301,9 +303,10 @@ const struct bttv_tvnorm bttv_tvnorms[] /* totalwidth */ 1135, /* sqwidth */ 944, /* vdelay */ 0x20, -/* bt878 (and bt848?) can capture another -line below active video. */ - /* sheight */ (576 + 2) + 0x20 - 2, + /* sheight */ 576, +/* bt878 (and bt848?) can capture another +line below active video. */ + /* extraheight */ 2, /* videostart0 */ 23) },{ .v4l2_id = V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_KR,
@@ -330,6 +333,7 @@ const struct bttv_tvnorm bttv_tvnorms[] /* sqwidth */ 780, /* vdelay */ 0x1a, /* sheight */ 480, + /* extraheight */ 0, /* videostart0 */ 23) },{ .v4l2_id = V4L2_STD_SECAM,
@@ -355,6 +359,7 @@ const struct bttv_tvnorm bttv_tvnorms[] /* sqwidth */ 944, /* vdelay */ 0x20, /* sheight */ 576, + /* extraheight */ 0, /* videostart0 */ 23) },{ .v4l2_id = V4L2_STD_PAL_Nc,
@@ -380,6 +385,7 @@ const struct bttv_tvnorm bttv_tvnorms[] /* sqwidth */ 780, /* vdelay */ 0x1a, /* sheight */ 576, + /* extraheight */ 0, /* videostart0 */ 23) },{ .v4l2_id = V4L2_STD_PAL_M,
@@ -405,6 +411,7 @@ const struct bttv_tvnorm bttv_tvnorms[] /* sqwidth */ 780, /* vdelay */ 0x1a, /* sheight */ 480, + /* extraheight */ 0, /* videostart0 */ 23) },{ .v4l2_id = V4L2_STD_PAL_N,
@@ -430,6 +437,7 @@ const struct bttv_tvnorm bttv_tvnorms[] /* sqwidth */ 944, /* vdelay */ 0x20, /* sheight */ 576, + /* extraheight */ 0, /* videostart0 */ 23) },{ .v4l2_id = V4L2_STD_NTSC_M_JP,
@@ -455,6 +463,7 @@ const struct bttv_tvnorm bttv_tvnorms[]/* sqwidth */ 780 ,/* vdelay */ 0x16 ,/* sheight */ 480 , +/* extraheight */ 0 , /* videostart0 */ 23) },{/* that one hopefully works with the strange timing
@@ -484,6 +493,7 @@ const struct bttv_tvnorm bttv_tvnorms[] /* sqwidth */ 944, /* vdelay */ 0x1a, /* sheight */ 480, + /* extraheight */ 0, /* videostart0 */ 23) } };
Greg Kroah-Hartman
maintainerPATCH 46/124 mac80211: prevent spurious HT/VHT downgrade message
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
commit 586e01ededf9b713a1512dd658806791a7ca1a50 upstream.
Even when connecting to an AP that doesn't support VHT, and even when the local device doesn't support it either, the downgrade message gets printed. Suppress the message if HT and/or VHT is disabled.
--- net/mac80211/mlme.c | 4 ++++ 1 file changed, 4 insertions(+)
net/mac80211/mlme.c +4 -0
@@ -3401,6 +3401,10 @@ ieee80211_determine_chantype(struct ieee ret =0 ; out: +/* don't print the message below for VHT mismatch if VHT is disabled */ +if (ret &IEEE80211_STA_DISABLE_VHT ) + vht_chandef = *chandef; +while (!cfg80211_chandef_usable (sdata->local->hw.wiphy, chandef,IEEE80211_CHAN_DISABLED )) {if (WARN_ON (chandef->width ==NL80211_CHAN_WIDTH_20_NOHT )) {
Greg Kroah-Hartman
maintainerPATCH 47/124 scm: Require CAP_SYS_ADMIN over the current pidns to spoof pids.
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Eric W. Biederman" <[email protected]>
commit 92f28d973cce45ef5823209aab3138eb45d8b349 upstream.
Don't allow spoofing pids over unix domain sockets in the corner cases where a user has created a user namespace but has not yet created a pid namespace.
--- net/core/scm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/core/scm.c +3 -1
@@ -24,6 +24,7 @@#include <linux/interrupt.h> #include <linux/netdevice.h> #include <linux/security.h> +#include <linux/pid_namespace.h> #include <linux/pid.h> #include <linux/nsproxy.h> #include <linux/slab.h>
@@ -52,7 +53,8 @@ static __inline__ int scm_check_creds(stif (!uid_valid (uid) || !gid_valid (gid))return -EINVAL ; - if ((creds->pid == task_tgid_vnr(current) || nsown_capable(CAP_SYS_ADMIN)) && + if ((creds->pid == task_tgid_vnr(current) || + ns_capable(current->nsproxy->pid_ns->user_ns, CAP_SYS_ADMIN)) && ((uid_eq(uid, cred->uid) || uid_eq(uid, cred->euid) || uid_eq(uid, cred->suid)) || nsown_capable(CAP_SETUID)) && ((gid_eq(gid, cred->gid) || gid_eq(gid, cred->egid) ||
Greg Kroah-Hartman
maintainerPATCH 48/124 pid: Handle the exit of a multi-threaded init.
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Eric W. Biederman" <[email protected]>
commit 751c644b95bb48aaa8825f0c66abbcc184d92051 upstream.
When a multi-threaded init exits and the initial thread is not the last thread to exit the initial thread hangs around as a zombie until the last thread exits. In that case zap_pid_ns_processes needs to wait until there are only 2 hashed pids in the pid namespace not one.
v2. Replace thread_pid_vnr(me) == 1 with the test thread_group_leader(me)
as suggested by Oleg.
--- kernel/pid_namespace.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/pid_namespace.c +2 -1
@@ -181,6 +181,7 @@ void zap_pid_ns_processes(struct pid_namint nr;int rc;struct task_struct *task, *me = current; +int init_pids =thread_group_leader (me) ?1 :2 ;/* Don't allow any more processes into the pid namespace */ disable_pid_allocation (pid_ns);
@@ -230,7 +231,7 @@ void zap_pid_ns_processes(struct pid_nam*/ for (;;) {set_current_state (TASK_UNINTERRUPTIBLE ); -if (pid_ns->nr_hashed ==1 ) +if (pid_ns->nr_hashed == init_pids)break ;schedule (); }
Greg Kroah-Hartman
maintainerPATCH 49/124 userns: Dont allow creation if the user is chrooted
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Eric W. Biederman" <[email protected]>
commit 3151527ee007b73a0ebd296010f1c0454a919c7d upstream.
Guarantee that the policy of which files may be access that is established by setting the root directory will not be violated by user namespaces by verifying that the root directory points to the root of the mount namespace at the time of user namespace creation.
Changing the root is a privileged operation, and as a matter of policy it serves to limit unprivileged processes to files below the current root directory.
For reasons of simplicity and comprehensibility the privilege to change the root directory is gated solely on the CAP_SYS_CHROOT capability in the user namespace. Therefore when creating a user namespace we must ensure that the policy of which files may be access can not be violated by changing the root directory.
Anyone who runs a processes in a chroot and would like to use user namespace can setup the same view of filesystems with a mount namespace instead. With this result that this is not a practical limitation for using user namespaces.
--- fs/namespace.c | 24 ++++++++++++++++++++++++ include/linux/fs_struct.h | 2 ++ kernel/user_namespace.c | 9 +++++++++ 3 files changed, 35 insertions(+)
fs/namespace.c +24 -0
@@ -2758,6 +2758,30 @@ bool our_mnt(struct vfsmount *mnt)return check_mnt (real_mount (mnt)); } +bool current_chrooted (void ) +{ +/* Does the current process have a non-standard root */ +struct path ns_root; +struct path fs_root; +bool chrooted; + +/* Find the namespace root */ + ns_root.mnt = ¤t->nsproxy->mnt_ns->root->mnt; + ns_root.dentry = ns_root.mnt->mnt_root; +path_get (&ns_root); +while (d_mountpoint (ns_root.dentry) &&follow_down_one (&ns_root)) + ; + +get_fs_root (current->fs, &fs_root); + + chrooted = !path_equal (&fs_root, &ns_root); + +path_put (&fs_root); +path_put (&ns_root); + +return chrooted; +} +static void *mntns_get (struct task_struct *task) {struct mnt_namespace *ns =NULL ;
include/linux/fs_struct.h +2 -0
@@ -50,4 +50,6 @@ static inline void get_fs_root_and_pwd(s spin_unlock(&fs->lock); } +extern bool current_chrooted (void ); +#endif /* _LINUX_FS_STRUCT_H */
kernel/user_namespace.c +9 -0
@@ -61,6 +61,15 @@ int create_user_ns(struct cred *new)kgid_t group = new->egid;int ret; +/* +* Verify that we can not violate the policy of which files +* may be accessed that is specified by the root directory, +* by verifing that the root directory is at the root of the +* mount namespace which allows all files to be accessed. +*/ +if (current_chrooted ()) +return -EPERM ; +/* The creator needs a mapping in the parent user namespace * or else we won't be able to reasonably tell userspace who * created a user_namespace.
Greg Kroah-Hartman
maintainerPATCH 50/124 vfs: Add a mount flag to lock read only bind mounts
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Eric W. Biederman" <[email protected]>
commit 90563b198e4c6674c63672fae1923da467215f45 upstream.
When a read-only bind mount is copied from mount namespace in a higher privileged user namespace to a mount namespace in a lesser privileged user namespace, it should not be possible to remove the the read-only restriction.
Add a MNT_LOCK_READONLY mount flag to indicate that a mount must remain read-only.
--- fs/namespace.c | 3 +++ include/linux/mount.h | 2 ++ 2 files changed, 5 insertions(+)
fs/namespace.c +3 -0
@@ -1736,6 +1736,9 @@ static int change_mount_flags(struct vfsif (readonly_request ==__mnt_is_readonly (mnt))return 0 ; +if (mnt->mnt_flags &MNT_LOCK_READONLY ) +return -EPERM ; +if (readonly_request) error =mnt_make_readonly (real_mount (mnt));else
include/linux/mount.h +2 -0
@@ -47,6 +47,8 @@ struct mnt_namespace;#define MNT_INTERNAL 0x4000 +#define MNT_LOCK_READONLY 0x400000 +struct vfsmount {struct dentry *mnt_root;/* root of the mounted tree */ struct super_block *mnt_sb;/* pointer to superblock */
Greg Kroah-Hartman
maintainerPATCH 51/124 vfs: Carefully propogate mounts across user namespaces
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Eric W. Biederman" <[email protected]>
commit 132c94e31b8bca8ea921f9f96a57d684fa4ae0a9 upstream.
As a matter of policy MNT_READONLY should not be changable if the original mounter had more privileges than creator of the mount namespace.
Add the flag CL_UNPRIVILEGED to note when we are copying a mount from a mount namespace that requires more privileges to a mount namespace that requires fewer privileges.
When the CL_UNPRIVILEGED flag is set cause clone_mnt to set MNT_NO_REMOUNT if any of the mnt flags that should never be changed are set.
This protects both mount propagation and the initial creation of a less privileged mount namespace.
--- fs/namespace.c | 6 +++++- fs/pnode.c | 6 ++++++ fs/pnode.h | 1 + 3 files changed, 12 insertions(+), 1 deletion(-)
fs/namespace.c +5 -1
@@ -798,6 +798,10 @@ static struct mount *clone_mnt(struct mo } mnt->mnt.mnt_flags = old->mnt.mnt_flags & ~MNT_WRITE_HOLD ; +/* Don't allow unprivileged users to change mount flags */ +if ((flag &CL_UNPRIVILEGED ) && (mnt->mnt.mnt_flags &MNT_READONLY )) + mnt->mnt.mnt_flags |=MNT_LOCK_READONLY ; +atomic_inc (&sb->s_active); mnt->mnt.mnt_sb = sb; mnt->mnt.mnt_root =dget (root);
@@ -2368,7 +2372,7 @@ static struct mnt_namespace *dup_mnt_ns(/* First pass: copy the tree topology */ copy_flags =CL_COPY_ALL |CL_EXPIRE ;if (user_ns != mnt_ns->user_ns) - copy_flags |=CL_SHARED_TO_SLAVE ; + copy_flags |=CL_SHARED_TO_SLAVE |CL_UNPRIVILEGED ; new =copy_tree (old, old->mnt.mnt_root, copy_flags);if (IS_ERR (new)) {up_write (&namespace_sem);
fs/pnode.c +6 -0
@@ -9,6 +9,7 @@#include <linux/mnt_namespace.h> #include <linux/mount.h> #include <linux/fs.h> +#include <linux/nsproxy.h> #include "internal.h" #include "pnode.h"
@@ -220,6 +221,7 @@ static struct mount *get_source(struct mint propagate_mnt (struct mount *dest_mnt,struct dentry *dest_dentry,struct mount *source_mnt,struct list_head *tree_list) { +struct user_namespace *user_ns = current->nsproxy->mnt_ns->user_ns;struct mount *m, *child;int ret =0 ;struct mount *prev_dest_mnt = dest_mnt;
@@ -237,6 +239,10 @@ int propagate_mnt(struct mount *dest_mnt source =get_source (m, prev_dest_mnt, prev_src_mnt, &type); +/* Notice when we are propagating across user namespaces */ +if (m->mnt_ns->user_ns != user_ns) + type |=CL_UNPRIVILEGED ; + child =copy_tree (source, source->mnt.mnt_root, type);if (IS_ERR (child)) { ret =PTR_ERR (child);
fs/pnode.h +1 -0
@@ -23,6 +23,7 @@#define CL_MAKE_SHARED 0x08#define CL_PRIVATE 0x10#define CL_SHARED_TO_SLAVE 0x20 +#define CL_UNPRIVILEGED 0x40static inline void set_mnt_shared (struct mount *mnt) {
Greg Kroah-Hartman
maintainerPATCH 52/124 ipc: Restrict mounting the mqueue filesystem
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Eric W. Biederman" <[email protected]>
commit a636b702ed1805e988ad3d8ff8b52c060f8b341c upstream.
Only allow mounting the mqueue filesystem if the caller has CAP_SYS_ADMIN
rights over the ipc namespace. The principle here is if you create
or have capabilities over it you can mount it, otherwise you get to live with what other people have mounted.
This information is not particularly sensitive and mqueue essentially only reports which posix messages queues exist. Still when creating a restricted environment for an application to live any extra information may be of use to someone with sufficient creativity. The historical if imperfect way this information has been restricted has been not to allow mounts and restricting this to ipc namespace creators maintains the spirit of the historical restriction.
--- ipc/mqueue.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
ipc/mqueue.c +10 -2
@@ -330,8 +330,16 @@ static struct dentry *mqueue_mount(struc int flags, const char *dev_name, void *data) { - if (!(flags & MS_KERNMOUNT)) - data = current->nsproxy->ipc_ns; + if (!(flags & MS_KERNMOUNT)) { + struct ipc_namespace *ns = current->nsproxy->ipc_ns; +/* Don't allow mounting unless the caller has CAP_SYS_ADMIN +* over the ipc namespace. +*/ +if (!ns_capable (ns->user_ns,CAP_SYS_ADMIN )) +return ERR_PTR (-EPERM ); + + data = ns; + }return mount_ns (fs_type, flags, data, mqueue_fill_super); }
Greg Kroah-Hartman
maintainerPATCH 53/124 userns: Restrict when proc and sysfs can be mounted
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Eric W. Biederman" <[email protected]>
commit 87a8ebd637dafc255070f503909a053cf0d98d3f upstream.
Only allow unprivileged mounts of proc and sysfs if they are already mounted when the user namespace is created.
proc and sysfs are interesting because they have content that is per namespace, and so fresh mounts are needed when new namespaces are created while at the same time proc and sysfs have content that is shared between every instance.
Respect the policy of who may see the shared content of proc and sysfs by only allowing new mounts if there was an existing mount at the time the user namespace was created.
In practice there are only two interesting cases: proc and sysfs are mounted at their usual places, proc and sysfs are not mounted at all (some form of mount namespace jail).
--- fs/namespace.c | 21 +++++++++++++++++++++ fs/proc/root.c | 4 ++++ fs/sysfs/mount.c | 4 ++++ include/linux/user_namespace.h | 4 ++++ kernel/user.c | 2 ++ kernel/user_namespace.c | 2 ++ 6 files changed, 37 insertions(+)
fs/namespace.c +21 -0
@@ -2789,6 +2789,27 @@ bool current_chrooted(void)return chrooted; } +void update_mnt_policy (struct user_namespace *userns) +{ +struct mnt_namespace *ns = current->nsproxy->mnt_ns; +struct mount *mnt; + +down_read (&namespace_sem); +list_for_each_entry (mnt, &ns->list, mnt_list) { +switch (mnt->mnt.mnt_sb->s_magic) { +case SYSFS_MAGIC : + userns->may_mount_sysfs = true; +break ; +case PROC_SUPER_MAGIC : + userns->may_mount_proc = true; +break ; + } +if (userns->may_mount_sysfs && userns->may_mount_proc) +break ; + } +up_read (&namespace_sem); +} +static void *mntns_get (struct task_struct *task) {struct mnt_namespace *ns =NULL ;
fs/proc/root.c +4 -0
@@ -16,6 +16,7 @@#include <linux/sched.h> #include <linux/module.h> #include <linux/bitops.h> +#include <linux/user_namespace.h> #include <linux/mount.h> #include <linux/pid_namespace.h> #include <linux/parser.h>
@@ -108,6 +109,9 @@ static struct dentry *proc_mount(struct }else { ns =task_active_pid_ns (current); options = data; + +if (!current_user_ns ()->may_mount_proc) +return ERR_PTR (-EPERM ); } sb =sget (fs_type, proc_test_super, proc_set_super, flags, ns);
fs/sysfs/mount.c +4 -0
@@ -19,6 +19,7 @@#include <linux/module.h> #include <linux/magic.h> #include <linux/slab.h> +#include <linux/user_namespace.h> #include "sysfs.h"
@@ -111,6 +112,9 @@ static struct dentry *sysfs_mount(structstruct super_block *sb;int error; +if (!(flags &MS_KERNMOUNT ) && !current_user_ns ()->may_mount_sysfs) +return ERR_PTR (-EPERM ); + info =kzalloc (sizeof (*info),GFP_KERNEL );if (!info)return ERR_PTR (-ENOMEM );
include/linux/user_namespace.h +4 -0
@@ -26,6 +26,8 @@ struct user_namespace {kuid_t owner;kgid_t group;unsigned int proc_inum; +bool may_mount_sysfs; +bool may_mount_proc; };extern struct user_namespace init_user_ns;
@@ -82,4 +84,6 @@ static inline void put_user_ns(struct us#endif +void update_mnt_policy (struct user_namespace *userns); +#endif /* _LINUX_USER_H */
kernel/user.c +2 -0
@@ -53,6 +53,8 @@ struct user_namespace init_user_ns = { .owner = GLOBAL_ROOT_UID, .group = GLOBAL_ROOT_GID, .proc_inum = PROC_USER_INIT_INO, + .may_mount_sysfs = true, + .may_mount_proc = true, };EXPORT_SYMBOL_GPL (init_user_ns);
kernel/user_namespace.c +2 -0
@@ -96,6 +96,8 @@ int create_user_ns(struct cred *new)set_cred_user_ns (new, ns); +update_mnt_policy (ns); +return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 54/124 Btrfs: use set_nlink if our i_nlink is 0
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
commit 9bf7a4890518186238d2579be16ecc5190a707c0 upstream.
We need to inc the nlink of deleted entries when running replay so we can do the unlink on the fs_root and get everything cleaned up and then have the orphan cleanup do the right thing. The problem is inc_nlink complains about this, even thought it still does the right thing. So use set_nlink() if our i_nlink is 0 to keep users from seeing the warnings during log replay. Thanks,
--- fs/btrfs/tree-log.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/btrfs/tree-log.c +4 -1
@@ -1384,7 +1384,10 @@ static noinline int link_to_fixup_dir(stbtrfs_release_path (path);if (ret ==0 ) { -btrfs_inc_nlink (inode); +if (!inode->i_nlink) +set_nlink (inode,1 ); +else +btrfs_inc_nlink (inode); ret =btrfs_update_inode (trans, root, inode); }else if (ret == -EEXIST ) { ret =0 ;
Greg Kroah-Hartman
maintainerPATCH 55/124 Btrfs: fix locking on ROOT_REPLACE operations in tree mod log
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Schmidt <[email protected]>
commit d9abbf1c3131b679379762700201ae69367f3f62 upstream.
To resolve backrefs, ROOT_REPLACE operations in the tree mod log are required to be tied to at least one KEY_REMOVE_WHILE_FREEING operation. Therefore, those operations must be enclosed by tree_mod_log_write_lock() and tree_mod_log_write_unlock() calls.
Those calls are private to the tree_mod_log_* functions, which means that removal of the elements of an old root node must be logged from tree_mod_log_insert_root. This partly reverts and corrects commit ba1bfbd5 (Btrfs: fix a tree mod logging issue for root replacement operations).
This fixes the brand-new version of xfstest 276 as of commit cfe73f71.
--- fs/btrfs/ctree.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-)
fs/btrfs/ctree.c +20 -10
@@ -651,6 +651,8 @@ tree_mod_log_insert_root(struct btrfs_fsif (tree_mod_dont_log (fs_info,NULL ))return 0 ; +__tree_mod_log_free_eb (fs_info, old_root); + ret =tree_mod_alloc (fs_info, flags, &tm);if (ret <0 ) goto out;
@@ -736,7 +738,7 @@ tree_mod_log_search(struct btrfs_fs_info static noinline voidtree_mod_log_eb_copy (struct btrfs_fs_info *fs_info,struct extent_buffer *dst,struct extent_buffer *src,unsigned long dst_offset, -unsigned long src_offset,int nr_items) +unsigned long src_offset,int nr_items,int log_removal) {int ret;int i;
@@ -750,10 +752,12 @@ tree_mod_log_eb_copy(struct btrfs_fs_inf }for (i =0 ; i < nr_items; i++) { - ret =tree_mod_log_insert_key_locked (fs_info, src, - i + src_offset, -MOD_LOG_KEY_REMOVE ); -BUG_ON (ret <0 ); +if (log_removal) { + ret =tree_mod_log_insert_key_locked (fs_info, src, + i + src_offset, +MOD_LOG_KEY_REMOVE ); +BUG_ON (ret <0 ); + } ret =tree_mod_log_insert_key_locked (fs_info, dst, i + dst_offset,MOD_LOG_KEY_ADD );
@@ -927,7 +931,6 @@ static noinline int update_ref_for_cow(s ret =btrfs_dec_ref (trans, root, buf,1 ,1 );BUG_ON (ret);/* -ENOMEM */ } -tree_mod_log_free_eb (root->fs_info, buf);clean_tree_block (trans, root, buf); *last_ref =1 ; }
@@ -1046,6 +1049,7 @@ static noinline int __btrfs_cow_block(stbtrfs_set_node_ptr_generation (parent, parent_slot, trans->transid);btrfs_mark_buffer_dirty (parent); +tree_mod_log_free_eb (root->fs_info, buf);btrfs_free_tree_block (trans, root, buf, parent_start, last_ref); }
@@ -1755,7 +1759,6 @@ static noinline int balance_level(struct goto enospc; } -tree_mod_log_free_eb (root->fs_info, root->node);tree_mod_log_set_root_pointer (root, child);rcu_assign_pointer (root->node, child);
@@ -3000,7 +3003,7 @@ static int push_node_left(struct btrfs_t push_items =min (src_nritems -8 , push_items);tree_mod_log_eb_copy (root->fs_info, dst, src, dst_nritems,0 , - push_items); + push_items,1 ); copy_extent_buffer(dst, src, btrfs_node_key_ptr_offset(dst_nritems), btrfs_node_key_ptr_offset(0),
@@ -3071,7 +3074,7 @@ static int balance_node_right(struct btr sizeof(struct btrfs_key_ptr));tree_mod_log_eb_copy (root->fs_info, dst, src,0 , - src_nritems - push_items, push_items); + src_nritems - push_items, push_items,1 ); copy_extent_buffer(dst, src, btrfs_node_key_ptr_offset(0), btrfs_node_key_ptr_offset(src_nritems - push_items),
@@ -3223,12 +3226,18 @@ static noinline int split_node(struct btint mid;int ret;u32 c_nritems; +int tree_mod_log_removal =1 ; c = path->nodes[level];WARN_ON (btrfs_header_generation (c) != trans->transid);if (c == root->node) {/* trying to split the root, lets make a new one */ ret =insert_new_root (trans, root, path, level +1 ); +/* +* removal of root nodes has been logged by +* tree_mod_log_set_root_pointer due to locking +*/ + tree_mod_log_removal =0 ;if (ret)return ret; }else {
@@ -3266,7 +3275,8 @@ static noinline int split_node(struct bt (unsigned long )btrfs_header_chunk_tree_uuid (split), BTRFS_UUID_SIZE); -tree_mod_log_eb_copy (root->fs_info, split, c,0 , mid, c_nritems - mid); +tree_mod_log_eb_copy (root->fs_info, split, c,0 , mid, c_nritems - mid, + tree_mod_log_removal); copy_extent_buffer(split, c, btrfs_node_key_ptr_offset(0), btrfs_node_key_ptr_offset(mid),
Greg Kroah-Hartman
maintainerPATCH 56/124 Btrfs: fix race between mmap writes and compression
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Mason <[email protected]>
commit 4adaa611020fa6ac65b0ac8db78276af4ec04e63 upstream.
Btrfs uses page_mkwrite to ensure stable pages during
crc calculations and mmap workloads. We call clear_page_dirty_for_io before we do any crcs, and this forces any application with the file mapped to wait for the crc to finish before it is allowed to change the file.
With compression on, the clear_page_dirty_for_io step is happening after we've compressed the pages. This means the applications might be changing the pages while we are compressing them, and some of those modifications might not hit the disk.
This commit adds the clear_page_dirty_for_io before compression starts and makes sure to redirty the page if we have to fallback to uncompressed IO as well.
--- fs/btrfs/extent_io.c | 33 +++++++++++++++++++++++++++++++++ fs/btrfs/extent_io.h | 2 ++ fs/btrfs/inode.c | 14 ++++++++++++++ 3 files changed, 49 insertions(+)
fs/btrfs/extent_io.c +33 -0
@@ -1258,6 +1258,39 @@ int unlock_extent(struct extent_io_tree GFP_NOFS); } +int extent_range_clear_dirty_for_io (struct inode *inode,u64 start,u64 end) +{ +unsigned long index = start >>PAGE_CACHE_SHIFT ; +unsigned long end_index = end >>PAGE_CACHE_SHIFT ; +struct page *page; + +while (index <= end_index) { + page =find_get_page (inode->i_mapping, index); +BUG_ON (!page);/* Pages should be in the extent_io_tree */ +clear_page_dirty_for_io (page); +page_cache_release (page); + index++; + } +return 0 ; +} + +int extent_range_redirty_for_io (struct inode *inode,u64 start,u64 end) +{ +unsigned long index = start >>PAGE_CACHE_SHIFT ; +unsigned long end_index = end >>PAGE_CACHE_SHIFT ; +struct page *page; + +while (index <= end_index) { + page =find_get_page (inode->i_mapping, index); +BUG_ON (!page);/* Pages should be in the extent_io_tree */ +account_page_redirty (page); +__set_page_dirty_nobuffers (page); +page_cache_release (page); + index++; + } +return 0 ; +} +/* * helper function to set both pages and extents in the tree writeback */
fs/btrfs/extent_io.h +2 -0
@@ -329,6 +329,8 @@ int map_private_extent_buffer(struct ext unsigned long *map_len);int extent_range_uptodate (struct extent_io_tree *tree,u64 start,u64 end); +int extent_range_clear_dirty_for_io (struct inode *inode,u64 start,u64 end); +int extent_range_redirty_for_io (struct inode *inode,u64 start,u64 end); int extent_clear_unlock_delalloc(struct inode *inode, struct extent_io_tree *tree, u64 start, u64 end, struct page *locked_page,
fs/btrfs/inode.c +14 -0
@@ -352,6 +352,7 @@ static noinline int compress_file_range(int i;int will_compress;int compress_type = root->fs_info->compress_type; +int redirty =0 ;/* if this is a small write inside eof, kick off a defrag */ if ((end - start + 1) < 16 * 1024 &&
@@ -414,6 +415,17 @@ again:if (BTRFS_I (inode)->force_compress) compress_type =BTRFS_I (inode)->force_compress; +/* +* we need to call clear_page_dirty_for_io on each +* page in the range. Otherwise applications with the file +* mmap'd can wander in and change the page contents while +* we are compressing them. +* +* If the compression fails for any reason, we set the pages +* dirty again later on. +*/ +extent_range_clear_dirty_for_io (inode, start, end); + redirty =1 ; ret = btrfs_compress_pages(compress_type, inode->i_mapping, start, total_compressed, pages,
@@ -555,6 +567,8 @@ cleanup_and_bail_uncompressed:__set_page_dirty_nobuffers (locked_page);/* unlocked later on in the async handlers */ } +if (redirty) +extent_range_redirty_for_io (inode, start, end);add_async_extent (async_cow, start, end - start +1 ,0 ,NULL ,0 ,BTRFS_COMPRESS_NONE ); *num_added +=1 ;
Greg Kroah-Hartman
maintainerPATCH 57/124 Btrfs: limit the global reserve to 512mb
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
commit fdf30d1c1b386e1b73116cc7e0fb14e962b763b0 upstream.
A user reported a problem where he was getting early ENOSPC with hundreds of gigs of free data space and 6 gigs of free metadata space. This is because the global block reserve was taking up the entire free metadata space. This is ridiculous, we have infrastructure in place to throttle if we start using too much of the global reserve, so instead of letting it get this huge just limit it to 512mb so that users can still get work done. This allowed the user to complete his rsync without issues. Thanks
--- fs/btrfs/extent-tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/extent-tree.c +1 -1
@@ -4308,7 +4308,7 @@ static void update_global_block_rsv(struspin_lock (&sinfo->lock);spin_lock (&block_rsv->lock); - block_rsv->size = num_bytes; + block_rsv->size =min_t (u64, num_bytes,512 *1024 *1024 ); num_bytes = sinfo->bytes_used + sinfo->bytes_pinned + sinfo->bytes_reserved + sinfo->bytes_readonly +
Greg Kroah-Hartman
maintainerPATCH 58/124 Btrfs: dont drop path when printing out tree errors in scrub
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
commit d8fe29e9dea8d7d61fd140d8779326856478fc62 upstream.
A user reported a panic where we were panicing somewhere in tree_backref_for_extent from scrub_print_warning. He only captured the trace but looking at scrub_print_warning we drop the path right before we mess with the extent buffer to print out a bunch of stuff, which isn't right. So fix this by dropping the path after we use the eb if we need to. Thanks,
--- fs/btrfs/scrub.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/scrub.c +2 -1
@@ -541,7 +541,6 @@ static void scrub_print_warning(const ch eb = path->nodes[0 ]; ei = btrfs_item_ptr(eb, path->slots[0], struct btrfs_extent_item); item_size =btrfs_item_size_nr (eb, path->slots[0 ]); -btrfs_release_path (path);if (flags &BTRFS_EXTENT_FLAG_TREE_BLOCK ) { do {
@@ -557,7 +556,9 @@ static void scrub_print_warning(const ch ret <0 ?-1 : ref_level, ret < 0 ? -1 : ref_root); }while (ret !=1 ); +btrfs_release_path (path); }else { +btrfs_release_path (path); swarn.path = path; swarn.dev = dev; iterate_extent_inodes(fs_info, found_key.objectid,
Greg Kroah-Hartman
maintainerPATCH 59/124 USB: serial: add modem-status-change wait queue
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit e5b33dc9d16053c2ae4c2c669cf008829530364b upstream.
Add modem-status-change wait queue to struct usb_serial_port that subdrivers can use to implement TIOCMIWAIT.
Currently subdrivers use a private wait queue which may have been released when waking up after device disconnected.
Note that we're adding a new wait queue rather than reusing the tty-port one as we do not want to get woken up at hangup (yet).
--- include/linux/usb/serial.h | 2 ++ 1 file changed, 2 insertions(+)
include/linux/usb/serial.h +2 -0
@@ -66,6 +66,7 @@* port. * @flags: usb serial port flags * @write_wait: a wait_queue_head_t used by the port. +* @delta_msr_wait: modem-status-change wait queue * @work: work queue entry for the line discipline waking up. * @throttled: nonzero if the read urb is inactive to throttle the device * @throttle_req: nonzero if the tty wants to throttle us
@@ -112,6 +113,7 @@ struct usb_serial_port {unsigned long flags;wait_queue_head_t write_wait; +wait_queue_head_t delta_msr_wait;struct work_struct work;char throttled;char throttle_req;
Greg Kroah-Hartman
maintainerPATCH 60/124 USB: serial: fix hang when opening port
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming Lei <[email protected]>
commit eba0e3c3a0ba7b96f01cbe997680f6a4401a0bfc upstream.
Johan's 'fix use-after-free in TIOCMIWAIT' patchset[1] introduces one bug which can cause kernel hang when opening port.
This patch initialized the 'port->delta_msr_wait' waitqueue head to fix the bug which is introduced in 3.9-rc4.
[1], http://marc.info/?l=linux-usb&m=136368139627876&w=2
--- drivers/usb/serial/usb-serial.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/serial/usb-serial.c +1 -0
@@ -897,6 +897,7 @@ static int usb_serial_probe(struct usb_i port->port.ops = &serial_port_ops; port->serial = serial;spin_lock_init (&port->lock); +init_waitqueue_head (&port->delta_msr_wait);/* Keep this for private driver use for the moment but should probably go away */ INIT_WORK (&port->work, usb_serial_port_work);
Greg Kroah-Hartman
maintainerPATCH 61/124 USB: quatech2: fix use-after-free in TIOCMIWAIT
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 69f87f40d2b98e8b4ab82a121fd2bd584690b887 upstream.
Use the port wait queue and make sure to check the serial disconnected flag before accessing private port data after waking up.
This is is needed as the private port data (including the wait queue itself) can be gone when waking up after a disconnect.
--- drivers/usb/serial/quatech2.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/usb/serial/quatech2.c +7 -5
@@ -128,7 +128,6 @@ struct qt2_port_private {u8 shadowLSR;u8 shadowMSR; -wait_queue_head_t delta_msr_wait;/* Used for TIOCMIWAIT */ struct async_icount icount;struct usb_serial_port *port;
@@ -506,8 +505,9 @@ static int wait_modem_info(struct usb_sespin_unlock_irqrestore (&priv->lock, flags);while (1 ) { -wait_event_interruptible (priv->delta_msr_wait, - ((priv->icount.rng != prev.rng) || +wait_event_interruptible (port->delta_msr_wait, + (port->serial->disconnected || + (priv->icount.rng != prev.rng) || (priv->icount.dsr != prev.dsr) || (priv->icount.dcd != prev.dcd) || (priv->icount.cts != prev.cts)));
@@ -515,6 +515,9 @@ static int wait_modem_info(struct usb_seif (signal_pending (current))return -ERESTARTSYS ; +if (port->serial->disconnected) +return -EIO ; +spin_lock_irqsave (&priv->lock, flags); cur = priv->icount;spin_unlock_irqrestore (&priv->lock, flags);
@@ -841,7 +844,6 @@ static int qt2_port_probe(struct usb_serspin_lock_init (&port_priv->lock);spin_lock_init (&port_priv->urb_lock); -init_waitqueue_head (&port_priv->delta_msr_wait); port_priv->port = port; port_priv->write_urb =usb_alloc_urb (0 ,GFP_KERNEL );
@@ -984,7 +986,7 @@ static void qt2_update_msr(struct usb_seif (newMSR &UART_MSR_TERI ) port_priv->icount.rng++; -wake_up_interruptible (&port_priv->delta_msr_wait); +wake_up_interruptible (&port->delta_msr_wait); } }
Greg Kroah-Hartman
maintainerPATCH 62/124 USB: mos7840: fix broken TIOCMIWAIT
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit e670c6af12517d08a403487b1122eecf506021cf upstream.
Make sure waiting processes are woken on modem-status changes.
Currently processes are only woken on termios changes regardless of whether the modem status has changed.
--- drivers/usb/serial/mos7840.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/usb/serial/mos7840.c +3 -2
@@ -423,6 +423,9 @@ static void mos7840_handle_new_msr(struc icount->rng++;smp_wmb (); } + + mos7840_port->delta_msr_cond =1 ; +wake_up_interruptible (&mos7840_port->delta_msr_wait); } }
@@ -2021,8 +2024,6 @@ static void mos7840_change_port_settings mos7840_port->read_urb_busy = false; } } -wake_up (&mos7840_port->delta_msr_wait); - mos7840_port->delta_msr_cond =1 ;dev_dbg (&port->dev,"%s - mos7840_port->shadowLCR is End %x\n" , __func__, mos7840_port->shadowLCR); }
Greg Kroah-Hartman
maintainerPATCH 63/124 USB: io_ti: fix use-after-free in TIOCMIWAIT
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 7b2459690584f239650a365f3411ba2ec1c6d1e0 upstream.
Use the port wait queue and make sure to check the serial disconnected flag before accessing private port data after waking up.
This is is needed as the private port data (including the wait queue itself) can be gone when waking up after a disconnect.
--- drivers/usb/serial/io_ti.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/usb/serial/io_ti.c +6 -6
@@ -87,9 +87,6 @@ struct edgeport_port {int close_pending;int lsr_event;struct async_icount icount; -wait_queue_head_t delta_msr_wait;/* for handling sleeping while -waiting for msr change to -happen */ struct edgeport_serial *edge_serial;struct usb_serial_port *port;__u8 bUartMode;/* Port type, 0: RS232, etc. */
@@ -1518,7 +1515,7 @@ static void handle_new_msr(struct edgepo icount->dcd++;if (msr &EDGEPORT_MSR_DELTA_RI ) icount->rng++; -wake_up_interruptible (&edge_port->delta_msr_wait); +wake_up_interruptible (&edge_port->port->delta_msr_wait); }/* Save the new modem status */
@@ -1821,7 +1818,6 @@ static int edge_open(struct tty_struct * dev = port->serial->dev;memset (&(edge_port->icount),0x00 ,sizeof (edge_port->icount)); -init_waitqueue_head (&edge_port->delta_msr_wait);/* turn off loopback */ status =ti_do_config (edge_port,UMPC_SET_CLR_LOOPBACK ,0 );
@@ -2488,10 +2484,14 @@ static int edge_ioctl(struct tty_structdev_dbg (&port->dev,"%s - TIOCMIWAIT\n" , __func__); cprev = edge_port->icount;while (1 ) { -interruptible_sleep_on (&edge_port->delta_msr_wait); +interruptible_sleep_on (&port->delta_msr_wait);/* see if a signal did it */ if (signal_pending (current))return -ERESTARTSYS ; + +if (port->serial->disconnected) +return -EIO ; + cnow = edge_port->icount;if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && cnow.dcd == cprev.dcd && cnow.cts == cprev.cts)
Greg Kroah-Hartman
maintainerPATCH 64/124 USB: oti6858: fix use-after-free in TIOCMIWAIT
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 8edfdab37157d2683e51b8be5d3d5697f66a9f7b upstream.
Use the port wait queue and make sure to check the serial disconnected flag before accessing private port data after waking up.
This is is needed as the private port data (including the wait queue itself) can be gone when waking up after a disconnect.
--- drivers/usb/serial/oti6858.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/usb/serial/oti6858.c +6 -4
@@ -188,7 +188,6 @@ struct oti6858_private {u8 setup_done;struct delayed_work delayed_setup_work; -wait_queue_head_t intr_wait;struct usb_serial_port *port;/* USB port with which associated */ };
@@ -339,7 +338,6 @@ static int oti6858_port_probe(struct usbreturn -ENOMEM ;spin_lock_init (&priv->lock); -init_waitqueue_head (&priv->intr_wait); priv->port = port;INIT_DELAYED_WORK (&priv->delayed_setup_work, setup_line);INIT_DELAYED_WORK (&priv->delayed_write_work, send_data);
@@ -664,11 +662,15 @@ static int wait_modem_info(struct usb_sespin_unlock_irqrestore (&priv->lock, flags);while (1 ) { -wait_event_interruptible (priv->intr_wait, +wait_event_interruptible (port->delta_msr_wait, + port->serial->disconnected || priv->status.pin_state != prev);if (signal_pending (current))return -ERESTARTSYS ; +if (port->serial->disconnected) +return -EIO ; +spin_lock_irqsave (&priv->lock, flags); status = priv->status.pin_state &PIN_MASK ;spin_unlock_irqrestore (&priv->lock, flags);
@@ -763,7 +765,7 @@ static void oti6858_read_int_callback(stif (!priv->transient) {if (xs->pin_state != priv->status.pin_state) -wake_up_interruptible (&priv->intr_wait); +wake_up_interruptible (&port->delta_msr_wait);memcpy (&priv->status, xs,OTI6858_CTRL_PKT_SIZE ); }
Greg Kroah-Hartman
maintainerPATCH 65/124 USB: ftdi_sio: fix use-after-free in TIOCMIWAIT
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 71ccb9b01981fabae27d3c98260ea4613207618e upstream.
Use the port wait queue and make sure to check the serial disconnected flag before accessing private port data after waking up.
This is is needed as the private port data (including the wait queue itself) can be gone when waking up after a disconnect.
When switching to tty ports, some lifetime assumptions were changed. Specifically, close can now be called before the final tty reference is dropped as part of hangup at device disconnect. Even with the ftdi private-data refcounting this means that the port private data can be freed while a process is sleeping on modem-status changes and thus cannot be relied on to detect disconnects when woken up.
--- drivers/usb/serial/ftdi_sio.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-)
drivers/usb/serial/ftdi_sio.c +8 -11
@@ -69,9 +69,7 @@ struct ftdi_private {int flags;/* some ASYNC_xxxx flags are supported */ unsigned long last_dtr_rts;/* saved modem control outputs */ struct async_icount icount; -wait_queue_head_t delta_msr_wait;/* Used for TIOCMIWAIT */ char prev_status;/* Used for TIOCMIWAIT */ -bool dev_gone;/* Used to abort TIOCMIWAIT */ char transmit_empty;/* If transmitter is empty or not */ __u16 interface;/* FT2232C, FT2232H or FT4232H port interface (0 for FT232/245) */
@@ -1692,10 +1690,8 @@ static int ftdi_sio_port_probe(struct uskref_init (&priv->kref);mutex_init (&priv->cfg_lock); -init_waitqueue_head (&priv->delta_msr_wait); priv->flags =ASYNC_LOW_LATENCY ; - priv->dev_gone = false;if (quirk && quirk->port_probe) quirk->port_probe (priv);
@@ -1841,8 +1837,7 @@ static int ftdi_sio_port_remove(struct u {struct ftdi_private *priv =usb_get_serial_port_data (port); - priv->dev_gone = true; -wake_up_interruptible_all (&priv->delta_msr_wait); +wake_up_interruptible (&port->delta_msr_wait);remove_sysfs_attrs (port);
@@ -1991,7 +1986,7 @@ static int ftdi_process_packet(struct ttif (diff_status &FTDI_RS0_RLSD ) priv->icount.dcd++; -wake_up_interruptible_all (&priv->delta_msr_wait); +wake_up_interruptible (&port->delta_msr_wait); priv->prev_status = status; }
@@ -2448,11 +2443,15 @@ static int ftdi_ioctl(struct tty_struct*/ case TIOCMIWAIT : cprev = priv->icount; -while (!priv->dev_gone) { -interruptible_sleep_on (&priv->delta_msr_wait); +for (;;) { +interruptible_sleep_on (&port->delta_msr_wait);/* see if a signal did it */ if (signal_pending (current))return -ERESTARTSYS ; + +if (port->serial->disconnected) +return -EIO ; + cnow = priv->icount; if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) || ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
@@ -2462,8 +2461,6 @@ static int ftdi_ioctl(struct tty_struct } cprev = cnow; } -return -EIO ; -break ;case TIOCSERGETLSR :return get_lsr_info (port, (struct serial_struct __user *)arg);break ;
Greg Kroah-Hartman
maintainerPATCH 66/124 USB: pl2303: fix use-after-free in TIOCMIWAIT
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 40509ca982c00c4b70fc00be887509feca0bff15 upstream.
Use the port wait queue and make sure to check the serial disconnected flag before accessing private port data after waking up.
This is is needed as the private port data (including the wait queue itself) can be gone when waking up after a disconnect.
--- drivers/usb/serial/pl2303.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/usb/serial/pl2303.c +6 -5
@@ -139,7 +139,6 @@ struct pl2303_serial_private {struct pl2303_private {spinlock_t lock; -wait_queue_head_t delta_msr_wait;u8 line_control;u8 line_status; };
@@ -233,7 +232,6 @@ static int pl2303_port_probe(struct usb_return -ENOMEM ;spin_lock_init (&priv->lock); -init_waitqueue_head (&priv->delta_msr_wait);usb_set_serial_port_data (port, priv);
@@ -607,11 +605,14 @@ static int wait_modem_info(struct usb_sespin_unlock_irqrestore (&priv->lock, flags);while (1 ) { -interruptible_sleep_on (&priv->delta_msr_wait); +interruptible_sleep_on (&port->delta_msr_wait);/* see if a signal did it */ if (signal_pending (current))return -ERESTARTSYS ; +if (port->serial->disconnected) +return -EIO ; +spin_lock_irqsave (&priv->lock, flags); status = priv->line_status;spin_unlock_irqrestore (&priv->lock, flags);
@@ -719,7 +720,7 @@ static void pl2303_update_line_status(stspin_unlock_irqrestore (&priv->lock, flags);if (priv->line_status &UART_BREAK_ERROR )usb_serial_handle_break (port); -wake_up_interruptible (&priv->delta_msr_wait); +wake_up_interruptible (&port->delta_msr_wait); tty =tty_port_tty_get (&port->port);if (!tty)
@@ -784,7 +785,7 @@ static void pl2303_process_read_urb(stru line_status = priv->line_status; priv->line_status &= ~UART_STATE_TRANSIENT_MASK ;spin_unlock_irqrestore (&priv->lock, flags); -wake_up_interruptible (&priv->delta_msr_wait); +wake_up_interruptible (&port->delta_msr_wait);if (!urb->actual_length)return ;
Greg Kroah-Hartman
maintainerPATCH 67/124 USB: mos7840: fix use-after-free in TIOCMIWAIT
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit a14430db686b8e459e1cf070a6ecf391515c9ab9 upstream.
Use the port wait queue and make sure to check the serial disconnected flag before accessing private port data after waking up.
This is is needed as the private port data (including the wait queue itself) can be gone when waking up after a disconnect.
--- drivers/usb/serial/mos7840.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/usb/serial/mos7840.c +8 -5
@@ -219,7 +219,6 @@ struct moschip_port {char open;char open_ports;wait_queue_head_t wait_chase;/* for handling sleeping while waiting for chase to finish */ -wait_queue_head_t delta_msr_wait;/* for handling sleeping while waiting for msr change to happen */ int delta_msr_cond;struct async_icount icount;struct usb_serial_port *port;/* loop back to the owner of this object */
@@ -425,7 +424,7 @@ static void mos7840_handle_new_msr(struc } mos7840_port->delta_msr_cond =1 ; -wake_up_interruptible (&mos7840_port->delta_msr_wait); +wake_up_interruptible (&port->port->delta_msr_wait); } }
@@ -1134,7 +1133,6 @@ static int mos7840_open(struct tty_struc/* initialize our wait queues */ init_waitqueue_head (&mos7840_port->wait_chase); -init_waitqueue_head (&mos7840_port->delta_msr_wait);/* initialize our icount structure */ memset (&(mos7840_port->icount),0x00 ,sizeof (mos7840_port->icount));
@@ -2224,13 +2222,18 @@ static int mos7840_ioctl(struct tty_struwhile (1 ) {/* interruptible_sleep_on(&mos7840_port->delta_msr_wait); */ mos7840_port->delta_msr_cond =0 ; -wait_event_interruptible (mos7840_port->delta_msr_wait, - (mos7840_port-> +wait_event_interruptible (port->delta_msr_wait, + (port->serial->disconnected || + mos7840_port-> delta_msr_cond ==1 ));/* see if a signal did it */ if (signal_pending (current))return -ERESTARTSYS ; + +if (port->serial->disconnected) +return -EIO ; + cnow = mos7840_port->icount;smp_rmb (); if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr &&
Greg Kroah-Hartman
maintainerPATCH 68/124 USB: spcp8x5: fix use-after-free in TIOCMIWAIT
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit dbcea7615d8d7d58f6ff49d2c5568113f70effe9 upstream.
Use the port wait queue and make sure to check the serial disconnected flag before accessing private port data after waking up.
This is is needed as the private port data (including the wait queue itself) can be gone when waking up after a disconnect.
--- drivers/usb/serial/spcp8x5.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/usb/serial/spcp8x5.c +5 -4
@@ -149,7 +149,6 @@ enum spcp8x5_type {struct spcp8x5_private {spinlock_t lock;enum spcp8x5_type type; -wait_queue_head_t delta_msr_wait;u8 line_control;u8 line_status; };
@@ -179,7 +178,6 @@ static int spcp8x5_port_probe(struct usbreturn -ENOMEM ;spin_lock_init (&priv->lock); -init_waitqueue_head (&priv->delta_msr_wait); priv->type = type;usb_set_serial_port_data (port , priv);
@@ -476,7 +474,7 @@ static void spcp8x5_process_read_urb(str priv->line_status &= ~UART_STATE_TRANSIENT_MASK ;spin_unlock_irqrestore (&priv->lock, flags);/* wake up the wait for termios */ -wake_up_interruptible (&priv->delta_msr_wait); +wake_up_interruptible (&port->delta_msr_wait);if (!urb->actual_length)return ;
@@ -526,12 +524,15 @@ static int spcp8x5_wait_modem_info(strucwhile (1 ) {/* wake up in bulk read */ -interruptible_sleep_on (&priv->delta_msr_wait); +interruptible_sleep_on (&port->delta_msr_wait);/* see if a signal did it */ if (signal_pending (current))return -ERESTARTSYS ; +if (port->serial->disconnected) +return -EIO ; +spin_lock_irqsave (&priv->lock, flags); status = priv->line_status;spin_unlock_irqrestore (&priv->lock, flags);
Greg Kroah-Hartman
maintainerPATCH 69/124 USB: ssu100: fix use-after-free in TIOCMIWAIT
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 43a66b4c417ad15f6d2f632ce67ad195bdf999e8 upstream.
Use the port wait queue and make sure to check the serial disconnected flag before accessing private port data after waking up.
This is is needed as the private port data (including the wait queue itself) can be gone when waking up after a disconnect.
--- drivers/usb/serial/ssu100.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/usb/serial/ssu100.c +7 -5
@@ -61,7 +61,6 @@ struct ssu100_port_private {spinlock_t status_lock;u8 shadowLSR;u8 shadowMSR; -wait_queue_head_t delta_msr_wait;/* Used for TIOCMIWAIT */ struct async_icount icount; };
@@ -355,8 +354,9 @@ static int wait_modem_info(struct usb_sespin_unlock_irqrestore (&priv->status_lock, flags);while (1 ) { -wait_event_interruptible (priv->delta_msr_wait, - ((priv->icount.rng != prev.rng) || +wait_event_interruptible (port->delta_msr_wait, + (port->serial->disconnected || + (priv->icount.rng != prev.rng) || (priv->icount.dsr != prev.dsr) || (priv->icount.dcd != prev.dcd) || (priv->icount.cts != prev.cts)));
@@ -364,6 +364,9 @@ static int wait_modem_info(struct usb_seif (signal_pending (current))return -ERESTARTSYS ; +if (port->serial->disconnected) +return -EIO ; +spin_lock_irqsave (&priv->status_lock, flags); cur = priv->icount;spin_unlock_irqrestore (&priv->status_lock, flags);
@@ -445,7 +448,6 @@ static int ssu100_port_probe(struct usb_return -ENOMEM ;spin_lock_init (&priv->status_lock); -init_waitqueue_head (&priv->delta_msr_wait);usb_set_serial_port_data (port, priv);
@@ -537,7 +539,7 @@ static void ssu100_update_msr(struct usb priv->icount.dcd++;if (msr &UART_MSR_TERI ) priv->icount.rng++; -wake_up_interruptible (&priv->delta_msr_wait); +wake_up_interruptible (&port->delta_msr_wait); } }
Greg Kroah-Hartman
maintainerPATCH 70/124 USB: ch341: fix use-after-free in TIOCMIWAIT
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit fa1e11d5231c001c80a479160b5832933c5d35fb upstream.
Use the port wait queue and make sure to check the serial disconnected flag before accessing private port data after waking up.
This is is needed as the private port data (including the wait queue itself) can be gone when waking up after a disconnect.
--- drivers/usb/serial/ch341.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/usb/serial/ch341.c +6 -5
@@ -80,7 +80,6 @@ MODULE_DEVICE_TABLE(usb, id_table);struct ch341_private {spinlock_t lock;/* access lock */ -wait_queue_head_t delta_msr_wait;/* wait queue for modem status */ unsigned baud_rate;/* set baud rate */ u8 line_control;/* set line control value RTS/DTR */ u8 line_status;/* active status of modem control inputs */
@@ -252,7 +251,6 @@ static int ch341_port_probe(struct usb_sreturn -ENOMEM ;spin_lock_init (&priv->lock); -init_waitqueue_head (&priv->delta_msr_wait); priv->baud_rate =DEFAULT_BAUD_RATE ; priv->line_control =CH341_BIT_RTS |CH341_BIT_DTR ;
@@ -298,7 +296,7 @@ static void ch341_dtr_rts(struct usb_ser priv->line_control &= ~(CH341_BIT_RTS |CH341_BIT_DTR );spin_unlock_irqrestore (&priv->lock, flags);ch341_set_handshake (port->serial->dev, priv->line_control); -wake_up_interruptible (&priv->delta_msr_wait); +wake_up_interruptible (&port->delta_msr_wait); }static void ch341_close (struct usb_serial_port *port)
@@ -491,7 +489,7 @@ static void ch341_read_int_callback(strutty_kref_put (tty); } -wake_up_interruptible (&priv->delta_msr_wait); +wake_up_interruptible (&port->delta_msr_wait); } exit:
@@ -517,11 +515,14 @@ static int wait_modem_info(struct usb_sespin_unlock_irqrestore (&priv->lock, flags);while (!multi_change) { -interruptible_sleep_on (&priv->delta_msr_wait); +interruptible_sleep_on (&port->delta_msr_wait);/* see if a signal did it */ if (signal_pending (current))return -ERESTARTSYS ; +if (port->serial->disconnected) +return -EIO ; +spin_lock_irqsave (&priv->lock, flags); status = priv->line_status; multi_change = priv->multi_status_change;
Greg Kroah-Hartman
maintainerPATCH 71/124 USB: io_edgeport: fix use-after-free in TIOCMIWAIT
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 333576255d4cfc53efd056aad438568184b36af6 upstream.
Use the port wait queue and make sure to check the serial disconnected flag before accessing private port data after waking up.
This is is needed as the private port data (including the wait queue itself) can be gone when waking up after a disconnect.
--- drivers/usb/serial/io_edgeport.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/usb/serial/io_edgeport.c +7 -5
@@ -110,7 +110,6 @@ struct edgeport_port {wait_queue_head_t wait_chase;/* for handling sleeping while waiting for chase to finish */ wait_queue_head_t wait_open;/* for handling sleeping while waiting for open to finish */ wait_queue_head_t wait_command;/* for handling sleeping while waiting for command to finish */ -wait_queue_head_t delta_msr_wait;/* for handling sleeping while waiting for msr change to happen */ struct async_icount icount;struct usb_serial_port *port;/* loop back to the owner of this object */
@@ -884,7 +883,6 @@ static int edge_open(struct tty_struct */* initialize our wait queues */ init_waitqueue_head (&edge_port->wait_open);init_waitqueue_head (&edge_port->wait_chase); -init_waitqueue_head (&edge_port->delta_msr_wait);init_waitqueue_head (&edge_port->wait_command);/* initialize our icount structure */
@@ -1669,13 +1667,17 @@ static int edge_ioctl(struct tty_structdev_dbg (&port->dev,"%s (%d) TIOCMIWAIT\n" , __func__, port->number); cprev = edge_port->icount;while (1 ) { -prepare_to_wait (&edge_port->delta_msr_wait, +prepare_to_wait (&port->delta_msr_wait, &wait,TASK_INTERRUPTIBLE );schedule (); -finish_wait (&edge_port->delta_msr_wait, &wait); +finish_wait (&port->delta_msr_wait, &wait);/* see if a signal did it */ if (signal_pending (current))return -ERESTARTSYS ; + +if (port->serial->disconnected) +return -EIO ; + cnow = edge_port->icount;if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && cnow.dcd == cprev.dcd && cnow.cts == cprev.cts)
@@ -2055,7 +2057,7 @@ static void handle_new_msr(struct edgepo icount->dcd++;if (newMsr &EDGEPORT_MSR_DELTA_RI ) icount->rng++; -wake_up_interruptible (&edge_port->delta_msr_wait); +wake_up_interruptible (&edge_port->port->delta_msr_wait); }/* Save the new modem status */
Greg Kroah-Hartman
maintainerPATCH 72/124 USB: f81232: fix use-after-free in TIOCMIWAIT
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 508f940f1407656076a2e7d8f7fa059b567ecac2 upstream.
Use the port wait queue and make sure to check the serial disconnected flag before accessing private port data after waking up.
This is is needed as the private port data (including the wait queue itself) can be gone when waking up after a disconnect.
--- drivers/usb/serial/f81232.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/usb/serial/f81232.c +5 -4
@@ -47,7 +47,6 @@ MODULE_DEVICE_TABLE(usb, id_table);struct f81232_private {spinlock_t lock; -wait_queue_head_t delta_msr_wait;u8 line_control;u8 line_status; };
@@ -112,7 +111,7 @@ static void f81232_process_read_urb(stru line_status = priv->line_status; priv->line_status &= ~UART_STATE_TRANSIENT_MASK ;spin_unlock_irqrestore (&priv->lock, flags); -wake_up_interruptible (&priv->delta_msr_wait); +wake_up_interruptible (&port->delta_msr_wait);if (!urb->actual_length)return ;
@@ -261,11 +260,14 @@ static int wait_modem_info(struct usb_sespin_unlock_irqrestore (&priv->lock, flags);while (1 ) { -interruptible_sleep_on (&priv->delta_msr_wait); +interruptible_sleep_on (&port->delta_msr_wait);/* see if a signal did it */ if (signal_pending (current))return -ERESTARTSYS ; +if (port->serial->disconnected) +return -EIO ; +spin_lock_irqsave (&priv->lock, flags); status = priv->line_status;spin_unlock_irqrestore (&priv->lock, flags);
@@ -327,7 +329,6 @@ static int f81232_port_probe(struct usb_return -ENOMEM ;spin_lock_init (&priv->lock); -init_waitqueue_head (&priv->delta_msr_wait);usb_set_serial_port_data (port, priv);
Greg Kroah-Hartman
maintainerPATCH 73/124 USB: ark3116: fix use-after-free in TIOCMIWAIT
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 5018860321dc7a9e50a75d5f319bc981298fb5b7 upstream.
Use the port wait queue and make sure to check the serial disconnected flag before accessing private port data after waking up.
This is is needed as the private port data (including the wait queue itself) can be gone when waking up after a disconnect.
--- drivers/usb/serial/ark3116.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/usb/serial/ark3116.c +6 -4
@@ -62,7 +62,6 @@ static int is_irda(struct usb_serial *se }struct ark3116_private { -wait_queue_head_t delta_msr_wait;struct async_icount icount;int irda;/* 1 for irda device */
@@ -146,7 +145,6 @@ static int ark3116_port_probe(struct usbif (!priv)return -ENOMEM ; -init_waitqueue_head (&priv->delta_msr_wait);mutex_init (&priv->hw_lock);spin_lock_init (&priv->status_lock);
@@ -456,10 +454,14 @@ static int ark3116_ioctl(struct tty_strucase TIOCMIWAIT :for (;;) {struct async_icount prev = priv->icount; -interruptible_sleep_on (&priv->delta_msr_wait); +interruptible_sleep_on (&port->delta_msr_wait);/* see if a signal did it */ if (signal_pending (current))return -ERESTARTSYS ; + +if (port->serial->disconnected) +return -EIO ; + if ((prev.rng == priv->icount.rng) && (prev.dsr == priv->icount.dsr) && (prev.dcd == priv->icount.dcd) &&
@@ -580,7 +582,7 @@ static void ark3116_update_msr(struct us priv->icount.dcd++;if (msr &UART_MSR_TERI ) priv->icount.rng++; -wake_up_interruptible (&priv->delta_msr_wait); +wake_up_interruptible (&port->delta_msr_wait); } }
Greg Kroah-Hartman
maintainerPATCH 74/124 USB: mct_u232: fix use-after-free in TIOCMIWAIT
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit cf1d24443677a0758cfa88ca40f24858b89261c0 upstream.
Use the port wait queue and make sure to check the serial disconnected flag before accessing private port data after waking up.
This is is needed as the private port data (including the wait queue itself) can be gone when waking up after a disconnect.
--- drivers/usb/serial/mct_u232.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/usb/serial/mct_u232.c +7 -6
@@ -114,8 +114,6 @@ struct mct_u232_private {unsigned char last_msr;/* Modem Status Register */ unsigned int rx_flags;/* Throttling flags */ struct async_icount icount; -wait_queue_head_t msr_wait;/* for handling sleeping while waiting -for msr change to happen */ };#define THROTTLED 0x01
@@ -409,7 +407,6 @@ static int mct_u232_port_probe(struct usreturn -ENOMEM ;spin_lock_init (&priv->lock); -init_waitqueue_head (&priv->msr_wait);usb_set_serial_port_data (port, priv);
@@ -606,7 +603,7 @@ static void mct_u232_read_int_callback(s tty_kref_put(tty); }#endif -wake_up_interruptible (&priv->msr_wait); +wake_up_interruptible (&port->delta_msr_wait);spin_unlock_irqrestore (&priv->lock, flags); exit: retval =usb_submit_urb (urb,GFP_ATOMIC );
@@ -815,13 +812,17 @@ static int mct_u232_ioctl(struct tty_st cprev = mct_u232_port->icount;spin_unlock_irqrestore (&mct_u232_port->lock, flags);for ( ; ; ) { -prepare_to_wait (&mct_u232_port->msr_wait, +prepare_to_wait (&port->delta_msr_wait, &wait,TASK_INTERRUPTIBLE );schedule (); -finish_wait (&mct_u232_port->msr_wait, &wait); +finish_wait (&port->delta_msr_wait, &wait);/* see if a signal did it */ if (signal_pending (current))return -ERESTARTSYS ; + +if (port->serial->disconnected) +return -EIO ; +spin_lock_irqsave (&mct_u232_port->lock, flags); cnow = mct_u232_port->icount;spin_unlock_irqrestore (&mct_u232_port->lock, flags);
Greg Kroah-Hartman
maintainerPATCH 75/124 USB: cypress_m8: fix use-after-free in TIOCMIWAIT
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 356050d8b1e526db093e9d2c78daf49d6bf418e3 upstream.
Use the port wait queue and make sure to check the serial disconnected flag before accessing private port data after waking up.
This is is needed as the private port data (including the wait queue itself) can be gone when waking up after a disconnect.
Also remove bogus test for private data pointer being NULL as it is never assigned in the loop.
--- drivers/usb/serial/cypress_m8.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/usb/serial/cypress_m8.c +8 -6
@@ -111,7 +111,6 @@ struct cypress_private {int baud_rate;/* stores current baud rate in integer form */ int isthrottled;/* if throttled, discard reads */ -wait_queue_head_t delta_msr_wait;/* used for TIOCMIWAIT */ char prev_status, diff_status;/* used for TIOCMIWAIT */ /* we pass a pointer to this as the argument sent to cypress_set_termios old_termios */
@@ -449,7 +448,6 @@ static int cypress_generic_port_probe(stkfree (priv);return -ENOMEM ; } -init_waitqueue_head (&priv->delta_msr_wait);usb_reset_configuration (serial->dev);
@@ -868,12 +866,16 @@ static int cypress_ioctl(struct tty_struswitch (cmd) {/* This code comes from drivers/char/serial.c and ftdi_sio.c */ case TIOCMIWAIT : -while (priv !=NULL ) { -interruptible_sleep_on (&priv->delta_msr_wait); +for (;;) { +interruptible_sleep_on (&port->delta_msr_wait);/* see if a signal did it */ if (signal_pending (current))return -ERESTARTSYS ; -else { + +if (port->serial->disconnected) +return -EIO ; + + {char diff = priv->diff_status;if (diff ==0 )return -EIO ;/* no change => error */
@@ -1187,7 +1189,7 @@ static void cypress_read_int_callback(stif (priv->current_status != priv->prev_status) { priv->diff_status |= priv->current_status ^ priv->prev_status; -wake_up_interruptible (&priv->delta_msr_wait); +wake_up_interruptible (&port->delta_msr_wait); priv->prev_status = priv->current_status; }spin_unlock_irqrestore (&priv->lock, flags);
Greg Kroah-Hartman
maintainerPATCH 76/124 USB: ti_usb_3410_5052: fix use-after-free in TIOCMIWAIT
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit fc98ab873aa3dbe783ce56a2ffdbbe7c7609521a upstream.
Use the port wait queue and make sure to check the serial disconnected flag before accessing private port data after waking up.
This is is needed as the private port data (including the wait queue itself) can be gone when waking up after a disconnect.
--- drivers/usb/serial/ti_usb_3410_5052.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/usb/serial/ti_usb_3410_5052.c +6 -4
@@ -74,7 +74,6 @@ struct ti_port {int tp_flags;int tp_closing_wait;/* in .01 secs */ struct async_icount tp_icount; -wait_queue_head_t tp_msr_wait;/* wait for msr change */ wait_queue_head_t tp_write_wait;struct ti_device *tp_tdev;struct usb_serial_port *tp_port;
@@ -432,7 +431,6 @@ static int ti_port_probe(struct usb_serielse tport->tp_uart_base_addr =TI_UART2_BASE_ADDR ; tport->tp_closing_wait = closing_wait; -init_waitqueue_head (&tport->tp_msr_wait);init_waitqueue_head (&tport->tp_write_wait);if (kfifo_alloc (&tport->write_fifo,TI_WRITE_BUF_SIZE ,GFP_KERNEL )) {kfree (tport);
@@ -784,9 +782,13 @@ static int ti_ioctl(struct tty_struct *tdev_dbg (&port->dev,"%s - TIOCMIWAIT\n" , __func__); cprev = tport->tp_icount;while (1 ) { -interruptible_sleep_on (&tport->tp_msr_wait); +interruptible_sleep_on (&port->delta_msr_wait);if (signal_pending (current))return -ERESTARTSYS ; + +if (port->serial->disconnected) +return -EIO ; + cnow = tport->tp_icount;if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && cnow.dcd == cprev.dcd && cnow.cts == cprev.cts)
@@ -1400,7 +1402,7 @@ static void ti_handle_new_msr(struct ti_ icount->dcd++;if (msr &TI_MSR_DELTA_RI ) icount->rng++; -wake_up_interruptible (&tport->tp_msr_wait); +wake_up_interruptible (&tport->tp_port->delta_msr_wait);spin_unlock_irqrestore (&tport->tp_lock, flags); }
Greg Kroah-Hartman
maintainerPATCH 77/124 usb: gadget: udc-core: fix a regression during gadget driver unbinding
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit 511f3c5326eabe1ece35202a404c24c0aeacc246 upstream.
This patch (as1666) fixes a regression in the UDC core. The core takes care of unbinding gadget drivers, and it does the unbinding before telling the UDC driver to turn off the controller hardware. When the call to the udc_stop callback is made, the gadget no longer has a driver. The callback routine should not be invoked with a pointer to the old driver; doing so can cause problems (such as use-after-free accesses in net2280).
This patch should be applied, with appropriate context changes, to all the stable kernels going back to 3.1.
--- drivers/usb/gadget/udc-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/udc-core.c +1 -1
@@ -265,7 +265,7 @@ static void usb_gadget_remove_driver(strusb_gadget_disconnect (udc->gadget); udc->driver->disconnect (udc->gadget); udc->driver->unbind (udc->gadget); -usb_gadget_udc_stop (udc->gadget, udc->driver); +usb_gadget_udc_stop (udc->gadget,NULL ); }else {usb_gadget_stop (udc->gadget, udc->driver); }
Greg Kroah-Hartman
maintainerPATCH 78/124 signal: Define __ARCH_HAS_SA_RESTORER so we know whether to clear sa_restorer
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ben Hutchings <[email protected]>
Vaguely based on upstream commit 574c4866e33d 'consolidate kernel-side struct sigaction declarations'.
flush_signal_handlers() needs to know whether sigaction::sa_restorer is defined, not whether SA_RESTORER is defined. Define the __ARCH_HAS_SA_RESTORER macro to indicate this.
--- arch/arm/include/asm/signal.h | 1 + arch/avr32/include/asm/signal.h | 1 + arch/cris/include/asm/signal.h | 1 + arch/h8300/include/asm/signal.h | 1 + arch/m32r/include/asm/signal.h | 1 + arch/m68k/include/asm/signal.h | 1 + arch/mn10300/include/asm/signal.h | 1 + arch/powerpc/include/asm/signal.h | 1 + arch/s390/include/asm/signal.h | 1 + arch/sparc/include/asm/signal.h | 2 ++ arch/x86/include/asm/signal.h | 3 +++ arch/xtensa/include/asm/signal.h | 1 + include/uapi/asm-generic/signal.h | 4 ++++ 13 files changed, 19 insertions(+)
arch/arm/include/asm/signal.h +1 -0
@@ -29,6 +29,7 @@ struct sigaction {__sigrestore_t sa_restorer;sigset_t sa_mask;/* mask last for extensibility */ }; +#define __ARCH_HAS_SA_RESTORERstruct k_sigaction {struct sigaction sa;
arch/avr32/include/asm/signal.h +1 -0
@@ -29,6 +29,7 @@ struct sigaction {__sigrestore_t sa_restorer;sigset_t sa_mask;/* mask last for extensibility */ }; +#define __ARCH_HAS_SA_RESTORERstruct k_sigaction {struct sigaction sa;
arch/cris/include/asm/signal.h +1 -0
@@ -29,6 +29,7 @@ struct sigaction {void (*sa_restorer)(void );sigset_t sa_mask;/* mask last for extensibility */ }; +#define __ARCH_HAS_SA_RESTORERstruct k_sigaction {struct sigaction sa;
arch/h8300/include/asm/signal.h +1 -0
@@ -29,6 +29,7 @@ struct sigaction {void (*sa_restorer)(void );sigset_t sa_mask;/* mask last for extensibility */ }; +#define __ARCH_HAS_SA_RESTORERstruct k_sigaction {struct sigaction sa;
arch/m32r/include/asm/signal.h +1 -0
@@ -22,6 +22,7 @@ struct sigaction {__sigrestore_t sa_restorer;sigset_t sa_mask;/* mask last for extensibility */ }; +#define __ARCH_HAS_SA_RESTORERstruct k_sigaction {struct sigaction sa;
arch/m68k/include/asm/signal.h +1 -0
@@ -29,6 +29,7 @@ struct sigaction {__sigrestore_t sa_restorer;sigset_t sa_mask;/* mask last for extensibility */ }; +#define __ARCH_HAS_SA_RESTORERstruct k_sigaction {struct sigaction sa;
arch/mn10300/include/asm/signal.h +1 -0
@@ -39,6 +39,7 @@ struct sigaction {__sigrestore_t sa_restorer;sigset_t sa_mask;/* mask last for extensibility */ }; +#define __ARCH_HAS_SA_RESTORERstruct k_sigaction {struct sigaction sa;
arch/powerpc/include/asm/signal.h +1 -0
@@ -1,6 +1,7 @@#ifndef _ASM_POWERPC_SIGNAL_H#define _ASM_POWERPC_SIGNAL_H +#define __ARCH_HAS_SA_RESTORER#include <uapi/asm/signal.h> #endif /* _ASM_POWERPC_SIGNAL_H */
arch/s390/include/asm/signal.h +1 -0
@@ -34,6 +34,7 @@ struct sigaction {void (*sa_restorer)(void );sigset_t sa_mask;/* mask last for extensibility */ }; +#define __ARCH_HAS_SA_RESTORERstruct k_sigaction {struct sigaction sa;
arch/sparc/include/asm/signal.h +2 -0
@@ -26,5 +26,7 @@ struct k_sigaction {void __user *ka_restorer; }; +#define __ARCH_HAS_SA_RESTORER +#endif /* !(__ASSEMBLY__) */ #endif /* !(__SPARC_SIGNAL_H) */
arch/x86/include/asm/signal.h +3 -0
@@ -31,6 +31,9 @@ typedef sigset_t compat_sigset_t;#include <uapi/asm/signal.h> #ifndef __ASSEMBLY__ extern void do_notify_resume(struct pt_regs *, void *, __u32); + +#define __ARCH_HAS_SA_RESTORER + #ifdef __i386__ struct old_sigaction { __sighandler_t sa_handler;
arch/xtensa/include/asm/signal.h +1 -0
@@ -21,6 +21,7 @@ struct sigaction {void (*sa_restorer)(void );sigset_t sa_mask;/* mask last for extensibility */ }; +#define __ARCH_HAS_SA_RESTORERstruct k_sigaction {struct sigaction sa;
include/uapi/asm-generic/signal.h +4 -0
@@ -93,6 +93,10 @@ typedef unsigned long old_sigset_t;#include <asm-generic/signal-defs.h> +#ifdef SA_RESTORER +#define __ARCH_HAS_SA_RESTORER +#endif +struct sigaction {__sighandler_t sa_handler;unsigned long sa_flags;
Greg Kroah-Hartman
maintainerPATCH 79/124 kernel/signal.c: use __ARCH_HAS_SA_RESTORER instead of SA_RESTORER
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Morton <[email protected]>
commit 522cff142d7d2f9230839c9e1f21a4d8bcc22a4a upstream.
__ARCH_HAS_SA_RESTORER is the preferred conditional for use in 3.9 and later kernels, per Kees.
--- kernel/signal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/signal.c +1 -1
@@ -485,7 +485,7 @@ flush_signal_handlers(struct task_structif (force_default || ka->sa.sa_handler !=SIG_IGN ) ka->sa.sa_handler =SIG_DFL ; ka->sa.sa_flags =0 ; -#ifdef SA_RESTORER +#ifdef __ARCH_HAS_SA_RESTORER ka->sa.sa_restorer =NULL ;#endif sigemptyset (&ka->sa.sa_mask);
Greg Kroah-Hartman
maintainerPATCH 80/124 loop: prevent bdev freeing while device in use
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anatol Pomozov <[email protected]>
commit c1681bf8a7b1b98edee8b862a42c19c4e53205fd upstream.
struct block_device lifecycle is defined by its inode (see fs/block_dev.c) - block_device allocated first time we access /dev/loopXX and deallocated on bdev_destroy_inode. When we create the device "losetup /dev/loopXX afile" we want that block_device stay alive until we destroy the loop device with "losetup -d".
But because we do not hold /dev/loopXX inode its counter goes 0, and inode/bdev can be destroyed at any moment. Usually it happens at memory pressure or when user drops inode cache (like in the test below). When later in loop_clr_fd() we want to use bdev we have use-after-free error with following stack:
BUG: unable to handle kernel NULL pointer dereference at 0000000000000280 bd_set_size+0x10/0xa0 loop_clr_fd+0x1f8/0x420 [loop] lo_ioctl+0x200/0x7e0 [loop] lo_compat_ioctl+0x47/0xe0 [loop] compat_blkdev_ioctl+0x341/0x1290 do_filp_open+0x42/0xa0 compat_sys_ioctl+0xc1/0xf20 do_sys_open+0x16e/0x1d0 sysenter_dispatch+0x7/0x1a
To prevent use-after-free we need to grab the device in loop_set_fd() and put it later in loop_clr_fd().
The issue is reprodusible on current Linus head and v3.3. Here is the test:
dd if=/dev/zero of=loop.file bs=1M count=1
while [ true ]; do
losetup /dev/loop0 loop.file
echo 2 > /proc/sys/vm/drop_caches
losetup -d /dev/loop0
done
[ Doing bdgrab/bput in loop_set_fd/loop_clr_fd is safe, because every
time we call loop_set_fd() we check that loop_device->lo_state is Lo_unbound and set it to Lo_bound If somebody will try to set_fd again it will get EBUSY. And if we try to loop_clr_fd() on unbound loop device we'll get ENXIO.
loop_set_fd/loop_clr_fd (and any other loop ioctl) is called under loop_device->lo_ctl_mutex. ]
--- drivers/block/loop.c | 9 ++++++++- fs/block_dev.c | 1 + 2 files changed, 9 insertions(+), 1 deletion(-)
drivers/block/loop.c +8 -1
@@ -917,6 +917,11 @@ static int loop_set_fd(struct loop_devic lo->lo_flags |=LO_FLAGS_PARTSCAN ;if (lo->lo_flags &LO_FLAGS_PARTSCAN )ioctl_by_bdev (bdev,BLKRRPART ,0 ); + +/* Grab the block_device to prevent its destruction after we +* put /dev/loopXX inode. Later in loop_clr_fd() we bdput(bdev). +*/ +bdgrab (bdev);return 0 ; out_clr:
@@ -1026,8 +1031,10 @@ static int loop_clr_fd(struct loop_devicmemset (lo->lo_encrypt_key,0 ,LO_KEY_SIZE );memset (lo->lo_crypt_name,0 ,LO_NAME_SIZE );memset (lo->lo_file_name,0 ,LO_NAME_SIZE ); -if (bdev) +if (bdev) { +bdput (bdev);invalidate_bdev (bdev); + }set_capacity (lo->lo_disk,0 );loop_sysfs_exit (lo);if (bdev) {
fs/block_dev.c +1 -0
@@ -551,6 +551,7 @@ struct block_device *bdgrab(struct blockihold (bdev->bd_inode);return bdev; } +EXPORT_SYMBOL (bdgrab);long nr_blockdev_pages (void ) {
Greg Kroah-Hartman
maintainerPATCH 81/124 ARM: cns3xxx: fix mapping of private memory region
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mac Lin <[email protected]>
commit a3d9052c6296ad3398d3ad649c3c682c3e7ecfa6 upstream.
Since commit 0536bdf33faf (ARM: move iotable mappings within the vmalloc region), the Cavium CNS3xxx cannot boot anymore.
This is caused by the pre-defined iotable mappings is not in the vmalloc region. This patch move the iotable mappings into the vmalloc region, and merge the MPCore private memory region (containing the SCU, the GIC and the TWD) as a single region.
--- arch/arm/mach-cns3xxx/core.c | 16 +++------------- arch/arm/mach-cns3xxx/include/mach/cns3xxx.h | 16 ++++++++-------- 2 files changed, 11 insertions(+), 21 deletions(-)
arch/arm/mach-cns3xxx/core.c +3 -13
@@ -22,19 +22,9 @@static struct map_desc cns3xxx_io_desc[]__initdata = { { - .virtual =CNS3XXX_TC11MP_TWD_BASE_VIRT , - .pfn =__phys_to_pfn (CNS3XXX_TC11MP_TWD_BASE ), - .length =SZ_4K , - .type =MT_DEVICE , - }, { - .virtual =CNS3XXX_TC11MP_GIC_CPU_BASE_VIRT , - .pfn =__phys_to_pfn (CNS3XXX_TC11MP_GIC_CPU_BASE ), - .length =SZ_4K , - .type =MT_DEVICE , - }, { - .virtual =CNS3XXX_TC11MP_GIC_DIST_BASE_VIRT , - .pfn =__phys_to_pfn (CNS3XXX_TC11MP_GIC_DIST_BASE ), - .length =SZ_4K , + .virtual =CNS3XXX_TC11MP_SCU_BASE_VIRT , + .pfn =__phys_to_pfn (CNS3XXX_TC11MP_SCU_BASE ), + .length =SZ_8K , .type =MT_DEVICE , }, { .virtual =CNS3XXX_TIMER1_2_3_BASE_VIRT ,
arch/arm/mach-cns3xxx/include/mach/cns3xxx.h +8 -8
@@ -94,10 +94,10 @@#define RTC_INTR_STS_OFFSET 0x34#define CNS3XXX_MISC_BASE 0x76000000/* Misc Control */ -#define CNS3XXX_MISC_BASE_VIRT 0xFFF07000/* Misc Control */ +#define CNS3XXX_MISC_BASE_VIRT 0xFB000000/* Misc Control */ #define CNS3XXX_PM_BASE 0x77000000/* Power Management Control */ -#define CNS3XXX_PM_BASE_VIRT 0xFFF08000 +#define CNS3XXX_PM_BASE_VIRT 0xFB001000#define PM_CLK_GATE_OFFSET 0x00#define PM_SOFT_RST_OFFSET 0x04
@@ -109,7 +109,7 @@#define PM_PLL_HM_PD_OFFSET 0x1C#define CNS3XXX_UART0_BASE 0x78000000/* UART 0 */ -#define CNS3XXX_UART0_BASE_VIRT 0xFFF09000 +#define CNS3XXX_UART0_BASE_VIRT 0xFB002000#define CNS3XXX_UART1_BASE 0x78400000/* UART 1 */ #define CNS3XXX_UART1_BASE_VIRT 0xFFF0A000
@@ -130,7 +130,7 @@#define CNS3XXX_I2S_BASE_VIRT 0xFFF10000#define CNS3XXX_TIMER1_2_3_BASE 0x7C800000/* Timer */ -#define CNS3XXX_TIMER1_2_3_BASE_VIRT 0xFFF10800 +#define CNS3XXX_TIMER1_2_3_BASE_VIRT 0xFB003000#define TIMER1_COUNTER_OFFSET 0x00#define TIMER1_AUTO_RELOAD_OFFSET 0x04
@@ -227,16 +227,16 @@* Testchip peripheral and fpga gic regions */ #define CNS3XXX_TC11MP_SCU_BASE 0x90000000/* IRQ, Test chip */ -#define CNS3XXX_TC11MP_SCU_BASE_VIRT 0xFF000000 +#define CNS3XXX_TC11MP_SCU_BASE_VIRT 0xFB004000#define CNS3XXX_TC11MP_GIC_CPU_BASE 0x90000100/* Test chip interrupt controller CPU interface */ -#define CNS3XXX_TC11MP_GIC_CPU_BASE_VIRT 0xFF000100 +#define CNS3XXX_TC11MP_GIC_CPU_BASE_VIRT (CNS3XXX_TC11MP_SCU_BASE_VIRT + 0x100)#define CNS3XXX_TC11MP_TWD_BASE 0x90000600 -#define CNS3XXX_TC11MP_TWD_BASE_VIRT 0xFF000600 +#define CNS3XXX_TC11MP_TWD_BASE_VIRT (CNS3XXX_TC11MP_SCU_BASE_VIRT + 0x600)#define CNS3XXX_TC11MP_GIC_DIST_BASE 0x90001000/* Test chip interrupt controller distributor */ -#define CNS3XXX_TC11MP_GIC_DIST_BASE_VIRT 0xFF001000 +#define CNS3XXX_TC11MP_GIC_DIST_BASE_VIRT (CNS3XXX_TC11MP_SCU_BASE_VIRT + 0x1000)#define CNS3XXX_TC11MP_L220_BASE 0x92002000/* L220 registers */ #define CNS3XXX_TC11MP_L220_BASE_VIRT 0xFF002000
Greg Kroah-Hartman
maintainerPATCH 82/124 ARM: imx: fix sync issue between imx_cpu_die and imx_cpu_kill
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shawn Guo <[email protected]>
commit 2f3edfd7e27ad4206acbc2ae99c9df5f46353024 upstream.
There is a sync issue with hotplug operation. It's possible that when imx_cpu_kill gets running on primary core, the imx_cpu_die execution on the core which is to be killed hasn't been finished yet. The problem will very likely be hit when running suspend without no_console_suspend setting on kernel cmdline.
It uses cpu jumping argument register to sync imx_cpu_die and imx_cpu_kill. The register will be set in imx_cpu_die and imx_cpu_kill will wait for the register being cleared to actually kill the cpu.
--- arch/arm/mach-imx/common.h | 2 ++ arch/arm/mach-imx/hotplug.c | 12 ++++++++++++ arch/arm/mach-imx/src.c | 12 ++++++++++++ 3 files changed, 26 insertions(+)
arch/arm/mach-imx/common.h +2 -0
@@ -116,6 +116,8 @@ void tzic_handle_irq(struct pt_regs *);extern void imx_enable_cpu (int cpu,bool enable);extern void imx_set_cpu_jump (int cpu,void *jump_addr); +extern u32 imx_get_cpu_arg (int cpu); +extern void imx_set_cpu_arg (int cpu,u32 arg);#ifdef CONFIG_DEBUG_LL extern void imx_lluart_map_io (void );#else
arch/arm/mach-imx/hotplug.c +12 -0
@@ -46,11 +46,23 @@ static inline void cpu_enter_lowpower(vovoid imx_cpu_die (unsigned int cpu) {cpu_enter_lowpower (); +/* +* We use the cpu jumping argument register to sync with +* imx_cpu_kill() which is running on cpu0 and waiting for +* the register being cleared to kill the cpu. +*/ +imx_set_cpu_arg (cpu, ~0 );cpu_do_idle (); }int imx_cpu_kill (unsigned int cpu) { +unsigned long timeout = jiffies +msecs_to_jiffies (50 ); + +while (imx_get_cpu_arg (cpu) ==0 ) +if (time_after (jiffies, timeout)) +return 0 ;imx_enable_cpu (cpu, false); +imx_set_cpu_arg (cpu,0 );return 1 ; }
arch/arm/mach-imx/src.c +12 -0
@@ -43,6 +43,18 @@ void imx_set_cpu_jump(int cpu, void *jum src_base + SRC_GPR1 + cpu * 8); } +u32 imx_get_cpu_arg (int cpu) +{ + cpu =cpu_logical_map (cpu); +return readl_relaxed (src_base +SRC_GPR1 + cpu *8 +4 ); +} + +void imx_set_cpu_arg (int cpu,u32 arg) +{ + cpu =cpu_logical_map (cpu); +writel_relaxed (arg, src_base +SRC_GPR1 + cpu *8 +4 ); +} +void imx_src_prepare_restart (void ) {u32 val;
Greg Kroah-Hartman
maintainerPATCH 83/124 ARM: kirkwood: Fix chip-delay for GoFlex Net
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Hutter <[email protected]>
commit 2992714d431976c4b154875bd18ba61bf4df3b93 upstream.
This fixes "Too few good blocks within range" issues on GoFlex Net by setting chip-delay to 40.
The basic problem was discussed at http://forum.doozan.com/read.php?2,7451
--- arch/arm/boot/dts/kirkwood-goflexnet.dts | 1 + 1 file changed, 1 insertion(+)
arch/arm/boot/dts/kirkwood-goflexnet.dts +1 -0
@@ -77,6 +77,7 @@ }; nand@3000000 { + chip-delay = <40>; status = "okay"; partition@0 {
Greg Kroah-Hartman
maintainerPATCH 84/124 ARM: OMAP: clocks: Delay clk inits atleast until slab is initialized
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rajendra Nayak <[email protected]>
commit ff931c821bab6713a52b768b0cd7ee7e90713b36 upstream.
clk inits on OMAP happen quite early, even before slab is available. The dependency comes from the fact that the timer init code starts to use clocks and hwmod and we need clocks to be initialized by then.
There are various problems doing clk inits this early, one is, not being able to do dynamic clk registrations and hence the dependency on clk-private.h. The other is, inability to debug early kernel crashes without enabling DEBUG_LL and earlyprintk.
Doing early clk init also exposed another instance of a kernel panic due to a BUG() when CONFIG_DEBUG_SLAB is enabled.
[ 0.000000] Kernel BUG at c01174f8 [verbose debug info unavailable] [ 0.000000] Internal error: Oops - BUG: 0 [#1] SMP ARM [ 0.000000] Modules linked in: [ 0.000000] CPU: 0 Not tainted (3.9.0-rc1-12179-g72d48f9 #6) [ 0.000000] PC is at __kmalloc+0x1d4/0x248 [ 0.000000] LR is at __clk_init+0x2e0/0x364 [ 0.000000] pc : [<c01174f8>] lr : [<c0441f54>] psr: 600001d3 [ 0.000000] sp : c076ff28 ip : c065cefc fp : c0441f54 [ 0.000000] r10: 0000001c r9 : 000080d0 r8 : c076ffd4 [ 0.000000] r7 : c074b578 r6 : c0794d88 r5 : 00000040 r4 : 00000000 [ 0.000000] r3 : 00000000 r2 : c07cac70 r1 : 000080d0 r0 : 0000001c [ 0.000000] Flags: nZCv IRQs off FIQs off Mode SVC_32 ISA ARM Segment kernel [ 0.000000] Control: 10c53c7d Table: 8000404a DAC: 00000017 [ 0.000000] Process swapper (pid: 0, stack limit = 0xc076e240) [ 0.000000] Stack: (0xc076ff28 to 0xc0770000) [ 0.000000] ff20: 22222222 c0794ec8 c06546e8 00000000 00000040 c0794d88 [ 0.000000] ff40: c074b578 c076ffd4 c07951c8 c076e000 00000000 c0441f54 c074b578 c076ffd4 [ 0.000000] ff60: c0793828 00000040 c0794d88 c074b578 c076ffd4 c0776900 c076e000 c07272ac [ 0.000000] ff80: 2f800000 c074c968 c07f93d0 c0719780 c076ffa0 c076ff98 00000000 00000000 [ 0.000000] ffa0: 00000000 00000000 00000000 00000001 c074cd6c c077b1ec 8000406a c0715724 [ 0.000000] ffc0: 00000000 00000000 00000000 00000000 00000000 c074c968 10c53c7d c0776974 [ 0.000000] ffe0: c074cd6c c077b1ec 8000406a 411fc092 00000000 80008074 00000000 00000000 [ 0.000000] [<c01174f8>] (__kmalloc+0x1d4/0x248) from [<c0441f54>] (__clk_init+0x2e0/0x364) [ 0.000000] [<c0441f54>] (__clk_init+0x2e0/0x364) from [<c07272ac>] (omap4xxx_clk_init+0xbc/0x140) [ 0.000000] [<c07272ac>] (omap4xxx_clk_init+0xbc/0x140) from [<c0719780>] (setup_arch+0x15c/0x284) [ 0.000000] [<c0719780>] (setup_arch+0x15c/0x284) from [<c0715724>] (start_kernel+0x7c/0x334) [ 0.000000] [<c0715724>] (start_kernel+0x7c/0x334) from [<80008074>] (0x80008074) [ 0.000000] Code: e5883004 e1a00006 e28dd00c e8bd8ff0 (e7f001f2) [ 0.000000] ---[ end trace 1b75b31a2719ed1c ]--- [ 0.000000] Kernel panic - not syncing: Attempted to kill the idle task!
It was a know issue, that slab allocations would fail when common clock core tries to cache parent pointers for mux clocks on OMAP, and hence a patch 'clk: Allow late cache allocation for clk->parents, commit 7975059d' was added to work this problem around.
A BUG() within kmalloc() with CONFIG_DEBUG_SLAB enabled was completely overlooked causing this regression.
More details on the issue reported can be found here,
http://www.mail-archive.com/[email protected]/msg85932.html
With all these issues around clk inits happening way too early, it makes sense to at least move them to a point where dynamic memory allocations are possible. So move them to a point just before the timer code starts using clocks and hwmod.
This should at least pave way for clk inits on OMAP moving to dynamic clock registrations instead of using the static macros defined in clk-private.h.
The issue with kernel panic while CONFIG_DEBUG_SLAB is enabled was reported by Piotr Haber and Tony Lindgren and this patch fixes the reported issue as well.
--- arch/arm/mach-omap2/common.h | 3 +++ arch/arm/mach-omap2/io.c | 18 ++++++++++++------ arch/arm/mach-omap2/timer.c | 4 ++++ 3 files changed, 19 insertions(+), 6 deletions(-)
arch/arm/mach-omap2/common.h +3 -0
@@ -286,5 +286,8 @@ extern void omap_reserve(void);struct omap_hwmod ;extern int omap_dss_reset (struct omap_hwmod *); +/* SoC specific clock initializer */ +extern int (*omap_clk_init)(void ); +#endif /* __ASSEMBLER__ */ #endif /* __ARCH_ARM_MACH_OMAP2PLUS_COMMON_H */
arch/arm/mach-omap2/io.c +12 -6
@@ -55,6 +55,12 @@#include "prm44xx.h" /* +* omap_clk_init: points to a function that does the SoC-specific +* clock initializations +*/ +int (*omap_clk_init)(void ); + +/* * The machine specific code may provide the extra mapping besides the * default mapping provided here. */
@@ -397,7 +403,7 @@ void __init omap2420_init_early(void)omap242x_clockdomains_init ();omap2420_hwmod_init ();omap_hwmod_init_postsetup (); -omap2420_clk_init (); + omap_clk_init = omap2420_clk_init; }void __init omap2420_init_late (void )
@@ -427,7 +433,7 @@ void __init omap2430_init_early(void)omap243x_clockdomains_init ();omap2430_hwmod_init ();omap_hwmod_init_postsetup (); -omap2430_clk_init (); + omap_clk_init = omap2430_clk_init; }void __init omap2430_init_late (void )
@@ -462,7 +468,7 @@ void __init omap3_init_early(void)omap3xxx_clockdomains_init ();omap3xxx_hwmod_init ();omap_hwmod_init_postsetup (); -omap3xxx_clk_init (); + omap_clk_init = omap3xxx_clk_init; }void __init omap3430_init_early (void )
@@ -500,7 +506,7 @@ void __init ti81xx_init_early(void)omap3xxx_clockdomains_init ();omap3xxx_hwmod_init ();omap_hwmod_init_postsetup (); -omap3xxx_clk_init (); + omap_clk_init = omap3xxx_clk_init; }void __init omap3_init_late (void )
@@ -568,7 +574,7 @@ void __init am33xx_init_early(void)am33xx_clockdomains_init ();am33xx_hwmod_init ();omap_hwmod_init_postsetup (); - am33xx_clk_init(); + omap_clk_init = am33xx_clk_init; }#endif
@@ -593,7 +599,7 @@ void __init omap4430_init_early(void)omap44xx_clockdomains_init ();omap44xx_hwmod_init ();omap_hwmod_init_postsetup (); -omap4xxx_clk_init (); + omap_clk_init = omap4xxx_clk_init; }void __init omap4430_init_late (void )
arch/arm/mach-omap2/timer.c +4 -0
@@ -554,6 +554,8 @@ static inline void __init realtime_count clksrc_nr, clksrc_src) \ static void __init omap##name##_gptimer_timer_init(void) \ { \ + if (omap_clk_init) \ + omap_clk_init(); \ omap_dmtimer_init(); \ omap2_gp_clockevent_init((clkev_nr), clkev_src, clkev_prop); \ omap2_gptimer_clocksource_init((clksrc_nr), clksrc_src); \
@@ -563,6 +565,8 @@ static void __init omap##name##_gptimer_ clksrc_nr, clksrc_src) \ static void __init omap##name##_sync32k_timer_init(void) \ { \ + if (omap_clk_init) \ + omap_clk_init(); \ omap_dmtimer_init(); \ omap2_gp_clockevent_init((clkev_nr), clkev_src, clkev_prop); \ /* Enable the use of clocksource="gp_timer" kernel parameter */ \
Greg Kroah-Hartman
maintainerPATCH 85/124 virtio: console: rename cvq_lock to c_ivq_lock
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amit Shah <[email protected]>
commit 165b1b8bbc17c9469b053bab78b11b7cbce6d161 upstream.
The cvq_lock was taken for the c_ivq. Rename the lock to make that obvious.
We'll also add a lock around the c_ovq in the next commit, so there's no ambiguity.
--- drivers/char/virtio_console.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/char/virtio_console.c +9 -8
@@ -152,7 +152,7 @@ struct ports_device {spinlock_t ports_lock;/* To protect the vq operations for the control channel */ -spinlock_t cvq_lock; +spinlock_t c_ivq_lock;/* The current config space is stored here */ struct virtio_console_config config;
@@ -1715,23 +1715,23 @@ static void control_work_handler(struct portdev = container_of(work, struct ports_device, control_work); vq = portdev->c_ivq; -spin_lock (&portdev->cvq_lock); +spin_lock (&portdev->c_ivq_lock);while ((buf =virtqueue_get_buf (vq, &len))) { -spin_unlock (&portdev->cvq_lock); +spin_unlock (&portdev->c_ivq_lock); buf->len = len; buf->offset =0 ;handle_control_message (portdev, buf); -spin_lock (&portdev->cvq_lock); +spin_lock (&portdev->c_ivq_lock);if (add_inbuf (portdev->c_ivq, buf) <0 ) {dev_warn (&portdev->vdev->dev,"Error adding buffer to queue\n" );free_buf (buf, false); } } -spin_unlock (&portdev->cvq_lock); +spin_unlock (&portdev->c_ivq_lock); }static void out_intr (struct virtqueue *vq)
@@ -1996,10 +1996,11 @@ static int virtcons_probe(struct virtio_if (multiport) {unsigned int nr_added_bufs; -spin_lock_init (&portdev->cvq_lock); +spin_lock_init (&portdev->c_ivq_lock);INIT_WORK (&portdev->control_work, &control_work_handler); - nr_added_bufs =fill_queue (portdev->c_ivq, &portdev->cvq_lock); + nr_added_bufs =fill_queue (portdev->c_ivq, + &portdev->c_ivq_lock);if (!nr_added_bufs) {dev_err (&vdev->dev,"Error allocating buffers for control queue\n" );
@@ -2150,7 +2151,7 @@ static int virtcons_restore(struct virtireturn ret;if (use_multiport (portdev)) -fill_queue (portdev->c_ivq, &portdev->cvq_lock); +fill_queue (portdev->c_ivq, &portdev->c_ivq_lock);list_for_each_entry (port, &portdev->ports, list) { port->in_vq = portdev->in_vqs[port->id];
Greg Kroah-Hartman
maintainerPATCH 86/124 virtio: console: add locking around c_ovq operations
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amit Shah <[email protected]>
commit 9ba5c80b1aea8648a3efe5f22dc1f7cacdfbeeb8 upstream.
When multiple ovq operations are being performed (lots of open/close operations on virtio_console fds), the __send_control_msg() function can get confused without locking.
A simple recipe to cause badness is:
* create a QEMU VM with two virtio-serial ports
* in the guest, do
while true;do echo abc >/dev/vport0p1;done
while true;do echo edf >/dev/vport0p2;done
In one run, this caused a panic in __send_control_msg(). In another, I got
virtio_console virtio0: control-o:id 0 is not a head!
This also results repeated messages similar to these on the host:
qemu-kvm: virtio-serial-bus: Unexpected port id 478762112 for device virtio-serial-bus.0
qemu-kvm: virtio-serial-bus: Unexpected port id 478762368 for device virtio-serial-bus.0
--- drivers/char/virtio_console.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/char/virtio_console.c +5 -0
@@ -153,6 +153,7 @@ struct ports_device {/* To protect the vq operations for the control channel */ spinlock_t c_ivq_lock; +spinlock_t c_ovq_lock;/* The current config space is stored here */ struct virtio_console_config config;
@@ -575,11 +576,14 @@ static ssize_t __send_control_msg(struct vq = portdev->c_ovq;sg_init_one (sg, &cpkt,sizeof (cpkt)); + +spin_lock (&portdev->c_ovq_lock);if (virtqueue_add_buf (vq, sg,1 ,0 , &cpkt,GFP_ATOMIC ) ==0 ) {virtqueue_kick (vq);while (!virtqueue_get_buf (vq, &len))cpu_relax (); } +spin_unlock (&portdev->c_ovq_lock);return 0 ; }
@@ -1997,6 +2001,7 @@ static int virtcons_probe(struct virtio_unsigned int nr_added_bufs;spin_lock_init (&portdev->c_ivq_lock); +spin_lock_init (&portdev->c_ovq_lock);INIT_WORK (&portdev->control_work, &control_work_handler); nr_added_bufs = fill_queue(portdev->c_ivq,
Greg Kroah-Hartman
maintainerPATCH 87/124 nfsd4: reject "negative" acl lengths
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: "J. Bruce Fields" <[email protected]>
commit 64a817cfbded8674f345d1117b117f942a351a69 upstream.
Since we only enforce an upper bound, not a lower bound, a "negative" length can get through here.
The symptom seen was a warning when we attempt to a kmalloc with an excessive size.
--- fs/nfsd/nfs4xdr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfsd/nfs4xdr.c +1 -1
@@ -264,7 +264,7 @@ nfsd4_decode_fattr(struct nfsd4_compound iattr->ia_valid |=ATTR_SIZE ; }if (bmval[0 ] &FATTR4_WORD0_ACL ) { -int nace; +u32 nace;struct nfs4_ace *ace;READ_BUF (4 ); len +=4 ;
Greg Kroah-Hartman
maintainerPATCH 88/124 drm/i915: Use the fixed pixel clock for eDP in intel_dp_set_m_n()
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 9d1a455b0ca1c2c956b4d9ab212864a8695270f1 upstream.
The eDP output on HP Z1 is still broken when X is started even after fixing the infinite link-train loop. The regression was introduced in 3.6 kernel for cleaning up the mode clock handling code in intel_dp.c by the commit [71244653: drm/i915: adjusted_mode->clock in the dp mode_fix].
In the past, the clock of the reference mode was modified in intel_dp_mode_fixup() in the case of eDP fixed clock, and this clock was used for calculating in intel_dp_set_m_n(). This override was removed, thus the wrong mode clock is used for the calculation, resulting in a psychedelic smoking output in the end.
This patch corrects the clock to be used in the place.
v1->v2: Use intel_edp_target_clock() for checking eDP fixed clock instead of open code as in ironlake_set_m_n().
Backported for 3.8-stable. Reverted refactoring in e69d0bc1.
--- drivers/gpu/drm/i915/intel_dp.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_dp.c +11 -1
@@ -788,6 +788,7 @@ intel_dp_set_m_n(struct drm_crtc *crtc,struct intel_dp_m_n m_n;int pipe = intel_crtc->pipe;enum transcoder cpu_transcoder = intel_crtc->cpu_transcoder; +int target_clock;/* * Find the lane count in the intel_encoder private
@@ -803,13 +804,22 @@ intel_dp_set_m_n(struct drm_crtc *crtc, } } + target_clock = mode->clock; +for_each_encoder_on_crtc (dev, crtc, intel_encoder) { +if (intel_encoder->type ==INTEL_OUTPUT_EDP ) { + target_clock =intel_edp_target_clock (intel_encoder, + mode); +break ; + } + } +/* * Compute the GMCH and Link ratios. The '3' here is * the number of bytes_per_pixel post-LUT, which we always * set up for 8-bits of R/G/B, or 3 bytes total. */ intel_dp_compute_m_n (intel_crtc->bpp, lane_count, - mode->clock, adjusted_mode->clock, &m_n); + target_clock, adjusted_mode->clock, &m_n);if (IS_HASWELL (dev)) { I915_WRITE(PIPE_DATA_M1(cpu_transcoder),
Greg Kroah-Hartman
maintainerPATCH 89/124 drm/i915: Dont clobber crtc->fb when queue_flip fails
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ville Syrjälä <[email protected]>
commit 4a35f83b2b7c6aae3fc0d1c4554fdc99dc33ad07 upstream.
Restore crtc->fb to the old framebuffer if queue_flip fails.
While at it, kill the pointless intel_fb temp variable.
v2: Update crtc->fb before queue_flip and restore it back
after a failure.
Backported for 3.8-stable. Restored an atomic_sub removed in 3.9 ca9c46.
--- drivers/gpu/drm/i915/intel_display.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/intel_display.c +4 -7
@@ -7420,8 +7420,8 @@ static int intel_crtc_page_flip(struct d {struct drm_device *dev = crtc->dev;struct drm_i915_private *dev_priv = dev->dev_private; -struct intel_framebuffer *intel_fb; -struct drm_i915_gem_object *obj; +struct drm_framebuffer *old_fb = crtc->fb; +struct drm_i915_gem_object *obj =to_intel_framebuffer (fb)->obj;struct intel_crtc *intel_crtc =to_intel_crtc (crtc);struct intel_unpin_work *work;unsigned long flags;
@@ -7446,8 +7446,7 @@ static int intel_crtc_page_flip(struct d work->event = event; work->crtc = crtc; - intel_fb =to_intel_framebuffer (crtc->fb); - work->old_fb_obj = intel_fb->obj; + work->old_fb_obj =to_intel_framebuffer (old_fb)->obj;INIT_WORK (&work->work, intel_unpin_work_fn); ret =drm_vblank_get (dev, intel_crtc->pipe);
@@ -7467,9 +7466,6 @@ static int intel_crtc_page_flip(struct d intel_crtc->unpin_work = work;spin_unlock_irqrestore (&dev->event_lock, flags); - intel_fb =to_intel_framebuffer (fb); - obj = intel_fb->obj; -if (atomic_read (&intel_crtc->unpin_work_count) >=2 )flush_workqueue (dev_priv->wq);
@@ -7507,6 +7503,7 @@ static int intel_crtc_page_flip(struct d cleanup_pending:atomic_dec (&intel_crtc->unpin_work_count); + crtc->fb = old_fb;atomic_sub (1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);drm_gem_object_unreference (&work->old_fb_obj->base);drm_gem_object_unreference (&obj->base);
Greg Kroah-Hartman
maintainerPATCH 90/124 iwlwifi: dvm: dont send HCMD in restart flow
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Emmanuel Grumbach <[email protected]>
commit 2d5d50ee596361566f7f84300117cba7d7672bc5 upstream.
There is a race between the restart flow and the workers. The workers are cancelled after the fw is already killed and might send HCMD when there is fw to handle them. Simply check that there is a fw to which the HCMD can be sent before actually sending it.
--- drivers/net/wireless/iwlwifi/dvm/lib.c | 9 +++++++++ drivers/net/wireless/iwlwifi/dvm/ucode.c | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-)
drivers/net/wireless/iwlwifi/dvm/lib.c +9 -0
@@ -1262,6 +1262,15 @@ int iwl_dvm_send_cmd(struct iwl_priv *pr }/* +* This can happen upon FW ASSERT: we clear the STATUS_FW_ERROR flag +* in iwl_down but cancel the workers only later. +*/ +if (!priv->ucode_loaded) { +IWL_ERR (priv,"Fw not loaded - dropping CMD: %x\n" , cmd->id); +return -EIO ; + } + +/* * Synchronous commands from this op-mode must hold * the mutex, this ensures we don't try to send two * (or more) synchronous commands at a time.
drivers/net/wireless/iwlwifi/dvm/ucode.c +2 -2
@@ -450,6 +450,8 @@ int iwl_load_ucode_wait_alive(struct iwlreturn -EIO ; } + priv->ucode_loaded = true; +/* * This step takes a long time (60-80ms!!) and * WoWLAN image should be loaded quickly, so
@@ -474,8 +476,6 @@ int iwl_load_ucode_wait_alive(struct iwlreturn ret; } - priv->ucode_loaded = true; -return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 91/124 Btrfs: fix space leak when we fail to reserve metadata space
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
commit f4881bc7a83eff263789dd524b7c269d138d4af5 upstream.
Dave reported a warning when running xfstest 275. We have been leaking delalloc metadata space when our reservations fail. This is because we were improperly calculating how much space to free for our checksum reservations. The problem is we would sometimes free up space that had already been freed in another thread and we would end up with negative usage for the delalloc space. This patch fixes the problem by calculating how much space the other threads would have already freed, and then calculate how much space we need to free had we not done the reservation at all, and then freeing any excess space. This makes xfstests 275 no longer have leaked space. Thanks
--- fs/btrfs/extent-tree.c | 47 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-)
fs/btrfs/extent-tree.c +41 -6
@@ -4601,14 +4601,49 @@ int btrfs_delalloc_reserve_metadata(stru* If the inodes csum_bytes is the same as the original * csum_bytes then we know we haven't raced with any free()ers * so we can just reduce our inodes csum bytes and carry on. -* Otherwise we have to do the normal free thing to account for -* the case that the free side didn't free up its reserve -* because of this outstanding reservation. */ -if (BTRFS_I (inode)->csum_bytes == csum_bytes) +if (BTRFS_I (inode)->csum_bytes == csum_bytes) {calc_csum_metadata_size (inode, num_bytes,0 ); -else - to_free =calc_csum_metadata_size (inode, num_bytes,0 ); + }else { +u64 orig_csum_bytes =BTRFS_I (inode)->csum_bytes; +u64 bytes; + +/* +* This is tricky, but first we need to figure out how much we +* free'd from any free-ers that occured during this +* reservation, so we reset ->csum_bytes to the csum_bytes +* before we dropped our lock, and then call the free for the +* number of bytes that were freed while we were trying our +* reservation. +*/ + bytes = csum_bytes -BTRFS_I (inode)->csum_bytes; +BTRFS_I (inode)->csum_bytes = csum_bytes; + to_free =calc_csum_metadata_size (inode, bytes,0 ); + + +/* +* Now we need to see how much we would have freed had we not +* been making this reservation and our ->csum_bytes were not +* artificially inflated. +*/ +BTRFS_I (inode)->csum_bytes = csum_bytes - num_bytes; + bytes = csum_bytes - orig_csum_bytes; + bytes =calc_csum_metadata_size (inode, bytes,0 ); + +/* +* Now reset ->csum_bytes to what it should be. If bytes is +* more than to_free then we would have free'd more space had we +* not had an artificially high ->csum_bytes, so we need to free +* the remainder. If bytes is the same or less then we don't +* need to do anything, the other free-ers did the correct +* thing. +*/ +BTRFS_I (inode)->csum_bytes = orig_csum_bytes - num_bytes; +if (bytes > to_free) + to_free = bytes - to_free; +else + to_free =0 ; + }spin_unlock (&BTRFS_I (inode)->lock);if (dropped) to_free +=btrfs_calc_trans_metadata_size (root, dropped);
Greg Kroah-Hartman
maintainerPATCH 92/124 xen/events: avoid race with raising an event in unmask_evtchn()
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Vrabel <[email protected]>
commit c26377e62f4e6bfb4d99ef88526047209701a83f upstream.
In unmask_evtchn(), when the mask bit is cleared after testing for pending and the event becomes pending between the test and clear, then the upcall will not become pending and the event may be lost or delayed.
Avoid this by always clearing the mask bit before checking for pending. If a hypercall is needed, remask the event as EVTCHNOP_unmask will only retrigger pending events if they were masked.
This fixes a regression introduced in 3.7 by b5e579232d635b79a3da052964cb357ccda8d9ea (xen/events: fix unmask_evtchn for PV on HVM guests) which reordered the clear mask and check pending operations.
Changes in v2:
- set mask before hypercall.
--- drivers/xen/events.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
drivers/xen/events.c +15 -5
@@ -388,11 +388,23 @@ static void unmask_evtchn(int port)if (unlikely ((cpu !=cpu_from_evtchn (port)))) do_hypercall =1 ; -else +else { +/* +* Need to clear the mask before checking pending to +* avoid a race with an event becoming pending. +* +* EVTCHNOP_unmask will only trigger an upcall if the +* mask bit was set, so if a hypercall is needed +* remask the event. +*/ +sync_clear_bit (port, &s->evtchn_mask[0 ]); evtchn_pending =sync_test_bit (port, &s->evtchn_pending[0 ]); -if (unlikely (evtchn_pending &&xen_hvm_domain ())) - do_hypercall =1 ; +if (unlikely (evtchn_pending &&xen_hvm_domain ())) { +sync_set_bit (port, &s->evtchn_mask[0 ]); + do_hypercall =1 ; + } + }/* Slow path (hypercall) if this is a non-local port or if this is * an hvm domain and an event is pending (hvm domains don't have
@@ -403,8 +415,6 @@ static void unmask_evtchn(int port) }else {struct vcpu_info *vcpu_info =__this_cpu_read (xen_vcpu); -sync_clear_bit (port, &s->evtchn_mask[0 ]); -/* * The following is basically the equivalent of * 'hw_resend_irq'. Just like a real IO-APIC we 'lose
Greg Kroah-Hartman
maintainerPATCH 93/124 tracing: Prevent buffer overwrite disabled for latency tracers
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Steven Rostedt (Red Hat)" <[email protected]>
commit 613f04a0f51e6e68ac6fe571ab79da3c0a5eb4da upstream.
The latency tracers require the buffers to be in overwrite mode, otherwise they get screwed up. Force the buffers to stay in overwrite mode when latency tracers are enabled.
Added a flag_changed() method to the tracer structure to allow the tracers to see what flags are being changed, and also be able to prevent the change from happing.
--- kernel/trace/trace.c | 38 ++++++++++++++++++++++++++++++++------ kernel/trace/trace.h | 6 ++++++ kernel/trace/trace_irqsoff.c | 19 ++++++++++++++----- kernel/trace/trace_sched_wakeup.c | 18 +++++++++++++----- 4 files changed, 65 insertions(+), 16 deletions(-)
kernel/trace/trace.c +32 -6
@@ -2836,11 +2836,25 @@ static int set_tracer_option(struct tracreturn -EINVAL ; } -static void set_tracer_flags (unsigned int mask,int enabled) +/* Some tracers require overwrite to stay enabled */ +int trace_keep_overwrite (struct tracer *tracer,u32 mask,int set) +{ +if (tracer->enabled && (mask &TRACE_ITER_OVERWRITE ) && !set) +return -1 ; + +return 0 ; +} + +int set_tracer_flag (unsigned int mask,int enabled) {/* do nothing if flag is already set */ if (!!(trace_flags & mask) == !!enabled) -return ; +return 0 ; + +/* Give the tracer a chance to approve the change */ +if (current_trace->flag_changed) +if (current_trace->flag_changed (current_trace, mask, !!enabled)) +return -EINVAL ;if (enabled) trace_flags |= mask;
@@ -2859,13 +2873,15 @@ static void set_tracer_flags(unsigned inif (mask ==TRACE_ITER_PRINTK )trace_printk_start_stop_comm (enabled); + +return 0 ; }static int trace_set_options (char *option) {char *cmp;int neg =0 ; -int ret =0 ; +int ret = -ENODEV ;int i; cmp =strstrip (option);
@@ -2879,7 +2895,7 @@ static int trace_set_options(char *optiofor (i =0 ; trace_options[i]; i++) {if (strcmp (cmp, trace_options[i]) ==0 ) { -set_tracer_flags (1 << i, !neg); + ret =set_tracer_flag (1 << i, !neg);break ; } }
@@ -2898,6 +2914,7 @@ tracing_trace_options_write(struct file size_t cnt, loff_t *ppos) { char buf[64]; +int ret;if (cnt >=sizeof (buf))return -EINVAL ;
@@ -2907,7 +2924,9 @@ tracing_trace_options_write(struct file buf[cnt] =0 ; -trace_set_options (buf); + ret =trace_set_options (buf); +if (ret <0 ) +return ret; *ppos += cnt;
@@ -3213,6 +3232,9 @@ static int tracing_set_tracer(const char goto out;trace_branch_disable (); + + current_trace->enabled = false; +if (current_trace && current_trace->reset) current_trace->reset (tr);if (current_trace && current_trace->use_max_tr) {
@@ -3244,6 +3266,7 @@ static int tracing_set_tracer(const char } current_trace = t; + current_trace->enabled = true;trace_branch_enable (tr); out:mutex_unlock (&trace_types_lock);
@@ -4648,9 +4671,12 @@ trace_options_core_write(struct file *fireturn -EINVAL ;mutex_lock (&trace_types_lock); -set_tracer_flags (1 << index, val); + ret =set_tracer_flag (1 << index, val);mutex_unlock (&trace_types_lock); +if (ret <0 ) +return ret; + *ppos += cnt;return cnt;
kernel/trace/trace.h +6 -0
@@ -283,10 +283,14 @@ struct tracer {enum print_line_t (*print_line)(struct trace_iterator *iter);/* If you handled the flag setting, return 0 */ int (*set_flag)(u32 old_flags,u32 bit,int set); +/* Return 0 if OK with change, else return non-zero */ +int (*flag_changed)(struct tracer *tracer, +u32 mask,int set);struct tracer *next;struct tracer_flags *flags;bool print_max;bool use_max_tr; +bool enabled; };
@@ -835,6 +839,8 @@ extern const char *__stop___trace_bprintvoid trace_printk_init_buffers (void );void trace_printk_start_comm (void ); +int trace_keep_overwrite (struct tracer *tracer,u32 mask,int set); +int set_tracer_flag (unsigned int mask,int enabled);#undef FTRACE_ENTRY#define FTRACE_ENTRY (call, struct_name, id, tstruct, print, filter) \
kernel/trace/trace_irqsoff.c +14 -5
@@ -32,7 +32,7 @@ enum {static int trace_type__read_mostly ; -static int save_lat_flag; +static int save_flags;static void stop_irqsoff_tracer (struct trace_array *tr,int graph);static int start_irqsoff_tracer (struct trace_array *tr,int graph);
@@ -558,8 +558,11 @@ static void stop_irqsoff_tracer(struct tstatic void __irqsoff_tracer_init (struct trace_array *tr) { - save_lat_flag = trace_flags &TRACE_ITER_LATENCY_FMT ; - trace_flags |=TRACE_ITER_LATENCY_FMT ; + save_flags = trace_flags; + +/* non overwrite screws up the latency tracers */ +set_tracer_flag (TRACE_ITER_OVERWRITE ,1 ); +set_tracer_flag (TRACE_ITER_LATENCY_FMT ,1 ); tracing_max_latency =0 ; irqsoff_trace = tr;
@@ -573,10 +576,13 @@ static void __irqsoff_tracer_init(structstatic void irqsoff_tracer_reset (struct trace_array *tr) { +int lat_flag = save_flags &TRACE_ITER_LATENCY_FMT ; +int overwrite_flag = save_flags &TRACE_ITER_OVERWRITE ; +stop_irqsoff_tracer (tr,is_graph ()); -if (!save_lat_flag) - trace_flags &= ~TRACE_ITER_LATENCY_FMT ; +set_tracer_flag (TRACE_ITER_LATENCY_FMT , lat_flag); +set_tracer_flag (TRACE_ITER_OVERWRITE , overwrite_flag); }static void irqsoff_tracer_start (struct trace_array *tr)
@@ -609,6 +615,7 @@ static struct tracer irqsoff_tracer __re .print_line = irqsoff_print_line, .flags = &tracer_flags, .set_flag = irqsoff_set_flag, + .flag_changed = trace_keep_overwrite,#ifdef CONFIG_FTRACE_SELFTEST .selftest = trace_selftest_startup_irqsoff,#endif
@@ -642,6 +649,7 @@ static struct tracer preemptoff_tracer _ .print_line = irqsoff_print_line, .flags = &tracer_flags, .set_flag = irqsoff_set_flag, + .flag_changed = trace_keep_overwrite,#ifdef CONFIG_FTRACE_SELFTEST .selftest = trace_selftest_startup_preemptoff,#endif
@@ -677,6 +685,7 @@ static struct tracer preemptirqsoff_trac .print_line = irqsoff_print_line, .flags = &tracer_flags, .set_flag = irqsoff_set_flag, + .flag_changed = trace_keep_overwrite,#ifdef CONFIG_FTRACE_SELFTEST .selftest = trace_selftest_startup_preemptirqsoff,#endif
kernel/trace/trace_sched_wakeup.c +13 -5
@@ -36,7 +36,7 @@ static void __wakeup_reset(struct trace_static int wakeup_graph_entry (struct ftrace_graph_ent *trace);static void wakeup_graph_return (struct ftrace_graph_ret *trace); -static int save_lat_flag; +static int save_flags;#define TRACE_DISPLAY_GRAPH 1
@@ -540,8 +540,11 @@ static void stop_wakeup_tracer(struct trstatic int __wakeup_tracer_init (struct trace_array *tr) { - save_lat_flag = trace_flags &TRACE_ITER_LATENCY_FMT ; - trace_flags |=TRACE_ITER_LATENCY_FMT ; + save_flags = trace_flags; + +/* non overwrite screws up the latency tracers */ +set_tracer_flag (TRACE_ITER_OVERWRITE ,1 ); +set_tracer_flag (TRACE_ITER_LATENCY_FMT ,1 ); tracing_max_latency =0 ; wakeup_trace = tr;
@@ -563,12 +566,15 @@ static int wakeup_rt_tracer_init(structstatic void wakeup_tracer_reset (struct trace_array *tr) { +int lat_flag = save_flags &TRACE_ITER_LATENCY_FMT ; +int overwrite_flag = save_flags &TRACE_ITER_OVERWRITE ; +stop_wakeup_tracer (tr);/* make sure we put back any tasks we are tracing */ wakeup_reset (tr); -if (!save_lat_flag) - trace_flags &= ~TRACE_ITER_LATENCY_FMT ; +set_tracer_flag (TRACE_ITER_LATENCY_FMT , lat_flag); +set_tracer_flag (TRACE_ITER_OVERWRITE , overwrite_flag); }static void wakeup_tracer_start (struct trace_array *tr)
@@ -594,6 +600,7 @@ static struct tracer wakeup_tracer __rea .print_line = wakeup_print_line, .flags = &tracer_flags, .set_flag = wakeup_set_flag, + .flag_changed = trace_keep_overwrite,#ifdef CONFIG_FTRACE_SELFTEST .selftest = trace_selftest_startup_wakeup,#endif
@@ -615,6 +622,7 @@ static struct tracer wakeup_rt_tracer __ .print_line = wakeup_print_line, .flags = &tracer_flags, .set_flag = wakeup_set_flag, + .flag_changed = trace_keep_overwrite,#ifdef CONFIG_FTRACE_SELFTEST .selftest = trace_selftest_startup_wakeup,#endif
Greg Kroah-Hartman
maintainerPATCH 94/124 efivars: explicitly calculate length of VariableName
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matt Fleming <[email protected]>
commit ec50bd32f1672d38ddce10fb1841cbfda89cfe9a upstream.
It's not wise to assume VariableNameSize represents the length of VariableName, as not all firmware updates VariableNameSize in the same way (some don't update it at all if EFI_SUCCESS is returned). There are even implementations out there that update VariableNameSize with values that are both larger than the string returned in VariableName and smaller than the buffer passed to GetNextVariableName(), which resulted in the following bug report from Michael Schroeder,
Quoted 8 lines
On HP z220 system (firmware version 1.54), some EFI variables are incorrectly named :
ls -d
/sys/firmware/efi/vars/*8be4d*| grep -v -- -8be returns/sys/firmware/efi/vars/dbxDefault-pport8be4df61-93ca-11d2-aa0d-00e098032b8c/sys/firmware/efi/vars/KEKDefault-pport8be4df61-93ca-11d2-aa0d-00e098032b8c/sys/firmware/efi/vars/SecureBoot-pport8be4df61-93ca-11d2-aa0d-00e098032b8c/sys/firmware/efi/vars/SetupMode-Information8be4df61-93ca-11d2-aa0d-00e098032b8c
The issue here is that because we blindly use VariableNameSize without verifying its value, we can potentially read garbage values from the buffer containing VariableName if VariableNameSize is larger than the length of VariableName.
Since VariableName is a string, we can calculate its size by searching for the terminating NULL character.
[Backported for 3.8-stable. Removed workqueue code added in a93bc0c 3.9-rc1.]
--- drivers/firmware/efivars.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
drivers/firmware/efivars.c +27 -0
@@ -1670,6 +1670,31 @@ static ssize_t efivar_delete(struct file }/* +* Returns the size of variable_name, in bytes, including the +* terminating NULL character, or variable_name_size if no NULL +* character is found among the first variable_name_size bytes. +*/ +static unsigned long var_name_strnsize (efi_char16_t *variable_name, +unsigned long variable_name_size) +{ +unsigned long len; +efi_char16_t c; + +/* +* The variable name is, by definition, a NULL-terminated +* string, so make absolutely sure that variable_name_size is +* the value we expect it to be. If not, return the real size. +*/ +for (len =2 ; len <= variable_name_size; len +=sizeof (c)) { + c = variable_name[(len /sizeof (c)) -1 ]; +if (!c) +break ; + } + +return min (len, variable_name_size); +} + +/* * Let's not leave out systab information that snuck into * the efivars driver */
@@ -1912,6 +1937,8 @@ int register_efivars(struct efivars *efi &vendor_guid);switch (status) {case EFI_SUCCESS : + variable_name_size =var_name_strnsize (variable_name, + variable_name_size); efivar_create_sysfs_entry(efivars, variable_name_size, variable_name,
Greg Kroah-Hartman
maintainerPATCH 95/124 efivars: Handle duplicate names from get_next_variable()
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matt Fleming <[email protected]>
commit e971318bbed610e28bb3fde9d548e6aaf0a6b02e upstream.
Some firmware exhibits a bug where the same VariableName and VendorGuid values are returned on multiple invocations of GetNextVariableName(). See,
https://bugzilla.kernel.org/show_bug.cgi?id=47631
As a consequence of such a bug, Andre reports hitting the following WARN_ON() in the sysfs code after updating the BIOS on his, "Gigabyte Technology Co., Ltd. To be filled by O.E.M./Z77X-UD3H, BIOS F19e 11/21/2012)" machine,
[ 0.581554] EFI Variables Facility v0.08 2004-May-17 [ 0.584914] ------------[ cut here ]------------ [ 0.585639] WARNING: at /home/andre/linux/fs/sysfs/dir.c:536 sysfs_add_one+0xd4/0x100() [ 0.586381] Hardware name: To be filled by O.E.M. [ 0.587123] sysfs: cannot create duplicate filename '/firmware/efi/vars/SbAslBufferPtrVar-01f33c25-764d-43ea-aeea-6b5a41f3f3e8' [ 0.588694] Modules linked in: [ 0.589484] Pid: 1, comm: swapper/0 Not tainted 3.8.0+ #7 [ 0.590280] Call Trace: [ 0.591066] [<ffffffff81208954>] ? sysfs_add_one+0xd4/0x100 [ 0.591861] [<ffffffff810587bf>] warn_slowpath_common+0x7f/0xc0 [ 0.592650] [<ffffffff810588bc>] warn_slowpath_fmt+0x4c/0x50 [ 0.593429] [<ffffffff8134dd85>] ? strlcat+0x65/0x80 [ 0.594203] [<ffffffff81208954>] sysfs_add_one+0xd4/0x100 [ 0.594979] [<ffffffff81208b78>] create_dir+0x78/0xd0 [ 0.595753] [<ffffffff81208ec6>] sysfs_create_dir+0x86/0xe0 [ 0.596532] [<ffffffff81347e4c>] kobject_add_internal+0x9c/0x220 [ 0.597310] [<ffffffff81348307>] kobject_init_and_add+0x67/0x90 [ 0.598083] [<ffffffff81584a71>] ? efivar_create_sysfs_entry+0x61/0x1c0 [ 0.598859] [<ffffffff81584b2b>] efivar_create_sysfs_entry+0x11b/0x1c0 [ 0.599631] [<ffffffff8158517e>] register_efivars+0xde/0x420 [ 0.600395] [<ffffffff81d430a7>] ? edd_init+0x2f5/0x2f5 [ 0.601150] [<ffffffff81d4315f>] efivars_init+0xb8/0x104 [ 0.601903] [<ffffffff8100215a>] do_one_initcall+0x12a/0x180 [ 0.602659] [<ffffffff81d05d80>] kernel_init_freeable+0x13e/0x1c6 [ 0.603418] [<ffffffff81d05586>] ? loglevel+0x31/0x31 [ 0.604183] [<ffffffff816a6530>] ? rest_init+0x80/0x80 [ 0.604936] [<ffffffff816a653e>] kernel_init+0xe/0xf0 [ 0.605681] [<ffffffff816ce7ec>] ret_from_fork+0x7c/0xb0 [ 0.606414] [<ffffffff816a6530>] ? rest_init+0x80/0x80 [ 0.607143] ---[ end trace 1609741ab737eb29 ]---
There's not much we can do to work around and keep traversing the variable list once we hit this firmware bug. Our only solution is to terminate the loop because, as Lingzhu reports, some machines get stuck when they encounter duplicate names,
Quoted 5 lines
I had an IBM System x3100 M4 and x3850 X5 on which kernel would get stuck in infinite loop creating duplicate sysfs files because, for some reason, there are several duplicate boot entries in nvram getting GetNextVariableName into a circle of iteration (with period > 2).
Also disable the workqueue, as efivar_update_sysfs_entries() uses GetNextVariableName() to figure out which variables have been created since the last iteration. That algorithm isn't going to work if GetNextVariableName() returns duplicates. Note that we don't disable EFI variable creation completely on the affected machines, it's just that any pstore dump-* files won't appear in sysfs until the next boot.
[Backported for 3.8-stable. Removed code related to pstore workqueue but pulled in helper function variable_is_present from a93bc0c.]
--- drivers/firmware/efivars.c | 60 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+)
drivers/firmware/efivars.c +60 -0
@@ -1669,6 +1669,28 @@ static ssize_t efivar_delete(struct filereturn count; } +static bool variable_is_present (efi_char16_t *variable_name,efi_guid_t *vendor) +{ +struct efivar_entry *entry, *n; +struct efivars *efivars = &__efivars; +unsigned long strsize1, strsize2; +bool found = false; + + strsize1 =utf16_strsize (variable_name,1024 ); +list_for_each_entry_safe (entry, n, &efivars->list, list) { + strsize2 =utf16_strsize (entry->var.VariableName,1024 ); +if (strsize1 == strsize2 && + !memcmp (variable_name, &(entry->var.VariableName), + strsize2) && + !efi_guidcmp (entry->var.VendorGuid, + *vendor)) { + found = true; +break ; + } + } +return found; +} +/* * Returns the size of variable_name, in bytes, including the * terminating NULL character, or variable_name_size if no NULL
@@ -1889,6 +1911,28 @@ void unregister_efivars(struct efivars * }EXPORT_SYMBOL_GPL (unregister_efivars); +/* +* Print a warning when duplicate EFI variables are encountered and +* disable the sysfs workqueue since the firmware is buggy. +*/ +static void dup_variable_bug (efi_char16_t *s16,efi_guid_t *vendor_guid, +unsigned long len16) +{ +size_t i, len8 = len16 /sizeof (efi_char16_t); +char *s8; + + s8 =kzalloc (len8,GFP_KERNEL ); +if (!s8) +return ; + +for (i =0 ; i < len8; i++) + s8[i] = s16[i]; + +printk (KERN_WARNING "efivars: duplicate variable: %s-%pUl\n" , + s8, vendor_guid); +kfree (s8); +} +int register_efivars (struct efivars *efivars,const struct efivar_operations *ops,struct kobject *parent_kobj)
@@ -1939,6 +1983,22 @@ int register_efivars(struct efivars *eficase EFI_SUCCESS : variable_name_size =var_name_strnsize (variable_name, variable_name_size); + +/* +* Some firmware implementations return the +* same variable name on multiple calls to +* get_next_variable(). Terminate the loop +* immediately as there is no guarantee that +* we'll ever see a different variable name, +* and may end up looping here forever. +*/ +if (variable_is_present (variable_name, &vendor_guid)) { +dup_variable_bug (variable_name, &vendor_guid, + variable_name_size); + status =EFI_NOT_FOUND ; +break ; + } + efivar_create_sysfs_entry(efivars, variable_name_size, variable_name,
Greg Kroah-Hartman
maintainerPATCH 96/124 regulator: Fix memory garbage dev_err printout.
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Russ Dill <[email protected]>
commit 9c7b4e8a8ad2624106fbf690fa97ab9c8c9bfa88 upstream.
commit dd8004af: 'regulator: core: Log when a device causes a voltage constraint fail', tried to print out some information about the check consumer min/max uV fixup, however, it uses a garbage pointer left over from list_for_each_entry leading to boot messages in the form:
'[ 2.079890] <RANDOM ASCII>: Restricting voltage, 3735899821-4294967295uV'
Because it references regulator->dev, it could potentially read memory from anywhere causing a panic.
This patch instead uses rdev and the updated min/max uV values.
--- drivers/regulator/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/regulator/core.c +2 -2
@@ -200,8 +200,8 @@ static int regulator_check_consumers(str }if (*min_uV > *max_uV) { -dev_err (regulator->dev,"Restricting voltage, %u-%uuV\n" , - regulator->min_uV, regulator->max_uV); +rdev_err (rdev,"Restricting voltage, %u-%uuV\n" , + *min_uV, *max_uV);return -EINVAL ; }
Greg Kroah-Hartman
maintainerPATCH 97/124 net: remove a WARN_ON() in net_enable_timestamp()
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 9979a55a833883242e3a29f3596676edd7199c46 ]
The WARN_ON(in_interrupt()) in net_enable_timestamp() can get false positive, in socket clone path, run from softirq context :
[ 3641.624425] WARNING: at net/core/dev.c:1532 net_enable_timestamp+0x7b/0x80() [ 3641.668811] Call Trace: [ 3641.671254] <IRQ> [<ffffffff80286817>] warn_slowpath_common+0x87/0xc0 [ 3641.677871] [<ffffffff8028686a>] warn_slowpath_null+0x1a/0x20 [ 3641.683683] [<ffffffff80742f8b>] net_enable_timestamp+0x7b/0x80 [ 3641.689668] [<ffffffff80732ce5>] sk_clone_lock+0x425/0x450 [ 3641.695222] [<ffffffff8078db36>] inet_csk_clone_lock+0x16/0x170 [ 3641.701213] [<ffffffff807ae449>] tcp_create_openreq_child+0x29/0x820 [ 3641.707663] [<ffffffff807d62e2>] ? ipt_do_table+0x222/0x670 [ 3641.713354] [<ffffffff807aaf5b>] tcp_v4_syn_recv_sock+0xab/0x3d0 [ 3641.719425] [<ffffffff807af63a>] tcp_check_req+0x3da/0x530 [ 3641.724979] [<ffffffff8078b400>] ? inet_hashinfo_init+0x60/0x80 [ 3641.730964] [<ffffffff807ade6f>] ? tcp_v4_rcv+0x79f/0xbe0 [ 3641.736430] [<ffffffff807ab9bd>] tcp_v4_do_rcv+0x38d/0x4f0 [ 3641.741985] [<ffffffff807ae14a>] tcp_v4_rcv+0xa7a/0xbe0
Its safe at this point because the parent socket owns a reference on the netstamp_needed, so we cant have a 0 -> 1 transition, which requires to lock a mutex.
Instead of refining the check, lets remove it, as all known callers are safe. If it ever changes in the future, static_key_slow_inc() will complain anyway.
--- net/core/dev.c | 1 - 1 file changed, 1 deletion(-)
net/core/dev.c +0 -1
@@ -1591,7 +1591,6 @@ void net_enable_timestamp(void) return; }#endif -WARN_ON (in_interrupt ());static_key_slow_inc (&netstamp_needed); }EXPORT_SYMBOL (net_enable_timestamp);
Greg Kroah-Hartman
maintainerPATCH 98/124 sky2: Receive Overflows not counted
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mirko Lindner <[email protected]>
[ Upstream commit 9cfe8b156c21cf340b3a10ecb3022fbbc1c39185 ]
The sky2 driver doesn't count the Receive Overflows because the MAC interrupt for this event is not set in the MAC's interrupt mask. The MAC's interrupt mask is set only for Transmit FIFO Underruns.
Fix: The correct setting should be (GM_IS_TX_FF_UR | GM_IS_RX_FF_OR) Otherwise the Receive Overflow event will not generate any interrupt. The Receive Overflow interrupt is handled correctly
--- drivers/net/ethernet/marvell/sky2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/marvell/sky2.h +1 -1
@@ -2074,7 +2074,7 @@ enum {GM_IS_RX_FF_OR =1 <<1 ,/* Receive FIFO Overrun */ GM_IS_RX_COMPL =1 <<0 ,/* Frame Reception Complete */ -#define GMAC_DEF_MSK GM_IS_TX_FF_UR +#define GMAC_DEF_MSK (GM_IS_TX_FF_UR | GM_IS_RX_FF_OR) };/* GMAC_LINK_CTRL 16 bit GMAC Link Control Reg (YUKON only) */
Greg Kroah-Hartman
maintainerPATCH 99/124 sky2: Threshold for Pause Packet is set wrong
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mirko Lindner <[email protected]>
[ Upstream commit 74f9f42c1c1650e74fb464f76644c9041f996851 ]
The sky2 driver sets the Rx Upper Threshold for Pause Packet generation to a wrong value which leads to only 2kB of RAM remaining space. This can lead to Rx overflow errors even with activated flow-control.
Fix: We should increase the value to 8192/8
--- drivers/net/ethernet/marvell/sky2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/marvell/sky2.c +1 -1
@@ -1067,7 +1067,7 @@ static void sky2_ramset(struct sky2_hw *sky2_write32 (hw,RB_ADDR (q,RB_RX_UTHP ), tp);sky2_write32 (hw,RB_ADDR (q,RB_RX_LTHP ), space/2 ); - tp = space -2048 /8 ; + tp = space -8192 /8 ;sky2_write32 (hw,RB_ADDR (q,RB_RX_UTPP ), tp);sky2_write32 (hw,RB_ADDR (q,RB_RX_LTPP ), space/4 ); }else {
Greg Kroah-Hartman
maintainerPATCH 100/124 tcp: preserve ACK clocking in TSO
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit f4541d60a449afd40448b06496dcd510f505928e ]
A long standing problem with TSO is the fact that tcp_tso_should_defer() rearms the deferred timer, while it should not.
Current code leads to following bad bursty behavior :
20:11:24.484333 IP A > B: . 297161:316921(19760) ack 1 win 119 20:11:24.484337 IP B > A: . ack 263721 win 1117 20:11:24.485086 IP B > A: . ack 265241 win 1117 20:11:24.485925 IP B > A: . ack 266761 win 1117 20:11:24.486759 IP B > A: . ack 268281 win 1117 20:11:24.487594 IP B > A: . ack 269801 win 1117 20:11:24.488430 IP B > A: . ack 271321 win 1117 20:11:24.489267 IP B > A: . ack 272841 win 1117 20:11:24.490104 IP B > A: . ack 274361 win 1117 20:11:24.490939 IP B > A: . ack 275881 win 1117 20:11:24.491775 IP B > A: . ack 277401 win 1117 20:11:24.491784 IP A > B: . 316921:332881(15960) ack 1 win 119 20:11:24.492620 IP B > A: . ack 278921 win 1117 20:11:24.493448 IP B > A: . ack 280441 win 1117 20:11:24.494286 IP B > A: . ack 281961 win 1117 20:11:24.495122 IP B > A: . ack 283481 win 1117 20:11:24.495958 IP B > A: . ack 285001 win 1117 20:11:24.496791 IP B > A: . ack 286521 win 1117 20:11:24.497628 IP B > A: . ack 288041 win 1117 20:11:24.498459 IP B > A: . ack 289561 win 1117 20:11:24.499296 IP B > A: . ack 291081 win 1117 20:11:24.500133 IP B > A: . ack 292601 win 1117 20:11:24.500970 IP B > A: . ack 294121 win 1117 20:11:24.501388 IP B > A: . ack 295641 win 1117 20:11:24.501398 IP A > B: . 332881:351881(19000) ack 1 win 119
While the expected behavior is more like :
20:19:49.259620 IP A > B: . 197601:202161(4560) ack 1 win 119 20:19:49.260446 IP B > A: . ack 154281 win 1212 20:19:49.261282 IP B > A: . ack 155801 win 1212 20:19:49.262125 IP B > A: . ack 157321 win 1212 20:19:49.262136 IP A > B: . 202161:206721(4560) ack 1 win 119 20:19:49.262958 IP B > A: . ack 158841 win 1212 20:19:49.263795 IP B > A: . ack 160361 win 1212 20:19:49.264628 IP B > A: . ack 161881 win 1212 20:19:49.264637 IP A > B: . 206721:211281(4560) ack 1 win 119 20:19:49.265465 IP B > A: . ack 163401 win 1212 20:19:49.265886 IP B > A: . ack 164921 win 1212 20:19:49.266722 IP B > A: . ack 166441 win 1212 20:19:49.266732 IP A > B: . 211281:215841(4560) ack 1 win 119 20:19:49.267559 IP B > A: . ack 167961 win 1212 20:19:49.268394 IP B > A: . ack 169481 win 1212 20:19:49.269232 IP B > A: . ack 171001 win 1212 20:19:49.269241 IP A > B: . 215841:221161(5320) ack 1 win 119
--- net/ipv4/tcp_output.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
net/ipv4/tcp_output.c +5 -2
@@ -1809,8 +1809,11 @@ static bool tcp_tso_should_defer(struct goto send_now; } -/* Ok, it looks like it is advisable to defer. */ - tp->tso_deferred =1 | (jiffies <<1 ); +/* Ok, it looks like it is advisable to defer. +* Do not rearm the timer if already set to not break TCP ACK clocking. +*/ +if (!tp->tso_deferred) + tp->tso_deferred =1 | (jiffies <<1 );return true;
Greg Kroah-Hartman
maintainerPATCH 101/124 tcp: undo spurious timeout after SACK reneging
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuchung Cheng <[email protected]>
[ Upstream commit 7ebe183c6d444ef5587d803b64a1f4734b18c564 ]
On SACK reneging the sender immediately retransmits and forces a timeout but disables Eifel (undo). If the (buggy) receiver does not drop any packet this can trigger a false slow-start retransmit storm driven by the ACKs of the original packets. This can be detected with undo and TCP timestamps.
--- net/ipv4/tcp_input.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
net/ipv4/tcp_input.c +2 -5
@@ -2064,11 +2064,8 @@ void tcp_enter_loss(struct sock *sk, intif (tcp_is_reno (tp))tcp_reset_reno_sack (tp); -if (!how) { -/* Push undo marker, if it was plain RTO and nothing -* was retransmitted. */ - tp->undo_marker = tp->snd_una; - }else { + tp->undo_marker = tp->snd_una; +if (how) { tp->sacked_out =0 ; tp->fackets_out =0 ; }
Greg Kroah-Hartman
maintainerPATCH 102/124 8021q: fix a potential use-after-free
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cong Wang <[email protected]>
[ Upstream commit 4a7df340ed1bac190c124c1601bfc10cde9fb4fb ]
vlan_vid_del() could possibly free ->vlan_info after a RCU grace period, however, we may still refer to the freed memory area by 'grp' pointer. Found by code inspection.
This patch moves vlan_vid_del() as behind as possible.
--- net/8021q/vlan.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
net/8021q/vlan.c +7 -7
@@ -86,13 +86,6 @@ void unregister_vlan_dev(struct net_devi grp = &vlan_info->grp; -/* Take it out of our own structures, but be sure to interlock with -* HW accelerating devices or SW vlan input packet processing if -* VLAN is not 0 (leave it there for 802.1p). -*/ -if (vlan_id) -vlan_vid_del (real_dev, vlan_id); - grp->nr_vlan_devs--;if (vlan->flags &VLAN_FLAG_GVRP )
@@ -108,6 +101,13 @@ void unregister_vlan_dev(struct net_deviif (grp->nr_vlan_devs ==0 )vlan_gvrp_uninit_applicant (real_dev); +/* Take it out of our own structures, but be sure to interlock with +* HW accelerating devices or SW vlan input packet processing if +* VLAN is not 0 (leave it there for 802.1p). +*/ +if (vlan_id) +vlan_vid_del (real_dev, vlan_id); +/* Get rid of the vlan's reference to real_dev */ dev_put (real_dev); }
Greg Kroah-Hartman
maintainerPATCH 103/124 thermal: shorten too long mcast group name
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masatake YAMATO <[email protected]>
[ Upstream commits 73214f5d9f33b79918b1f7babddd5c8af28dd23d
and f1e79e208076ffe7bad97158275f1c572c04f5c7, the latter adds an assertion to genetlink to prevent this from happening again in the future. ]
The original name is too long.
--- include/linux/thermal.h | 2 +- net/netlink/genetlink.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
include/linux/thermal.h +1 -1
@@ -44,7 +44,7 @@/* Adding event notification support elements */ #define THERMAL_GENL_FAMILY_NAME "thermal_event"#define THERMAL_GENL_VERSION 0x01 -#define THERMAL_GENL_MCAST_GROUP_NAME "thermal_mc_group" +#define THERMAL_GENL_MCAST_GROUP_NAME "thermal_mc_grp"/* Default Thermal Governor */ #if defined(CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE )
net/netlink/genetlink.c +1 -0
@@ -142,6 +142,7 @@ int genl_register_mc_group(struct genl_fint err =0 ;BUG_ON (grp->name[0 ] =='\0' ); +BUG_ON (memchr (grp->name,'\0' ,GENL_NAMSIZ ) ==NULL );genl_lock ();
Greg Kroah-Hartman
maintainerPATCH 104/124 unix: fix a race condition in unix_release()
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Moore <[email protected]>
[ Upstream commit ded34e0fe8fe8c2d595bfa30626654e4b87621e0 ]
As reported by Jan, and others over the past few years, there is a race condition caused by unix_release setting the sock->sk pointer to NULL before properly marking the socket as dead/orphaned. This can cause a problem with the LSM hook security_unix_may_send() if there is another socket attempting to write to this partially released socket in between when sock->sk is set to NULL and it is marked as dead/orphaned. This patch fixes this by only setting sock->sk to NULL after the socket has been marked as dead; I also take the opportunity to make unix_release_sock() a void function as it only ever returned 0/success.
Dave, I think this one should go on the -stable pile.
Special thanks to Jan for coming up with a reproducer for this problem.
--- net/unix/af_unix.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
net/unix/af_unix.c +3 -4
@@ -384,7 +384,7 @@ static void unix_sock_destructor(struct#endif } -static int unix_release_sock (struct sock *sk,int embrion) +static void unix_release_sock (struct sock *sk,int embrion) {struct unix_sock *u =unix_sk (sk);struct path path;
@@ -453,8 +453,6 @@ static int unix_release_sock(struct sockif (unix_tot_inflight)unix_gc ();/* Garbage collect fds */ - -return 0 ; }static void init_peercred (struct sock *sk)
@@ -701,9 +699,10 @@ static int unix_release(struct socket *sif (!sk)return 0 ; +unix_release_sock (sk,0 ); sock->sk =NULL ; -return unix_release_sock (sk,0 ); +return 0 ; }static int unix_autobind (struct socket *sock)
Greg Kroah-Hartman
maintainerPATCH 105/124 af_unix: dont send SCM_CREDENTIAL when dest socket is NULL
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: dingtianhong <[email protected]>
[ Upstream commit 14134f6584212d585b310ce95428014b653dfaf6 ]
SCM_SCREDENTIALS should apply to write() syscalls only either source or destination socket asserted SOCK_PASSCRED. The original implememtation in maybe_add_creds is wrong, and breaks several LSB testcases ( i.e. /tset/LSB.os/netowkr/recvfrom/T.recvfrom).
--- net/unix/af_unix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/unix/af_unix.c +2 -2
@@ -1414,8 +1414,8 @@ static void maybe_add_creds(struct sk_buif (UNIXCB (skb).cred)return ;if (test_bit (SOCK_PASSCRED , &sock->flags) || - !other->sk_socket || -test_bit (SOCK_PASSCRED , &other->sk_socket->flags)) { + (other->sk_socket && +test_bit (SOCK_PASSCRED , &other->sk_socket->flags))) {UNIXCB (skb).pid =get_pid (task_tgid (current));UNIXCB (skb).cred =get_current_cred (); }
Re: [ 105/124] af_unix: dont send SCM_CREDENTIAL when dest socket is NULL
Quoted 1 line · Greg Kroah-Hartman
3.8-stable review patch. If anyone has any objections, please let me know.
I'm seeing several complaints from udevd at boot in both 3.8.6-rc1 and 3.9-rc5: "udevd[56]: sender uid=65534, message ignored". Reverting the patch below on top of 3.8.6-rc1 fixes that. I'm using udev version 175 here, and 65534 is the uid of user "nobody".
Cheers,
Sven
Quoted 30 lines
From: dingtianhong <[email protected]>
[ Upstream commit
14134f6584212d585b310ce95428014b653dfaf6]
SCM_SCREDENTIALSshould apply towrite()syscalls only either source or destination socket assertedSOCK_PASSCRED. The original implememtation inmaybe_add_credsis wrong, and breaks several LSB testcases ( i.e. /tset/LSB.os/netowkr/recvfrom/T.recvfrom).Origionally-authored-by Karel Srot <[email protected]>Signed-off-by Ding Tianhong <[email protected]>Acked-by Eric Dumazet <[email protected]>Signed-off-by David S. Miller <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- net/unix/af_unix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)net/unix/af_unix.c +2
-2@@ -1414,8 +1414,8 @@ static void maybe_add_creds(struct sk_buif (UNIXCB (skb).cred)return ;if (test_bit (SOCK_PASSCRED , &sock->flags) || - !other->sk_socket || -test_bit (SOCK_PASSCRED , &other->sk_socket->flags)) { + (other->sk_socket && +test_bit (SOCK_PASSCRED , &other->sk_socket->flags))) {UNIXCB (skb).pid =get_pid (task_tgid (current));UNIXCB (skb).cred =get_current_cred (); }
Re: [ 105/124] af_unix: dont send SCM_CREDENTIAL when dest socket is NULL
Quoted 8 lines · Sven Joachim
Quoted 1 line · Greg Kroah-Hartman
3.8-stable review patch. If anyone has any objections, please let me know.
I'm seeing several complaints from udevd at boot in both 3.8.6-rc1 and 3.9-rc5: "udevd[56]: sender uid=65534, message ignored". Reverting the patch below on top of 3.8.6-rc1 fixes that. I'm using udev version 175 here, and 65534 is the uid of user "nobody".
And if you use a 3.1 kernel (before commit 16e5726269611b71c930054ffe9b858c1cea88eb) are you seeing this message ?
It might be a wrong sender (application bug or bad identity), and udevd correctly discards the incoming message.
Re: [ 105/124] af_unix: dont send SCM_CREDENTIAL when dest socket is NULL
Quoted 5 lines · Eric Dumazet
Quoted 4 lines · Sven Joachim
Quoted 1 line · Greg Kroah-Hartman
3.8-stable review patch. If anyone has any objections, please let me know.
Quoted 7 lines
Quoted 4 lines
I'm seeing several complaints from udevd at boot in both 3.8.6-rc1 and 3.9-rc5: "udevd[56]: sender uid=65534, message ignored". Reverting the patch below on top of 3.8.6-rc1 fixes that. I'm using udev version 175 here, and 65534 is the uid of user "nobody".
And if you use a 3.1 kernel (before commit
16e5726269611b71c930054ffe9b858c1cea88eb) are you seeing this message ?
No (tested with 3.1.10).
Quoted 2 lines
It might be a wrong sender (application bug or bad identity), and udevd correctly discards the incoming message.
How would I find out the culprit?
Cheers,
Sven
Greg Kroah-Hartman
maintainerRe: [ 105/124] af_unix: dont send SCM_CREDENTIAL when dest socket is NULL
Quoted 15 lines · Sven Joachim
Quoted 5 lines · Eric Dumazet
Quoted 4 lines · Sven Joachim
Quoted 1 line · Greg Kroah-Hartman
3.8-stable review patch. If anyone has any objections, please let me know.
Quoted 7 lines
Quoted 4 lines
I'm seeing several complaints from udevd at boot in both 3.8.6-rc1 and 3.9-rc5: "udevd[56]: sender uid=65534, message ignored". Reverting the patch below on top of 3.8.6-rc1 fixes that. I'm using udev version 175 here, and 65534 is the uid of user "nobody".
And if you use a 3.1 kernel (before commit
16e5726269611b71c930054ffe9b858c1cea88eb) are you seeing this message ?
Quoted 6 lines
No (tested with 3.1.10).
Quoted 2 lines
It might be a wrong sender (application bug or bad identity), and udevd correctly discards the incoming message.
How would I find out the culprit?
Try running 'udevadm monitor' as root and see if something shows up there.
I can't reproduce this here, running a newer version of udev (195), sorry, I don't have any systems with older udev releases.
Note, someone else posted this same error earlier today on the linux-usb mailing list, saying that USB storage devices would not automount anymore. Does that work properly for you?
thanks,
greg k-h
Re: [ 105/124] af_unix: dont send SCM_CREDENTIAL when dest socket is NULL
Hi
Quoted 10 lines · Greg Kroah-Hartman
Quoted 9 lines · Sven Joachim
Quoted 8 lines · Eric Dumazet
Quoted 7 lines · Sven Joachim
Quoted 1 line · Greg Kroah-Hartman
3.8-stable review patch. If anyone has any objections, please let me know.
I'm seeing several complaints from udevd at boot in both 3.8.6-rc1 and 3.9-rc5: "udevd[56]: sender uid=65534, message ignored". Reverting the patch below on top of 3.8.6-rc1 fixes that. I'm using udev version 175 here, and 65534 is the uid of user "nobody".
[…]
I can reproduce this issue on several systems with a Debian unstable (udev 175, same version as in the upcoming Debian 7.0 'wheezy') userland. Reverting only this patch from 3.8.6-rc1 avoids the problem.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
It might be a wrong sender (application bug or bad identity), and udevd correctly discards the incoming message.
How would I find out the culprit?
Try running 'udevadm monitor' as root and see if something shows up there.
There are no re-occuring messages on an idle system, connecting a USB stick (not mounting) results in these messages.
broken (3.8.6-rc1, with "af_unix: dont send SCM_CREDENTIAL when dest socket is NULL" applied):
KERNEL[11739.713368] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1 (usb) KERNEL[11739.713514] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0 (usb) UDEV [11739.713663] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1 (usb) KERNEL[11739.713677] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host7 (scsi) KERNEL[11739.713688] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host7/scsi_host/host7 (scsi_host) UDEV [11739.713734] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0 (usb) UDEV [11739.713797] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host7 (scsi) UDEV [11739.713893] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host7/scsi_host/host7 (scsi_host) UDEV [11739.718583] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1 (usb) UDEV [11739.720709] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0 (usb) UDEV [11739.720900] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host7 (scsi) UDEV [11739.721191] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host7/scsi_host/host7 (scsi_host) KERNEL[11740.747996] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host7/target7:0:0 (scsi) KERNEL[11740.748032] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host7/target7:0:0/7:0:0:0 (scsi) KERNEL[11740.748042] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host7/target7:0:0/7:0:0:0/scsi_disk/7:0:0:0 (scsi_disk) KERNEL[11740.748048] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host7/target7:0:0/7:0:0:0/scsi_device/7:0:0:0 (scsi_device) KERNEL[11740.748103] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host7/target7:0:0/7:0:0:0/scsi_generic/sg5 (scsi_generic) UDEV [11740.748129] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host7/target7:0:0 (scsi) KERNEL[11740.748146] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host7/target7:0:0/7:0:0:0/bsg/7:0:0:0 (bsg) UDEV [11740.748251] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host7/target7:0:0 (scsi) UDEV [11740.748349] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host7/target7:0:0/7:0:0:0 (scsi) UDEV [11740.748459] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host7/target7:0:0/7:0:0:0/scsi_disk/7:0:0:0 (scsi_disk) UDEV [11740.748533] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host7/target7:0:0/7:0:0:0/scsi_device/7:0:0:0 (scsi_device) UDEV [11740.748910] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host7/target7:0:0/7:0:0:0/scsi_generic/sg5 (scsi_generic) UDEV [11740.749039] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host7/target7:0:0/7:0:0:0/bsg/7:0:0:0 (bsg) UDEV [11740.750204] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host7/target7:0:0/7:0:0:0 (scsi) UDEV [11740.750531] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host7/target7:0:0/7:0:0:0/scsi_disk/7:0:0:0 (scsi_disk) UDEV [11740.750652] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host7/target7:0:0/7:0:0:0/scsi_device/7:0:0:0 (scsi_device) UDEV [11740.751143] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host7/target7:0:0/7:0:0:0/bsg/7:0:0:0 (bsg) UDEV [11740.751323] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host7/target7:0:0/7:0:0:0/scsi_generic/sg5 (scsi_generic) KERNEL[11740.943534] add /devices/virtual/bdi/8:80 (bdi) UDEV [11740.943700] add /devices/virtual/bdi/8:80 (bdi) UDEV [11740.943807] add /devices/virtual/bdi/8:80 (bdi) KERNEL[11740.987877] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host7/target7:0:0/7:0:0:0/block/sdf (block) KERNEL[11740.987921] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host7/target7:0:0/7:0:0:0/block/sdf/sdf1 (block) UDEV [11740.988152] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host7/target7:0:0/7:0:0:0/block/sdf (block) UDEV [11740.988307] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host7/target7:0:0/7:0:0:0/block/sdf/sdf1 (block) UDEV [11741.047184] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host7/target7:0:0/7:0:0:0/block/sdf (block) UDEV [11741.104796] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host7/target7:0:0/7:0:0:0/block/sdf/sdf1 (block)
working (3.8.6-rc1, with "af_unix: dont send SCM_CREDENTIAL when dest socket is NULL" reverted):
KERNEL[637.018561] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1 (usb) KERNEL[637.018607] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0 (usb) UDEV [637.023544] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1 (usb) KERNEL[637.028060] add /module/usb_storage (module) UDEV [637.028268] add /module/usb_storage (module) KERNEL[637.028293] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host6 (scsi) KERNEL[637.028332] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host6/scsi_host/host6 (scsi_host) KERNEL[637.028364] add /bus/usb/drivers/usb-storage (drivers) UDEV [637.028586] add /bus/usb/drivers/usb-storage (drivers) UDEV [637.028614] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0 (usb) UDEV [637.028910] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host6 (scsi) UDEV [637.029294] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host6/scsi_host/host6 (scsi_host) KERNEL[638.062158] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host6/target6:0:0 (scsi) KERNEL[638.062191] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host6/target6:0:0/6:0:0:0 (scsi) KERNEL[638.062238] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host6/target6:0:0/6:0:0:0/scsi_disk/6:0:0:0 (scsi_disk) KERNEL[638.062280] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host6/target6:0:0/6:0:0:0/scsi_device/6:0:0:0 (scsi_device) KERNEL[638.062347] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host6/target6:0:0/6:0:0:0/scsi_generic/sg5 (scsi_generic) KERNEL[638.062410] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host6/target6:0:0/6:0:0:0/bsg/6:0:0:0 (bsg) UDEV [638.062455] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host6/target6:0:0 (scsi) UDEV [638.064574] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host6/target6:0:0/6:0:0:0 (scsi) UDEV [638.064941] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host6/target6:0:0/6:0:0:0/scsi_disk/6:0:0:0 (scsi_disk) UDEV [638.064974] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host6/target6:0:0/6:0:0:0/scsi_device/6:0:0:0 (scsi_device) UDEV [638.065568] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host6/target6:0:0/6:0:0:0/bsg/6:0:0:0 (bsg) UDEV [638.065766] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host6/target6:0:0/6:0:0:0/scsi_generic/sg5 (scsi_generic) KERNEL[638.257660] add /devices/virtual/bdi/8:80 (bdi) UDEV [638.258029] add /devices/virtual/bdi/8:80 (bdi) KERNEL[638.301820] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host6/target6:0:0/6:0:0:0/block/sdf (block) KERNEL[638.301864] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host6/target6:0:0/6:0:0:0/block/sdf/sdf1 (block) UDEV [638.361377] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host6/target6:0:0/6:0:0:0/block/sdf (block) UDEV [638.420664] add /devices/pci0000:00/0000:00:1a.0/usb7/7-1/7-1.1/7-1.1:1.0/host6/target6:0:0/6:0:0:0/block/sdf/sdf1 (block)
Quoted 6 lines
I can't reproduce this here, running a newer version of udev (195), sorry, I don't have any systems with older udev releases.
Note, someone else posted this same error earlier today on the linux-usb mailing list, saying that USB storage devices would not automount anymore. Does that work properly for you?
Yes, this patch breaks automounting or USB devices under KDE 4.8.4.
Regards
Stefan Lippers-Hollmann
Re: [ 105/124] af_unix: dont send SCM_CREDENTIAL when dest socket is NULL
In reply to Sven JoachimQuoted 7 lines · Sven Joachim
Quoted 2 lines · Eric Dumazet
It might be a wrong sender (application bug or bad identity), and udevd correctly discards the incoming message.
How would I find out the culprit?
Change udevd to display the pid as well, and hopefully track the sender.
udevd receives uid and pid in the credentials.
Re: [ 105/124] af_unix: dont send SCM_CREDENTIAL when dest socket is NULL
Quoted 4 lines · Eric Dumazet
Quoted 3 lines · Sven Joachim
On 2013-04-03 16:00 +0200, Eric Dumazet wrote:
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
It might be a wrong sender (application bug or bad identity), and udevd correctly discards the incoming message.
How would I find out the culprit?
Change udevd to display the pid as well, and hopefully track the sender.
udevd receives uid and pid in the credentials.
This sounds suspiciously like an SCM_CREDENTIALS bug triggered by a race. There's a fix (that needs both a new version from me and a review by someone) here:
http://www.spinics.net/lists/netdev/msg229948.html
--Andy
Re: [ 105/124] af_unix: dont send SCM_CREDENTIAL when dest socket is NULL
Quoted 6 lines · Andy Lutomirski
This sounds suspiciously like an
SCM_CREDENTIALSbug triggered by a race. There's a fix (that needs both a new version from me and a review by someone) here:
Hmm... this is not a stable candidate, IMHO.
This has to be fixed (if needed) in a more easy way.
What about this one liner ?
CC Eric W. Biederman as he wrote commit dbe9a4173ea53b72b2c3
(scm: Don't use struct ucred in NETLINK_CB and struct scm_cookie.)
include/net/scm.h +1 -1
@@ -120,7 +120,7 @@ static __inline__ void scm_recv(struct socket *sock, struct msghdr *msg,return ; } -if (test_bit (SOCK_PASSCRED , &sock->flags)) { +if (test_bit (SOCK_PASSCRED , &sock->flags) && scm->creds.pid) {struct user_namespace *current_ns =current_user_ns ();struct ucred ucreds = { .pid = scm->creds.pid,
Re: [ 105/124] af_unix: dont send SCM_CREDENTIAL when dest socket is NULL
Quoted 10 lines · Eric Dumazet
Quoted 6 lines · Andy Lutomirski
This sounds suspiciously like an
SCM_CREDENTIALSbug triggered by a race. There's a fix (that needs both a new version from me and a review by someone) here:Hmm... this is not a stable candidate, IMHO.
Agreed.
Quoted 16 lines
This has to be fixed (if needed) in a more easy way.
What about this one liner ?
CC Eric W. Biederman as he wrote commit
dbe9a4173ea53b72b2c3
(scm: Don't use struct ucred inNETLINK_CBand structscm_cookie.)include/net/scm.h +0
-0
include/net/scm.h static __inline__ void scm_recv(struct socket *sock, struct msghdr *msg, · line 126
Quoted 8 lines
include/net/scm.h +1
-1@@ -120,7 +120,7 @@ static __inline__ void scm_recv(struct socket *sock, struct msghdr *msg,return ; } -if (test_bit (SOCK_PASSCRED , &sock->flags)) { +if (test_bit (SOCK_PASSCRED , &sock->flags) && scm->creds.pid) {struct user_namespace *current_ns =current_user_ns ();struct ucred ucreds = { .pid = scm->creds.pid,
That looks like it's correct. If it gets applied, I'll respin my patches on top of it.
(This approach may be a POSIX violation for all I know, and it's even possible that some really fragile userspace breaks. But I doubt it, and anything that will break as a result is already operating in a highly confused state; hence the original problem.)
--Andy
Re: [ 105/124] af_unix: dont send SCM_CREDENTIAL when dest socket is NULL
Quoted 42 lines · Andy Lutomirski
Quoted 10 lines · Eric Dumazet
Quoted 6 lines · Andy Lutomirski
This sounds suspiciously like an
SCM_CREDENTIALSbug triggered by a race. There's a fix (that needs both a new version from me and a review by someone) here:Hmm... this is not a stable candidate, IMHO.
Agreed.
Quoted 16 lines
This has to be fixed (if needed) in a more easy way.
What about this one liner ?
CC Eric W. Biederman as he wrote commit
dbe9a4173ea53b72b2c3
(scm: Don't use struct ucred inNETLINK_CBand structscm_cookie.)include/net/scm.h +0
-0include/net/scm.h static __inline__ void scm_recv(struct socket *sock, struct msghdr *msg, · line 126
Quoted 8 lines
include/net/scm.h +1
-1@@ -120,7 +120,7 @@ static __inline__ void scm_recv(struct socket *sock, struct msghdr *msg,return ; } -if (test_bit (SOCK_PASSCRED , &sock->flags)) { +if (test_bit (SOCK_PASSCRED , &sock->flags) && scm->creds.pid) {struct user_namespace *current_ns =current_user_ns ();struct ucred ucreds = { .pid = scm->creds.pid,That looks like it's correct. If it gets applied, I'll respin my patches on top of it.
Quoted 4 lines
(This approach may be a POSIX violation for all I know, and it's even possible that some really fragile userspace breaks. But I doubt it, and anything that will break as a result is already operating in a highly confused state; hence the original problem.)
It certainly looks like we are not giving userspace what userspace asked for, which can break in all kinds of subtle ways. And I can't possibly see how not giving udev any information will when udev asked for the sender will fix anything.
I think we need to answer why in the world do we do not want to pass credentials from an unconnected unix mode socket, before we ask why don't we want to deliver credentials that we didn't pass when passing of credentials was explicitly requested.
If the only concern about the LSB test case is performance I think we need to revert the original commit and just stop passing a struct cred pointer. If there is a concern about the data I think we need a better explanation of what those LSB test cases were that broke.
Eric
Re: [ 105/124] af_unix: dont send SCM_CREDENTIAL when dest socket is NULL
In reply to Sven JoachimQuoted 8 lines · Sven Joachim
Quoted 1 line · Greg Kroah-Hartman
3.8-stable review patch. If anyone has any objections, please let me know.
I'm seeing several complaints from udevd at boot in both 3.8.6-rc1 and 3.9-rc5: "udevd[56]: sender uid=65534, message ignored". Reverting the patch below on top of 3.8.6-rc1 fixes that. I'm using udev version 175 here, and 65534 is the uid of user "nobody".
Hmm.
Ok. I don't understand the commit that was being backported here. I am pretty certain it a fix for a problem that did not exist.
Unless I am completely mis-reading scm_recv we only generate a SCM_CREDENTIALS message if the receiving socket asserts SOCK_PASSCRED. Which means that the only harm that can come from adding scm credentials to a disconnected af_unix socket is a loss in efficiency.
Not adding scm credentials to be passed to userspace as the commit below is doing can result is bogus data being passed to userspace. Which is very actively WRONG.
Now before scm_recv does anything we first call scm_set_cred. If no credential was passed to scm_set_cred we set the uid to INVALID_UID. Which scm_recv in the call from_kuid_munged translates into 65534 for reporting to userspace.
So this is is pretty clearly a case of us not sending the unix credentials.
Since not sending credential is just a performance optimization I can see no earthly reason why the commit below should have been applied in the first place, and no reason why it should have been backported in the second place. So my vote is that we revert this bogus commit. Upstream and then backport the revert.
Am I missing something?
Eric
Quoted 30 lines
Quoted 30 lines
From: dingtianhong <[email protected]>
[ Upstream commit
14134f6584212d585b310ce95428014b653dfaf6]
SCM_SCREDENTIALSshould apply towrite()syscalls only either source or destination socket assertedSOCK_PASSCRED. The original implememtation inmaybe_add_credsis wrong, and breaks several LSB testcases ( i.e. /tset/LSB.os/netowkr/recvfrom/T.recvfrom).Origionally-authored-by Karel Srot <[email protected]>Signed-off-by Ding Tianhong <[email protected]>Acked-by Eric Dumazet <[email protected]>Signed-off-by David S. Miller <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- net/unix/af_unix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)net/unix/af_unix.c +2
-2@@ -1414,8 +1414,8 @@ static void maybe_add_creds(struct sk_buif (UNIXCB (skb).cred)return ;if (test_bit (SOCK_PASSCRED , &sock->flags) || - !other->sk_socket || -test_bit (SOCK_PASSCRED , &other->sk_socket->flags)) { + (other->sk_socket && +test_bit (SOCK_PASSCRED , &other->sk_socket->flags))) {UNIXCB (skb).pid =get_pid (task_tgid (current));UNIXCB (skb).cred =get_current_cred (); }
Re: [ 105/124] af_unix: dont send SCM_CREDENTIAL when dest socket is NULL
Quoted 33 lines · Eric W. Biederman
Quoted 8 lines · Sven Joachim
Quoted 1 line · Greg Kroah-Hartman
3.8-stable review patch. If anyone has any objections, please let me know.
I'm seeing several complaints from udevd at boot in both 3.8.6-rc1 and 3.9-rc5: "udevd[56]: sender uid=65534, message ignored". Reverting the patch below on top of 3.8.6-rc1 fixes that. I'm using udev version 175 here, and 65534 is the uid of user "nobody".
Hmm.
Ok. I don't understand the commit that was being backported here. I am pretty certain it a fix for a problem that did not exist.
Unless I am completely mis-reading
scm_recvwe only generate aSCM_CREDENTIALSmessage if the receiving socket assertsSOCK_PASSCRED. Which means that the only harm that can come from adding scm credentials to a disconnectedaf_unixsocket is a loss in efficiency.Not adding scm credentials to be passed to userspace as the commit below is doing can result is bogus data being passed to userspace. Which is very actively WRONG.
Now before
scm_recvdoes anything we first callscm_set_cred. If no credential was passed toscm_set_credwe set the uid toINVALID_UID. Whichscm_recvin the callfrom_kuid_mungedtranslates into 65534 for reporting to userspace.So this is is pretty clearly a case of us not sending the unix credentials.
Quoted 7 lines
Since not sending credential is just a performance optimization I can see no earthly reason why the commit below should have been applied in the first place, and no reason why it should have been backported in the second place. So my vote is that we revert this bogus commit. Upstream and then backport the revert.
Am I missing something?
Well, yes, this commit fixes a real bug : We were coalescing two messages into a single one, even if the senders were different.
Copy of a reply I did :
So the problem is that two messages have different credentials, because other->sk_socket changed between first and second message.
and unix_stream_recvmsg() has the following check :
if (check_creds) {
/* Never glue messages from different writers */
if ((UNIXCB(skb).pid != siocb->scm->pid) ||
(UNIXCB(skb).cred != siocb->scm->cred))
break;
} else {
/* Copy credentials */
scm_set_cred(siocb->scm, UNIXCB(skb).pid, UNIXCB(skb).cred);
check_creds = 1;
}So the patch was good, and we need a followup, like the one I posted today ?
Some user apps dont know about uid 65534.
include/net/scm.h +1 -1
@@ -120,7 +120,7 @@ static __inline__ void scm_recv(struct socket *sock, struct msghdr *msg,return ; } -if (test_bit (SOCK_PASSCRED , &sock->flags)) { +if (test_bit (SOCK_PASSCRED , &sock->flags) && scm->creds.pid) {struct user_namespace *current_ns =current_user_ns ();struct ucred ucreds = { .pid = scm->creds.pid,
Re: [ 105/124] af_unix: dont send SCM_CREDENTIAL when dest socket is NULL
Quoted 2 lines · Eric Dumazet
Well, yes, this commit fixes a real bug : We were coalescing two messages into a single one, even if the senders were different.
By the way, the 'LSB' test program can be found here :
Re: [ 105/124] af_unix: dont send SCM_CREDENTIAL when dest socket is NULL
Quoted 8 lines · Eric Dumazet
Quoted 2 lines · Eric Dumazet
Well, yes, this commit fixes a real bug : We were coalescing two messages into a single one, even if the senders were different.
By the way, the 'LSB' test program can be found here :
And we have two sends and one recvfrom, and no loops.
So the the problem must be a failure to coalesce messages.
There is a race between creating the sending and receiving sockets.
At a first glance that race looks like we put the cred on the first message and not on the second message because we are connected by the time the second messages is sent.
Which would definitely cause a failure to coallesce messages.
Eric
PATCH 1/2 Revert "af_unix: dont send SCM_CREDENTIAL when dest socket is NULL"
This reverts commit 14134f6584212d585b310ce95428014b653dfaf6.
The problem that the above patch was meant to address is that af_unix messages are not being coallesced because we are sending unnecesarry credentials. Not sending credentials in maybe_add_creds totally breaks unconnected unix domain sockets that wish to send credentails to other sockets.
In practice this break some versions of udev because they receive a message and the sending uid is bogus so they drop the message.
--- net/unix/af_unix.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
net/unix/af_unix.c +2 -2
@@ -1412,8 +1412,8 @@ static void maybe_add_creds(struct sk_buff *skb, const struct socket *sock,if (UNIXCB (skb).cred)return ;if (test_bit (SOCK_PASSCRED , &sock->flags) || - (other->sk_socket && -test_bit (SOCK_PASSCRED , &other->sk_socket->flags))) { + !other->sk_socket || +test_bit (SOCK_PASSCRED , &other->sk_socket->flags)) {UNIXCB (skb).pid =get_pid (task_tgid (current));UNIXCB (skb).cred =get_current_cred (); }
Signature · 1 line
1.7.5.4
PATCH 2/2 af_unix: If we don't care about credentials coallesce all messages
It was reported that the following LSB test case failed
https://lsbbugs.linuxfoundation.org/attachment.cgi?id=2144 because we were not coallescing unix stream messages when the application was expecting us to.
The problem was that the first send was before the socket was accepted and thus sock->sk_socket was NULL in maybe_add_creds, and the second send after the socket was accepted had a non-NULL value for sk->socket and thus we could tell the credentials were not needed so we did not bother.
The unnecessary credentials on the first message cause unix_stream_recvmsg to start verifying that all messages had the same credentials before coallescing and then the coallescing failed because the second message had no credentials.
Ignoring credentials when we don't care in unix_stream_recvmsg fixes a long standing pessimization which would fail to coallesce messages when reading from a unix stream socket if the senders were different even if we did not care about their credentials.
I have tested this and verified that the in the LSB test case mentioned above that the messages do coallesce now, while the were failing to coallesce without this change.
--- net/unix/af_unix.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
net/unix/af_unix.c +1 -1
@@ -1993,7 +1993,7 @@ again:if ((UNIXCB (skb).pid != siocb->scm->pid) || (UNIXCB (skb).cred != siocb->scm->cred))break ; - }else { + }else if (test_bit (SOCK_PASSCRED , &sock->flags)) {/* Copy credentials */ scm_set_cred (siocb->scm,UNIXCB (skb).pid,UNIXCB (skb).cred); check_creds =1 ;
Signature · 1 line
1.7.5.4
[PATCH 3/2] scm: Stop passing struct cred
Now that uids and gids are completely encapsulated in kuid_t and kgid_t we no longer need to pass struct cred which allowed us to test both the uid and the user namespace for equality.
Passing struct cred potentially allows us to pass the entire group list as BSD does but I don't believe the cost of cache line misses justifies retaining code for a future potential application.
---
Included in this patchset because there are trivial dependencies, and since we are sort of arguing about this anyway. This definitely is not for stable.
include/net/af_unix.h | 3 ++- include/net/scm.h | 16 ++++++---------- net/core/scm.c | 16 ---------------- net/unix/af_unix.c | 16 ++++++++-------- 4 files changed, 16 insertions(+), 35 deletions(-)
include/net/af_unix.h +2 -1
@@ -29,7 +29,8 @@ struct unix_address {struct unix_skb_parms {struct pid *pid;/* Skb credentials */ -const struct cred *cred; +kuid_t uid; +kgid_t gid;struct scm_fp_list *fp;/* Passed files */ #ifdef CONFIG_SECURITY_NETWORK u32 secid;/* Security ID */
include/net/scm.h +6 -10
@@ -26,7 +26,6 @@ struct scm_fp_list {struct scm_cookie {struct pid *pid;/* Skb credentials */ -const struct cred *cred;struct scm_fp_list *fp;/* Passed files */ struct scm_creds creds;/* Skb credentials */ #ifdef CONFIG_SECURITY_NETWORK
@@ -51,23 +50,18 @@ static __inline__ void unix_get_peersec_dgram(struct socket *sock, struct scm_co#endif /* CONFIG_SECURITY_NETWORK */ static __inline__void scm_set_cred (struct scm_cookie *scm, -struct pid *pid,const struct cred *cred) +struct pid *pid,kuid_t uid,kgid_t gid) { scm->pid =get_pid (pid); - scm->cred = cred ?get_cred (cred) :NULL ; scm->creds.pid =pid_vnr (pid); - scm->creds.uid = cred ? cred->euid :INVALID_UID ; - scm->creds.gid = cred ? cred->egid :INVALID_GID ; + scm->creds.uid = uid; + scm->creds.gid = gid; }static __inline__void scm_destroy_cred (struct scm_cookie *scm) {put_pid (scm->pid); scm->pid =NULL ; - -if (scm->cred) -put_cred (scm->cred); - scm->cred =NULL ; }static __inline__void scm_destroy (struct scm_cookie *scm)
@@ -81,8 +75,10 @@ static __inline__ int scm_send(struct socket *sock, struct msghdr *msg, struct scm_cookie *scm, bool forcecreds) { memset(scm, 0, sizeof(*scm)); + scm->creds.uid =INVALID_UID ; + scm->creds.gid =INVALID_GID ;if (forcecreds) -scm_set_cred (scm,task_tgid (current),current_cred ()); +scm_set_cred (scm,task_tgid (current),current_euid (),current_egid ());unix_get_peersec_dgram (sock, scm);if (msg->msg_controllen <=0 )return 0 ;
net/core/scm.c +0 -16
@@ -187,22 +187,6 @@ int __scm_send(struct socket *sock, struct msghdr *msg, struct scm_cookie *p) p->creds.uid = uid; p->creds.gid = gid; - -if (!p->cred || - !uid_eq (p->cred->euid, uid) || - !gid_eq (p->cred->egid, gid)) { -struct cred *cred; - err = -ENOMEM ; - cred =prepare_creds (); -if (!cred) - goto error; - - cred->uid = cred->euid = uid; - cred->gid = cred->egid = gid; -if (p->cred) -put_cred (p->cred); - p->cred = cred; - }break ; }default :
net/unix/af_unix.c +8 -8
@@ -1340,7 +1340,6 @@ static void unix_destruct_scm(struct sk_buff *skb)struct scm_cookie scm;memset (&scm,0 ,sizeof (scm)); scm.pid =UNIXCB (skb).pid; - scm.cred =UNIXCB (skb).cred;if (UNIXCB (skb).fp)unix_detach_fds (&scm, skb);
@@ -1391,8 +1390,8 @@ static int unix_scm_to_skb(struct scm_cookie *scm, struct sk_buff *skb, bool senint err =0 ;UNIXCB (skb).pid =get_pid (scm->pid); -if (scm->cred) -UNIXCB (skb).cred =get_cred (scm->cred); +UNIXCB (skb).uid = scm->creds.uid; +UNIXCB (skb).gid = scm->creds.gid;UNIXCB (skb).fp =NULL ;if (scm->fp && send_fds) err =unix_attach_fds (scm, skb);
@@ -1409,13 +1408,13 @@ static int unix_scm_to_skb(struct scm_cookie *scm, struct sk_buff *skb, bool senstatic void maybe_add_creds (struct sk_buff *skb,const struct socket *sock,const struct sock *other) { -if (UNIXCB (skb).cred) +if (UNIXCB (skb).pid)return ;if (test_bit (SOCK_PASSCRED , &sock->flags) || !other->sk_socket ||test_bit (SOCK_PASSCRED , &other->sk_socket->flags)) {UNIXCB (skb).pid =get_pid (task_tgid (current)); -UNIXCB (skb).cred =get_current_cred (); +current_euid_egid (&UNIXCB (skb).uid, &UNIXCB (skb).gid); } }
@@ -1819,7 +1818,7 @@ static int unix_dgram_recvmsg(struct kiocb *iocb, struct socket *sock, siocb->scm = &tmp_scm;memset (&tmp_scm,0 ,sizeof (tmp_scm)); } -scm_set_cred (siocb->scm,UNIXCB (skb).pid,UNIXCB (skb).cred); +scm_set_cred (siocb->scm,UNIXCB (skb).pid,UNIXCB (skb).uid,UNIXCB (skb).gid);unix_set_secdata (siocb->scm, skb);if (!(flags &MSG_PEEK )) {
@@ -1991,11 +1990,12 @@ again:if (check_creds) {/* Never glue messages from different writers */ if ((UNIXCB (skb).pid != siocb->scm->pid) || - (UNIXCB (skb).cred != siocb->scm->cred)) + !uid_eq (UNIXCB (skb).uid, siocb->scm->creds.uid) || + !gid_eq (UNIXCB (skb).gid, siocb->scm->creds.gid))break ; }else if (test_bit (SOCK_PASSCRED , &sock->flags)) {/* Copy credentials */ -scm_set_cred (siocb->scm,UNIXCB (skb).pid,UNIXCB (skb).cred); +scm_set_cred (siocb->scm,UNIXCB (skb).pid,UNIXCB (skb).uid,UNIXCB (skb).gid); check_creds =1 ; }
Signature · 1 line
1.7.5.4
David Miller
maintainerRe: [PATCH 3/2] scm: Stop passing struct cred
From: [email protected] (Eric W. Biederman)
Date: Wed, 03 Apr 2013 20:28:16 -0700
Quoted 10 lines
Now that uids and gids are completely encapsulated in
kuid_tandkgid_twe no longer need to pass struct cred which allowed us to test both the uid and the user namespace for equality.Passing struct cred potentially allows us to pass the entire group list as BSD does but I don't believe the cost of cache line misses justifies retaining code for a future potential application.
Signed-off-by "Eric W. Biederman" <[email protected]>
I'll apply this to net-next once #1 and #2 propagate there.
Thanks!
Re: [PATCH 2/2] af_unix: If we don't care about credentials coallesce all messages
In reply to Eric W. BiedermanQuoted 39 lines · Eric W. Biederman
It was reported that the following LSB test case failed
https://lsbbugs.linuxfoundation.org/attachment.cgi?id=2144 because we were not coallescing unix stream messages when the application was expecting us to.The problem was that the first send was before the socket was accepted and thus
sock->sk_socketwas NULL inmaybe_add_creds, and the second send after the socket was accepted had a non-NULL value forsk->socketand thus we could tell the credentials were not needed so we did not bother.The unnecessary credentials on the first message cause
unix_stream_recvmsgto start verifying that all messages had the same credentials before coallescing and then the coallescing failed because the second message had no credentials.Ignoring credentials when we don't care in
unix_stream_recvmsgfixes a long standing pessimization which would fail to coallesce messages when reading from a unix stream socket if the senders were different even if we did not care about their credentials.I have tested this and verified that the in the LSB test case mentioned above that the messages do coallesce now, while the were failing to coallesce without this change.
Reported-by Karel Srot <[email protected]>Reported-by Ding Tianhong <[email protected]>Signed-off-by "Eric W. Biederman" <[email protected]>--- net/unix/af_unix.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)net/unix/af_unix.c +0
-0
net/unix/af_unix.c again: · line 1999
Quoted 8 lines
net/unix/af_unix.c +1
-1@@ -1993,7 +1993,7 @@ again:if ((UNIXCB (skb).pid != siocb->scm->pid) || (UNIXCB (skb).cred != siocb->scm->cred))break ; - }else { + }else if (test_bit (SOCK_PASSCRED , &sock->flags)) {/* Copy credentials */ scm_set_cred (siocb->scm,UNIXCB (skb).pid,UNIXCB (skb).cred); check_creds =1 ;
As your opinion, I think the way is better:
if (test_bit(SOCK_PASSCRED, &sock->flags)) {
if (check_creds) {
/* Never glue messages from different writers */
if ((UNIXCB(skb).pid != siocb->scm->pid) ||
(UNIXCB(skb).cred != siocb->scm->cred))
break;
} else {
/* Copy credentials */
scm_set_cred(siocb->scm, UNIXCB(skb).pid, UNIXCB(skb).cred);
check_creds = 1;
}
}Ding
Re: [PATCH 2/2] af_unix: If we don't care about credentials coallesce all messages
Quoted 51 lines · dingtianhong
Quoted 39 lines · Eric W. Biederman
It was reported that the following LSB test case failed
https://lsbbugs.linuxfoundation.org/attachment.cgi?id=2144 because we were not coallescing unix stream messages when the application was expecting us to.The problem was that the first send was before the socket was accepted and thus
sock->sk_socketwas NULL inmaybe_add_creds, and the second send after the socket was accepted had a non-NULL value forsk->socketand thus we could tell the credentials were not needed so we did not bother.The unnecessary credentials on the first message cause
unix_stream_recvmsgto start verifying that all messages had the same credentials before coallescing and then the coallescing failed because the second message had no credentials.Ignoring credentials when we don't care in
unix_stream_recvmsgfixes a long standing pessimization which would fail to coallesce messages when reading from a unix stream socket if the senders were different even if we did not care about their credentials.I have tested this and verified that the in the LSB test case mentioned above that the messages do coallesce now, while the were failing to coallesce without this change.
Reported-by Karel Srot <[email protected]>Reported-by Ding Tianhong <[email protected]>Signed-off-by "Eric W. Biederman" <[email protected]>--- net/unix/af_unix.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)net/unix/af_unix.c +0
-0net/unix/af_unix.c again: · line 1999
Quoted 8 lines
net/unix/af_unix.c +1
-1@@ -1993,7 +1993,7 @@ again:if ((UNIXCB (skb).pid != siocb->scm->pid) || (UNIXCB (skb).cred != siocb->scm->cred))break ; - }else { + }else if (test_bit (SOCK_PASSCRED , &sock->flags)) {/* Copy credentials */ scm_set_cred (siocb->scm,UNIXCB (skb).pid,UNIXCB (skb).cred); check_creds =1 ;As your opinion, I think the way is better:
Quoted 12 lines
if (test_bit(SOCK_PASSCRED, &sock->flags)) {
if (check_creds) {
/* Never glue messages from different writers */
if ((UNIXCB(skb).pid != siocb->scm->pid) ||
(UNIXCB(skb).cred != siocb->scm->cred))
break;
} else {
/* Copy credentials */
scm_set_cred(siocb->scm, UNIXCB(skb).pid, UNIXCB(skb).cred);
check_creds = 1;
}
}It is a smidge clearer in intent, but there is no functional difference. The lines get really long.
Shrug.
Patches are always welcome.
Beyond getting something correct for the right reasons I don't care.
Eric
Re: [PATCH 2/2] af_unix: If we don't care about credentials coallesce all messages
In reply to Eric W. BiedermanFrom: [email protected] (Eric W. Biederman)
Date: Wed, 03 Apr 2013 19:14:47 -0700
Quoted 22 lines
It was reported that the following LSB test case failed
https://lsbbugs.linuxfoundation.org/attachment.cgi?id=2144 because we were not coallescing unix stream messages when the application was expecting us to.The problem was that the first send was before the socket was accepted and thus
sock->sk_socketwas NULL inmaybe_add_creds, and the second send after the socket was accepted had a non-NULL value forsk->socketand thus we could tell the credentials were not needed so we did not bother.The unnecessary credentials on the first message cause
unix_stream_recvmsgto start verifying that all messages had the same credentials before coallescing and then the coallescing failed because the second message had no credentials.Ignoring credentials when we don't care in
unix_stream_recvmsgfixes a long standing pessimization which would fail to coallesce messages when reading from a unix stream socket if the senders were different even if we did not care about their credentials.
Quoted 7 lines
I have tested this and verified that the in the LSB test case mentioned above that the messages do coallesce now, while the were failing to coallesce without this change.
Reported-by Karel Srot <[email protected]>Reported-by Ding Tianhong <[email protected]>Signed-off-by "Eric W. Biederman" <[email protected]>
Applied.
Re: [PATCH 1/2] Revert "af_unix: dont send SCM_CREDENTIAL when dest socket is NULL"
In reply to Eric W. BiedermanQuoted 9 lines · Eric W. Biederman
This reverts commit
14134f6584212d585b310ce95428014b653dfaf6.The problem that the above patch was meant to address is that
af_unixmessages are not being coallesced because we are sending unnecesarry credentials. Not sending credentials inmaybe_add_credstotally breaks unconnected unix domain sockets that wish to send credentails to other sockets.
thanks for check the question and make a fix solution, but I still doubt that if unconnected unix domain socket wish to send credentails to oher sockets, why dont set SOCK_PASSCRED on sock->flags, I think the user need to decide the param
and shouldnt send creds by default way.
Ding
Quoted 26 lines
In practice this break some versions of udev because they receive a message and the sending uid is bogus so they drop the message.
Reported-by Sven Joachim <[email protected]>Signed-off-by "Eric W. Biederman" <[email protected]>--- net/unix/af_unix.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)net/unix/af_unix.c +2
-2@@ -1412,8 +1412,8 @@ static void maybe_add_creds(struct sk_buff *skb, const struct socket *sock,if (UNIXCB (skb).cred)return ;if (test_bit (SOCK_PASSCRED , &sock->flags) || - (other->sk_socket && -test_bit (SOCK_PASSCRED , &other->sk_socket->flags))) { + !other->sk_socket || +test_bit (SOCK_PASSCRED , &other->sk_socket->flags)) {UNIXCB (skb).pid =get_pid (task_tgid (current));UNIXCB (skb).cred =get_current_cred (); }
Re: [PATCH 1/2] Revert "af_unix: dont send SCM_CREDENTIAL when dest socket is NULL"
Quoted 11 lines · dingtianhong
Quoted 9 lines · Eric W. Biederman
This reverts commit
14134f6584212d585b310ce95428014b653dfaf6.The problem that the above patch was meant to address is that
af_unixmessages are not being coallesced because we are sending unnecesarry credentials. Not sending credentials inmaybe_add_credstotally breaks unconnected unix domain sockets that wish to send credentails to other sockets.
Quoted 4 lines
thanks for check the question and make a fix solution, but I still doubt that if unconnected unix domain socket wish to send credentails to oher sockets, why dont set
SOCK_PASSCREDonsock->flags, I think the user need to decide the param
and shouldnt send creds by default way.
The big issue is the semantics are the receiver sets SOCK_PASSCRED when they want to receive credentials. When transmitting packets from unconnected or unaccepted sockets we don't know if the receiver has set SOCK_PASSCRED so when in doubt transmit. Historically we always tranmitted credentials.
Furthermore we have a real regression in udev that breaks systems, so this patch must be reverted.
Eric
Re: [PATCH 1/2] Revert "af_unix: dont send SCM_CREDENTIAL when dest socket is NULL"
In reply to Eric W. BiedermanFrom: [email protected] (Eric W. Biederman)
Date: Wed, 03 Apr 2013 19:13:35 -0700
Quoted 9 lines
This reverts commit
14134f6584212d585b310ce95428014b653dfaf6.The problem that the above patch was meant to address is that
af_unixmessages are not being coallesced because we are sending unnecesarry credentials. Not sending credentials inmaybe_add_credstotally breaks unconnected unix domain sockets that wish to send credentails to other sockets.
Quoted 6 lines
In practice this break some versions of udev because they receive a message and the sending uid is bogus so they drop the message.
Reported-by Sven Joachim <[email protected]>Signed-off-by "Eric W. Biederman" <[email protected]>
Applied.
Re: [ 105/124] af_unix: dont send SCM_CREDENTIAL when dest socket is NULL
In reply to Eric DumazetQuoted 40 lines · Eric Dumazet
Quoted 39 lines · Eric W. Biederman
Quoted 8 lines · Sven Joachim
Quoted 1 line · Greg Kroah-Hartman
3.8-stable review patch. If anyone has any objections, please let me know.
I'm seeing several complaints from udevd at boot in both 3.8.6-rc1 and 3.9-rc5: "udevd[56]: sender uid=65534, message ignored". Reverting the patch below on top of 3.8.6-rc1 fixes that. I'm using udev version 175 here, and 65534 is the uid of user "nobody".
Hmm.
Ok. I don't understand the commit that was being backported here. I am pretty certain it a fix for a problem that did not exist.
Unless I am completely mis-reading
scm_recvwe only generate aSCM_CREDENTIALSmessage if the receiving socket assertsSOCK_PASSCRED. Which means that the only harm that can come from adding scm credentials to a disconnectedaf_unixsocket is a loss in efficiency.Not adding scm credentials to be passed to userspace as the commit below is doing can result is bogus data being passed to userspace. Which is very actively WRONG.
Now before
scm_recvdoes anything we first callscm_set_cred. If no credential was passed toscm_set_credwe set the uid toINVALID_UID. Whichscm_recvin the callfrom_kuid_mungedtranslates into 65534 for reporting to userspace.So this is is pretty clearly a case of us not sending the unix credentials.
Since not sending credential is just a performance optimization I can see no earthly reason why the commit below should have been applied in the first place, and no reason why it should have been backported in the second place. So my vote is that we revert this bogus commit. Upstream and then backport the revert.
Quoted 4 lines
Quoted 1 line
Am I missing something?
Well, yes, this commit fixes a real bug : We were coalescing two messages into a single one, even if the senders were different.
What???
As far as I can tell this patch can only server to _allow_ coalescing two messages into a single one.
Quoted 19 lines
Copy of a reply I did :
So the problem is that two messages have different credentials, because
other->sk_socketchanged between first and second message.and
unix_stream_recvmsg()has the following check :if (check_creds) { /* Never glue messages from different writers */ if ((UNIXCB(skb).pid != siocb->scm->pid) || (UNIXCB(skb).cred != siocb->scm->cred)) break; } else { /* Copy credentials */ scm_set_cred(siocb->scm, UNIXCB(skb).pid, UNIXCB(skb).cred); check_creds = 1; }
Quoted 2 lines
So the patch was good, and we need a followup, like the one I posted today ?
No. The patch is still bogus.
If the problem is that we are not coallescing messages in stream_recvmsg we need a different fix.
Probably something like:
if (check_creds) {
/* Never glue messages from different writers */
if ((UNIXCB(skb).pid != siocb->scm->pid) ||
(UNIXCB(skb).cred != siocb->scm->cred))
break;
- } else {
+ } else if (test_bit(SOCK_PASSCRED, &sock->flags)) {
/* Copy credentials */
scm_set_cred(siocb->scm, UNIXCB(skb).pid, UNIXCB(skb).cred);
check_creds = 1;
}Although comapring comparing the applicable uids and gids might be sensible as well.
Quoted 1 line
Some user apps dont know about uid 65534.
What??? The problem is that the app wanted the uid and we gave it garbage. You can't fix wanting a valid uid by not passing a uid.
include/net/scm.h static __inline__ void scm_recv(struct socket *sock, struct msghdr *msg, · line 126
Quoted 13 lines
include/net/scm.h +1
-1@@ -120,7 +120,7 @@ static __inline__ void scm_recv(struct socket *sock, struct msghdr *msg,return ; } -if (test_bit (SOCK_PASSCRED , &sock->flags)) { +if (test_bit (SOCK_PASSCRED , &sock->flags) && scm->creds.pid) {struct user_namespace *current_ns =current_user_ns ();struct ucred ucreds = { .pid = scm->creds.pid,
Eric
Re: [ 105/124] af_unix: dont send SCM_CREDENTIAL when dest socket is NULL
Quoted 86 lines · Eric W. Biederman
Quoted 40 lines · Eric Dumazet
Quoted 39 lines · Eric W. Biederman
Quoted 8 lines · Sven Joachim
Quoted 1 line · Greg Kroah-Hartman
3.8-stable review patch. If anyone has any objections, please let me know.
I'm seeing several complaints from udevd at boot in both 3.8.6-rc1 and 3.9-rc5: "udevd[56]: sender uid=65534, message ignored". Reverting the patch below on top of 3.8.6-rc1 fixes that. I'm using udev version 175 here, and 65534 is the uid of user "nobody".
Hmm.
Ok. I don't understand the commit that was being backported here. I am pretty certain it a fix for a problem that did not exist.
Unless I am completely mis-reading
scm_recvwe only generate aSCM_CREDENTIALSmessage if the receiving socket assertsSOCK_PASSCRED. Which means that the only harm that can come from adding scm credentials to a disconnectedaf_unixsocket is a loss in efficiency.Not adding scm credentials to be passed to userspace as the commit below is doing can result is bogus data being passed to userspace. Which is very actively WRONG.
Now before
scm_recvdoes anything we first callscm_set_cred. If no credential was passed toscm_set_credwe set the uid toINVALID_UID. Whichscm_recvin the callfrom_kuid_mungedtranslates into 65534 for reporting to userspace.So this is is pretty clearly a case of us not sending the unix credentials.
Since not sending credential is just a performance optimization I can see no earthly reason why the commit below should have been applied in the first place, and no reason why it should have been backported in the second place. So my vote is that we revert this bogus commit. Upstream and then backport the revert.
Quoted 4 lines
Quoted 1 line
Am I missing something?
Well, yes, this commit fixes a real bug : We were coalescing two messages into a single one, even if the senders were different.
What???
As far as I can tell this patch can only server to _allow_ coalescing two messages into a single one.
Quoted 19 lines
Copy of a reply I did :
So the problem is that two messages have different credentials, because
other->sk_socketchanged between first and second message.and
unix_stream_recvmsg()has the following check :if (check_creds) { /* Never glue messages from different writers */ if ((UNIXCB(skb).pid != siocb->scm->pid) || (UNIXCB(skb).cred != siocb->scm->cred)) break; } else { /* Copy credentials */ scm_set_cred(siocb->scm, UNIXCB(skb).pid, UNIXCB(skb).cred); check_creds = 1; }Quoted 2 lines
So the patch was good, and we need a followup, like the one I posted today ?
No. The patch is still bogus.
If the problem is that we are not coallescing messages in
stream_recvmsgwe need a different fix.Probably something like:
if (check_creds) { /* Never glue messages from different writers */ if ((UNIXCB(skb).pid != siocb->scm->pid) || (UNIXCB(skb).cred != siocb->scm->cred)) break;
Review
Quoted 6 lines
(quoted diff) +1
-1- } else { + } else if (test_bit(SOCK_PASSCRED, &sock->flags)) { /* Copy credentials */ scm_set_cred(siocb->scm, UNIXCB(skb).pid, UNIXCB(skb).cred); check_creds = 1; }
I'm confused. Isn't this making the problem worse, not better?
The original don't-always-pass-creds logic came from (I think):
commit 16e5726269611b71c930054ffe9b858c1cea88eb
Author: Eric Dumazet <[email protected]> Date: Mon Sep 19 05:52:27 2011 +0000
af_unix: dont send SCM_CREDENTIALS by default
Since commit 7361c36c5224 (af_unix: Allow credentials to work across user and pid namespaces) af_unix performance dropped a lot.
This is because we now take a reference on pid and cred in each write(), and release them in read(), usually done from another process, eventually from another cpu. This triggers false sharing.
With my patches, the cost should go way down and it could be made unconditional, but that's still probably not a good -stable change.
--Andy
Re: [ 105/124] af_unix: dont send SCM_CREDENTIAL when dest socket is NULL
Quoted 21 lines · Andy Lutomirski
Quoted 13 lines · Eric W. Biederman
No. The patch is still bogus.
If the problem is that we are not coallescing messages in
stream_recvmsgwe need a different fix.Probably something like:
if (check_creds) { /* Never glue messages from different writers */ if ((UNIXCB(skb).pid != siocb->scm->pid) || (UNIXCB(skb).cred != siocb->scm->cred)) break;Review
Quoted 6 lines
(quoted diff) +1
-1- } else { + } else if (test_bit(SOCK_PASSCRED, &sock->flags)) { /* Copy credentials */ scm_set_cred(siocb->scm, UNIXCB(skb).pid, UNIXCB(skb).cred); check_creds = 1; }
Quoted 1 line
I'm confused. Isn't this making the problem worse, not better?
For udev that is a don't care.
For the case where we are coallescing messages this ensures we always collaesce messages if we don't care about the credentials. Which turns out to be a fix for a long standing pessimization, that no on has bother to complain about.
Quoted 2 lines
With my patches, the cost should go way down and it could be made unconditional, but that's still probably not a good -stable change.
Reducing the cost and the complexity as far as we can is good, but we really want small steps as we optimize the case of sending credentials.
Eric
David Miller
maintainerRe: [ 105/124] af_unix: dont send SCM_CREDENTIAL when dest socket is NULL
In reply to Sven JoachimFrom: Sven Joachim <[email protected]>
Date: Wed, 03 Apr 2013 13:41:32 +0200
Quoted 8 lines · Greg Kroah-Hartman
Quoted 2 lines
3.8-stable review patch. If anyone has any objections, please let me know.
I'm seeing several complaints from udevd at boot in both 3.8.6-rc1 and 3.9-rc5: "udevd[56]: sender uid=65534, message ignored". Reverting the patch below on top of 3.8.6-rc1 fixes that. I'm using udev version 175 here, and 65534 is the uid of user "nobody".
Greg and Ben, please stop this patch from all of the -stable trees.
I'm going to revert it and use Eric Biederman's fix instead.
Thanks!
Greg KH
maintainerRe: [ 105/124] af_unix: dont send SCM_CREDENTIAL when dest socket is NULL
Quoted 5 lines · David Miller
From: Sven Joachim <[email protected]>
Date: Wed, 03 Apr 2013 13:41:32 +0200Quoted 2 lines · Greg Kroah-Hartman
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
3.8-stable review patch. If anyone has any objections, please let me know.
I'm seeing several complaints from udevd at boot in both 3.8.6-rc1 and 3.9-rc5: "udevd[56]: sender uid=65534, message ignored". Reverting the patch below on top of 3.8.6-rc1 fixes that. I'm using udev version 175 here, and 65534 is the uid of user "nobody".
Greg and Ben, please stop this patch from all of the -stable trees.
Now dropped from the 3.4.x and 3.8.x -stable trees (it wasn't part of the 3.0.x network patches that I can tell).
Quoted 1 line
I'm going to revert it and use Eric Biederman's fix instead.
That seems better, breaking older versions of udev, while fun at times, did seem to annoy a bunch of Ubuntu and Debian users :)
thanks,
greg k-h
Re: [ 105/124] af_unix: dont send SCM_CREDENTIAL when dest socket is NULL
In reply to David MillerQuoted 12 lines · David Miller
From: Sven Joachim <[email protected]>
Date: Wed, 03 Apr 2013 13:41:32 +0200Quoted 8 lines · Greg Kroah-Hartman
Quoted 2 lines
3.8-stable review patch. If anyone has any objections, please let me know.
I'm seeing several complaints from udevd at boot in both 3.8.6-rc1 and 3.9-rc5: "udevd[56]: sender uid=65534, message ignored". Reverting the patch below on top of 3.8.6-rc1 fixes that. I'm using udev version 175 here, and 65534 is the uid of user "nobody".
Quoted 5 lines
Greg and Ben, please stop this patch from all of the -stable trees.
I'm going to revert it and use Eric Biederman's fix instead.
Thanks!
OK, dropped it.
Ben.
Signature · 2 lines
Ben Hutchings I'm not a reverse psychological virus. Please don't copy me into your sig.
Greg Kroah-Hartman
maintainerPATCH 106/124 bonding: remove already created master sysfs link on failure
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Veaceslav Falico <[email protected]>
[ Upstream commit 9fe16b78ee17579cb4f333534cf7043e94c67024 ]
If slave sysfs symlink failes to be created - we end up without removing the master sysfs symlink. Remove it in case of failure.
--- drivers/net/bonding/bond_sysfs.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/bonding/bond_sysfs.c +5 -0
@@ -183,6 +183,11 @@ int bond_create_slave_symlinks(struct nesprintf (linkname,"slave_%s" , slave->name); ret =sysfs_create_link (&(master->dev.kobj), &(slave->dev.kobj), linkname); + +/* free the master link created earlier in case of error */ +if (ret) +sysfs_remove_link (&(slave->dev.kobj),"master" ); +return ret; }
Greg Kroah-Hartman
maintainerPATCH 107/124 bonding: fix disabling of arp_interval and miimon
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: "[email protected]" <[email protected]>
[ Upstream commit 1bc7db16782c2a581fb4d53ca853631050f31611 ]
Currently if either arp_interval or miimon is disabled, they both get disabled, and upon disabling they get executed once more which is not the proper behaviour. Also when doing a no-op and disabling an already disabled one, the other again gets disabled.
Also fix the error messages with the proper valid ranges, and a small typo fix in the up delay error message (outputting "down delay", instead of "up delay").
--- drivers/net/bonding/bond_sysfs.c | 92 ++++++++++++++++++++------------------- 1 file changed, 48 insertions(+), 44 deletions(-)
drivers/net/bonding/bond_sysfs.c +48 -44
@@ -527,7 +527,7 @@ static ssize_t bonding_store_arp_interva goto out; }if (new_value <0 ) { -pr_err ("%s: Invalid arp_interval value %d not in range 1-%d; rejected.\n" , +pr_err ("%s: Invalid arp_interval value %d not in range 0-%d; rejected.\n" , bond->dev->name, new_value,INT_MAX ); ret = -EINVAL ; goto out;
@@ -542,14 +542,15 @@ static ssize_t bonding_store_arp_intervapr_info ("%s: Setting ARP monitoring interval to %d.\n" , bond->dev->name, new_value); bond->params.arp_interval = new_value; -if (bond->params.miimon) { -pr_info ("%s: ARP monitoring cannot be used with MII monitoring. %s Disabling MII monitoring.\n" , - bond->dev->name, bond->dev->name); - bond->params.miimon =0 ; - } -if (!bond->params.arp_targets[0 ]) { -pr_info ("%s: ARP monitoring has been set up, but no ARP targets have been specified.\n" , - bond->dev->name); +if (new_value) { +if (bond->params.miimon) { +pr_info ("%s: ARP monitoring cannot be used with MII monitoring. %s Disabling MII monitoring.\n" , + bond->dev->name, bond->dev->name); + bond->params.miimon =0 ; + } +if (!bond->params.arp_targets[0 ]) +pr_info ("%s: ARP monitoring has been set up, but no ARP targets have been specified.\n" , + bond->dev->name); }if (bond->dev->flags &IFF_UP ) {/* If the interface is up, we may need to fire off
@@ -557,10 +558,13 @@ static ssize_t bonding_store_arp_interva* timer will get fired off when the open function * is called. */ -cancel_delayed_work_sync (&bond->mii_work); -queue_delayed_work (bond->wq, &bond->arp_work,0 ); +if (!new_value) { +cancel_delayed_work_sync (&bond->arp_work); + }else { +cancel_delayed_work_sync (&bond->mii_work); +queue_delayed_work (bond->wq, &bond->arp_work,0 ); + } } - out:rtnl_unlock ();return ret;
@@ -702,7 +706,7 @@ static ssize_t bonding_store_downdelay(s }if (new_value <0 ) {pr_err ("%s: Invalid down delay value %d not in range %d-%d; rejected.\n" , - bond->dev->name, new_value,1 ,INT_MAX ); + bond->dev->name, new_value,0 ,INT_MAX ); ret = -EINVAL ; goto out; }else {
@@ -757,8 +761,8 @@ static ssize_t bonding_store_updelay(str goto out; }if (new_value <0 ) { -pr_err ("%s: Invalid down delay value %d not in range %d-%d; rejected.\n" , - bond->dev->name, new_value,1 ,INT_MAX ); +pr_err ("%s: Invalid up delay value %d not in range %d-%d; rejected.\n" , + bond->dev->name, new_value,0 ,INT_MAX ); ret = -EINVAL ; goto out; }else {
@@ -968,37 +972,37 @@ static ssize_t bonding_store_miimon(stru }if (new_value <0 ) {pr_err ("%s: Invalid miimon value %d not in range %d-%d; rejected.\n" , - bond->dev->name, new_value,1 ,INT_MAX ); + bond->dev->name, new_value,0 ,INT_MAX ); ret = -EINVAL ; goto out; - }else { -pr_info ("%s: Setting MII monitoring interval to %d.\n" , - bond->dev->name, new_value); - bond->params.miimon = new_value; -if (bond->params.updelay) -pr_info ("%s: Note: Updating updelay (to %d) since it is a multiple of the miimon value.\n" , - bond->dev->name, - bond->params.updelay * bond->params.miimon); -if (bond->params.downdelay) -pr_info ("%s: Note: Updating downdelay (to %d) since it is a multiple of the miimon value.\n" , - bond->dev->name, - bond->params.downdelay * bond->params.miimon); -if (bond->params.arp_interval) { -pr_info ("%s: MII monitoring cannot be used with ARP monitoring. Disabling ARP monitoring...\n" , - bond->dev->name); - bond->params.arp_interval =0 ; -if (bond->params.arp_validate) { - bond->params.arp_validate = -BOND_ARP_VALIDATE_NONE ; - } - } - -if (bond->dev->flags &IFF_UP ) { -/* If the interface is up, we may need to fire off -* the MII timer. If the interface is down, the -* timer will get fired off when the open function -* is called. -*/ + } +pr_info ("%s: Setting MII monitoring interval to %d.\n" , + bond->dev->name, new_value); + bond->params.miimon = new_value; +if (bond->params.updelay) +pr_info ("%s: Note: Updating updelay (to %d) since it is a multiple of the miimon value.\n" , + bond->dev->name, + bond->params.updelay * bond->params.miimon); +if (bond->params.downdelay) +pr_info ("%s: Note: Updating downdelay (to %d) since it is a multiple of the miimon value.\n" , + bond->dev->name, + bond->params.downdelay * bond->params.miimon); +if (new_value && bond->params.arp_interval) { +pr_info ("%s: MII monitoring cannot be used with ARP monitoring. Disabling ARP monitoring...\n" , + bond->dev->name); + bond->params.arp_interval =0 ; +if (bond->params.arp_validate) + bond->params.arp_validate =BOND_ARP_VALIDATE_NONE ; + } +if (bond->dev->flags &IFF_UP ) { +/* If the interface is up, we may need to fire off +* the MII timer. If the interface is down, the +* timer will get fired off when the open function +* is called. +*/ +if (!new_value) { +cancel_delayed_work_sync (&bond->mii_work); + }else {cancel_delayed_work_sync (&bond->arp_work);queue_delayed_work (bond->wq, &bond->mii_work,0 ); }
Greg Kroah-Hartman
maintainerPATCH 108/124 drivers: net: ethernet: davinci_emac: use netif_wake_queue() while restarting tx queue
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
To restart tx queue use netif_wake_queue() intead of netif_start_queue() so that net schedule will restart transmission immediately which will increase network performance while doing huge data transfers.
--- drivers/net/ethernet/ti/davinci_emac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/ti/davinci_emac.c +1 -1
@@ -1055,7 +1055,7 @@ static void emac_tx_handler(void *token,atomic_dec (&priv->cur_tx);if (unlikely (netif_queue_stopped (ndev))) -netif_start_queue (ndev); +netif_wake_queue (ndev); ndev->stats.tx_packets++; ndev->stats.tx_bytes += len;dev_kfree_skb_any (skb);
Greg Kroah-Hartman
maintainerPATCH 109/124 drivers: net: ethernet: cpsw: use netif_wake_queue() while restarting tx queue
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mugunthan V N <[email protected]>
[ Upstream commit b56d6b3fca6d1214dbc9c5655f26e5d4ec04afc8 ]
To restart tx queue use netif_wake_queue() intead of netif_start_queue() so that net schedule will restart transmission immediately which will increase network performance while doing huge data transfers.
--- drivers/net/ethernet/ti/cpsw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/ti/cpsw.c +1 -1
@@ -375,7 +375,7 @@ void cpsw_tx_handler(void *token, int lestruct cpsw_priv *priv =netdev_priv (ndev);if (unlikely (netif_queue_stopped (ndev))) -netif_start_queue (ndev); +netif_wake_queue (ndev);cpts_tx_timestamp (&priv->cpts, skb); priv->stats.tx_packets++; priv->stats.tx_bytes += len;
Greg Kroah-Hartman
maintainerPATCH 110/124 net: fix *_DIAG_MAX constants
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrey Vagin <[email protected]>
[ Upstream commit ae5fc98728c8bbbd6d7cab0b9781671fc4419c1b ]
Follow the common pattern and define *_DIAG_MAX like:
[...]
__XXX_DIAG_MAX,
};Because everyone is used to do:
struct nlattr *attrs[XXX_DIAG_MAX+1];
nla_parse([...], XXX_DIAG_MAX, [...]--- include/uapi/linux/packet_diag.h | 4 +++- include/uapi/linux/unix_diag.h | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-)
include/uapi/linux/packet_diag.h +3 -1
@@ -33,9 +33,11 @@ enum { PACKET_DIAG_TX_RING,PACKET_DIAG_FANOUT , - PACKET_DIAG_MAX, + __PACKET_DIAG_MAX, }; +#define PACKET_DIAG_MAX (__PACKET_DIAG_MAX - 1) +struct packet_diag_info {__u32 pdi_index;__u32 pdi_version;
include/uapi/linux/unix_diag.h +3 -1
@@ -39,9 +39,11 @@ enum { UNIX_DIAG_MEMINFO,UNIX_DIAG_SHUTDOWN , - UNIX_DIAG_MAX, + __UNIX_DIAG_MAX, }; +#define UNIX_DIAG_MAX (__UNIX_DIAG_MAX - 1) +struct unix_diag_vfs {__u32 udiag_vfs_ino;__u32 udiag_vfs_dev;
Greg Kroah-Hartman
maintainerPATCH 111/124 aoe: reserve enough headroom on skbs
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 91c5746425aed8f7188a351f1224a26aa232e4b3 ]
Some network drivers use a non default hard_header_len
Transmitted skb should take into account dev->hard_header_len, or risk crashes or expensive reallocations.
In the case of aoe, lets reserve MAX_HEADER bytes.
David reported a crash in defxx driver, solved by this patch.
--- drivers/block/aoe/aoecmd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/block/aoe/aoecmd.c +2 -1
@@ -51,8 +51,9 @@ new_skb(ulong len) {struct sk_buff *skb; - skb =alloc_skb (len,GFP_ATOMIC ); + skb =alloc_skb (len +MAX_HEADER ,GFP_ATOMIC );if (skb) { +skb_reserve (skb,MAX_HEADER );skb_reset_mac_header (skb);skb_reset_network_header (skb); skb->protocol =__constant_htons (ETH_P_AOE );
Greg Kroah-Hartman
maintainerPATCH 112/124 atl1e: drop pci-msi support because of packet corruption
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hannes Frederic Sowa <[email protected]>
[ Upstream commit 188ab1b105c96656f6bcfb49d0d8bb1b1936b632 ]
Usage of pci-msi results in corrupted dma packet transfers to the host.
--- drivers/net/ethernet/atheros/atl1e/atl1e.h | 1 - drivers/net/ethernet/atheros/atl1e/atl1e_main.c | 19 ++----------------- 2 files changed, 2 insertions(+), 18 deletions(-)
drivers/net/ethernet/atheros/atl1e/atl1e.h +0 -1
@@ -438,7 +438,6 @@ struct atl1e_adapter {struct atl1e_hw hw;struct atl1e_hw_stats hw_stats; -bool have_msi;u32 wol;u16 link_speed;u16 link_duplex;
drivers/net/ethernet/atheros/atl1e/atl1e_main.c +2 -17
@@ -1851,34 +1851,19 @@ static void atl1e_free_irq(struct atl1e_struct net_device *netdev = adapter->netdev;free_irq (adapter->pdev->irq, netdev); - -if (adapter->have_msi) -pci_disable_msi (adapter->pdev); }static int atl1e_request_irq (struct atl1e_adapter *adapter) {struct pci_dev *pdev = adapter->pdev;struct net_device *netdev = adapter->netdev; -int flags =0 ;int err =0 ; - adapter->have_msi = true; - err =pci_enable_msi (pdev); -if (err) { -netdev_dbg (netdev, -"Unable to allocate MSI interrupt Error: %d\n" , err); - adapter->have_msi = false; - } - -if (!adapter->have_msi) - flags |=IRQF_SHARED ; - err =request_irq (pdev->irq, atl1e_intr, flags, netdev->name, netdev); + err =request_irq (pdev->irq, atl1e_intr,IRQF_SHARED , netdev->name, + netdev);if (err) {netdev_dbg (adapter->netdev,"Unable to allocate interrupt Error: %d\n" , err); -if (adapter->have_msi) -pci_disable_msi (pdev);return err; }netdev_dbg (netdev,"atl1e_request_irq OK\n" );
Greg Kroah-Hartman
maintainerPATCH 113/124 DM9000B: driver initialization upgrade
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joseph CHANG <[email protected]>
[ Upstream commit 6741f40d198c6a5feb23653a1efd4ca47f93d83d ]
Fix bug for DM9000 revision B which contain a DSP PHY
DM9000B use DSP PHY instead previouse DM9000 revisions' analog PHY, So need extra change in initialization, For
explicity PHY Reset and PHY init parameter, and
first DM9000_NCR reset need NCR_MAC_LBK bit by dm9000_probe().
Following DM9000_NCR reset cause by dm9000_open() clear the NCR_MAC_LBK bit.
Without this fix, Power-up FIFO pointers error happen around 2% rate among Davicom's customers' boards. With this fix, All above cases can be solved.
--- drivers/net/ethernet/davicom/dm9000.c | 214 +++++++++++++++++----------------- drivers/net/ethernet/davicom/dm9000.h | 11 + 2 files changed, 120 insertions(+), 105 deletions(-)
drivers/net/ethernet/davicom/dm9000.c +110 -104
@@ -257,6 +257,107 @@ static void dm9000_dumpblk_32bit(void __ tmp =readl (reg); } +/* +* Sleep, either by using msleep() or if we are suspending, then +* use mdelay() to sleep. +*/ +static void dm9000_msleep (board_info_t *db,unsigned int ms) +{ +if (db->in_suspend) +mdelay (ms); +else +msleep (ms); +} + +/* Read a word from phyxcer */ +static int +dm9000_phy_read (struct net_device *dev,int phy_reg_unused,int reg) +{ +board_info_t *db =netdev_priv (dev); +unsigned long flags; +unsigned int reg_save; +int ret; + +mutex_lock (&db->addr_lock); + +spin_lock_irqsave (&db->lock, flags); + +/* Save previous register address */ + reg_save =readb (db->io_addr); + +/* Fill the phyxcer register into REG_0C */ +iow (db,DM9000_EPAR ,DM9000_PHY | reg); + +/* Issue phyxcer read command */ +iow (db,DM9000_EPCR ,EPCR_ERPRR |EPCR_EPOS ); + +writeb (reg_save, db->io_addr); +spin_unlock_irqrestore (&db->lock, flags); + +dm9000_msleep (db,1 );/* Wait read complete */ + +spin_lock_irqsave (&db->lock, flags); + reg_save =readb (db->io_addr); + +iow (db,DM9000_EPCR ,0x0 );/* Clear phyxcer read command */ + +/* The read data keeps on REG_0D & REG_0E */ + ret = (ior (db,DM9000_EPDRH ) <<8 ) |ior (db,DM9000_EPDRL ); + +/* restore the previous address */ +writeb (reg_save, db->io_addr); +spin_unlock_irqrestore (&db->lock, flags); + +mutex_unlock (&db->addr_lock); + +dm9000_dbg (db,5 ,"phy_read[%02x] -> %04x\n" , reg, ret); +return ret; +} + +/* Write a word to phyxcer */ +static void +dm9000_phy_write (struct net_device *dev, +int phyaddr_unused,int reg,int value) +{ +board_info_t *db =netdev_priv (dev); +unsigned long flags; +unsigned long reg_save; + +dm9000_dbg (db,5 ,"phy_write[%02x] = %04x\n" , reg, value); +mutex_lock (&db->addr_lock); + +spin_lock_irqsave (&db->lock, flags); + +/* Save previous register address */ + reg_save =readb (db->io_addr); + +/* Fill the phyxcer register into REG_0C */ +iow (db,DM9000_EPAR ,DM9000_PHY | reg); + +/* Fill the written data into REG_0D & REG_0E */ +iow (db,DM9000_EPDRL , value); +iow (db,DM9000_EPDRH , value >>8 ); + +/* Issue phyxcer write command */ +iow (db,DM9000_EPCR ,EPCR_EPOS |EPCR_ERPRW ); + +writeb (reg_save, db->io_addr); +spin_unlock_irqrestore (&db->lock, flags); + +dm9000_msleep (db,1 );/* Wait write complete */ + +spin_lock_irqsave (&db->lock, flags); + reg_save =readb (db->io_addr); + +iow (db,DM9000_EPCR ,0x0 );/* Clear phyxcer write command */ + +/* restore the previous address */ +writeb (reg_save, db->io_addr); + +spin_unlock_irqrestore (&db->lock, flags); +mutex_unlock (&db->addr_lock); +} +/* dm9000_set_io * * select the specified set of io routines to use with the
@@ -794,6 +895,9 @@ dm9000_init_dm9000(struct net_device *deiow (db,DM9000_GPCR ,GPCR_GEP_CNTL );/* Let GPIO0 output */ +dm9000_phy_write (dev,0 ,MII_BMCR ,BMCR_RESET );/* PHY RESET */ +dm9000_phy_write (dev,0 ,MII_DM_DSPCR ,DSPCR_INIT_PARAM );/* Init */ + ncr = (db->flags &DM9000_PLATF_EXT_PHY ) ?NCR_EXT_PHY :0 ;/* if wol is needed, then always set NCR_WAKEEN otherwise we end
@@ -1200,109 +1304,6 @@ dm9000_open(struct net_device *dev)return 0 ; } -/* -* Sleep, either by using msleep() or if we are suspending, then -* use mdelay() to sleep. -*/ -static void dm9000_msleep (board_info_t *db,unsigned int ms) -{ -if (db->in_suspend) -mdelay (ms); -else -msleep (ms); -} - -/* -* Read a word from phyxcer -*/ -static int -dm9000_phy_read (struct net_device *dev,int phy_reg_unused,int reg) -{ -board_info_t *db =netdev_priv (dev); -unsigned long flags; -unsigned int reg_save; -int ret; - -mutex_lock (&db->addr_lock); - -spin_lock_irqsave (&db->lock,flags); - -/* Save previous register address */ - reg_save =readb (db->io_addr); - -/* Fill the phyxcer register into REG_0C */ -iow (db,DM9000_EPAR ,DM9000_PHY | reg); - -iow (db,DM9000_EPCR ,EPCR_ERPRR |EPCR_EPOS );/* Issue phyxcer read command */ - -writeb (reg_save, db->io_addr); -spin_unlock_irqrestore (&db->lock,flags); - -dm9000_msleep (db,1 );/* Wait read complete */ - -spin_lock_irqsave (&db->lock,flags); - reg_save =readb (db->io_addr); - -iow (db,DM9000_EPCR ,0x0 );/* Clear phyxcer read command */ - -/* The read data keeps on REG_0D & REG_0E */ - ret = (ior (db,DM9000_EPDRH ) <<8 ) |ior (db,DM9000_EPDRL ); - -/* restore the previous address */ -writeb (reg_save, db->io_addr); -spin_unlock_irqrestore (&db->lock,flags); - -mutex_unlock (&db->addr_lock); - -dm9000_dbg (db,5 ,"phy_read[%02x] -> %04x\n" , reg, ret); -return ret; -} - -/* -* Write a word to phyxcer -*/ -static void -dm9000_phy_write (struct net_device *dev, -int phyaddr_unused,int reg,int value) -{ -board_info_t *db =netdev_priv (dev); -unsigned long flags; -unsigned long reg_save; - -dm9000_dbg (db,5 ,"phy_write[%02x] = %04x\n" , reg, value); -mutex_lock (&db->addr_lock); - -spin_lock_irqsave (&db->lock,flags); - -/* Save previous register address */ - reg_save =readb (db->io_addr); - -/* Fill the phyxcer register into REG_0C */ -iow (db,DM9000_EPAR ,DM9000_PHY | reg); - -/* Fill the written data into REG_0D & REG_0E */ -iow (db,DM9000_EPDRL , value); -iow (db,DM9000_EPDRH , value >>8 ); - -iow (db,DM9000_EPCR ,EPCR_EPOS |EPCR_ERPRW );/* Issue phyxcer write command */ - -writeb (reg_save, db->io_addr); -spin_unlock_irqrestore (&db->lock, flags); - -dm9000_msleep (db,1 );/* Wait write complete */ - -spin_lock_irqsave (&db->lock,flags); - reg_save =readb (db->io_addr); - -iow (db,DM9000_EPCR ,0x0 );/* Clear phyxcer write command */ - -/* restore the previous address */ -writeb (reg_save, db->io_addr); - -spin_unlock_irqrestore (&db->lock, flags); -mutex_unlock (&db->addr_lock); -} -static void dm9000_shutdown (struct net_device *dev) {
@@ -1501,7 +1502,12 @@ dm9000_probe(struct platform_device *pde db->flags |=DM9000_PLATF_SIMPLE_PHY ;#endif -dm9000_reset (db); +/* Fixing bug on dm9000_probe, takeover dm9000_reset(db), +* Need 'NCR_MAC_LBK' bit to indeed stable our DM9000 fifo +* while probe stage. +*/ + +iow (db,DM9000_NCR ,NCR_MAC_LBK |NCR_RST );/* try multiple times, DM9000 sometimes gets the read wrong */ for (i =0 ; i <8 ; i++) {
drivers/net/ethernet/davicom/dm9000.h +10 -1
@@ -69,7 +69,9 @@#define NCR_WAKEEN (1<<6)#define NCR_FCOL (1<<4)#define NCR_FDX (1<<3) -#define NCR_LBK (3<<1) + +#define NCR_RESERVED (3<<1) +#define NCR_MAC_LBK (1<<1)#define NCR_RST (1<<0)#define NSR_SPEED (1<<7)
@@ -167,5 +169,12 @@#define ISR_LNKCHNG (1<<5)#define ISR_UNDERRUN (1<<4) +/* Davicom MII registers. +*/ + +#define MII_DM_DSPCR 0x1b/* DSP Control Register */ + +#define DSPCR_INIT_PARAM 0xE100/* DSP init parameter */ +#endif /* _DM9000X_H_ */
Greg Kroah-Hartman
maintainerPATCH 114/124 fec: Fix the build as module
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fabio Estevam <[email protected]>
[ Upstream commit 9d73adf431e093b23fb4990f1ade11283cb67a98 ]
Since commit ff43da86c69 (NET: FEC: dynamtic check DMA desc buff type) the following build error happens when CONFIG_FEC=m
ERROR: "fec_ptp_init" [drivers/net/ethernet/freescale/fec.ko] undefined!
ERROR: "fec_ptp_ioctl" [drivers/net/ethernet/freescale/fec.ko] undefined!
ERROR: "fec_ptp_start_cyclecounter" [drivers/net/ethernet/freescale/fec.ko] undefined!
Fix it by exporting the required fec_ptp symbols.
--- drivers/net/ethernet/freescale/fec_ptp.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/freescale/fec_ptp.c +3 -0
@@ -128,6 +128,7 @@ void fec_ptp_start_cyclecounter(struct nspin_unlock_irqrestore (&fep->tmreg_lock, flags); } +EXPORT_SYMBOL (fec_ptp_start_cyclecounter);/** * fec_ptp_adjfreq - adjust ptp cycle frequency
@@ -318,6 +319,7 @@ int fec_ptp_ioctl(struct net_device *ndereturn copy_to_user (ifr->ifr_data, &config,sizeof (config)) ? -EFAULT :0 ; } +EXPORT_SYMBOL (fec_ptp_ioctl);/** * fec_time_keep - call timecounter_read every second to avoid timer overrun
@@ -381,3 +383,4 @@ void fec_ptp_init(struct net_device *ndepr_info ("registered PHC device on %s\n" , ndev->name); } } +EXPORT_SYMBOL (fec_ptp_init);
Greg Kroah-Hartman
maintainerPATCH 115/124 ipv6: fix bad free of addrconf_init_net
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hong Zhiguo <[email protected]>
[ Upstream commit a79ca223e029aa4f09abb337accf1812c900a800 ]
--- net/ipv6/addrconf.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-)
net/ipv6/addrconf.c +10 -16
@@ -4787,26 +4787,20 @@ static void addrconf_sysctl_unregister(sstatic int __net_init addrconf_init_net (struct net *net) { -int err; +int err = -ENOMEM ;struct ipv6_devconf *all, *dflt; - err = -ENOMEM ; - all = &ipv6_devconf; - dflt = &ipv6_devconf_dflt; + all =kmemdup (&ipv6_devconf,sizeof (ipv6_devconf),GFP_KERNEL ); +if (all ==NULL ) + goto err_alloc_all; -if (!net_eq (net, &init_net)) { - all =kmemdup (all,sizeof (ipv6_devconf),GFP_KERNEL ); -if (all ==NULL ) - goto err_alloc_all; + dflt =kmemdup (&ipv6_devconf_dflt,sizeof (ipv6_devconf_dflt),GFP_KERNEL ); +if (dflt ==NULL ) + goto err_alloc_dflt; - dflt =kmemdup (dflt,sizeof (ipv6_devconf_dflt),GFP_KERNEL ); -if (dflt ==NULL ) - goto err_alloc_dflt; - }else { -/* these will be inherited by all namespaces */ - dflt->autoconf = ipv6_defaults.autoconf; - dflt->disable_ipv6 = ipv6_defaults.disable_ipv6; - } +/* these will be inherited by all namespaces */ + dflt->autoconf = ipv6_defaults.autoconf; + dflt->disable_ipv6 = ipv6_defaults.disable_ipv6; net->ipv6.devconf_all = all; net->ipv6.devconf_dflt = dflt;
Greg Kroah-Hartman
maintainerPATCH 116/124 ipv6: dont accept multicast traffic with scope 0
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hannes Frederic Sowa <[email protected]>
[ Upstream commit 20314092c1b41894d8c181bf9aa6f022be2416aa ]
v2:
a) moved before multicast source address check
b) changed comment to netdev style
--- net/ipv6/ip6_input.c | 9 +++++++++ 1 file changed, 9 insertions(+)
net/ipv6/ip6_input.c +9 -0
@@ -118,6 +118,15 @@ int ipv6_rcv(struct sk_buff *skb, struct ipv6_addr_loopback(&hdr->daddr)) goto err; +/* RFC4291 2.7 +* Nodes must not originate a packet to a multicast address whose scope +* field contains the reserved value 0; if such a packet is received, it +* must be silently dropped. +*/ +if (ipv6_addr_is_multicast (&hdr->daddr) && +IPV6_ADDR_MC_SCOPE (&hdr->daddr) ==0 ) + goto err; +/* * RFC4291 2.7 * Multicast addresses must not be used as source addresses in IPv6
Greg Kroah-Hartman
maintainerPATCH 117/124 ipv6: dont accept node local multicast traffic from the wire
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hannes Frederic Sowa <[email protected]>
[ Upstream commit 1c4a154e5253687c51123956dfcee9e9dfa8542d ]
Erik Hugne's errata proposal (Errata ID: 3480) to RFC4291 has been
verified: http://www.rfc-editor.org/errata_search.php?eid=3480
We have to check for pkt_type and loopback flag because either the packets are allowed to travel over the loopback interface (in which case pkt_type is PACKET_HOST and IFF_LOOPBACK flag is set) or they travel over a non-loopback interface back to us (in which case PACKET_TYPE is PACKET_LOOPBACK and IFF_LOOPBACK flag is not set).
--- net/ipv6/ip6_input.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
net/ipv6/ip6_input.c +12 -0
@@ -118,6 +118,18 @@ int ipv6_rcv(struct sk_buff *skb, struct ipv6_addr_loopback(&hdr->daddr)) goto err; +/* RFC4291 Errata ID: 3480 +* Interface-Local scope spans only a single interface on a +* node and is useful only for loopback transmission of +* multicast. Packets with interface-local scope received +* from another node must be discarded. +*/ +if (!(skb->pkt_type ==PACKET_LOOPBACK || + dev->flags &IFF_LOOPBACK ) && +ipv6_addr_is_multicast (&hdr->daddr) && +IPV6_ADDR_MC_SCOPE (&hdr->daddr) ==1 ) + goto err; +/* RFC4291 2.7 * Nodes must not originate a packet to a multicast address whose scope * field contains the reserved value 0; if such a packet is received, it
Greg Kroah-Hartman
maintainerPATCH 118/124 ks8851: Fix interpretation of rxlen field.
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: "[email protected]" <[email protected]>
[ Upstream commit 14bc435ea54cb888409efb54fc6b76c13ef530e9 ]
According to the Datasheet (page 52):
15-12 Reserved
11-0 RXBC Receive Byte Count
This field indicates the present received frame byte size.
The code has a bug:
rxh = ks8851_rdreg32(ks, KS_RXFHSR);
rxstat = rxh & 0xffff;
rxlen = rxh >> 16; // BUG!!! 0xFFF mask should be applied--- drivers/net/ethernet/micrel/ks8851.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/micrel/ks8851.c +1 -1
@@ -547,7 +547,7 @@ static void ks8851_rx_pkts(struct ks8851for (; rxfc !=0 ; rxfc--) { rxh =ks8851_rdreg32 (ks,KS_RXFHSR ); rxstat = rxh &0xffff ; - rxlen = rxh >>16 ; + rxlen = (rxh >>16 ) &0xfff ;netif_dbg (ks, rx_status, ks->netdev,"rx: stat 0x%04x, len 0x%04x\n" , rxstat, rxlen);
Greg Kroah-Hartman
maintainerPATCH 119/124 net: add a synchronize_net() in netdev_rx_handler_unregister()
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 00cfec37484761a44a3b6f4675a54caa618210ae ]
commit 35d48903e97819 (bonding: fix rx_handler locking) added a race in bonding driver, reported by Steven Rostedt who did a very good diagnosis :
<quoting Steven>
I'm currently debugging a crash in an old 3.0-rt kernel that one of our customers is seeing. The bug happens with a stress test that loads and unloads the bonding module in a loop (I don't know all the details as I'm not the one that is directly interacting with the customer). But the bug looks to be something that may still be present and possibly present in mainline too. It will just be much harder to trigger it in mainline.
In -rt, interrupts are threads, and can schedule in and out just like any other thread. Note, mainline now supports interrupt threads so this may be easily reproducible in mainline as well. I don't have the ability to tell the customer to try mainline or other kernels, so my hands are somewhat tied to what I can do.
But according to a core dump, I tracked down that the eth irq thread crashed in bond_handle_frame() here:
slave = bond_slave_get_rcu(skb->dev);
bond = slave->bond; <--- BUGthe slave returned was NULL and accessing slave->bond caused a NULL pointer dereference.
Looking at the code that unregisters the handler:
void netdev_rx_handler_unregister(struct net_device *dev) {
ASSERT_RTNL();
RCU_INIT_POINTER(dev->rx_handler, NULL);
RCU_INIT_POINTER(dev->rx_handler_data, NULL);
}Which is basically:
dev->rx_handler = NULL;
dev->rx_handler_data = NULL;And looking at __netif_receive_skb() we have:
rx_handler = rcu_dereference(skb->dev->rx_handler);
if (rx_handler) {
if (pt_prev) {
ret = deliver_skb(skb, pt_prev, orig_dev);
pt_prev = NULL;
}
switch (rx_handler(&skb)) {My question to all of you is, what stops this interrupt from happening while the bonding module is unloading? What happens if the interrupt triggers and we have this:
CPU0 CPU1
---- ---- rx_handler = skb->dev->rx_handler
netdev_rx_handler_unregister() {
dev->rx_handler = NULL;
dev->rx_handler_data = NULL; rx_handler()
bond_handle_frame() {
slave = skb->dev->rx_handler;
bond = slave->bond; <-- NULL pointer dereference!!!What protection am I missing in the bond release handler that would prevent the above from happening?
</quoting Steven>
We can fix bug this in two ways. First is adding a test in bond_handle_frame() and others to check if rx_handler_data is NULL.
A second way is adding a synchronize_net() in netdev_rx_handler_unregister() to make sure that a rcu protected reader has the guarantee to see a non NULL rx_handler_data.
The second way is better as it avoids an extra test in fast path.
--- net/core/dev.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/core/dev.c +6 -0
@@ -3276,6 +3276,7 @@ int netdev_rx_handler_register(struct neif (dev->rx_handler)return -EBUSY ; +/* Note: rx_handler_data must be set before rx_handler */ rcu_assign_pointer (dev->rx_handler_data, rx_handler_data);rcu_assign_pointer (dev->rx_handler, rx_handler);
@@ -3296,6 +3297,11 @@ void netdev_rx_handler_unregister(structASSERT_RTNL ();RCU_INIT_POINTER (dev->rx_handler,NULL ); +/* a reader seeing a non NULL rx_handler in a rcu_read_lock() +* section has a guarantee to see a non NULL rx_handler_data +* as well. +*/ +synchronize_net ();RCU_INIT_POINTER (dev->rx_handler_data,NULL ); }EXPORT_SYMBOL_GPL (netdev_rx_handler_unregister);
Greg Kroah-Hartman
maintainerPATCH 120/124 net: ethernet: cpsw: fix erroneous condition in error check
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: =?UTF-8?q?Lothar=20Wa=C3=9Fmann?= <[email protected]>
[ Upstream commit ce16294fda230c787ce5c35f61b2f80d14d70a72 ]
The error check in cpsw_probe_dt() has an '&&' where an '||' is meant to be. This causes a NULL pointer dereference when incomplet DT data is passed to the driver ('phy_id' property for cpsw_emac1 missing).
--- drivers/net/ethernet/ti/cpsw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/ti/cpsw.c +1 -1
@@ -1111,7 +1111,7 @@ static int cpsw_probe_dt(struct cpsw_plastruct platform_device *mdio; parp =of_get_property (slave_node,"phy_id" , &lenp); -if ((parp ==NULL ) && (lenp != (sizeof (void *) *2 ))) { +if ((parp ==NULL ) || (lenp != (sizeof (void *) *2 ))) {pr_err ("Missing slave[%d] phy_id property\n" , i); ret = -EINVAL ; goto error_ret;
Greg Kroah-Hartman
maintainerPATCH 121/124 net: fix the use of this_cpu_ptr
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li RongQing <[email protected]>
[ Upstream commit 50eab0503a7579ada512e4968738b7c9737cf36e ]
flush_tasklet is not percpu var, and percpu is percpu var, and
this_cpu_ptr(&info->cache->percpu->flush_tasklet) is not equal to &this_cpu_ptr(info->cache->percpu)->flush_tasklet
1f743b076(use this_cpu_ptr per-cpu helper) introduced this bug.
--- net/core/flow.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/flow.c +1 -1
@@ -329,7 +329,7 @@ static void flow_cache_flush_per_cpu(voistruct flow_flush_info *info = data;struct tasklet_struct *tasklet; - tasklet =this_cpu_ptr (&info->cache->percpu->flush_tasklet); + tasklet = &this_cpu_ptr (info->cache->percpu)->flush_tasklet; tasklet->data = (unsigned long )info;tasklet_schedule (tasklet); }
Greg Kroah-Hartman
maintainerPATCH 122/124 net: fq_codel: Fix off-by-one error
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vijay Subramanian <[email protected]>
[ Upstream commit cd68ddd4c29ab523440299f24ff2417fe7a0dca6 ]
Currently, we hold a max of sch->limit -1 number of packets instead of sch->limit packets. Fix this off-by-one error.
--- net/sched/sch_fq_codel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/sch_fq_codel.c +1 -1
@@ -195,7 +195,7 @@ static int fq_codel_enqueue(struct sk_bu flow->deficit = q->quantum; flow->dropped =0 ; } -if (++sch->q.qlen < sch->limit) +if (++sch->q.qlen <= sch->limit)return NET_XMIT_SUCCESS ; q->drop_overlimit++;
Greg Kroah-Hartman
maintainerPATCH 123/124 pch_gbe: fix ip_summed checksum reporting on rx
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Veaceslav Falico <[email protected]>
[ Upstream commit 76a0e68129d7d24eb995a6871ab47081bbfa0acc ]
skb->ip_summed should be CHECKSUM_UNNECESSARY when the driver reports that checksums were correct and CHECKSUM_NONE in any other case. They're currently placed vice versa, which breaks the forwarding scenario. Fix it by placing them as described above.
--- drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c +2 -2
@@ -1726,9 +1726,9 @@ pch_gbe_clean_rx(struct pch_gbe_adapter skb->protocol =eth_type_trans (skb, netdev);if (tcp_ip_status &PCH_GBE_RXD_ACC_STAT_TCPIPOK ) - skb->ip_summed =CHECKSUM_NONE ; -else skb->ip_summed =CHECKSUM_UNNECESSARY ; +else + skb->ip_summed =CHECKSUM_NONE ;napi_gro_receive (&adapter->napi, skb); (*work_done)++;
Greg Kroah-Hartman
maintainerPATCH 124/124 smsc75xx: fix jumbo frame support
In reply to Greg Kroah-Hartman3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steve Glendinning <[email protected]>
[ Upstream commit 4c51e53689569398d656e631c17308d9b8e84650 ]
This patch enables RX of jumbo frames for LAN7500.
Previously the driver would transmit jumbo frames succesfully but would drop received jumbo frames (incrementing the interface errors count).
With this patch applied the device can succesfully receive jumbo frames up to MTU 9000 (9014 bytes on the wire including ethernet header).
--- drivers/net/usb/smsc75xx.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/net/usb/smsc75xx.c +8 -4
@@ -914,8 +914,12 @@ static int smsc75xx_set_rx_max_frame_lenstatic int smsc75xx_change_mtu (struct net_device *netdev,int new_mtu) {struct usbnet *dev =netdev_priv (netdev); +int ret; + +if (new_mtu >MAX_SINGLE_PACKET_SIZE ) +return -EINVAL ; -int ret =smsc75xx_set_rx_max_frame_length (dev, new_mtu); + ret =smsc75xx_set_rx_max_frame_length (dev, new_mtu +ETH_HLEN );if (ret <0 ) {netdev_warn (dev->net,"Failed to set mac rx frame length\n" );return ret;
@@ -1324,7 +1328,7 @@ static int smsc75xx_reset(struct usbnetnetif_dbg (dev, ifup, dev->net,"FCT_TX_CTL set to 0x%08x\n" , buf); - ret =smsc75xx_set_rx_max_frame_length (dev,1514 ); + ret =smsc75xx_set_rx_max_frame_length (dev, dev->net->mtu +ETH_HLEN );if (ret <0 ) {netdev_warn (dev->net,"Failed to set max rx frame length\n" );return ret;
@@ -2136,8 +2140,8 @@ static int smsc75xx_rx_fixup(struct usbnelse if (rx_cmd_a & (RX_CMD_A_LONG |RX_CMD_A_RUNT )) dev->net->stats.rx_frame_errors++; }else { -/* ETH_FRAME_LEN + 4(CRC) + 2(COE) + 4(Vlan) */ -if (unlikely (size > (ETH_FRAME_LEN +12 ))) { +/* MAX_SINGLE_PACKET_SIZE + 4(CRC) + 2(COE) + 4(Vlan) */ +if (unlikely (size > (MAX_SINGLE_PACKET_SIZE +ETH_HLEN +12 ))) {netif_dbg (dev, rx_err, dev->net,"size err rx_cmd_a=0x%08x\n" , rx_cmd_a);
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 3.8.6 release. There are 124 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu Apr 4 22:09:55 UTC 2013. Anything received after that time might be too late.
Quoted 8 lines
The whole patch series can be found in one patch at:
kernel.org/pub/linux/kernel/v3.0/stable-review/patch-3.8.6-rc1.gzand the diffstat can be found below.
thanks,
greg k-h
Patches applied cleanly to 3.0.71, 3.4.38, and 3.8.5
Reviewing patches - will let you know anything odd.
Compiled and booted on the following systems:
HP EliteBook 6930p Intel(R) Core(TM)2 Duo CPU T9400 @ 2.53GHz HP ProBook 6475b AMD A10-4600M APU with Radeon(tm) HD Graphics
dmesgs for all releases look good. No regressions compared to the previous dmesgs for each of these releases.
mips compile problem fixed
Cross-compile tests results:
alpha: defconfig passed on all
arm: defconfig passed on all
arm64: not applicable to 3.0.y, 3.4.y. defconfig passed on 3.8.y
c6x: not applicable to 3.0.y, defconfig passed on 3.4.y, and 3.8.y.
powerpc: wii_defconfig passed on all
sh: defconfig passed on all
sparc: defconfig passed on all
tile: tilegx_defconfig passed on all
mips: defconfig passed on all
mipsel: defconfig passed on all
-- Shuah
Greg Kroah-Hartman
maintainerQuoted 36 lines · Shuah Khan
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 3.8.6 release. There are 124 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu Apr 4 22:09:55 UTC 2013. Anything received after that time might be too late.
Quoted 8 lines
The whole patch series can be found in one patch at:
kernel.org/pub/linux/kernel/v3.0/stable-review/patch-3.8.6-rc1.gzand the diffstat can be found below.
thanks,
greg k-h
Patches applied cleanly to 3.0.71, 3.4.38, and 3.8.5
Reviewing patches - will let you know anything odd.
Compiled and booted on the following systems:
HP EliteBook 6930p Intel(R) Core(TM)2 Duo CPU T9400 @ 2.53GHz HP ProBook 6475b AMD A10-4600M APU with Radeon(tm) HD Graphics
dmesgs for all releases look good. No regressions compared to the previous dmesgs for each of these releases.
mips compile problem fixed
Cross-compile tests results:
Quoted 10 lines
alpha: defconfig passed on all
arm: defconfig passed on all
arm64: not applicable to 3.0.y, 3.4.y. defconfig passed on 3.8.y
c6x: not applicable to 3.0.y, defconfig passed on 3.4.y, and 3.8.y.
powerpc:wii_defconfigpassed on all
sh: defconfig passed on all
sparc: defconfig passed on all
tile:tilegx_defconfigpassed on all
mips: defconfig passed on all
mipsel: defconfig passed on all
Thanks for testing, and confirming that I got the build problem fixed.
greg k-h