linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [3.8.y.z extended stable] Linux 3.8.13.27 stable review
@ 2014-07-22 22:20 Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 001/116] igb: fix stats for i210 rx_fifo_errors Kamal Mostafa
                   ` (115 more replies)
  0 siblings, 116 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Kamal Mostafa

This is the start of the review cycle for the Linux 3.8.13.27 stable kernel.

This version contains 116 new patches, summarized below.  The new patches are
posted as replies to this message and also available in this git branch:

http://kernel.ubuntu.com/git?p=ubuntu/linux.git;h=linux-3.8.y-review;a=shortlog

git://kernel.ubuntu.com/ubuntu/linux.git  linux-3.8.y-review

The review period for version 3.8.13.27 will be open for the next three days.
To report a problem, please reply to the relevant follow-up patch message.

For more information about the Linux 3.8.y.z extended stable kernel version,
see https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable .

 -Kamal

--
 arch/arm/kernel/stacktrace.c                 |  18 ++--
 arch/arm64/include/asm/Kbuild                |   1 -
 arch/arm64/include/asm/dma-mapping.h         |   2 -
 arch/arm64/include/uapi/asm/posix_types.h    |  10 +++
 arch/arm64/kernel/entry.S                    |   1 -
 arch/arm64/kernel/ptrace.c                   |   4 +
 arch/mips/kernel/irq-msc01.c                 |   2 +-
 arch/mips/lantiq/dts/easy50712.dts           |   1 +
 arch/powerpc/include/asm/systbl.h            |   2 +-
 arch/powerpc/kernel/legacy_serial.c          |  15 ++--
 arch/powerpc/kernel/setup-common.c           |  10 ++-
 arch/powerpc/platforms/pseries/eeh_pseries.c |   1 +
 arch/s390/include/asm/lowcore.h              |  11 +--
 arch/x86/kernel/entry_32.S                   |  15 ++--
 arch/x86/syscalls/syscall_64.tbl             |   6 +-
 drivers/acpi/bus.c                           |   7 ++
 drivers/acpi/video_detect.c                  |   8 ++
 drivers/ata/ahci.c                           |   4 +
 drivers/base/power/opp.c                     |   4 +-
 drivers/block/mtip32xx/mtip32xx.c            | 124 ++++++++++++++++++++-------
 drivers/bluetooth/hci_ldisc.c                |  24 ++++--
 drivers/bluetooth/hci_uart.h                 |   1 +
 drivers/gpu/drm/radeon/atombios_crtc.c       |  48 ++++++-----
 drivers/gpu/drm/radeon/atombios_dp.c         |  17 +++-
 drivers/gpu/drm/radeon/atombios_encoders.c   |   5 +-
 drivers/gpu/drm/radeon/radeon_connectors.c   |   2 +-
 drivers/hid/hid-core.c                       |  12 ++-
 drivers/iio/adc/at91_adc.c                   |  16 ++--
 drivers/iio/adc/max1363.c                    |  16 ++--
 drivers/infiniband/core/user_mad.c           |  75 +++++++++-------
 drivers/infiniband/hw/cxgb4/cq.c             |   3 +-
 drivers/infiniband/hw/cxgb4/user.h           |   1 +
 drivers/infiniband/hw/ipath/ipath_diag.c     |   4 +
 drivers/infiniband/hw/qib/qib_mad.c          |   2 +-
 drivers/infiniband/ulp/srp/ib_srp.c          |   6 ++
 drivers/input/mouse/elantech.c               |  26 ++++--
 drivers/md/dm-thin.c                         |   3 +-
 drivers/media/pci/ivtv/ivtv-alsa-pcm.c       |   6 ++
 drivers/media/usb/uvc/uvc_video.c            |  15 ++--
 drivers/net/ethernet/intel/igb/igb_main.c    |   4 +-
 drivers/net/wireless/b43/xmit.c              |  10 ++-
 drivers/net/wireless/iwlwifi/pcie/trans.c    |  26 +++---
 drivers/net/wireless/rt2x00/rt2500pci.c      |   7 +-
 drivers/net/wireless/rt2x00/rt2x00.h         |   1 +
 drivers/net/wireless/rt2x00/rt2x00dev.c      |  24 +++++-
 drivers/net/wireless/rt2x00/rt2x00mac.c      |   2 +
 drivers/pci/quirks.c                         |   1 +
 drivers/rtc/rtc-at91rm9200.c                 |  16 +++-
 drivers/scsi/hpsa.c                          |  37 ++++++++
 drivers/staging/iio/light/tsl2x7x_core.c     |   8 +-
 drivers/target/iscsi/iscsi_target.c          |   1 +
 drivers/target/iscsi/iscsi_target_auth.c     |  10 +++
 drivers/target/iscsi/iscsi_target_login.c    |  18 ++--
 drivers/target/target_core_device.c          |   1 +
 drivers/uio/uio.c                            |   2 +
 drivers/usb/dwc3/gadget.c                    |   4 +
 drivers/usb/host/pci-quirks.c                |  19 +++-
 drivers/usb/misc/usbtest.c                   |  10 +++
 drivers/usb/serial/qcserial.c                |  21 +++++
 drivers/watchdog/ath79_wdt.c                 |  10 +++
 drivers/watchdog/sp805_wdt.c                 |   4 +-
 fs/attr.c                                    |   8 +-
 fs/btrfs/extent_io.c                         |   1 +
 fs/cifs/cifs_unicode.c                       |   7 +-
 fs/ext4/mballoc.c                            |   2 +-
 fs/ext4/page-io.c                            |  24 +++---
 fs/inode.c                                   |  10 ++-
 fs/namei.c                                   |  11 +--
 fs/nfs/inode.c                               |  26 ++++--
 fs/nfs/super.c                               |   1 +
 fs/nfsd/nfs4state.c                          |   2 +-
 fs/nfsd/nfs4xdr.c                            |   4 +-
 fs/reiserfs/inode.c                          |   8 +-
 fs/ubifs/file.c                              |   3 +-
 fs/ubifs/shrinker.c                          |   1 -
 fs/xfs/xfs_ioctl.c                           |  11 ++-
 include/linux/capability.h                   |   2 +-
 include/linux/irqdesc.h                      |   4 +
 include/linux/mmzone.h                       |   6 +-
 include/linux/pageblock-flags.h              |  37 ++++++--
 include/linux/pci_ids.h                      |   1 +
 include/linux/ptrace.h                       |  32 +++++++
 include/sound/core.h                         |   2 +
 include/uapi/sound/compress_offload.h        |   2 +-
 kernel/auditsc.c                             |  27 ++++--
 kernel/capability.c                          |  19 ++--
 kernel/fork.c                                |  10 ++-
 kernel/irq/manage.c                          |   4 +-
 kernel/irq/spurious.c                        | 106 ++++++++++++++++++++++-
 lib/idr.c                                    |   8 +-
 mm/hugetlb.c                                 |  71 +++++++++------
 mm/memcontrol.c                              |   5 +-
 mm/memory-failure.c                          |  25 +++---
 mm/mempolicy.c                               |  44 ++++------
 mm/page_alloc.c                              |  51 ++++++-----
 mm/rmap.c                                    |   8 +-
 mm/vmscan.c                                  |  46 ++++++++--
 net/bluetooth/hci_conn.c                     |  11 ++-
 net/bluetooth/hci_event.c                    |  11 ++-
 net/bluetooth/l2cap_sock.c                   |  10 +--
 net/bluetooth/mgmt.c                         |   7 +-
 net/bluetooth/smp.c                          |   9 +-
 net/mac80211/debugfs_netdev.c                |   6 +-
 net/mac80211/ibss.c                          |   1 +
 net/netfilter/nf_nat_core.c                  |  35 +++++++-
 net/sunrpc/svc_xprt.c                        |   2 +
 scripts/recordmcount.h                       |   4 +-
 security/integrity/evm/evm_main.c            |  12 ++-
 security/integrity/ima/ima_crypto.c          |  32 ++++++-
 sound/core/control.c                         |  78 +++++++++++------
 sound/core/init.c                            |   1 +
 sound/pci/hda/patch_realtek.c                |   1 +
 sound/usb/card.c                             |  13 ++-
 sound/usb/endpoint.c                         |  17 +++-
 sound/usb/endpoint.h                         |   1 +
 115 files changed, 1203 insertions(+), 441 deletions(-)

Alan Stern (1):
      USB: EHCI: avoid BIOS handover on the HASEE E200

Aleksander Morgado (2):
      usb: qcserial: add Netgear AirCard 341U
      usb: qcserial: add additional Sierra Wireless QMI devices

Alex Deucher (4):
      drm/radeon: fix typo in radeon_connector_is_dp12_capable()
      drm/radeon/dp: fix lane/clock setup for dp 1.2 capable devices
      drm/radeon/atom: fix dithering on certain panels
      drm/radeon: only apply hdmi bpc pll flags when encoder mode is hdmi

Alex Smith (1):
      recordmcount/MIPS: Fix possible incorrect mcount_loc table entries in modules

Andreas Schrägle (1):
      ahci: add PCI ID for Marvell 88SE91A0 SATA Controller

Andy Lutomirski (3):
      auditsc: audit_krule mask accesses need bounds checking
      fs,userns: Change inode_capable to capable_wrt_inode_uidgid
      x86_32, entry: Do syscall exit work on badsys (CVE-2014-4508)

Anton Blanchard (1):
      powerpc: 64bit sendfile is capped at 2GB

Arik Nemtsov (1):
      mac80211: don't check netdev state for debugfs read/write

Asai Thambi S P (3):
      mtip32xx: Increase timeout for STANDBY IMMEDIATE command
      mtip32xx: Remove dfs_parent after pci unregister
      mtip32xx: Fix ERO and NoSnoop values in PCIe upstream on AMD systems

Bart Van Assche (3):
      IB/srp: Fix a sporadic crash triggered by cable pulling
      IB/umad: Fix error handling
      IB/umad: Fix use-after-free on close

Benjamin Herrenschmidt (1):
      powerpc/serial: Use saner flags when creating legacy ports

Bin Wang (1):
      uio: fix vma io range check in mmap

Boris BREZILLON (1):
      rtc: rtc-at91rm9200: fix infinite wait for ACKUPD irq

Chander Kashyap (1):
      PM / OPP: fix incorrect OPP count handling in of_init_opp_table

ChiaHao (1):
      arm64: Bug fix in stack alignment exception

Chris Mason (1):
      Btrfs: fix double free in find_lock_delalloc_range

Christian Borntraeger (1):
      s390/lowcore: reserve 96 bytes for IRB in lowcore

Christoph Hellwig (1):
      nfsd: getattr for FATTR4_WORD0_FILES_AVAIL needs the statfs buffer

Dan Carpenter (1):
      iio: adc: at91: signedness bug in at91_adc_get_trigger_value_by_name()

Dennis Dalessandro (1):
      IB/ipath: Translate legacy diagpkt into newer extended diagpkt

Dmitry Kasatkin (1):
      ima: introduce ima_kernel_read()

Dwight Engen (1):
      xfs: ioctl check for capabilities in the current user namespace

Edward Lin (1):
      ACPI / video: Add Dell Inspiron 5737 to the blacklist

Emmanuel Grumbach (1):
      iwlwifi: pcie: try to get ownership several times

Felipe Balbi (2):
      usb: dwc3: gadget: clear stall when disabling endpoint
      bluetooth: hci_ldisc: fix deadlock condition

Florian Westphal (1):
      netfilter: nf_nat: fix oops on netns removal

Gabor Juhos (1):
      watchdog: ath79_wdt: avoid spurious restarts on AR934x

Gavin Shan (1):
      powerpc/pseries: Fix overwritten PE state

Greg Kroah-Hartman (1):
      Revert "uio: fix vma io range check in mmap"

H. Peter Anvin (1):
      x86-32, espfix: Remove filter for espfix32 due to race

Hans de Goede (2):
      Input: elantech - deal with clickpads reporting right button events
      Input: elantech - don't set bit 1 of reg_10 when the no_hw_res quirk is set

Huang Rui (1):
      usb: usbtest: fix unlink write error with pattern 1

Hugh Dickins (2):
      mm: fix sleeping function warning from __put_anon_vma
      mm: fix crashes from mbind() merging vmas

J. Bruce Fields (1):
      nfsd4: fix FREE_STATEID lockowner leak

Jan Kara (1):
      ext4: fix zeroing of page during writeback

Jeff Mahoney (1):
      reiserfs: call truncate_setsize under tailpack mutex

Joe Handzik (1):
      hpsa: add new Smart Array PCI IDs (May 2014)

Johan Hedberg (6):
      Bluetooth: Fix redundant encryption request for reauthentication
      Bluetooth: Fix check for connection encryption
      Bluetooth: Fix SSP acceptor just-works confirmation without MITM
      Bluetooth: Fix setting correct authentication information for SMP STK
      Bluetooth: Fix indicating discovery state when canceling inquiry
      Bluetooth: Fix locking of hdev when calling into SMP code

Johannes Weiner (1):
      mm: vmscan: clear kswapd's special reclaim powers before exiting

Jonathan Cameron (1):
      iio:adc:max1363 incorrect resolutions for max11604, max11605, max11610 and max11611.

Jukka Taimisto (1):
      Bluetooth: Fix L2CAP deadlock

Jérôme Carretero (1):
      ahci: Add Device ID for HighPoint RocketRaid 642L

Kailang Yang (1):
      ALSA: hda/realtek - Add support of ALC891 codec

Kees Cook (1):
      HID: core: fix validation of report id 0

Krzysztof Hałasa (1):
      mac80211: fix IBSS join by initializing last_scan_completed

Lai Jiangshan (1):
      idr: fix overflow bug during maximum ID calculation at maximum height

Lars-Peter Clausen (5):
      ALSA: control: Protect user controls against concurrent access
      ALSA: control: Fix replacing user controls
      ALSA: control: Don't access controls outside of protected regions
      ALSA: control: Handle numid overflow
      ALSA: control: Make sure that id->index does not overflow

Leif Lindholm (1):
      MIPS: DTS: Fix missing device_type="memory" property in memory nodes

Linus Torvalds (1):
      uio: we cannot mmap unaligned page contents

Lukas Czerner (1):
      dm thin: update discard_granularity to reflect the thin-pool blocksize

Lv Zheng (1):
      ACPI: Fix conflict between customized DSDT and DSDT local copy

Marcin Kraglak (1):
      Bluetooth: Allow change security level on ATT_CID in slave role

Mario Schuknecht (1):
      staging: iio: tsl2x7x_core: fix proximity treshold

Markos Chandras (1):
      MIPS: MSC: Prevent out-of-bounds writes to MIPS SC ioremap'd region

Mateusz Guzik (1):
      NFS: populate ->net in mount data when remounting

Matthew Dempsky (1):
      ptrace: fix fork event messages across pid namespaces

Maurizio Lombardi (1):
      ext4: fix wrong assert in ext4_mb_normalize_request()

Mel Gorman (2):
      mm: vmscan: do not throttle based on pfmemalloc reserves if node has no ZONE_NORMAL
      mm: page_alloc: use word-based accesses for get/set pageblock bitmaps

Michael Neuling (1):
      powerpc: Don't setup CPUs with bad status

Michal Hocko (1):
      memcg: do not hang on OOM when killed by userspace OOM access to memory reserves

Mike Frysinger (1):
      x86, x32: Use compat shims for io_{setup,submit}

Mike Marciniszyn (1):
      IB/qib: Fix port in pkey change event

Mike Miller (1):
      [SCSI] hpsa: add HP Smart Array Gen9 PCI ID's

Mikulas Patocka (1):
      iscsi-target: fix iscsit_del_np deadlock on unload

Mimi Zohar (1):
      evm: prohibit userspace writing 'security.evm' HMAC value

Naoya Horiguchi (1):
      hugetlb: fix copy_hugetlb_page_range() to handle migration/hwpoisoned entry

Nicholas Bellinger (3):
      iscsi-target: Reject mutual authentication with reflected CHAP_C
      target: Fix left-over se_lun->lun_sep pointer OOPs
      iscsi-target: Fix incorrect np->np_thread NULL assignment

Olivier Langlois (1):
      [media] uvcvideo: Fix clock param realtime setting

Rafał Miłecki (1):
      b43: fix frequency reported on G-PHY with /new/ firmware

Russell King (1):
      ARM: stacktrace: avoid listing stacktrace functions in stacktrace

Scott Wood (1):
      powerpc: Don't skip ePAPR spin-table CPUs

Stanislaw Gruszka (2):
      rt2x00: disable TKIP on USB
      rt2x00: fix rfkill regression on rt2500pci

Steve French (1):
      [CIFS] fix mount failure with broken pathnames when smb3 mount with mapchars option

Suravee Suthikulpanit (1):
      arm64/dma: Removing ARCH_HAS_DMA_GET_REQUIRED_MASK macro

Takashi Iwai (2):
      [media] ivtv: Fix Oops when no firmware is loaded
      ALSA: usb-audio: Fix races at disconnection and PCM closing

Thomas Gleixner (1):
      genirq: Sanitize spurious interrupt detection of threaded irqs

Thomas Jarosch (1):
      PCI: Add new ID for Intel GPU "spurious interrupt" quirk

Todd Fujinaka (1):
      igb: fix stats for i210 rx_fifo_errors

Tony Luck (2):
      mm/memory-failure.c-failure: send right signal code to correct thread
      mm/memory-failure.c: don't let collect_procs() skip over processes for MF_ACTION_REQUIRED

Trond Myklebust (2):
      NFS: Don't declare inode uptodate unless all attributes were checked
      SUNRPC: Fix a module reference leak in svc_handle_xprt

Viresh Kumar (1):
      watchdog: sp805: Set watchdog_device->timeout from ->set_timeout()

Wang, Xiaoming (1):
      ALSA: compress: Cancel the optimization of compiler and fix the size of struct for all platform.

Will Deacon (2):
      arm64: ptrace: change fs when passing kernel pointer to regset code
      arm64: uid16: fix __kernel_old_{gid,uid}_t definitions

Yann Droneaud (1):
      RDMA/cxgb4: Add missing padding at end of struct c4iw_create_cq_resp

hujianyang (2):
      UBIFS: fix an mmap and fsync race condition
      UBIFS: Remove incorrect assertion in shrink_tnc()

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

* [PATCH 3.8 001/116] igb: fix stats for i210 rx_fifo_errors
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 002/116] netfilter: nf_nat: fix oops on netns removal Kamal Mostafa
                   ` (114 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Todd Fujinaka, Jeff Kirsher, Tim Gardner, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Todd Fujinaka <todd.fujinaka@intel.com>

commit e66c083aab32842f225bae2a2c30744bf96abaec upstream.

RQDPC on i210/i211 is R/W not ReadClear. Clear after reading.

Signed-off-by: Todd Fujinaka <todd.fujinaka@intel.com>
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Cc: Tim Gardner <tim.gardner@canonical.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/net/ethernet/intel/igb/igb_main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index 31cfe2e..40f80c3 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -4592,8 +4592,10 @@ void igb_update_stats(struct igb_adapter *adapter,
 	bytes = 0;
 	packets = 0;
 	for (i = 0; i < adapter->num_rx_queues; i++) {
-		u32 rqdpc = rd32(E1000_RQDPC(i));
 		struct igb_ring *ring = adapter->rx_ring[i];
+		u32 rqdpc = rd32(E1000_RQDPC(i));
+		if (hw->mac.type >= e1000_i210)
+			wr32(E1000_RQDPC(i), 0);
 
 		if (rqdpc) {
 			ring->rx_stats.drops += rqdpc;
-- 
1.9.1


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

* [PATCH 3.8 002/116] netfilter: nf_nat: fix oops on netns removal
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 001/116] igb: fix stats for i210 rx_fifo_errors Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 003/116] ACPI / video: Add Dell Inspiron 5737 to the blacklist Kamal Mostafa
                   ` (113 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Florian Westphal, Pablo Neira Ayuso, Chris J Arges, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Florian Westphal <fw@strlen.de>

commit 945b2b2d259d1a4364a2799e80e8ff32f8c6ee6f upstream.

Quoting Samu Kallio:

 Basically what's happening is, during netns cleanup,
 nf_nat_net_exit gets called before ipv4_net_exit. As I understand
 it, nf_nat_net_exit is supposed to kill any conntrack entries which
 have NAT context (through nf_ct_iterate_cleanup), but for some
 reason this doesn't happen (perhaps something else is still holding
 refs to those entries?).

 When ipv4_net_exit is called, conntrack entries (including those
 with NAT context) are cleaned up, but the
 nat_bysource hashtable is long gone - freed in nf_nat_net_exit. The
 bug happens when attempting to free a conntrack entry whose NAT hash
 'prev' field points to a slot in the freed hash table (head for that
 bin).

We ignore conntracks with null nat bindings.  But this is wrong,
as these are in bysource hash table as well.

Restore nat-cleaning for the netns-is-being-removed case.

bug:
https://bugzilla.kernel.org/show_bug.cgi?id=65191

Fixes: c2d421e1718 ('netfilter: nf_nat: fix race when unloading protocol modules')
Reported-by: Samu Kallio <samu.kallio@aberdeencloud.com>
Debugged-by: Samu Kallio <samu.kallio@aberdeencloud.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
Tested-by: Samu Kallio <samu.kallio@aberdeencloud.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
[ kamal: backport to 3.8-stable: context ]
Cc: Chris J Arges <chris.j.arges@canonical.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 net/netfilter/nf_nat_core.c | 35 ++++++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/net/netfilter/nf_nat_core.c b/net/netfilter/nf_nat_core.c
index 4bc2aaf..e40b77d 100644
--- a/net/netfilter/nf_nat_core.c
+++ b/net/netfilter/nf_nat_core.c
@@ -486,6 +486,39 @@ static int nf_nat_proto_remove(struct nf_conn *i, void *data)
 	return i->status & IPS_NAT_MASK ? 1 : 0;
 }
 
+static int nf_nat_proto_clean(struct nf_conn *ct, void *data)
+{
+	struct nf_conn_nat *nat = nfct_nat(ct);
+
+	if (nf_nat_proto_remove(ct, data))
+		return 1;
+
+	if (!nat || !nat->ct)
+		return 0;
+
+	/* This netns is being destroyed, and conntrack has nat null binding.
+	 * Remove it from bysource hash, as the table will be freed soon.
+	 *
+	 * Else, when the conntrack is destoyed, nf_nat_cleanup_conntrack()
+	 * will delete entry from already-freed table.
+	 */
+	if (!del_timer(&ct->timeout))
+		return 1;
+
+	spin_lock_bh(&nf_nat_lock);
+	hlist_del_rcu(&nat->bysource);
+	ct->status &= ~IPS_NAT_DONE_MASK;
+	nat->ct = NULL;
+	spin_unlock_bh(&nf_nat_lock);
+
+	add_timer(&ct->timeout);
+
+	/* don't delete conntrack.  Although that would make things a lot
+	 * simpler, we'd end up flushing all conntracks on nat rmmod.
+	 */
+	return 0;
+}
+
 static void nf_nat_l4proto_clean(u8 l3proto, u8 l4proto)
 {
 	struct nf_nat_proto_clean clean = {
@@ -748,7 +781,7 @@ static void __net_exit nf_nat_net_exit(struct net *net)
 {
 	struct nf_nat_proto_clean clean = {};
 
-	nf_ct_iterate_cleanup(net, &nf_nat_proto_remove, &clean);
+	nf_ct_iterate_cleanup(net, nf_nat_proto_clean, &clean);
 	synchronize_rcu();
 	nf_ct_free_hashtable(net->ct.nat_bysource, net->ct.nat_htable_size);
 }
-- 
1.9.1


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

* [PATCH 3.8 003/116] ACPI / video: Add Dell Inspiron 5737 to the blacklist
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 001/116] igb: fix stats for i210 rx_fifo_errors Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 002/116] netfilter: nf_nat: fix oops on netns removal Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 004/116] NFS: Don't declare inode uptodate unless all attributes were checked Kamal Mostafa
                   ` (112 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Edward Lin, Rafael J. Wysocki, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Edward Lin <yidi.lin@canonical.com>

commit 08a56226d84706d402372d891550e130ef5df9f0 upstream.

With win8 capabiltiy, the ACPI backlight control is broken.
The system also loses backlight setting when resuming from S3.

Add this model to the the ACPI video detect blacklist to make backlight
functionality work.

Although backlight functionality works via video.use_native_backlight=1,
this approach may be safer.

Signed-off-by: Edward Lin <yidi.lin@canonical.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/acpi/video_detect.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
index abcae69..c81409a 100644
--- a/drivers/acpi/video_detect.c
+++ b/drivers/acpi/video_detect.c
@@ -172,6 +172,14 @@ static struct dmi_system_id video_detect_dmi_table[] = {
 		DMI_MATCH(DMI_PRODUCT_NAME, "UL30A"),
 		},
 	},
+	{
+	.callback = video_detect_force_vendor,
+	.ident = "Dell Inspiron 5737",
+	.matches = {
+		DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
+		DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 5737"),
+		},
+	},
 	{ },
 };
 
-- 
1.9.1


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

* [PATCH 3.8 004/116] NFS: Don't declare inode uptodate unless all attributes were checked
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (2 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 003/116] ACPI / video: Add Dell Inspiron 5737 to the blacklist Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 005/116] usb: dwc3: gadget: clear stall when disabling endpoint Kamal Mostafa
                   ` (111 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Trond Myklebust, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Trond Myklebust <trond.myklebust@primarydata.com>

commit 43b6535e717d2f656f71d9bd16022136b781c934 upstream.

Fix a bug, whereby nfs_update_inode() was declaring the inode to be
up to date despite not having checked all the attributes.
The bug occurs because the temporary variable in which we cache
the validity information is 'sanitised' before reapplying to
nfsi->cache_validity.

Reported-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 fs/nfs/inode.c | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index ebeb94c..a5130f1 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -1381,18 +1381,20 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
 			inode->i_version = fattr->change_attr;
 		}
 	} else if (server->caps & NFS_CAP_CHANGE_ATTR)
-		invalid |= save_cache_validity;
+		nfsi->cache_validity |= save_cache_validity;
 
 	if (fattr->valid & NFS_ATTR_FATTR_MTIME) {
 		memcpy(&inode->i_mtime, &fattr->mtime, sizeof(inode->i_mtime));
 	} else if (server->caps & NFS_CAP_MTIME)
-		invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
+		nfsi->cache_validity |= save_cache_validity &
+				(NFS_INO_INVALID_ATTR
 				| NFS_INO_REVAL_FORCED);
 
 	if (fattr->valid & NFS_ATTR_FATTR_CTIME) {
 		memcpy(&inode->i_ctime, &fattr->ctime, sizeof(inode->i_ctime));
 	} else if (server->caps & NFS_CAP_CTIME)
-		invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
+		nfsi->cache_validity |= save_cache_validity &
+				(NFS_INO_INVALID_ATTR
 				| NFS_INO_REVAL_FORCED);
 
 	/* Check if our cached file size is stale */
@@ -1415,7 +1417,8 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
 					(long long)new_isize);
 		}
 	} else
-		invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
+		nfsi->cache_validity |= save_cache_validity &
+				(NFS_INO_INVALID_ATTR
 				| NFS_INO_REVAL_PAGECACHE
 				| NFS_INO_REVAL_FORCED);
 
@@ -1423,7 +1426,8 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
 	if (fattr->valid & NFS_ATTR_FATTR_ATIME)
 		memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
 	else if (server->caps & NFS_CAP_ATIME)
-		invalid |= save_cache_validity & (NFS_INO_INVALID_ATIME
+		nfsi->cache_validity |= save_cache_validity &
+				(NFS_INO_INVALID_ATIME
 				| NFS_INO_REVAL_FORCED);
 
 	if (fattr->valid & NFS_ATTR_FATTR_MODE) {
@@ -1434,7 +1438,8 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
 			invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
 		}
 	} else if (server->caps & NFS_CAP_MODE)
-		invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
+		nfsi->cache_validity |= save_cache_validity &
+				(NFS_INO_INVALID_ATTR
 				| NFS_INO_INVALID_ACCESS
 				| NFS_INO_INVALID_ACL
 				| NFS_INO_REVAL_FORCED);
@@ -1445,7 +1450,8 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
 			inode->i_uid = fattr->uid;
 		}
 	} else if (server->caps & NFS_CAP_OWNER)
-		invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
+		nfsi->cache_validity |= save_cache_validity &
+				(NFS_INO_INVALID_ATTR
 				| NFS_INO_INVALID_ACCESS
 				| NFS_INO_INVALID_ACL
 				| NFS_INO_REVAL_FORCED);
@@ -1456,7 +1462,8 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
 			inode->i_gid = fattr->gid;
 		}
 	} else if (server->caps & NFS_CAP_OWNER_GROUP)
-		invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
+		nfsi->cache_validity |= save_cache_validity &
+				(NFS_INO_INVALID_ATTR
 				| NFS_INO_INVALID_ACCESS
 				| NFS_INO_INVALID_ACL
 				| NFS_INO_REVAL_FORCED);
@@ -1469,7 +1476,8 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
 			set_nlink(inode, fattr->nlink);
 		}
 	} else if (server->caps & NFS_CAP_NLINK)
-		invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
+		nfsi->cache_validity |= save_cache_validity &
+				(NFS_INO_INVALID_ATTR
 				| NFS_INO_REVAL_FORCED);
 
 	if (fattr->valid & NFS_ATTR_FATTR_SPACE_USED) {
-- 
1.9.1


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

* [PATCH 3.8 005/116] usb: dwc3: gadget: clear stall when disabling endpoint
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (3 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 004/116] NFS: Don't declare inode uptodate unless all attributes were checked Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 006/116] mtip32xx: Increase timeout for STANDBY IMMEDIATE command Kamal Mostafa
                   ` (110 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Felipe Balbi, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Felipe Balbi <balbi@ti.com>

commit 687ef9817df7ed960d14575b9033dde3d04631fe upstream.

so it seems like DWC3 IP doesn't clear stalls
automatically when we disable an endpoint, because
of that, we _must_ make sure stalls are cleared
before clearing the proper bit in DALEPENA register.

Reported-by: Johannes Stezenbach <js@sig21.net>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/usb/dwc3/gadget.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 418288e..288ec5e 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -603,6 +603,10 @@ static int __dwc3_gadget_ep_disable(struct dwc3_ep *dep)
 
 	dwc3_remove_requests(dwc, dep);
 
+	/* make sure HW endpoint isn't stalled */
+	if (dep->flags & DWC3_EP_STALL)
+		__dwc3_gadget_ep_set_halt(dep, 0);
+
 	reg = dwc3_readl(dwc->regs, DWC3_DALEPENA);
 	reg &= ~DWC3_DALEPENA_EP(dep->number);
 	dwc3_writel(dwc->regs, DWC3_DALEPENA, reg);
-- 
1.9.1


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

* [PATCH 3.8 006/116] mtip32xx: Increase timeout for STANDBY IMMEDIATE command
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (4 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 005/116] usb: dwc3: gadget: clear stall when disabling endpoint Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 007/116] mtip32xx: Remove dfs_parent after pci unregister Kamal Mostafa
                   ` (109 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Selvan Mani, Asai Thambi S P, Jens Axboe, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Asai Thambi S P <asamymuthupa@micron.com>

commit 670a641420a3d9586eebe7429dfeec4e7ed447aa upstream.

Increased timeout for STANDBY IMMEDIATE command to 2 minutes.

Signed-off-by: Selvan Mani <smani@micron.com>
Signed-off-by: Asai Thambi S P <asamymuthupa@micron.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/block/mtip32xx/mtip32xx.c | 66 +++++++++++++++++++++------------------
 1 file changed, 35 insertions(+), 31 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index ca69cf9..6a748ff 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -1419,6 +1419,37 @@ static inline void ata_swap_string(u16 *buf, unsigned int len)
 		be16_to_cpus(&buf[i]);
 }
 
+static void mtip_set_timeout(struct driver_data *dd,
+					struct host_to_dev_fis *fis,
+					unsigned int *timeout, u8 erasemode)
+{
+	switch (fis->command) {
+	case ATA_CMD_DOWNLOAD_MICRO:
+		*timeout = 120000; /* 2 minutes */
+		break;
+	case ATA_CMD_SEC_ERASE_UNIT:
+	case 0xFC:
+		if (erasemode)
+			*timeout = ((*(dd->port->identify + 90) * 2) * 60000);
+		else
+			*timeout = ((*(dd->port->identify + 89) * 2) * 60000);
+		break;
+	case ATA_CMD_STANDBYNOW1:
+		*timeout = 120000;  /* 2 minutes */
+		break;
+	case 0xF7:
+	case 0xFA:
+		*timeout = 60000;  /* 60 seconds */
+		break;
+	case ATA_CMD_SMART:
+		*timeout = 15000;  /* 15 seconds */
+		break;
+	default:
+		*timeout = MTIP_IOCTL_COMMAND_TIMEOUT_MS;
+		break;
+	}
+}
+
 /*
  * Request the device identity information.
  *
@@ -1520,6 +1551,7 @@ static int mtip_standby_immediate(struct mtip_port *port)
 	int rv;
 	struct host_to_dev_fis	fis;
 	unsigned long start;
+	unsigned int timeout;
 
 	/* Build the FIS. */
 	memset(&fis, 0, sizeof(struct host_to_dev_fis));
@@ -1527,6 +1559,8 @@ static int mtip_standby_immediate(struct mtip_port *port)
 	fis.opts	= 1 << 7;
 	fis.command	= ATA_CMD_STANDBYNOW1;
 
+	mtip_set_timeout(port->dd, &fis, &timeout, 0);
+
 	start = jiffies;
 	rv = mtip_exec_internal_command(port,
 					&fis,
@@ -1535,7 +1569,7 @@ static int mtip_standby_immediate(struct mtip_port *port)
 					0,
 					0,
 					GFP_ATOMIC,
-					15000);
+					timeout);
 	dbg_printk(MTIP_DRV_NAME "Time taken to complete standby cmd: %d ms\n",
 			jiffies_to_msecs(jiffies - start));
 	if (rv)
@@ -2037,36 +2071,6 @@ static unsigned int implicit_sector(unsigned char command,
 	}
 	return rv;
 }
-static void mtip_set_timeout(struct driver_data *dd,
-					struct host_to_dev_fis *fis,
-					unsigned int *timeout, u8 erasemode)
-{
-	switch (fis->command) {
-	case ATA_CMD_DOWNLOAD_MICRO:
-		*timeout = 120000; /* 2 minutes */
-		break;
-	case ATA_CMD_SEC_ERASE_UNIT:
-	case 0xFC:
-		if (erasemode)
-			*timeout = ((*(dd->port->identify + 90) * 2) * 60000);
-		else
-			*timeout = ((*(dd->port->identify + 89) * 2) * 60000);
-		break;
-	case ATA_CMD_STANDBYNOW1:
-		*timeout = 120000;  /* 2 minutes */
-		break;
-	case 0xF7:
-	case 0xFA:
-		*timeout = 60000;  /* 60 seconds */
-		break;
-	case ATA_CMD_SMART:
-		*timeout = 15000;  /* 15 seconds */
-		break;
-	default:
-		*timeout = MTIP_IOCTL_COMMAND_TIMEOUT_MS;
-		break;
-	}
-}
 
 /*
  * Executes a taskfile
-- 
1.9.1


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

* [PATCH 3.8 007/116] mtip32xx: Remove dfs_parent after pci unregister
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (5 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 006/116] mtip32xx: Increase timeout for STANDBY IMMEDIATE command Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 008/116] mtip32xx: Fix ERO and NoSnoop values in PCIe upstream on AMD systems Kamal Mostafa
                   ` (108 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Asai Thambi S P, Jens Axboe, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Asai Thambi S P <asamymuthupa@micron.com>

commit af5ded8ccf21627f9614afc03b356712666ed225 upstream.

In module exit, dfs_parent and it's subtree were removed before
unregistering with pci. When debugfs entry for each device is attempted
to remove in pci_remove() context, they don't exist, as dfs_parent and
its children were already ripped apart.

Modified to first unregister with pci and then remove dfs_parent.

Signed-off-by: Asai Thambi S P <asamymuthupa@micron.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/block/mtip32xx/mtip32xx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index 6a748ff..f01adbc 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -4282,13 +4282,13 @@ static int __init mtip_init(void)
  */
 static void __exit mtip_exit(void)
 {
-	debugfs_remove_recursive(dfs_parent);
-
 	/* Release the allocated major block device number. */
 	unregister_blkdev(mtip_major, MTIP_DRV_NAME);
 
 	/* Unregister the PCI driver. */
 	pci_unregister_driver(&mtip_pci_driver);
+
+	debugfs_remove_recursive(dfs_parent);
 }
 
 MODULE_AUTHOR("Micron Technology, Inc");
-- 
1.9.1


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

* [PATCH 3.8 008/116] mtip32xx: Fix ERO and NoSnoop values in PCIe upstream on AMD systems
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (6 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 007/116] mtip32xx: Remove dfs_parent after pci unregister Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 009/116] bluetooth: hci_ldisc: fix deadlock condition Kamal Mostafa
                   ` (107 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Asai Thambi S P, Sam Bradshaw, Jens Axboe, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Asai Thambi S P <asamymuthupa@micron.com>

commit d1e714db8129a1d3670e449b87719c78e2c76f9f upstream.

A hardware quirk in P320h/P420m interfere with PCIe transactions on some
AMD chipsets, making P320h/P420m unusable. This workaround is to disable
ERO and NoSnoop bits in the parent and root complex for normal
functioning of these devices

NOTE: This workaround is specific to AMD chipset with a PCIe upstream
device with device id 0x5aXX

Signed-off-by: Asai Thambi S P <asamymuthupa@micron.com>
Signed-off-by: Sam Bradshaw <sbradshaw@micron.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/block/mtip32xx/mtip32xx.c | 54 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)

diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index f01adbc..d2a3f3d 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -3968,6 +3968,57 @@ static int mtip_block_resume(struct driver_data *dd)
 	return 0;
 }
 
+static void mtip_disable_link_opts(struct driver_data *dd, struct pci_dev *pdev)
+{
+	int pos;
+	unsigned short pcie_dev_ctrl;
+
+	pos = pci_find_capability(pdev, PCI_CAP_ID_EXP);
+	if (pos) {
+		pci_read_config_word(pdev,
+			pos + PCI_EXP_DEVCTL,
+			&pcie_dev_ctrl);
+		if (pcie_dev_ctrl & (1 << 11) ||
+		    pcie_dev_ctrl & (1 << 4)) {
+			dev_info(&dd->pdev->dev,
+				"Disabling ERO/No-Snoop on bridge device %04x:%04x\n",
+					pdev->vendor, pdev->device);
+			pcie_dev_ctrl &= ~(PCI_EXP_DEVCTL_NOSNOOP_EN |
+						PCI_EXP_DEVCTL_RELAX_EN);
+			pci_write_config_word(pdev,
+				pos + PCI_EXP_DEVCTL,
+				pcie_dev_ctrl);
+		}
+	}
+}
+
+static void mtip_fix_ero_nosnoop(struct driver_data *dd, struct pci_dev *pdev)
+{
+	/*
+	 * This workaround is specific to AMD/ATI chipset with a PCI upstream
+	 * device with device id 0x5aXX
+	 */
+	if (pdev->bus && pdev->bus->self) {
+		if (pdev->bus->self->vendor == PCI_VENDOR_ID_ATI &&
+		    ((pdev->bus->self->device & 0xff00) == 0x5a00)) {
+			mtip_disable_link_opts(dd, pdev->bus->self);
+		} else {
+			/* Check further up the topology */
+			struct pci_dev *parent_dev = pdev->bus->self;
+			if (parent_dev->bus &&
+				parent_dev->bus->parent &&
+				parent_dev->bus->parent->self &&
+				parent_dev->bus->parent->self->vendor ==
+					 PCI_VENDOR_ID_ATI &&
+				(parent_dev->bus->parent->self->device &
+					0xff00) == 0x5a00) {
+				mtip_disable_link_opts(dd,
+					parent_dev->bus->parent->self);
+			}
+		}
+	}
+}
+
 /*
  * Called for each supported PCI device detected.
  *
@@ -4029,11 +4080,14 @@ static int mtip_pci_probe(struct pci_dev *pdev,
 		goto block_initialize_err;
 	}
 
+
 	/* Copy the info we may need later into the private data structure. */
 	dd->major	= mtip_major;
 	dd->instance	= instance;
 	dd->pdev	= pdev;
 
+	mtip_fix_ero_nosnoop(dd, pdev);
+
 	/* Initialize the block layer. */
 	rv = mtip_block_initialize(dd);
 	if (rv < 0) {
-- 
1.9.1


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

* [PATCH 3.8 009/116] bluetooth: hci_ldisc: fix deadlock condition
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (7 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 008/116] mtip32xx: Fix ERO and NoSnoop values in PCIe upstream on AMD systems Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 010/116] powerpc/pseries: Fix overwritten PE state Kamal Mostafa
                   ` (106 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Felipe Balbi, Greg Kroah-Hartman, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Felipe Balbi <balbi@ti.com>

commit da64c27d3c93ee9f89956b9de86c4127eb244494 upstream.

LDISCs shouldn't call tty->ops->write() from within
->write_wakeup().

->write_wakeup() is called with port lock taken and
IRQs disabled, tty->ops->write() will try to acquire
the same port lock and we will deadlock.

Acked-by: Marcel Holtmann <marcel@holtmann.org>
Reviewed-by: Peter Hurley <peter@hurleysoftware.com>
Reported-by: Huang Shijie <b32955@freescale.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Tested-by: Andreas Bießmann <andreas@biessmann.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/bluetooth/hci_ldisc.c | 24 +++++++++++++++++++-----
 drivers/bluetooth/hci_uart.h  |  1 +
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index ed0fade..97deda4 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -118,10 +118,6 @@ static inline struct sk_buff *hci_uart_dequeue(struct hci_uart *hu)
 
 int hci_uart_tx_wakeup(struct hci_uart *hu)
 {
-	struct tty_struct *tty = hu->tty;
-	struct hci_dev *hdev = hu->hdev;
-	struct sk_buff *skb;
-
 	if (test_and_set_bit(HCI_UART_SENDING, &hu->tx_state)) {
 		set_bit(HCI_UART_TX_WAKEUP, &hu->tx_state);
 		return 0;
@@ -129,6 +125,22 @@ int hci_uart_tx_wakeup(struct hci_uart *hu)
 
 	BT_DBG("");
 
+	schedule_work(&hu->write_work);
+
+	return 0;
+}
+
+static void hci_uart_write_work(struct work_struct *work)
+{
+	struct hci_uart *hu = container_of(work, struct hci_uart, write_work);
+	struct tty_struct *tty = hu->tty;
+	struct hci_dev *hdev = hu->hdev;
+	struct sk_buff *skb;
+
+	/* REVISIT: should we cope with bad skbs or ->write() returning
+	 * and error value ?
+	 */
+
 restart:
 	clear_bit(HCI_UART_TX_WAKEUP, &hu->tx_state);
 
@@ -153,7 +165,6 @@ restart:
 		goto restart;
 
 	clear_bit(HCI_UART_SENDING, &hu->tx_state);
-	return 0;
 }
 
 static void hci_uart_init_work(struct work_struct *work)
@@ -289,6 +300,7 @@ static int hci_uart_tty_open(struct tty_struct *tty)
 	tty->receive_room = 65536;
 
 	INIT_WORK(&hu->init_ready, hci_uart_init_work);
+	INIT_WORK(&hu->write_work, hci_uart_write_work);
 
 	spin_lock_init(&hu->rx_lock);
 
@@ -326,6 +338,8 @@ static void hci_uart_tty_close(struct tty_struct *tty)
 	if (hdev)
 		hci_uart_close(hdev);
 
+	cancel_work_sync(&hu->write_work);
+
 	if (test_and_clear_bit(HCI_UART_PROTO_SET, &hu->flags)) {
 		if (hdev) {
 			if (test_bit(HCI_UART_REGISTERED, &hu->flags))
diff --git a/drivers/bluetooth/hci_uart.h b/drivers/bluetooth/hci_uart.h
index fffa61f..12df101 100644
--- a/drivers/bluetooth/hci_uart.h
+++ b/drivers/bluetooth/hci_uart.h
@@ -68,6 +68,7 @@ struct hci_uart {
 	unsigned long		hdev_flags;
 
 	struct work_struct	init_ready;
+	struct work_struct	write_work;
 
 	struct hci_uart_proto	*proto;
 	void			*priv;
-- 
1.9.1


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

* [PATCH 3.8 010/116] powerpc/pseries: Fix overwritten PE state
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (8 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 009/116] bluetooth: hci_ldisc: fix deadlock condition Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 011/116] PCI: Add new ID for Intel GPU "spurious interrupt" quirk Kamal Mostafa
                   ` (105 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Gavin Shan, Benjamin Herrenschmidt, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Gavin Shan <gwshan@linux.vnet.ibm.com>

commit 54f112a3837d4e7532bbedbbbf27c0de277be510 upstream.

In pseries_eeh_get_state(), EEH_STATE_UNAVAILABLE is always
overwritten by EEH_STATE_NOT_SUPPORT because of the missed
"break" there. The patch fixes the issue.

Reported-by: Joe Perches <joe@perches.com>
Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 arch/powerpc/platforms/pseries/eeh_pseries.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/powerpc/platforms/pseries/eeh_pseries.c b/arch/powerpc/platforms/pseries/eeh_pseries.c
index b456b15..68f97d5 100644
--- a/arch/powerpc/platforms/pseries/eeh_pseries.c
+++ b/arch/powerpc/platforms/pseries/eeh_pseries.c
@@ -400,6 +400,7 @@ static int pseries_eeh_get_state(struct eeh_pe *pe, int *state)
 			} else {
 				result = EEH_STATE_NOT_SUPPORT;
 			}
+			break;
 		default:
 			result = EEH_STATE_NOT_SUPPORT;
 		}
-- 
1.9.1


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

* [PATCH 3.8 011/116] PCI: Add new ID for Intel GPU "spurious interrupt" quirk
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (9 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 010/116] powerpc/pseries: Fix overwritten PE state Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 012/116] x86-32, espfix: Remove filter for espfix32 due to race Kamal Mostafa
                   ` (104 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Thomas Jarosch, Bjorn Helgaas, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Thomas Jarosch <thomas.jarosch@intra2net.com>

commit 7c82126a94e69bbbac586f0249e7ef11e681246c upstream.

After a CPU upgrade while keeping the same mainboard, we faced "spurious
interrupt" problems again.

It turned out that the new CPU also featured a new GPU with a different PCI
ID.

Add this PCI ID to the quirk table.  Probably all other Intel GPU PCI IDs
are affected, too, but I don't want to add them without a test system.

See f67fd55fa96f ("PCI: Add quirk for still enabled interrupts on Intel
Sandy Bridge GPUs") for some history.

[bhelgaas: add f67fd55fa96f reference, stable tag]
Signed-off-by: Thomas Jarosch <thomas.jarosch@intra2net.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/pci/quirks.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 8b51656..902cb3b 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -2952,6 +2952,7 @@ static void disable_igfx_irq(struct pci_dev *dev)
 }
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x0102, disable_igfx_irq);
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x010a, disable_igfx_irq);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x0152, disable_igfx_irq);
 
 /*
  * Some devices may pass our check in pci_intx_mask_supported if
-- 
1.9.1


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

* [PATCH 3.8 012/116] x86-32, espfix: Remove filter for espfix32 due to race
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (10 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 011/116] PCI: Add new ID for Intel GPU "spurious interrupt" quirk Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 013/116] genirq: Sanitize spurious interrupt detection of threaded irqs Kamal Mostafa
                   ` (103 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: H. Peter Anvin, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: "H. Peter Anvin" <hpa@linux.intel.com>

commit 246f2d2ee1d715e1077fc47d61c394569c8ee692 upstream.

It is not safe to use LAR to filter when to go down the espfix path,
because the LDT is per-process (rather than per-thread) and another
thread might change the descriptors behind our back.  Fortunately it
is always *safe* (if a bit slow) to go down the espfix path, and a
32-bit LDT stack segment is extremely rare.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Link: http://lkml.kernel.org/r/1398816946-3351-1-git-send-email-hpa@linux.intel.com
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 arch/x86/kernel/entry_32.S | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
index 1d7fdbe..60d03c2 100644
--- a/arch/x86/kernel/entry_32.S
+++ b/arch/x86/kernel/entry_32.S
@@ -554,11 +554,6 @@ ENTRY(iret_exc)
 
 	CFI_RESTORE_STATE
 ldt_ss:
-	larl PT_OLDSS(%esp), %eax
-	jnz restore_nocheck
-	testl $0x00400000, %eax		# returning to 32bit stack?
-	jnz restore_nocheck		# allright, normal return
-
 #ifdef CONFIG_PARAVIRT
 	/*
 	 * The kernel can't run on a non-flat stack if paravirt mode
-- 
1.9.1


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

* [PATCH 3.8 013/116] genirq: Sanitize spurious interrupt detection of threaded irqs
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (11 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 012/116] x86-32, espfix: Remove filter for espfix32 due to race Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 014/116] x86, x32: Use compat shims for io_{setup,submit} Kamal Mostafa
                   ` (102 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Thomas Gleixner, Oliver Hartkopp, Wolfgang Grandegger,
	Pavel Pisa, Marc Kleine-Budde, linux-can, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Thomas Gleixner <tglx@linutronix.de>

commit 1e77d0a1ed7417d2a5a52a7b8d32aea1833faa6c upstream.

Till reported that the spurious interrupt detection of threaded
interrupts is broken in two ways:

- note_interrupt() is called for each action thread of a shared
  interrupt line. That's wrong as we are only interested whether none
  of the device drivers felt responsible for the interrupt, but by
  calling multiple times for a single interrupt line we account
  IRQ_NONE even if one of the drivers felt responsible.

- note_interrupt() when called from the thread handler is not
  serialized. That leaves the members of irq_desc which are used for
  the spurious detection unprotected.

To solve this we need to defer the spurious detection of a threaded
interrupt to the next hardware interrupt context where we have
implicit serialization.

If note_interrupt is called with action_ret == IRQ_WAKE_THREAD, we
check whether the previous interrupt requested a deferred check. If
not, we request a deferred check for the next hardware interrupt and
return.

If set, we check whether one of the interrupt threads signaled
success. Depending on this information we feed the result into the
spurious detector.

If one primary handler of a shared interrupt returns IRQ_HANDLED we
disable the deferred check of irq threads on the same line, as we have
found at least one device driver who cared.

Reported-by: Till Straumann <strauman@slac.stanford.edu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Austin Schuh <austin@peloton-tech.com>
Cc: Oliver Hartkopp <socketcan@hartkopp.net>
Cc: Wolfgang Grandegger <wg@grandegger.com>
Cc: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Cc: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: linux-can@vger.kernel.org
Link: http://lkml.kernel.org/r/alpine.LFD.2.02.1303071450130.22263@ionos

Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 include/linux/irqdesc.h |   4 ++
 kernel/irq/manage.c     |   4 +-
 kernel/irq/spurious.c   | 106 ++++++++++++++++++++++++++++++++++++++++++++++--
 3 files changed, 108 insertions(+), 6 deletions(-)

diff --git a/include/linux/irqdesc.h b/include/linux/irqdesc.h
index 623325e..078bc2f 100644
--- a/include/linux/irqdesc.h
+++ b/include/linux/irqdesc.h
@@ -27,6 +27,8 @@ struct irq_desc;
  * @irq_count:		stats field to detect stalled irqs
  * @last_unhandled:	aging timer for unhandled count
  * @irqs_unhandled:	stats field for spurious unhandled interrupts
+ * @threads_handled:	stats field for deferred spurious detection of threaded handlers
+ * @threads_handled_last: comparator field for deferred spurious detection of theraded handlers
  * @lock:		locking for SMP
  * @affinity_hint:	hint to user space for preferred irq affinity
  * @affinity_notify:	context for notification of affinity changes
@@ -52,6 +54,8 @@ struct irq_desc {
 	unsigned int		irq_count;	/* For detecting broken IRQs */
 	unsigned long		last_unhandled;	/* Aging timer for unhandled count */
 	unsigned int		irqs_unhandled;
+	atomic_t		threads_handled;
+	int			threads_handled_last;
 	raw_spinlock_t		lock;
 	struct cpumask		*percpu_enabled;
 #ifdef CONFIG_SMP
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index edbe80e..f26e367 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -860,8 +860,8 @@ static int irq_thread(void *data)
 		irq_thread_check_affinity(desc, action);
 
 		action_ret = handler_fn(desc, action);
-		if (!noirqdebug)
-			note_interrupt(action->irq, desc, action_ret);
+		if (action_ret == IRQ_HANDLED)
+			atomic_inc(&desc->threads_handled);
 
 		wake_threads_waitq(desc);
 	}
diff --git a/kernel/irq/spurious.c b/kernel/irq/spurious.c
index 7b5f012..febcee3c 100644
--- a/kernel/irq/spurious.c
+++ b/kernel/irq/spurious.c
@@ -265,21 +265,119 @@ try_misrouted_irq(unsigned int irq, struct irq_desc *desc,
 	return action && (action->flags & IRQF_IRQPOLL);
 }
 
+#define SPURIOUS_DEFERRED	0x80000000
+
 void note_interrupt(unsigned int irq, struct irq_desc *desc,
 		    irqreturn_t action_ret)
 {
 	if (desc->istate & IRQS_POLL_INPROGRESS)
 		return;
 
-	/* we get here again via the threaded handler */
-	if (action_ret == IRQ_WAKE_THREAD)
-		return;
-
 	if (bad_action_ret(action_ret)) {
 		report_bad_irq(irq, desc, action_ret);
 		return;
 	}
 
+	/*
+	 * We cannot call note_interrupt from the threaded handler
+	 * because we need to look at the compound of all handlers
+	 * (primary and threaded). Aside of that in the threaded
+	 * shared case we have no serialization against an incoming
+	 * hardware interrupt while we are dealing with a threaded
+	 * result.
+	 *
+	 * So in case a thread is woken, we just note the fact and
+	 * defer the analysis to the next hardware interrupt.
+	 *
+	 * The threaded handlers store whether they sucessfully
+	 * handled an interrupt and we check whether that number
+	 * changed versus the last invocation.
+	 *
+	 * We could handle all interrupts with the delayed by one
+	 * mechanism, but for the non forced threaded case we'd just
+	 * add pointless overhead to the straight hardirq interrupts
+	 * for the sake of a few lines less code.
+	 */
+	if (action_ret & IRQ_WAKE_THREAD) {
+		/*
+		 * There is a thread woken. Check whether one of the
+		 * shared primary handlers returned IRQ_HANDLED. If
+		 * not we defer the spurious detection to the next
+		 * interrupt.
+		 */
+		if (action_ret == IRQ_WAKE_THREAD) {
+			int handled;
+			/*
+			 * We use bit 31 of thread_handled_last to
+			 * denote the deferred spurious detection
+			 * active. No locking necessary as
+			 * thread_handled_last is only accessed here
+			 * and we have the guarantee that hard
+			 * interrupts are not reentrant.
+			 */
+			if (!(desc->threads_handled_last & SPURIOUS_DEFERRED)) {
+				desc->threads_handled_last |= SPURIOUS_DEFERRED;
+				return;
+			}
+			/*
+			 * Check whether one of the threaded handlers
+			 * returned IRQ_HANDLED since the last
+			 * interrupt happened.
+			 *
+			 * For simplicity we just set bit 31, as it is
+			 * set in threads_handled_last as well. So we
+			 * avoid extra masking. And we really do not
+			 * care about the high bits of the handled
+			 * count. We just care about the count being
+			 * different than the one we saw before.
+			 */
+			handled = atomic_read(&desc->threads_handled);
+			handled |= SPURIOUS_DEFERRED;
+			if (handled != desc->threads_handled_last) {
+				action_ret = IRQ_HANDLED;
+				/*
+				 * Note: We keep the SPURIOUS_DEFERRED
+				 * bit set. We are handling the
+				 * previous invocation right now.
+				 * Keep it for the current one, so the
+				 * next hardware interrupt will
+				 * account for it.
+				 */
+				desc->threads_handled_last = handled;
+			} else {
+				/*
+				 * None of the threaded handlers felt
+				 * responsible for the last interrupt
+				 *
+				 * We keep the SPURIOUS_DEFERRED bit
+				 * set in threads_handled_last as we
+				 * need to account for the current
+				 * interrupt as well.
+				 */
+				action_ret = IRQ_NONE;
+			}
+		} else {
+			/*
+			 * One of the primary handlers returned
+			 * IRQ_HANDLED. So we don't care about the
+			 * threaded handlers on the same line. Clear
+			 * the deferred detection bit.
+			 *
+			 * In theory we could/should check whether the
+			 * deferred bit is set and take the result of
+			 * the previous run into account here as
+			 * well. But it's really not worth the
+			 * trouble. If every other interrupt is
+			 * handled we never trigger the spurious
+			 * detector. And if this is just the one out
+			 * of 100k unhandled ones which is handled
+			 * then we merily delay the spurious detection
+			 * by one hard interrupt. Not a real problem.
+			 */
+			desc->threads_handled_last &= ~SPURIOUS_DEFERRED;
+		}
+	}
+
 	if (unlikely(action_ret == IRQ_NONE)) {
 		/*
 		 * If we are seeing only the odd spurious IRQ caused by
-- 
1.9.1


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

* [PATCH 3.8 014/116] x86, x32: Use compat shims for io_{setup,submit}
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (12 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 013/116] genirq: Sanitize spurious interrupt detection of threaded irqs Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 015/116] iwlwifi: pcie: try to get ownership several times Kamal Mostafa
                   ` (101 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Mike Frysinger, H.J. Lu, H. Peter Anvin, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Mike Frysinger <vapier@gentoo.org>

commit 7fd44dacdd803c0bbf38bf478d51d280902bb0f1 upstream.

The io_setup takes a pointer to a context id of type aio_context_t.
This in turn is typed to a __kernel_ulong_t.  We could tweak the
exported headers to define this as a 64bit quantity for specific
ABIs, but since we already have a 32bit compat shim for the x86 ABI,
let's just re-use that logic.  The libaio package is also written to
expect this as a pointer type, so a compat shim would simplify that.

The io_submit func operates on an array of pointers to iocb structs.
Padding out the array to be 64bit aligned is a huge pain, so convert
it over to the existing compat shim too.

We don't convert io_getevents to the compat func as its only purpose
is to handle the timespec struct, and the x32 ABI uses 64bit times.

With this change, the libaio package can now pass its testsuite when
built for the x32 ABI.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Link: http://lkml.kernel.org/r/1399250595-5005-1-git-send-email-vapier@gentoo.org
Cc: H.J. Lu <hjl.tools@gmail.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 arch/x86/syscalls/syscall_64.tbl | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/x86/syscalls/syscall_64.tbl b/arch/x86/syscalls/syscall_64.tbl
index dc97328..0a42b1e 100644
--- a/arch/x86/syscalls/syscall_64.tbl
+++ b/arch/x86/syscalls/syscall_64.tbl
@@ -212,10 +212,10 @@
 203	common	sched_setaffinity	sys_sched_setaffinity
 204	common	sched_getaffinity	sys_sched_getaffinity
 205	64	set_thread_area
-206	common	io_setup		sys_io_setup
+206	64	io_setup		sys_io_setup
 207	common	io_destroy		sys_io_destroy
 208	common	io_getevents		sys_io_getevents
-209	common	io_submit		sys_io_submit
+209	64	io_submit		sys_io_submit
 210	common	io_cancel		sys_io_cancel
 211	64	get_thread_area
 212	common	lookup_dcookie		sys_lookup_dcookie
@@ -356,3 +356,5 @@
 540	x32	process_vm_writev	compat_sys_process_vm_writev
 541	x32	setsockopt		compat_sys_setsockopt
 542	x32	getsockopt		compat_sys_getsockopt
+543	x32	io_setup		compat_sys_io_setup
+544	x32	io_submit		compat_sys_io_submit
-- 
1.9.1


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

* [PATCH 3.8 015/116] iwlwifi: pcie: try to get ownership several times
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (13 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 014/116] x86, x32: Use compat shims for io_{setup,submit} Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 016/116] UBIFS: fix an mmap and fsync race condition Kamal Mostafa
                   ` (100 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Emmanuel Grumbach, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Emmanuel Grumbach <emmanuel.grumbach@intel.com>

commit 501fd9895c1d7d8161ed56698ae2fccb10ef14f5 upstream.

Some races with the hardware can happen when we take
ownership of the device. Don't give up after the first try.

Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/net/wireless/iwlwifi/pcie/trans.c | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
index be0f8b9..68335b5 100644
--- a/drivers/net/wireless/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
@@ -304,6 +304,7 @@ static int iwl_pcie_prepare_card_hw(struct iwl_trans *trans)
 {
 	int ret;
 	int t = 0;
+	int iter;
 
 	IWL_DEBUG_INFO(trans, "iwl_trans_prepare_card_hw enter\n");
 
@@ -312,18 +313,23 @@ static int iwl_pcie_prepare_card_hw(struct iwl_trans *trans)
 	if (ret >= 0)
 		return 0;
 
-	/* If HW is not ready, prepare the conditions to check again */
-	iwl_set_bit(trans, CSR_HW_IF_CONFIG_REG,
-		    CSR_HW_IF_CONFIG_REG_PREPARE);
+	for (iter = 0; iter < 10; iter++) {
+		/* If HW is not ready, prepare the conditions to check again */
+		iwl_set_bit(trans, CSR_HW_IF_CONFIG_REG,
+			    CSR_HW_IF_CONFIG_REG_PREPARE);
+
+		do {
+			ret = iwl_pcie_set_hw_ready(trans);
+			if (ret >= 0)
+				return 0;
 
-	do {
-		ret = iwl_pcie_set_hw_ready(trans);
-		if (ret >= 0)
-			return 0;
+			usleep_range(200, 1000);
+			t += 200;
+		} while (t < 150000);
+		msleep(25);
+	}
 
-		usleep_range(200, 1000);
-		t += 200;
-	} while (t < 150000);
+	IWL_DEBUG_INFO(trans, "got NIC after %d iterations\n", iter);
 
 	return ret;
 }
-- 
1.9.1


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

* [PATCH 3.8 016/116] UBIFS: fix an mmap and fsync race condition
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (14 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 015/116] iwlwifi: pcie: try to get ownership several times Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 017/116] ACPI: Fix conflict between customized DSDT and DSDT local copy Kamal Mostafa
                   ` (99 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: hujianyang, Artem Bityutskiy, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: hujianyang <hujianyang@huawei.com>

commit 691a7c6f28ac90cccd0dbcf81348ea90b211bdd0 upstream.

There is a race condition in UBIFS:

Thread A (mmap)                        Thread B (fsync)

->__do_fault                           ->write_cache_pages
   -> ubifs_vm_page_mkwrite
       -> budget_space
       -> lock_page
       -> release/convert_page_budget
       -> SetPagePrivate
       -> TestSetPageDirty
       -> unlock_page
                                       -> lock_page
                                           -> TestClearPageDirty
                                           -> ubifs_writepage
                                               -> do_writepage
                                                   -> release_budget
                                                   -> ClearPagePrivate
                                                   -> unlock_page
   -> !(ret & VM_FAULT_LOCKED)
   -> lock_page
   -> set_page_dirty
       -> ubifs_set_page_dirty
           -> TestSetPageDirty (set page dirty without budgeting)
   -> unlock_page

This leads to situation where we have a diry page but no budget allocated for
this page, so further write-back may fail with -ENOSPC.

In this fix we return from page_mkwrite without performing unlock_page. We
return VM_FAULT_LOCKED instead. After doing this, the race above will not
happen.

Signed-off-by: hujianyang <hujianyang@huawei.com>
Tested-by: Laurence Withers <lwithers@guralp.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 fs/ubifs/file.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
index 5bc7781..bc7798d 100644
--- a/fs/ubifs/file.c
+++ b/fs/ubifs/file.c
@@ -1522,8 +1522,7 @@ static int ubifs_vm_page_mkwrite(struct vm_area_struct *vma,
 			ubifs_release_dirty_inode_budget(c, ui);
 	}
 
-	unlock_page(page);
-	return 0;
+	return VM_FAULT_LOCKED;
 
 out_unlock:
 	unlock_page(page);
-- 
1.9.1


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

* [PATCH 3.8 017/116] ACPI: Fix conflict between customized DSDT and DSDT local copy
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (15 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 016/116] UBIFS: fix an mmap and fsync race condition Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 018/116] [SCSI] hpsa: add HP Smart Array Gen9 PCI ID's Kamal Mostafa
                   ` (98 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Enrico Etxe Arte, Lv Zheng, Rafael J. Wysocki, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Lv Zheng <lv.zheng@intel.com>

commit 73577d1df8e1f31f6b1a5eebcdbc334eb0330e47 upstream.

This patch fixes the following issue:
If DSDT is customized, no local DSDT copy is needed.

References: https://bugzilla.kernel.org/show_bug.cgi?id=69711
Signed-off-by: Enrico Etxe Arte <goitizena.generoa@gmail.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
[rjw: Subject]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/acpi/bus.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index de22f48..5e9ad05 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -57,6 +57,12 @@ EXPORT_SYMBOL(acpi_root_dir);
 
 
 #ifdef CONFIG_X86
+#ifdef CONFIG_ACPI_CUSTOM_DSDT
+static inline int set_copy_dsdt(const struct dmi_system_id *id)
+{
+	return 0;
+}
+#else
 static int set_copy_dsdt(const struct dmi_system_id *id)
 {
 	printk(KERN_NOTICE "%s detected - "
@@ -64,6 +70,7 @@ static int set_copy_dsdt(const struct dmi_system_id *id)
 	acpi_gbl_copy_dsdt_locally = 1;
 	return 0;
 }
+#endif
 
 static struct dmi_system_id dsdt_dmi_table[] __initdata = {
 	/*
-- 
1.9.1


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

* [PATCH 3.8 018/116] [SCSI] hpsa: add HP Smart Array Gen9 PCI ID's
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (16 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 017/116] ACPI: Fix conflict between customized DSDT and DSDT local copy Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 019/116] hpsa: add new Smart Array PCI IDs (May 2014) Kamal Mostafa
                   ` (97 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Mike Miller, James Bottomley, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Mike Miller <mike.miller@hp.com>

commit 97b9f53d7deb3b8c0acdeb52a5801f9f5080ce0f upstream.

This patch adds the PCI ID's for HP Smart Array Gen9 controllers. Please
consider this patch for inclusion.

Signed-off-by: Mike Miller <mike.miller@hp.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/scsi/hpsa.c     | 25 +++++++++++++++++++++++++
 include/linux/pci_ids.h |  1 +
 2 files changed, 26 insertions(+)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 4884df9..051085d 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -108,6 +108,19 @@ static const struct pci_device_id hpsa_pci_device_id[] = {
 	{PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSH,     0x103C, 0x1926},
 	{PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSH,     0x103C, 0x1928},
 	{PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSF,     0x103C, 0x334d},
+	{PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSH,     0x103C, 0x1929},
+	{PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSI,     0x103C, 0x21BD},
+	{PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSI,     0x103C, 0x21BE},
+	{PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSI,     0x103C, 0x21BF},
+	{PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSI,     0x103C, 0x21C0},
+	{PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSI,     0x103C, 0x21C1},
+	{PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSI,     0x103C, 0x21C2},
+	{PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSI,     0x103C, 0x21C3},
+	{PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSI,     0x103C, 0x21C4},
+	{PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSI,     0x103C, 0x21C5},
+	{PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSI,     0x103C, 0x21C7},
+	{PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSI,     0x103C, 0x21C8},
+	{PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSI,     0x103C, 0x21C9},
 	{PCI_VENDOR_ID_HP,     PCI_ANY_ID,	PCI_ANY_ID, PCI_ANY_ID,
 		PCI_CLASS_STORAGE_RAID << 8, 0xffff << 8, 0},
 	{0,}
@@ -143,6 +156,18 @@ static struct board_type products[] = {
 	{0x1926103C, "Smart Array", &SA5_access},
 	{0x1928103C, "Smart Array", &SA5_access},
 	{0x334d103C, "Smart Array P822se", &SA5_access},
+	{0x21BD103C, "Smart Array", &SA5_access},
+	{0x21BE103C, "Smart Array", &SA5_access},
+	{0x21BF103C, "Smart Array", &SA5_access},
+	{0x21C0103C, "Smart Array", &SA5_access},
+	{0x21C1103C, "Smart Array", &SA5_access},
+	{0x21C2103C, "Smart Array", &SA5_access},
+	{0x21C3103C, "Smart Array", &SA5_access},
+	{0x21C4103C, "Smart Array", &SA5_access},
+	{0x21C5103C, "Smart Array", &SA5_access},
+	{0x21C7103C, "Smart Array", &SA5_access},
+	{0x21C8103C, "Smart Array", &SA5_access},
+	{0x21C9103C, "Smart Array", &SA5_access},
 	{0xFFFF103C, "Unknown Smart Array", &SA5_access},
 };
 
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index 0eb6579..ed403e9 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -754,6 +754,7 @@
 #define PCI_DEVICE_ID_HP_CISSE		0x323a
 #define PCI_DEVICE_ID_HP_CISSF		0x323b
 #define PCI_DEVICE_ID_HP_CISSH		0x323c
+#define PCI_DEVICE_ID_HP_CISSI		0x3239
 #define PCI_DEVICE_ID_HP_ZX2_IOC	0x4031
 
 #define PCI_VENDOR_ID_PCTECH		0x1042
-- 
1.9.1


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

* [PATCH 3.8 019/116] hpsa: add new Smart Array PCI IDs (May 2014)
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (17 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 018/116] [SCSI] hpsa: add HP Smart Array Gen9 PCI ID's Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 020/116] PM / OPP: fix incorrect OPP count handling in of_init_opp_table Kamal Mostafa
                   ` (96 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Scott Teel, Joe Handzik, Stephen M. Cameron, Christoph Hellwig,
	Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Joe Handzik <joseph.t.handzik@hp.com>

commit 3b7a45e5ba85dc79c7714edd9eee9aaed730cd6b upstream.

Signed-off-by: Scott Teel <scott.teel@hp.com>
Signed-off-by: Joe Handzik <joseph.t.handzik@hp.com>
Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/scsi/hpsa.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 051085d..3cdaed0 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -118,9 +118,15 @@ static const struct pci_device_id hpsa_pci_device_id[] = {
 	{PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSI,     0x103C, 0x21C3},
 	{PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSI,     0x103C, 0x21C4},
 	{PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSI,     0x103C, 0x21C5},
+	{PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSI,     0x103C, 0x21C6},
 	{PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSI,     0x103C, 0x21C7},
 	{PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSI,     0x103C, 0x21C8},
 	{PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSI,     0x103C, 0x21C9},
+	{PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSI,     0x103C, 0x21CA},
+	{PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSI,     0x103C, 0x21CB},
+	{PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSI,     0x103C, 0x21CC},
+	{PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSI,     0x103C, 0x21CD},
+	{PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSI,     0x103C, 0x21CE},
 	{PCI_VENDOR_ID_HP,     PCI_ANY_ID,	PCI_ANY_ID, PCI_ANY_ID,
 		PCI_CLASS_STORAGE_RAID << 8, 0xffff << 8, 0},
 	{0,}
@@ -165,9 +171,15 @@ static struct board_type products[] = {
 	{0x21C3103C, "Smart Array", &SA5_access},
 	{0x21C4103C, "Smart Array", &SA5_access},
 	{0x21C5103C, "Smart Array", &SA5_access},
+	{0x21C6103C, "Smart Array", &SA5_access},
 	{0x21C7103C, "Smart Array", &SA5_access},
 	{0x21C8103C, "Smart Array", &SA5_access},
 	{0x21C9103C, "Smart Array", &SA5_access},
+	{0x21CA103C, "Smart Array", &SA5_access},
+	{0x21CB103C, "Smart Array", &SA5_access},
+	{0x21CC103C, "Smart Array", &SA5_access},
+	{0x21CD103C, "Smart Array", &SA5_access},
+	{0x21CE103C, "Smart Array", &SA5_access},
 	{0xFFFF103C, "Unknown Smart Array", &SA5_access},
 };
 
-- 
1.9.1


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

* [PATCH 3.8 020/116] PM / OPP: fix incorrect OPP count handling in of_init_opp_table
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (18 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 019/116] hpsa: add new Smart Array PCI IDs (May 2014) Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 021/116] HID: core: fix validation of report id 0 Kamal Mostafa
                   ` (95 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Chander Kashyap, Inderpal Singh, Rafael J. Wysocki, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Chander Kashyap <chander.kashyap@linaro.org>

commit 086abb58590a4df73e8a6ed71fd418826937cd46 upstream.

In of_init_opp_table function, if a failure to add an OPP is
detected, the count of OPPs, yet to be added is not updated.
Fix this by decrementing this count on failure as well.

Signed-off-by: Chander Kashyap <k.chander@samsung.com>
Signed-off-by: Inderpal Singh <inderpal.s@samsung.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
[ kamal: backport to 3.8-stable: context ]
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/base/power/opp.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
index 50b2831..7461649 100644
--- a/drivers/base/power/opp.c
+++ b/drivers/base/power/opp.c
@@ -728,11 +728,9 @@ int of_init_opp_table(struct device *dev)
 		unsigned long freq = be32_to_cpup(val++) * 1000;
 		unsigned long volt = be32_to_cpup(val++);
 
-		if (opp_add(dev, freq, volt)) {
+		if (opp_add(dev, freq, volt))
 			dev_warn(dev, "%s: Failed to add OPP %ld\n",
 				 __func__, freq);
-			continue;
-		}
 		nr -= 2;
 	}
 
-- 
1.9.1


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

* [PATCH 3.8 021/116] HID: core: fix validation of report id 0
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (19 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 020/116] PM / OPP: fix incorrect OPP count handling in of_init_opp_table Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 022/116] IB/srp: Fix a sporadic crash triggered by cable pulling Kamal Mostafa
                   ` (94 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Kees Cook, Jiri Kosina, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Kees Cook <keescook@chromium.org>

commit 1b15d2e5b8077670b1e6a33250a0d9577efff4a5 upstream.

Some drivers use the first HID report in the list instead of using an
index. In these cases, validation uses ID 0, which was supposed to mean
"first known report". This fixes the problem, which was causing at least
the lgff family of devices to stop working since hid_validate_values
was being called with ID 0, but the devices used single numbered IDs
for their reports:

0x05, 0x01,         /*  Usage Page (Desktop),                   */
0x09, 0x05,         /*  Usage (Gamepad),                        */
0xA1, 0x01,         /*  Collection (Application),               */
0xA1, 0x02,         /*      Collection (Logical),               */
0x85, 0x01,         /*          Report ID (1),                  */
...

Reported-by: Simon Wood <simon@mungewell.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/hid/hid-core.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 14744e0..8ad2505 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -797,7 +797,17 @@ struct hid_report *hid_validate_values(struct hid_device *hid,
 	 * ->numbered being checked, which may not always be the case when
 	 * drivers go to access report values.
 	 */
-	report = hid->report_enum[type].report_id_hash[id];
+	if (id == 0) {
+		/*
+		 * Validating on id 0 means we should examine the first
+		 * report in the list.
+		 */
+		report = list_entry(
+				hid->report_enum[type].report_list.next,
+				struct hid_report, list);
+	} else {
+		report = hid->report_enum[type].report_id_hash[id];
+	}
 	if (!report) {
 		hid_err(hid, "missing %s %u\n", hid_report_names[type], id);
 		return NULL;
-- 
1.9.1


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

* [PATCH 3.8 022/116] IB/srp: Fix a sporadic crash triggered by cable pulling
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (20 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 021/116] HID: core: fix validation of report id 0 Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 023/116] reiserfs: call truncate_setsize under tailpack mutex Kamal Mostafa
                   ` (93 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Bart Van Assche, Roland Dreier, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Bart Van Assche <bvanassche@acm.org>

commit 024ca90151f5e4296d30f72c13ff9a075e23c9ec upstream.

Avoid that the loops that iterate over the request ring can encounter
a pointer to a SCSI command in req->scmnd that is no longer associated
with that request. If the function srp_unmap_data() is invoked twice
for a SCSI command that is not in flight then that would cause
ib_fmr_pool_unmap() to be invoked with an invalid pointer as argument,
resulting in a kernel oops.

Reported-by: Sagi Grimberg <sagig@mellanox.com>
Reference: http://thread.gmane.org/gmane.linux.drivers.rdma/19068/focus=19069
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Sagi Grimberg <sagig@mellanox.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/infiniband/ulp/srp/ib_srp.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index e070166..5682e8e 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -1410,6 +1410,12 @@ err_unmap:
 err_iu:
 	srp_put_tx_iu(target, iu, SRP_IU_CMD);
 
+	/*
+	 * Avoid that the loops that iterate over the request ring can
+	 * encounter a dangling SCSI command pointer.
+	 */
+	req->scmnd = NULL;
+
 	spin_lock_irqsave(&target->lock, flags);
 	list_add(&req->list, &target->free_reqs);
 
-- 
1.9.1


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

* [PATCH 3.8 023/116] reiserfs: call truncate_setsize under tailpack mutex
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (21 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 022/116] IB/srp: Fix a sporadic crash triggered by cable pulling Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 024/116] ARM: stacktrace: avoid listing stacktrace functions in stacktrace Kamal Mostafa
                   ` (92 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Jeff Mahoney, Jan Kara, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Jeff Mahoney <jeffm@suse.com>

commit 22e7478ddbcb670e33fab72d0bbe7c394c3a2c84 upstream.

Prior to commit 0e4f6a791b1e (Fix reiserfs_file_release()), reiserfs
truncates serialized on i_mutex. They mostly still do, with the exception
of reiserfs_file_release. That blocks out other writers via the tailpack
mutex and the inode openers counter adjusted in reiserfs_file_open.

However, NFS will call reiserfs_setattr without having called ->open, so
we end up with a race when nfs is calling ->setattr while another
process is releasing the file. Ultimately, it triggers the
BUG_ON(inode->i_size != new_file_size) check in maybe_indirect_to_direct.

The solution is to pull the lock into reiserfs_setattr to encompass the
truncate_setsize call as well.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 fs/reiserfs/inode.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index ca71b1f..0c1e96e 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -3210,8 +3210,14 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
 	    attr->ia_size != i_size_read(inode)) {
 		error = inode_newsize_ok(inode, attr->ia_size);
 		if (!error) {
+			/*
+			 * Could race against reiserfs_file_release
+			 * if called from NFS, so take tailpack mutex.
+			 */
+			mutex_lock(&REISERFS_I(inode)->tailpack);
 			truncate_setsize(inode, attr->ia_size);
-			reiserfs_vfs_truncate_file(inode);
+			reiserfs_truncate_file(inode, 1);
+			mutex_unlock(&REISERFS_I(inode)->tailpack);
 		}
 	}
 
-- 
1.9.1


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

* [PATCH 3.8 024/116] ARM: stacktrace: avoid listing stacktrace functions in stacktrace
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (22 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 023/116] reiserfs: call truncate_setsize under tailpack mutex Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 025/116] SUNRPC: Fix a module reference leak in svc_handle_xprt Kamal Mostafa
                   ` (91 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Russell King, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Russell King <rmk+kernel@arm.linux.org.uk>

commit 3683f44c42e991d313dc301504ee0fca1aeb8580 upstream.

While debugging the FEC ethernet driver using stacktrace, it was noticed
that the stacktraces always begin as follows:

 [<c00117b4>] save_stack_trace_tsk+0x0/0x98
 [<c0011870>] save_stack_trace+0x24/0x28
 ...

This is because the stack trace code includes the stack frames for itself.
This is incorrect behaviour, and also leads to "skip" doing the wrong
thing (which is the number of stack frames to avoid recording.)

Perversely, it does the right thing when passed a non-current thread.  Fix
this by ensuring that we have a known constant number of frames above the
main stack trace function, and always skip these.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 arch/arm/kernel/stacktrace.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/arch/arm/kernel/stacktrace.c b/arch/arm/kernel/stacktrace.c
index af4e8c8..6582c4a 100644
--- a/arch/arm/kernel/stacktrace.c
+++ b/arch/arm/kernel/stacktrace.c
@@ -83,13 +83,16 @@ static int save_trace(struct stackframe *frame, void *d)
 	return trace->nr_entries >= trace->max_entries;
 }
 
-void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
+/* This must be noinline to so that our skip calculation works correctly */
+static noinline void __save_stack_trace(struct task_struct *tsk,
+	struct stack_trace *trace, unsigned int nosched)
 {
 	struct stack_trace_data data;
 	struct stackframe frame;
 
 	data.trace = trace;
 	data.skip = trace->skip;
+	data.no_sched_functions = nosched;
 
 	if (tsk != current) {
 #ifdef CONFIG_SMP
@@ -102,7 +105,6 @@ void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
 			trace->entries[trace->nr_entries++] = ULONG_MAX;
 		return;
 #else
-		data.no_sched_functions = 1;
 		frame.fp = thread_saved_fp(tsk);
 		frame.sp = thread_saved_sp(tsk);
 		frame.lr = 0;		/* recovered from the stack */
@@ -111,11 +113,12 @@ void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
 	} else {
 		register unsigned long current_sp asm ("sp");
 
-		data.no_sched_functions = 0;
+		/* We don't want this function nor the caller */
+		data.skip += 2;
 		frame.fp = (unsigned long)__builtin_frame_address(0);
 		frame.sp = current_sp;
 		frame.lr = (unsigned long)__builtin_return_address(0);
-		frame.pc = (unsigned long)save_stack_trace_tsk;
+		frame.pc = (unsigned long)__save_stack_trace;
 	}
 
 	walk_stackframe(&frame, save_trace, &data);
@@ -123,9 +126,14 @@ void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
 		trace->entries[trace->nr_entries++] = ULONG_MAX;
 }
 
+void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
+{
+	__save_stack_trace(tsk, trace, 1);
+}
+
 void save_stack_trace(struct stack_trace *trace)
 {
-	save_stack_trace_tsk(current, trace);
+	__save_stack_trace(current, trace, 0);
 }
 EXPORT_SYMBOL_GPL(save_stack_trace);
 #endif
-- 
1.9.1


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

* [PATCH 3.8 025/116] SUNRPC: Fix a module reference leak in svc_handle_xprt
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (23 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 024/116] ARM: stacktrace: avoid listing stacktrace functions in stacktrace Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 026/116] [media] uvcvideo: Fix clock param realtime setting Kamal Mostafa
                   ` (90 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Trond Myklebust, J. Bruce Fields, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Trond Myklebust <trond.myklebust@primarydata.com>

commit c789102c20bbbdda6831a273e046715be9d6af79 upstream.

If the accept() call fails, we need to put the module reference.

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 net/sunrpc/svc_xprt.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
index ca71056..9088c68 100644
--- a/net/sunrpc/svc_xprt.c
+++ b/net/sunrpc/svc_xprt.c
@@ -723,6 +723,8 @@ static int svc_handle_xprt(struct svc_rqst *rqstp, struct svc_xprt *xprt)
 		newxpt = xprt->xpt_ops->xpo_accept(xprt);
 		if (newxpt)
 			svc_add_new_temp_xprt(serv, newxpt);
+		else
+			module_put(xprt->xpt_class->xcl_owner);
 	} else if (xprt->xpt_ops->xpo_has_wspace(xprt)) {
 		/* XPT_DATA|XPT_DEFERRED case: */
 		dprintk("svc: server %p, pool %u, transport %p, inuse=%d\n",
-- 
1.9.1


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

* [PATCH 3.8 026/116] [media] uvcvideo: Fix clock param realtime setting
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (24 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 025/116] SUNRPC: Fix a module reference leak in svc_handle_xprt Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 027/116] [media] ivtv: Fix Oops when no firmware is loaded Kamal Mostafa
                   ` (89 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Olivier Langlois, Laurent Pinchart, Mauro Carvalho Chehab, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Olivier Langlois <olivier@trillion01.com>

commit 3b35fc81e7ec552147a4fd843d0da0bbbe4ef253 upstream.

timestamps in v4l2 buffers returned to userspace are updated in
uvc_video_clock_update() which uses timestamps fetched from
uvc_video_clock_decode() by calling unconditionally ktime_get_ts().

Hence setting the module clock param to realtime has no effect before
this patch.

This has been tested with ffmpeg:

ffmpeg -y -f v4l2 -input_format yuyv422 -video_size 640x480 -framerate 30 -i /dev/video0 \
 -f alsa -acodec pcm_s16le -ar 16000 -ac 1 -i default \
 -c:v libx264 -preset ultrafast \
 -c:a libfdk_aac \
 out.mkv

and inspecting the v4l2 input starting timestamp.

Signed-off-by: Olivier Langlois <olivier@trillion01.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/media/usb/uvc/uvc_video.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
index e1c5bf3e..c081812 100644
--- a/drivers/media/usb/uvc/uvc_video.c
+++ b/drivers/media/usb/uvc/uvc_video.c
@@ -361,6 +361,14 @@ static int uvc_commit_video(struct uvc_streaming *stream,
  * Clocks and timestamps
  */
 
+static inline void uvc_video_get_ts(struct timespec *ts)
+{
+	if (uvc_clock_param == CLOCK_MONOTONIC)
+		ktime_get_ts(ts);
+	else
+		ktime_get_real_ts(ts);
+}
+
 static void
 uvc_video_clock_decode(struct uvc_streaming *stream, struct uvc_buffer *buf,
 		       const __u8 *data, int len)
@@ -420,7 +428,7 @@ uvc_video_clock_decode(struct uvc_streaming *stream, struct uvc_buffer *buf,
 	stream->clock.last_sof = dev_sof;
 
 	host_sof = usb_get_current_frame_number(stream->dev->udev);
-	ktime_get_ts(&ts);
+	uvc_video_get_ts(&ts);
 
 	/* The UVC specification allows device implementations that can't obtain
 	 * the USB frame number to keep their own frame counters as long as they
@@ -1010,10 +1018,7 @@ static int uvc_video_decode_start(struct uvc_streaming *stream,
 			return -ENODATA;
 		}
 
-		if (uvc_clock_param == CLOCK_MONOTONIC)
-			ktime_get_ts(&ts);
-		else
-			ktime_get_real_ts(&ts);
+		uvc_video_get_ts(&ts);
 
 		buf->buf.v4l2_buf.sequence = stream->sequence;
 		buf->buf.v4l2_buf.timestamp.tv_sec = ts.tv_sec;
-- 
1.9.1


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

* [PATCH 3.8 027/116] [media] ivtv: Fix Oops when no firmware is loaded
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (25 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 026/116] [media] uvcvideo: Fix clock param realtime setting Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 028/116] iio:adc:max1363 incorrect resolutions for max11604, max11605, max11610 and max11611 Kamal Mostafa
                   ` (88 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Takashi Iwai, Hans Verkuil, Mauro Carvalho Chehab, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Takashi Iwai <tiwai@suse.de>

commit deb29e90221a6d4417aa67be971613c353180331 upstream.

When ivtv PCM device is accessed at the state where no firmware is
loaded, it oopses like:

  BUG: unable to handle kernel NULL pointer dereference at 0000000000000050
  IP: [<ffffffffa049a881>] try_mailbox.isra.0+0x11/0x50 [ivtv]
  Call Trace:
    [<ffffffffa049aa20>] ivtv_api_call+0x160/0x6b0 [ivtv]
    [<ffffffffa049af86>] ivtv_api+0x16/0x40 [ivtv]
    [<ffffffffa049b10c>] ivtv_vapi+0xac/0xc0 [ivtv]
    [<ffffffffa049d40d>] ivtv_start_v4l2_encode_stream+0x19d/0x630 [ivtv]
    [<ffffffffa0530653>] snd_ivtv_pcm_capture_open+0x173/0x1c0 [ivtv_alsa]
    [<ffffffffa04526f1>] snd_pcm_open_substream+0x51/0x100 [snd_pcm]
    [<ffffffffa0452853>] snd_pcm_open+0xb3/0x260 [snd_pcm]
    [<ffffffffa0452a37>] snd_pcm_capture_open+0x37/0x50 [snd_pcm]
    [<ffffffffa033f557>] snd_open+0xa7/0x1e0 [snd]
    [<ffffffff8118a628>] chrdev_open+0x88/0x1d0
    [<ffffffff811840be>] do_dentry_open+0x1de/0x270
    [<ffffffff81193a73>] do_last+0x1c3/0xec0
    [<ffffffff81194826>] path_openat+0xb6/0x670
    [<ffffffff81195b65>] do_filp_open+0x35/0x80
    [<ffffffff81185449>] do_sys_open+0x129/0x210
    [<ffffffff815b782d>] system_call_fastpath+0x1a/0x1f

This patch adds the check of firmware at PCM open callback like other
open callbacks of this driver.

Bugzilla: https://apibugzilla.novell.com/show_bug.cgi?id=875440

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/media/pci/ivtv/ivtv-alsa-pcm.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/media/pci/ivtv/ivtv-alsa-pcm.c b/drivers/media/pci/ivtv/ivtv-alsa-pcm.c
index e1863db..7a9b98b 100644
--- a/drivers/media/pci/ivtv/ivtv-alsa-pcm.c
+++ b/drivers/media/pci/ivtv/ivtv-alsa-pcm.c
@@ -159,6 +159,12 @@ static int snd_ivtv_pcm_capture_open(struct snd_pcm_substream *substream)
 
 	/* Instruct the CX2341[56] to start sending packets */
 	snd_ivtv_lock(itvsc);
+
+	if (ivtv_init_on_first_open(itv)) {
+		snd_ivtv_unlock(itvsc);
+		return -ENXIO;
+	}
+
 	s = &itv->streams[IVTV_ENC_STREAM_TYPE_PCM];
 
 	v4l2_fh_init(&item.fh, s->vdev);
-- 
1.9.1


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

* [PATCH 3.8 028/116] iio:adc:max1363 incorrect resolutions for max11604, max11605, max11610 and max11611.
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (26 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 027/116] [media] ivtv: Fix Oops when no firmware is loaded Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 029/116] MIPS: DTS: Fix missing device_type="memory" property in memory nodes Kamal Mostafa
                   ` (87 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Jonathan Cameron, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Jonathan Cameron <jic23@kernel.org>

commit a91a73c8b39a6b8bcc53fafa5372c65387c81233 upstream.

Reported-by: Erik Habbinga <Erik.Habbinga@schneider-electric.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Acked-by: Hartmut Knaack <knaack.h@gmx.de>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/iio/adc/max1363.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/adc/max1363.c b/drivers/iio/adc/max1363.c
index 03b25b3..96670f9 100644
--- a/drivers/iio/adc/max1363.c
+++ b/drivers/iio/adc/max1363.c
@@ -1211,8 +1211,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = {
 		.num_modes = ARRAY_SIZE(max1238_mode_list),
 		.default_mode = s0to11,
 		.info = &max1238_info,
-		.channels = max1238_channels,
-		.num_channels = ARRAY_SIZE(max1238_channels),
+		.channels = max1038_channels,
+		.num_channels = ARRAY_SIZE(max1038_channels),
 	},
 	[max11605] = {
 		.bits = 8,
@@ -1221,8 +1221,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = {
 		.num_modes = ARRAY_SIZE(max1238_mode_list),
 		.default_mode = s0to11,
 		.info = &max1238_info,
-		.channels = max1238_channels,
-		.num_channels = ARRAY_SIZE(max1238_channels),
+		.channels = max1038_channels,
+		.num_channels = ARRAY_SIZE(max1038_channels),
 	},
 	[max11606] = {
 		.bits = 10,
@@ -1271,8 +1271,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = {
 		.num_modes = ARRAY_SIZE(max1238_mode_list),
 		.default_mode = s0to11,
 		.info = &max1238_info,
-		.channels = max1238_channels,
-		.num_channels = ARRAY_SIZE(max1238_channels),
+		.channels = max1138_channels,
+		.num_channels = ARRAY_SIZE(max1138_channels),
 	},
 	[max11611] = {
 		.bits = 10,
@@ -1281,8 +1281,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = {
 		.num_modes = ARRAY_SIZE(max1238_mode_list),
 		.default_mode = s0to11,
 		.info = &max1238_info,
-		.channels = max1238_channels,
-		.num_channels = ARRAY_SIZE(max1238_channels),
+		.channels = max1138_channels,
+		.num_channels = ARRAY_SIZE(max1138_channels),
 	},
 	[max11612] = {
 		.bits = 12,
-- 
1.9.1


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

* [PATCH 3.8 029/116] MIPS: DTS: Fix missing device_type="memory" property in memory nodes
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (27 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 028/116] iio:adc:max1363 incorrect resolutions for max11604, max11605, max11610 and max11611 Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 030/116] mac80211: fix IBSS join by initializing last_scan_completed Kamal Mostafa
                   ` (86 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Leif Lindholm, Grant Likely, linux-mips, devicetree,
	Mark Rutland, gaurav.minocha, Ralf Baechle, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Leif Lindholm <leif.lindholm@linaro.org>

commit 1d530fa42a317deca1c4a4780d18e2dbf316e0cb upstream.

A few platforms lack a 'device_type = "memory"' for their memory
nodes, relying on an old ppc quirk in order to discover its memory.
Add the missing data so that all parsing code can find memory nodes
correctly.

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
Acked-by: John Crispin <blogic@openwrt.org>
Signed-off-by: Grant Likely <grant.likely@linaro.org>
Cc: linux-mips@linux-mips.org
Cc: devicetree@vger.kernel.org
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: gaurav.minocha@alumni.ubc.ca
Patchwork: https://patchwork.linux-mips.org/patch/6989/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
[ kamal: backport to 3.8-stable: only lantiq/dts/easy50712.dts ]
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 arch/mips/lantiq/dts/easy50712.dts | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/mips/lantiq/dts/easy50712.dts b/arch/mips/lantiq/dts/easy50712.dts
index 68c1731..de53a1b 100644
--- a/arch/mips/lantiq/dts/easy50712.dts
+++ b/arch/mips/lantiq/dts/easy50712.dts
@@ -8,6 +8,7 @@
 	};
 
 	memory@0 {
+		device_type = "memory";
 		reg = <0x0 0x2000000>;
 	};
 
-- 
1.9.1


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

* [PATCH 3.8 030/116] mac80211: fix IBSS join by initializing last_scan_completed
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (28 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 029/116] MIPS: DTS: Fix missing device_type="memory" property in memory nodes Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 031/116] ahci: add PCI ID for Marvell 88SE91A0 SATA Controller Kamal Mostafa
                   ` (85 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Krzysztof Hałasa, Johannes Berg, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: =?UTF-8?q?Krzysztof=20Ha=C5=82asa?= <khalasa@piap.pl>

commit c7d37a66e345df2fdf1aa7b2c9a6d3d53846ca5b upstream.

Without this fix, freshly rebooted Linux creates a new IBSS
instead of joining an existing one. Only when jiffies counter
overflows after 5 minutes the IBSS can be successfully joined.

Signed-off-by: Krzysztof Hałasa <khalasa@piap.pl>
[edit commit message slightly]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 net/mac80211/ibss.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c
index 217064a..808628a 100644
--- a/net/mac80211/ibss.c
+++ b/net/mac80211/ibss.c
@@ -1091,6 +1091,7 @@ int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata,
 	sdata->u.ibss.privacy = params->privacy;
 	sdata->u.ibss.control_port = params->control_port;
 	sdata->u.ibss.basic_rates = params->basic_rates;
+	sdata->u.ibss.last_scan_completed = jiffies;
 	memcpy(sdata->vif.bss_conf.mcast_rate, params->mcast_rate,
 	       sizeof(params->mcast_rate));
 
-- 
1.9.1


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

* [PATCH 3.8 031/116] ahci: add PCI ID for Marvell 88SE91A0 SATA Controller
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (29 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 030/116] mac80211: fix IBSS join by initializing last_scan_completed Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 032/116] ext4: fix zeroing of page during writeback Kamal Mostafa
                   ` (84 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Andreas Schrägle, Tejun Heo, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: =?UTF-8?q?Andreas=20Schr=C3=A4gle?= <ajs124.ajs124@gmail.com>

commit 754a292fe6b08196cb135c03b404444e17de520a upstream.

Add support for Marvell Technology Group Ltd. 88SE91A0 SATA 6Gb/s
Controller by adding its PCI ID.

Signed-off-by: Andreas Schrägle <ajs124.ajs124@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
[ kamal: backport to 3.8-stable ]
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/ata/ahci.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index f0faa0d..c752e6f 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -440,6 +440,8 @@ static const struct pci_device_id ahci_pci_tbl[] = {
 	  .driver_data = board_ahci_yes_fbs },			/* 88se9172 */
 	{ PCI_DEVICE(0x1b4b, 0x9192),
 	  .driver_data = board_ahci_yes_fbs },			/* 88se9172 on some Gigabyte */
+	{ PCI_DEVICE(0x1b4b, 0x91a0),
+	  .driver_data = board_ahci_yes_fbs },
 	{ PCI_DEVICE(0x1b4b, 0x91a3),
 	  .driver_data = board_ahci_yes_fbs },
 	{ PCI_DEVICE(0x1b4b, 0x9230),
-- 
1.9.1


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

* [PATCH 3.8 032/116] ext4: fix zeroing of page during writeback
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (30 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 031/116] ahci: add PCI ID for Marvell 88SE91A0 SATA Controller Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 033/116] ext4: fix wrong assert in ext4_mb_normalize_request() Kamal Mostafa
                   ` (83 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Jan Kara, Theodore Ts'o, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Jan Kara <jack@suse.cz>

commit eeece469dedadf3918bad50ad80f4616a0064e90 upstream.

Tail of a page straddling inode size must be zeroed when being written
out due to POSIX requirement that modifications of mmaped page beyond
inode size must not be written to the file. ext4_bio_write_page() did
this only for blocks fully beyond inode size but didn't properly zero
blocks partially beyond inode size. Fix this.

The problem has been uncovered by mmap_11-4 test in openposix test suite
(part of LTP).

Reported-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
Fixes: 5a0dc7365c240
Fixes: bd2d0210cf22f
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 fs/ext4/page-io.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c
index 311d1db..a30ef89 100644
--- a/fs/ext4/page-io.c
+++ b/fs/ext4/page-io.c
@@ -446,24 +446,24 @@ int ext4_bio_write_page(struct ext4_io_submit *io,
 	set_page_writeback(page);
 	ClearPageError(page);
 
+	/*
+	 * Comments copied from block_write_full_page_endio:
+	 *
+	 * The page straddles i_size.  It must be zeroed out on each and every
+	 * writepage invocation because it may be mmapped.  "A file is mapped
+	 * in multiples of the page size.  For a file that is not a multiple of
+	 * the page size, the remaining memory is zeroed when mapped, and
+	 * writes to that region are not written out to the file."
+	 */
+	if (len < PAGE_CACHE_SIZE)
+		zero_user_segment(page, len, PAGE_CACHE_SIZE);
+
 	for (bh = head = page_buffers(page), block_start = 0;
 	     bh != head || !block_start;
 	     block_start = block_end, bh = bh->b_this_page) {
 
 		block_end = block_start + blocksize;
 		if (block_start >= len) {
-			/*
-			 * Comments copied from block_write_full_page_endio:
-			 *
-			 * The page straddles i_size.  It must be zeroed out on
-			 * each and every writepage invocation because it may
-			 * be mmapped.  "A file is mapped in multiples of the
-			 * page size.  For a file that is not a multiple of
-			 * the  page size, the remaining memory is zeroed when
-			 * mapped, and writes to that region are not written
-			 * out to the file."
-			 */
-			zero_user_segment(page, block_start, block_end);
 			clear_buffer_dirty(bh);
 			set_buffer_uptodate(bh);
 			continue;
-- 
1.9.1


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

* [PATCH 3.8 033/116] ext4: fix wrong assert in ext4_mb_normalize_request()
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (31 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 032/116] ext4: fix zeroing of page during writeback Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 034/116] IB/qib: Fix port in pkey change event Kamal Mostafa
                   ` (82 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Maurizio Lombardi, Theodore Ts'o, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Maurizio Lombardi <mlombard@redhat.com>

commit b5b60778558cafad17bbcbf63e0310bd3c68eb17 upstream.

The variable "size" is expressed as number of blocks and not as
number of clusters, this could trigger a kernel panic when using
ext4 with the size of a cluster different from the size of a block.

Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 fs/ext4/mballoc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 2167e90..a72f1c0 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -3030,7 +3030,7 @@ ext4_mb_normalize_request(struct ext4_allocation_context *ac,
 	}
 	BUG_ON(start + size <= ac->ac_o_ex.fe_logical &&
 			start > ac->ac_o_ex.fe_logical);
-	BUG_ON(size <= 0 || size > EXT4_CLUSTERS_PER_GROUP(ac->ac_sb));
+	BUG_ON(size <= 0 || size > EXT4_BLOCKS_PER_GROUP(ac->ac_sb));
 
 	/* now prepare goal request */
 
-- 
1.9.1


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

* [PATCH 3.8 034/116] IB/qib: Fix port in pkey change event
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (32 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 033/116] ext4: fix wrong assert in ext4_mb_normalize_request() Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 035/116] IB/ipath: Translate legacy diagpkt into newer extended diagpkt Kamal Mostafa
                   ` (81 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Mike Marciniszyn, Roland Dreier, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Mike Marciniszyn <mike.marciniszyn@intel.com>

commit 911eccd284d13d78c92ec4f1f1092c03457d732a upstream.

The code used a literal 1 in dispatching an IB_EVENT_PKEY_CHANGE.

As of the dual port qib QDR card, this is not necessarily correct.

Change to use the port as specified in the call.

Reported-by: Alex Estrin <alex.estrin@intel.com>
Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/infiniband/hw/qib/qib_mad.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/qib/qib_mad.c b/drivers/infiniband/hw/qib/qib_mad.c
index ccb1191..1dd9fcb 100644
--- a/drivers/infiniband/hw/qib/qib_mad.c
+++ b/drivers/infiniband/hw/qib/qib_mad.c
@@ -1028,7 +1028,7 @@ static int set_pkeys(struct qib_devdata *dd, u8 port, u16 *pkeys)
 
 		event.event = IB_EVENT_PKEY_CHANGE;
 		event.device = &dd->verbs_dev.ibdev;
-		event.element.port_num = 1;
+		event.element.port_num = port;
 		ib_dispatch_event(&event);
 	}
 	return 0;
-- 
1.9.1


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

* [PATCH 3.8 035/116] IB/ipath: Translate legacy diagpkt into newer extended diagpkt
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (33 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 034/116] IB/qib: Fix port in pkey change event Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 036/116] uio: we cannot mmap unaligned page contents Kamal Mostafa
                   ` (80 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Dennis Dalessandro, Roland Dreier, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Dennis Dalessandro <dennis.dalessandro@intel.com>

commit 7e6d3e5c70f13874fb06e6b67696ed90ce79bd48 upstream.

This patch addresses an issue where the legacy diagpacket is sent in
from the user, but the driver operates on only the extended
diagpkt. This patch specifically initializes the extended diagpkt
based on the legacy packet.

Reported-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/infiniband/hw/ipath/ipath_diag.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/infiniband/hw/ipath/ipath_diag.c b/drivers/infiniband/hw/ipath/ipath_diag.c
index e2f9a51..45802e9 100644
--- a/drivers/infiniband/hw/ipath/ipath_diag.c
+++ b/drivers/infiniband/hw/ipath/ipath_diag.c
@@ -346,6 +346,10 @@ static ssize_t ipath_diagpkt_write(struct file *fp,
 			ret = -EFAULT;
 			goto bail;
 		}
+		dp.len = odp.len;
+		dp.unit = odp.unit;
+		dp.data = odp.data;
+		dp.pbc_wd = 0;
 	} else {
 		ret = -EINVAL;
 		goto bail;
-- 
1.9.1


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

* [PATCH 3.8 036/116] uio: we cannot mmap unaligned page contents
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (34 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 035/116] IB/ipath: Translate legacy diagpkt into newer extended diagpkt Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 037/116] uio: fix vma io range check in mmap Kamal Mostafa
                   ` (79 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Linus Torvalds, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Linus Torvalds <torvalds@linux-foundation.org>

commit b65502879556d041b45104c6a35abbbba28c8f2d upstream.

In commit 7314e613d5ff ("Fix a few incorrectly checked
[io_]remap_pfn_range() calls") the uio driver started more properly
checking the passed-in user mapping arguments against the size of the
actual uio driver data.

That in turn exposed that some driver authors apparently didn't realize
that mmap can only work on a page granularity, and had tried to use it
with smaller mappings, with the new size check catching that out.

So since it's not just the user mmap() arguments that can be confused,
make the uio mmap code also verify that the uio driver has the memory
allocated at page boundaries in order for mmap to work.  If the device
memory isn't properly aligned, we return

  [ENODEV]
    The fildes argument refers to a file whose type is not supported by mmap().

as per the open group documentation on mmap.

Reported-by: Holger Brunck <holger.brunck@keymile.com>
Acked-by: Greg KH <gregkh@linuxfoundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/uio/uio.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index 96f1359..9981b9b 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -655,6 +655,8 @@ static int uio_mmap_physical(struct vm_area_struct *vma)
 		return -EINVAL;
 	mem = idev->info->mem + mi;
 
+	if (mem->addr & ~PAGE_MASK)
+		return -ENODEV;
 	if (vma->vm_end - vma->vm_start > mem->size)
 		return -EINVAL;
 
-- 
1.9.1


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

* [PATCH 3.8 037/116] uio: fix vma io range check in mmap
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (35 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 036/116] uio: we cannot mmap unaligned page contents Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 038/116] usb: usbtest: fix unlink write error with pattern 1 Kamal Mostafa
                   ` (78 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Bin Wang, Nobuhiro Iwamatsu, Greg Kroah-Hartman, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Bin Wang <binw@marvell.com>

commit ddb09754e6c7239e302c7b675df9bbd415f8de5d upstream.

the vma range size is always page size aligned in mmap, while the
real io space range may not be page aligned, thus leading to range
check failure in the uio_mmap_physical().

for example, in a case of io range size "mem->size == 1KB", and we
have (vma->vm_end - vma->vm_start) == 4KB, due to "len" is aligned
to page size in do_mmap_pgoff().

now fix this issue by align mem->size to page size in the check.

Signed-off-by: Bin Wang <binw@marvell.com>
Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/uio/uio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index 9981b9b..354c095 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -657,7 +657,7 @@ static int uio_mmap_physical(struct vm_area_struct *vma)
 
 	if (mem->addr & ~PAGE_MASK)
 		return -ENODEV;
-	if (vma->vm_end - vma->vm_start > mem->size)
+	if (vma->vm_end - vma->vm_start > PAGE_ALIGN(mem->size))
 		return -EINVAL;
 
 	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
-- 
1.9.1


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

* [PATCH 3.8 038/116] usb: usbtest: fix unlink write error with pattern 1
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (36 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 037/116] uio: fix vma io range check in mmap Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 039/116] s390/lowcore: reserve 96 bytes for IRB in lowcore Kamal Mostafa
                   ` (77 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Huang Rui, Greg Kroah-Hartman, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Huang Rui <ray.huang@amd.com>

commit e4d58f5dcb7d7be45df8def31881ebfae99c75da upstream.

TEST 12 and TEST 24 unlinks the URB write request for N times. When
host and gadget both initialize pattern 1 (mod 63) data series to
transfer, the gadget side will complain the wrong data which is not
expected.  Because in host side, usbtest doesn't fill the data buffer
as mod 63 and this patch fixed it.

[20285.488974] dwc3 dwc3.0.auto: ep1out-bulk: Transfer Not Ready
[20285.489181] dwc3 dwc3.0.auto: ep1out-bulk: reason Transfer Not Active
[20285.489423] dwc3 dwc3.0.auto: ep1out-bulk: req ffff8800aa6cb480 dma aeb50800 length 512 last
[20285.489727] dwc3 dwc3.0.auto: ep1out-bulk: cmd 'Start Transfer' params 00000000 a9eaf000 00000000
[20285.490055] dwc3 dwc3.0.auto: Command Complete --> 0
[20285.490281] dwc3 dwc3.0.auto: ep1out-bulk: Transfer Not Ready
[20285.490492] dwc3 dwc3.0.auto: ep1out-bulk: reason Transfer Active
[20285.490713] dwc3 dwc3.0.auto: ep1out-bulk: endpoint busy
[20285.490909] dwc3 dwc3.0.auto: ep1out-bulk: Transfer Complete
[20285.491117] dwc3 dwc3.0.auto: request ffff8800aa6cb480 from ep1out-bulk completed 512/512 ===> 0
[20285.491431] zero gadget: bad OUT byte, buf[1] = 0
[20285.491605] dwc3 dwc3.0.auto: ep1out-bulk: cmd 'Set Stall' params 00000000 00000000 00000000
[20285.491915] dwc3 dwc3.0.auto: Command Complete --> 0
[20285.492099] dwc3 dwc3.0.auto: queing request ffff8800aa6cb480 to ep1out-bulk length 512
[20285.492387] dwc3 dwc3.0.auto: ep1out-bulk: Transfer Not Ready
[20285.492595] dwc3 dwc3.0.auto: ep1out-bulk: reason Transfer Not Active
[20285.492830] dwc3 dwc3.0.auto: ep1out-bulk: req ffff8800aa6cb480 dma aeb51000 length 512 last
[20285.493135] dwc3 dwc3.0.auto: ep1out-bulk: cmd 'Start Transfer' params 00000000 a9eaf000 00000000
[20285.493465] dwc3 dwc3.0.auto: Command Complete --> 0

Signed-off-by: Huang Rui <ray.huang@amd.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/usb/misc/usbtest.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index 268148d..66cf0c5 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -1138,6 +1138,11 @@ static int unlink1(struct usbtest_dev *dev, int pipe, int size, int async)
 	urb->context = &completion;
 	urb->complete = unlink1_callback;
 
+	if (usb_pipeout(urb->pipe)) {
+		simple_fill_buf(urb);
+		urb->transfer_flags |= URB_ZERO_PACKET;
+	}
+
 	/* keep the endpoint busy.  there are lots of hc/hcd-internal
 	 * states, and testing should get to all of them over time.
 	 *
@@ -1268,6 +1273,11 @@ static int unlink_queued(struct usbtest_dev *dev, int pipe, unsigned num,
 				unlink_queued_callback, &ctx);
 		ctx.urbs[i]->transfer_dma = buf_dma;
 		ctx.urbs[i]->transfer_flags = URB_NO_TRANSFER_DMA_MAP;
+
+		if (usb_pipeout(ctx.urbs[i]->pipe)) {
+			simple_fill_buf(ctx.urbs[i]);
+			ctx.urbs[i]->transfer_flags |= URB_ZERO_PACKET;
+		}
 	}
 
 	/* Submit all the URBs and then unlink URBs num - 4 and num - 2. */
-- 
1.9.1


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

* [PATCH 3.8 039/116] s390/lowcore: reserve 96 bytes for IRB in lowcore
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (37 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 038/116] usb: usbtest: fix unlink write error with pattern 1 Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 040/116] mac80211: don't check netdev state for debugfs read/write Kamal Mostafa
                   ` (76 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Christian Borntraeger, Martin Schwidefsky, Heiko Carstens,
	Sebastian Ott, Cornelia Huck, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Christian Borntraeger <borntraeger@de.ibm.com>

commit 993072ee67aa179c48c85eb19869804e68887d86 upstream.

The IRB might be 96 bytes if the extended-I/O-measurement facility is
used. This feature is currently not used by Linux, but struct irb
already has the emw defined. So let's make the irb in lowcore match the
size of the internal data structure to be future proof.
We also have to add a pad, to correctly align the paste.

The bigger irb field also circumvents a bug in some QEMU versions that
always write the emw field on test subchannel and therefore destroy the
paste definitions of this CPU. Running under these QEMU version broke
some timing functions in the VDSO and all users of these functions,
e.g. some JREs.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Sebastian Ott <sebott@linux.vnet.ibm.com>
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 arch/s390/include/asm/lowcore.h | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/arch/s390/include/asm/lowcore.h b/arch/s390/include/asm/lowcore.h
index bbf8141..2bed4f0 100644
--- a/arch/s390/include/asm/lowcore.h
+++ b/arch/s390/include/asm/lowcore.h
@@ -142,9 +142,9 @@ struct _lowcore {
 	__u8	pad_0x02fc[0x0300-0x02fc];	/* 0x02fc */
 
 	/* Interrupt response block */
-	__u8	irb[64];			/* 0x0300 */
+	__u8	irb[96];			/* 0x0300 */
 
-	__u8	pad_0x0340[0x0e00-0x0340];	/* 0x0340 */
+	__u8	pad_0x0360[0x0e00-0x0360];	/* 0x0360 */
 
 	/*
 	 * 0xe00 contains the address of the IPL Parameter Information
@@ -288,12 +288,13 @@ struct _lowcore {
 	__u8	pad_0x03a0[0x0400-0x03a0];	/* 0x03a0 */
 
 	/* Interrupt response block. */
-	__u8	irb[64];			/* 0x0400 */
+	__u8	irb[96];			/* 0x0400 */
+	__u8	pad_0x0460[0x0480-0x0460];	/* 0x0460 */
 
 	/* Per cpu primary space access list */
-	__u32	paste[16];			/* 0x0440 */
+	__u32	paste[16];			/* 0x0480 */
 
-	__u8	pad_0x0480[0x0e00-0x0480];	/* 0x0480 */
+	__u8	pad_0x04c0[0x0e00-0x04c0];	/* 0x04c0 */
 
 	/*
 	 * 0xe00 contains the address of the IPL Parameter Information
-- 
1.9.1


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

* [PATCH 3.8 040/116] mac80211: don't check netdev state for debugfs read/write
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (38 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 039/116] s390/lowcore: reserve 96 bytes for IRB in lowcore Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 041/116] usb: qcserial: add Netgear AirCard 341U Kamal Mostafa
                   ` (75 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Arik Nemtsov, Emmanuel Grumbach, Johannes Berg, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Arik Nemtsov <arik@wizery.com>

commit 923eaf367206e01f22c97aee22300e332d071916 upstream.

Doing so will lead to an oops for a p2p-dev interface, since it has
no netdev.

Signed-off-by: Arik Nemtsov <arikx.nemtsov@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 net/mac80211/debugfs_netdev.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c
index cbde5cc..8736537 100644
--- a/net/mac80211/debugfs_netdev.c
+++ b/net/mac80211/debugfs_netdev.c
@@ -34,8 +34,7 @@ static ssize_t ieee80211_if_read(
 	ssize_t ret = -EINVAL;
 
 	read_lock(&dev_base_lock);
-	if (sdata->dev->reg_state == NETREG_REGISTERED)
-		ret = (*format)(sdata, buf, sizeof(buf));
+	ret = (*format)(sdata, buf, sizeof(buf));
 	read_unlock(&dev_base_lock);
 
 	if (ret >= 0)
@@ -62,8 +61,7 @@ static ssize_t ieee80211_if_write(
 
 	ret = -ENODEV;
 	rtnl_lock();
-	if (sdata->dev->reg_state == NETREG_REGISTERED)
-		ret = (*write)(sdata, buf, count);
+	ret = (*write)(sdata, buf, count);
 	rtnl_unlock();
 
 	return ret;
-- 
1.9.1


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

* [PATCH 3.8 041/116] usb: qcserial: add Netgear AirCard 341U
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (39 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 040/116] mac80211: don't check netdev state for debugfs read/write Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 042/116] usb: qcserial: add additional Sierra Wireless QMI devices Kamal Mostafa
                   ` (74 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Aleksander Morgado, Greg Kroah-Hartman, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Aleksander Morgado <aleksander@aleksander.es>

commit ff1fcd50bc2459744e6f948310bc18eb7d6e8c72 upstream.

Signed-off-by: Aleksander Morgado <aleksander@aleksander.es>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[ Aleksander: backport to 3.13-stable ]
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/usb/serial/qcserial.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/serial/qcserial.c b/drivers/usb/serial/qcserial.c
index 6c0a542..781e4db 100644
--- a/drivers/usb/serial/qcserial.c
+++ b/drivers/usb/serial/qcserial.c
@@ -151,6 +151,9 @@ static const struct usb_device_id id_table[] = {
 	{USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9051, 0)},	/* Netgear AirCard 340U Device Management */
 	{USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9051, 2)},	/* Netgear AirCard 340U NMEA */
 	{USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9051, 3)},	/* Netgear AirCard 340U Modem */
+	{USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9055, 0)},	/* Netgear AirCard 341U Device Management */
+	{USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9055, 2)},	/* Netgear AirCard 341U NMEA */
+	{USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9055, 3)},	/* Netgear AirCard 341U Modem */
 	{USB_DEVICE_INTERFACE_NUMBER(0x413c, 0x81a2, 0)},	/* Dell Wireless 5806 Gobi(TM) 4G LTE Mobile Broadband Card Device Management */
 	{USB_DEVICE_INTERFACE_NUMBER(0x413c, 0x81a2, 2)},	/* Dell Wireless 5806 Gobi(TM) 4G LTE Mobile Broadband Card NMEA */
 	{USB_DEVICE_INTERFACE_NUMBER(0x413c, 0x81a2, 3)},	/* Dell Wireless 5806 Gobi(TM) 4G LTE Mobile Broadband Card Modem */
-- 
1.9.1


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

* [PATCH 3.8 042/116] usb: qcserial: add additional Sierra Wireless QMI devices
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (40 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 041/116] usb: qcserial: add Netgear AirCard 341U Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 043/116] IB/umad: Fix error handling Kamal Mostafa
                   ` (73 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Aleksander Morgado, Johan Hovold, Greg Kroah-Hartman, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Aleksander Morgado <aleksander@aleksander.es>

commit 0ce5fb58564fd85aa8fd2d24209900e2e845317b upstream.

A set of new VID/PIDs retrieved from the out-of-tree GobiNet/GobiSerial
Sierra Wireless drivers.

Signed-off-by: Aleksander Morgado <aleksander@aleksander.es>
Link: http://marc.info/?l=linux-usb&m=140136310027293&w=2
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[ Aleksander: backport to 3.13-stable ]
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/usb/serial/qcserial.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/usb/serial/qcserial.c b/drivers/usb/serial/qcserial.c
index 781e4db..43d93db 100644
--- a/drivers/usb/serial/qcserial.c
+++ b/drivers/usb/serial/qcserial.c
@@ -145,15 +145,33 @@ static const struct usb_device_id id_table[] = {
 	{USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x901f, 0)},	/* Sierra Wireless EM7355 Device Management */
 	{USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x901f, 2)},	/* Sierra Wireless EM7355 NMEA */
 	{USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x901f, 3)},	/* Sierra Wireless EM7355 Modem */
+	{USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9040, 0)},	/* Sierra Wireless Modem Device Management */
+	{USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9040, 2)},	/* Sierra Wireless Modem NMEA */
+	{USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9040, 3)},	/* Sierra Wireless Modem Modem */
 	{USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9041, 0)},	/* Sierra Wireless MC7305/MC7355 Device Management */
 	{USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9041, 2)},	/* Sierra Wireless MC7305/MC7355 NMEA */
 	{USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9041, 3)},	/* Sierra Wireless MC7305/MC7355 Modem */
 	{USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9051, 0)},	/* Netgear AirCard 340U Device Management */
 	{USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9051, 2)},	/* Netgear AirCard 340U NMEA */
 	{USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9051, 3)},	/* Netgear AirCard 340U Modem */
+	{USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9053, 0)},	/* Sierra Wireless Modem Device Management */
+	{USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9053, 2)},	/* Sierra Wireless Modem NMEA */
+	{USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9053, 3)},	/* Sierra Wireless Modem Modem */
+	{USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9054, 0)},	/* Sierra Wireless Modem Device Management */
+	{USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9054, 2)},	/* Sierra Wireless Modem NMEA */
+	{USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9054, 3)},	/* Sierra Wireless Modem Modem */
 	{USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9055, 0)},	/* Netgear AirCard 341U Device Management */
 	{USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9055, 2)},	/* Netgear AirCard 341U NMEA */
 	{USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9055, 3)},	/* Netgear AirCard 341U Modem */
+	{USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9056, 0)},	/* Sierra Wireless Modem Device Management */
+	{USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9056, 2)},	/* Sierra Wireless Modem NMEA */
+	{USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9056, 3)},	/* Sierra Wireless Modem Modem */
+	{USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9060, 0)},	/* Sierra Wireless Modem Device Management */
+	{USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9060, 2)},	/* Sierra Wireless Modem NMEA */
+	{USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9060, 3)},	/* Sierra Wireless Modem Modem */
+	{USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9061, 0)},	/* Sierra Wireless Modem Device Management */
+	{USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9061, 2)},	/* Sierra Wireless Modem NMEA */
+	{USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9061, 3)},	/* Sierra Wireless Modem Modem */
 	{USB_DEVICE_INTERFACE_NUMBER(0x413c, 0x81a2, 0)},	/* Dell Wireless 5806 Gobi(TM) 4G LTE Mobile Broadband Card Device Management */
 	{USB_DEVICE_INTERFACE_NUMBER(0x413c, 0x81a2, 2)},	/* Dell Wireless 5806 Gobi(TM) 4G LTE Mobile Broadband Card NMEA */
 	{USB_DEVICE_INTERFACE_NUMBER(0x413c, 0x81a2, 3)},	/* Dell Wireless 5806 Gobi(TM) 4G LTE Mobile Broadband Card Modem */
-- 
1.9.1


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

* [PATCH 3.8 043/116] IB/umad: Fix error handling
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (41 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 042/116] usb: qcserial: add additional Sierra Wireless QMI devices Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 044/116] RDMA/cxgb4: Add missing padding at end of struct c4iw_create_cq_resp Kamal Mostafa
                   ` (72 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Bart Van Assche, Yann Droneaud, Roland Dreier, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Bart Van Assche <bvanassche@acm.org>

commit 8ec0a0e6b58218bdc1db91dd70ebfcd6ad8dd6cd upstream.

Avoid leaking a kref count in ib_umad_open() if port->ib_dev == NULL
or if nonseekable_open() fails.

Avoid leaking a kref count, that sm_sem is kept down and also that the
IB_PORT_SM capability mask is not cleared in ib_umad_sm_open() if
nonseekable_open() fails.

Since container_of() never returns NULL, remove the code that tests
whether container_of() returns NULL.

Moving the kref_get() call from the start of ib_umad_*open() to the
end is safe since it is the responsibility of the caller of these
functions to ensure that the cdev pointer remains valid until at least
when these functions return.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>

[ydroneaud@opteya.com: rework a bit to reduce the amount of code changed]

Signed-off-by: Yann Droneaud <ydroneaud@opteya.com>

[ nonseekable_open() can't actually fail, but....  - Roland ]

Signed-off-by: Roland Dreier <roland@purestorage.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/infiniband/core/user_mad.c | 49 +++++++++++++++++++++-----------------
 1 file changed, 27 insertions(+), 22 deletions(-)

diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
index f0d588f..9bdf576 100644
--- a/drivers/infiniband/core/user_mad.c
+++ b/drivers/infiniband/core/user_mad.c
@@ -780,27 +780,19 @@ static int ib_umad_open(struct inode *inode, struct file *filp)
 {
 	struct ib_umad_port *port;
 	struct ib_umad_file *file;
-	int ret;
+	int ret = -ENXIO;
 
 	port = container_of(inode->i_cdev, struct ib_umad_port, cdev);
-	if (port)
-		kref_get(&port->umad_dev->ref);
-	else
-		return -ENXIO;
 
 	mutex_lock(&port->file_mutex);
 
-	if (!port->ib_dev) {
-		ret = -ENXIO;
+	if (!port->ib_dev)
 		goto out;
-	}
 
+	ret = -ENOMEM;
 	file = kzalloc(sizeof *file, GFP_KERNEL);
-	if (!file) {
-		kref_put(&port->umad_dev->ref, ib_umad_release_dev);
-		ret = -ENOMEM;
+	if (!file)
 		goto out;
-	}
 
 	mutex_init(&file->mutex);
 	spin_lock_init(&file->send_lock);
@@ -814,6 +806,13 @@ static int ib_umad_open(struct inode *inode, struct file *filp)
 	list_add_tail(&file->port_list, &port->file_list);
 
 	ret = nonseekable_open(inode, filp);
+	if (ret) {
+		list_del(&file->port_list);
+		kfree(file);
+		goto out;
+	}
+
+	kref_get(&port->umad_dev->ref);
 
 out:
 	mutex_unlock(&port->file_mutex);
@@ -880,10 +879,6 @@ static int ib_umad_sm_open(struct inode *inode, struct file *filp)
 	int ret;
 
 	port = container_of(inode->i_cdev, struct ib_umad_port, sm_cdev);
-	if (port)
-		kref_get(&port->umad_dev->ref);
-	else
-		return -ENXIO;
 
 	if (filp->f_flags & O_NONBLOCK) {
 		if (down_trylock(&port->sm_sem)) {
@@ -898,17 +893,27 @@ static int ib_umad_sm_open(struct inode *inode, struct file *filp)
 	}
 
 	ret = ib_modify_port(port->ib_dev, port->port_num, 0, &props);
-	if (ret) {
-		up(&port->sm_sem);
-		goto fail;
-	}
+	if (ret)
+		goto err_up_sem;
 
 	filp->private_data = port;
 
-	return nonseekable_open(inode, filp);
+	ret = nonseekable_open(inode, filp);
+	if (ret)
+		goto err_clr_sm_cap;
+
+	kref_get(&port->umad_dev->ref);
+
+	return 0;
+
+err_clr_sm_cap:
+	swap(props.set_port_cap_mask, props.clr_port_cap_mask);
+	ib_modify_port(port->ib_dev, port->port_num, 0, &props);
+
+err_up_sem:
+	up(&port->sm_sem);
 
 fail:
-	kref_put(&port->umad_dev->ref, ib_umad_release_dev);
 	return ret;
 }
 
-- 
1.9.1


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

* [PATCH 3.8 044/116] RDMA/cxgb4: Add missing padding at end of struct c4iw_create_cq_resp
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (42 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 043/116] IB/umad: Fix error handling Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 045/116] nfsd: getattr for FATTR4_WORD0_FILES_AVAIL needs the statfs buffer Kamal Mostafa
                   ` (71 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Dan Carpenter, Yann Droneaud, Roland Dreier, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Yann Droneaud <ydroneaud@opteya.com>

commit b6f04d3d21458818073a2f5af5339f958864bf71 upstream.

The i386 ABI disagrees with most other ABIs regarding alignment of
data types larger than 4 bytes: on most ABIs a padding must be added
at end of the structures, while it is not required on i386.

So for most ABI struct c4iw_create_cq_resp gets implicitly padded
to be aligned on a 8 bytes multiple, while for i386, such padding
is not added.

The tool pahole can be used to find such implicit padding:

  $ pahole --anon_include \
           --nested_anon_include \
           --recursive \
           --class_name c4iw_create_cq_resp \
           drivers/infiniband/hw/cxgb4/iw_cxgb4.o

Then, structure layout can be compared between i386 and x86_64:

  +++ obj-i386/drivers/infiniband/hw/cxgb4/iw_cxgb4.o.pahole.txt   2014-03-28 11:43:05.547432195 +0100
  --- obj-x86_64/drivers/infiniband/hw/cxgb4/iw_cxgb4.o.pahole.txt 2014-03-28 10:55:10.990133017 +0100
  @@ -14,9 +13,8 @@ struct c4iw_create_cq_resp {
          __u32                      size;                 /*    28     4 */
          __u32                      qid_mask;             /*    32     4 */

  -       /* size: 36, cachelines: 1, members: 6 */
  -       /* last cacheline: 36 bytes */
  +       /* size: 40, cachelines: 1, members: 6 */
  +       /* padding: 4 */
  +       /* last cacheline: 40 bytes */
   };

This ABI disagreement will make an x86_64 kernel try to write past the
buffer provided by an i386 binary.

When boundary check will be implemented, the x86_64 kernel will refuse
to write past the i386 userspace provided buffer and the uverbs will
fail.

If the structure is on a page boundary and the next page is not
mapped, ib_copy_to_udata() will fail and the uverb will fail.

This patch adds an explicit padding at end of structure
c4iw_create_cq_resp, and, like 92b0ca7cb149 ("IB/mlx5: Fix stack info
leak in mlx5_ib_alloc_ucontext()"), makes function c4iw_create_cq()
not writting this padding field to userspace. This way, x86_64 kernel
will be able to write struct c4iw_create_cq_resp as expected by
unpatched and patched i386 libcxgb4.

Link: http://marc.info/?i=cover.1399309513.git.ydroneaud@opteya.com
Fixes: cfdda9d764362 ("RDMA/cxgb4: Add driver for Chelsio T4 RNIC")
Fixes: e24a72a3302a6 ("RDMA/cxgb4: Fix four byte info leak in c4iw_create_cq()")
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Yann Droneaud <ydroneaud@opteya.com>
Acked-by: Steve Wise <swise@opengridcomputing.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/infiniband/hw/cxgb4/cq.c   | 3 ++-
 drivers/infiniband/hw/cxgb4/user.h | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/cxgb4/cq.c b/drivers/infiniband/hw/cxgb4/cq.c
index 0f1607c..3bd6b69 100644
--- a/drivers/infiniband/hw/cxgb4/cq.c
+++ b/drivers/infiniband/hw/cxgb4/cq.c
@@ -843,7 +843,8 @@ struct ib_cq *c4iw_create_cq(struct ib_device *ibdev, int entries,
 		uresp.gts_key = ucontext->key;
 		ucontext->key += PAGE_SIZE;
 		spin_unlock(&ucontext->mmap_lock);
-		ret = ib_copy_to_udata(udata, &uresp, sizeof uresp);
+		ret = ib_copy_to_udata(udata, &uresp,
+				       sizeof(uresp) - sizeof(uresp.reserved));
 		if (ret)
 			goto err5;
 
diff --git a/drivers/infiniband/hw/cxgb4/user.h b/drivers/infiniband/hw/cxgb4/user.h
index 32b754c..4893599 100644
--- a/drivers/infiniband/hw/cxgb4/user.h
+++ b/drivers/infiniband/hw/cxgb4/user.h
@@ -48,6 +48,7 @@ struct c4iw_create_cq_resp {
 	__u32 cqid;
 	__u32 size;
 	__u32 qid_mask;
+	__u32 reserved; /* explicit padding (optional for i386) */
 };
 
 
-- 
1.9.1


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

* [PATCH 3.8 045/116] nfsd: getattr for FATTR4_WORD0_FILES_AVAIL needs the statfs buffer
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (43 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 044/116] RDMA/cxgb4: Add missing padding at end of struct c4iw_create_cq_resp Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 046/116] UBIFS: Remove incorrect assertion in shrink_tnc() Kamal Mostafa
                   ` (70 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Christoph Hellwig, J. Bruce Fields, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Christoph Hellwig <hch@lst.de>

commit 12337901d654415d9f764b5f5ba50052e9700f37 upstream.

Note nobody's ever noticed because the typical client probably never
requests FILES_AVAIL without also requesting something else on the list.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 fs/nfsd/nfs4xdr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index dc12d02..562fab9 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -2048,8 +2048,8 @@ nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp,
 	err = vfs_getattr(exp->ex_path.mnt, dentry, &stat);
 	if (err)
 		goto out_nfserr;
-	if ((bmval0 & (FATTR4_WORD0_FILES_FREE | FATTR4_WORD0_FILES_TOTAL |
-			FATTR4_WORD0_MAXNAME)) ||
+	if ((bmval0 & (FATTR4_WORD0_FILES_AVAIL | FATTR4_WORD0_FILES_FREE |
+			FATTR4_WORD0_FILES_TOTAL | FATTR4_WORD0_MAXNAME)) ||
 	    (bmval1 & (FATTR4_WORD1_SPACE_AVAIL | FATTR4_WORD1_SPACE_FREE |
 		       FATTR4_WORD1_SPACE_TOTAL))) {
 		err = vfs_statfs(&path, &statfs);
-- 
1.9.1


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

* [PATCH 3.8 046/116] UBIFS: Remove incorrect assertion in shrink_tnc()
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (44 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 045/116] nfsd: getattr for FATTR4_WORD0_FILES_AVAIL needs the statfs buffer Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 047/116] Bluetooth: Fix L2CAP deadlock Kamal Mostafa
                   ` (69 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: hujianyang, Artem Bityutskiy, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: hujianyang <hujianyang@huawei.com>

commit 72abc8f4b4e8574318189886de627a2bfe6cd0da upstream.

I hit the same assert failed as Dolev Raviv reported in Kernel v3.10
shows like this:

[ 9641.164028] UBIFS assert failed in shrink_tnc at 131 (pid 13297)
[ 9641.234078] CPU: 1 PID: 13297 Comm: mmap.test Tainted: G           O 3.10.40 #1
[ 9641.234116] [<c0011a6c>] (unwind_backtrace+0x0/0x12c) from [<c000d0b0>] (show_stack+0x20/0x24)
[ 9641.234137] [<c000d0b0>] (show_stack+0x20/0x24) from [<c0311134>] (dump_stack+0x20/0x28)
[ 9641.234188] [<c0311134>] (dump_stack+0x20/0x28) from [<bf22425c>] (shrink_tnc_trees+0x25c/0x350 [ubifs])
[ 9641.234265] [<bf22425c>] (shrink_tnc_trees+0x25c/0x350 [ubifs]) from [<bf2245ac>] (ubifs_shrinker+0x25c/0x310 [ubifs])
[ 9641.234307] [<bf2245ac>] (ubifs_shrinker+0x25c/0x310 [ubifs]) from [<c00cdad8>] (shrink_slab+0x1d4/0x2f8)
[ 9641.234327] [<c00cdad8>] (shrink_slab+0x1d4/0x2f8) from [<c00d03d0>] (do_try_to_free_pages+0x300/0x544)
[ 9641.234344] [<c00d03d0>] (do_try_to_free_pages+0x300/0x544) from [<c00d0a44>] (try_to_free_pages+0x2d0/0x398)
[ 9641.234363] [<c00d0a44>] (try_to_free_pages+0x2d0/0x398) from [<c00c6a60>] (__alloc_pages_nodemask+0x494/0x7e8)
[ 9641.234382] [<c00c6a60>] (__alloc_pages_nodemask+0x494/0x7e8) from [<c00f62d8>] (new_slab+0x78/0x238)
[ 9641.234400] [<c00f62d8>] (new_slab+0x78/0x238) from [<c031081c>] (__slab_alloc.constprop.42+0x1a4/0x50c)
[ 9641.234419] [<c031081c>] (__slab_alloc.constprop.42+0x1a4/0x50c) from [<c00f80e8>] (kmem_cache_alloc_trace+0x54/0x188)
[ 9641.234459] [<c00f80e8>] (kmem_cache_alloc_trace+0x54/0x188) from [<bf227908>] (do_readpage+0x168/0x468 [ubifs])
[ 9641.234553] [<bf227908>] (do_readpage+0x168/0x468 [ubifs]) from [<bf2296a0>] (ubifs_readpage+0x424/0x464 [ubifs])
[ 9641.234606] [<bf2296a0>] (ubifs_readpage+0x424/0x464 [ubifs]) from [<c00c17c0>] (filemap_fault+0x304/0x418)
[ 9641.234638] [<c00c17c0>] (filemap_fault+0x304/0x418) from [<c00de694>] (__do_fault+0xd4/0x530)
[ 9641.234665] [<c00de694>] (__do_fault+0xd4/0x530) from [<c00e10c0>] (handle_pte_fault+0x480/0xf54)
[ 9641.234690] [<c00e10c0>] (handle_pte_fault+0x480/0xf54) from [<c00e2bf8>] (handle_mm_fault+0x140/0x184)
[ 9641.234716] [<c00e2bf8>] (handle_mm_fault+0x140/0x184) from [<c0316688>] (do_page_fault+0x150/0x3ac)
[ 9641.234737] [<c0316688>] (do_page_fault+0x150/0x3ac) from [<c000842c>] (do_DataAbort+0x3c/0xa0)
[ 9641.234759] [<c000842c>] (do_DataAbort+0x3c/0xa0) from [<c0314e38>] (__dabt_usr+0x38/0x40)

After analyzing the code, I found a condition that may cause this failed
in correct operations. Thus, I think this assertion is wrong and should be
removed.

Suppose there are two clean znodes and one dirty znode in TNC. So the
per-filesystem atomic_t @clean_zn_cnt is (2). If commit start, dirty_znode
is set to COW_ZNODE in get_znodes_to_commit() in case of potentially ops
on this znode. We clear COW bit and DIRTY bit in write_index() without
@tnc_mutex locked. We don't increase @clean_zn_cnt in this place. As the
comments in write_index() shows, if another process hold @tnc_mutex and
dirty this znode after we clean it, @clean_zn_cnt would be decreased to (1).
We will increase @clean_zn_cnt to (2) with @tnc_mutex locked in
free_obsolete_znodes() to keep it right.

If shrink_tnc() performs between decrease and increase, it will release
other 2 clean znodes it holds and found @clean_zn_cnt is less than zero
(1 - 2 = -1), then hit the assertion. Because free_obsolete_znodes() will
soon correct @clean_zn_cnt and no harm to fs in this case, I think this
assertion could be removed.

2 clean zondes and 1 dirty znode, @clean_zn_cnt == 2

Thread A (commit)         Thread B (write or others)       Thread C (shrinker)
->write_index
   ->clear_bit(DIRTY_NODE)
   ->clear_bit(COW_ZNODE)

            @clean_zn_cnt == 2
                          ->mutex_locked(&tnc_mutex)
                          ->dirty_cow_znode
                              ->!ubifs_zn_cow(znode)
                              ->!test_and_set_bit(DIRTY_NODE)
                              ->atomic_dec(&clean_zn_cnt)
                          ->mutex_unlocked(&tnc_mutex)

            @clean_zn_cnt == 1
                                                           ->mutex_locked(&tnc_mutex)
                                                           ->shrink_tnc
                                                             ->destroy_tnc_subtree
                                                             ->atomic_sub(&clean_zn_cnt, 2)
                                                             ->ubifs_assert  <- hit
                                                           ->mutex_unlocked(&tnc_mutex)

            @clean_zn_cnt == -1
->mutex_lock(&tnc_mutex)
->free_obsolete_znodes
   ->atomic_inc(&clean_zn_cnt)
->mutux_unlock(&tnc_mutex)

            @clean_zn_cnt == 0 (correct after shrink)

Signed-off-by: hujianyang <hujianyang@huawei.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 fs/ubifs/shrinker.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/ubifs/shrinker.c b/fs/ubifs/shrinker.c
index 9e1d056..e0a7a76 100644
--- a/fs/ubifs/shrinker.c
+++ b/fs/ubifs/shrinker.c
@@ -128,7 +128,6 @@ static int shrink_tnc(struct ubifs_info *c, int nr, int age, int *contention)
 			freed = ubifs_destroy_tnc_subtree(znode);
 			atomic_long_sub(freed, &ubifs_clean_zn_cnt);
 			atomic_long_sub(freed, &c->clean_zn_cnt);
-			ubifs_assert(atomic_long_read(&c->clean_zn_cnt) >= 0);
 			total_freed += freed;
 			znode = zprev;
 		}
-- 
1.9.1


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

* [PATCH 3.8 047/116] Bluetooth: Fix L2CAP deadlock
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (45 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 046/116] UBIFS: Remove incorrect assertion in shrink_tnc() Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:20 ` [PATCH 3.8 048/116] drm/radeon: fix typo in radeon_connector_is_dp12_capable() Kamal Mostafa
                   ` (68 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Jukka Taimisto, Johan Hedberg, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Jukka Taimisto <jtt@codenomicon.com>

commit 8a96f3cd22878fc0bb564a8478a6e17c0b8dca73 upstream.

-[0x01 Introduction

We have found a programming error causing a deadlock in Bluetooth subsystem
of Linux kernel. The problem is caused by missing release_sock() call when
L2CAP connection creation fails due full accept queue.

The issue can be reproduced with 3.15-rc5 kernel and is also present in
earlier kernels.

-[0x02 Details

The problem occurs when multiple L2CAP connections are created to a PSM which
contains listening socket (like SDP) and left pending, for example,
configuration (the underlying ACL link is not disconnected between
connections).

When L2CAP connection request is received and listening socket is found the
l2cap_sock_new_connection_cb() function (net/bluetooth/l2cap_sock.c) is called.
This function locks the 'parent' socket and then checks if the accept queue
is full.

1178         lock_sock(parent);
1179
1180         /* Check for backlog size */
1181         if (sk_acceptq_is_full(parent)) {
1182                 BT_DBG("backlog full %d", parent->sk_ack_backlog);
1183                 return NULL;
1184         }

If case the accept queue is full NULL is returned, but the 'parent' socket
is not released. Thus when next L2CAP connection request is received the code
blocks on lock_sock() since the parent is still locked.

Also note that for connections already established and waiting for
configuration to complete a timeout will occur and l2cap_chan_timeout()
(net/bluetooth/l2cap_core.c) will be called. All threads calling this
function will also be blocked waiting for the channel mutex since the thread
which is waiting on lock_sock() alread holds the channel mutex.

We were able to reproduce this by sending continuously L2CAP connection
request followed by disconnection request containing invalid CID. This left
the created connections pending configuration.

After the deadlock occurs it is impossible to kill bluetoothd, btmon will not
get any more data etc. requiring reboot to recover.

-[0x03 Fix

Releasing the 'parent' socket when l2cap_sock_new_connection_cb() returns NULL
seems to fix the issue.

Signed-off-by: Jukka Taimisto <jtt@codenomicon.com>
Reported-by: Tommi Mäkilä <tmakila@codenomicon.com>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 net/bluetooth/l2cap_sock.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 1bcfb84..59011c4 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -943,13 +943,16 @@ static struct l2cap_chan *l2cap_sock_new_connection_cb(struct l2cap_chan *chan)
 	/* Check for backlog size */
 	if (sk_acceptq_is_full(parent)) {
 		BT_DBG("backlog full %d", parent->sk_ack_backlog);
+		release_sock(parent);
 		return NULL;
 	}
 
 	sk = l2cap_sock_alloc(sock_net(parent), NULL, BTPROTO_L2CAP,
 			      GFP_ATOMIC);
-	if (!sk)
+	if (!sk) {
+		release_sock(parent);
 		return NULL;
+        }
 
 	bt_sock_reclassify_lock(sk, BTPROTO_L2CAP);
 
-- 
1.9.1


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

* [PATCH 3.8 048/116] drm/radeon: fix typo in radeon_connector_is_dp12_capable()
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (46 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 047/116] Bluetooth: Fix L2CAP deadlock Kamal Mostafa
@ 2014-07-22 22:20 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 049/116] drm/radeon/dp: fix lane/clock setup for dp 1.2 capable devices Kamal Mostafa
                   ` (67 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:20 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Alex Deucher, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Alex Deucher <alexander.deucher@amd.com>

commit af5d36539dfe043f1cf0f8b7334d6bb12cd14e75 upstream.

We were checking the ext clock rather than the display clock.

Noticed by ArtForz on IRC.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/gpu/drm/radeon/radeon_connectors.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
index 5a87c9f..fc604fc 100644
--- a/drivers/gpu/drm/radeon/radeon_connectors.c
+++ b/drivers/gpu/drm/radeon/radeon_connectors.c
@@ -1345,7 +1345,7 @@ bool radeon_connector_is_dp12_capable(struct drm_connector *connector)
 	struct radeon_device *rdev = dev->dev_private;
 
 	if (ASIC_IS_DCE5(rdev) &&
-	    (rdev->clock.dp_extclk >= 53900) &&
+	    (rdev->clock.default_dispclk >= 53900) &&
 	    radeon_connector_encoder_is_hbr2(connector)) {
 		return true;
 	}
-- 
1.9.1


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

* [PATCH 3.8 049/116] drm/radeon/dp: fix lane/clock setup for dp 1.2 capable devices
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (47 preceding siblings ...)
  2014-07-22 22:20 ` [PATCH 3.8 048/116] drm/radeon: fix typo in radeon_connector_is_dp12_capable() Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 050/116] drm/radeon/atom: fix dithering on certain panels Kamal Mostafa
                   ` (66 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Alex Deucher, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Alex Deucher <alexander.deucher@amd.com>

commit 3b6d9fd23e015b5397c438fd3cd74147d2c805b6 upstream.

Only DCE5+ asics support DP 1.2.

Noticed by ArtForz on IRC.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/gpu/drm/radeon/atombios_dp.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/radeon/atombios_dp.c b/drivers/gpu/drm/radeon/atombios_dp.c
index 1602398..4c05f2b 100644
--- a/drivers/gpu/drm/radeon/atombios_dp.c
+++ b/drivers/gpu/drm/radeon/atombios_dp.c
@@ -384,6 +384,19 @@ static int dp_get_max_dp_pix_clock(int link_rate,
 
 /***** radeon specific DP functions *****/
 
+static int radeon_dp_get_max_link_rate(struct drm_connector *connector,
+				       u8 dpcd[DP_DPCD_SIZE])
+{
+	int max_link_rate;
+
+	if (radeon_connector_is_dp12_capable(connector))
+		max_link_rate = min(drm_dp_max_link_rate(dpcd), 540000);
+	else
+		max_link_rate = min(drm_dp_max_link_rate(dpcd), 270000);
+
+	return max_link_rate;
+}
+
 /* First get the min lane# when low rate is used according to pixel clock
  * (prefer low rate), second check max lane# supported by DP panel,
  * if the max lane# < low rate lane# then use max lane# instead.
@@ -393,7 +406,7 @@ static int radeon_dp_get_dp_lane_number(struct drm_connector *connector,
 					int pix_clock)
 {
 	int bpp = convert_bpc_to_bpp(radeon_get_monitor_bpc(connector));
-	int max_link_rate = drm_dp_max_link_rate(dpcd);
+	int max_link_rate = radeon_dp_get_max_link_rate(connector, dpcd);
 	int max_lane_num = drm_dp_max_lane_count(dpcd);
 	int lane_num;
 	int max_dp_pix_clock;
@@ -431,7 +444,7 @@ static int radeon_dp_get_dp_link_clock(struct drm_connector *connector,
 			return 540000;
 	}
 
-	return drm_dp_max_link_rate(dpcd);
+	return radeon_dp_get_max_link_rate(connector, dpcd);
 }
 
 static u8 radeon_dp_encoder_service(struct radeon_device *rdev,
-- 
1.9.1


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

* [PATCH 3.8 050/116] drm/radeon/atom: fix dithering on certain panels
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (48 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 049/116] drm/radeon/dp: fix lane/clock setup for dp 1.2 capable devices Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 051/116] drm/radeon: only apply hdmi bpc pll flags when encoder mode is hdmi Kamal Mostafa
                   ` (65 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Alex Deucher, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Alex Deucher <alexander.deucher@amd.com>

commit 642528355c694f5ed68f6bff9ff520326a249f99 upstream.

We need to specify the encoder mode as LVDS for eDP
when using the Crtc_Source atom table in order to properly
set up the FMT hardware.

bug:
https://bugs.freedesktop.org/show_bug.cgi?id=73911

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/gpu/drm/radeon/atombios_encoders.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/radeon/atombios_encoders.c b/drivers/gpu/drm/radeon/atombios_encoders.c
index 71619b0..f04f3c9 100644
--- a/drivers/gpu/drm/radeon/atombios_encoders.c
+++ b/drivers/gpu/drm/radeon/atombios_encoders.c
@@ -1877,8 +1877,11 @@ atombios_set_encoder_crtc_source(struct drm_encoder *encoder)
 					args.v2.ucEncodeMode = ATOM_ENCODER_MODE_CRT;
 				else
 					args.v2.ucEncodeMode = atombios_get_encoder_mode(encoder);
-			} else
+			} else if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
+				args.v2.ucEncodeMode = ATOM_ENCODER_MODE_LVDS;
+			} else {
 				args.v2.ucEncodeMode = atombios_get_encoder_mode(encoder);
+			}
 			switch (radeon_encoder->encoder_id) {
 			case ENCODER_OBJECT_ID_INTERNAL_UNIPHY:
 			case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1:
-- 
1.9.1


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

* [PATCH 3.8 051/116] drm/radeon: only apply hdmi bpc pll flags when encoder mode is hdmi
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (49 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 050/116] drm/radeon/atom: fix dithering on certain panels Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 052/116] ahci: Add Device ID for HighPoint RocketRaid 642L Kamal Mostafa
                   ` (64 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Alex Deucher, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Alex Deucher <alexander.deucher@amd.com>

commit 7d5ab3009a8ca777174f6f469277b3922d56fd4b upstream.

May fix display issues with non-HDMI displays.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/gpu/drm/radeon/atombios_crtc.c | 48 ++++++++++++++++++----------------
 1 file changed, 26 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
index b9ff6e2..bbcc441 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -839,14 +839,16 @@ static void atombios_crtc_program_pll(struct drm_crtc *crtc,
 			args.v5.ucMiscInfo = 0; /* HDMI depth, etc. */
 			if (ss_enabled && (ss->type & ATOM_EXTERNAL_SS_MASK))
 				args.v5.ucMiscInfo |= PIXEL_CLOCK_V5_MISC_REF_DIV_SRC;
-			switch (bpc) {
-			case 8:
-			default:
-				args.v5.ucMiscInfo |= PIXEL_CLOCK_V5_MISC_HDMI_24BPP;
-				break;
-			case 10:
-				args.v5.ucMiscInfo |= PIXEL_CLOCK_V5_MISC_HDMI_30BPP;
-				break;
+			if (encoder_mode == ATOM_ENCODER_MODE_HDMI) {
+				switch (bpc) {
+				case 8:
+				default:
+					args.v5.ucMiscInfo |= PIXEL_CLOCK_V5_MISC_HDMI_24BPP;
+					break;
+				case 10:
+					args.v5.ucMiscInfo |= PIXEL_CLOCK_V5_MISC_HDMI_30BPP;
+					break;
+				}
 			}
 			args.v5.ucTransmitterID = encoder_id;
 			args.v5.ucEncoderMode = encoder_mode;
@@ -861,20 +863,22 @@ static void atombios_crtc_program_pll(struct drm_crtc *crtc,
 			args.v6.ucMiscInfo = 0; /* HDMI depth, etc. */
 			if (ss_enabled && (ss->type & ATOM_EXTERNAL_SS_MASK))
 				args.v6.ucMiscInfo |= PIXEL_CLOCK_V6_MISC_REF_DIV_SRC;
-			switch (bpc) {
-			case 8:
-			default:
-				args.v6.ucMiscInfo |= PIXEL_CLOCK_V6_MISC_HDMI_24BPP;
-				break;
-			case 10:
-				args.v6.ucMiscInfo |= PIXEL_CLOCK_V6_MISC_HDMI_30BPP;
-				break;
-			case 12:
-				args.v6.ucMiscInfo |= PIXEL_CLOCK_V6_MISC_HDMI_36BPP;
-				break;
-			case 16:
-				args.v6.ucMiscInfo |= PIXEL_CLOCK_V6_MISC_HDMI_48BPP;
-				break;
+			if (encoder_mode == ATOM_ENCODER_MODE_HDMI) {
+				switch (bpc) {
+				case 8:
+				default:
+					args.v6.ucMiscInfo |= PIXEL_CLOCK_V6_MISC_HDMI_24BPP;
+					break;
+				case 10:
+					args.v6.ucMiscInfo |= PIXEL_CLOCK_V6_MISC_HDMI_30BPP;
+					break;
+				case 12:
+					args.v6.ucMiscInfo |= PIXEL_CLOCK_V6_MISC_HDMI_36BPP;
+					break;
+				case 16:
+					args.v6.ucMiscInfo |= PIXEL_CLOCK_V6_MISC_HDMI_48BPP;
+					break;
+				}
 			}
 			args.v6.ucTransmitterID = encoder_id;
 			args.v6.ucEncoderMode = encoder_mode;
-- 
1.9.1


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

* [PATCH 3.8 052/116] ahci: Add Device ID for HighPoint RocketRaid 642L
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (50 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 051/116] drm/radeon: only apply hdmi bpc pll flags when encoder mode is hdmi Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 053/116] mm: fix sleeping function warning from __put_anon_vma Kamal Mostafa
                   ` (63 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Jérôme Carretero, Tejun Heo, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Carretero?= <cJ-ko@zougloub.eu>

commit d251836508fb26cd1a22b41381739835ee23728d upstream.

This device normally comes with a proprietary driver, using a web GUI
to configure RAID:
 http://www.highpoint-tech.com/USA_new/series_rr600-download.htm
But thankfully it also works out of the box with the AHCI driver,
being just a Marvell 88SE9235.

Devices 640L, 644L, 644LS should also be supported but not tested here.

Signed-off-by: Jérôme Carretero <cJ-ko@zougloub.eu>
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/ata/ahci.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index c752e6f..a08cb7a 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -446,6 +446,8 @@ static const struct pci_device_id ahci_pci_tbl[] = {
 	  .driver_data = board_ahci_yes_fbs },
 	{ PCI_DEVICE(0x1b4b, 0x9230),
 	  .driver_data = board_ahci_yes_fbs },
+	{ PCI_DEVICE(PCI_VENDOR_ID_TTI, 0x0642),
+	  .driver_data = board_ahci_yes_fbs },
 
 	/* Promise */
 	{ PCI_VDEVICE(PROMISE, 0x3f20), board_ahci },	/* PDC42819 */
-- 
1.9.1


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

* [PATCH 3.8 053/116] mm: fix sleeping function warning from __put_anon_vma
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (51 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 052/116] ahci: Add Device ID for HighPoint RocketRaid 642L Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 054/116] mm: vmscan: do not throttle based on pfmemalloc reserves if node has no ZONE_NORMAL Kamal Mostafa
                   ` (62 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Hugh Dickins, Peter Zijlstra, Andrew Morton, Linus Torvalds,
	Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Hugh Dickins <hughd@google.com>

commit 7f39dda9d86fb4f4f17af0de170decf125726f8c upstream.

Trinity reports BUG:

  sleeping function called from invalid context at kernel/locking/rwsem.c:47
  in_atomic(): 0, irqs_disabled(): 0, pid: 5787, name: trinity-c27

__might_sleep < down_write < __put_anon_vma < page_get_anon_vma <
migrate_pages < compact_zone < compact_zone_order < try_to_compact_pages ..

Right, since conversion to mutex then rwsem, we should not put_anon_vma()
from inside an rcu_read_lock()ed section: fix the two places that did so.
And add might_sleep() to anon_vma_free(), as suggested by Peter Zijlstra.

Fixes: 88c22088bf23 ("mm: optimize page_lock_anon_vma() fast-path")
Reported-by: Dave Jones <davej@redhat.com>
Signed-off-by: Hugh Dickins <hughd@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 mm/rmap.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/mm/rmap.c b/mm/rmap.c
index 770320b..f350f9f 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -103,6 +103,7 @@ static inline void anon_vma_free(struct anon_vma *anon_vma)
 	 * LOCK should suffice since the actual taking of the lock must
 	 * happen _before_ what follows.
 	 */
+	might_sleep();
 	if (rwsem_is_locked(&anon_vma->root->rwsem)) {
 		anon_vma_lock_write(anon_vma);
 		anon_vma_unlock_write(anon_vma);
@@ -426,8 +427,9 @@ struct anon_vma *page_get_anon_vma(struct page *page)
 	 * above cannot corrupt).
 	 */
 	if (!page_mapped(page)) {
+		rcu_read_unlock();
 		put_anon_vma(anon_vma);
-		anon_vma = NULL;
+		return NULL;
 	}
 out:
 	rcu_read_unlock();
@@ -477,9 +479,9 @@ struct anon_vma *page_lock_anon_vma_read(struct page *page)
 	}
 
 	if (!page_mapped(page)) {
+		rcu_read_unlock();
 		put_anon_vma(anon_vma);
-		anon_vma = NULL;
-		goto out;
+		return NULL;
 	}
 
 	/* we pinned the anon_vma, its safe to sleep */
-- 
1.9.1


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

* [PATCH 3.8 054/116] mm: vmscan: do not throttle based on pfmemalloc reserves if node has no ZONE_NORMAL
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (52 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 053/116] mm: fix sleeping function warning from __put_anon_vma Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 055/116] memcg: do not hang on OOM when killed by userspace OOM access to memory reserves Kamal Mostafa
                   ` (61 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Mel Gorman, Andrew Morton, Linus Torvalds, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Mel Gorman <mgorman@suse.de>

commit 675becce15f320337499bc1a9356260409a5ba29 upstream.

throttle_direct_reclaim() is meant to trigger during swap-over-network
during which the min watermark is treated as a pfmemalloc reserve.  It
throttes on the first node in the zonelist but this is flawed.

The user-visible impact is that a process running on CPU whose local
memory node has no ZONE_NORMAL will stall for prolonged periods of time,
possibly indefintely.  This is due to throttle_direct_reclaim thinking the
pfmemalloc reserves are depleted when in fact they don't exist on that
node.

On a NUMA machine running a 32-bit kernel (I know) allocation requests
from CPUs on node 1 would detect no pfmemalloc reserves and the process
gets throttled.  This patch adjusts throttling of direct reclaim to
throttle based on the first node in the zonelist that has a usable
ZONE_NORMAL or lower zone.

[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: Mel Gorman <mgorman@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 mm/vmscan.c | 43 +++++++++++++++++++++++++++++++++++++------
 1 file changed, 37 insertions(+), 6 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 9dcc836..9cbc502 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2226,10 +2226,17 @@ static bool pfmemalloc_watermark_ok(pg_data_t *pgdat)
 
 	for (i = 0; i <= ZONE_NORMAL; i++) {
 		zone = &pgdat->node_zones[i];
+		if (!populated_zone(zone))
+			continue;
+
 		pfmemalloc_reserve += min_wmark_pages(zone);
 		free_pages += zone_page_state(zone, NR_FREE_PAGES);
 	}
 
+	/* If there are no reserves (unexpected config) then do not throttle */
+	if (!pfmemalloc_reserve)
+		return true;
+
 	wmark_ok = free_pages > pfmemalloc_reserve / 2;
 
 	/* kswapd must be awake if processes are being throttled */
@@ -2254,9 +2261,9 @@ static bool pfmemalloc_watermark_ok(pg_data_t *pgdat)
 static bool throttle_direct_reclaim(gfp_t gfp_mask, struct zonelist *zonelist,
 					nodemask_t *nodemask)
 {
+	struct zoneref *z;
 	struct zone *zone;
-	int high_zoneidx = gfp_zone(gfp_mask);
-	pg_data_t *pgdat;
+	pg_data_t *pgdat = NULL;
 
 	/*
 	 * Kernel threads should not be throttled as they may be indirectly
@@ -2275,10 +2282,34 @@ static bool throttle_direct_reclaim(gfp_t gfp_mask, struct zonelist *zonelist,
 	if (fatal_signal_pending(current))
 		goto out;
 
-	/* Check if the pfmemalloc reserves are ok */
-	first_zones_zonelist(zonelist, high_zoneidx, NULL, &zone);
-	pgdat = zone->zone_pgdat;
-	if (pfmemalloc_watermark_ok(pgdat))
+	/*
+	 * Check if the pfmemalloc reserves are ok by finding the first node
+	 * with a usable ZONE_NORMAL or lower zone. The expectation is that
+	 * GFP_KERNEL will be required for allocating network buffers when
+	 * swapping over the network so ZONE_HIGHMEM is unusable.
+	 *
+	 * Throttling is based on the first usable node and throttled processes
+	 * wait on a queue until kswapd makes progress and wakes them. There
+	 * is an affinity then between processes waking up and where reclaim
+	 * progress has been made assuming the process wakes on the same node.
+	 * More importantly, processes running on remote nodes will not compete
+	 * for remote pfmemalloc reserves and processes on different nodes
+	 * should make reasonable progress.
+	 */
+	for_each_zone_zonelist_nodemask(zone, z, zonelist,
+					gfp_mask, nodemask) {
+		if (zone_idx(zone) > ZONE_NORMAL)
+			continue;
+
+		/* Throttle based on the first usable node */
+		pgdat = zone->zone_pgdat;
+		if (pfmemalloc_watermark_ok(pgdat))
+			goto out;
+		break;
+	}
+
+	/* If no zone was usable by the allocation flags then do not throttle */
+	if (!pgdat)
 		goto out;
 
 	/* Account for the throttling */
-- 
1.9.1


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

* [PATCH 3.8 055/116] memcg: do not hang on OOM when killed by userspace OOM access to memory reserves
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (53 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 054/116] mm: vmscan: do not throttle based on pfmemalloc reserves if node has no ZONE_NORMAL Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 056/116] mm: page_alloc: use word-based accesses for get/set pageblock bitmaps Kamal Mostafa
                   ` (60 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Michal Hocko, KAMEZAWA Hiroyuki, Andrew Morton, Linus Torvalds,
	Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Michal Hocko <mhocko@suse.cz>

commit d8dc595ce3909fbc131bdf5ab8c9808fe624b18d upstream.

Eric has reported that he can see task(s) stuck in memcg OOM handler
regularly.  The only way out is to

	echo 0 > $GROUP/memory.oom_control

His usecase is:

- Setup a hierarchy with memory and the freezer (disable kernel oom and
  have a process watch for oom).

- In that memory cgroup add a process with one thread per cpu.

- In one thread slowly allocate once per second I think it is 16M of ram
  and mlock and dirty it (just to force the pages into ram and stay
  there).

- When oom is achieved loop:
  * attempt to freeze all of the tasks.
  * if frozen send every task SIGKILL, unfreeze, remove the directory in
    cgroupfs.

Eric has then pinpointed the issue to be memcg specific.

All tasks are sitting on the memcg_oom_waitq when memcg oom is disabled.
Those that have received fatal signal will bypass the charge and should
continue on their way out.  The tricky part is that the exit path might
trigger a page fault (e.g.  exit_robust_list), thus the memcg charge,
while its memcg is still under OOM because nobody has released any charges
yet.

Unlike with the in-kernel OOM handler the exiting task doesn't get
TIF_MEMDIE set so it doesn't shortcut further charges of the killed task
and falls to the memcg OOM again without any way out of it as there are no
fatal signals pending anymore.

This patch fixes the issue by checking PF_EXITING early in
mem_cgroup_try_charge and bypass the charge same as if it had fatal
signal pending or TIF_MEMDIE set.

Normally exiting tasks (aka not killed) will bypass the charge now but
this should be OK as the task is leaving and will release memory and
increasing the memory pressure just to release it in a moment seems
dubious wasting of cycles.  Besides that charges after exit_signals should
be rare.

I am bringing this patch again (rebased on the current mmotm tree). I
hope we can move forward finally. If there is still an opposition then
I would really appreciate a concurrent approach so that we can discuss
alternatives.

http://comments.gmane.org/gmane.linux.kernel.stable/77650 is a reference
to the followup discussion when the patch has been dropped from the mmotm
last time.

Reported-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Michal Hocko <mhocko@suse.cz>
Acked-by: David Rientjes <rientjes@google.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[ kamal: backport to 3.13: whitespace ]
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 mm/memcontrol.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 3e6bb9f..c29c7d5 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2502,8 +2502,9 @@ static int __mem_cgroup_try_charge(struct mm_struct *mm,
 	 * in system level. So, allow to go ahead dying process in addition to
 	 * MEMDIE process.
 	 */
-	if (unlikely(test_thread_flag(TIF_MEMDIE)
-		     || fatal_signal_pending(current)))
+	if (unlikely(test_thread_flag(TIF_MEMDIE) ||
+		     fatal_signal_pending(current) ||
+		     current->flags & PF_EXITING))
 		goto bypass;
 
 	/*
-- 
1.9.1


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

* [PATCH 3.8 056/116] mm: page_alloc: use word-based accesses for get/set pageblock bitmaps
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (54 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 055/116] memcg: do not hang on OOM when killed by userspace OOM access to memory reserves Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 057/116] mm/memory-failure.c-failure: send right signal code to correct thread Kamal Mostafa
                   ` (59 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Mel Gorman, Johannes Weiner, Jan Kara, Michal Hocko,
	Hugh Dickins, Dave Hansen, Theodore Ts'o, Paul E. McKenney,
	Oleg Nesterov, Rik van Riel, Peter Zijlstra, Andrew Morton,
	Linus Torvalds, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Mel Gorman <mgorman@suse.de>

commit e58469bafd0524e848c3733bc3918d854595e20f upstream.

The test_bit operations in get/set pageblock flags are expensive.  This
patch reads the bitmap on a word basis and use shifts and masks to isolate
the bits of interest.  Similarly masks are used to set a local copy of the
bitmap and then use cmpxchg to update the bitmap if there have been no
other changes made in parallel.

In a test running dd onto tmpfs the overhead of the pageblock-related
functions went from 1.27% in profiles to 0.5%.

In addition to the performance benefits, this patch closes races that are
possible between:

a) get_ and set_pageblock_migratetype(), where get_pageblock_migratetype()
   reads part of the bits before and other part of the bits after
   set_pageblock_migratetype() has updated them.

b) set_pageblock_migratetype() and set_pageblock_skip(), where the non-atomic
   read-modify-update set bit operation in set_pageblock_skip() will cause
   lost updates to some bits changed in the set_pageblock_migratetype().

Joonsoo Kim first reported the case a) via code inspection.  Vlastimil
Babka's testing with a debug patch showed that either a) or b) occurs
roughly once per mmtests' stress-highalloc benchmark (although not
necessarily in the same pageblock).  Furthermore during development of
unrelated compaction patches, it was observed that frequent calls to
{start,undo}_isolate_page_range() the race occurs several thousands of
times and has resulted in NULL pointer dereferences in move_freepages()
and free_one_page() in places where free_list[migratetype] is
manipulated by e.g.  list_move().  Further debugging confirmed that
migratetype had invalid value of 6, causing out of bounds access to the
free_list array.

That confirmed that the race exist, although it may be extremely rare,
and currently only fatal where page isolation is performed due to
memory hot remove.  Races on pageblocks being updated by
set_pageblock_migratetype(), where both old and new migratetype are
lower MIGRATE_RESERVE, currently cannot result in an invalid value
being observed, although theoretically they may still lead to
unexpected creation or destruction of MIGRATE_RESERVE pageblocks.
Furthermore, things could get suddenly worse when memory isolation is
used more, or when new migratetypes are added.

After this patch, the race has no longer been observed in testing.

Signed-off-by: Mel Gorman <mgorman@suse.de>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Reported-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Reported-and-tested-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Jan Kara <jack@suse.cz>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Hugh Dickins <hughd@google.com>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Theodore Ts'o <tytso@mit.edu>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 include/linux/mmzone.h          |  6 ++++-
 include/linux/pageblock-flags.h | 37 +++++++++++++++++++++++++-----
 mm/page_alloc.c                 | 51 +++++++++++++++++++++++++----------------
 3 files changed, 67 insertions(+), 27 deletions(-)

diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 73b64a3..d1584a4 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -73,9 +73,13 @@ enum {
 
 extern int page_group_by_mobility_disabled;
 
+#define NR_MIGRATETYPE_BITS (PB_migrate_end - PB_migrate + 1)
+#define MIGRATETYPE_MASK ((1UL << NR_MIGRATETYPE_BITS) - 1)
+
 static inline int get_pageblock_migratetype(struct page *page)
 {
-	return get_pageblock_flags_group(page, PB_migrate, PB_migrate_end);
+	BUILD_BUG_ON(PB_migrate_end - PB_migrate != 2);
+	return get_pageblock_flags_mask(page, PB_migrate_end, MIGRATETYPE_MASK);
 }
 
 struct free_area {
diff --git a/include/linux/pageblock-flags.h b/include/linux/pageblock-flags.h
index be655e4..bed78c9 100644
--- a/include/linux/pageblock-flags.h
+++ b/include/linux/pageblock-flags.h
@@ -30,9 +30,12 @@ enum pageblock_bits {
 	PB_migrate,
 	PB_migrate_end = PB_migrate + 3 - 1,
 			/* 3 bits required for migrate types */
-#ifdef CONFIG_COMPACTION
 	PB_migrate_skip,/* If set the block is skipped by compaction */
-#endif /* CONFIG_COMPACTION */
+
+	/*
+	 * Assume the bits will always align on a word. If this assumption
+	 * changes then get/set pageblock needs updating.
+	 */
 	NR_PAGEBLOCK_BITS
 };
 
@@ -62,11 +65,33 @@ extern int pageblock_order;
 /* Forward declaration */
 struct page;
 
+unsigned long get_pageblock_flags_mask(struct page *page,
+				unsigned long end_bitidx,
+				unsigned long mask);
+void set_pageblock_flags_mask(struct page *page,
+				unsigned long flags,
+				unsigned long end_bitidx,
+				unsigned long mask);
+
 /* Declarations for getting and setting flags. See mm/page_alloc.c */
-unsigned long get_pageblock_flags_group(struct page *page,
-					int start_bitidx, int end_bitidx);
-void set_pageblock_flags_group(struct page *page, unsigned long flags,
-					int start_bitidx, int end_bitidx);
+static inline unsigned long get_pageblock_flags_group(struct page *page,
+					int start_bitidx, int end_bitidx)
+{
+	unsigned long nr_flag_bits = end_bitidx - start_bitidx + 1;
+	unsigned long mask = (1 << nr_flag_bits) - 1;
+
+	return get_pageblock_flags_mask(page, end_bitidx, mask);
+}
+
+static inline void set_pageblock_flags_group(struct page *page,
+					unsigned long flags,
+					int start_bitidx, int end_bitidx)
+{
+	unsigned long nr_flag_bits = end_bitidx - start_bitidx + 1;
+	unsigned long mask = (1 << nr_flag_bits) - 1;
+
+	set_pageblock_flags_mask(page, flags, end_bitidx, mask);
+}
 
 #ifdef CONFIG_COMPACTION
 #define get_pageblock_skip(page) \
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 7708f66..cea283e 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5613,54 +5613,65 @@ static inline int pfn_to_bitidx(struct zone *zone, unsigned long pfn)
  * @end_bitidx: The last bit of interest
  * returns pageblock_bits flags
  */
-unsigned long get_pageblock_flags_group(struct page *page,
-					int start_bitidx, int end_bitidx)
+unsigned long get_pageblock_flags_mask(struct page *page,
+					unsigned long end_bitidx,
+					unsigned long mask)
 {
 	struct zone *zone;
 	unsigned long *bitmap;
-	unsigned long pfn, bitidx;
-	unsigned long flags = 0;
-	unsigned long value = 1;
+	unsigned long pfn, bitidx, word_bitidx;
+	unsigned long word;
 
 	zone = page_zone(page);
 	pfn = page_to_pfn(page);
 	bitmap = get_pageblock_bitmap(zone, pfn);
 	bitidx = pfn_to_bitidx(zone, pfn);
+	word_bitidx = bitidx / BITS_PER_LONG;
+	bitidx &= (BITS_PER_LONG-1);
 
-	for (; start_bitidx <= end_bitidx; start_bitidx++, value <<= 1)
-		if (test_bit(bitidx + start_bitidx, bitmap))
-			flags |= value;
-
-	return flags;
+	word = bitmap[word_bitidx];
+	bitidx += end_bitidx;
+	return (word >> (BITS_PER_LONG - bitidx - 1)) & mask;
 }
 
 /**
- * set_pageblock_flags_group - Set the requested group of flags for a pageblock_nr_pages block of pages
+ * set_pageblock_flags_mask - Set the requested group of flags for a pageblock_nr_pages block of pages
  * @page: The page within the block of interest
  * @start_bitidx: The first bit of interest
  * @end_bitidx: The last bit of interest
  * @flags: The flags to set
  */
-void set_pageblock_flags_group(struct page *page, unsigned long flags,
-					int start_bitidx, int end_bitidx)
+void set_pageblock_flags_mask(struct page *page, unsigned long flags,
+					unsigned long end_bitidx,
+					unsigned long mask)
 {
 	struct zone *zone;
 	unsigned long *bitmap;
-	unsigned long pfn, bitidx;
-	unsigned long value = 1;
+	unsigned long pfn, bitidx, word_bitidx;
+	unsigned long old_word, word;
+
+	BUILD_BUG_ON(NR_PAGEBLOCK_BITS != 4);
 
 	zone = page_zone(page);
 	pfn = page_to_pfn(page);
 	bitmap = get_pageblock_bitmap(zone, pfn);
 	bitidx = pfn_to_bitidx(zone, pfn);
+	word_bitidx = bitidx / BITS_PER_LONG;
+	bitidx &= (BITS_PER_LONG-1);
 	VM_BUG_ON(pfn < zone->zone_start_pfn);
 	VM_BUG_ON(pfn >= zone->zone_start_pfn + zone->spanned_pages);
 
-	for (; start_bitidx <= end_bitidx; start_bitidx++, value <<= 1)
-		if (flags & value)
-			__set_bit(bitidx + start_bitidx, bitmap);
-		else
-			__clear_bit(bitidx + start_bitidx, bitmap);
+	bitidx += end_bitidx;
+	mask <<= (BITS_PER_LONG - bitidx - 1);
+	flags <<= (BITS_PER_LONG - bitidx - 1);
+
+	word = ACCESS_ONCE(bitmap[word_bitidx]);
+	for (;;) {
+		old_word = cmpxchg(&bitmap[word_bitidx], word, (word & ~mask) | flags);
+		if (word == old_word)
+			break;
+		word = old_word;
+	}
 }
 
 /*
-- 
1.9.1


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

* [PATCH 3.8 057/116] mm/memory-failure.c-failure: send right signal code to correct thread
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (55 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 056/116] mm: page_alloc: use word-based accesses for get/set pageblock bitmaps Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 058/116] mm/memory-failure.c: don't let collect_procs() skip over processes for MF_ACTION_REQUIRED Kamal Mostafa
                   ` (58 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Tony Luck, Naoya Horiguchi, Andi Kleen, Borislav Petkov,
	Chen Gong, Andrew Morton, Linus Torvalds, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Tony Luck <tony.luck@intel.com>

commit a70ffcac741d31a406c1d2b832ae43d658e7e1cf upstream.

When a thread in a multi-threaded application hits a machine check because
of an uncorrectable error in memory - we want to send the SIGBUS with
si.si_code = BUS_MCEERR_AR to that thread.  Currently we fail to do that
if the active thread is not the primary thread in the process.
collect_procs() just finds primary threads and this test:

	if ((flags & MF_ACTION_REQUIRED) && t == current) {

will see that the thread we found isn't the current thread and so send a
si.si_code = BUS_MCEERR_AO to the primary (and nothing to the active
thread at this time).

We can fix this by checking whether "current" shares the same mm with the
process that collect_procs() said owned the page.  If so, we send the
SIGBUS to current (with code BUS_MCEERR_AR).

Signed-off-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Reported-by: Otto Bruggeman <otto.g.bruggeman@intel.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Borislav Petkov <bp@suse.de>
Cc: Chen Gong <gong.chen@linux.jf.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 mm/memory-failure.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index d3ed748..0af800c 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -208,9 +208,9 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
 #endif
 	si.si_addr_lsb = compound_trans_order(compound_head(page)) + PAGE_SHIFT;
 
-	if ((flags & MF_ACTION_REQUIRED) && t == current) {
+	if ((flags & MF_ACTION_REQUIRED) && t->mm == current->mm) {
 		si.si_code = BUS_MCEERR_AR;
-		ret = force_sig_info(SIGBUS, &si, t);
+		ret = force_sig_info(SIGBUS, &si, current);
 	} else {
 		/*
 		 * Don't use force here, it's convenient if the signal
-- 
1.9.1


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

* [PATCH 3.8 058/116] mm/memory-failure.c: don't let collect_procs() skip over processes for MF_ACTION_REQUIRED
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (56 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 057/116] mm/memory-failure.c-failure: send right signal code to correct thread Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 059/116] powerpc/serial: Use saner flags when creating legacy ports Kamal Mostafa
                   ` (57 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Tony Luck, Naoya Horiguchi, Andi Kleen, Borislav Petkov,
	Chen Gong, Andrew Morton, Linus Torvalds, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Tony Luck <tony.luck@intel.com>

commit 74614de17db6fb472370c426d4f934d8d616edf2 upstream.

When Linux sees an "action optional" machine check (where h/w has reported
an error that is not in the current execution path) we generally do not
want to signal a process, since most processes do not have a SIGBUS
handler - we'd just prematurely terminate the process for a problem that
they might never actually see.

task_early_kill() decides whether to consider a process - and it checks
whether this specific process has been marked for early signals with
"prctl", or if the system administrator has requested early signals for
all processes using /proc/sys/vm/memory_failure_early_kill.

But for MF_ACTION_REQUIRED case we must not defer.  The error is in the
execution path of the current thread so we must send the SIGBUS
immediatley.

Fix by passing a flag argument through collect_procs*() to
task_early_kill() so it knows whether we can defer or must take action.

Signed-off-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Borislav Petkov <bp@suse.de>
Cc: Chen Gong <gong.chen@linux.jf.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 mm/memory-failure.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 0af800c..7f3ceb1 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -382,10 +382,12 @@ static void kill_procs(struct list_head *to_kill, int forcekill, int trapno,
 	}
 }
 
-static int task_early_kill(struct task_struct *tsk)
+static int task_early_kill(struct task_struct *tsk, int force_early)
 {
 	if (!tsk->mm)
 		return 0;
+	if (force_early)
+		return 1;
 	if (tsk->flags & PF_MCE_PROCESS)
 		return !!(tsk->flags & PF_MCE_EARLY);
 	return sysctl_memory_failure_early_kill;
@@ -395,7 +397,7 @@ static int task_early_kill(struct task_struct *tsk)
  * Collect processes when the error hit an anonymous page.
  */
 static void collect_procs_anon(struct page *page, struct list_head *to_kill,
-			      struct to_kill **tkc)
+			      struct to_kill **tkc, int force_early)
 {
 	struct vm_area_struct *vma;
 	struct task_struct *tsk;
@@ -411,7 +413,7 @@ static void collect_procs_anon(struct page *page, struct list_head *to_kill,
 	for_each_process (tsk) {
 		struct anon_vma_chain *vmac;
 
-		if (!task_early_kill(tsk))
+		if (!task_early_kill(tsk, force_early))
 			continue;
 		anon_vma_interval_tree_foreach(vmac, &av->rb_root,
 					       pgoff, pgoff) {
@@ -430,7 +432,7 @@ static void collect_procs_anon(struct page *page, struct list_head *to_kill,
  * Collect processes when the error hit a file mapped page.
  */
 static void collect_procs_file(struct page *page, struct list_head *to_kill,
-			      struct to_kill **tkc)
+			      struct to_kill **tkc, int force_early)
 {
 	struct vm_area_struct *vma;
 	struct task_struct *tsk;
@@ -441,7 +443,7 @@ static void collect_procs_file(struct page *page, struct list_head *to_kill,
 	for_each_process(tsk) {
 		pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
 
-		if (!task_early_kill(tsk))
+		if (!task_early_kill(tsk, force_early))
 			continue;
 
 		vma_interval_tree_foreach(vma, &mapping->i_mmap, pgoff,
@@ -467,7 +469,8 @@ static void collect_procs_file(struct page *page, struct list_head *to_kill,
  * First preallocate one tokill structure outside the spin locks,
  * so that we can kill at least one process reasonably reliable.
  */
-static void collect_procs(struct page *page, struct list_head *tokill)
+static void collect_procs(struct page *page, struct list_head *tokill,
+				int force_early)
 {
 	struct to_kill *tk;
 
@@ -478,9 +481,9 @@ static void collect_procs(struct page *page, struct list_head *tokill)
 	if (!tk)
 		return;
 	if (PageAnon(page))
-		collect_procs_anon(page, tokill, &tk);
+		collect_procs_anon(page, tokill, &tk, force_early);
 	else
-		collect_procs_file(page, tokill, &tk);
+		collect_procs_file(page, tokill, &tk, force_early);
 	kfree(tk);
 }
 
@@ -950,7 +953,7 @@ static int hwpoison_user_mappings(struct page *p, unsigned long pfn,
 	 * there's nothing that can be done.
 	 */
 	if (kill)
-		collect_procs(ppage, &tokill);
+		collect_procs(ppage, &tokill, flags & MF_ACTION_REQUIRED);
 
 	if (hpage != ppage)
 		lock_page(ppage);
-- 
1.9.1


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

* [PATCH 3.8 059/116] powerpc/serial: Use saner flags when creating legacy ports
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (57 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 058/116] mm/memory-failure.c: don't let collect_procs() skip over processes for MF_ACTION_REQUIRED Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 060/116] powerpc: 64bit sendfile is capped at 2GB Kamal Mostafa
                   ` (56 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Benjamin Herrenschmidt, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Benjamin Herrenschmidt <benh@kernel.crashing.org>

commit c4cad90f9e9dcb85afc5e75a02ae3522ed077296 upstream.

We had a mix & match of flags used when creating legacy ports
depending on where we found them in the device-tree. Among others
we were missing UPF_SKIP_TEST for some kind of ISA ports which is
a problem as quite a few UARTs out there don't support the loopback
test (such as a lot of BMCs).

Let's pick the set of flags used by the SoC code and generalize it
which means autoconf, no loopback test, irq maybe shared and fixed
port.

Sending to stable as the lack of UPF_SKIP_TEST is breaking
serial on some machines so I want this back into distros

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 arch/powerpc/kernel/legacy_serial.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/kernel/legacy_serial.c b/arch/powerpc/kernel/legacy_serial.c
index 0733b05..23af574 100644
--- a/arch/powerpc/kernel/legacy_serial.c
+++ b/arch/powerpc/kernel/legacy_serial.c
@@ -48,6 +48,9 @@ static struct __initdata of_device_id legacy_serial_parents[] = {
 static unsigned int legacy_serial_count;
 static int legacy_serial_console = -1;
 
+static const upf_t legacy_port_flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
+	UPF_SHARE_IRQ | UPF_FIXED_PORT;
+
 static unsigned int tsi_serial_in(struct uart_port *p, int offset)
 {
 	unsigned int tmp;
@@ -153,8 +156,6 @@ static int __init add_legacy_soc_port(struct device_node *np,
 {
 	u64 addr;
 	const u32 *addrp;
-	upf_t flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_SHARE_IRQ
-		| UPF_FIXED_PORT;
 	struct device_node *tsi = of_get_parent(np);
 
 	/* We only support ports that have a clock frequency properly
@@ -185,9 +186,11 @@ static int __init add_legacy_soc_port(struct device_node *np,
 	 * IO port value. It will be fixed up later along with the irq
 	 */
 	if (tsi && !strcmp(tsi->type, "tsi-bridge"))
-		return add_legacy_port(np, -1, UPIO_TSI, addr, addr, NO_IRQ, flags, 0);
+		return add_legacy_port(np, -1, UPIO_TSI, addr, addr,
+				       NO_IRQ, legacy_port_flags, 0);
 	else
-		return add_legacy_port(np, -1, UPIO_MEM, addr, addr, NO_IRQ, flags, 0);
+		return add_legacy_port(np, -1, UPIO_MEM, addr, addr,
+				       NO_IRQ, legacy_port_flags, 0);
 }
 
 static int __init add_legacy_isa_port(struct device_node *np,
@@ -228,7 +231,7 @@ static int __init add_legacy_isa_port(struct device_node *np,
 
 	/* Add port, irq will be dealt with later */
 	return add_legacy_port(np, index, UPIO_PORT, be32_to_cpu(reg[1]), taddr,
-			       NO_IRQ, UPF_BOOT_AUTOCONF, 0);
+			       NO_IRQ, legacy_port_flags, 0);
 
 }
 
@@ -301,7 +304,7 @@ static int __init add_legacy_pci_port(struct device_node *np,
 	 * IO port value. It will be fixed up later along with the irq
 	 */
 	return add_legacy_port(np, index, iotype, base, addr, NO_IRQ,
-			       UPF_BOOT_AUTOCONF, np != pci_dev);
+			       legacy_port_flags, np != pci_dev);
 }
 #endif
 
-- 
1.9.1


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

* [PATCH 3.8 060/116] powerpc: 64bit sendfile is capped at 2GB
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (58 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 059/116] powerpc/serial: Use saner flags when creating legacy ports Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 061/116] ALSA: hda/realtek - Add support of ALC891 codec Kamal Mostafa
                   ` (55 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Anton Blanchard, Benjamin Herrenschmidt, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Anton Blanchard <anton@samba.org>

commit 5d73320a96fcce80286f1447864c481b5f0b96fa upstream.

commit 8f9c0119d7ba (compat: fs: Generic compat_sys_sendfile
implementation) changed the PowerPC 64bit sendfile call from
sys_sendile64 to sys_sendfile.

Unfortunately this broke sendfile of lengths greater than 2G because
sys_sendfile caps at MAX_NON_LFS. Restore what we had previously which
fixes the bug.

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
[ kamal: backport to 3.8: context ]
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 arch/powerpc/include/asm/systbl.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/systbl.h b/arch/powerpc/include/asm/systbl.h
index 97909d3b..4ca7fca 100644
--- a/arch/powerpc/include/asm/systbl.h
+++ b/arch/powerpc/include/asm/systbl.h
@@ -189,7 +189,7 @@ SYSCALL_SPU(getcwd)
 SYSCALL_SPU(capget)
 SYSCALL_SPU(capset)
 COMPAT_SYS(sigaltstack)
-SYSX_SPU(sys_sendfile,compat_sys_sendfile_wrapper,sys_sendfile)
+SYSX_SPU(sys_sendfile64,compat_sys_sendfile,sys_sendfile)
 SYSCALL(ni_syscall)
 SYSCALL(ni_syscall)
 PPC_SYS(vfork)
-- 
1.9.1


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

* [PATCH 3.8 061/116] ALSA: hda/realtek - Add support of ALC891 codec
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (59 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 060/116] powerpc: 64bit sendfile is capped at 2GB Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 062/116] iscsi-target: Reject mutual authentication with reflected CHAP_C Kamal Mostafa
                   ` (54 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Kailang Yang, Takashi Iwai, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Kailang Yang <kailang@realtek.com>

commit b6c5fbad16aa5026f508093a8d651c25e1cb6179 upstream.

New codec support for ALC891.

Signed-off-by: Kailang Yang <kailang@realtek.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 sound/pci/hda/patch_realtek.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 6cc07f0..8609cf2 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -7282,6 +7282,7 @@ static const struct hda_codec_preset snd_hda_preset_realtek[] = {
 	{ .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
 	{ .id = 0x10ec0671, .name = "ALC671", .patch = patch_alc662 },
 	{ .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
+	{ .id = 0x10ec0867, .name = "ALC891", .patch = patch_alc882 },
 	{ .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
 	{ .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
 	{ .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
-- 
1.9.1


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

* [PATCH 3.8 062/116] iscsi-target: Reject mutual authentication with reflected CHAP_C
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (60 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 061/116] ALSA: hda/realtek - Add support of ALC891 codec Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 063/116] IB/umad: Fix use-after-free on close Kamal Mostafa
                   ` (53 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Nicholas Bellinger, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Nicholas Bellinger <nab@linux-iscsi.org>

commit 1d2b60a5545942b1376cb48c1d55843d71e3a08f upstream.

This patch adds an explicit check in chap_server_compute_md5() to ensure
the CHAP_C value received from the initiator during mutual authentication
does not match the original CHAP_C provided by the target.

This is in line with RFC-3720, section 8.2.1:

   Originators MUST NOT reuse the CHAP challenge sent by the Responder
   for the other direction of a bidirectional authentication.
   Responders MUST check for this condition and close the iSCSI TCP
   connection if it occurs.

Reported-by: Tejas Vaykole <tejas.vaykole@calsoftinc.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/target/iscsi/iscsi_target_auth.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/target/iscsi/iscsi_target_auth.c b/drivers/target/iscsi/iscsi_target_auth.c
index b54f6ec..cbb04f3 100644
--- a/drivers/target/iscsi/iscsi_target_auth.c
+++ b/drivers/target/iscsi/iscsi_target_auth.c
@@ -342,6 +342,16 @@ static int chap_server_compute_md5(
 		goto out;
 	}
 	/*
+	 * During mutual authentication, the CHAP_C generated by the
+	 * initiator must not match the original CHAP_C generated by
+	 * the target.
+	 */
+	if (!memcmp(challenge_binhex, chap->challenge, CHAP_CHALLENGE_LENGTH)) {
+		pr_err("initiator CHAP_C matches target CHAP_C, failing"
+		       " login attempt\n");
+		goto out;
+	}
+	/*
 	 * Generate CHAP_N and CHAP_R for mutual authentication.
 	 */
 	tfm = crypto_alloc_hash("md5", 0, CRYPTO_ALG_ASYNC);
-- 
1.9.1


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

* [PATCH 3.8 063/116] IB/umad: Fix use-after-free on close
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (61 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 062/116] iscsi-target: Reject mutual authentication with reflected CHAP_C Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 064/116] mm: vmscan: clear kswapd's special reclaim powers before exiting Kamal Mostafa
                   ` (52 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Bart Van Assche, Roland Dreier, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Bart Van Assche <bvanassche@acm.org>

commit 60e1751cb52cc6d1ae04b6bd3c2b96e770b5823f upstream.

Avoid that closing /dev/infiniband/umad<n> or /dev/infiniband/issm<n>
triggers a use-after-free.  __fput() invokes f_op->release() before it
invokes cdev_put().  Make sure that the ib_umad_device structure is
freed by the cdev_put() call instead of f_op->release().  This avoids
that changing the port mode from IB into Ethernet and back to IB
followed by restarting opensmd triggers the following kernel oops:

    general protection fault: 0000 [#1] PREEMPT SMP
    RIP: 0010:[<ffffffff810cc65c>]  [<ffffffff810cc65c>] module_put+0x2c/0x170
    Call Trace:
     [<ffffffff81190f20>] cdev_put+0x20/0x30
     [<ffffffff8118e2ce>] __fput+0x1ae/0x1f0
     [<ffffffff8118e35e>] ____fput+0xe/0x10
     [<ffffffff810723bc>] task_work_run+0xac/0xe0
     [<ffffffff81002a9f>] do_notify_resume+0x9f/0xc0
     [<ffffffff814b8398>] int_signal+0x12/0x17

Reference: https://bugzilla.kernel.org/show_bug.cgi?id=75051
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Yann Droneaud <ydroneaud@opteya.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/infiniband/core/user_mad.c | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
index 9bdf576..1acb991 100644
--- a/drivers/infiniband/core/user_mad.c
+++ b/drivers/infiniband/core/user_mad.c
@@ -98,7 +98,7 @@ struct ib_umad_port {
 
 struct ib_umad_device {
 	int                  start_port, end_port;
-	struct kref          ref;
+	struct kobject       kobj;
 	struct ib_umad_port  port[0];
 };
 
@@ -134,14 +134,18 @@ static DECLARE_BITMAP(dev_map, IB_UMAD_MAX_PORTS);
 static void ib_umad_add_one(struct ib_device *device);
 static void ib_umad_remove_one(struct ib_device *device);
 
-static void ib_umad_release_dev(struct kref *ref)
+static void ib_umad_release_dev(struct kobject *kobj)
 {
 	struct ib_umad_device *dev =
-		container_of(ref, struct ib_umad_device, ref);
+		container_of(kobj, struct ib_umad_device, kobj);
 
 	kfree(dev);
 }
 
+static struct kobj_type ib_umad_dev_ktype = {
+	.release = ib_umad_release_dev,
+};
+
 static int hdr_size(struct ib_umad_file *file)
 {
 	return file->use_pkey_index ? sizeof (struct ib_user_mad_hdr) :
@@ -812,7 +816,7 @@ static int ib_umad_open(struct inode *inode, struct file *filp)
 		goto out;
 	}
 
-	kref_get(&port->umad_dev->ref);
+	kobject_get(&port->umad_dev->kobj);
 
 out:
 	mutex_unlock(&port->file_mutex);
@@ -851,7 +855,7 @@ static int ib_umad_close(struct inode *inode, struct file *filp)
 	mutex_unlock(&file->port->file_mutex);
 
 	kfree(file);
-	kref_put(&dev->ref, ib_umad_release_dev);
+	kobject_put(&dev->kobj);
 
 	return 0;
 }
@@ -902,7 +906,7 @@ static int ib_umad_sm_open(struct inode *inode, struct file *filp)
 	if (ret)
 		goto err_clr_sm_cap;
 
-	kref_get(&port->umad_dev->ref);
+	kobject_get(&port->umad_dev->kobj);
 
 	return 0;
 
@@ -932,7 +936,7 @@ static int ib_umad_sm_close(struct inode *inode, struct file *filp)
 
 	up(&port->sm_sem);
 
-	kref_put(&port->umad_dev->ref, ib_umad_release_dev);
+	kobject_put(&port->umad_dev->kobj);
 
 	return ret;
 }
@@ -1000,6 +1004,7 @@ static int find_overflow_devnum(void)
 }
 
 static int ib_umad_init_port(struct ib_device *device, int port_num,
+			     struct ib_umad_device *umad_dev,
 			     struct ib_umad_port *port)
 {
 	int devnum;
@@ -1032,6 +1037,7 @@ static int ib_umad_init_port(struct ib_device *device, int port_num,
 
 	cdev_init(&port->cdev, &umad_fops);
 	port->cdev.owner = THIS_MODULE;
+	port->cdev.kobj.parent = &umad_dev->kobj;
 	kobject_set_name(&port->cdev.kobj, "umad%d", port->dev_num);
 	if (cdev_add(&port->cdev, base, 1))
 		goto err_cdev;
@@ -1050,6 +1056,7 @@ static int ib_umad_init_port(struct ib_device *device, int port_num,
 	base += IB_UMAD_MAX_PORTS;
 	cdev_init(&port->sm_cdev, &umad_sm_fops);
 	port->sm_cdev.owner = THIS_MODULE;
+	port->sm_cdev.kobj.parent = &umad_dev->kobj;
 	kobject_set_name(&port->sm_cdev.kobj, "issm%d", port->dev_num);
 	if (cdev_add(&port->sm_cdev, base, 1))
 		goto err_sm_cdev;
@@ -1143,7 +1150,7 @@ static void ib_umad_add_one(struct ib_device *device)
 	if (!umad_dev)
 		return;
 
-	kref_init(&umad_dev->ref);
+	kobject_init(&umad_dev->kobj, &ib_umad_dev_ktype);
 
 	umad_dev->start_port = s;
 	umad_dev->end_port   = e;
@@ -1151,7 +1158,8 @@ static void ib_umad_add_one(struct ib_device *device)
 	for (i = s; i <= e; ++i) {
 		umad_dev->port[i - s].umad_dev = umad_dev;
 
-		if (ib_umad_init_port(device, i, &umad_dev->port[i - s]))
+		if (ib_umad_init_port(device, i, umad_dev,
+				      &umad_dev->port[i - s]))
 			goto err;
 	}
 
@@ -1163,7 +1171,7 @@ err:
 	while (--i >= s)
 		ib_umad_kill_port(&umad_dev->port[i - s]);
 
-	kref_put(&umad_dev->ref, ib_umad_release_dev);
+	kobject_put(&umad_dev->kobj);
 }
 
 static void ib_umad_remove_one(struct ib_device *device)
@@ -1177,7 +1185,7 @@ static void ib_umad_remove_one(struct ib_device *device)
 	for (i = 0; i <= umad_dev->end_port - umad_dev->start_port; ++i)
 		ib_umad_kill_port(&umad_dev->port[i]);
 
-	kref_put(&umad_dev->ref, ib_umad_release_dev);
+	kobject_put(&umad_dev->kobj);
 }
 
 static char *umad_devnode(struct device *dev, umode_t *mode)
-- 
1.9.1


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

* [PATCH 3.8 064/116] mm: vmscan: clear kswapd's special reclaim powers before exiting
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (62 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 063/116] IB/umad: Fix use-after-free on close Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 065/116] rtc: rtc-at91rm9200: fix infinite wait for ACKUPD irq Kamal Mostafa
                   ` (51 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Johannes Weiner, Yasuaki Ishimatsu, Tang Chen, Andrew Morton,
	Linus Torvalds, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Johannes Weiner <hannes@cmpxchg.org>

commit 71abdc15adf8c702a1dd535f8e30df50758848d2 upstream.

When kswapd exits, it can end up taking locks that were previously held
by allocating tasks while they waited for reclaim.  Lockdep currently
warns about this:

On Wed, May 28, 2014 at 06:06:34PM +0800, Gu Zheng wrote:
>  inconsistent {RECLAIM_FS-ON-W} -> {IN-RECLAIM_FS-R} usage.
>  kswapd2/1151 [HC0[0]:SC0[0]:HE1:SE1] takes:
>   (&sig->group_rwsem){+++++?}, at: exit_signals+0x24/0x130
>  {RECLAIM_FS-ON-W} state was registered at:
>     mark_held_locks+0xb9/0x140
>     lockdep_trace_alloc+0x7a/0xe0
>     kmem_cache_alloc_trace+0x37/0x240
>     flex_array_alloc+0x99/0x1a0
>     cgroup_attach_task+0x63/0x430
>     attach_task_by_pid+0x210/0x280
>     cgroup_procs_write+0x16/0x20
>     cgroup_file_write+0x120/0x2c0
>     vfs_write+0xc0/0x1f0
>     SyS_write+0x4c/0xa0
>     tracesys+0xdd/0xe2
>  irq event stamp: 49
>  hardirqs last  enabled at (49):  _raw_spin_unlock_irqrestore+0x36/0x70
>  hardirqs last disabled at (48):  _raw_spin_lock_irqsave+0x2b/0xa0
>  softirqs last  enabled at (0):  copy_process.part.24+0x627/0x15f0
>  softirqs last disabled at (0):            (null)
>
>  other info that might help us debug this:
>   Possible unsafe locking scenario:
>
>         CPU0
>         ----
>    lock(&sig->group_rwsem);
>    <Interrupt>
>      lock(&sig->group_rwsem);
>
>   *** DEADLOCK ***
>
>  no locks held by kswapd2/1151.
>
>  stack backtrace:
>  CPU: 30 PID: 1151 Comm: kswapd2 Not tainted 3.10.39+ #4
>  Call Trace:
>    dump_stack+0x19/0x1b
>    print_usage_bug+0x1f7/0x208
>    mark_lock+0x21d/0x2a0
>    __lock_acquire+0x52a/0xb60
>    lock_acquire+0xa2/0x140
>    down_read+0x51/0xa0
>    exit_signals+0x24/0x130
>    do_exit+0xb5/0xa50
>    kthread+0xdb/0x100
>    ret_from_fork+0x7c/0xb0

This is because the kswapd thread is still marked as a reclaimer at the
time of exit.  But because it is exiting, nobody is actually waiting on
it to make reclaim progress anymore, and it's nothing but a regular
thread at this point.  Be tidy and strip it of all its powers
(PF_MEMALLOC, PF_SWAPWRITE, PF_KSWAPD, and the lockdep reclaim state)
before returning from the thread function.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Reported-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
Cc: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Cc: Tang Chen <tangchen@cn.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 mm/vmscan.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 9cbc502..cfd005c 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -3056,7 +3056,10 @@ static int kswapd(void *p)
 		}
 	}
 
+	tsk->flags &= ~(PF_MEMALLOC | PF_SWAPWRITE | PF_KSWAPD);
 	current->reclaim_state = NULL;
+	lockdep_clear_current_reclaim_state();
+
 	return 0;
 }
 
-- 
1.9.1


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

* [PATCH 3.8 065/116] rtc: rtc-at91rm9200: fix infinite wait for ACKUPD irq
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (63 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 064/116] mm: vmscan: clear kswapd's special reclaim powers before exiting Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 066/116] ptrace: fix fork event messages across pid namespaces Kamal Mostafa
                   ` (50 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Boris BREZILLON, Andrew Victor, Nicolas Ferre,
	Jean-Christophe Plagniol-Villard, Alessandro Zummo,
	Andrew Morton, Linus Torvalds, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Boris BREZILLON <boris.brezillon@free-electrons.com>

commit 2fe121e1f5aa3bf31b418a9790db6c400e922291 upstream.

The rtc user must wait at least 1 sec between each time/calandar update
(see atmel's datasheet chapter "Updating Time/Calendar").

Use the 1Hz interrupt to update the at91_rtc_upd_rdy flag and wait for
the at91_rtc_wait_upd_rdy event if the rtc is not ready.

This patch fixes a deadlock in an uninterruptible wait when the RTC is
updated more than once every second.  AFAICT the bug is here from the
beginning, but I think we should at least backport this fix to 3.10 and
the following longterm and stable releases.

Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
Reported-by: Bryan Evenson <bevenson@melinkcorp.com>
Tested-by: Bryan Evenson <bevenson@melinkcorp.com>
Cc: Andrew Victor <linux@maxim.org.za>
Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/rtc/rtc-at91rm9200.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/rtc/rtc-at91rm9200.c b/drivers/rtc/rtc-at91rm9200.c
index 357da6b..243d8c7 100644
--- a/drivers/rtc/rtc-at91rm9200.c
+++ b/drivers/rtc/rtc-at91rm9200.c
@@ -41,6 +41,7 @@
 #define AT91_RTC_EPOCH		1900UL	/* just like arch/arm/common/rtctime.c */
 
 static DECLARE_COMPLETION(at91_rtc_updated);
+static DECLARE_COMPLETION(at91_rtc_upd_rdy);
 static unsigned int at91_alarm_year = AT91_RTC_EPOCH;
 static void __iomem *at91_rtc_regs;
 static int irq;
@@ -104,6 +105,8 @@ static int at91_rtc_settime(struct device *dev, struct rtc_time *tm)
 		1900 + tm->tm_year, tm->tm_mon, tm->tm_mday,
 		tm->tm_hour, tm->tm_min, tm->tm_sec);
 
+	wait_for_completion(&at91_rtc_upd_rdy);
+
 	/* Stop Time/Calendar from counting */
 	cr = at91_rtc_read(AT91_RTC_CR);
 	at91_rtc_write(AT91_RTC_CR, cr | AT91_RTC_UPDCAL | AT91_RTC_UPDTIM);
@@ -126,7 +129,9 @@ static int at91_rtc_settime(struct device *dev, struct rtc_time *tm)
 
 	/* Restart Time/Calendar */
 	cr = at91_rtc_read(AT91_RTC_CR);
+	at91_rtc_write(AT91_RTC_SCCR, AT91_RTC_SECEV);
 	at91_rtc_write(AT91_RTC_CR, cr & ~(AT91_RTC_UPDCAL | AT91_RTC_UPDTIM));
+	at91_rtc_write_ier(AT91_RTC_SECEV);
 
 	return 0;
 }
@@ -233,8 +238,10 @@ static irqreturn_t at91_rtc_interrupt(int irq, void *dev_id)
 	if (rtsr) {		/* this interrupt is shared!  Is it ours? */
 		if (rtsr & AT91_RTC_ALARM)
 			events |= (RTC_AF | RTC_IRQF);
-		if (rtsr & AT91_RTC_SECEV)
-			events |= (RTC_UF | RTC_IRQF);
+		if (rtsr & AT91_RTC_SECEV) {
+			complete(&at91_rtc_upd_rdy);
+			at91_rtc_write_idr(AT91_RTC_SECEV);
+		}
 		if (rtsr & AT91_RTC_ACKUPD)
 			complete(&at91_rtc_updated);
 
@@ -317,6 +324,11 @@ static int __init at91_rtc_probe(struct platform_device *pdev)
 	}
 	platform_set_drvdata(pdev, rtc);
 
+	/* enable SECEV interrupt in order to initialize at91_rtc_upd_rdy
+	 * completion.
+	 */
+	at91_rtc_write_ier(AT91_RTC_SECEV);
+
 	printk(KERN_INFO "AT91 Real Time Clock driver.\n");
 	return 0;
 
-- 
1.9.1


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

* [PATCH 3.8 066/116] ptrace: fix fork event messages across pid namespaces
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (64 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 065/116] rtc: rtc-at91rm9200: fix infinite wait for ACKUPD irq Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 067/116] idr: fix overflow bug during maximum ID calculation at maximum height Kamal Mostafa
                   ` (49 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Matthew Dempsky, Kees Cook, Julien Tinnes, Roland McGrath,
	Jan Kratochvil, Andrew Morton, Linus Torvalds, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Matthew Dempsky <mdempsky@chromium.org>

commit 4e52365f279564cef0ddd41db5237f0471381093 upstream.

When tracing a process in another pid namespace, it's important for fork
event messages to contain the child's pid as seen from the tracer's pid
namespace, not the parent's.  Otherwise, the tracer won't be able to
correlate the fork event with later SIGTRAP signals it receives from the
child.

We still risk a race condition if a ptracer from a different pid
namespace attaches after we compute the pid_t value.  However, sending a
bogus fork event message in this unlikely scenario is still a vast
improvement over the status quo where we always send bogus fork event
messages to debuggers in a different pid namespace than the forking
process.

Signed-off-by: Matthew Dempsky <mdempsky@chromium.org>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Julien Tinnes <jln@chromium.org>
Cc: Roland McGrath <mcgrathr@chromium.org>
Cc: Jan Kratochvil <jan.kratochvil@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 include/linux/ptrace.h | 32 ++++++++++++++++++++++++++++++++
 kernel/fork.c          | 10 +++++++---
 2 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h
index 89573a3..2e99b8e 100644
--- a/include/linux/ptrace.h
+++ b/include/linux/ptrace.h
@@ -5,6 +5,7 @@
 #include <linux/sched.h>		/* For struct task_struct.  */
 #include <linux/err.h>			/* for IS_ERR_VALUE */
 #include <linux/bug.h>			/* For BUG_ON.  */
+#include <linux/pid_namespace.h>	/* For task_active_pid_ns.  */
 #include <uapi/linux/ptrace.h>
 
 /*
@@ -129,6 +130,37 @@ static inline void ptrace_event(int event, unsigned long message)
 }
 
 /**
+ * ptrace_event_pid - possibly stop for a ptrace event notification
+ * @event:	%PTRACE_EVENT_* value to report
+ * @pid:	process identifier for %PTRACE_GETEVENTMSG to return
+ *
+ * Check whether @event is enabled and, if so, report @event and @pid
+ * to the ptrace parent.  @pid is reported as the pid_t seen from the
+ * the ptrace parent's pid namespace.
+ *
+ * Called without locks.
+ */
+static inline void ptrace_event_pid(int event, struct pid *pid)
+{
+	/*
+	 * FIXME: There's a potential race if a ptracer in a different pid
+	 * namespace than parent attaches between computing message below and
+	 * when we acquire tasklist_lock in ptrace_stop().  If this happens,
+	 * the ptracer will get a bogus pid from PTRACE_GETEVENTMSG.
+	 */
+	unsigned long message = 0;
+	struct pid_namespace *ns;
+
+	rcu_read_lock();
+	ns = task_active_pid_ns(rcu_dereference(current->parent));
+	if (ns)
+		message = pid_nr_ns(pid, ns);
+	rcu_read_unlock();
+
+	ptrace_event(event, message);
+}
+
+/**
  * ptrace_init_task - initialize ptrace state for a new child
  * @child:		new child task
  * @ptrace:		true if child should be ptrace'd by parent's tracer
diff --git a/kernel/fork.c b/kernel/fork.c
index 65b8b0a..e788b14 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1596,10 +1596,12 @@ long do_fork(unsigned long clone_flags,
 	 */
 	if (!IS_ERR(p)) {
 		struct completion vfork;
+		struct pid *pid;
 
 		trace_sched_process_fork(current, p);
 
-		nr = task_pid_vnr(p);
+		pid = get_task_pid(p, PIDTYPE_PID);
+		nr = pid_vnr(pid);
 
 		if (clone_flags & CLONE_PARENT_SETTID)
 			put_user(nr, parent_tidptr);
@@ -1614,12 +1616,14 @@ long do_fork(unsigned long clone_flags,
 
 		/* forking complete and child started to run, tell ptracer */
 		if (unlikely(trace))
-			ptrace_event(trace, nr);
+			ptrace_event_pid(trace, pid);
 
 		if (clone_flags & CLONE_VFORK) {
 			if (!wait_for_vfork_done(p, &vfork))
-				ptrace_event(PTRACE_EVENT_VFORK_DONE, nr);
+				ptrace_event_pid(PTRACE_EVENT_VFORK_DONE, pid);
 		}
+
+		put_pid(pid);
 	} else {
 		nr = PTR_ERR(p);
 	}
-- 
1.9.1


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

* [PATCH 3.8 067/116] idr: fix overflow bug during maximum ID calculation at maximum height
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (65 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 066/116] ptrace: fix fork event messages across pid namespaces Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 068/116] Input: elantech - deal with clickpads reporting right button events Kamal Mostafa
                   ` (48 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Lai Jiangshan, Andrew Morton, Linus Torvalds, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Lai Jiangshan <laijs@cn.fujitsu.com>

commit 3afb69cb5572b3c8c898c00880803cf1a49852c4 upstream.

idr_replace() open-codes the logic to calculate the maximum valid ID
given the height of the idr tree; unfortunately, the open-coded logic
doesn't account for the fact that the top layer may have unused slots
and over-shifts the limit to zero when the tree is at its maximum
height.

The following test code shows it fails to replace the value for
id=((1<<27)+42):

  static void test5(void)
  {
        int id;
        DEFINE_IDR(test_idr);
  #define TEST5_START ((1<<27)+42) /* use the highest layer */

        printk(KERN_INFO "Start test5\n");
        id = idr_alloc(&test_idr, (void *)1, TEST5_START, 0, GFP_KERNEL);
        BUG_ON(id != TEST5_START);
        TEST_BUG_ON(idr_replace(&test_idr, (void *)2, TEST5_START) != (void *)1);
        idr_destroy(&test_idr);
        printk(KERN_INFO "End of test5\n");
  }

Fix the bug by using idr_max() which correctly takes into account the
maximum allowed shift.

sub_alloc() shares the same problem and may incorrectly fail with
-EAGAIN; however, this bug doesn't affect correct operation because
idr_get_empty_slot(), which already uses idr_max(), retries with the
increased @id in such cases.

[tj@kernel.org: Updated patch description.]
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[ kamal: backport to 3.8-stable: context ]
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 lib/idr.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/lib/idr.c b/lib/idr.c
index 60f7619..fb49014 100644
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -167,7 +167,7 @@ static int sub_alloc(struct idr *idp, int *starting_id, struct idr_layer **pa)
 			id = (id | ((1 << (IDR_BITS * l)) - 1)) + 1;
 
 			/* if already at the top layer, we need to grow */
-			if (id >= 1 << (idp->layers * IDR_BITS)) {
+			if (id > idr_max(idp->layers)) {
 				*starting_id = id;
 				return IDR_NEED_TO_GROW;
 			}
@@ -672,14 +672,12 @@ void *idr_replace(struct idr *idp, void *ptr, int id)
 	if (!p)
 		return ERR_PTR(-EINVAL);
 
-	n = (p->layer+1) * IDR_BITS;
-
 	id &= MAX_IDR_MASK;
 
-	if (id >= (1 << n))
+	if (id > idr_max(p->layer + 1))
 		return ERR_PTR(-EINVAL);
 
-	n -= IDR_BITS;
+	n = p->layer * IDR_BITS;
 	while ((n > 0) && p) {
 		p = p->ary[(id >> n) & IDR_MASK];
 		n -= IDR_BITS;
-- 
1.9.1


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

* [PATCH 3.8 068/116] Input: elantech - deal with clickpads reporting right button events
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (66 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 067/116] idr: fix overflow bug during maximum ID calculation at maximum height Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 069/116] Input: elantech - don't set bit 1 of reg_10 when the no_hw_res quirk is set Kamal Mostafa
                   ` (47 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Hans de Goede, Dmitry Torokhov, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Hans de Goede <hdegoede@redhat.com>

commit cd9e83e2754465856097f31c7ab933ce74c473f8 upstream.

At least the Dell Vostro 5470 elantech *clickpad* reports right button
clicks when clicked in the right bottom area:

https://bugzilla.redhat.com/show_bug.cgi?id=1103528

This is different from how (elantech) clickpads normally operate, normally
no matter where the user clicks on the pad the pad always reports a left
button event, since there is only 1 hardware button beneath the path.

It looks like Dell has put 2 buttons under the pad, one under each bottom
corner, causing this.

Since this however still clearly is a real clickpad hardware-wise, we still
want to report it as such to userspace, so that things like finger movement
in the bottom area can be properly ignored as it should be on clickpads.

So deal with this weirdness by simply mapping a right click to a left click
on elantech clickpads. As an added advantage this is something which we can
simply do on all elantech clickpads, so no need to add special quirks for
this weird model.

Reported-and-tested-by: Elder Marco <eldermarco@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/input/mouse/elantech.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index c7bd58e..dc66ca8 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -473,8 +473,15 @@ static void elantech_report_absolute_v3(struct psmouse *psmouse,
 	input_report_key(dev, BTN_TOOL_FINGER, fingers == 1);
 	input_report_key(dev, BTN_TOOL_DOUBLETAP, fingers == 2);
 	input_report_key(dev, BTN_TOOL_TRIPLETAP, fingers == 3);
-	input_report_key(dev, BTN_LEFT, packet[0] & 0x01);
-	input_report_key(dev, BTN_RIGHT, packet[0] & 0x02);
+
+	/* For clickpads map both buttons to BTN_LEFT */
+	if (etd->fw_version & 0x001000) {
+		input_report_key(dev, BTN_LEFT, packet[0] & 0x03);
+	} else {
+		input_report_key(dev, BTN_LEFT, packet[0] & 0x01);
+		input_report_key(dev, BTN_RIGHT, packet[0] & 0x02);
+	}
+
 	input_report_abs(dev, ABS_PRESSURE, pres);
 	input_report_abs(dev, ABS_TOOL_WIDTH, width);
 
@@ -484,9 +491,17 @@ static void elantech_report_absolute_v3(struct psmouse *psmouse,
 static void elantech_input_sync_v4(struct psmouse *psmouse)
 {
 	struct input_dev *dev = psmouse->dev;
+	struct elantech_data *etd = psmouse->private;
 	unsigned char *packet = psmouse->packet;
 
-	input_report_key(dev, BTN_LEFT, packet[0] & 0x01);
+	/* For clickpads map both buttons to BTN_LEFT */
+	if (etd->fw_version & 0x001000) {
+		input_report_key(dev, BTN_LEFT, packet[0] & 0x03);
+	} else {
+		input_report_key(dev, BTN_LEFT, packet[0] & 0x01);
+		input_report_key(dev, BTN_RIGHT, packet[0] & 0x02);
+	}
+
 	input_mt_report_pointer_emulation(dev, true);
 	input_sync(dev);
 }
-- 
1.9.1


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

* [PATCH 3.8 069/116] Input: elantech - don't set bit 1 of reg_10 when the no_hw_res quirk is set
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (67 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 068/116] Input: elantech - deal with clickpads reporting right button events Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 070/116] nfsd4: fix FREE_STATEID lockowner leak Kamal Mostafa
                   ` (46 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Hans de Goede, Dmitry Torokhov, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Hans de Goede <hdegoede@redhat.com>

commit fb4f8f568a9def02240ef9bf7aabd246dc63a081 upstream.

The touchpad on the GIGABYTE U2442 not only stops communicating when we try
to set bit 3 (enable real hardware resolution) of reg_10, but on some BIOS
versions also when we set bit 1 (enable two finger mode auto correct).

I've asked the original reporter of:
https://bugzilla.kernel.org/show_bug.cgi?id=61151

To check that not setting bit 1 does not lead to any adverse effects on his
model / BIOS revision, and it does not, so this commit fixes the touchpad
not working on these versions by simply never setting bit 1 for laptop
models with the no_hw_res quirk.

Reported-and-tested-by: James Lademann <jwlademann@gmail.com>
Tested-by: Philipp Wolfer <ph.wolfer@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/input/mouse/elantech.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index dc66ca8..729f75d 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -819,7 +819,7 @@ static int elantech_set_absolute_mode(struct psmouse *psmouse)
 		if (etd->set_hw_resolution)
 			etd->reg_10 = 0x0b;
 		else
-			etd->reg_10 = 0x03;
+			etd->reg_10 = 0x01;
 
 		if (elantech_write_reg(psmouse, 0x10, etd->reg_10))
 			rc = -1;
@@ -1282,7 +1282,8 @@ static int elantech_reconnect(struct psmouse *psmouse)
 }
 
 /*
- * Some hw_version 3 models go into error state when we try to set bit 3 of r10
+ * Some hw_version 3 models go into error state when we try to set
+ * bit 3 and/or bit 1 of r10.
  */
 static const struct dmi_system_id no_hw_res_dmi_table[] = {
 #if defined(CONFIG_DMI) && defined(CONFIG_X86)
-- 
1.9.1


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

* [PATCH 3.8 070/116] nfsd4: fix FREE_STATEID lockowner leak
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (68 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 069/116] Input: elantech - don't set bit 1 of reg_10 when the no_hw_res quirk is set Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 071/116] Btrfs: fix double free in find_lock_delalloc_range Kamal Mostafa
                   ` (45 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: J. Bruce Fields, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: "J. Bruce Fields" <bfields@redhat.com>

commit 48385408b45523d9a432c66292d47ef43efcbb94 upstream.

27b11428b7de ("nfsd4: remove lockowner when removing lock stateid")
introduced a memory leak.

Reported-by: Jeff Layton <jeff.layton@primarydata.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 fs/nfsd/nfs4state.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index d5e1349..5986138 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -3520,7 +3520,7 @@ nfsd4_free_lock_stateid(struct nfs4_ol_stateid *stp)
 	 * correspondance, and we have to delete the lockowner when we
 	 * delete the lock stateid:
 	 */
-	unhash_lockowner(lo);
+	release_lockowner(lo);
 	return nfs_ok;
 }
 
-- 
1.9.1


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

* [PATCH 3.8 071/116] Btrfs: fix double free in find_lock_delalloc_range
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (69 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 070/116] nfsd4: fix FREE_STATEID lockowner leak Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 072/116] NFS: populate ->net in mount data when remounting Kamal Mostafa
                   ` (44 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Chris Mason, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Chris Mason <clm@fb.com>

commit 7d78874273463a784759916fc3e0b4e2eb141c70 upstream.

We need to NULL the cached_state after freeing it, otherwise
we might free it again if find_delalloc_range doesn't find anything.

Signed-off-by: Chris Mason <clm@fb.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 fs/btrfs/extent_io.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 125397e..0a800dc 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -1595,6 +1595,7 @@ again:
 		 * shortening the size of the delalloc range we're searching
 		 */
 		free_extent_state(cached_state);
+		cached_state = NULL;
 		if (!loops) {
 			unsigned long offset = (*start) & (PAGE_CACHE_SIZE - 1);
 			max_bytes = PAGE_CACHE_SIZE - offset;
-- 
1.9.1


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

* [PATCH 3.8 072/116] NFS: populate ->net in mount data when remounting
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (70 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 071/116] Btrfs: fix double free in find_lock_delalloc_range Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 073/116] auditsc: audit_krule mask accesses need bounds checking Kamal Mostafa
                   ` (43 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Mateusz Guzik, linux-nfs, Trond Myklebust, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Mateusz Guzik <mguzik@redhat.com>

commit a914722f333b3359d2f4f12919380a334176bb89 upstream.

Otherwise the kernel oopses when remounting with IPv6 server because
net is dereferenced in dev_get_by_name.

Use net ns of current thread so that dev_get_by_name does not operate on
foreign ns. Changing the address is prohibited anyway so this should not
affect anything.

Signed-off-by: Mateusz Guzik <mguzik@redhat.com>
Cc: linux-nfs@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 fs/nfs/super.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index b056b16..f4d000a 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -2167,6 +2167,7 @@ nfs_remount(struct super_block *sb, int *flags, char *raw_data)
 	data->timeo = 10U * nfss->client->cl_timeout->to_initval / HZ;
 	data->nfs_server.port = nfss->port;
 	data->nfs_server.addrlen = nfss->nfs_client->cl_addrlen;
+	data->net = current->nsproxy->net_ns;
 	memcpy(&data->nfs_server.address, &nfss->nfs_client->cl_addr,
 		data->nfs_server.addrlen);
 
-- 
1.9.1


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

* [PATCH 3.8 073/116] auditsc: audit_krule mask accesses need bounds checking
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (71 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 072/116] NFS: populate ->net in mount data when remounting Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 074/116] watchdog: ath79_wdt: avoid spurious restarts on AR934x Kamal Mostafa
                   ` (42 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Andy Lutomirski, Eric Paris, Linus Torvalds, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Andy Lutomirski <luto@amacapital.net>

commit a3c54931199565930d6d84f4c3456f6440aefd41 upstream.

Fixes an easy DoS and possible information disclosure.

This does nothing about the broken state of x32 auditing.

eparis: If the admin has enabled auditd and has specifically loaded
audit rules.  This bug has been around since before git.  Wow...

Signed-off-by: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: Eric Paris <eparis@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 kernel/auditsc.c | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index ba198b1..999a48d 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -859,6 +859,22 @@ static enum audit_state audit_filter_task(struct task_struct *tsk, char **key)
 	return AUDIT_BUILD_CONTEXT;
 }
 
+static int audit_in_mask(const struct audit_krule *rule, unsigned long val)
+{
+	int word, bit;
+
+	if (val > 0xffffffff)
+		return false;
+
+	word = AUDIT_WORD(val);
+	if (word >= AUDIT_BITMASK_SIZE)
+		return false;
+
+	bit = AUDIT_BIT(val);
+
+	return rule->mask[word] & bit;
+}
+
 /* At syscall entry and exit time, this filter is called if the
  * audit_state is not low enough that auditing cannot take place, but is
  * also not high enough that we already know we have to write an audit
@@ -876,11 +892,8 @@ static enum audit_state audit_filter_syscall(struct task_struct *tsk,
 
 	rcu_read_lock();
 	if (!list_empty(list)) {
-		int word = AUDIT_WORD(ctx->major);
-		int bit  = AUDIT_BIT(ctx->major);
-
 		list_for_each_entry_rcu(e, list, list) {
-			if ((e->rule.mask[word] & bit) == bit &&
+			if (audit_in_mask(&e->rule, ctx->major) &&
 			    audit_filter_rules(tsk, &e->rule, ctx, NULL,
 					       &state, false)) {
 				rcu_read_unlock();
@@ -900,20 +913,16 @@ static enum audit_state audit_filter_syscall(struct task_struct *tsk,
 static int audit_filter_inode_name(struct task_struct *tsk,
 				   struct audit_names *n,
 				   struct audit_context *ctx) {
-	int word, bit;
 	int h = audit_hash_ino((u32)n->ino);
 	struct list_head *list = &audit_inode_hash[h];
 	struct audit_entry *e;
 	enum audit_state state;
 
-	word = AUDIT_WORD(ctx->major);
-	bit  = AUDIT_BIT(ctx->major);
-
 	if (list_empty(list))
 		return 0;
 
 	list_for_each_entry_rcu(e, list, list) {
-		if ((e->rule.mask[word] & bit) == bit &&
+		if (audit_in_mask(&e->rule, ctx->major) &&
 		    audit_filter_rules(tsk, &e->rule, ctx, n, &state, false)) {
 			ctx->current_state = state;
 			return 1;
-- 
1.9.1


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

* [PATCH 3.8 074/116] watchdog: ath79_wdt: avoid spurious restarts on AR934x
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (72 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 073/116] auditsc: audit_krule mask accesses need bounds checking Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 075/116] watchdog: sp805: Set watchdog_device->timeout from ->set_timeout() Kamal Mostafa
                   ` (41 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Gabor Juhos, Wim Van Sebroeck, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Gabor Juhos <juhosg@openwrt.org>

commit 23afeb613ec0e10aecfae7838a14d485db62ac52 upstream.

On some AR934x based systems, where the frequency of
the AHB bus is relatively high, the built-in watchdog
causes a spurious restart when it gets enabled.

The possible cause of these restarts is that the timeout
value written into the TIMER register does not reaches
the hardware in time.

Add an explicit delay into the ath79_wdt_enable function
to avoid the spurious restarts.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/watchdog/ath79_wdt.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/watchdog/ath79_wdt.c b/drivers/watchdog/ath79_wdt.c
index 38a999e..bb242bd 100644
--- a/drivers/watchdog/ath79_wdt.c
+++ b/drivers/watchdog/ath79_wdt.c
@@ -20,6 +20,7 @@
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include <linux/bitops.h>
+#include <linux/delay.h>
 #include <linux/errno.h>
 #include <linux/fs.h>
 #include <linux/init.h>
@@ -77,6 +78,15 @@ static inline void ath79_wdt_keepalive(void)
 static inline void ath79_wdt_enable(void)
 {
 	ath79_wdt_keepalive();
+
+	/*
+	 * Updating the TIMER register requires a few microseconds
+	 * on the AR934x SoCs at least. Use a small delay to ensure
+	 * that the TIMER register is updated within the hardware
+	 * before enabling the watchdog.
+	 */
+	udelay(2);
+
 	ath79_reset_wr(AR71XX_RESET_REG_WDOG_CTRL, WDOG_CTRL_ACTION_FCR);
 	/* flush write */
 	ath79_reset_rr(AR71XX_RESET_REG_WDOG_CTRL);
-- 
1.9.1


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

* [PATCH 3.8 075/116] watchdog: sp805: Set watchdog_device->timeout from ->set_timeout()
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (73 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 074/116] watchdog: ath79_wdt: avoid spurious restarts on AR934x Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 076/116] xfs: ioctl check for capabilities in the current user namespace Kamal Mostafa
                   ` (40 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Viresh Kumar, Wim Van Sebroeck, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Viresh Kumar <viresh.kumar@linaro.org>

commit 938626d96a3ffb9eb54552bb0d3a4f2b30ffdeb0 upstream.

Implementation of ->set_timeout() is supposed to set 'timeout' field of 'struct
watchdog_device' passed to it. sp805 was rather setting this in a local
variable. Fix it.

Reported-by: Arun Ramamurthy <arun.ramamurthy@broadcom.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/watchdog/sp805_wdt.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/watchdog/sp805_wdt.c b/drivers/watchdog/sp805_wdt.c
index 8872642..e421182 100644
--- a/drivers/watchdog/sp805_wdt.c
+++ b/drivers/watchdog/sp805_wdt.c
@@ -60,7 +60,6 @@
  * @adev: amba device structure of wdt
  * @status: current status of wdt
  * @load_val: load value to be set for current timeout
- * @timeout: current programmed timeout
  */
 struct sp805_wdt {
 	struct watchdog_device		wdd;
@@ -69,7 +68,6 @@ struct sp805_wdt {
 	struct clk			*clk;
 	struct amba_device		*adev;
 	unsigned int			load_val;
-	unsigned int			timeout;
 };
 
 static bool nowayout = WATCHDOG_NOWAYOUT;
@@ -99,7 +97,7 @@ static int wdt_setload(struct watchdog_device *wdd, unsigned int timeout)
 	spin_lock(&wdt->lock);
 	wdt->load_val = load;
 	/* roundup timeout to closest positive integer value */
-	wdt->timeout = div_u64((load + 1) * 2 + (rate / 2), rate);
+	wdd->timeout = div_u64((load + 1) * 2 + (rate / 2), rate);
 	spin_unlock(&wdt->lock);
 
 	return 0;
-- 
1.9.1


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

* [PATCH 3.8 076/116] xfs: ioctl check for capabilities in the current user namespace
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (74 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 075/116] watchdog: sp805: Set watchdog_device->timeout from ->set_timeout() Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 23:12   ` Dave Chinner
  2014-07-22 22:21 ` [PATCH 3.8 077/116] fs,userns: Change inode_capable to capable_wrt_inode_uidgid Kamal Mostafa
                   ` (39 subsequent siblings)
  115 siblings, 1 reply; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Dwight Engen, Ben Myers, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Dwight Engen <dwight.engen@oracle.com>

commit fd5e2aa8653665ae1cc60f7aca1069abdbcad3f6 upstream.

Use inode_capable() to check if SUID|SGID bits should be cleared to match
similar check in inode_change_ok().

The check for CAP_LINUX_IMMUTABLE was not modified since all other file
systems also check against init_user_ns rather than current_user_ns.

Only allow changing of projid from init_user_ns.

Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Gao feng <gaofeng@cn.fujitsu.com>
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
[ kamal: 3.8-stable prereq for
  23adbe1 fs,userns: Change inode_capable to capable_wrt_inode_uidgid ]
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 fs/xfs/xfs_ioctl.c  | 11 +++++++++--
 kernel/capability.c |  1 +
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index cdaef2d..ec74a78 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -976,15 +976,22 @@ xfs_ioctl_setattr(
 	 * to the file owner ID, except in cases where the
 	 * CAP_FSETID capability is applicable.
 	 */
-	if (current_fsuid() != ip->i_d.di_uid && !capable(CAP_FOWNER)) {
+	if (!inode_owner_or_capable(VFS_I(ip))) {
 		code = XFS_ERROR(EPERM);
 		goto error_return;
 	}
 
 	/*
 	 * Do a quota reservation only if projid is actually going to change.
+	 * Only allow changing of projid from init_user_ns since it is a
+	 * non user namespace aware identifier.
 	 */
 	if (mask & FSX_PROJID) {
+		if (current_user_ns() != &init_user_ns) {
+			code = XFS_ERROR(EINVAL);
+			goto error_return;
+		}
+
 		if (XFS_IS_QUOTA_RUNNING(mp) &&
 		    XFS_IS_PQUOTA_ON(mp) &&
 		    xfs_get_projid(ip) != fa->fsx_projid) {
@@ -1098,7 +1105,7 @@ xfs_ioctl_setattr(
 		 * cleared upon successful return from chown()
 		 */
 		if ((ip->i_d.di_mode & (S_ISUID|S_ISGID)) &&
-		    !capable(CAP_FSETID))
+		    !inode_capable(VFS_I(ip), CAP_FSETID))
 			ip->i_d.di_mode &= ~(S_ISUID|S_ISGID);
 
 		/*
diff --git a/kernel/capability.c b/kernel/capability.c
index f6c2ce5..a4b6744 100644
--- a/kernel/capability.c
+++ b/kernel/capability.c
@@ -464,3 +464,4 @@ bool inode_capable(const struct inode *inode, int cap)
 
 	return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
 }
+EXPORT_SYMBOL(inode_capable);
-- 
1.9.1


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

* [PATCH 3.8 077/116] fs,userns: Change inode_capable to capable_wrt_inode_uidgid
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (75 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 076/116] xfs: ioctl check for capabilities in the current user namespace Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 078/116] powerpc: Don't setup CPUs with bad status Kamal Mostafa
                   ` (38 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Theodore Ts'o, Serge Hallyn, Eric W. Biederman, Dave Chinner,
	Andy Lutomirski, Linus Torvalds, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Andy Lutomirski <luto@amacapital.net>

commit 23adbe12ef7d3d4195e80800ab36b37bee28cd03 upstream.

The kernel has no concept of capabilities with respect to inodes; inodes
exist independently of namespaces.  For example, inode_capable(inode,
CAP_LINUX_IMMUTABLE) would be nonsense.

This patch changes inode_capable to check for uid and gid mappings and
renames it to capable_wrt_inode_uidgid, which should make it more
obvious what it does.

Fixes CVE-2014-4014.

Cc: Theodore Ts'o <tytso@mit.edu>
Cc: Serge Hallyn <serge.hallyn@ubuntu.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Dave Chinner <david@fromorbit.com>
Signed-off-by: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 fs/attr.c                  |  8 ++++----
 fs/inode.c                 | 10 +++++++---
 fs/namei.c                 | 11 ++++++-----
 fs/xfs/xfs_ioctl.c         |  2 +-
 include/linux/capability.h |  2 +-
 kernel/capability.c        | 20 ++++++++------------
 6 files changed, 27 insertions(+), 26 deletions(-)

diff --git a/fs/attr.c b/fs/attr.c
index 1449adb..6a54f13 100644
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -50,14 +50,14 @@ int inode_change_ok(const struct inode *inode, struct iattr *attr)
 	if ((ia_valid & ATTR_UID) &&
 	    (!uid_eq(current_fsuid(), inode->i_uid) ||
 	     !uid_eq(attr->ia_uid, inode->i_uid)) &&
-	    !inode_capable(inode, CAP_CHOWN))
+	    !capable_wrt_inode_uidgid(inode, CAP_CHOWN))
 		return -EPERM;
 
 	/* Make sure caller can chgrp. */
 	if ((ia_valid & ATTR_GID) &&
 	    (!uid_eq(current_fsuid(), inode->i_uid) ||
 	    (!in_group_p(attr->ia_gid) && !gid_eq(attr->ia_gid, inode->i_gid))) &&
-	    !inode_capable(inode, CAP_CHOWN))
+	    !capable_wrt_inode_uidgid(inode, CAP_CHOWN))
 		return -EPERM;
 
 	/* Make sure a caller can chmod. */
@@ -67,7 +67,7 @@ int inode_change_ok(const struct inode *inode, struct iattr *attr)
 		/* Also check the setgid bit! */
 		if (!in_group_p((ia_valid & ATTR_GID) ? attr->ia_gid :
 				inode->i_gid) &&
-		    !inode_capable(inode, CAP_FSETID))
+		    !capable_wrt_inode_uidgid(inode, CAP_FSETID))
 			attr->ia_mode &= ~S_ISGID;
 	}
 
@@ -160,7 +160,7 @@ void setattr_copy(struct inode *inode, const struct iattr *attr)
 		umode_t mode = attr->ia_mode;
 
 		if (!in_group_p(inode->i_gid) &&
-		    !inode_capable(inode, CAP_FSETID))
+		    !capable_wrt_inode_uidgid(inode, CAP_FSETID))
 			mode &= ~S_ISGID;
 		inode->i_mode = mode;
 	}
diff --git a/fs/inode.c b/fs/inode.c
index b98540e..2e4031e 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -1842,14 +1842,18 @@ EXPORT_SYMBOL(inode_init_owner);
  * inode_owner_or_capable - check current task permissions to inode
  * @inode: inode being checked
  *
- * Return true if current either has CAP_FOWNER to the inode, or
- * owns the file.
+ * Return true if current either has CAP_FOWNER in a namespace with the
+ * inode owner uid mapped, or owns the file.
  */
 bool inode_owner_or_capable(const struct inode *inode)
 {
+	struct user_namespace *ns;
+
 	if (uid_eq(current_fsuid(), inode->i_uid))
 		return true;
-	if (inode_capable(inode, CAP_FOWNER))
+
+	ns = current_user_ns();
+	if (ns_capable(ns, CAP_FOWNER) && kuid_has_mapping(ns, inode->i_uid))
 		return true;
 	return false;
 }
diff --git a/fs/namei.c b/fs/namei.c
index 77dc200..8bbff22 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -321,10 +321,11 @@ int generic_permission(struct inode *inode, int mask)
 
 	if (S_ISDIR(inode->i_mode)) {
 		/* DACs are overridable for directories */
-		if (inode_capable(inode, CAP_DAC_OVERRIDE))
+		if (capable_wrt_inode_uidgid(inode, CAP_DAC_OVERRIDE))
 			return 0;
 		if (!(mask & MAY_WRITE))
-			if (inode_capable(inode, CAP_DAC_READ_SEARCH))
+			if (capable_wrt_inode_uidgid(inode,
+						     CAP_DAC_READ_SEARCH))
 				return 0;
 		return -EACCES;
 	}
@@ -334,7 +335,7 @@ int generic_permission(struct inode *inode, int mask)
 	 * at least one exec bit set.
 	 */
 	if (!(mask & MAY_EXEC) || (inode->i_mode & S_IXUGO))
-		if (inode_capable(inode, CAP_DAC_OVERRIDE))
+		if (capable_wrt_inode_uidgid(inode, CAP_DAC_OVERRIDE))
 			return 0;
 
 	/*
@@ -342,7 +343,7 @@ int generic_permission(struct inode *inode, int mask)
 	 */
 	mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
 	if (mask == MAY_READ)
-		if (inode_capable(inode, CAP_DAC_READ_SEARCH))
+		if (capable_wrt_inode_uidgid(inode, CAP_DAC_READ_SEARCH))
 			return 0;
 
 	return -EACCES;
@@ -2208,7 +2209,7 @@ static inline int check_sticky(struct inode *dir, struct inode *inode)
 		return 0;
 	if (uid_eq(dir->i_uid, fsuid))
 		return 0;
-	return !inode_capable(inode, CAP_FOWNER);
+	return !capable_wrt_inode_uidgid(inode, CAP_FOWNER);
 }
 
 /*
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index ec74a78..272a458 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -1105,7 +1105,7 @@ xfs_ioctl_setattr(
 		 * cleared upon successful return from chown()
 		 */
 		if ((ip->i_d.di_mode & (S_ISUID|S_ISGID)) &&
-		    !inode_capable(VFS_I(ip), CAP_FSETID))
+		    !capable_wrt_inode_uidgid(VFS_I(ip), CAP_FSETID))
 			ip->i_d.di_mode &= ~(S_ISUID|S_ISGID);
 
 		/*
diff --git a/include/linux/capability.h b/include/linux/capability.h
index d9a4f7f..15f9092 100644
--- a/include/linux/capability.h
+++ b/include/linux/capability.h
@@ -211,7 +211,7 @@ extern bool has_ns_capability_noaudit(struct task_struct *t,
 extern bool capable(int cap);
 extern bool ns_capable(struct user_namespace *ns, int cap);
 extern bool nsown_capable(int cap);
-extern bool inode_capable(const struct inode *inode, int cap);
+extern bool capable_wrt_inode_uidgid(const struct inode *inode, int cap);
 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
 
 /* audit system wants to get cap info from files as well */
diff --git a/kernel/capability.c b/kernel/capability.c
index a4b6744..4ba8734 100644
--- a/kernel/capability.c
+++ b/kernel/capability.c
@@ -445,23 +445,19 @@ bool nsown_capable(int cap)
 }
 
 /**
- * inode_capable - Check superior capability over inode
+ * capable_wrt_inode_uidgid - Check nsown_capable and uid and gid mapped
  * @inode: The inode in question
  * @cap: The capability in question
  *
- * Return true if the current task has the given superior capability
- * targeted at it's own user namespace and that the given inode is owned
- * by the current user namespace or a child namespace.
- *
- * Currently we check to see if an inode is owned by the current
- * user namespace by seeing if the inode's owner maps into the
- * current user namespace.
- *
+ * Return true if the current task has the given capability targeted at
+ * its own user namespace and that the given inode's uid and gid are
+ * mapped into the current user namespace.
  */
-bool inode_capable(const struct inode *inode, int cap)
+bool capable_wrt_inode_uidgid(const struct inode *inode, int cap)
 {
 	struct user_namespace *ns = current_user_ns();
 
-	return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
+	return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid) &&
+		kgid_has_mapping(ns, inode->i_gid);
 }
-EXPORT_SYMBOL(inode_capable);
+EXPORT_SYMBOL(capable_wrt_inode_uidgid);
-- 
1.9.1


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

* [PATCH 3.8 078/116] powerpc: Don't setup CPUs with bad status
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (76 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 077/116] fs,userns: Change inode_capable to capable_wrt_inode_uidgid Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 079/116] dm thin: update discard_granularity to reflect the thin-pool blocksize Kamal Mostafa
                   ` (37 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Michael Neuling, Benjamin Herrenschmidt, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Michael Neuling <mikey@neuling.org>

commit 59a53afe70fd530040bdc69581f03d880157f15a upstream.

OPAL will mark a CPU that is guarded as "bad" in the status property of the CPU
node.

Unfortunatley Linux doesn't check this property and will put the bad CPU in the
present map.  This has caused hangs on booting when we try to unsplit the core.

This patch checks the CPU is avaliable via this status property before putting
it in the present map.

Signed-off-by: Michael Neuling <mikey@neuling.org>
Tested-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 arch/powerpc/kernel/setup-common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index bdc499c..b050263 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -457,7 +457,7 @@ void __init smp_setup_cpu_maps(void)
 		for (j = 0; j < nthreads && cpu < nr_cpu_ids; j++) {
 			DBG("    thread %d -> cpu %d (hard id %d)\n",
 			    j, cpu, intserv[j]);
-			set_cpu_present(cpu, true);
+			set_cpu_present(cpu, of_device_is_available(dn));
 			set_hard_smp_processor_id(cpu, intserv[j]);
 			set_cpu_possible(cpu, true);
 			cpu++;
-- 
1.9.1


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

* [PATCH 3.8 079/116] dm thin: update discard_granularity to reflect the thin-pool blocksize
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (77 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 078/116] powerpc: Don't setup CPUs with bad status Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 080/116] ALSA: compress: Cancel the optimization of compiler and fix the size of struct for all platform Kamal Mostafa
                   ` (36 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Lukas Czerner, Mike Snitzer, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Lukas Czerner <lczerner@redhat.com>

commit 09869de57ed2728ae3c619803932a86cb0e2c4f8 upstream.

DM thinp already checks whether the discard_granularity of the data
device is a factor of the thin-pool block size.  But when using the
dm-thin-pool's discard passdown support, DM thinp was not selecting the
max of the underlying data device's discard_granularity and the
thin-pool's block size.

Update set_discard_limits() to set discard_granularity to the max of
these values.  This enables blkdev_issue_discard() to properly align the
discards that are sent to the DM thin device on a full block boundary.
As such each discard will now cover an entire DM thin-pool block and the
block will be reclaimed.

Reported-by: Zdenek Kabelac <zkabelac@redhat.com>
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/md/dm-thin.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
index ca954b1..3d183ca 100644
--- a/drivers/md/dm-thin.c
+++ b/drivers/md/dm-thin.c
@@ -2479,7 +2479,8 @@ static void set_discard_limits(struct pool_c *pt, struct queue_limits *limits)
 	 */
 	if (pt->adjusted_pf.discard_passdown) {
 		data_limits = &bdev_get_queue(pt->data_dev->bdev)->limits;
-		limits->discard_granularity = data_limits->discard_granularity;
+		limits->discard_granularity = max(data_limits->discard_granularity,
+						  pool->sectors_per_block << SECTOR_SHIFT);
 	} else if (block_size_is_power_of_two(pool))
 		limits->discard_granularity = pool->sectors_per_block << SECTOR_SHIFT;
 	else
-- 
1.9.1


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

* [PATCH 3.8 080/116] ALSA: compress: Cancel the optimization of compiler and fix the size of struct for all platform.
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (78 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 079/116] dm thin: update discard_granularity to reflect the thin-pool blocksize Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 081/116] evm: prohibit userspace writing 'security.evm' HMAC value Kamal Mostafa
                   ` (35 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Zhang Dongxing, xiaoming wang, Takashi Iwai, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: "Wang, Xiaoming" <xiaoming.wang@intel.com>

commit 2bd0ae464a6cf7363bbf72c8545e0aa43caa57f0 upstream.

Cancel the optimization of compiler for struct snd_compr_avail
which size will be 0x1c in 32bit kernel while 0x20 in 64bit
kernel under the optimizer. That will make compaction between
32bit and 64bit. So add packed to fix the size of struct
snd_compr_avail to 0x1c for all platform.

Signed-off-by: Zhang Dongxing <dongxing.zhang@intel.com>
Signed-off-by: xiaoming wang <xiaoming.wang@intel.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 include/uapi/sound/compress_offload.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/uapi/sound/compress_offload.h b/include/uapi/sound/compress_offload.h
index 9aa8624..9c94dd8 100644
--- a/include/uapi/sound/compress_offload.h
+++ b/include/uapi/sound/compress_offload.h
@@ -80,7 +80,7 @@ struct snd_compr_tstamp {
 struct snd_compr_avail {
 	__u64 avail;
 	struct snd_compr_tstamp tstamp;
-};
+} __attribute__((packed));
 
 enum snd_compr_direction {
 	SND_COMPRESS_PLAYBACK = 0,
-- 
1.9.1


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

* [PATCH 3.8 081/116] evm: prohibit userspace writing 'security.evm' HMAC value
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (79 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 080/116] ALSA: compress: Cancel the optimization of compiler and fix the size of struct for all platform Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 082/116] ima: introduce ima_kernel_read() Kamal Mostafa
                   ` (34 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Mimi Zohar, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Mimi Zohar <zohar@linux.vnet.ibm.com>

commit 2fb1c9a4f2dbc2f0bd2431c7fa64d0b5483864e4 upstream.

Calculating the 'security.evm' HMAC value requires access to the
EVM encrypted key.  Only the kernel should have access to it.  This
patch prevents userspace tools(eg. setfattr, cp --preserve=xattr)
from setting/modifying the 'security.evm' HMAC value directly.

Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 security/integrity/evm/evm_main.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c
index eb54845..1db13b3 100644
--- a/security/integrity/evm/evm_main.c
+++ b/security/integrity/evm/evm_main.c
@@ -274,12 +274,20 @@ static int evm_protect_xattr(struct dentry *dentry, const char *xattr_name,
  * @xattr_value: pointer to the new extended attribute value
  * @xattr_value_len: pointer to the new extended attribute value length
  *
- * Updating 'security.evm' requires CAP_SYS_ADMIN privileges and that
- * the current value is valid.
+ * Before allowing the 'security.evm' protected xattr to be updated,
+ * verify the existing value is valid.  As only the kernel should have
+ * access to the EVM encrypted key needed to calculate the HMAC, prevent
+ * userspace from writing HMAC value.  Writing 'security.evm' requires
+ * requires CAP_SYS_ADMIN privileges.
  */
 int evm_inode_setxattr(struct dentry *dentry, const char *xattr_name,
 		       const void *xattr_value, size_t xattr_value_len)
 {
+	const struct evm_ima_xattr_data *xattr_data = xattr_value;
+
+	if ((strcmp(xattr_name, XATTR_NAME_EVM) == 0)
+	    && (xattr_data->type == EVM_XATTR_HMAC))
+		return -EPERM;
 	return evm_protect_xattr(dentry, xattr_name, xattr_value,
 				 xattr_value_len);
 }
-- 
1.9.1


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

* [PATCH 3.8 082/116] ima: introduce ima_kernel_read()
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (80 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 081/116] evm: prohibit userspace writing 'security.evm' HMAC value Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 083/116] staging: iio: tsl2x7x_core: fix proximity treshold Kamal Mostafa
                   ` (33 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Dmitry Kasatkin, Mimi Zohar, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Dmitry Kasatkin <d.kasatkin@samsung.com>

commit 0430e49b6e7c6b5e076be8fefdee089958c9adad upstream.

Commit 8aac62706 "move exit_task_namespaces() outside of exit_notify"
introduced the kernel opps since the kernel v3.10, which happens when
Apparmor and IMA-appraisal are enabled at the same time.

----------------------------------------------------------------------
[  106.750167] BUG: unable to handle kernel NULL pointer dereference at
0000000000000018
[  106.750221] IP: [<ffffffff811ec7da>] our_mnt+0x1a/0x30
[  106.750241] PGD 0
[  106.750254] Oops: 0000 [#1] SMP
[  106.750272] Modules linked in: cuse parport_pc ppdev bnep rfcomm
bluetooth rpcsec_gss_krb5 nfsd auth_rpcgss nfs_acl nfs lockd sunrpc
fscache dm_crypt intel_rapl x86_pkg_temp_thermal intel_powerclamp
kvm_intel snd_hda_codec_hdmi kvm crct10dif_pclmul crc32_pclmul
ghash_clmulni_intel aesni_intel aes_x86_64 glue_helper lrw gf128mul
ablk_helper cryptd snd_hda_codec_realtek dcdbas snd_hda_intel
snd_hda_codec snd_hwdep snd_pcm snd_page_alloc snd_seq_midi
snd_seq_midi_event snd_rawmidi psmouse snd_seq microcode serio_raw
snd_timer snd_seq_device snd soundcore video lpc_ich coretemp mac_hid lp
parport mei_me mei nbd hid_generic e1000e usbhid ahci ptp hid libahci
pps_core
[  106.750658] CPU: 6 PID: 1394 Comm: mysqld Not tainted 3.13.0-rc7-kds+ #15
[  106.750673] Hardware name: Dell Inc. OptiPlex 9010/0M9KCM, BIOS A08
09/19/2012
[  106.750689] task: ffff8800de804920 ti: ffff880400fca000 task.ti:
ffff880400fca000
[  106.750704] RIP: 0010:[<ffffffff811ec7da>]  [<ffffffff811ec7da>]
our_mnt+0x1a/0x30
[  106.750725] RSP: 0018:ffff880400fcba60  EFLAGS: 00010286
[  106.750738] RAX: 0000000000000000 RBX: 0000000000000100 RCX:
ffff8800d51523e7
[  106.750764] RDX: ffffffffffffffea RSI: ffff880400fcba34 RDI:
ffff880402d20020
[  106.750791] RBP: ffff880400fcbae0 R08: 0000000000000000 R09:
0000000000000001
[  106.750817] R10: 0000000000000000 R11: 0000000000000001 R12:
ffff8800d5152300
[  106.750844] R13: ffff8803eb8df510 R14: ffff880400fcbb28 R15:
ffff8800d51523e7
[  106.750871] FS:  0000000000000000(0000) GS:ffff88040d200000(0000)
knlGS:0000000000000000
[  106.750910] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  106.750935] CR2: 0000000000000018 CR3: 0000000001c0e000 CR4:
00000000001407e0
[  106.750962] Stack:
[  106.750981]  ffffffff813434eb ffff880400fcbb20 ffff880400fcbb18
0000000000000000
[  106.751037]  ffff8800de804920 ffffffff8101b9b9 0001800000000000
0000000000000100
[  106.751093]  0000010000000000 0000000000000002 000000000000000e
ffff8803eb8df500
[  106.751149] Call Trace:
[  106.751172]  [<ffffffff813434eb>] ? aa_path_name+0x2ab/0x430
[  106.751199]  [<ffffffff8101b9b9>] ? sched_clock+0x9/0x10
[  106.751225]  [<ffffffff8134a68d>] aa_path_perm+0x7d/0x170
[  106.751250]  [<ffffffff8101b945>] ? native_sched_clock+0x15/0x80
[  106.751276]  [<ffffffff8134aa73>] aa_file_perm+0x33/0x40
[  106.751301]  [<ffffffff81348c5e>] common_file_perm+0x8e/0xb0
[  106.751327]  [<ffffffff81348d78>] apparmor_file_permission+0x18/0x20
[  106.751355]  [<ffffffff8130c853>] security_file_permission+0x23/0xa0
[  106.751382]  [<ffffffff811c77a2>] rw_verify_area+0x52/0xe0
[  106.751407]  [<ffffffff811c789d>] vfs_read+0x6d/0x170
[  106.751432]  [<ffffffff811cda31>] kernel_read+0x41/0x60
[  106.751457]  [<ffffffff8134fd45>] ima_calc_file_hash+0x225/0x280
[  106.751483]  [<ffffffff8134fb52>] ? ima_calc_file_hash+0x32/0x280
[  106.751509]  [<ffffffff8135022d>] ima_collect_measurement+0x9d/0x160
[  106.751536]  [<ffffffff810b552d>] ? trace_hardirqs_on+0xd/0x10
[  106.751562]  [<ffffffff8134f07c>] ? ima_file_free+0x6c/0xd0
[  106.751587]  [<ffffffff81352824>] ima_update_xattr+0x34/0x60
[  106.751612]  [<ffffffff8134f0d0>] ima_file_free+0xc0/0xd0
[  106.751637]  [<ffffffff811c9635>] __fput+0xd5/0x300
[  106.751662]  [<ffffffff811c98ae>] ____fput+0xe/0x10
[  106.751687]  [<ffffffff81086774>] task_work_run+0xc4/0xe0
[  106.751712]  [<ffffffff81066fad>] do_exit+0x2bd/0xa90
[  106.751738]  [<ffffffff8173c958>] ? retint_swapgs+0x13/0x1b
[  106.751763]  [<ffffffff8106780c>] do_group_exit+0x4c/0xc0
[  106.751788]  [<ffffffff81067894>] SyS_exit_group+0x14/0x20
[  106.751814]  [<ffffffff8174522d>] system_call_fastpath+0x1a/0x1f
[  106.751839] Code: c3 0f 1f 44 00 00 55 48 89 e5 e8 22 fe ff ff 5d c3
0f 1f 44 00 00 55 65 48 8b 04 25 c0 c9 00 00 48 8b 80 28 06 00 00 48 89
e5 5d <48> 8b 40 18 48 39 87 c0 00 00 00 0f 94 c0 c3 0f 1f 80 00 00 00
[  106.752185] RIP  [<ffffffff811ec7da>] our_mnt+0x1a/0x30
[  106.752214]  RSP <ffff880400fcba60>
[  106.752236] CR2: 0000000000000018
[  106.752258] ---[ end trace 3c520748b4732721 ]---
----------------------------------------------------------------------

The reason for the oops is that IMA-appraisal uses "kernel_read()" when
file is closed. kernel_read() honors LSM security hook which calls
Apparmor handler, which uses current->nsproxy->mnt_ns. The 'guilty'
commit changed the order of cleanup code so that nsproxy->mnt_ns was
not already available for Apparmor.

Discussion about the issue with Al Viro and Eric W. Biederman suggested
that kernel_read() is too high-level for IMA. Another issue, except
security checking, that was identified is mandatory locking. kernel_read
honors it as well and it might prevent IMA from calculating necessary hash.
It was suggested to use simplified version of the function without security
and locking checks.

This patch introduces special version ima_kernel_read(), which skips security
and mandatory locking checking. It prevents the kernel oops to happen.

Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
Suggested-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 security/integrity/ima/ima_crypto.c | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/security/integrity/ima/ima_crypto.c b/security/integrity/ima/ima_crypto.c
index b21ee5b..bb65b0d 100644
--- a/security/integrity/ima/ima_crypto.c
+++ b/security/integrity/ima/ima_crypto.c
@@ -21,6 +21,36 @@
 #include <linux/slab.h>
 #include "ima.h"
 
+/**
+ * ima_kernel_read - read file content
+ *
+ * This is a function for reading file content instead of kernel_read().
+ * It does not perform locking checks to ensure it cannot be blocked.
+ * It does not perform security checks because it is irrelevant for IMA.
+ *
+ */
+static int ima_kernel_read(struct file *file, loff_t offset,
+			   char *addr, unsigned long count)
+{
+	mm_segment_t old_fs;
+	char __user *buf = addr;
+	ssize_t ret;
+
+	if (!(file->f_mode & FMODE_READ))
+		return -EBADF;
+	if (!file->f_op->read && !file->f_op->aio_read)
+		return -EINVAL;
+
+	old_fs = get_fs();
+	set_fs(get_ds());
+	if (file->f_op->read)
+		ret = file->f_op->read(file, buf, count, &offset);
+	else
+		ret = do_sync_read(file, buf, count, &offset);
+	set_fs(old_fs);
+	return ret;
+}
+
 static int init_desc(struct hash_desc *desc)
 {
 	int rc;
@@ -67,7 +97,7 @@ int ima_calc_hash(struct file *file, char *digest)
 	while (offset < i_size) {
 		int rbuf_len;
 
-		rbuf_len = kernel_read(file, offset, rbuf, PAGE_SIZE);
+		rbuf_len = ima_kernel_read(file, offset, rbuf, PAGE_SIZE);
 		if (rbuf_len < 0) {
 			rc = rbuf_len;
 			break;
-- 
1.9.1


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

* [PATCH 3.8 083/116] staging: iio: tsl2x7x_core: fix proximity treshold
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (81 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 082/116] ima: introduce ima_kernel_read() Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 084/116] iio: adc: at91: signedness bug in at91_adc_get_trigger_value_by_name() Kamal Mostafa
                   ` (32 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Mario Schuknecht, Jonathan Cameron, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Mario Schuknecht <mario.schuknecht@dresearch-fe.de>

commit c404618cd06dad771495fe1cf9d5a63b5664f65f upstream.

Consider high byte of proximity min and max treshold in function
'tsl2x7x_chip_on'. So far, the high byte was not set.

Signed-off-by: Mario Schuknecht <mario.schuknecht@dresearch-fe.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/staging/iio/light/tsl2x7x_core.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x_core.c b/drivers/staging/iio/light/tsl2x7x_core.c
index 395d8f6..b15b7cb 100644
--- a/drivers/staging/iio/light/tsl2x7x_core.c
+++ b/drivers/staging/iio/light/tsl2x7x_core.c
@@ -725,9 +725,13 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
 	chip->tsl2x7x_config[TSL2X7X_PRX_COUNT] =
 			chip->tsl2x7x_settings.prox_pulse_count;
 	chip->tsl2x7x_config[TSL2X7X_PRX_MINTHRESHLO] =
-	chip->tsl2x7x_settings.prox_thres_low;
+			(chip->tsl2x7x_settings.prox_thres_low) & 0xFF;
+	chip->tsl2x7x_config[TSL2X7X_PRX_MINTHRESHHI] =
+			(chip->tsl2x7x_settings.prox_thres_low >> 8) & 0xFF;
 	chip->tsl2x7x_config[TSL2X7X_PRX_MAXTHRESHLO] =
-			chip->tsl2x7x_settings.prox_thres_high;
+			(chip->tsl2x7x_settings.prox_thres_high) & 0xFF;
+	chip->tsl2x7x_config[TSL2X7X_PRX_MAXTHRESHHI] =
+			(chip->tsl2x7x_settings.prox_thres_high >> 8) & 0xFF;
 
 	/* and make sure we're not already on */
 	if (chip->tsl2x7x_chip_status == TSL2X7X_CHIP_WORKING) {
-- 
1.9.1


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

* [PATCH 3.8 084/116] iio: adc: at91: signedness bug in at91_adc_get_trigger_value_by_name()
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (82 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 083/116] staging: iio: tsl2x7x_core: fix proximity treshold Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 085/116] Revert "uio: fix vma io range check in mmap" Kamal Mostafa
                   ` (31 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Dan Carpenter, Jonathan Cameron, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Dan Carpenter <dan.carpenter@oracle.com>

commit 4f3bcd878f1d3c730fe00f619b7260c6125d49eb upstream.

at91_adc_get_trigger_value_by_name() was returning -ENOMEM truncated to
a positive u8 and that doesn't work.  I've changed it to int and
refactored it to preserve the error code.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Tested-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/iio/adc/at91_adc.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index a526c0e..aa78185 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -157,12 +157,11 @@ static int at91_adc_channel_init(struct iio_dev *idev)
 	return idev->num_channels;
 }
 
-static u8 at91_adc_get_trigger_value_by_name(struct iio_dev *idev,
+static int at91_adc_get_trigger_value_by_name(struct iio_dev *idev,
 					     struct at91_adc_trigger *triggers,
 					     const char *trigger_name)
 {
 	struct at91_adc_state *st = iio_priv(idev);
-	u8 value = 0;
 	int i;
 
 	for (i = 0; i < st->trigger_number; i++) {
@@ -175,15 +174,16 @@ static u8 at91_adc_get_trigger_value_by_name(struct iio_dev *idev,
 			return -ENOMEM;
 
 		if (strcmp(trigger_name, name) == 0) {
-			value = triggers[i].value;
 			kfree(name);
-			break;
+			if (triggers[i].value == 0)
+				return -EINVAL;
+			return triggers[i].value;
 		}
 
 		kfree(name);
 	}
 
-	return value;
+	return -EINVAL;
 }
 
 static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state)
@@ -193,14 +193,14 @@ static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state)
 	struct iio_buffer *buffer = idev->buffer;
 	struct at91_adc_reg_desc *reg = st->registers;
 	u32 status = at91_adc_readl(st, reg->trigger_register);
-	u8 value;
+	int value;
 	u8 bit;
 
 	value = at91_adc_get_trigger_value_by_name(idev,
 						   st->trigger_list,
 						   idev->trig->name);
-	if (value == 0)
-		return -EINVAL;
+	if (value < 0)
+		return value;
 
 	if (state) {
 		st->buffer = kmalloc(idev->scan_bytes, GFP_KERNEL);
-- 
1.9.1


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

* [PATCH 3.8 085/116] Revert "uio: fix vma io range check in mmap"
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (83 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 084/116] iio: adc: at91: signedness bug in at91_adc_get_trigger_value_by_name() Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 086/116] USB: EHCI: avoid BIOS handover on the HASEE E200 Kamal Mostafa
                   ` (30 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Bin Wang, Nobuhiro Iwamatsu, Norbert Ciosek, Greg Kroah-Hartman,
	Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit b29f680c4fe305902d02c1d5aa4968fe13a45fe6 upstream.

This reverts commit ddb09754e6c7239e302c7b675df9bbd415f8de5d.

Linus objected to this originally, I can see why it might be needed, but
given that no one spoke up defending this patch, I'm going to revert it.

If you have hardware that requires this change, please speak up in the
future and defend the patch.

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Bin Wang <binw@marvell.com>
Cc: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
Cc: Norbert Ciosek <norbertciosek@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/uio/uio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index 354c095..9981b9b 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -657,7 +657,7 @@ static int uio_mmap_physical(struct vm_area_struct *vma)
 
 	if (mem->addr & ~PAGE_MASK)
 		return -ENODEV;
-	if (vma->vm_end - vma->vm_start > PAGE_ALIGN(mem->size))
+	if (vma->vm_end - vma->vm_start > mem->size)
 		return -EINVAL;
 
 	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
-- 
1.9.1


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

* [PATCH 3.8 086/116] USB: EHCI: avoid BIOS handover on the HASEE E200
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (84 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 085/116] Revert "uio: fix vma io range check in mmap" Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 087/116] arm64: Bug fix in stack alignment exception Kamal Mostafa
                   ` (29 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Alan Stern, Greg Kroah-Hartman, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Alan Stern <stern@rowland.harvard.edu>

commit b0a50e92bda3c4aeb8017d4e6c6e92146ebd5c9b upstream.

Leandro Liptak reports that his HASEE E200 computer hangs when we ask
the BIOS to hand over control of the EHCI host controller.  This
definitely sounds like a bug in the BIOS, but at the moment there is
no way to fix it.

This patch works around the problem by avoiding the handoff whenever
the motherboard and BIOS version match those of Leandro's computer.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Reported-by: Leandro Liptak <leandroliptak@gmail.com>
Tested-by: Leandro Liptak <leandroliptak@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/usb/host/pci-quirks.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
index 4c338ec..9cfe3af 100644
--- a/drivers/usb/host/pci-quirks.c
+++ b/drivers/usb/host/pci-quirks.c
@@ -555,6 +555,14 @@ static const struct dmi_system_id ehci_dmi_nohandoff_table[] = {
 			DMI_MATCH(DMI_BIOS_VERSION, "Lucid-"),
 		},
 	},
+	{
+		/* HASEE E200 */
+		.matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "HASEE"),
+			DMI_MATCH(DMI_BOARD_NAME, "E210"),
+			DMI_MATCH(DMI_BIOS_VERSION, "6.00"),
+		},
+	},
 	{ }
 };
 
@@ -564,9 +572,14 @@ static void ehci_bios_handoff(struct pci_dev *pdev,
 {
 	int try_handoff = 1, tried_handoff = 0;
 
-	/* The Pegatron Lucid tablet sporadically waits for 98 seconds trying
-	 * the handoff on its unused controller.  Skip it. */
-	if (pdev->vendor == 0x8086 && pdev->device == 0x283a) {
+	/*
+	 * The Pegatron Lucid tablet sporadically waits for 98 seconds trying
+	 * the handoff on its unused controller.  Skip it.
+	 *
+	 * The HASEE E200 hangs when the semaphore is set (bugzilla #77021).
+	 */
+	if (pdev->vendor == 0x8086 && (pdev->device == 0x283a ||
+			pdev->device == 0x27cc)) {
 		if (dmi_check_system(ehci_dmi_nohandoff_table))
 			try_handoff = 0;
 	}
-- 
1.9.1


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

* [PATCH 3.8 087/116] arm64: Bug fix in stack alignment exception
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (85 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 086/116] USB: EHCI: avoid BIOS handover on the HASEE E200 Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 088/116] arm64: ptrace: change fs when passing kernel pointer to regset code Kamal Mostafa
                   ` (28 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: ChiaHao, Catalin Marinas, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: ChiaHao <andy.jhshiu@gmail.com>

commit 3906c2b53cd23c2ae03e6ce41432c8e7f0a3cbbb upstream.

The value of ESR has been stored into x1, and should be directly pass to
do_sp_pc_abort function, "MOV x1, x25" is an extra operation and do_sp_pc_abort
will get the wrong value of ESR.

Signed-off-by: ChiaHao <andy.jhshiu@gmail.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 arch/arm64/kernel/entry.S | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
index 9c94f40..9e3d509 100644
--- a/arch/arm64/kernel/entry.S
+++ b/arch/arm64/kernel/entry.S
@@ -274,7 +274,6 @@ el1_sp_pc:
 	 * Stack or PC alignment exception handling
 	 */
 	mrs	x0, far_el1
-	mov	x1, x25
 	mov	x2, sp
 	b	do_sp_pc_abort
 el1_undef:
-- 
1.9.1


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

* [PATCH 3.8 088/116] arm64: ptrace: change fs when passing kernel pointer to regset code
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (86 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 087/116] arm64: Bug fix in stack alignment exception Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 089/116] arm64: uid16: fix __kernel_old_{gid,uid}_t definitions Kamal Mostafa
                   ` (27 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Will Deacon, Catalin Marinas, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Will Deacon <will.deacon@arm.com>

commit c168870704bcde6bb63d05f7882b620dd3985a46 upstream.

Our compat PTRACE_POKEUSR implementation simply passes the user data to
regset_copy_from_user after some simple range checking. Unfortunately,
the data in question has already been copied to the kernel stack by this
point, so the subsequent access_ok check fails and the ptrace request
returns -EFAULT. This causes problems tracing fork() with older versions
of strace.

This patch briefly changes the fs to KERNEL_DS, so that the access_ok
check passes even with a kernel address.

Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 arch/arm64/kernel/ptrace.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
index 5341534..8553668 100644
--- a/arch/arm64/kernel/ptrace.c
+++ b/arch/arm64/kernel/ptrace.c
@@ -872,6 +872,7 @@ static int compat_ptrace_write_user(struct task_struct *tsk, compat_ulong_t off,
 				    compat_ulong_t val)
 {
 	int ret;
+	mm_segment_t old_fs = get_fs();
 
 	if (off & 3 || off >= COMPAT_USER_SZ)
 		return -EIO;
@@ -879,10 +880,13 @@ static int compat_ptrace_write_user(struct task_struct *tsk, compat_ulong_t off,
 	if (off >= sizeof(compat_elf_gregset_t))
 		return 0;
 
+	set_fs(KERNEL_DS);
 	ret = copy_regset_from_user(tsk, &user_aarch32_view,
 				    REGSET_COMPAT_GPR, off,
 				    sizeof(compat_ulong_t),
 				    &val);
+	set_fs(old_fs);
+
 	return ret;
 }
 
-- 
1.9.1


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

* [PATCH 3.8 089/116] arm64: uid16: fix __kernel_old_{gid,uid}_t definitions
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (87 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 088/116] arm64: ptrace: change fs when passing kernel pointer to regset code Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 090/116] arm64/dma: Removing ARCH_HAS_DMA_GET_REQUIRED_MASK macro Kamal Mostafa
                   ` (26 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Will Deacon, Catalin Marinas, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Will Deacon <will.deacon@arm.com>

commit 34c65c43f1518bf85f93526ad373adc6a683b4c5 upstream.

Whilst native arm64 applications don't have the 16-bit UID/GID syscalls
wired up, compat tasks can still access them. The 16-bit wrappers for
these syscalls use __kernel_old_uid_t and __kernel_old_gid_t, which must
be 16-bit data types to maintain compatibility with the 16-bit UIDs used
by compat applications.

This patch defines 16-bit __kernel_old_{gid,uid}_t types for arm64
instead of using the 32-bit types provided by asm-generic.

Signed-off-by: Will Deacon <will.deacon@arm.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 arch/arm64/include/asm/Kbuild             |  1 -
 arch/arm64/include/uapi/asm/posix_types.h | 10 ++++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm64/include/uapi/asm/posix_types.h

diff --git a/arch/arm64/include/asm/Kbuild b/arch/arm64/include/asm/Kbuild
index 14a9d5a..9357d33 100644
--- a/arch/arm64/include/asm/Kbuild
+++ b/arch/arm64/include/asm/Kbuild
@@ -27,7 +27,6 @@ generic-y += mutex.h
 generic-y += pci.h
 generic-y += percpu.h
 generic-y += poll.h
-generic-y += posix_types.h
 generic-y += resource.h
 generic-y += scatterlist.h
 generic-y += sections.h
diff --git a/arch/arm64/include/uapi/asm/posix_types.h b/arch/arm64/include/uapi/asm/posix_types.h
new file mode 100644
index 0000000..7985ff6
--- /dev/null
+++ b/arch/arm64/include/uapi/asm/posix_types.h
@@ -0,0 +1,10 @@
+#ifndef __ASM_POSIX_TYPES_H
+#define __ASM_POSIX_TYPES_H
+
+typedef unsigned short __kernel_old_uid_t;
+typedef unsigned short __kernel_old_gid_t;
+#define __kernel_old_uid_t __kernel_old_uid_t
+
+#include <asm-generic/posix_types.h>
+
+#endif /*  __ASM_POSIX_TYPES_H */
-- 
1.9.1


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

* [PATCH 3.8 090/116] arm64/dma: Removing ARCH_HAS_DMA_GET_REQUIRED_MASK macro
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (88 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 089/116] arm64: uid16: fix __kernel_old_{gid,uid}_t definitions Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 091/116] ALSA: control: Protect user controls against concurrent access Kamal Mostafa
                   ` (25 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Suravee Suthikulpanit, Catalin Marinas, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>

commit f3a183cb422574014538017b5b291a416396f97e upstream.

Arm64 does not define dma_get_required_mask() function.
Therefore, it should not define the ARCH_HAS_DMA_GET_REQUIRED_MASK.
This causes build errors in some device drivers (e.g. mpt2sas)

Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 arch/arm64/include/asm/dma-mapping.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/arm64/include/asm/dma-mapping.h b/arch/arm64/include/asm/dma-mapping.h
index 9947768..3699d1d 100644
--- a/arch/arm64/include/asm/dma-mapping.h
+++ b/arch/arm64/include/asm/dma-mapping.h
@@ -23,8 +23,6 @@
 
 #include <asm-generic/dma-coherent.h>
 
-#define ARCH_HAS_DMA_GET_REQUIRED_MASK
-
 extern struct dma_map_ops *dma_ops;
 
 static inline struct dma_map_ops *get_dma_ops(struct device *dev)
-- 
1.9.1


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

* [PATCH 3.8 091/116] ALSA: control: Protect user controls against concurrent access
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (89 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 090/116] arm64/dma: Removing ARCH_HAS_DMA_GET_REQUIRED_MASK macro Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 092/116] ALSA: control: Fix replacing user controls Kamal Mostafa
                   ` (24 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Lars-Peter Clausen, Takashi Iwai, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Lars-Peter Clausen <lars@metafoo.de>

commit 07f4d9d74a04aa7c72c5dae0ef97565f28f17b92 upstream.

The user-control put and get handlers as well as the tlv do not protect against
concurrent access from multiple threads. Since the state of the control is not
updated atomically it is possible that either two write operations or a write
and a read operation race against each other. Both can lead to arbitrary memory
disclosure. This patch introduces a new lock that protects user-controls from
concurrent access. Since applications typically access controls sequentially
than in parallel a single lock per card should be fine.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 include/sound/core.h |  2 ++
 sound/core/control.c | 31 +++++++++++++++++++++++++------
 sound/core/init.c    |  1 +
 3 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/include/sound/core.h b/include/sound/core.h
index 93896ad..8d29d28 100644
--- a/include/sound/core.h
+++ b/include/sound/core.h
@@ -120,6 +120,8 @@ struct snd_card {
 	int user_ctl_count;		/* count of all user controls */
 	struct list_head controls;	/* all controls for this card */
 	struct list_head ctl_files;	/* active control files */
+	struct mutex user_ctl_lock;	/* protects user controls against
+					   concurrent access */
 
 	struct snd_info_entry *proc_root;	/* root for soundcard specific files */
 	struct snd_info_entry *proc_id;	/* the card id */
diff --git a/sound/core/control.c b/sound/core/control.c
index 8c7c2c9..c254cab 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -989,6 +989,7 @@ static int snd_ctl_elem_unlock(struct snd_ctl_file *file,
 
 struct user_element {
 	struct snd_ctl_elem_info info;
+	struct snd_card *card;
 	void *elem_data;		/* element data */
 	unsigned long elem_data_size;	/* size of element data in bytes */
 	void *tlv_data;			/* TLV data */
@@ -1032,7 +1033,9 @@ static int snd_ctl_elem_user_get(struct snd_kcontrol *kcontrol,
 {
 	struct user_element *ue = kcontrol->private_data;
 
+	mutex_lock(&ue->card->user_ctl_lock);
 	memcpy(&ucontrol->value, ue->elem_data, ue->elem_data_size);
+	mutex_unlock(&ue->card->user_ctl_lock);
 	return 0;
 }
 
@@ -1041,10 +1044,12 @@ static int snd_ctl_elem_user_put(struct snd_kcontrol *kcontrol,
 {
 	int change;
 	struct user_element *ue = kcontrol->private_data;
-	
+
+	mutex_lock(&ue->card->user_ctl_lock);
 	change = memcmp(&ucontrol->value, ue->elem_data, ue->elem_data_size) != 0;
 	if (change)
 		memcpy(ue->elem_data, &ucontrol->value, ue->elem_data_size);
+	mutex_unlock(&ue->card->user_ctl_lock);
 	return change;
 }
 
@@ -1064,19 +1069,32 @@ static int snd_ctl_elem_user_tlv(struct snd_kcontrol *kcontrol,
 		new_data = memdup_user(tlv, size);
 		if (IS_ERR(new_data))
 			return PTR_ERR(new_data);
+		mutex_lock(&ue->card->user_ctl_lock);
 		change = ue->tlv_data_size != size;
 		if (!change)
 			change = memcmp(ue->tlv_data, new_data, size);
 		kfree(ue->tlv_data);
 		ue->tlv_data = new_data;
 		ue->tlv_data_size = size;
+		mutex_unlock(&ue->card->user_ctl_lock);
 	} else {
-		if (! ue->tlv_data_size || ! ue->tlv_data)
-			return -ENXIO;
-		if (size < ue->tlv_data_size)
-			return -ENOSPC;
+		int ret = 0;
+
+		mutex_lock(&ue->card->user_ctl_lock);
+		if (!ue->tlv_data_size || !ue->tlv_data) {
+			ret = -ENXIO;
+			goto err_unlock;
+		}
+		if (size < ue->tlv_data_size) {
+			ret = -ENOSPC;
+			goto err_unlock;
+		}
 		if (copy_to_user(tlv, ue->tlv_data, ue->tlv_data_size))
-			return -EFAULT;
+			ret = -EFAULT;
+err_unlock:
+		mutex_unlock(&ue->card->user_ctl_lock);
+		if (ret)
+			return ret;
 	}
 	return change;
 }
@@ -1208,6 +1226,7 @@ static int snd_ctl_elem_add(struct snd_ctl_file *file,
 	ue = kzalloc(sizeof(struct user_element) + private_size, GFP_KERNEL);
 	if (ue == NULL)
 		return -ENOMEM;
+	ue->card = card;
 	ue->info = *info;
 	ue->info.access = 0;
 	ue->elem_data = (char *)ue + sizeof(*ue);
diff --git a/sound/core/init.c b/sound/core/init.c
index 7b012d1..41020d7 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -208,6 +208,7 @@ int snd_card_create(int idx, const char *xid,
 	INIT_LIST_HEAD(&card->devices);
 	init_rwsem(&card->controls_rwsem);
 	rwlock_init(&card->ctl_files_rwlock);
+	mutex_init(&card->user_ctl_lock);
 	INIT_LIST_HEAD(&card->controls);
 	INIT_LIST_HEAD(&card->ctl_files);
 	spin_lock_init(&card->files_lock);
-- 
1.9.1


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

* [PATCH 3.8 092/116] ALSA: control: Fix replacing user controls
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (90 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 091/116] ALSA: control: Protect user controls against concurrent access Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 093/116] ALSA: control: Don't access controls outside of protected regions Kamal Mostafa
                   ` (23 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Lars-Peter Clausen, Takashi Iwai, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Lars-Peter Clausen <lars@metafoo.de>

commit 82262a46627bebb0febcc26664746c25cef08563 upstream.

There are two issues with the current implementation for replacing user
controls. The first is that the code does not check if the control is actually a
user control and neither does it check if the control is owned by the process
that tries to remove it. That allows userspace applications to remove arbitrary
controls, which can cause a user after free if a for example a driver does not
expect a control to be removed from under its feed.

The second issue is that on one hand when a control is replaced the
user_ctl_count limit is not checked and on the other hand the user_ctl_count is
increased (even though the number of user controls does not change). This allows
userspace, once the user_ctl_count limit as been reached, to repeatedly replace
a control until user_ctl_count overflows. Once that happens new controls can be
added effectively bypassing the user_ctl_count limit.

Both issues can be fixed by instead of open-coding the removal of the control
that is to be replaced to use snd_ctl_remove_user_ctl(). This function does
proper permission checks as well as decrements user_ctl_count after the control
has been removed.

Note that by using snd_ctl_remove_user_ctl() the check which returns -EBUSY at
beginning of the function if the control already exists is removed. This is not
a problem though since the check is quite useless, because the lock that is
protecting the control list is released between the check and before adding the
new control to the list, which means that it is possible that a different
control with the same settings is added to the list after the check. Luckily
there is another check that is done while holding the lock in snd_ctl_add(), so
we'll rely on that to make sure that the same control is not added twice.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 sound/core/control.c | 25 +++++++++----------------
 1 file changed, 9 insertions(+), 16 deletions(-)

diff --git a/sound/core/control.c b/sound/core/control.c
index c254cab..eede351 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -1152,8 +1152,6 @@ static int snd_ctl_elem_add(struct snd_ctl_file *file,
 	struct user_element *ue;
 	int idx, err;
 
-	if (!replace && card->user_ctl_count >= MAX_USER_CONTROLS)
-		return -ENOMEM;
 	if (info->count < 1)
 		return -EINVAL;
 	access = info->access == 0 ? SNDRV_CTL_ELEM_ACCESS_READWRITE :
@@ -1162,21 +1160,16 @@ static int snd_ctl_elem_add(struct snd_ctl_file *file,
 				 SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE));
 	info->id.numid = 0;
 	memset(&kctl, 0, sizeof(kctl));
-	down_write(&card->controls_rwsem);
-	_kctl = snd_ctl_find_id(card, &info->id);
-	err = 0;
-	if (_kctl) {
-		if (replace)
-			err = snd_ctl_remove(card, _kctl);
-		else
-			err = -EBUSY;
-	} else {
-		if (replace)
-			err = -ENOENT;
+
+	if (replace) {
+		err = snd_ctl_remove_user_ctl(file, &info->id);
+		if (err)
+			return err;
 	}
-	up_write(&card->controls_rwsem);
-	if (err < 0)
-		return err;
+
+	if (card->user_ctl_count >= MAX_USER_CONTROLS)
+		return -ENOMEM;
+
 	memcpy(&kctl.id, &info->id, sizeof(info->id));
 	kctl.count = info->owner ? info->owner : 1;
 	access |= SNDRV_CTL_ELEM_ACCESS_USER;
-- 
1.9.1


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

* [PATCH 3.8 093/116] ALSA: control: Don't access controls outside of protected regions
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (91 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 092/116] ALSA: control: Fix replacing user controls Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 094/116] ALSA: control: Handle numid overflow Kamal Mostafa
                   ` (22 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Lars-Peter Clausen, Takashi Iwai, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Lars-Peter Clausen <lars@metafoo.de>

commit fd9f26e4eca5d08a27d12c0933fceef76ed9663d upstream.

A control that is visible on the card->controls list can be freed at any time.
This means we must not access any of its memory while not holding the
controls_rw_lock. Otherwise we risk a use after free access.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 sound/core/control.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/sound/core/control.c b/sound/core/control.c
index eede351..7619a57 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -330,6 +330,7 @@ int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol)
 {
 	struct snd_ctl_elem_id id;
 	unsigned int idx;
+	unsigned int count;
 	int err = -EINVAL;
 
 	if (! kcontrol)
@@ -358,8 +359,9 @@ int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol)
 	card->controls_count += kcontrol->count;
 	kcontrol->id.numid = card->last_numid + 1;
 	card->last_numid += kcontrol->count;
+	count = kcontrol->count;
 	up_write(&card->controls_rwsem);
-	for (idx = 0; idx < kcontrol->count; idx++, id.index++, id.numid++)
+	for (idx = 0; idx < count; idx++, id.index++, id.numid++)
 		snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_ADD, &id);
 	return 0;
 
@@ -388,6 +390,7 @@ int snd_ctl_replace(struct snd_card *card, struct snd_kcontrol *kcontrol,
 		    bool add_on_replace)
 {
 	struct snd_ctl_elem_id id;
+	unsigned int count;
 	unsigned int idx;
 	struct snd_kcontrol *old;
 	int ret;
@@ -423,8 +426,9 @@ add:
 	card->controls_count += kcontrol->count;
 	kcontrol->id.numid = card->last_numid + 1;
 	card->last_numid += kcontrol->count;
+	count = kcontrol->count;
 	up_write(&card->controls_rwsem);
-	for (idx = 0; idx < kcontrol->count; idx++, id.index++, id.numid++)
+	for (idx = 0; idx < count; idx++, id.index++, id.numid++)
 		snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_ADD, &id);
 	return 0;
 
@@ -895,9 +899,9 @@ static int snd_ctl_elem_write(struct snd_card *card, struct snd_ctl_file *file,
 			result = kctl->put(kctl, control);
 		}
 		if (result > 0) {
+			struct snd_ctl_elem_id id = control->id;
 			up_read(&card->controls_rwsem);
-			snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE,
-				       &control->id);
+			snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, &id);
 			return 0;
 		}
 	}
@@ -1331,8 +1335,9 @@ static int snd_ctl_tlv_ioctl(struct snd_ctl_file *file,
 		}
 		err = kctl->tlv.c(kctl, op_flag, tlv.length, _tlv->tlv);
 		if (err > 0) {
+			struct snd_ctl_elem_id id = kctl->id;
 			up_read(&card->controls_rwsem);
-			snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_TLV, &kctl->id);
+			snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_TLV, &id);
 			return 0;
 		}
 	} else {
-- 
1.9.1


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

* [PATCH 3.8 094/116] ALSA: control: Handle numid overflow
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (92 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 093/116] ALSA: control: Don't access controls outside of protected regions Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 095/116] ALSA: control: Make sure that id->index does not overflow Kamal Mostafa
                   ` (21 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Lars-Peter Clausen, Takashi Iwai, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Lars-Peter Clausen <lars@metafoo.de>

commit ac902c112d90a89e59916f751c2745f4dbdbb4bd upstream.

Each control gets automatically assigned its numids when the control is created.
The allocation is done by incrementing the numid by the amount of allocated
numids per allocation. This means that excessive creation and destruction of
controls (e.g. via SNDRV_CTL_IOCTL_ELEM_ADD/REMOVE) can cause the id to
eventually overflow. Currently when this happens for the control that caused the
overflow kctl->id.numid + kctl->count will also over flow causing it to be
smaller than kctl->id.numid. Most of the code assumes that this is something
that can not happen, so we need to make sure that it won't happen

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 sound/core/control.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sound/core/control.c b/sound/core/control.c
index 7619a57..f92ca31 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -289,6 +289,10 @@ static bool snd_ctl_remove_numid_conflict(struct snd_card *card,
 {
 	struct snd_kcontrol *kctl;
 
+	/* Make sure that the ids assigned to the control do not wrap around */
+	if (card->last_numid >= UINT_MAX - count)
+		card->last_numid = 0;
+
 	list_for_each_entry(kctl, &card->controls, list) {
 		if (kctl->id.numid < card->last_numid + 1 + count &&
 		    kctl->id.numid + kctl->count > card->last_numid + 1) {
-- 
1.9.1


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

* [PATCH 3.8 095/116] ALSA: control: Make sure that id->index does not overflow
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (93 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 094/116] ALSA: control: Handle numid overflow Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 096/116] Bluetooth: Fix redundant encryption request for reauthentication Kamal Mostafa
                   ` (20 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Lars-Peter Clausen, Takashi Iwai, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Lars-Peter Clausen <lars@metafoo.de>

commit 883a1d49f0d77d30012f114b2e19fc141beb3e8e upstream.

The ALSA control code expects that the range of assigned indices to a control is
continuous and does not overflow. Currently there are no checks to enforce this.
If a control with a overflowing index range is created that control becomes
effectively inaccessible and unremovable since snd_ctl_find_id() will not be
able to find it. This patch adds a check that makes sure that controls with a
overflowing index range can not be created.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 sound/core/control.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sound/core/control.c b/sound/core/control.c
index f92ca31..6919da7 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -342,6 +342,9 @@ int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol)
 	if (snd_BUG_ON(!card || !kcontrol->info))
 		goto error;
 	id = kcontrol->id;
+	if (id.index > UINT_MAX - kcontrol->count)
+		goto error;
+
 	down_write(&card->controls_rwsem);
 	if (snd_ctl_find_id(card, &id)) {
 		up_write(&card->controls_rwsem);
-- 
1.9.1


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

* [PATCH 3.8 096/116] Bluetooth: Fix redundant encryption request for reauthentication
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (94 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 095/116] ALSA: control: Make sure that id->index does not overflow Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 097/116] Bluetooth: Fix check for connection encryption Kamal Mostafa
                   ` (19 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Johan Hedberg, Marcel Holtmann, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Johan Hedberg <johan.hedberg@intel.com>

commit 09da1f3463eb81d59685df723b1c5950b7570340 upstream.

When we're performing reauthentication (in order to elevate the
security level from an unauthenticated key to an authenticated one) we
do not need to issue any encryption command once authentication
completes. Since the trigger for the encryption HCI command is the
ENCRYPT_PEND flag this flag should not be set in this scenario.
Instead, the REAUTH_PEND flag takes care of all necessary steps for
reauthentication.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 net/bluetooth/hci_conn.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 4925a02..058897f 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -643,14 +643,17 @@ static int hci_conn_auth(struct hci_conn *conn, __u8 sec_level, __u8 auth_type)
 	if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) {
 		struct hci_cp_auth_requested cp;
 
-		/* encrypt must be pending if auth is also pending */
-		set_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags);
-
 		cp.handle = cpu_to_le16(conn->handle);
 		hci_send_cmd(conn->hdev, HCI_OP_AUTH_REQUESTED,
 			     sizeof(cp), &cp);
+
+		/* If we're already encrypted set the REAUTH_PEND flag,
+		 * otherwise set the ENCRYPT_PEND.
+		 */
 		if (conn->key_type != 0xff)
 			set_bit(HCI_CONN_REAUTH_PEND, &conn->flags);
+		else
+			set_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags);
 	}
 
 	return 0;
-- 
1.9.1


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

* [PATCH 3.8 097/116] Bluetooth: Fix check for connection encryption
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (95 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 096/116] Bluetooth: Fix redundant encryption request for reauthentication Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 098/116] Bluetooth: Fix SSP acceptor just-works confirmation without MITM Kamal Mostafa
                   ` (18 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Johan Hedberg, Marcel Holtmann, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Johan Hedberg <johan.hedberg@intel.com>

commit e694788d73efe139b24f78b036deb97fe57fa8cb upstream.

The conn->link_key variable tracks the type of link key in use. It is
set whenever we respond to a link key request as well as when we get a
link key notification event.

These two events do not however always guarantee that encryption is
enabled: getting a link key request and responding to it may only mean
that the remote side has requested authentication but not encryption. On
the other hand, the encrypt change event is a certain guarantee that
encryption is enabled. The real encryption state is already tracked in
the conn->link_mode variable through the HCI_LM_ENCRYPT bit.

This patch fixes a check for encryption in the hci_conn_auth function to
use the proper conn->link_mode value and thereby eliminates the chance
of a false positive result.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 net/bluetooth/hci_conn.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 058897f..947a965 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -650,7 +650,7 @@ static int hci_conn_auth(struct hci_conn *conn, __u8 sec_level, __u8 auth_type)
 		/* If we're already encrypted set the REAUTH_PEND flag,
 		 * otherwise set the ENCRYPT_PEND.
 		 */
-		if (conn->key_type != 0xff)
+		if (conn->link_mode & HCI_LM_ENCRYPT)
 			set_bit(HCI_CONN_REAUTH_PEND, &conn->flags);
 		else
 			set_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags);
-- 
1.9.1


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

* [PATCH 3.8 098/116] Bluetooth: Fix SSP acceptor just-works confirmation without MITM
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (96 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 097/116] Bluetooth: Fix check for connection encryption Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 099/116] Bluetooth: Fix setting correct authentication information for SMP STK Kamal Mostafa
                   ` (17 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Johan Hedberg, Marcel Holtmann, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Johan Hedberg <johan.hedberg@intel.com>

commit ba15a58b179ed76a7e887177f2b06de12c58ec8f upstream.

>From the Bluetooth Core Specification 4.1 page 1958:

"if both devices have set the Authentication_Requirements parameter to
one of the MITM Protection Not Required options, authentication stage 1
shall function as if both devices set their IO capabilities to
DisplayOnly (e.g., Numeric comparison with automatic confirmation on
both devices)"

So far our implementation has done user confirmation for all just-works
cases regardless of the MITM requirements, however following the
specification to the word means that we should not be doing confirmation
when neither side has the MITM flag set.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Tested-by: Szymon Janc <szymon.janc@tieto.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 net/bluetooth/hci_event.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index ba6f399..4d9e4b0 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -3573,8 +3573,11 @@ static void hci_user_confirm_request_evt(struct hci_dev *hdev,
 
 		/* If we're not the initiators request authorization to
 		 * proceed from user space (mgmt_user_confirm with
-		 * confirm_hint set to 1). */
-		if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags)) {
+		 * confirm_hint set to 1). The exception is if neither
+		 * side had MITM in which case we do auto-accept.
+		 */
+		if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags) &&
+		    (loc_mitm || rem_mitm)) {
 			BT_DBG("Confirming auto-accept as acceptor");
 			confirm_hint = 1;
 			goto confirm;
-- 
1.9.1


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

* [PATCH 3.8 099/116] Bluetooth: Fix setting correct authentication information for SMP STK
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (97 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 098/116] Bluetooth: Fix SSP acceptor just-works confirmation without MITM Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 100/116] Bluetooth: Fix indicating discovery state when canceling inquiry Kamal Mostafa
                   ` (16 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Johan Hedberg, Marcel Holtmann, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Johan Hedberg <johan.hedberg@intel.com>

commit fff3490f47810e2d34b91fb9e31103e923b11c2f upstream.

When we store the STK in slave role we should set the correct
authentication information for it. If the pairing is producing a HIGH
security level the STK is considered authenticated, and otherwise it's
considered unauthenticated. This patch fixes the value passed to the
hci_add_ltk() function when adding the STK on the slave side.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Tested-by: Marcin Kraglak <marcin.kraglak@tieto.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
[ kamal: backport to 3.8-stable: context ]
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 net/bluetooth/smp.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index 5abefb1..ba765a4 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -464,7 +464,7 @@ static void random_work(struct work_struct *work)
 		hci_le_start_enc(hcon, ediv, rand, stk);
 		hcon->enc_key_size = smp->enc_key_size;
 	} else {
-		u8 stk[16], r[16], rand[8];
+		u8 stk[16], r[16], rand[8], auth;
 		__le16 ediv;
 
 		memset(rand, 0, sizeof(rand));
@@ -479,8 +479,13 @@ static void random_work(struct work_struct *work)
 		memset(stk + smp->enc_key_size, 0,
 				SMP_MAX_ENC_KEY_SIZE - smp->enc_key_size);
 
+		if (hcon->pending_sec_level == BT_SECURITY_HIGH)
+			auth = 1;
+		else
+			auth = 0;
+
 		hci_add_ltk(hcon->hdev, conn->dst, hcon->dst_type,
-			    HCI_SMP_STK_SLAVE, 0, 0, stk, smp->enc_key_size,
+			    HCI_SMP_STK_SLAVE, 0, auth, stk, smp->enc_key_size,
 			    ediv, rand);
 	}
 
-- 
1.9.1


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

* [PATCH 3.8 100/116] Bluetooth: Fix indicating discovery state when canceling inquiry
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (98 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 099/116] Bluetooth: Fix setting correct authentication information for SMP STK Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 101/116] Bluetooth: Fix locking of hdev when calling into SMP code Kamal Mostafa
                   ` (15 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Johan Hedberg, Marcel Holtmann, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Johan Hedberg <johan.hedberg@intel.com>

commit 50143a433b70e3145bcf8a4a4e54f0c11bdee32b upstream.

When inquiry is canceled through the HCI_Cancel_Inquiry command there is
no Inquiry Complete event generated. Instead, all we get is the command
complete for the HCI_Inquiry_Cancel command. This means that we must
call the hci_discovery_set_state() function from the respective command
complete handler in order to ensure that user space knows the correct
discovery state.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 net/bluetooth/hci_event.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 4d9e4b0..86cd8f5 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -55,6 +55,10 @@ static void hci_cc_inquiry_cancel(struct hci_dev *hdev, struct sk_buff *skb)
 
 	hci_req_complete(hdev, HCI_OP_INQUIRY_CANCEL, status);
 
+	hci_dev_lock(hdev);
+	hci_discovery_set_state(hdev, DISCOVERY_STOPPED);
+	hci_dev_unlock(hdev);
+
 	hci_conn_check_pending(hdev);
 }
 
-- 
1.9.1


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

* [PATCH 3.8 101/116] Bluetooth: Fix locking of hdev when calling into SMP code
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (99 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 100/116] Bluetooth: Fix indicating discovery state when canceling inquiry Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 102/116] Bluetooth: Allow change security level on ATT_CID in slave role Kamal Mostafa
                   ` (14 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Johan Hedberg, Marcel Holtmann, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Johan Hedberg <johan.hedberg@intel.com>

commit c73f94b8c093a615ce80eabbde0ac6eb9abfe31a upstream.

The SMP code expects hdev to be unlocked since e.g. crypto functions
will try to (re)lock it. Therefore, we need to release the lock before
calling into smp.c from mgmt.c. Without this we risk a deadlock whenever
the smp_user_confirm_reply() function is called.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Tested-by: Lukasz Rymanowski <lukasz.rymanowski@tieto.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 net/bluetooth/mgmt.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index d8ba861..e470516 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -2048,8 +2048,13 @@ static int user_pairing_resp(struct sock *sk, struct hci_dev *hdev,
 	}
 
 	if (type == BDADDR_LE_PUBLIC || type == BDADDR_LE_RANDOM) {
-		/* Continue with pairing via SMP */
+		/* Continue with pairing via SMP. The hdev lock must be
+		 * released as SMP may try to recquire it for crypto
+		 * purposes.
+		 */
+		hci_dev_unlock(hdev);
 		err = smp_user_confirm_reply(conn, mgmt_op, passkey);
+		hci_dev_lock(hdev);
 
 		if (!err)
 			err = cmd_status(sk, hdev->id, mgmt_op,
-- 
1.9.1


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

* [PATCH 3.8 102/116] Bluetooth: Allow change security level on ATT_CID in slave role
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (100 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 101/116] Bluetooth: Fix locking of hdev when calling into SMP code Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 103/116] rt2x00: disable TKIP on USB Kamal Mostafa
                   ` (13 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Marcin Kraglak, Marcel Holtmann, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Marcin Kraglak <marcin.kraglak@tieto.com>

commit 92d1372e1a9fec00e146b74e8b9ad7a385b9b37f upstream.

Kernel supports SMP Security Request so don't block increasing security
when we are slave.

Signed-off-by: Marcin Kraglak <marcin.kraglak@tieto.com>
Acked-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 net/bluetooth/l2cap_sock.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 59011c4..a166b26 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -625,11 +625,6 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
 
 		/*change security for LE channels */
 		if (chan->scid == L2CAP_CID_LE_DATA) {
-			if (!conn->hcon->out) {
-				err = -EINVAL;
-				break;
-			}
-
 			if (smp_conn_security(conn->hcon, sec.level))
 				break;
 			sk->sk_state = BT_CONFIG;
-- 
1.9.1


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

* [PATCH 3.8 103/116] rt2x00: disable TKIP on USB
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (101 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 102/116] Bluetooth: Allow change security level on ATT_CID in slave role Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 104/116] b43: fix frequency reported on G-PHY with /new/ firmware Kamal Mostafa
                   ` (12 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Stanislaw Gruszka, John W. Linville, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Stanislaw Gruszka <sgruszka@redhat.com>

commit 8edcb0ba0d56f5914eef11eda6db8bfe74eb9ca8 upstream.

On USB we can not get atomically TKIP key. We have to disable support
for TKIP acceleration on USB hardware to avoid bug as showed bellow.

[  860.827243] BUG: scheduling while atomic: hostapd/3397/0x00000002
<snip>
[  860.827280] Call Trace:
[  860.827282]  [<ffffffff81682ea6>] dump_stack+0x4d/0x66
[  860.827284]  [<ffffffff8167eb9b>] __schedule_bug+0x47/0x55
[  860.827285]  [<ffffffff81685bb3>] __schedule+0x733/0x7b0
[  860.827287]  [<ffffffff81685c59>] schedule+0x29/0x70
[  860.827289]  [<ffffffff81684f8a>] schedule_timeout+0x15a/0x2b0
[  860.827291]  [<ffffffff8105ac50>] ? ftrace_raw_event_tick_stop+0xc0/0xc0
[  860.827294]  [<ffffffff810c13c2>] ? __module_text_address+0x12/0x70
[  860.827296]  [<ffffffff81686823>] wait_for_completion_timeout+0xb3/0x140
[  860.827298]  [<ffffffff81080fc0>] ? wake_up_state+0x20/0x20
[  860.827301]  [<ffffffff814d5b3d>] usb_start_wait_urb+0x7d/0x150
[  860.827303]  [<ffffffff814d5cd5>] usb_control_msg+0xc5/0x110
[  860.827305]  [<ffffffffa02fb0c6>] rt2x00usb_vendor_request+0xc6/0x160  [rt2x00usb]
[  860.827307]  [<ffffffffa02fb215>] rt2x00usb_vendor_req_buff_lock+0x75/0x150 [rt2x00usb]
[  860.827309]  [<ffffffffa02fb393>] rt2x00usb_vendor_request_buff+0xa3/0xe0 [rt2x00usb]
[  860.827311]  [<ffffffffa023d1a3>] rt2x00usb_register_multiread+0x33/0x40 [rt2800usb]
[  860.827314]  [<ffffffffa05805f9>] rt2800_get_tkip_seq+0x39/0x50  [rt2800lib]
[  860.827321]  [<ffffffffa0480f88>] ieee80211_get_key+0x218/0x2a0  [mac80211]
[  860.827322]  [<ffffffff815cc68c>] ? __nlmsg_put+0x6c/0x80
[  860.827329]  [<ffffffffa051b02e>] nl80211_get_key+0x22e/0x360 [cfg80211]

Reported-and-tested-by: Peter Wu <lekensteyn@gmail.com>
Reported-and-tested-by: Pontus Fuchs <pontus.fuchs@gmail.com>
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/net/wireless/rt2x00/rt2x00mac.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/wireless/rt2x00/rt2x00mac.c b/drivers/net/wireless/rt2x00/rt2x00mac.c
index 65225fa..7195a30 100644
--- a/drivers/net/wireless/rt2x00/rt2x00mac.c
+++ b/drivers/net/wireless/rt2x00/rt2x00mac.c
@@ -489,6 +489,8 @@ int rt2x00mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
 	crypto.cipher = rt2x00crypto_key_to_cipher(key);
 	if (crypto.cipher == CIPHER_NONE)
 		return -EOPNOTSUPP;
+	if (crypto.cipher == CIPHER_TKIP && rt2x00_is_usb(rt2x00dev))
+		return -EOPNOTSUPP;
 
 	crypto.cmd = cmd;
 
-- 
1.9.1


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

* [PATCH 3.8 104/116] b43: fix frequency reported on G-PHY with /new/ firmware
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (102 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 103/116] rt2x00: disable TKIP on USB Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 105/116] rt2x00: fix rfkill regression on rt2500pci Kamal Mostafa
                   ` (11 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Rafał Miłecki, John W. Linville, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>

commit 2fc68eb122c7ea6cd5be1fe7d6650c0beb2f4f40 upstream.

Support for firmware rev 508+ was added years ago, but we never noticed
it reports channel in a different way for G-PHY devices. Instead of
offset from 2400 MHz it simply passes channel id (AKA hw_value).

So far it was (most probably) affecting monitor mode users only, but
the following recent commit made it noticeable for quite everybody:

commit 3afc2167f60a327a2c1e1e2600ef209a3c2b75b7
Author: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Date:   Tue Mar 4 16:50:13 2014 +0200

    cfg80211/mac80211: ignore signal if the frame was heard on wrong channel

Reported-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Tested-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/net/wireless/b43/xmit.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/b43/xmit.c b/drivers/net/wireless/b43/xmit.c
index e85d34b..ebcce00 100644
--- a/drivers/net/wireless/b43/xmit.c
+++ b/drivers/net/wireless/b43/xmit.c
@@ -810,9 +810,13 @@ void b43_rx(struct b43_wldev *dev, struct sk_buff *skb, const void *_rxhdr)
 		break;
 	case B43_PHYTYPE_G:
 		status.band = IEEE80211_BAND_2GHZ;
-		/* chanid is the radio channel cookie value as used
-		 * to tune the radio. */
-		status.freq = chanid + 2400;
+		/* Somewhere between 478.104 and 508.1084 firmware for G-PHY
+		 * has been modified to be compatible with N-PHY and others.
+		 */
+		if (dev->fw.rev >= 508)
+			status.freq = ieee80211_channel_to_frequency(chanid, status.band);
+		else
+			status.freq = chanid + 2400;
 		break;
 	case B43_PHYTYPE_N:
 	case B43_PHYTYPE_LP:
-- 
1.9.1


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

* [PATCH 3.8 105/116] rt2x00: fix rfkill regression on rt2500pci
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (103 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 104/116] b43: fix frequency reported on G-PHY with /new/ firmware Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:21 ` [PATCH 3.8 106/116] x86_32, entry: Do syscall exit work on badsys (CVE-2014-4508) Kamal Mostafa
                   ` (10 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Stanislaw Gruszka, John W. Linville, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Stanislaw Gruszka <stf_xl@wp.pl>

commit 616a8394b5df8c88f4dd416f4527439a4e365034 upstream.

As reported by Niels, starting rfkill polling during device probe
(commit e2bc7c5, generally sane change) broke rfkill on rt2500pci
device. I considered that bug as some initalization issue, which
should be fixed on rt2500pci specific code. But after several
attempts (see bug report for details) we fail to find working solution.
Hence I decided to revert to old behaviour on rt2500pci to fix
regression.

Additionally patch also unregister rfkill on device remove instead
of ifconfig down, what was another issue introduced by bad commit.

Bug report:
https://bugzilla.kernel.org/show_bug.cgi?id=73821

Fixes: e2bc7c5f3cb8 ("rt2x00: Fix rfkill_polling register function.")
Bisected-by: Niels <nille0386@googlemail.com>
Reported-and-tested-by: Niels <nille0386@googlemail.com>
Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/net/wireless/rt2x00/rt2500pci.c |  7 ++++++-
 drivers/net/wireless/rt2x00/rt2x00.h    |  1 +
 drivers/net/wireless/rt2x00/rt2x00dev.c | 24 +++++++++++++++++++++---
 3 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c
index 9bea10f..2ab12a4 100644
--- a/drivers/net/wireless/rt2x00/rt2500pci.c
+++ b/drivers/net/wireless/rt2x00/rt2500pci.c
@@ -1679,8 +1679,13 @@ static int rt2500pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
 	/*
 	 * Detect if this device has an hardware controlled radio.
 	 */
-	if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_HARDWARE_RADIO))
+	if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_HARDWARE_RADIO)) {
 		__set_bit(CAPABILITY_HW_BUTTON, &rt2x00dev->cap_flags);
+		/*
+		 * On this device RFKILL initialized during probe does not work.
+		 */
+		__set_bit(REQUIRE_DELAYED_RFKILL, &rt2x00dev->cap_flags);
+	}
 
 	/*
 	 * Check if the BBP tuning should be enabled.
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
index 0751b35..dfffbfb 100644
--- a/drivers/net/wireless/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/rt2x00/rt2x00.h
@@ -720,6 +720,7 @@ enum rt2x00_capability_flags {
 	REQUIRE_SW_SEQNO,
 	REQUIRE_HT_TX_DESC,
 	REQUIRE_PS_AUTOWAKE,
+	REQUIRE_DELAYED_RFKILL,
 
 	/*
 	 * Capabilities
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index a1789f5..0e2cd3c 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -1032,9 +1032,10 @@ static void rt2x00lib_uninitialize(struct rt2x00_dev *rt2x00dev)
 		return;
 
 	/*
-	 * Unregister extra components.
+	 * Stop rfkill polling.
 	 */
-	rt2x00rfkill_unregister(rt2x00dev);
+	if (test_bit(REQUIRE_DELAYED_RFKILL, &rt2x00dev->cap_flags))
+		rt2x00rfkill_unregister(rt2x00dev);
 
 	/*
 	 * Allow the HW to uninitialize.
@@ -1072,6 +1073,12 @@ static int rt2x00lib_initialize(struct rt2x00_dev *rt2x00dev)
 
 	set_bit(DEVICE_STATE_INITIALIZED, &rt2x00dev->flags);
 
+	/*
+	 * Start rfkill polling.
+	 */
+	if (test_bit(REQUIRE_DELAYED_RFKILL, &rt2x00dev->cap_flags))
+		rt2x00rfkill_register(rt2x00dev);
+
 	return 0;
 }
 
@@ -1262,7 +1269,12 @@ int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev)
 	rt2x00link_register(rt2x00dev);
 	rt2x00leds_register(rt2x00dev);
 	rt2x00debug_register(rt2x00dev);
-	rt2x00rfkill_register(rt2x00dev);
+
+	/*
+	 * Start rfkill polling.
+	 */
+	if (!test_bit(REQUIRE_DELAYED_RFKILL, &rt2x00dev->cap_flags))
+		rt2x00rfkill_register(rt2x00dev);
 
 	return 0;
 
@@ -1278,6 +1290,12 @@ void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev)
 	clear_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags);
 
 	/*
+	 * Stop rfkill polling.
+	 */
+	if (!test_bit(REQUIRE_DELAYED_RFKILL, &rt2x00dev->cap_flags))
+		rt2x00rfkill_unregister(rt2x00dev);
+
+	/*
 	 * Disable radio.
 	 */
 	rt2x00lib_disable_radio(rt2x00dev);
-- 
1.9.1


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

* [PATCH 3.8 106/116] x86_32, entry: Do syscall exit work on badsys (CVE-2014-4508)
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (104 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 105/116] rt2x00: fix rfkill regression on rt2500pci Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:27   ` Andy Lutomirski
  2014-07-22 22:21 ` [PATCH 3.8 107/116] hugetlb: fix copy_hugetlb_page_range() to handle migration/hwpoisoned entry Kamal Mostafa
                   ` (9 subsequent siblings)
  115 siblings, 1 reply; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Roland McGrath, Andy Lutomirski, H. Peter Anvin, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Andy Lutomirski <luto@amacapital.net>

commit 554086d85e71f30abe46fc014fea31929a7c6a8a upstream.

The bad syscall nr paths are their own incomprehensible route
through the entry control flow.  Rearrange them to work just like
syscalls that return -ENOSYS.

This fixes an OOPS in the audit code when fast-path auditing is
enabled and sysenter gets a bad syscall nr (CVE-2014-4508).

This has probably been broken since Linux 2.6.27:
af0575bba0 i386 syscall audit fast-path

Cc: Roland McGrath <roland@redhat.com>
Reported-by: Toralf Förster <toralf.foerster@gmx.de>
Signed-off-by: Andy Lutomirski <luto@amacapital.net>
Link: http://lkml.kernel.org/r/e09c499eade6fc321266dd6b54da7beb28d6991c.1403558229.git.luto@amacapital.net
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 arch/x86/kernel/entry_32.S | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
index 60d03c2..b32b466 100644
--- a/arch/x86/kernel/entry_32.S
+++ b/arch/x86/kernel/entry_32.S
@@ -434,9 +434,10 @@ sysenter_past_esp:
 	jnz sysenter_audit
 sysenter_do_call:
 	cmpl $(NR_syscalls), %eax
-	jae syscall_badsys
+	jae sysenter_badsys
 	call *sys_call_table(,%eax,4)
 	movl %eax,PT_EAX(%esp)
+sysenter_after_call:
 	LOCKDEP_SYS_EXIT
 	DISABLE_INTERRUPTS(CLBR_ANY)
 	TRACE_IRQS_OFF
@@ -686,7 +687,12 @@ END(syscall_fault)
 
 syscall_badsys:
 	movl $-ENOSYS,PT_EAX(%esp)
-	jmp resume_userspace
+	jmp syscall_exit
+END(syscall_badsys)
+
+sysenter_badsys:
+	movl $-ENOSYS,PT_EAX(%esp)
+	jmp sysenter_after_call
 END(syscall_badsys)
 	CFI_ENDPROC
 /*
-- 
1.9.1


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

* [PATCH 3.8 107/116] hugetlb: fix copy_hugetlb_page_range() to handle migration/hwpoisoned entry
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (105 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 106/116] x86_32, entry: Do syscall exit work on badsys (CVE-2014-4508) Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 23:08   ` Hugh Dickins
  2014-07-22 22:21 ` [PATCH 3.8 108/116] mm: fix crashes from mbind() merging vmas Kamal Mostafa
                   ` (8 subsequent siblings)
  115 siblings, 1 reply; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Naoya Horiguchi, Christoph Lameter, Andrew Morton,
	Linus Torvalds, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>

commit 4a705fef986231a3e7a6b1a6d3c37025f021f49f upstream.

There's a race between fork() and hugepage migration, as a result we try
to "dereference" a swap entry as a normal pte, causing kernel panic.
The cause of the problem is that copy_hugetlb_page_range() can't handle
"swap entry" family (migration entry and hwpoisoned entry) so let's fix
it.

[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Acked-by: Hugh Dickins <hughd@google.com>
Cc: Christoph Lameter <cl@linux.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 mm/hugetlb.c | 71 ++++++++++++++++++++++++++++++++++++------------------------
 1 file changed, 43 insertions(+), 28 deletions(-)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 35fc5eb..7b180d7 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -2291,6 +2291,31 @@ static void set_huge_ptep_writable(struct vm_area_struct *vma,
 		update_mmu_cache(vma, address, ptep);
 }
 
+static int is_hugetlb_entry_migration(pte_t pte)
+{
+	swp_entry_t swp;
+
+	if (huge_pte_none(pte) || pte_present(pte))
+		return 0;
+	swp = pte_to_swp_entry(pte);
+	if (non_swap_entry(swp) && is_migration_entry(swp))
+		return 1;
+	else
+		return 0;
+}
+
+static int is_hugetlb_entry_hwpoisoned(pte_t pte)
+{
+	swp_entry_t swp;
+
+	if (huge_pte_none(pte) || pte_present(pte))
+		return 0;
+	swp = pte_to_swp_entry(pte);
+	if (non_swap_entry(swp) && is_hwpoison_entry(swp))
+		return 1;
+	else
+		return 0;
+}
 
 int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
 			    struct vm_area_struct *vma)
@@ -2318,10 +2343,26 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
 
 		spin_lock(&dst->page_table_lock);
 		spin_lock_nested(&src->page_table_lock, SINGLE_DEPTH_NESTING);
-		if (!huge_pte_none(huge_ptep_get(src_pte))) {
+		entry = huge_ptep_get(src_pte);
+		if (huge_pte_none(entry)) { /* skip none entry */
+			;
+		} else if (unlikely(is_hugetlb_entry_migration(entry) ||
+				    is_hugetlb_entry_hwpoisoned(entry))) {
+			swp_entry_t swp_entry = pte_to_swp_entry(entry);
+
+			if (is_write_migration_entry(swp_entry) && cow) {
+				/*
+				 * COW mappings require pages in both
+				 * parent and child to be set to read.
+				 */
+				make_migration_entry_read(&swp_entry);
+				entry = swp_entry_to_pte(swp_entry);
+				set_huge_pte_at(src, addr, src_pte, entry);
+			}
+			set_huge_pte_at(dst, addr, dst_pte, entry);
+		} else {
 			if (cow)
 				huge_ptep_set_wrprotect(src, addr, src_pte);
-			entry = huge_ptep_get(src_pte);
 			ptepage = pte_page(entry);
 			get_page(ptepage);
 			page_dup_rmap(ptepage);
@@ -2336,32 +2377,6 @@ nomem:
 	return -ENOMEM;
 }
 
-static int is_hugetlb_entry_migration(pte_t pte)
-{
-	swp_entry_t swp;
-
-	if (huge_pte_none(pte) || pte_present(pte))
-		return 0;
-	swp = pte_to_swp_entry(pte);
-	if (non_swap_entry(swp) && is_migration_entry(swp))
-		return 1;
-	else
-		return 0;
-}
-
-static int is_hugetlb_entry_hwpoisoned(pte_t pte)
-{
-	swp_entry_t swp;
-
-	if (huge_pte_none(pte) || pte_present(pte))
-		return 0;
-	swp = pte_to_swp_entry(pte);
-	if (non_swap_entry(swp) && is_hwpoison_entry(swp))
-		return 1;
-	else
-		return 0;
-}
-
 void __unmap_hugepage_range(struct mmu_gather *tlb, struct vm_area_struct *vma,
 			    unsigned long start, unsigned long end,
 			    struct page *ref_page)
-- 
1.9.1


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

* [PATCH 3.8 108/116] mm: fix crashes from mbind() merging vmas
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (106 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 107/116] hugetlb: fix copy_hugetlb_page_range() to handle migration/hwpoisoned entry Kamal Mostafa
@ 2014-07-22 22:21 ` Kamal Mostafa
  2014-07-22 22:22 ` [PATCH 3.8 109/116] [CIFS] fix mount failure with broken pathnames when smb3 mount with mapchars option Kamal Mostafa
                   ` (7 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:21 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Hugh Dickins, KOSAKI Motohiro, Minchan Kim, Andrew Morton,
	Linus Torvalds, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Hugh Dickins <hughd@google.com>

commit d05f0cdcbe6388723f1900c549b4850360545201 upstream.

In v2.6.34 commit 9d8cebd4bcd7 ("mm: fix mbind vma merge problem")
introduced vma merging to mbind(), but it should have also changed the
convention of passing start vma from queue_pages_range() (formerly
check_range()) to new_vma_page(): vma merging may have already freed
that structure, resulting in BUG at mm/mempolicy.c:1738 and probably
worse crashes.

Fixes: 9d8cebd4bcd7 ("mm: fix mbind vma merge problem")
Reported-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Tested-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Signed-off-by: Hugh Dickins <hughd@google.com>
Acked-by: Christoph Lameter <cl@linux.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Minchan Kim <minchan.kim@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[ backport to 3.8-stable: queue_pages_range was check_range; context ]
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 mm/mempolicy.c | 44 +++++++++++++++++++-------------------------
 1 file changed, 19 insertions(+), 25 deletions(-)

diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index eb2848e..58198da 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -621,19 +621,18 @@ static unsigned long change_prot_numa(struct vm_area_struct *vma,
  * If pagelist != NULL then isolate pages from the LRU and
  * put them on the pagelist.
  */
-static struct vm_area_struct *
+static int
 check_range(struct mm_struct *mm, unsigned long start, unsigned long end,
 		const nodemask_t *nodes, unsigned long flags, void *private)
 {
-	int err;
-	struct vm_area_struct *first, *vma, *prev;
-
+	int err = 0;
+	struct vm_area_struct *vma, *prev;
 
-	first = find_vma(mm, start);
-	if (!first)
-		return ERR_PTR(-EFAULT);
+	vma = find_vma(mm, start);
+	if (!vma)
+		return -EFAULT;
 	prev = NULL;
-	for (vma = first; vma && vma->vm_start < end; vma = vma->vm_next) {
+	for (; vma && vma->vm_start < end; vma = vma->vm_next) {
 		unsigned long endvma = vma->vm_end;
 
 		if (endvma > end)
@@ -643,9 +642,9 @@ check_range(struct mm_struct *mm, unsigned long start, unsigned long end,
 
 		if (!(flags & MPOL_MF_DISCONTIG_OK)) {
 			if (!vma->vm_next && vma->vm_end < end)
-				return ERR_PTR(-EFAULT);
+				return -EFAULT;
 			if (prev && prev->vm_end < vma->vm_start)
-				return ERR_PTR(-EFAULT);
+				return -EFAULT;
 		}
 
 		if (is_vm_hugetlb_page(vma))
@@ -662,15 +661,13 @@ check_range(struct mm_struct *mm, unsigned long start, unsigned long end,
 
 			err = check_pgd_range(vma, start, endvma, nodes,
 						flags, private);
-			if (err) {
-				first = ERR_PTR(err);
+			if (err)
 				break;
-			}
 		}
 next:
 		prev = vma;
 	}
-	return first;
+	return err;
 }
 
 /*
@@ -1152,16 +1149,17 @@ out:
 
 /*
  * Allocate a new page for page migration based on vma policy.
- * Start assuming that page is mapped by vma pointed to by @private.
+ * Start by assuming the page is mapped by the same vma as contains @start.
  * Search forward from there, if not.  N.B., this assumes that the
  * list of pages handed to migrate_pages()--which is how we get here--
  * is in virtual address order.
  */
-static struct page *new_vma_page(struct page *page, unsigned long private, int **x)
+static struct page *new_page(struct page *page, unsigned long start, int **x)
 {
-	struct vm_area_struct *vma = (struct vm_area_struct *)private;
+	struct vm_area_struct *vma;
 	unsigned long uninitialized_var(address);
 
+	vma = find_vma(current->mm, start);
 	while (vma) {
 		address = page_address_in_vma(page, vma);
 		if (address != -EFAULT)
@@ -1187,7 +1185,7 @@ int do_migrate_pages(struct mm_struct *mm, const nodemask_t *from,
 	return -ENOSYS;
 }
 
-static struct page *new_vma_page(struct page *page, unsigned long private, int **x)
+static struct page *new_page(struct page *page, unsigned long start, int **x)
 {
 	return NULL;
 }
@@ -1197,7 +1195,6 @@ static long do_mbind(unsigned long start, unsigned long len,
 		     unsigned short mode, unsigned short mode_flags,
 		     nodemask_t *nmask, unsigned long flags)
 {
-	struct vm_area_struct *vma;
 	struct mm_struct *mm = current->mm;
 	struct mempolicy *new;
 	unsigned long end;
@@ -1263,11 +1260,9 @@ static long do_mbind(unsigned long start, unsigned long len,
 	if (err)
 		goto mpol_out;
 
-	vma = check_range(mm, start, end, nmask,
+	err = check_range(mm, start, end, nmask,
 			  flags | MPOL_MF_INVERT, &pagelist);
-
-	err = PTR_ERR(vma);	/* maybe ... */
-	if (!IS_ERR(vma))
+	if (!err)
 		err = mbind_range(mm, start, end, new);
 
 	if (!err) {
@@ -1275,8 +1270,7 @@ static long do_mbind(unsigned long start, unsigned long len,
 
 		if (!list_empty(&pagelist)) {
 			WARN_ON_ONCE(flags & MPOL_MF_LAZY);
-			nr_failed = migrate_pages(&pagelist, new_vma_page,
-						(unsigned long)vma,
+			nr_failed = migrate_pages(&pagelist, new_page, start,
 						false, MIGRATE_SYNC,
 						MR_MEMPOLICY_MBIND);
 			if (nr_failed)
-- 
1.9.1


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

* [PATCH 3.8 109/116] [CIFS] fix mount failure with broken pathnames when smb3 mount with mapchars option
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (107 preceding siblings ...)
  2014-07-22 22:21 ` [PATCH 3.8 108/116] mm: fix crashes from mbind() merging vmas Kamal Mostafa
@ 2014-07-22 22:22 ` Kamal Mostafa
  2014-07-22 22:22 ` [PATCH 3.8 110/116] powerpc: Don't skip ePAPR spin-table CPUs Kamal Mostafa
                   ` (6 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:22 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Steve French, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Steve French <smfrench@gmail.com>

commit ce36d9ab3bab06b7b5522f5c8b68fac231b76ffb upstream.

When we SMB3 mounted with mapchars (to allow reserved characters : \ / > < * ?
via the Unicode Windows to POSIX remap range) empty paths
(eg when we open "" to query the root of the SMB3 directory on mount) were not
null terminated so we sent garbarge as a path name on empty paths which caused
SMB2/SMB2.1/SMB3 mounts to fail when mapchars was specified.  mapchars is
particularly important since Unix Extensions for SMB3 are not supported (yet)

Signed-off-by: Steve French <smfrench@gmail.com>
Reviewed-by: David Disseldorp <ddiss@suse.de>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 fs/cifs/cifs_unicode.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/fs/cifs/cifs_unicode.c b/fs/cifs/cifs_unicode.c
index 71d5d0a..839a5321 100644
--- a/fs/cifs/cifs_unicode.c
+++ b/fs/cifs/cifs_unicode.c
@@ -290,7 +290,8 @@ int
 cifsConvertToUTF16(__le16 *target, const char *source, int srclen,
 		 const struct nls_table *cp, int mapChars)
 {
-	int i, j, charlen;
+	int i, charlen;
+	int j = 0;
 	char src_char;
 	__le16 dst_char;
 	wchar_t tmp;
@@ -298,12 +299,11 @@ cifsConvertToUTF16(__le16 *target, const char *source, int srclen,
 	if (!mapChars)
 		return cifs_strtoUTF16(target, source, PATH_MAX, cp);
 
-	for (i = 0, j = 0; i < srclen; j++) {
+	for (i = 0; i < srclen; j++) {
 		src_char = source[i];
 		charlen = 1;
 		switch (src_char) {
 		case 0:
-			put_unaligned(0, &target[j]);
 			goto ctoUTF16_out;
 		case ':':
 			dst_char = cpu_to_le16(UNI_COLON);
@@ -350,6 +350,7 @@ cifsConvertToUTF16(__le16 *target, const char *source, int srclen,
 	}
 
 ctoUTF16_out:
+	put_unaligned(0, &target[j]); /* Null terminate target unicode string */
 	return j;
 }
 
-- 
1.9.1


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

* [PATCH 3.8 110/116] powerpc: Don't skip ePAPR spin-table CPUs
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (108 preceding siblings ...)
  2014-07-22 22:22 ` [PATCH 3.8 109/116] [CIFS] fix mount failure with broken pathnames when smb3 mount with mapchars option Kamal Mostafa
@ 2014-07-22 22:22 ` Kamal Mostafa
  2014-07-22 22:22 ` [PATCH 3.8 111/116] ALSA: usb-audio: Fix races at disconnection and PCM closing Kamal Mostafa
                   ` (5 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:22 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Scott Wood, Michael Neuling, Emil Medve, Benjamin Herrenschmidt,
	Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Scott Wood <scottwood@freescale.com>

commit 6663a4fa6711050036562ddfd2086edf735fae21 upstream.

Commit 59a53afe70fd530040bdc69581f03d880157f15a "powerpc: Don't setup
CPUs with bad status" broke ePAPR SMP booting.  ePAPR says that CPUs
that aren't presently running shall have status of disabled, with
enable-method being used to determine whether the CPU can be enabled.

Fix by checking for spin-table, which is currently the only supported
enable-method.

Signed-off-by: Scott Wood <scottwood@freescale.com>
Cc: Michael Neuling <mikey@neuling.org>
Cc: Emil Medve <Emilian.Medve@Freescale.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 arch/powerpc/kernel/setup-common.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index b050263..069f857 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -455,9 +455,17 @@ void __init smp_setup_cpu_maps(void)
 		}
 
 		for (j = 0; j < nthreads && cpu < nr_cpu_ids; j++) {
+			bool avail;
+
 			DBG("    thread %d -> cpu %d (hard id %d)\n",
 			    j, cpu, intserv[j]);
-			set_cpu_present(cpu, of_device_is_available(dn));
+
+			avail = of_device_is_available(dn);
+			if (!avail)
+				avail = !of_property_match_string(dn,
+						"enable-method", "spin-table");
+
+			set_cpu_present(cpu, avail);
 			set_hard_smp_processor_id(cpu, intserv[j]);
 			set_cpu_possible(cpu, true);
 			cpu++;
-- 
1.9.1


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

* [PATCH 3.8 111/116] ALSA: usb-audio: Fix races at disconnection and PCM closing
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (109 preceding siblings ...)
  2014-07-22 22:22 ` [PATCH 3.8 110/116] powerpc: Don't skip ePAPR spin-table CPUs Kamal Mostafa
@ 2014-07-22 22:22 ` Kamal Mostafa
  2014-07-22 22:22 ` [PATCH 3.8 112/116] recordmcount/MIPS: Fix possible incorrect mcount_loc table entries in modules Kamal Mostafa
                   ` (4 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:22 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Takashi Iwai, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Takashi Iwai <tiwai@suse.de>

commit 92a586bdc06de6629dae1b357dac221253f55ff8 upstream.

When a USB-audio device is disconnected while PCM is still running, we
still see some race: the disconnect callback calls
snd_usb_endpoint_free() that calls release_urbs() and then kfree()
while a PCM stream would be closed at the same time and calls
stop_endpoints() that leads to wait_clear_urbs().  That is, the EP
object might be deallocated while a PCM stream is syncing with
wait_clear_urbs() with the same EP.

Basically calling multiple wait_clear_urbs() would work fine, also
calling wait_clear_urbs() and release_urbs() would work, too, as
wait_clear_urbs() just reads some fields in ep.  The problem is the
succeeding kfree() in snd_pcm_endpoint_free().

This patch moves out the EP deallocation into the later point, the
destructor callback.  At this stage, all PCMs must have been already
closed, so it's safe to free the objects.

Reported-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 sound/usb/card.c     | 13 ++++++++++---
 sound/usb/endpoint.c | 17 ++++++++++++++---
 sound/usb/endpoint.h |  1 +
 3 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/sound/usb/card.c b/sound/usb/card.c
index 3e4565f..3e42e2b 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -289,6 +289,11 @@ static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif)
 
 static int snd_usb_audio_free(struct snd_usb_audio *chip)
 {
+	struct list_head *p, *n;
+
+	list_for_each_safe(p, n, &chip->ep_list)
+		snd_usb_endpoint_free(p);
+
 	mutex_destroy(&chip->mutex);
 	kfree(chip);
 	return 0;
@@ -564,7 +569,7 @@ static void snd_usb_audio_disconnect(struct usb_device *dev,
 				     struct snd_usb_audio *chip)
 {
 	struct snd_card *card;
-	struct list_head *p, *n;
+	struct list_head *p;
 
 	if (chip == (void *)-1L)
 		return;
@@ -577,14 +582,16 @@ static void snd_usb_audio_disconnect(struct usb_device *dev,
 	mutex_lock(&register_mutex);
 	chip->num_interfaces--;
 	if (chip->num_interfaces <= 0) {
+		struct snd_usb_endpoint *ep;
+
 		snd_card_disconnect(card);
 		/* release the pcm resources */
 		list_for_each(p, &chip->pcm_list) {
 			snd_usb_stream_disconnect(p);
 		}
 		/* release the endpoint resources */
-		list_for_each_safe(p, n, &chip->ep_list) {
-			snd_usb_endpoint_free(p);
+		list_for_each_entry(ep, &chip->ep_list, list) {
+			snd_usb_endpoint_release(ep);
 		}
 		/* release the midi resources */
 		list_for_each(p, &chip->midi_list) {
diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
index f46a4e0..a86ccd7 100644
--- a/sound/usb/endpoint.c
+++ b/sound/usb/endpoint.c
@@ -950,19 +950,30 @@ int snd_usb_endpoint_deactivate(struct snd_usb_endpoint *ep)
 }
 
 /**
+ * snd_usb_endpoint_release: Tear down an snd_usb_endpoint
+ *
+ * @ep: the endpoint to release
+ *
+ * This function does not care for the endpoint's use count but will tear
+ * down all the streaming URBs immediately.
+ */
+void snd_usb_endpoint_release(struct snd_usb_endpoint *ep)
+{
+	release_urbs(ep, 1);
+}
+
+/**
  * snd_usb_endpoint_free: Free the resources of an snd_usb_endpoint
  *
  * @ep: the list header of the endpoint to free
  *
- * This function does not care for the endpoint's use count but will tear
- * down all the streaming URBs immediately and free all resources.
+ * This free all resources of the given ep.
  */
 void snd_usb_endpoint_free(struct list_head *head)
 {
 	struct snd_usb_endpoint *ep;
 
 	ep = list_entry(head, struct snd_usb_endpoint, list);
-	release_urbs(ep, 1);
 	kfree(ep);
 }
 
diff --git a/sound/usb/endpoint.h b/sound/usb/endpoint.h
index 447902d..b21f844 100644
--- a/sound/usb/endpoint.h
+++ b/sound/usb/endpoint.h
@@ -21,6 +21,7 @@ void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep);
 void snd_usb_endpoint_sync_pending_stop(struct snd_usb_endpoint *ep);
 int  snd_usb_endpoint_activate(struct snd_usb_endpoint *ep);
 int  snd_usb_endpoint_deactivate(struct snd_usb_endpoint *ep);
+void snd_usb_endpoint_release(struct snd_usb_endpoint *ep);
 void snd_usb_endpoint_free(struct list_head *head);
 
 int snd_usb_endpoint_implict_feedback_sink(struct snd_usb_endpoint *ep);
-- 
1.9.1


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

* [PATCH 3.8 112/116] recordmcount/MIPS: Fix possible incorrect mcount_loc table entries in modules
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (110 preceding siblings ...)
  2014-07-22 22:22 ` [PATCH 3.8 111/116] ALSA: usb-audio: Fix races at disconnection and PCM closing Kamal Mostafa
@ 2014-07-22 22:22 ` Kamal Mostafa
  2014-07-22 22:22 ` [PATCH 3.8 113/116] MIPS: MSC: Prevent out-of-bounds writes to MIPS SC ioremap'd region Kamal Mostafa
                   ` (3 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:22 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Alex Smith, linux-mips, Ralf Baechle, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Alex Smith <alex.smith@imgtec.com>

commit 91ad11d7cc6f4472ebf177a6252fbf0fd100d798 upstream.

On MIPS calls to _mcount in modules generate 2 instructions to load
the _mcount address (and therefore 2 relocations). The mcount_loc
table should only reference the first of these, so the second is
filtered out by checking the relocation offset and ignoring ones that
immediately follow the previous one seen.

However if a module has an _mcount call at offset 0, the second
relocation would not be filtered out due to old_r_offset == 0
being taken to mean that the current relocation is the first one
seen, and both would end up in the mcount_loc table.

This results in ftrace_make_nop() patching both (adjacent)
instructions to branches over the _mcount call sequence like so:

  0xffffffffc08a8000:  04 00 00 10     b       0xffffffffc08a8014
  0xffffffffc08a8004:  04 00 00 10     b       0xffffffffc08a8018
  0xffffffffc08a8008:  2d 08 e0 03     move    at,ra
  ...

The second branch is in the delay slot of the first, which is
defined to be unpredictable - on the platform on which this bug was
encountered, it triggers a reserved instruction exception.

Fix by initializing old_r_offset to ~0 and using that instead of 0
to determine whether the current relocation is the first seen.

Signed-off-by: Alex Smith <alex.smith@imgtec.com>
Cc: linux-kernel@vger.kernel.org
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/7098/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 scripts/recordmcount.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/recordmcount.h b/scripts/recordmcount.h
index 9d1421e..49b582a 100644
--- a/scripts/recordmcount.h
+++ b/scripts/recordmcount.h
@@ -163,11 +163,11 @@ static int mcount_adjust = 0;
 
 static int MIPS_is_fake_mcount(Elf_Rel const *rp)
 {
-	static Elf_Addr old_r_offset;
+	static Elf_Addr old_r_offset = ~(Elf_Addr)0;
 	Elf_Addr current_r_offset = _w(rp->r_offset);
 	int is_fake;
 
-	is_fake = old_r_offset &&
+	is_fake = (old_r_offset != ~(Elf_Addr)0) &&
 		(current_r_offset - old_r_offset == MIPS_FAKEMCOUNT_OFFSET);
 	old_r_offset = current_r_offset;
 
-- 
1.9.1


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

* [PATCH 3.8 113/116] MIPS: MSC: Prevent out-of-bounds writes to MIPS SC ioremap'd region
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (111 preceding siblings ...)
  2014-07-22 22:22 ` [PATCH 3.8 112/116] recordmcount/MIPS: Fix possible incorrect mcount_loc table entries in modules Kamal Mostafa
@ 2014-07-22 22:22 ` Kamal Mostafa
  2014-07-22 22:22 ` [PATCH 3.8 114/116] target: Fix left-over se_lun->lun_sep pointer OOPs Kamal Mostafa
                   ` (2 subsequent siblings)
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:22 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Markos Chandras, linux-mips, Ralf Baechle, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Markos Chandras <markos.chandras@imgtec.com>

commit ab6c15bc6620ebe220970cc040b29bcb2757f373 upstream.

Previously, the lower limit for the MIPS SC initialization loop was
set incorrectly allowing one extra loop leading to writes
beyond the MSC ioremap'd space. More precisely, the value of the 'imp'
in the last loop increased beyond the msc_irqmap_t boundaries and
as a result of which, the 'n' variable was loaded with an incorrect
value. This value was used later on to calculate the offset in the
MSC01_IC_SUP which led to random crashes like the following one:

CPU 0 Unable to handle kernel paging request at virtual address e75c0200,
epc == 8058dba4, ra == 8058db90
[...]
Call Trace:
[<8058dba4>] init_msc_irqs+0x104/0x154
[<8058b5bc>] arch_init_irq+0xd8/0x154
[<805897b0>] start_kernel+0x220/0x36c

Kernel panic - not syncing: Attempted to kill the idle task!

This patch fixes the problem

Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
Reviewed-by: James Hogan <james.hogan@imgtec.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/7118/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 arch/mips/kernel/irq-msc01.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/kernel/irq-msc01.c b/arch/mips/kernel/irq-msc01.c
index 14ac52c..884de34 100644
--- a/arch/mips/kernel/irq-msc01.c
+++ b/arch/mips/kernel/irq-msc01.c
@@ -131,7 +131,7 @@ void __init init_msc_irqs(unsigned long icubase, unsigned int irqbase, msc_irqma
 
 	board_bind_eic_interrupt = &msc_bind_eic_interrupt;
 
-	for (; nirq >= 0; nirq--, imp++) {
+	for (; nirq > 0; nirq--, imp++) {
 		int n = imp->im_irq;
 
 		switch (imp->im_type) {
-- 
1.9.1


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

* [PATCH 3.8 114/116] target: Fix left-over se_lun->lun_sep pointer OOPs
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (112 preceding siblings ...)
  2014-07-22 22:22 ` [PATCH 3.8 113/116] MIPS: MSC: Prevent out-of-bounds writes to MIPS SC ioremap'd region Kamal Mostafa
@ 2014-07-22 22:22 ` Kamal Mostafa
  2014-07-22 22:22 ` [PATCH 3.8 115/116] iscsi-target: Fix incorrect np->np_thread NULL assignment Kamal Mostafa
  2014-07-22 22:22 ` [PATCH 3.8 116/116] iscsi-target: fix iscsit_del_np deadlock on unload Kamal Mostafa
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:22 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Nicholas Bellinger, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Nicholas Bellinger <nab@linux-iscsi.org>

commit 83ff42fcce070801a3aa1cd6a3269d7426271a8d upstream.

This patch fixes a left-over se_lun->lun_sep pointer OOPs when one
of the /sys/kernel/config/target/$FABRIC/$WWPN/$TPGT/lun/$LUN/alua*
attributes is accessed after the $DEVICE symlink has been removed.

To address this bug, go ahead and clear se_lun->lun_sep memory in
core_dev_unexport(), so that the existing checks for show/store
ALUA attributes in target_core_fabric_configfs.c work as expected.

Reported-by: Sebastian Herbszt <herbszt@gmx.de>
Tested-by: Sebastian Herbszt <herbszt@gmx.de>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/target/target_core_device.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
index c461180..d0d943f 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -628,6 +628,7 @@ void core_dev_unexport(
 	dev->export_count--;
 	spin_unlock(&hba->device_lock);
 
+	lun->lun_sep = NULL;
 	lun->lun_se_dev = NULL;
 }
 
-- 
1.9.1


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

* [PATCH 3.8 115/116] iscsi-target: Fix incorrect np->np_thread NULL assignment
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (113 preceding siblings ...)
  2014-07-22 22:22 ` [PATCH 3.8 114/116] target: Fix left-over se_lun->lun_sep pointer OOPs Kamal Mostafa
@ 2014-07-22 22:22 ` Kamal Mostafa
  2014-07-22 22:22 ` [PATCH 3.8 116/116] iscsi-target: fix iscsit_del_np deadlock on unload Kamal Mostafa
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:22 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team; +Cc: Nicholas Bellinger, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Nicholas Bellinger <nab@linux-iscsi.org>

commit db6077fd0b7dd41dc6ff18329cec979379071f87 upstream.

When shutting down a target there is a race condition between
iscsit_del_np() and __iscsi_target_login_thread().
The latter sets the thread pointer to NULL, and the former
tries to issue kthread_stop() on that pointer without any
synchronization.

This patch moves the np->np_thread NULL assignment into
iscsit_del_np(), after kthread_stop() has completed. It also
removes the signal_pending() + np_state check, and only
exits when kthread_should_stop() is true.

Reported-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/target/iscsi/iscsi_target.c       | 1 +
 drivers/target/iscsi/iscsi_target_login.c | 5 -----
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index a6326f1..ba56bfe 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -460,6 +460,7 @@ int iscsit_del_np(struct iscsi_np *np)
 		 */
 		send_sig(SIGINT, np->np_thread, 1);
 		kthread_stop(np->np_thread);
+		np->np_thread = NULL;
 	}
 	iscsit_del_np_comm(np);
 
diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c
index fdb632f..6b82c62 100644
--- a/drivers/target/iscsi/iscsi_target_login.c
+++ b/drivers/target/iscsi/iscsi_target_login.c
@@ -1167,11 +1167,6 @@ old_sess_out:
 
 out:
 	stop = kthread_should_stop();
-	if (!stop && signal_pending(current)) {
-		spin_lock_bh(&np->np_thread_lock);
-		stop = (np->np_thread_state == ISCSI_NP_THREAD_SHUTDOWN);
-		spin_unlock_bh(&np->np_thread_lock);
-	}
 	/* Wait for another socket.. */
 	if (!stop)
 		return 1;
-- 
1.9.1


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

* [PATCH 3.8 116/116] iscsi-target: fix iscsit_del_np deadlock on unload
  2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
                   ` (114 preceding siblings ...)
  2014-07-22 22:22 ` [PATCH 3.8 115/116] iscsi-target: Fix incorrect np->np_thread NULL assignment Kamal Mostafa
@ 2014-07-22 22:22 ` Kamal Mostafa
  115 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-22 22:22 UTC (permalink / raw)
  To: linux-kernel, stable, kernel-team
  Cc: Mikulas Patocka, Nicholas Bellinger, Kamal Mostafa

3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.

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

From: Mikulas Patocka <mpatocka@redhat.com>

commit 81a9c5e72bdf7109a65102ca61d8cbd722cf4021 upstream.

On uniprocessor preemptible kernel, target core deadlocks on unload. The
following events happen:
* iscsit_del_np is called
* it calls send_sig(SIGINT, np->np_thread, 1);
* the scheduler switches to the np_thread
* the np_thread is woken up, it sees that kthread_should_stop() returns
  false, so it doesn't terminate
* the np_thread clears signals with flush_signals(current); and goes back
  to sleep in iscsit_accept_np
* the scheduler switches back to iscsit_del_np
* iscsit_del_np calls kthread_stop(np->np_thread);
* the np_thread is waiting in iscsit_accept_np and it doesn't respond to
  kthread_stop

The deadlock could be resolved if the administrator sends SIGINT signal to
the np_thread with killall -INT iscsi_np

The reproducible deadlock was introduced in commit
db6077fd0b7dd41dc6ff18329cec979379071f87, but the thread-stopping code was
racy even before.

This patch fixes the problem. Using kthread_should_stop to stop the
np_thread is unreliable, so we test np_thread_state instead. If
np_thread_state equals ISCSI_NP_THREAD_SHUTDOWN, the thread exits.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
[ kamal: backport to 3.8-stable: context ]
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/target/iscsi/iscsi_target_login.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c
index 6b82c62..1f400ae 100644
--- a/drivers/target/iscsi/iscsi_target_login.c
+++ b/drivers/target/iscsi/iscsi_target_login.c
@@ -867,7 +867,7 @@ fail:
 static int __iscsi_target_login_thread(struct iscsi_np *np)
 {
 	u8 buffer[ISCSI_HDR_LEN], iscsi_opcode, zero_tsih = 0;
-	int err, ret = 0, stop;
+	int err, ret = 0;
 	struct iscsi_conn *conn = NULL;
 	struct iscsi_login *login;
 	struct iscsi_portal_group *tpg = NULL;
@@ -884,6 +884,9 @@ static int __iscsi_target_login_thread(struct iscsi_np *np)
 	if (np->np_thread_state == ISCSI_NP_THREAD_RESET) {
 		np->np_thread_state = ISCSI_NP_THREAD_ACTIVE;
 		complete(&np->np_restart_comp);
+	} else if (np->np_thread_state == ISCSI_NP_THREAD_SHUTDOWN) {
+		spin_unlock_bh(&np->np_thread_lock);
+		goto exit;
 	} else {
 		np->np_thread_state = ISCSI_NP_THREAD_ACTIVE;
 	}
@@ -1166,11 +1169,9 @@ old_sess_out:
 	}
 
 out:
-	stop = kthread_should_stop();
-	/* Wait for another socket.. */
-	if (!stop)
-		return 1;
+	return 1;
 
+exit:
 	iscsi_stop_login_thread_timer(np);
 	spin_lock_bh(&np->np_thread_lock);
 	np->np_thread_state = ISCSI_NP_THREAD_EXIT;
@@ -1185,7 +1186,7 @@ int iscsi_target_login_thread(void *arg)
 
 	allow_signal(SIGINT);
 
-	while (!kthread_should_stop()) {
+	while (1) {
 		ret = __iscsi_target_login_thread(np);
 		/*
 		 * We break and exit here unless another sock_accept() call
-- 
1.9.1


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

* Re: [PATCH 3.8 106/116] x86_32, entry: Do syscall exit work on badsys (CVE-2014-4508)
  2014-07-22 22:21 ` [PATCH 3.8 106/116] x86_32, entry: Do syscall exit work on badsys (CVE-2014-4508) Kamal Mostafa
@ 2014-07-22 22:27   ` Andy Lutomirski
  2014-07-22 23:59     ` Greg KH
  2014-07-23 21:10     ` Kamal Mostafa
  0 siblings, 2 replies; 131+ messages in thread
From: Andy Lutomirski @ 2014-07-22 22:27 UTC (permalink / raw)
  To: Kamal Mostafa
  Cc: linux-kernel, stable, kernel-team, Roland McGrath, H. Peter Anvin

On Tue, Jul 22, 2014 at 3:21 PM, Kamal Mostafa <kamal@canonical.com> wrote:
> 3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.
>
> ------------------
>
> From: Andy Lutomirski <luto@amacapital.net>
>
> commit 554086d85e71f30abe46fc014fea31929a7c6a8a upstream.
>
> The bad syscall nr paths are their own incomprehensible route
> through the entry control flow.  Rearrange them to work just like
> syscalls that return -ENOSYS.
>
> This fixes an OOPS in the audit code when fast-path auditing is
> enabled and sysenter gets a bad syscall nr (CVE-2014-4508).
>
> This has probably been broken since Linux 2.6.27:
> af0575bba0 i386 syscall audit fast-path

Don't apply this without:

https://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?h=x86/urgent&id=8142b215501f8b291a108a202b3a053a265b03dd

Sorry!

--Andy

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

* Re: [PATCH 3.8 107/116] hugetlb: fix copy_hugetlb_page_range() to handle migration/hwpoisoned entry
  2014-07-22 22:21 ` [PATCH 3.8 107/116] hugetlb: fix copy_hugetlb_page_range() to handle migration/hwpoisoned entry Kamal Mostafa
@ 2014-07-22 23:08   ` Hugh Dickins
  2014-07-23 21:02     ` Kamal Mostafa
  0 siblings, 1 reply; 131+ messages in thread
From: Hugh Dickins @ 2014-07-22 23:08 UTC (permalink / raw)
  To: Kamal Mostafa
  Cc: linux-kernel, stable, kernel-team, Naoya Horiguchi,
	Christoph Lameter, Andrew Morton, Linus Torvalds

On Tue, 22 Jul 2014, Kamal Mostafa wrote:

> 3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.
> 
> ------------------
> 
> From: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
> 
> commit 4a705fef986231a3e7a6b1a6d3c37025f021f49f upstream.
> 
> There's a race between fork() and hugepage migration, as a result we try
> to "dereference" a swap entry as a normal pte, causing kernel panic.
> The cause of the problem is that copy_hugetlb_page_range() can't handle
> "swap entry" family (migration entry and hwpoisoned entry) so let's fix
> it.
> 
> [akpm@linux-foundation.org: coding-style fixes]
> Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
> Acked-by: Hugh Dickins <hughd@google.com>
> Cc: Christoph Lameter <cl@linux.com>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
> Signed-off-by: Kamal Mostafa <kamal@canonical.com>

Please drop this one for now: other -stables have carried it, but it
was found last week to contain a bug of its own, arguably worse than
what it's fixing.  Naoya-san has done the fix for that, it's in mmotm
and should make its way to Linus probably this week: so please hold
this back until that can join it - thanks.

Hugh

> ---
>  mm/hugetlb.c | 71 ++++++++++++++++++++++++++++++++++++------------------------
>  1 file changed, 43 insertions(+), 28 deletions(-)
> 
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index 35fc5eb..7b180d7 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -2291,6 +2291,31 @@ static void set_huge_ptep_writable(struct vm_area_struct *vma,
>  		update_mmu_cache(vma, address, ptep);
>  }
>  
> +static int is_hugetlb_entry_migration(pte_t pte)
> +{
> +	swp_entry_t swp;
> +
> +	if (huge_pte_none(pte) || pte_present(pte))
> +		return 0;
> +	swp = pte_to_swp_entry(pte);
> +	if (non_swap_entry(swp) && is_migration_entry(swp))
> +		return 1;
> +	else
> +		return 0;
> +}
> +
> +static int is_hugetlb_entry_hwpoisoned(pte_t pte)
> +{
> +	swp_entry_t swp;
> +
> +	if (huge_pte_none(pte) || pte_present(pte))
> +		return 0;
> +	swp = pte_to_swp_entry(pte);
> +	if (non_swap_entry(swp) && is_hwpoison_entry(swp))
> +		return 1;
> +	else
> +		return 0;
> +}
>  
>  int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
>  			    struct vm_area_struct *vma)
> @@ -2318,10 +2343,26 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
>  
>  		spin_lock(&dst->page_table_lock);
>  		spin_lock_nested(&src->page_table_lock, SINGLE_DEPTH_NESTING);
> -		if (!huge_pte_none(huge_ptep_get(src_pte))) {
> +		entry = huge_ptep_get(src_pte);
> +		if (huge_pte_none(entry)) { /* skip none entry */
> +			;
> +		} else if (unlikely(is_hugetlb_entry_migration(entry) ||
> +				    is_hugetlb_entry_hwpoisoned(entry))) {
> +			swp_entry_t swp_entry = pte_to_swp_entry(entry);
> +
> +			if (is_write_migration_entry(swp_entry) && cow) {
> +				/*
> +				 * COW mappings require pages in both
> +				 * parent and child to be set to read.
> +				 */
> +				make_migration_entry_read(&swp_entry);
> +				entry = swp_entry_to_pte(swp_entry);
> +				set_huge_pte_at(src, addr, src_pte, entry);
> +			}
> +			set_huge_pte_at(dst, addr, dst_pte, entry);
> +		} else {
>  			if (cow)
>  				huge_ptep_set_wrprotect(src, addr, src_pte);
> -			entry = huge_ptep_get(src_pte);
>  			ptepage = pte_page(entry);
>  			get_page(ptepage);
>  			page_dup_rmap(ptepage);
> @@ -2336,32 +2377,6 @@ nomem:
>  	return -ENOMEM;
>  }
>  
> -static int is_hugetlb_entry_migration(pte_t pte)
> -{
> -	swp_entry_t swp;
> -
> -	if (huge_pte_none(pte) || pte_present(pte))
> -		return 0;
> -	swp = pte_to_swp_entry(pte);
> -	if (non_swap_entry(swp) && is_migration_entry(swp))
> -		return 1;
> -	else
> -		return 0;
> -}
> -
> -static int is_hugetlb_entry_hwpoisoned(pte_t pte)
> -{
> -	swp_entry_t swp;
> -
> -	if (huge_pte_none(pte) || pte_present(pte))
> -		return 0;
> -	swp = pte_to_swp_entry(pte);
> -	if (non_swap_entry(swp) && is_hwpoison_entry(swp))
> -		return 1;
> -	else
> -		return 0;
> -}
> -
>  void __unmap_hugepage_range(struct mmu_gather *tlb, struct vm_area_struct *vma,
>  			    unsigned long start, unsigned long end,
>  			    struct page *ref_page)
> -- 
> 1.9.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 

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

* Re: [PATCH 3.8 076/116] xfs: ioctl check for capabilities in the current user namespace
  2014-07-22 22:21 ` [PATCH 3.8 076/116] xfs: ioctl check for capabilities in the current user namespace Kamal Mostafa
@ 2014-07-22 23:12   ` Dave Chinner
  2014-07-23 21:05     ` Kamal Mostafa
  0 siblings, 1 reply; 131+ messages in thread
From: Dave Chinner @ 2014-07-22 23:12 UTC (permalink / raw)
  To: Kamal Mostafa; +Cc: linux-kernel, stable, kernel-team, Dwight Engen, Ben Myers

On Tue, Jul 22, 2014 at 03:21:27PM -0700, Kamal Mostafa wrote:
> 3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.
> 
> ------------------
> 
> From: Dwight Engen <dwight.engen@oracle.com>
> 
> commit fd5e2aa8653665ae1cc60f7aca1069abdbcad3f6 upstream.
> 
> Use inode_capable() to check if SUID|SGID bits should be cleared to match
> similar check in inode_change_ok().
> 
> The check for CAP_LINUX_IMMUTABLE was not modified since all other file
> systems also check against init_user_ns rather than current_user_ns.
> 
> Only allow changing of projid from init_user_ns.
> 
> Reviewed-by: Dave Chinner <dchinner@redhat.com>
> Reviewed-by: Gao feng <gaofeng@cn.fujitsu.com>
> Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
> Signed-off-by: Ben Myers <bpm@sgi.com>
> [ kamal: 3.8-stable prereq for
>   23adbe1 fs,userns: Change inode_capable to capable_wrt_inode_uidgid ]
> Signed-off-by: Kamal Mostafa <kamal@canonical.com>
> ---
>  fs/xfs/xfs_ioctl.c  | 11 +++++++++--
>  kernel/capability.c |  1 +
>  2 files changed, 10 insertions(+), 2 deletions(-)

Why are you backporting this to 3.8? namespace support didn't come
along until much later, so grabbing one patch out of themiddle of a
patch series to allow userns support in XFS is likely to cause
problems because there's no supporting code in XFS it.

Please don't randomly cherry pick userns support patches that change
permission checks back into kernels that don't have userns support.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

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

* Re: [PATCH 3.8 106/116] x86_32, entry: Do syscall exit work on badsys (CVE-2014-4508)
  2014-07-22 22:27   ` Andy Lutomirski
@ 2014-07-22 23:59     ` Greg KH
  2014-07-23 21:10     ` Kamal Mostafa
  1 sibling, 0 replies; 131+ messages in thread
From: Greg KH @ 2014-07-22 23:59 UTC (permalink / raw)
  To: Andy Lutomirski
  Cc: Kamal Mostafa, linux-kernel, stable, kernel-team, Roland McGrath,
	H. Peter Anvin

On Tue, Jul 22, 2014 at 03:27:59PM -0700, Andy Lutomirski wrote:
> On Tue, Jul 22, 2014 at 3:21 PM, Kamal Mostafa <kamal@canonical.com> wrote:
> > 3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.
> >
> > ------------------
> >
> > From: Andy Lutomirski <luto@amacapital.net>
> >
> > commit 554086d85e71f30abe46fc014fea31929a7c6a8a upstream.
> >
> > The bad syscall nr paths are their own incomprehensible route
> > through the entry control flow.  Rearrange them to work just like
> > syscalls that return -ENOSYS.
> >
> > This fixes an OOPS in the audit code when fast-path auditing is
> > enabled and sysenter gets a bad syscall nr (CVE-2014-4508).
> >
> > This has probably been broken since Linux 2.6.27:
> > af0575bba0 i386 syscall audit fast-path
> 
> Don't apply this without:
> 
> https://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?h=x86/urgent&id=8142b215501f8b291a108a202b3a053a265b03dd
> 
> Sorry!

As that isn't in Linus's tree yet, don't apply that one either...

thanks,

greg k-h

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

* Re: [PATCH 3.8 107/116] hugetlb: fix copy_hugetlb_page_range() to handle migration/hwpoisoned entry
  2014-07-22 23:08   ` Hugh Dickins
@ 2014-07-23 21:02     ` Kamal Mostafa
  2014-07-24  0:07       ` Hugh Dickins
  0 siblings, 1 reply; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-23 21:02 UTC (permalink / raw)
  To: Hugh Dickins
  Cc: linux-kernel, stable, kernel-team, Naoya Horiguchi,
	Christoph Lameter, Andrew Morton, Linus Torvalds

On Tue, 2014-07-22 at 16:08 -0700, Hugh Dickins wrote:
> On Tue, 22 Jul 2014, Kamal Mostafa wrote:
> 
> > 3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.
> > 
> > ------------------
> > 
> > From: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
> > 
> > commit 4a705fef986231a3e7a6b1a6d3c37025f021f49f upstream.
> > 
> > There's a race between fork() and hugepage migration, as a result we try
> > [...]
> 
> Please drop this one for now: other -stables have carried it, but it
> was found last week to contain a bug of its own, arguably worse than
> what it's fixing.  Naoya-san has done the fix for that, it's in mmotm
> and should make its way to Linus probably this week: so please hold
> this back until that can join it - thanks.
> 
> Hugh

OK, I've dropped it from the 3.8-stable queue, and will watch for the
fix to land.  Thanks very much, Hugh!

 -Kamal



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

* Re: [PATCH 3.8 076/116] xfs: ioctl check for capabilities in the current user namespace
  2014-07-22 23:12   ` Dave Chinner
@ 2014-07-23 21:05     ` Kamal Mostafa
  2014-07-24  1:51       ` Eric W. Biederman
  0 siblings, 1 reply; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-23 21:05 UTC (permalink / raw)
  To: Dave Chinner; +Cc: linux-kernel, stable, kernel-team, Dwight Engen, Ben Myers

On Wed, 2014-07-23 at 09:12 +1000, Dave Chinner wrote:
> On Tue, Jul 22, 2014 at 03:21:27PM -0700, Kamal Mostafa wrote:
> > 3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.
> > 
> > ------------------
> > 
> > From: Dwight Engen <dwight.engen@oracle.com>
> > 
> > commit fd5e2aa8653665ae1cc60f7aca1069abdbcad3f6 upstream.
> > 
> > Use inode_capable() to check if SUID|SGID bits should be cleared to match
> > [...]
> 
> Why are you backporting this to 3.8? namespace support didn't come
> along until much later, so grabbing one patch out of themiddle of a
> patch series to allow userns support in XFS is likely to cause
> problems because there's no supporting code in XFS it.
> 
> Please don't randomly cherry pick userns support patches that change
> permission checks back into kernels that don't have userns support.

Yup, that's why we ask for reviews all right!  I've dropped these from
the 3.8-stable queue:

    fs,userns: Change inode_capable to capable_wrt_inode_uidgid
    xfs: ioctl check for capabilities in the current user namespace

Thanks Dave,

 -Kamal



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

* Re: [PATCH 3.8 106/116] x86_32, entry: Do syscall exit work on badsys (CVE-2014-4508)
  2014-07-22 22:27   ` Andy Lutomirski
  2014-07-22 23:59     ` Greg KH
@ 2014-07-23 21:10     ` Kamal Mostafa
  1 sibling, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-23 21:10 UTC (permalink / raw)
  To: Andy Lutomirski, Greg KH
  Cc: linux-kernel, stable, kernel-team, Roland McGrath, H. Peter Anvin

On Tue, 2014-07-22 at 15:27 -0700, Andy Lutomirski wrote:
> On Tue, Jul 22, 2014 at 3:21 PM, Kamal Mostafa <kamal@canonical.com> wrote:
> > 3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.
> >
> > ------------------
> >
> > From: Andy Lutomirski <luto@amacapital.net>
> >
> > commit 554086d85e71f30abe46fc014fea31929a7c6a8a upstream.
> >
> > The bad syscall nr paths are their own incomprehensible route
> > [...]
> 
> Don't apply this without:
> 
> https://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?h=x86/urgent&id=8142b215501f8b291a108a202b3a053a265b03dd
> 
> Sorry!

No worries -- I've dropped this from the 3.8-stable queue, pending . . .

> As that isn't in Linus's tree yet, don't apply that one either...
> thanks,
> greg k-h

. . . that.  Thanks Andy and Greg,

 -Kamal



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

* Re: [PATCH 3.8 107/116] hugetlb: fix copy_hugetlb_page_range() to handle migration/hwpoisoned entry
  2014-07-23 21:02     ` Kamal Mostafa
@ 2014-07-24  0:07       ` Hugh Dickins
  2014-07-24  8:54         ` Luis Henriques
                           ` (3 more replies)
  0 siblings, 4 replies; 131+ messages in thread
From: Hugh Dickins @ 2014-07-24  0:07 UTC (permalink / raw)
  To: Kamal Mostafa
  Cc: Jiri Slaby, Luis Henriques, linux-kernel, stable, kernel-team,
	Naoya Horiguchi, Christoph Lameter, Andrew Morton,
	Linus Torvalds

On Wed, 23 Jul 2014, Kamal Mostafa wrote:
> On Tue, 2014-07-22 at 16:08 -0700, Hugh Dickins wrote:
> > On Tue, 22 Jul 2014, Kamal Mostafa wrote:
> > 
> > > 3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.
> > > 
> > > ------------------
> > > 
> > > From: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
> > > 
> > > commit 4a705fef986231a3e7a6b1a6d3c37025f021f49f upstream.
> > > 
> > > There's a race between fork() and hugepage migration, as a result we try
> > > [...]
> > 
> > Please drop this one for now: other -stables have carried it, but it
> > was found last week to contain a bug of its own, arguably worse than
> > what it's fixing.  Naoya-san has done the fix for that, it's in mmotm
> > and should make its way to Linus probably this week: so please hold
> > this back until that can join it - thanks.
> > 
> > Hugh
> 
> OK, I've dropped it from the 3.8-stable queue, and will watch for the
> fix to land.  Thanks very much, Hugh!

commit 0253d634e0803a8376a0d88efee0bf523d8673f9
Author: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Date:   Wed Jul 23 14:00:19 2014 -0700
mm: hugetlb: fix copy_hugetlb_page_range()

is now in Linus's tree: so the original patch is good to go into
your -stables, so long as you add 0253d634e080 on top.

Hugh

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

* Re: [PATCH 3.8 076/116] xfs: ioctl check for capabilities in the current user namespace
  2014-07-23 21:05     ` Kamal Mostafa
@ 2014-07-24  1:51       ` Eric W. Biederman
  2014-07-24 19:27         ` Kamal Mostafa
  0 siblings, 1 reply; 131+ messages in thread
From: Eric W. Biederman @ 2014-07-24  1:51 UTC (permalink / raw)
  To: Kamal Mostafa
  Cc: Dave Chinner, linux-kernel, stable, kernel-team, Dwight Engen, Ben Myers

Kamal Mostafa <kamal@canonical.com> writes:

> On Wed, 2014-07-23 at 09:12 +1000, Dave Chinner wrote:
>> On Tue, Jul 22, 2014 at 03:21:27PM -0700, Kamal Mostafa wrote:
>> > 3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.
>> > 
>> > ------------------
>> > 
>> > From: Dwight Engen <dwight.engen@oracle.com>
>> > 
>> > commit fd5e2aa8653665ae1cc60f7aca1069abdbcad3f6 upstream.
>> > 
>> > Use inode_capable() to check if SUID|SGID bits should be cleared to match
>> > [...]
>> 
>> Why are you backporting this to 3.8? namespace support didn't come
>> along until much later, so grabbing one patch out of themiddle of a
>> patch series to allow userns support in XFS is likely to cause
>> problems because there's no supporting code in XFS it.
>> 
>> Please don't randomly cherry pick userns support patches that change
>> permission checks back into kernels that don't have userns support.
>
> Yup, that's why we ask for reviews all right!  I've dropped these from
> the 3.8-stable queue:
>
>     fs,userns: Change inode_capable to capable_wrt_inode_uidgid

The fs,userns: Chage inode_capable to capable_wrt_inode_uidgid is
appropriate for 3.8.  I think that one is applicable all of the way
back to 3.4

I don't know if xfs in 3.8 called inode_capable in xfs and if it didn't
you can remove that hunk.  To keep things very simple you could just
skip the rename of inode_capable to capable_wrt_uidgid and just
include the one line change to add kgid_has_mapping.

But that bug fix is very much applicable to older kernels.

Eric

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

* Re: [PATCH 3.8 107/116] hugetlb: fix copy_hugetlb_page_range() to handle migration/hwpoisoned entry
  2014-07-24  0:07       ` Hugh Dickins
@ 2014-07-24  8:54         ` Luis Henriques
  2014-07-24 17:12         ` Kamal Mostafa
                           ` (2 subsequent siblings)
  3 siblings, 0 replies; 131+ messages in thread
From: Luis Henriques @ 2014-07-24  8:54 UTC (permalink / raw)
  To: Hugh Dickins
  Cc: Kamal Mostafa, Jiri Slaby, linux-kernel, stable, kernel-team,
	Naoya Horiguchi, Christoph Lameter, Andrew Morton,
	Linus Torvalds

On Wed, Jul 23, 2014 at 05:07:16PM -0700, Hugh Dickins wrote:
> On Wed, 23 Jul 2014, Kamal Mostafa wrote:
> > On Tue, 2014-07-22 at 16:08 -0700, Hugh Dickins wrote:
> > > On Tue, 22 Jul 2014, Kamal Mostafa wrote:
> > > 
> > > > 3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.
> > > > 
> > > > ------------------
> > > > 
> > > > From: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
> > > > 
> > > > commit 4a705fef986231a3e7a6b1a6d3c37025f021f49f upstream.
> > > > 
> > > > There's a race between fork() and hugepage migration, as a result we try
> > > > [...]
> > > 
> > > Please drop this one for now: other -stables have carried it, but it
> > > was found last week to contain a bug of its own, arguably worse than
> > > what it's fixing.  Naoya-san has done the fix for that, it's in mmotm
> > > and should make its way to Linus probably this week: so please hold
> > > this back until that can join it - thanks.
> > > 
> > > Hugh
> > 
> > OK, I've dropped it from the 3.8-stable queue, and will watch for the
> > fix to land.  Thanks very much, Hugh!
> 
> commit 0253d634e0803a8376a0d88efee0bf523d8673f9
> Author: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
> Date:   Wed Jul 23 14:00:19 2014 -0700
> mm: hugetlb: fix copy_hugetlb_page_range()
> 
> is now in Linus's tree: so the original patch is good to go into
> your -stables, so long as you add 0253d634e080 on top.
> 

Awesome, I'll queue both for the 3.11 kernel as well.  Thanks Hugh!

Cheers,
--
Luís

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

* Re: [PATCH 3.8 107/116] hugetlb: fix copy_hugetlb_page_range() to handle migration/hwpoisoned entry
  2014-07-24  0:07       ` Hugh Dickins
  2014-07-24  8:54         ` Luis Henriques
@ 2014-07-24 17:12         ` Kamal Mostafa
  2014-08-04  0:07         ` Ben Hutchings
  2014-08-19 15:45         ` Jiri Slaby
  3 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-24 17:12 UTC (permalink / raw)
  To: Hugh Dickins
  Cc: Jiri Slaby, Luis Henriques, linux-kernel, stable, kernel-team,
	Naoya Horiguchi, Christoph Lameter, Andrew Morton,
	Linus Torvalds

On Wed, 2014-07-23 at 17:07 -0700, Hugh Dickins wrote:
> 
> commit 0253d634e0803a8376a0d88efee0bf523d8673f9
> Author: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
> Date:   Wed Jul 23 14:00:19 2014 -0700
> mm: hugetlb: fix copy_hugetlb_page_range()
> 
> is now in Linus's tree: so the original patch is good to go into
> your -stables, so long as you add 0253d634e080 on top.
> 
> Hugh

OK, I have queued both for the imminent 3.8-stable release:
        
        4a705fe hugetlb: fix copy_hugetlb_page_range() to handle migration/hwpoisoned entry
        0253d63 mm: hugetlb: fix copy_hugetlb_page_range()

The first patch was already released in the previous 3.13-stable cycle;
I've now queued up the second for the next 3.13 cycle.

Thanks again, Hugh and Naoya-san!

 -Kamal



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

* Re: [PATCH 3.8 076/116] xfs: ioctl check for capabilities in the current user namespace
  2014-07-24  1:51       ` Eric W. Biederman
@ 2014-07-24 19:27         ` Kamal Mostafa
  0 siblings, 0 replies; 131+ messages in thread
From: Kamal Mostafa @ 2014-07-24 19:27 UTC (permalink / raw)
  To: Eric W. Biederman
  Cc: Dave Chinner, linux-kernel, stable, kernel-team, Dwight Engen, Ben Myers

On Wed, 2014-07-23 at 18:51 -0700, Eric W. Biederman wrote:

> The fs,userns: Chage inode_capable to capable_wrt_inode_uidgid is
> appropriate for 3.8.  I think that one is applicable all of the way
> back to 3.4
> 
> I don't know if xfs in 3.8 called inode_capable in xfs and if it didn't
> you can remove that hunk.

Okay, yup, that's what was done in the 3.10-stable port which I should
have found and used in the first place.

So I have now queued that (fs,userns: Change inode_capable to
capable_wrt_inode_uidgid) up again for 3.8-stable.

Thanks very much, Eric.  I appreciate you not letting this one slip past
me!

 -Kamal


>   To keep things very simple you could just
> skip the rename of inode_capable to capable_wrt_uidgid and just
> include the one line change to add kgid_has_mapping.
> 
> But that bug fix is very much applicable to older kernels.
> 
> Eric
> 



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

* Re: [PATCH 3.8 107/116] hugetlb: fix copy_hugetlb_page_range() to handle migration/hwpoisoned entry
  2014-07-24  0:07       ` Hugh Dickins
  2014-07-24  8:54         ` Luis Henriques
  2014-07-24 17:12         ` Kamal Mostafa
@ 2014-08-04  0:07         ` Ben Hutchings
  2014-08-19 15:45         ` Jiri Slaby
  3 siblings, 0 replies; 131+ messages in thread
From: Ben Hutchings @ 2014-08-04  0:07 UTC (permalink / raw)
  To: Hugh Dickins
  Cc: Kamal Mostafa, Jiri Slaby, Luis Henriques, linux-kernel, stable,
	kernel-team, Naoya Horiguchi, Christoph Lameter, Andrew Morton,
	Linus Torvalds

[-- Attachment #1: Type: text/plain, Size: 1594 bytes --]

On Wed, 2014-07-23 at 17:07 -0700, Hugh Dickins wrote:
> On Wed, 23 Jul 2014, Kamal Mostafa wrote:
> > On Tue, 2014-07-22 at 16:08 -0700, Hugh Dickins wrote:
> > > On Tue, 22 Jul 2014, Kamal Mostafa wrote:
> > > 
> > > > 3.8.13.27 -stable review patch.  If anyone has any objections, please let me know.
> > > > 
> > > > ------------------
> > > > 
> > > > From: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
> > > > 
> > > > commit 4a705fef986231a3e7a6b1a6d3c37025f021f49f upstream.
> > > > 
> > > > There's a race between fork() and hugepage migration, as a result we try
> > > > [...]
> > > 
> > > Please drop this one for now: other -stables have carried it, but it
> > > was found last week to contain a bug of its own, arguably worse than
> > > what it's fixing.  Naoya-san has done the fix for that, it's in mmotm
> > > and should make its way to Linus probably this week: so please hold
> > > this back until that can join it - thanks.
> > > 
> > > Hugh
> > 
> > OK, I've dropped it from the 3.8-stable queue, and will watch for the
> > fix to land.  Thanks very much, Hugh!
> 
> commit 0253d634e0803a8376a0d88efee0bf523d8673f9
> Author: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
> Date:   Wed Jul 23 14:00:19 2014 -0700
> mm: hugetlb: fix copy_hugetlb_page_range()
> 
> is now in Linus's tree: so the original patch is good to go into
> your -stables, so long as you add 0253d634e080 on top.

I've now queued up "mm: hugetlb: fix copy_hugetlb_page_range()" for 3.2.

Ben.

-- 
Ben Hutchings
Tomorrow will be cancelled due to lack of interest.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

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

* Re: [PATCH 3.8 107/116] hugetlb: fix copy_hugetlb_page_range() to handle migration/hwpoisoned entry
  2014-07-24  0:07       ` Hugh Dickins
                           ` (2 preceding siblings ...)
  2014-08-04  0:07         ` Ben Hutchings
@ 2014-08-19 15:45         ` Jiri Slaby
  3 siblings, 0 replies; 131+ messages in thread
From: Jiri Slaby @ 2014-08-19 15:45 UTC (permalink / raw)
  To: Hugh Dickins, Kamal Mostafa
  Cc: Luis Henriques, linux-kernel, stable, kernel-team,
	Naoya Horiguchi, Christoph Lameter, Andrew Morton,
	Linus Torvalds

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 07/24/2014, 02:07 AM, Hugh Dickins wrote:
> On Wed, 23 Jul 2014, Kamal Mostafa wrote:
>> On Tue, 2014-07-22 at 16:08 -0700, Hugh Dickins wrote:
>>> On Tue, 22 Jul 2014, Kamal Mostafa wrote:
>>> 
>>>> 3.8.13.27 -stable review patch.  If anyone has any
>>>> objections, please let me know.
>>>> 
>>>> ------------------
>>>> 
>>>> From: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
>>>> 
>>>> commit 4a705fef986231a3e7a6b1a6d3c37025f021f49f upstream.
>>>> 
>>>> There's a race between fork() and hugepage migration, as a
>>>> result we try [...]
>>> 
>>> Please drop this one for now: other -stables have carried it,
>>> but it was found last week to contain a bug of its own,
>>> arguably worse than what it's fixing.  Naoya-san has done the
>>> fix for that, it's in mmotm and should make its way to Linus
>>> probably this week: so please hold this back until that can
>>> join it - thanks.
>>> 
>>> Hugh
>> 
>> OK, I've dropped it from the 3.8-stable queue, and will watch for
>> the fix to land.  Thanks very much, Hugh!
> 
> commit 0253d634e0803a8376a0d88efee0bf523d8673f9 Author: Naoya
> Horiguchi <n-horiguchi@ah.jp.nec.com> Date:   Wed Jul 23 14:00:19
> 2014 -0700 mm: hugetlb: fix copy_hugetlb_page_range()
> 
> is now in Linus's tree: so the original patch is good to go into 
> your -stables, so long as you add 0253d634e080 on top.

So I have queued both to 3.12 now. Thanks.

- -- 
js
suse labs
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBAgAGBQJT83EFAAoJEL0lsQQGtHBJMfAP/jkMSZK9NI6ApH7RB+YREGgI
l3+0qdjYsknE/RlC7exmSh3WY+EfMc4iPcBomiQ3n26FTCEYo00xeqjSXLXcdVIK
AtUawzDRuQvKHBDFZvqgtBVpHRT89WkqoMSchzBDeFx3M6XvLWW2waUoI0aPu4s+
PYc2cqlgz2lAP9u8Ic1qNu3vznbWt+p96/H9b4wb3/UE9IxU1PCfkvq66ep9w2cv
0vq6VqszQwCQsP0Jb75b2EV+1woqCvlz6pOcf3qZlpkzLwcZ3UQHDha0USwMAHMa
L354ZxdKbyqZJrYwH6PDWWIEkMQ5mULHoesHjZg7oVIAsE3kJsqAghf6o+tK9Li7
RqXy2SxhV2/08AAk8QzAuJGKZp4rtZFc0O5eB6V9JWag2+5xLV5EmSWstkQAbGNc
IkVmGZuZWsiaIDj/eTOD4+p7iU51nj4GPxKEe/S51B7iFAjwenczIaSDFqDcLxU7
HiSDGxRMb16TQtBgX9v+sZDDlhf/y4gG9dUYNgAhteQklriXfaF6fiH5MhsCUmNW
tOIiyQV6NQ2XXCzZvGvGVBHutxKNQhQQtiiTMamp5U1sLcg9iAjyFemRK49W+Q3q
5gumMp+1ObY0XgqjRA6b7zVYYqIMtrLVTlWvTVB+UsQ9cS8stYfC0EYgSD/thvZ6
k3x6oxbVkZMrZDJCHWMP
=72iL
-----END PGP SIGNATURE-----

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

end of thread, other threads:[~2014-08-19 15:45 UTC | newest]

Thread overview: 131+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-22 22:20 [3.8.y.z extended stable] Linux 3.8.13.27 stable review Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 001/116] igb: fix stats for i210 rx_fifo_errors Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 002/116] netfilter: nf_nat: fix oops on netns removal Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 003/116] ACPI / video: Add Dell Inspiron 5737 to the blacklist Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 004/116] NFS: Don't declare inode uptodate unless all attributes were checked Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 005/116] usb: dwc3: gadget: clear stall when disabling endpoint Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 006/116] mtip32xx: Increase timeout for STANDBY IMMEDIATE command Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 007/116] mtip32xx: Remove dfs_parent after pci unregister Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 008/116] mtip32xx: Fix ERO and NoSnoop values in PCIe upstream on AMD systems Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 009/116] bluetooth: hci_ldisc: fix deadlock condition Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 010/116] powerpc/pseries: Fix overwritten PE state Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 011/116] PCI: Add new ID for Intel GPU "spurious interrupt" quirk Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 012/116] x86-32, espfix: Remove filter for espfix32 due to race Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 013/116] genirq: Sanitize spurious interrupt detection of threaded irqs Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 014/116] x86, x32: Use compat shims for io_{setup,submit} Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 015/116] iwlwifi: pcie: try to get ownership several times Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 016/116] UBIFS: fix an mmap and fsync race condition Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 017/116] ACPI: Fix conflict between customized DSDT and DSDT local copy Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 018/116] [SCSI] hpsa: add HP Smart Array Gen9 PCI ID's Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 019/116] hpsa: add new Smart Array PCI IDs (May 2014) Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 020/116] PM / OPP: fix incorrect OPP count handling in of_init_opp_table Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 021/116] HID: core: fix validation of report id 0 Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 022/116] IB/srp: Fix a sporadic crash triggered by cable pulling Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 023/116] reiserfs: call truncate_setsize under tailpack mutex Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 024/116] ARM: stacktrace: avoid listing stacktrace functions in stacktrace Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 025/116] SUNRPC: Fix a module reference leak in svc_handle_xprt Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 026/116] [media] uvcvideo: Fix clock param realtime setting Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 027/116] [media] ivtv: Fix Oops when no firmware is loaded Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 028/116] iio:adc:max1363 incorrect resolutions for max11604, max11605, max11610 and max11611 Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 029/116] MIPS: DTS: Fix missing device_type="memory" property in memory nodes Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 030/116] mac80211: fix IBSS join by initializing last_scan_completed Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 031/116] ahci: add PCI ID for Marvell 88SE91A0 SATA Controller Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 032/116] ext4: fix zeroing of page during writeback Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 033/116] ext4: fix wrong assert in ext4_mb_normalize_request() Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 034/116] IB/qib: Fix port in pkey change event Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 035/116] IB/ipath: Translate legacy diagpkt into newer extended diagpkt Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 036/116] uio: we cannot mmap unaligned page contents Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 037/116] uio: fix vma io range check in mmap Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 038/116] usb: usbtest: fix unlink write error with pattern 1 Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 039/116] s390/lowcore: reserve 96 bytes for IRB in lowcore Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 040/116] mac80211: don't check netdev state for debugfs read/write Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 041/116] usb: qcserial: add Netgear AirCard 341U Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 042/116] usb: qcserial: add additional Sierra Wireless QMI devices Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 043/116] IB/umad: Fix error handling Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 044/116] RDMA/cxgb4: Add missing padding at end of struct c4iw_create_cq_resp Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 045/116] nfsd: getattr for FATTR4_WORD0_FILES_AVAIL needs the statfs buffer Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 046/116] UBIFS: Remove incorrect assertion in shrink_tnc() Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 047/116] Bluetooth: Fix L2CAP deadlock Kamal Mostafa
2014-07-22 22:20 ` [PATCH 3.8 048/116] drm/radeon: fix typo in radeon_connector_is_dp12_capable() Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 049/116] drm/radeon/dp: fix lane/clock setup for dp 1.2 capable devices Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 050/116] drm/radeon/atom: fix dithering on certain panels Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 051/116] drm/radeon: only apply hdmi bpc pll flags when encoder mode is hdmi Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 052/116] ahci: Add Device ID for HighPoint RocketRaid 642L Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 053/116] mm: fix sleeping function warning from __put_anon_vma Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 054/116] mm: vmscan: do not throttle based on pfmemalloc reserves if node has no ZONE_NORMAL Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 055/116] memcg: do not hang on OOM when killed by userspace OOM access to memory reserves Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 056/116] mm: page_alloc: use word-based accesses for get/set pageblock bitmaps Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 057/116] mm/memory-failure.c-failure: send right signal code to correct thread Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 058/116] mm/memory-failure.c: don't let collect_procs() skip over processes for MF_ACTION_REQUIRED Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 059/116] powerpc/serial: Use saner flags when creating legacy ports Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 060/116] powerpc: 64bit sendfile is capped at 2GB Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 061/116] ALSA: hda/realtek - Add support of ALC891 codec Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 062/116] iscsi-target: Reject mutual authentication with reflected CHAP_C Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 063/116] IB/umad: Fix use-after-free on close Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 064/116] mm: vmscan: clear kswapd's special reclaim powers before exiting Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 065/116] rtc: rtc-at91rm9200: fix infinite wait for ACKUPD irq Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 066/116] ptrace: fix fork event messages across pid namespaces Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 067/116] idr: fix overflow bug during maximum ID calculation at maximum height Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 068/116] Input: elantech - deal with clickpads reporting right button events Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 069/116] Input: elantech - don't set bit 1 of reg_10 when the no_hw_res quirk is set Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 070/116] nfsd4: fix FREE_STATEID lockowner leak Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 071/116] Btrfs: fix double free in find_lock_delalloc_range Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 072/116] NFS: populate ->net in mount data when remounting Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 073/116] auditsc: audit_krule mask accesses need bounds checking Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 074/116] watchdog: ath79_wdt: avoid spurious restarts on AR934x Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 075/116] watchdog: sp805: Set watchdog_device->timeout from ->set_timeout() Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 076/116] xfs: ioctl check for capabilities in the current user namespace Kamal Mostafa
2014-07-22 23:12   ` Dave Chinner
2014-07-23 21:05     ` Kamal Mostafa
2014-07-24  1:51       ` Eric W. Biederman
2014-07-24 19:27         ` Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 077/116] fs,userns: Change inode_capable to capable_wrt_inode_uidgid Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 078/116] powerpc: Don't setup CPUs with bad status Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 079/116] dm thin: update discard_granularity to reflect the thin-pool blocksize Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 080/116] ALSA: compress: Cancel the optimization of compiler and fix the size of struct for all platform Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 081/116] evm: prohibit userspace writing 'security.evm' HMAC value Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 082/116] ima: introduce ima_kernel_read() Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 083/116] staging: iio: tsl2x7x_core: fix proximity treshold Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 084/116] iio: adc: at91: signedness bug in at91_adc_get_trigger_value_by_name() Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 085/116] Revert "uio: fix vma io range check in mmap" Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 086/116] USB: EHCI: avoid BIOS handover on the HASEE E200 Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 087/116] arm64: Bug fix in stack alignment exception Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 088/116] arm64: ptrace: change fs when passing kernel pointer to regset code Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 089/116] arm64: uid16: fix __kernel_old_{gid,uid}_t definitions Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 090/116] arm64/dma: Removing ARCH_HAS_DMA_GET_REQUIRED_MASK macro Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 091/116] ALSA: control: Protect user controls against concurrent access Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 092/116] ALSA: control: Fix replacing user controls Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 093/116] ALSA: control: Don't access controls outside of protected regions Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 094/116] ALSA: control: Handle numid overflow Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 095/116] ALSA: control: Make sure that id->index does not overflow Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 096/116] Bluetooth: Fix redundant encryption request for reauthentication Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 097/116] Bluetooth: Fix check for connection encryption Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 098/116] Bluetooth: Fix SSP acceptor just-works confirmation without MITM Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 099/116] Bluetooth: Fix setting correct authentication information for SMP STK Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 100/116] Bluetooth: Fix indicating discovery state when canceling inquiry Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 101/116] Bluetooth: Fix locking of hdev when calling into SMP code Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 102/116] Bluetooth: Allow change security level on ATT_CID in slave role Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 103/116] rt2x00: disable TKIP on USB Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 104/116] b43: fix frequency reported on G-PHY with /new/ firmware Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 105/116] rt2x00: fix rfkill regression on rt2500pci Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 106/116] x86_32, entry: Do syscall exit work on badsys (CVE-2014-4508) Kamal Mostafa
2014-07-22 22:27   ` Andy Lutomirski
2014-07-22 23:59     ` Greg KH
2014-07-23 21:10     ` Kamal Mostafa
2014-07-22 22:21 ` [PATCH 3.8 107/116] hugetlb: fix copy_hugetlb_page_range() to handle migration/hwpoisoned entry Kamal Mostafa
2014-07-22 23:08   ` Hugh Dickins
2014-07-23 21:02     ` Kamal Mostafa
2014-07-24  0:07       ` Hugh Dickins
2014-07-24  8:54         ` Luis Henriques
2014-07-24 17:12         ` Kamal Mostafa
2014-08-04  0:07         ` Ben Hutchings
2014-08-19 15:45         ` Jiri Slaby
2014-07-22 22:21 ` [PATCH 3.8 108/116] mm: fix crashes from mbind() merging vmas Kamal Mostafa
2014-07-22 22:22 ` [PATCH 3.8 109/116] [CIFS] fix mount failure with broken pathnames when smb3 mount with mapchars option Kamal Mostafa
2014-07-22 22:22 ` [PATCH 3.8 110/116] powerpc: Don't skip ePAPR spin-table CPUs Kamal Mostafa
2014-07-22 22:22 ` [PATCH 3.8 111/116] ALSA: usb-audio: Fix races at disconnection and PCM closing Kamal Mostafa
2014-07-22 22:22 ` [PATCH 3.8 112/116] recordmcount/MIPS: Fix possible incorrect mcount_loc table entries in modules Kamal Mostafa
2014-07-22 22:22 ` [PATCH 3.8 113/116] MIPS: MSC: Prevent out-of-bounds writes to MIPS SC ioremap'd region Kamal Mostafa
2014-07-22 22:22 ` [PATCH 3.8 114/116] target: Fix left-over se_lun->lun_sep pointer OOPs Kamal Mostafa
2014-07-22 22:22 ` [PATCH 3.8 115/116] iscsi-target: Fix incorrect np->np_thread NULL assignment Kamal Mostafa
2014-07-22 22:22 ` [PATCH 3.8 116/116] iscsi-target: fix iscsit_del_np deadlock on unload Kamal Mostafa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).