1. 04 Dec, 2013 40 commits
    • Rodolfo Giometti's avatar
      mmc: atmel-mci: fix oops in atmci_tasklet_func · aa54481e
      Rodolfo Giometti authored
      commit fbd986cd upstream.
      
      In some cases, a NULL pointer dereference happens because data is NULL when
      STATE_END_REQUEST case is reached in atmci_tasklet_func.
      Signed-off-by: default avatarRodolfo Giometti <giometti@enneenne.com>
      Acked-by: default avatarLudovic Desroches <ludovic.desroches@atmel.com>
      Acked-by: default avatarNicolas Ferre <nicolas.ferre@atmel.com>
      Signed-off-by: default avatarChris Ball <cjb@laptop.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      aa54481e
    • Ludovic Desroches's avatar
      mmc: atmel-mci: abort transfer on timeout error · 491e7886
      Ludovic Desroches authored
      commit c1fa3426 upstream.
      
      When a software timeout occurs, the transfer is not stopped. In DMA case,
      it causes DMA channel to be stuck because the transfer is still active
      causing following transfers to be queued but not computed.
      Signed-off-by: default avatarLudovic Desroches <ludovic.desroches@atmel.com>
      Reported-by: default avatarAlexander Morozov <etesial@gmail.com>
      Acked-by: default avatarNicolas Ferre <nicolas.ferre@atmel.com>
      Signed-off-by: default avatarChris Ball <cjb@laptop.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      491e7886
    • Weijie Yang's avatar
      mm/zswap: bugfix: memory leak when invalidate and reclaim occur concurrently · 7edd86e5
      Weijie Yang authored
      commit 67d13fe8 upstream.
      
      Consider the following scenario:
      
      thread 0: reclaim entry x (get refcount, but not call zswap_get_swap_cache_page)
      thread 1: call zswap_frontswap_invalidate_page to invalidate entry x.
      	finished, entry x and its zbud is not freed as its refcount != 0
      	now, the swap_map[x] = 0
      thread 0: now call zswap_get_swap_cache_page
      	swapcache_prepare return -ENOENT because entry x is not used any more
      	zswap_get_swap_cache_page return ZSWAP_SWAPCACHE_NOMEM
      	zswap_writeback_entry do nothing except put refcount
      
      Now, the memory of zswap_entry x and its zpage leak.
      
      Modify:
       - check the refcount in fail path, free memory if it is not referenced.
      
       - use ZSWAP_SWAPCACHE_FAIL instead of ZSWAP_SWAPCACHE_NOMEM as the fail path
         can be not only caused by nomem but also by invalidate.
      Signed-off-by: default avatarWeijie Yang <weijie.yang@samsung.com>
      Reviewed-by: default avatarBob Liu <bob.liu@oracle.com>
      Reviewed-by: default avatarMinchan Kim <minchan@kernel.org>
      Acked-by: default avatarSeth Jennings <sjenning@linux.vnet.ibm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7edd86e5
    • Akira Takeuchi's avatar
      mm: ensure get_unmapped_area() returns higher address than mmap_min_addr · e360d51f
      Akira Takeuchi authored
      commit 2afc745f upstream.
      
      This patch fixes the problem that get_unmapped_area() can return illegal
      address and result in failing mmap(2) etc.
      
      In case that the address higher than PAGE_SIZE is set to
      /proc/sys/vm/mmap_min_addr, the address lower than mmap_min_addr can be
      returned by get_unmapped_area(), even if you do not pass any virtual
      address hint (i.e.  the second argument).
      
      This is because the current get_unmapped_area() code does not take into
      account mmap_min_addr.
      
      This leads to two actual problems as follows:
      
      1. mmap(2) can fail with EPERM on the process without CAP_SYS_RAWIO,
         although any illegal parameter is not passed.
      
      2. The bottom-up search path after the top-down search might not work in
         arch_get_unmapped_area_topdown().
      
      Note: The first and third chunk of my patch, which changes "len" check,
      are for more precise check using mmap_min_addr, and not for solving the
      above problem.
      
      [How to reproduce]
      
      	--- test.c -------------------------------------------------
      	#include <stdio.h>
      	#include <unistd.h>
      	#include <sys/mman.h>
      	#include <sys/errno.h>
      
      	int main(int argc, char *argv[])
      	{
      		void *ret = NULL, *last_map;
      		size_t pagesize = sysconf(_SC_PAGESIZE);
      
      		do {
      			last_map = ret;
      			ret = mmap(0, pagesize, PROT_NONE,
      				MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
      	//		printf("ret=%p\n", ret);
      		} while (ret != MAP_FAILED);
      
      		if (errno != ENOMEM) {
      			printf("ERR: unexpected errno: %d (last map=%p)\n",
      			errno, last_map);
      		}
      
      		return 0;
      	}
      	---------------------------------------------------------------
      
      	$ gcc -m32 -o test test.c
      	$ sudo sysctl -w vm.mmap_min_addr=65536
      	vm.mmap_min_addr = 65536
      	$ ./test  (run as non-priviledge user)
      	ERR: unexpected errno: 1 (last map=0x10000)
      Signed-off-by: default avatarAkira Takeuchi <takeuchi.akr@jp.panasonic.com>
      Signed-off-by: default avatarKiyoshi Owada <owada.kiyoshi@jp.panasonic.com>
      Reviewed-by: default avatarNaoya Horiguchi <n-horiguchi@ah.jp.nec.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e360d51f
    • Stanislaw Gruszka's avatar
      rt2400pci: fix RSSI read · be200404
      Stanislaw Gruszka authored
      commit 2bf127a5 upstream.
      
      RSSI value is provided on word3 not on word2.
      Signed-off-by: default avatarStanislaw Gruszka <stf_xl@wp.pl>
      Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      be200404
    • Ursula Braun's avatar
      qeth: avoid buffer overflow in snmp ioctl · 8abbf7ce
      Ursula Braun authored
      commit 6fb392b1 upstream.
      
      Check user-defined length in snmp ioctl request and allow request
      only if it fits into a qeth command buffer.
      Signed-off-by: default avatarUrsula Braun <ursula.braun@de.ibm.com>
      Signed-off-by: default avatarFrank Blaschka <frank.blaschka@de.ibm.com>
      Reviewed-by: default avatarHeiko Carstens <heicars2@linux.vnet.ibm.com>
      Reported-by: default avatarNico Golde <nico@ngolde.de>
      Reported-by: default avatarFabian Yamaguchi <fabs@goesec.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8abbf7ce
    • Felix Fietkau's avatar
      ath5k: fix regression in tx status processing · 0d654144
      Felix Fietkau authored
      commit 7ede612f upstream.
      
      The regression was introduced in the following commit:
      
      0967e01e
      "ath5k: make use of the new rate control API"
      
      ath5k_tx_frame_completed saves the intended per-rate retry counts before
      they are cleared by ieee80211_tx_info_clear_status, however at this
      point the information in info->status.rates is incomplete.
      
      This causes significant throughput degradation and excessive packet loss
      on links where high bit rates don't work properly.
      
      Move the copy from bf->rates a few lines up to ensure that the saved
      retry counts are updated, and that they are really cleared in
      info->status.rates after the call to ieee80211_tx_info_clear_status.
      
      Cc: Thomas Huehn <thomas@net.t-labs.tu-berlin.de>
      Cc: Benjamin Vahl <bvahl@net.t-labs.tu-berlin.de>
      Reported-by: default avatarBen West <ben@gowasabi.net>
      Signed-off-by: default avatarFelix Fietkau <nbd@openwrt.org>
      Acked-by: default avatarThomas Huehn <thomas@net.t-labs.tu-berlin.de>
      Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0d654144
    • Larry Finger's avatar
      rtlwifi: rtl8192cu: Fix incorrect signal strength for unassociated AP · f9a7e9f5
      Larry Finger authored
      commit 78dbfecb upstream.
      
      The routine that processes received frames was returning the RSSI value for the
      signal strength; however, that value is available only for associated APs. As
      a result, the strength was the absurd value of 10 dBm. As a result, scans
      return incorrect values for the strength, which causes unwanted attempts to roam.
      Signed-off-by: default avatarLarry Finger <Larry.Finger@lwfinger.net>
      Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f9a7e9f5
    • Larry Finger's avatar
      rtlwifi: rtl8192se: Fix incorrect signal strength for unassociated AP · 6c72ff6c
      Larry Finger authored
      commit b4ade797 upstream.
      
      The routine that processes received frames was returning the RSSI value for the
      signal strength; however, that value is available only for associated APs. As
      a result, the strength was the absurd value of 10 dBm. As a result, scans
      return incorrect values for the strength, which causes unwanted attempts to roam.
      
      This patch fixes https://bugzilla.kernel.org/show_bug.cgi?id=63881.
      Signed-off-by: default avatarLarry Finger <Larry.Finger@lwfinger.net>
      Reported-by: default avatarMatthieu Baerts <matttbe@gmail.com>
      Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6c72ff6c
    • Larry Finger's avatar
      rtlwifi: rtl8192de: Fix incorrect signal strength for unassociated AP · 28a55f32
      Larry Finger authored
      commit 3545f3d5 upstream.
      
      The routine that processes received frames was returning the RSSI value for the
      signal strength; however, that value is available only for associated APs. As
      a result, the strength was the absurd value of 10 dBm. As a result, scans
      return incorrect values for the strength, which causes unwanted attempts to roam.
      Signed-off-by: default avatarLarry Finger <Larry.Finger@lwfinger.net>
      Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      28a55f32
    • Vegard Nossum's avatar
      xen/blkback: fix reference counting · 27c3c863
      Vegard Nossum authored
      commit ea5ec76d upstream.
      
      If the permission check fails, we drop a reference to the blkif without
      having taken it in the first place. The bug was introduced in commit
      604c499c (xen/blkback: Check device
      permissions before allowing OP_DISCARD).
      
      Cc: Jan Beulich <JBeulich@suse.com>
      Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Signed-off-by: default avatarVegard Nossum <vegard.nossum@oracle.com>
      Signed-off-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      27c3c863
    • Theodore Ts'o's avatar
    • Huang Shijie's avatar
      mtd: gpmi: fix the NULL pointer · dba6d8ec
      Huang Shijie authored
      commit 885d71e5 upstream.
      
      The imx23 board will check the fingerprint, so it will call the
      mx23_check_transcription_stamp. This function will use @chip->buffers->databuf
      as its buffer which is allocated in the nand_scan_tail().
      
      Unfortunately, the mx23_check_transcription_stamp is called before the
      nand_scan_tail(). So we will meet a NULL pointer bug:
      
      --------------------------------------------------------------------
      [    1.150000] NAND device: Manufacturer ID: 0xec, Chip ID: 0xd7 (Samsung NAND 4GiB 3,3V 8-bit), 4096MiB, page size: 4096, OOB size: 8
      [    1.160000] Unable to handle kernel NULL pointer dereference at virtual address 000005d0
      [    1.170000] pgd = c0004000
      [    1.170000] [000005d0] *pgd=00000000
      [    1.180000] Internal error: Oops: 5 [#1] ARM
      [    1.180000] Modules linked in:
      [    1.180000] CPU: 0 PID: 1 Comm: swapper Not tainted 3.12.0 #89
      [    1.180000] task: c7440000 ti: c743a000 task.ti: c743a000
      [    1.180000] PC is at memcmp+0x10/0x54
      [    1.180000] LR is at gpmi_nand_probe+0x42c/0x894
      [    1.180000] pc : [<c025fcb0>]    lr : [<c02f6a68>]    psr: 20000053
      [    1.180000] sp : c743be2c  ip : 600000d3  fp : ffffffff
      [    1.180000] r10: 000005d0  r9 : c02f5f08  r8 : 00000000
      [    1.180000] r7 : c75858a8  r6 : c75858a8  r5 : c7585b18  r4 : c7585800
      [    1.180000] r3 : 000005d0  r2 : 00000004  r1 : c05c33e4  r0 : 000005d0
      [    1.180000] Flags: nzCv  IRQs on  FIQs off  Mode SVC_32  ISA ARM  Segment kernel
      [    1.180000] Control: 0005317f  Table: 40004000  DAC: 00000017
      [    1.180000] Process swapper (pid: 1, stack limit = 0xc743a1c0)
      --------------------------------------------------------------------
      
      This patch rearrange the init procedure:
         Set the NAND_SKIP_BBTSCAN to skip the nand scan firstly, and after we
         set the proper settings, we will call the chip->scan_bbt() manually.
      Signed-off-by: default avatarHuang Shijie <b32955@freescale.com>
      Reported-by: default avatarFabio Estevam <festevam@gmail.com>
      Tested-by: default avatarFabio Estevam <fabio.estevam@freescale.com>
      Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dba6d8ec
    • Huang Shijie's avatar
      mtd: gpmi: fix kernel BUG due to racing DMA operations · 55968759
      Huang Shijie authored
      commit 7b3d2fb9 upstream.
      
      [1] The gpmi uses the nand_command_lp to issue the commands to NAND chips.
          The gpmi issues a DMA operation with gpmi_cmd_ctrl when it handles
          a NAND_CMD_NONE control command. So when we read a page(NAND_CMD_READ0)
          from the NAND, we may send two DMA operations back-to-back.
      
          If we do not serialize the two DMA operations, we will meet a bug when
      
          1.1) we enable CONFIG_DMA_API_DEBUG, CONFIG_DMADEVICES_DEBUG,
               and CONFIG_DEBUG_SG.
      
          1.2) Use the following commands in an UART console and a SSH console:
               cmd 1: while true;do dd if=/dev/mtd0 of=/dev/null;done
               cmd 1: while true;do dd if=/dev/mmcblk0 of=/dev/null;done
      
          The kernel log shows below:
          -----------------------------------------------------------------
          kernel BUG at lib/scatterlist.c:28!
          Unable to handle kernel NULL pointer dereference at virtual address 00000000
            .........................
          [<80044a0c>] (__bug+0x18/0x24) from [<80249b74>] (sg_next+0x48/0x4c)
          [<80249b74>] (sg_next+0x48/0x4c) from [<80255398>] (debug_dma_unmap_sg+0x170/0x1a4)
          [<80255398>] (debug_dma_unmap_sg+0x170/0x1a4) from [<8004af58>] (dma_unmap_sg+0x14/0x6c)
          [<8004af58>] (dma_unmap_sg+0x14/0x6c) from [<8027e594>] (mxs_dma_tasklet+0x18/0x1c)
          [<8027e594>] (mxs_dma_tasklet+0x18/0x1c) from [<8007d444>] (tasklet_action+0x114/0x164)
          -----------------------------------------------------------------
      
          1.3) Assume the two DMA operations is X (first) and Y (second).
      
               The root cause of the bug:
      	   Assume process P issues DMA X, and sleep on the completion
      	 @this->dma_done. X's tasklet callback is dma_irq_callback. It firstly
      	 wake up the process sleeping on the completion @this->dma_done,
      	 and then trid to unmap the scatterlist S. The waked process P will
      	 issue Y in another ARM core. Y initializes S->sg_magic to zero
      	 with sg_init_one(), while dma_irq_callback is unmapping S at the same
      	 time.
      
      	 See the diagram:
      
                         ARM core 0              |         ARM core 1
      	 -------------------------------------------------------------
               (P issues DMA X, then sleep)  --> |
                                                 |
               (X's tasklet wakes P)         --> |
                                                 |
                                                 | <-- (P begin to issue DMA Y)
                                                 |
               (X's tasklet unmap the            |
            scatterlist S with dma_unmap_sg) --> | <-- (Y calls sg_init_one() to init
                                                 |      scatterlist S)
                                                 |
      
      [2] This patch serialize both the X and Y in the following way:
           Unmap the DMA scatterlist S firstly, and wake up the process at the end
           of the DMA callback, in such a way, Y will be executed after X.
      
           After this patch:
      
                         ARM core 0              |         ARM core 1
      	 -------------------------------------------------------------
               (P issues DMA X, then sleep)  --> |
                                                 |
               (X's tasklet unmap the            |
            scatterlist S with dma_unmap_sg) --> |
                                                 |
               (X's tasklet wakes P)         --> |
                                                 |
                                                 | <-- (P begin to issue DMA Y)
                                                 |
                                                 | <-- (Y calls sg_init_one() to init
                                                 |     scatterlist S)
                                                 |
      Signed-off-by: default avatarHuang Shijie <b32955@freescale.com>
      Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      55968759
    • Josh Wu's avatar
      mtd: atmel_nand: fix bug driver will in a dead lock if no nand detected · 8a631f3a
      Josh Wu authored
      commit a749d13a upstream.
      
      In the atmel driver probe function, the code shows like following:
        atmel_nand_probe(...) {
              ...
      
        err_nand_ioremap:
              platform_driver_unregister(&atmel_nand_nfc_driver);
              return res;
        }
      
      If no nand flash detected, the driver probe function will goto
      err_nand_ioremap label.
      Then platform_driver_unregister() will be called. It will get the
      lock of atmel_nand device since it is parent of nfc_device. The
      problem is the lock is already hold by atmel_nand_probe itself.
      So system will be in a dead lock.
      
      This patch just simply removed to platform_driver_unregister() call.
      When atmel_nand driver is quit the platform_driver_unregister() will
      be called in atmel_nand_remove().
      
      [Brian: the NAND platform probe really has no business
       registering/unregistering another driver; this fixes the deadlock, but
       we should follow up the likely racy behavior here with a better
       architecture]
      Signed-off-by: default avatarJosh Wu <josh.wu@atmel.com>
      Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8a631f3a
    • Wang Haitao's avatar
      mtd: map: fixed bug in 64-bit systems · 7524987e
      Wang Haitao authored
      commit a4d62bab upstream.
      
      Hardware:
      	CPU: XLP832,the 64-bit OS
      	NOR Flash:S29GL128S 128M
      Software:
      	Kernel:2.6.32.41
      	Filesystem:JFFS2
      When writing files, errors appear:
      	Write len 182  but return retlen 180
      	Write of 182 bytes at 0x072c815c failed. returned -5, retlen 180
      	Write len 186  but return retlen 184
      	Write of 186 bytes at 0x072caff4 failed. returned -5, retlen 184
      These errors exist only in 64-bit systems,not in 32-bit systems. After analysis, we
      found that the left shift operation is wrong in map_word_load_partial. For instance:
      	unsigned char buf[3] ={0x9e,0x3a,0xea};
      	map_bankwidth(map) is 4;
      	for (i=0; i < 3; i++) {
      		int bitpos;
      		bitpos = (map_bankwidth(map)-1-i)*8;
      		orig.x[0] &= ~(0xff << bitpos);
      		orig.x[0] |= buf[i] << bitpos;
      	}
      
      The value of orig.x[0] is expected to be 0x9e3aeaff, but in this situation(64-bit
      System) we'll get the wrong value of 0xffffffff9e3aeaff due to the 64-bit sign
      extension:
      buf[i] is defined as "unsigned char" and the left-shift operation will convert it
      to the type of "signed int", so when left-shift buf[i] by 24 bits, the final result
      will get the wrong value: 0xffffffff9e3aeaff.
      
      If the left-shift bits are less than 24, then sign extension will not occur. Whereas
      the bankwidth of the nor flash we used is 4, therefore this BUG emerges.
      Signed-off-by: default avatarPang Xunlei <pang.xunlei@zte.com.cn>
      Signed-off-by: default avatarZhang Yi <zhang.yi20@zte.com.cn>
      Signed-off-by: default avatarLu Zhongjun <lu.zhongjun@zte.com.cn>
      Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7524987e
    • Brian Norris's avatar
      mtd: m25p80: fix allocation size · 0e2155be
      Brian Norris authored
      commit 778d226a upstream.
      
      This patch fixes two memory errors:
      
      1. During a probe failure (in mtd_device_parse_register?) the command
         buffer would not be freed.
      
      2. The command buffer's size is determined based on the 'fast_read'
         boolean, but the assignment of fast_read is made after this
         allocation. Thus, the buffer may be allocated "too small".
      
      To fix the first, just switch to the devres version of kzalloc.
      
      To fix the second, increase MAX_CMD_SIZE unconditionally. It's not worth
      saving a byte to fiddle around with the conditions here.
      
      This problem was reported by Yuhang Wang a while back.
      Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
      Reported-by: default avatarYuhang Wang <wangyuhang2014@gmail.com>
      Reviewed-by: default avatarSourav Poddar <sourav.poddar@ti.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0e2155be
    • Brian Norris's avatar
      mtd: nand: hack ONFI for non-power-of-2 dimensions · 87ce636f
      Brian Norris authored
      commit 4355b70c upstream.
      
      Some bright specification writers decided to write this in the ONFI spec
      (from ONFI 3.0, Section 3.1):
      
        "The number of blocks and number of pages per block is not required to
        be a power of two. In the case where one of these values is not a
        power of two, the corresponding address shall be rounded to an
        integral number of bits such that it addresses a range up to the
        subsequent power of two value. The host shall not access upper
        addresses in a range that is shown as not supported."
      
      This breaks every assumption MTD makes about NAND block/chip-size
      dimensions -- they *must* be a power of two!
      
      And of course, an enterprising manufacturer has made use of this lovely
      freedom. Exhibit A: Micron MT29F32G08CBADAWP
      
        "- Plane size: 2 planes x 1064 blocks per plane
         - Device size: 32Gb: 2128 blockss [sic]"
      
      This quickly hits a BUG() in nand_base.c, since the extra dimensions
      overflow so we think it's a second chip (on my single-chip setup):
      
          ONFI param page 0 valid
          ONFI flash detected
          NAND device: Manufacturer ID: 0x2c, Chip ID: 0x44 (Micron MT29F32G08CBADAWP), 4256MiB, page size: 8192, OOB size: 744
          ------------[ cut here ]------------
          kernel BUG at drivers/mtd/nand/nand_base.c:203!
          Internal error: Oops - BUG: 0 [#1] SMP ARM
          [... trim ...]
          [<c02cf3e4>] (nand_select_chip+0x18/0x2c) from [<c02d25c0>] (nand_do_read_ops+0x90/0x424)
          [<c02d25c0>] (nand_do_read_ops+0x90/0x424) from [<c02d2dd8>] (nand_read+0x54/0x78)
          [<c02d2dd8>] (nand_read+0x54/0x78) from [<c02ad2c8>] (mtd_read+0x84/0xbc)
          [<c02ad2c8>] (mtd_read+0x84/0xbc) from [<c02d4b28>] (scan_read.clone.4+0x4c/0x64)
          [<c02d4b28>] (scan_read.clone.4+0x4c/0x64) from [<c02d4c88>] (search_bbt+0x148/0x290)
          [<c02d4c88>] (search_bbt+0x148/0x290) from [<c02d4ea4>] (nand_scan_bbt+0xd4/0x5c0)
          [... trim ...]
          ---[ end trace 0c9363860d865ff2 ]---
      
      So to fix this, just truncate these dimensions down to the greatest
      power-of-2 dimension that is less than or equal to the specified
      dimension.
      Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      87ce636f
    • Mikulas Patocka's avatar
      loop: fix crash when using unassigned loop device · b9762e28
      Mikulas Patocka authored
      commit ef7e7c82 upstream.
      
      When the loop module is loaded, it creates 8 loop devices /dev/loop[0-7].
      The devices have no request routine and thus, when they are used without
      being assigned, a crash happens.
      
      For example, these commands cause crash (assuming there are no used loop
      devices):
      
      Kernel Fault: Code=26 regs=000000007f420980 (Addr=0000000000000010)
      CPU: 1 PID: 50 Comm: kworker/1:1 Not tainted 3.11.0 #1
      Workqueue: ksnaphd do_metadata [dm_snapshot]
      task: 000000007fcf4078 ti: 000000007f420000 task.ti: 000000007f420000
      [  116.319988]
           YZrvWESTHLNXBCVMcbcbcbcbOGFRQPDI
      PSW: 00001000000001001111111100001111 Not tainted
      r00-03  000000ff0804ff0f 00000000408bf5d0 00000000402d8204 000000007b7ff6c0
      r04-07  00000000408a95d0 000000007f420950 000000007b7ff6c0 000000007d06c930
      r08-11  000000007f4205c0 0000000000000001 000000007f4205c0 000000007f4204b8
      r12-15  0000000000000010 0000000000000000 0000000000000000 0000000000000000
      r16-19  000000001108dd48 000000004061cd7c 000000007d859800 000000000800000f
      r20-23  0000000000000000 0000000000000008 0000000000000000 0000000000000000
      r24-27  00000000ffffffff 000000007b7ff6c0 000000007d859800 00000000408a95d0
      r28-31  0000000000000000 000000007f420950 000000007f420980 000000007f4208e8
      sr00-03  0000000000000000 0000000000000000 0000000000000000 0000000000303000
      sr04-07  0000000000000000 0000000000000000 0000000000000000 0000000000000000
      [  117.549988]
      IASQ: 0000000000000000 0000000000000000 IAOQ: 00000000402d82fc 00000000402d8300
       IIR: 53820020    ISR: 0000000000000000  IOR: 0000000000000010
       CPU:        1   CR30: 000000007f420000 CR31: ffffffffffffffff
       ORIG_R28: 0000000000000001
       IAOQ[0]: generic_make_request+0x11c/0x1a0
       IAOQ[1]: generic_make_request+0x120/0x1a0
       RP(r2): generic_make_request+0x24/0x1a0
      Backtrace:
       [<00000000402d83f0>] submit_bio+0x70/0x140
       [<0000000011087c4c>] dispatch_io+0x234/0x478 [dm_mod]
       [<0000000011087f44>] sync_io+0xb4/0x190 [dm_mod]
       [<00000000110883bc>] dm_io+0x2c4/0x310 [dm_mod]
       [<00000000110bfcd0>] do_metadata+0x28/0xb0 [dm_snapshot]
       [<00000000401591d8>] process_one_work+0x160/0x460
       [<0000000040159bc0>] worker_thread+0x300/0x478
       [<0000000040161a70>] kthread+0x118/0x128
       [<0000000040104020>] end_fault_vector+0x20/0x28
       [<0000000040177220>] task_tick_fair+0x420/0x4d0
       [<00000000401aa048>] invoke_rcu_core+0x50/0x60
       [<00000000401ad5b8>] rcu_check_callbacks+0x210/0x8d8
       [<000000004014aaa0>] update_process_times+0xa8/0xc0
       [<00000000401ab86c>] rcu_process_callbacks+0x4b4/0x598
       [<0000000040142408>] __do_softirq+0x250/0x2c0
       [<00000000401789d0>] find_busiest_group+0x3c0/0xc70
      [  119.379988]
      Kernel panic - not syncing: Kernel Fault
      Rebooting in 1 seconds..
      Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b9762e28
    • Mikulas Patocka's avatar
      loop: fix crash if blk_alloc_queue fails · ec25370c
      Mikulas Patocka authored
      commit 3ec981e3 upstream.
      
      loop: fix crash if blk_alloc_queue fails
      
      If blk_alloc_queue fails, loop_add cleans up, but it doesn't clean up the
      identifier allocated with idr_alloc. That causes crash on module unload in
      idr_for_each(&loop_index_idr, &loop_exit_cb, NULL); where we attempt to
      remove non-existed device with that id.
      
      BUG: unable to handle kernel NULL pointer dereference at 0000000000000380
      IP: [<ffffffff812057c9>] del_gendisk+0x19/0x2d0
      PGD 43d399067 PUD 43d0ad067 PMD 0
      Oops: 0000 [#1] PREEMPT SMP
      Modules linked in: loop(-) dm_snapshot dm_zero dm_mirror dm_region_hash dm_log dm_loop dm_mod ip6table_filter ip6_tables uvesafb cfbcopyarea cfbimgblt cfbfillrect fbcon font bitblit fbcon_rotate fbcon_cw fbcon_ud fbcon_ccw softcursor fb fbdev msr ipt_MASQUERADE iptable_nat nf_nat_ipv4 nf_conntrack_ipv4 nf_defrag_ipv4 xt_state ipt_REJECT xt_tcpudp iptable_filter ip_tables x_tables bridge stp llc tun ipv6 cpufreq_userspace cpufreq_stats cpufreq_ondemand cpufreq_conservative cpufreq_powersave spadfs fuse hid_generic usbhid hid raid0 md_mod dmi_sysfs nf_nat_ftp nf_nat nf_conntrack_ftp nf_conntrack snd_usb_audio snd_pcm_oss snd_mixer_oss snd_pcm snd_timer snd_page_alloc lm85 hwmon_vid snd_hwdep snd_usbmidi_lib snd_rawmidi snd soundcore acpi_cpufreq ohci_hcd freq_table tg3 ehci_pci mperf ehci_hcd kvm_amd kvm sata_svw serverworks libphy libata ide_core k10temp usbcore hwmon microcode ptp pcspkr pps_core e100 skge mii usb_common i2c_piix4 floppy evdev rtc_cmos i2c_core processor but!
       ton unix
      CPU: 7 PID: 2735 Comm: rmmod Tainted: G        W    3.10.15-devel #15
      Hardware name: empty empty/S3992-E, BIOS 'V1.06   ' 06/09/2009
      task: ffff88043d38e780 ti: ffff88043d21e000 task.ti: ffff88043d21e000
      RIP: 0010:[<ffffffff812057c9>]  [<ffffffff812057c9>] del_gendisk+0x19/0x2d0
      RSP: 0018:ffff88043d21fe10  EFLAGS: 00010282
      RAX: ffffffffa05102e0 RBX: 0000000000000000 RCX: 0000000000000000
      RDX: 0000000000000000 RSI: ffff88043ea82800 RDI: 0000000000000000
      RBP: ffff88043d21fe48 R08: 0000000000000000 R09: 0000000000000001
      R10: 0000000000000001 R11: 0000000000000000 R12: 00000000000000ff
      R13: 0000000000000080 R14: 0000000000000000 R15: ffff88043ea82800
      FS:  00007ff646534700(0000) GS:ffff880447000000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
      CR2: 0000000000000380 CR3: 000000043e9bf000 CR4: 00000000000007e0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
      Stack:
       ffffffff8100aba4 0000000000000092 ffff88043d21fe48 ffff88043ea82800
       00000000000000ff ffff88043d21fe98 0000000000000000 ffff88043d21fe60
       ffffffffa05102b4 0000000000000000 ffff88043d21fe70 ffffffffa05102ec
      Call Trace:
       [<ffffffff8100aba4>] ? native_sched_clock+0x24/0x80
       [<ffffffffa05102b4>] loop_remove+0x14/0x40 [loop]
       [<ffffffffa05102ec>] loop_exit_cb+0xc/0x10 [loop]
       [<ffffffff81217b74>] idr_for_each+0x104/0x190
       [<ffffffffa05102e0>] ? loop_remove+0x40/0x40 [loop]
       [<ffffffff8109adc5>] ? trace_hardirqs_on_caller+0x105/0x1d0
       [<ffffffffa05135dc>] loop_exit+0x34/0xa58 [loop]
       [<ffffffff810a98ea>] SyS_delete_module+0x13a/0x260
       [<ffffffff81221d5e>] ? trace_hardirqs_on_thunk+0x3a/0x3f
       [<ffffffff813cff16>] system_call_fastpath+0x1a/0x1f
      Code: f0 4c 8b 6d f8 c9 c3 66 66 2e 0f 1f 84 00 00 00 00 00 55 48 89 e5 41 56 41 55 4c 8d af 80 00 00 00 41 54 53 48 89 fb 48 83 ec 18 <48> 83 bf 80 03 00
      00 00 74 4d e8 98 fe ff ff 31 f6 48 c7 c7 20
      RIP  [<ffffffff812057c9>] del_gendisk+0x19/0x2d0
       RSP <ffff88043d21fe10>
      CR2: 0000000000000380
      ---[ end trace 64ec069ec70f1309 ]---
      Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
      Acked-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ec25370c
    • Bart Van Assche's avatar
      IB/srp: Report receive errors correctly · cd8875d6
      Bart Van Assche authored
      commit cd4e3854 upstream.
      
      The IB spec does not guarantee that the opcode is available in error
      completions.  Hence do not rely on it.  See also commit 948d1e88
      ("IB/srp: Introduce srp_handle_qp_err()").
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cd8875d6
    • Bart Van Assche's avatar
      IB/srp: Avoid offlining operational SCSI devices · 748d2db3
      Bart Van Assche authored
      commit 99b6697a upstream.
      
      If SCSI commands are submitted with a SCSI request timeout that is
      lower than the the IB RC timeout, it can happen that the SCSI error
      handler has already started device recovery before transport layer
      error handling starts.  So it can happen that the SCSI error handler
      tries to abort a SCSI command after it has been reset by
      srp_rport_reconnect().
      
      Tell the SCSI error handler that such commands have finished and that
      it is not necessary to continue its recovery strategy for commands
      that have been reset by srp_rport_reconnect().
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      748d2db3
    • Vu Pham's avatar
      IB/srp: Remove target from list before freeing Scsi_Host structure · a3ecf3cc
      Vu Pham authored
      commit 65d7dd2f upstream.
      
      Remove an SRP target from the SRP target list before invoking the last
      scsi_host_put() call.  This change is necessary because that last put
      frees the memory that holds the srp_target_port structure.
      
      This patch prevents the following kernel oops:
      
          RIP: 0010:[<ffffffff810b00d0>] __lock_acquire+0x500/0x1570
          Call Trace:
           [<ffffffff810b11e4>] lock_acquire+0xa4/0x120
           [<ffffffff81531206>] _spin_lock+0x36/0x70
           [<ffffffffa01b6d8f>] srp_remove_work+0xef/0x180 [ib_srp]
           [<ffffffff8109125c>] worker_thread+0x21c/0x3d0
           [<ffffffff81096e86>] kthread+0x96/0xa0
           [<ffffffff8100c20a>] child_rip+0xa/0x20
      Signed-off-by: default avatarVu Pham <vuhuong@mellanox.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      
      [ bvanassche - Modified path description and CC'ed stable. ]
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
      a3ecf3cc
    • Mike Marciniszyn's avatar
      IB/qib: Fix txselect regression · 09304cda
      Mike Marciniszyn authored
      commit 2fadd831 upstream.
      
      Commit 7fac3301("IB/qib: checkpatch fixes") was overzealous in
      removing a simple_strtoul for a parse routine, setup_txselect().  That
      routine is required to handle a multi-value string.
      
      Unwind that aspect of the fix.
      Signed-off-by: default avatarMike Marciniszyn <mike.marciniszyn@intel.com>
      Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      09304cda
    • Jan Kara's avatar
      IB/qib: Convert qib_user_sdma_pin_pages() to use get_user_pages_fast() · 6e604271
      Jan Kara authored
      commit 603e7729 upstream.
      
      qib_user_sdma_queue_pkts() gets called with mmap_sem held for
      writing. Except for get_user_pages() deep down in
      qib_user_sdma_pin_pages() we don't seem to need mmap_sem at all.  Even
      more interestingly the function qib_user_sdma_queue_pkts() (and also
      qib_user_sdma_coalesce() called somewhat later) call copy_from_user()
      which can hit a page fault and we deadlock on trying to get mmap_sem
      when handling that fault.
      
      So just make qib_user_sdma_pin_pages() use get_user_pages_fast() and
      leave mmap_sem locking for mm.
      
      This deadlock has actually been observed in the wild when the node
      is under memory pressure.
      Reviewed-by: default avatarMike Marciniszyn <mike.marciniszyn@intel.com>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6e604271
    • Jan Kara's avatar
      IB/ipath: Convert ipath_user_sdma_pin_pages() to use get_user_pages_fast() · f292f8b1
      Jan Kara authored
      commit 4adcf7fb upstream.
      
      ipath_user_sdma_queue_pkts() gets called with mmap_sem held for
      writing.  Except for get_user_pages() deep down in
      ipath_user_sdma_pin_pages() we don't seem to need mmap_sem at all.
      
      Even more interestingly the function ipath_user_sdma_queue_pkts() (and
      also ipath_user_sdma_coalesce() called somewhat later) call
      copy_from_user() which can hit a page fault and we deadlock on trying
      to get mmap_sem when handling that fault.  So just make
      ipath_user_sdma_pin_pages() use get_user_pages_fast() and leave
      mmap_sem locking for mm.
      
      This deadlock has actually been observed in the wild when the node
      is under memory pressure.
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarMike Marciniszyn <mike.marciniszyn@intel.com>
      [ Merged in fix for call to get_user_pages_fast from Tetsuo Handa
        <penguin-kernel@I-love.SAKURA.ne.jp>.  - Roland ]
      Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f292f8b1
    • Eric Seppanen's avatar
      iscsi-target: chap auth shouldn't match username with trailing garbage · ee265ec2
      Eric Seppanen authored
      commit 86784c6b upstream.
      
      In iSCSI negotiations with initiator CHAP enabled, usernames with
      trailing garbage are permitted, because the string comparison only
      checks the strlen of the configured username.
      
      e.g. "usernameXXXXX" will be permitted to match "username".
      
      Just check one more byte so the trailing null char is also matched.
      Signed-off-by: default avatarEric Seppanen <eric@purestorage.com>
      Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ee265ec2
    • Eric Seppanen's avatar
      iscsi-target: fix extract_param to handle buffer length corner case · 94574447
      Eric Seppanen authored
      commit 369653e4 upstream.
      
      extract_param() is called with max_length set to the total size of the
      output buffer.  It's not safe to allow a parameter length equal to the
      buffer size as the terminating null would be written one byte past the
      end of the output buffer.
      Signed-off-by: default avatarEric Seppanen <eric@purestorage.com>
      Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      94574447
    • Nicholas Bellinger's avatar
      iscsi-target: Fix mutex_trylock usage in iscsit_increment_maxcmdsn · 82452e2a
      Nicholas Bellinger authored
      commit 5e8e6b4b upstream.
      
      This patch fixes a >= v3.10 regression bug with mutex_trylock() usage
      within iscsit_increment_maxcmdsn(), that was originally added to allow
      for a special case where ->cmdsn_mutex was already held from the
      iscsit_execute_cmd() exception path for ib_isert.
      
      When !mutex_trylock() was occuring under contention during normal RX/TX
      process context codepaths, the bug was manifesting itself as the following
      protocol error:
      
        Received CmdSN: 0x000fcbb7 is greater than MaxCmdSN: 0x000fcbb6, protocol error.
        Received CmdSN: 0x000fcbb8 is greater than MaxCmdSN: 0x000fcbb6, protocol error.
      
      This patch simply avoids the direct ib_isert callback in lio_queue_status()
      for the special iscsi_execute_cmd() exception cases, that allows the problematic
      mutex_trylock() usage in iscsit_increment_maxcmdsn() to go away.
      Reported-by: default avatarMoussa Ba <moussaba@micron.com>
      Tested-by: default avatarMoussa Ba <moussaba@micron.com>
      Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      82452e2a
    • Samir Benmendil's avatar
      ahci: add Marvell 9230 to the AHCI PCI device list · c6f8707f
      Samir Benmendil authored
      commit 6d5278a6 upstream.
      
      Tested with a DAWICONTROL DC-624e on 3.10.10
      Signed-off-by: default avatarSamir Benmendil <samir.benmendil@gmail.com>
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Reviewed-by: default avatarLevente Kurusa <levex@linux.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c6f8707f
    • xiangliang yu's avatar
      ahci: disabled FBS prior to issuing software reset · 9cfb82a3
      xiangliang yu authored
      commit 89dafa20 upstream.
      
      Tested with Marvell 88se9125, attached with one port mulitplier(5 ports)
      and one disk, we will get following boot log messages if using current
      code:
      
        ata8: SATA link up 6.0 Gbps (SStatus 133 SControl 330)
        ata8.15: Port Multiplier 1.2, 0x1b4b:0x9715 r160, 5 ports, feat 0x1/0x1f
        ahci 0000:03:00.0: FBS is enabled
        ata8.00: hard resetting link
        ata8.00: SATA link down (SStatus 0 SControl 330)
        ata8.01: hard resetting link
        ata8.01: SATA link down (SStatus 0 SControl 330)
        ata8.02: hard resetting link
        ata8.02: SATA link down (SStatus 0 SControl 330)
        ata8.03: hard resetting link
        ata8.03: SATA link up 6.0 Gbps (SStatus 133 SControl 133)
        ata8.04: hard resetting link
        ata8.04: failed to resume link (SControl 133)
        ata8.04: failed to read SCR 0 (Emask=0x40)
        ata8.04: failed to read SCR 0 (Emask=0x40)
        ata8.04: failed to read SCR 1 (Emask=0x40)
        ata8.04: failed to read SCR 0 (Emask=0x40)
        ata8.03: native sectors (2) is smaller than sectors (976773168)
        ata8.03: ATA-8: ST3500413AS, JC4B, max UDMA/133
        ata8.03: 976773168 sectors, multi 0: LBA48 NCQ (depth 31/32)
        ata8.03: configured for UDMA/133
        ata8.04: failed to IDENTIFY (I/O error, err_mask=0x100)
        ata8.15: hard resetting link
        ata8.15: SATA link up 6.0 Gbps (SStatus 133 SControl 330)
        ata8.15: Port Multiplier vendor mismatch '0x1b4b' != '0x133'
        ata8.15: PMP revalidation failed (errno=-19)
        ata8.15: hard resetting link
        ata8.15: SATA link up 6.0 Gbps (SStatus 133 SControl 330)
        ata8.15: Port Multiplier vendor mismatch '0x1b4b' != '0x133'
        ata8.15: PMP revalidation failed (errno=-19)
        ata8.15: limiting SATA link speed to 3.0 Gbps
        ata8.15: hard resetting link
        ata8.15: SATA link up 3.0 Gbps (SStatus 123 SControl 320)
        ata8.15: Port Multiplier vendor mismatch '0x1b4b' != '0x133'
        ata8.15: PMP revalidation failed (errno=-19)
        ata8.15: failed to recover PMP after 5 tries, giving up
        ata8.15: Port Multiplier detaching
        ata8.03: disabled
        ata8.00: disabled
        ata8: EH complete
      
      The reason is that current detection code doesn't follow AHCI spec:
      
      First,the port multiplier detection process look like this:
      
      	ahci_hardreset(link, class, deadline)
      	if (class == ATA_DEV_PMP) {
      		sata_pmp_attach(dev)	/* will enable FBS */
      		sata_pmp_init_links(ap, nr_ports);
      		ata_for_each_link(link, ap, EDGE) {
      			sata_std_hardreset(link, class, deadline);
      			if (link_is_online)	/* do soft reset */
      				ahci_softreset(link, class, deadline);
      		}
      	}
      But, according to chapter 9.3.9 in AHCI spec: Prior to issuing software
      reset, software shall clear PxCMD.ST to '0' and then clear PxFBS.EN to
      '0'.
      
      The patch test ok with kernel 3.11.1.
      
      tj: Patch white space contaminated, applied manually with trivial
          updates.
      Signed-off-by: default avatarXiangliang Yu <yuxiangl@marvell.com>
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9cfb82a3
    • James Ralston's avatar
      ahci: Add Device IDs for Intel Wildcat Point-LP · e7125540
      James Ralston authored
      commit 9f961a5f upstream.
      
      This patch adds the AHCI-mode SATA Device IDs for the Intel Wildcat Point-LP PCH.
      Signed-off-by: default avatarJames Ralston <james.d.ralston@intel.com>
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e7125540
    • Mathias Krause's avatar
      ipc, msg: fix message length check for negative values · 620ff33d
      Mathias Krause authored
      commit 4e9b45a1 upstream.
      
      On 64 bit systems the test for negative message sizes is bogus as the
      size, which may be positive when evaluated as a long, will get truncated
      to an int when passed to load_msg().  So a long might very well contain a
      positive value but when truncated to an int it would become negative.
      
      That in combination with a small negative value of msg_ctlmax (which will
      be promoted to an unsigned type for the comparison against msgsz, making
      it a big positive value and therefore make it pass the check) will lead to
      two problems: 1/ The kmalloc() call in alloc_msg() will allocate a too
      small buffer as the addition of alen is effectively a subtraction.  2/ The
      copy_from_user() call in load_msg() will first overflow the buffer with
      userland data and then, when the userland access generates an access
      violation, the fixup handler copy_user_handle_tail() will try to fill the
      remainder with zeros -- roughly 4GB.  That almost instantly results in a
      system crash or reset.
      
        ,-[ Reproducer (needs to be run as root) ]--
        | #include <sys/stat.h>
        | #include <sys/msg.h>
        | #include <unistd.h>
        | #include <fcntl.h>
        |
        | int main(void) {
        |     long msg = 1;
        |     int fd;
        |
        |     fd = open("/proc/sys/kernel/msgmax", O_WRONLY);
        |     write(fd, "-1", 2);
        |     close(fd);
        |
        |     msgsnd(0, &msg, 0xfffffff0, IPC_NOWAIT);
        |
        |     return 0;
        | }
        '---
      
      Fix the issue by preventing msgsz from getting truncated by consistently
      using size_t for the message length.  This way the size checks in
      do_msgsnd() could still be passed with a negative value for msg_ctlmax but
      we would fail on the buffer allocation in that case and error out.
      
      Also change the type of m_ts from int to size_t to avoid similar nastiness
      in other code paths -- it is used in similar constructs, i.e.  signed vs.
      unsigned checks.  It should never become negative under normal
      circumstances, though.
      
      Setting msg_ctlmax to a negative value is an odd configuration and should
      be prevented.  As that might break existing userland, it will be handled
      in a separate commit so it could easily be reverted and reworked without
      reintroducing the above described bug.
      
      Hardening mechanisms for user copy operations would have catched that bug
      early -- e.g.  checking slab object sizes on user copy operations as the
      usercopy feature of the PaX patch does.  Or, for that matter, detect the
      long vs.  int sign change due to truncation, as the size overflow plugin
      of the very same patch does.
      
      [akpm@linux-foundation.org: fix i386 min() warnings]
      Signed-off-by: default avatarMathias Krause <minipli@googlemail.com>
      Cc: Pax Team <pageexec@freemail.hu>
      Cc: Davidlohr Bueso <davidlohr@hp.com>
      Cc: Brad Spengler <spender@grsecurity.net>
      Cc: Manfred Spraul <manfred@colorfullife.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      620ff33d
    • Larry Finger's avatar
      rtlwifi: rtl8192cu: Fix more pointer arithmetic errors · c6ab0ff1
      Larry Finger authored
      commit eafbdde9 upstream.
      
      This driver uses a number of macros to get and set various fields in the
      RX and TX descriptors. To work correctly, a u8 pointer to the descriptor
      must be used; however, in some cases a descriptor structure pointer is used
      instead. In addition, a duplicated statement is removed.
      Signed-off-by: default avatarLarry Finger <Larry.Finger@lwfinger.net>
      Reported-by: default avatarMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
      Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c6ab0ff1
    • Felipe Pena's avatar
      rtlwifi: rtl8192se: Fix wrong assignment · b11e2eb8
      Felipe Pena authored
      commit 3aef7dde upstream.
      
      There is a typo in the struct member name on assignment when checking
      rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20_40, the check uses pwrgroup_ht40
      for bound limit and uses pwrgroup_ht20 when assigning instead.
      Signed-off-by: default avatarFelipe Pena <felipensp@gmail.com>
      Acked-by: default avatarLarry Finger <Larry.Finger@lwfinger.net>
      Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b11e2eb8
    • Mark Cave-Ayland's avatar
      rtlwifi: Fix endian error in extracting packet type · fb1f1a73
      Mark Cave-Ayland authored
      commit 0c5d63f0 upstream.
      
      All of the rtlwifi drivers have an error in the routine that tests if
      the data is "special". If it is, the subsequant transmission will be
      at the lowest rate to enhance reliability. The 16-bit quantity is
      big-endian, but was being extracted in native CPU mode. One of the
      effects of this bug is to inhibit association under some conditions
      as the TX rate is too high.
      
      Based on suggestions by Joe Perches, the entire routine is rewritten.
      
      One of the local headers contained duplicates of some of the ETH_P_XXX
      definitions. These are deleted.
      Signed-off-by: default avatarLarry Finger <Larry.Finger@lwfinger.net>
      Cc: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
      Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fb1f1a73
    • Larry Finger's avatar
      rtlwifi: rtl8188ee: Fix smatch warning in rtl8188ee/hw.c · 4a517025
      Larry Finger authored
      commit dab3df5e upstream.
      
      Smatch lists the following:
        CHECK   drivers/net/wireless/rtlwifi/rtl8188ee/hw.c
      drivers/net/wireless/rtlwifi/rtl8188ee/hw.c:149 _rtl88ee_set_fw_clock_on() info: ignoring unreachable code.
      drivers/net/wireless/rtlwifi/rtl8188ee/hw.c:149 _rtl88ee_set_fw_clock_on() info: ignoring unreachable code.
      
      This info message is the result of a real error due to a missing break statement
      in a "while (1)" loop.
      Signed-off-by: default avatarLarry Finger <Larry.Finger@lwfinger.net>
      Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4a517025
    • Ryan Mallon's avatar
      vsprintf: check real user/group id for %pK · 4aa3ce54
      Ryan Mallon authored
      commit 312b4e22 upstream.
      
      Some setuid binaries will allow reading of files which have read
      permission by the real user id.  This is problematic with files which
      use %pK because the file access permission is checked at open() time,
      but the kptr_restrict setting is checked at read() time.  If a setuid
      binary opens a %pK file as an unprivileged user, and then elevates
      permissions before reading the file, then kernel pointer values may be
      leaked.
      
      This happens for example with the setuid pppd application on Ubuntu 12.04:
      
        $ head -1 /proc/kallsyms
        00000000 T startup_32
      
        $ pppd file /proc/kallsyms
        pppd: In file /proc/kallsyms: unrecognized option 'c1000000'
      
      This will only leak the pointer value from the first line, but other
      setuid binaries may leak more information.
      
      Fix this by adding a check that in addition to the current process having
      CAP_SYSLOG, that effective user and group ids are equal to the real ids.
      If a setuid binary reads the contents of a file which uses %pK then the
      pointer values will be printed as NULL if the real user is unprivileged.
      
      Update the sysctl documentation to reflect the changes, and also correct
      the documentation to state the kptr_restrict=0 is the default.
      
      This is a only temporary solution to the issue.  The correct solution is
      to do the permission check at open() time on files, and to replace %pK
      with a function which checks the open() time permission.  %pK uses in
      printk should be removed since no sane permission check can be done, and
      instead protected by using dmesg_restrict.
      Signed-off-by: default avatarRyan Mallon <rmallon@gmail.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Joe Perches <joe@perches.com>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4aa3ce54
    • Shan Hai's avatar
      drivers/libata: Set max sector to 65535 for Slimtype DVD A DS8A9SH drive · 0a2f4ddf
      Shan Hai authored
      commit 0523f037 upstream.
      
      The "Slimtype DVD A  DS8A9SH" drive locks up with following backtrace when
      the max sector is smaller than 65535 bytes, fix it by adding a quirk to set
      the max sector to 65535 bytes.
      
      INFO: task flush-11:0:663 blocked for more than 120 seconds.
      "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
      flush-11:0    D 00000000ffff5ceb     0   663      2 0x00000000
       ffff88026d3b1710 0000000000000046 0000000000000001 0000000000000000
       ffff88026f2530c0 ffff88026d365860 ffff88026d3b16e0 ffffffff812ffd52
       ffff88026d4fd3d0 0000000100000001 ffff88026d3b16f0 ffff88026d3b1fd8
      Call Trace:
       [<ffffffff812ffd52>] ? cfq_may_queue+0x52/0xf0
       [<ffffffff81604338>] schedule+0x18/0x30
       [<ffffffff81604392>] io_schedule+0x42/0x60
       [<ffffffff812f22bb>] get_request_wait+0xeb/0x1f0
       [<ffffffff81065660>] ? autoremove_wake_function+0x0/0x40
       [<ffffffff812eb382>] ? elv_merge+0x42/0x210
       [<ffffffff812f26ae>] __make_request+0x8e/0x4e0
       [<ffffffff812f068e>] generic_make_request+0x21e/0x5e0
       [<ffffffff812f0aad>] submit_bio+0x5d/0xd0
       [<ffffffff81141422>] submit_bh+0xf2/0x130
       [<ffffffff8114474c>] __block_write_full_page+0x1dc/0x3a0
       [<ffffffff81143f60>] ? end_buffer_async_write+0x0/0x120
       [<ffffffff811474e0>] ? blkdev_get_block+0x0/0x70
       [<ffffffff811474e0>] ? blkdev_get_block+0x0/0x70
       [<ffffffff81143f60>] ? end_buffer_async_write+0x0/0x120
       [<ffffffff811449ee>] block_write_full_page_endio+0xde/0x100
       [<ffffffff81144a20>] block_write_full_page+0x10/0x20
       [<ffffffff81148703>] blkdev_writepage+0x13/0x20
       [<ffffffff810d7525>] __writepage+0x15/0x40
       [<ffffffff810d7c0f>] write_cache_pages+0x1cf/0x3e0
       [<ffffffff810d7510>] ? __writepage+0x0/0x40
       [<ffffffff810d7e42>] generic_writepages+0x22/0x30
       [<ffffffff810d7e6f>] do_writepages+0x1f/0x40
       [<ffffffff8113ae67>] writeback_single_inode+0xe7/0x3b0
       [<ffffffff8113b574>] writeback_sb_inodes+0x184/0x280
       [<ffffffff8113bedb>] writeback_inodes_wb+0x6b/0x1a0
       [<ffffffff8113c24b>] wb_writeback+0x23b/0x2a0
       [<ffffffff8113c42d>] wb_do_writeback+0x17d/0x190
       [<ffffffff8113c48b>] bdi_writeback_task+0x4b/0xe0
       [<ffffffff810e82a0>] ? bdi_start_fn+0x0/0x100
       [<ffffffff810e8321>] bdi_start_fn+0x81/0x100
       [<ffffffff810e82a0>] ? bdi_start_fn+0x0/0x100
       [<ffffffff8106522e>] kthread+0x8e/0xa0
       [<ffffffff81039274>] ? finish_task_switch+0x54/0xc0
       [<ffffffff81003334>] kernel_thread_helper+0x4/0x10
       [<ffffffff810651a0>] ? kthread+0x0/0xa0
       [<ffffffff81003330>] ? kernel_thread_helper+0x0/0x10
      
       The above trace was triggered by
         "dd if=/dev/zero of=/dev/sr0 bs=2048 count=32768"
      Signed-off-by: default avatarShan Hai <shan.hai@windriver.com>
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0a2f4ddf
    • Gwendal Grignou's avatar
      libata: Fix display of sata speed · 7b7329ef
      Gwendal Grignou authored
      commit 3e85c3ec upstream.
      
      6.0 Gbps link speed was not decoded properly:
      speed was reported at 3.0 Gbps only.
      
      Tested: On a machine where libata reports 6.0 Gbps in
              /var/log/messages:
          ata1: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
      
          Before:
          	cat /sys/class/ata_link/link1/sata_spd
          	3.0 Gbps
          After:
          	cat /sys/class/ata_link/link1/sata_spd
          	6.0 Gbps
      Signed-off-by: default avatarGwendal Grignou <gwendal@google.com>
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7b7329ef