1. 19 Sep, 2012 40 commits
    • Bjørn Mork's avatar
      USB: option: add ZTE K5006-Z · fef1ddd5
      Bjørn Mork authored
      commit f1b5c997 upstream.
      
      The ZTE (Vodafone) K5006-Z use the following
      interface layout:
      
      00 DIAG
      01 secondary
      02 modem
      03 networkcard
      04 storage
      
      Ignoring interface #3 which is handled by the qmi_wwan
      driver.
      
      Cc: Thomas Schäfer <tschaefer@t-online.de>
      Signed-off-by: default avatarBjørn Mork <bjorn@mork.no>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      fef1ddd5
    • James Ralston's avatar
      i2c-i801: Add Device IDs for Intel Lynx Point-LP PCH · d5d9014f
      James Ralston authored
      commit 4a8f1ddd upstream.
      
      Add the SMBus Device IDs for the Intel Lynx Point-LP PCH.
      Signed-off-by: default avatarJames Ralston <james.d.ralston@intel.com>
      Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      d5d9014f
    • Seth Heasley's avatar
      i2c-i801: Add device IDs for Intel Lynx Point · 79c4d0f5
      Seth Heasley authored
      commit 062737fb upstream.
      
      Add the SMBus controller device IDs for the Intel Lynx Point PCH.
      Signed-off-by: default avatarSeth Heasley <seth.heasley@intel.com>
      Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      79c4d0f5
    • Will Deacon's avatar
      ARM: 7487/1: mm: avoid setting nG bit for user mappings that aren't present · ed756add
      Will Deacon authored
      commit 47f12043 upstream.
      
      Swap entries are encoding in ptes such that !pte_present(pte) and
      pte_file(pte). The remaining bits of the descriptor are used to identify
      the swapfile and offset within it to the swap entry.
      
      When writing such a pte for a user virtual address, set_pte_at
      unconditionally sets the nG bit, which (in the case of LPAE) will
      corrupt the swapfile offset and lead to a BUG:
      
      [  140.494067] swap_free: Unused swap offset entry 000763b4
      [  140.509989] BUG: Bad page map in process rs:main Q:Reg  pte:0ec76800 pmd:8f92e003
      
      This patch fixes the problem by only setting the nG bit for user
      mappings that are actually present.
      Reviewed-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      ed756add
    • Sarah Sharp's avatar
      xhci: Fix bug after deq ptr set to link TRB. · 2543c104
      Sarah Sharp authored
      This patch fixes a particularly nasty bug that was revealed by the ring
      expansion patches.  The bug has been present since the very beginning of
      the xHCI driver history, and could have caused general protection faults
      from bad memory accesses.
      
      The first thing to note is that a Set TR Dequeue Pointer command can
      move the dequeue pointer to a link TRB, if the canceled or stalled
      transfer TD ended just before a link TRB.  The function to increment the
      dequeue pointer, inc_deq, was written before cancellation and stall
      support was added.  It assumed that the dequeue pointer could never
      point to a link TRB.  It would unconditionally increment the dequeue
      pointer at the start of the function, check if the pointer was now on a
      link TRB, and move it to the top of the next segment if so.
      
      This means that if a Set TR Dequeue Point command moved the dequeue
      pointer to a link TRB, a subsequent call to inc_deq() would move the
      pointer off the segment and into la-la-land.  It would then read from
      that memory to determine if it was a link TRB.  Other functions would
      often call inc_deq() until the dequeue pointer matched some other
      pointer, which means this function would quite happily read all of
      system memory before wrapping around to the right pointer value.
      
      Often, there would be another endpoint segment from a different ring
      allocated from the same DMA pool, which would be contiguous to the
      segment inc_deq just stepped off of.  inc_deq would eventually find the
      link TRB in that segment, and blindly move the dequeue pointer back to
      the top of the correct ring segment.
      
      The only reason the original code worked at all is because there was
      only one ring segment.  With the ring expansion patches, the dequeue
      pointer would eventually wrap into place, but the dequeue segment would
      be out-of-sync.  On the second TD after the dequeue pointer was moved to
      a link TRB, trb_in_td() would fail (because the dequeue pointer and
      dequeue segment were out-of-sync), and this message would appear:
      
      ERROR Transfer event TRB DMA ptr not part of current TD
      
      This fixes bugzilla entry 4333 (option-based modem unhappy on USB 3.0
      port: "Transfer event TRB DMA ptr not part of current TD", "rejecting
      I/O to offline device"),
      
      	https://bugzilla.kernel.org/show_bug.cgi?id=43333
      
      and possibly other general protection fault bugs as well.
      
      This patch should be backported to kernels as old as 2.6.31.  The
      original upstream commit is 50d0206f,
      but it does not apply to kernels older than 3.4, because inc_deq was
      changed in 3.3 and 3.4.  This patch should apply to the 3.2 kernel and
      older.
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      2543c104
    • Chris Wilson's avatar
      drm/i915: Wait for all pending operations to the fb before disabling the pipe · 7da67bc3
      Chris Wilson authored
      During modeset we have to disable the pipe to reconfigure its timings
      and maybe its size. Userspace may have queued up command buffers that
      depend upon the pipe running in a certain configuration and so the
      commands may become confused across the modeset. At the moment, we use a
      less than satisfactory kick-scanline-waits should the GPU hang during
      the modeset. It should be more reliable to wait for the pending
      operations to complete first, even though we still have a window for
      userspace to submit a broken command buffer during the modeset.
      Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      (cherry picked from commit 0f91128d)
      Signed-off-by: default avatarTimo Aaltonen <timo.aaltonen@canonical.com>
      7da67bc3
    • John Stultz's avatar
      time: Move ktime_t overflow checking into timespec_valid_strict · 63180c8a
      John Stultz authored
      This is a -stable backport of cee58483
      
      Andreas Bombe reported that the added ktime_t overflow checking added to
      timespec_valid in commit 4e8b1452 ("time: Improve sanity checking of
      timekeeping inputs") was causing problems with X.org because it caused
      timeouts larger then KTIME_T to be invalid.
      
      Previously, these large timeouts would be clamped to KTIME_MAX and would
      never expire, which is valid.
      
      This patch splits the ktime_t overflow checking into a new
      timespec_valid_strict function, and converts the timekeeping codes
      internal checking to use this more strict function.
      Reported-and-tested-by: default avatarAndreas Bombe <aeb@debian.org>
      Cc: Zhouping Liu <zliu@redhat.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Prarit Bhargava <prarit@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Cc: Linux Kernel <linux-kernel@vger.kernel.org>
      Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
      63180c8a
    • John Stultz's avatar
      time: Avoid making adjustments if we haven't accumulated anything · cfb06dcb
      John Stultz authored
      This is a -stable backport of bf2ac312
      
      If update_wall_time() is called and the current offset isn't large
      enough to accumulate, avoid re-calling timekeeping_adjust which may
      change the clock freq and can cause 1ns inconsistencies with
      CLOCK_REALTIME_COARSE/CLOCK_MONOTONIC_COARSE.
      Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
      Cc: Prarit Bhargava <prarit@redhat.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Link: http://lkml.kernel.org/r/1345595449-34965-5-git-send-email-john.stultz@linaro.orgSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: Linux Kernel <linux-kernel@vger.kernel.org>
      Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
      cfb06dcb
    • John Stultz's avatar
      time: Improve sanity checking of timekeeping inputs · 8dd006cd
      John Stultz authored
      This is a -stable backport of 4e8b1452
      
      Unexpected behavior could occur if the time is set to a value large
      enough to overflow a 64bit ktime_t (which is something larger then the
      year 2262).
      
      Also unexpected behavior could occur if large negative offsets are
      injected via adjtimex.
      
      So this patch improves the sanity check timekeeping inputs by
      improving the timespec_valid() check, and then makes better use of
      timespec_valid() to make sure we don't set the time to an invalid
      negative value or one that overflows ktime_t.
      
      Note: This does not protect from setting the time close to overflowing
      ktime_t and then letting natural accumulation cause the overflow.
      Reported-by: default avatarCAI Qian <caiqian@redhat.com>
      Reported-by: default avatarSasha Levin <levinsasha928@gmail.com>
      Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Prarit Bhargava <prarit@redhat.com>
      Cc: Zhouping Liu <zliu@redhat.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Link: http://lkml.kernel.org/r/1344454580-17031-1-git-send-email-john.stultz@linaro.orgSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: Linux Kernel <linux-kernel@vger.kernel.org>
      Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
      8dd006cd
    • Marc Gariepy's avatar
      fixing dmi match for hp t5745 and hp st5747 thin client · 6293b621
      Marc Gariepy authored
      commit 62004978 upstream.
      
      Match the correct information which is DMI_PRODUCT_NAME instead of DMI_BOARD_NAME
      See dmidecode information on launchpad for both thin client:
      
      https://bugs.launchpad.net/ubuntu/+source/linux/+bug/911920
      https://bugs.launchpad.net/ubuntu/+source/linux/+bug/911916Signed-off-by: default avatarMarc Gariepy <mgariepy@ubuntu.com>
      Reviewed-by: default avatarAdam Jackson <ajax@redhat.com>
      Signed-Off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      6293b621
    • Lai Jiangshan's avatar
      workqueue: UNBOUND -> REBIND morphing in rebind_workers() should be atomic · f152c392
      Lai Jiangshan authored
      commit 96e65306 upstream.
      
      The compiler may compile the following code into TWO write/modify
      instructions.
      
      	worker->flags &= ~WORKER_UNBOUND;
      	worker->flags |= WORKER_REBIND;
      
      so the other CPU may temporarily see worker->flags which doesn't have
      either WORKER_UNBOUND or WORKER_REBIND set and perform local wakeup
      prematurely.
      
      Fix it by using single explicit assignment via ACCESS_ONCE().
      
      Because idle workers have another WORKER_NOT_RUNNING flag, this bug
      doesn't exist for them; however, update it to use the same pattern for
      consistency.
      
      tj: Applied the change to idle workers too and updated comments and
          patch description a bit.
      
      stable: Idle worker rebinding doesn't apply for -stable and
              WORKER_UNBOUND used to be WORKER_ROGUE.  Updated accordingly.
      Signed-off-by: default avatarLai Jiangshan <laijs@cn.fujitsu.com>
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      f152c392
    • Yuval Mintz's avatar
      bnx2x: fix 57840_MF pci id · e8bf333a
      Yuval Mintz authored
      [ Upstream commit 5c879d20 ]
      
      Commit c3def943 have added support for
      new pci ids of the 57840 board, while failing to change the obsolete value
      in 'pci_ids.h'.
      This patch does so, allowing the probe of such devices.
      Signed-off-by: default avatarYuval Mintz <yuvalmin@broadcom.com>
      Signed-off-by: default avatarEilon Greenstein <eilong@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      e8bf333a
    • Francesco Ruggeri's avatar
      net: ipv4: ipmr_expire_timer causes crash when removing net namespace · 4c5e5e2a
      Francesco Ruggeri authored
      [ Upstream commit acbb219d ]
      
      When tearing down a net namespace, ipv4 mr_table structures are freed
      without first deactivating their timers. This can result in a crash in
      run_timer_softirq.
      This patch mimics the corresponding behaviour in ipv6.
      Locking and synchronization seem to be adequate.
      We are about to kfree mrt, so existing code should already make sure that
      no other references to mrt are pending or can be created by incoming traffic.
      The functions invoked here do not cause new references to mrt or other
      race conditions to be created.
      Invoking del_timer_sync guarantees that ipmr_expire_timer is inactive.
      Both ipmr_expire_process (whose completion we may have to wait in
      del_timer_sync) and mroute_clean_tables internally use mfc_unres_lock
      or other synchronizations when needed, and they both only modify mrt.
      
      Tested in Linux 3.4.8.
      Signed-off-by: default avatarFrancesco Ruggeri <fruggeri@aristanetworks.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      4c5e5e2a
    • xeb@mail.ru's avatar
      l2tp: avoid to use synchronize_rcu in tunnel free function · db385ea9
      xeb@mail.ru authored
      [ Upstream commit 99469c32 ]
      
      Avoid to use synchronize_rcu in l2tp_tunnel_free because context may be
      atomic.
      Signed-off-by: default avatarDmitry Kozlov <xeb@mail.ru>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      db385ea9
    • Claudiu Manoil's avatar
      gianfar: fix default tx vlan offload feature flag · a0411257
      Claudiu Manoil authored
      [ Upstream commit e2c53be2 ]
      
      Commit -
      "b852b720 gianfar: fix bug caused by
      87c288c6"
      disables by default (on mac init) the hw vlan tag insertion.
      The "features" flags were not updated to reflect this, and
      "ethtool -K" shows tx-vlan-offload to be "on" by default.
      
      Cc: Sebastian Poehn <sebastian.poehn@belden.com>
      Signed-off-by: default avatarClaudiu Manoil <claudiu.manoil@freescale.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      a0411257
    • Pablo Neira Ayuso's avatar
      netlink: fix possible spoofing from non-root processes · e6ae7506
      Pablo Neira Ayuso authored
      [ Upstream commit 20e1db19 ]
      
      Non-root user-space processes can send Netlink messages to other
      processes that are well-known for being subscribed to Netlink
      asynchronous notifications. This allows ilegitimate non-root
      process to send forged messages to Netlink subscribers.
      
      The userspace process usually verifies the legitimate origin in
      two ways:
      
      a) Socket credentials. If UID != 0, then the message comes from
         some ilegitimate process and the message needs to be dropped.
      
      b) Netlink portID. In general, portID == 0 means that the origin
         of the messages comes from the kernel. Thus, discarding any
         message not coming from the kernel.
      
      However, ctnetlink sets the portID in event messages that has
      been triggered by some user-space process, eg. conntrack utility.
      So other processes subscribed to ctnetlink events, eg. conntrackd,
      know that the event was triggered by some user-space action.
      
      Neither of the two ways to discard ilegitimate messages coming
      from non-root processes can help for ctnetlink.
      
      This patch adds capability validation in case that dst_pid is set
      in netlink_sendmsg(). This approach is aggressive since existing
      applications using any Netlink bus to deliver messages between
      two user-space processes will break. Note that the exception is
      NETLINK_USERSOCK, since it is reserved for netlink-to-netlink
      userspace communication.
      
      Still, if anyone wants that his Netlink bus allows netlink-to-netlink
      userspace, then they can set NL_NONROOT_SEND. However, by default,
      I don't think it makes sense to allow to use NETLINK_ROUTE to
      communicate two processes that are sending no matter what information
      that is not related to link/neighbouring/routing. They should be using
      NETLINK_USERSOCK instead for that.
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      e6ae7506
    • Eric Dumazet's avatar
      af_netlink: force credentials passing [CVE-2012-3520] · dc77000f
      Eric Dumazet authored
      [ Upstream commit e0e3cea4 ]
      
      Pablo Neira Ayuso discovered that avahi and
      potentially NetworkManager accept spoofed Netlink messages because of a
      kernel bug.  The kernel passes all-zero SCM_CREDENTIALS ancillary data
      to the receiver if the sender did not provide such data, instead of not
      including any such data at all or including the correct data from the
      peer (as it is the case with AF_UNIX).
      
      This bug was introduced in commit 16e57262
      (af_unix: dont send SCM_CREDENTIALS by default)
      
      This patch forces passing credentials for netlink, as
      before the regression.
      
      Another fix would be to not add SCM_CREDENTIALS in
      netlink messages if not provided by the sender, but it
      might break some programs.
      
      With help from Florian Weimer & Petr Matousek
      
      This issue is designated as CVE-2012-3520
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Cc: Petr Matousek <pmatouse@redhat.com>
      Cc: Florian Weimer <fweimer@redhat.com>
      Cc: Pablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      dc77000f
    • Eric Leblond's avatar
      af_packet: don't emit packet on orig fanout group · 1b048ea7
      Eric Leblond authored
      [ Upstream commit c0de08d0 ]
      
      If a packet is emitted on one socket in one group of fanout sockets,
      it is transmitted again. It is thus read again on one of the sockets
      of the fanout group. This result in a loop for software which
      generate packets when receiving one.
      This retransmission is not the intended behavior: a fanout group
      must behave like a single socket. The packet should not be
      transmitted on a socket if it originates from a socket belonging
      to the same fanout group.
      
      This patch fixes the issue by changing the transmission check to
      take fanout group info account.
      Reported-by: default avatarAleksandr Kotov <a1k@mail.ru>
      Signed-off-by: default avatarEric Leblond <eric@regit.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      1b048ea7
    • Mathias Krause's avatar
      net: fix info leak in compat dev_ifconf() · daf8fa93
      Mathias Krause authored
      [ Upstream commit 43da5f2e ]
      
      The implementation of dev_ifconf() for the compat ioctl interface uses
      an intermediate ifc structure allocated in userland for the duration of
      the syscall. Though, it fails to initialize the padding bytes inserted
      for alignment and that for leaks four bytes of kernel stack. Add an
      explicit memset(0) before filling the structure to avoid the info leak.
      Signed-off-by: default avatarMathias Krause <minipli@googlemail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      daf8fa93
    • Mathias Krause's avatar
      ipvs: fix info leak in getsockopt(IP_VS_SO_GET_TIMEOUT) · 9b2a1401
      Mathias Krause authored
      [ Upstream commit 2d8a041b ]
      
      If at least one of CONFIG_IP_VS_PROTO_TCP or CONFIG_IP_VS_PROTO_UDP is
      not set, __ip_vs_get_timeouts() does not fully initialize the structure
      that gets copied to userland and that for leaks up to 12 bytes of kernel
      stack. Add an explicit memset(0) before passing the structure to
      __ip_vs_get_timeouts() to avoid the info leak.
      Signed-off-by: default avatarMathias Krause <minipli@googlemail.com>
      Cc: Wensong Zhang <wensong@linux-vs.org>
      Cc: Simon Horman <horms@verge.net.au>
      Cc: Julian Anastasov <ja@ssi.bg>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      9b2a1401
    • Mathias Krause's avatar
      dccp: fix info leak via getsockopt(DCCP_SOCKOPT_CCID_TX_INFO) · 24635bcd
      Mathias Krause authored
      [ Upstream commit 7b07f8eb ]
      
      The CCID3 code fails to initialize the trailing padding bytes of struct
      tfrc_tx_info added for alignment on 64 bit architectures. It that for
      potentially leaks four bytes kernel stack via the getsockopt() syscall.
      Add an explicit memset(0) before filling the structure to avoid the
      info leak.
      Signed-off-by: default avatarMathias Krause <minipli@googlemail.com>
      Cc: Gerrit Renker <gerrit@erg.abdn.ac.uk>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      24635bcd
    • Mathias Krause's avatar
      llc: fix info leak via getsockname() · 3f497daa
      Mathias Krause authored
      [ Upstream commit 3592aaeb ]
      
      The LLC code wrongly returns 0, i.e. "success", when the socket is
      zapped. Together with the uninitialized uaddrlen pointer argument from
      sys_getsockname this leads to an arbitrary memory leak of up to 128
      bytes kernel stack via the getsockname() syscall.
      
      Return an error instead when the socket is zapped to prevent the info
      leak. Also remove the unnecessary memset(0). We don't directly write to
      the memory pointed by uaddr but memcpy() a local structure at the end of
      the function that is properly initialized.
      Signed-off-by: default avatarMathias Krause <minipli@googlemail.com>
      Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      3f497daa
    • Mathias Krause's avatar
      Bluetooth: L2CAP - Fix info leak via getsockname() · 79690021
      Mathias Krause authored
      [ Upstream commit 792039c7 ]
      
      The L2CAP code fails to initialize the l2_bdaddr_type member of struct
      sockaddr_l2 and the padding byte added for alignment. It that for leaks
      two bytes kernel stack via the getsockname() syscall. Add an explicit
      memset(0) before filling the structure to avoid the info leak.
      Signed-off-by: default avatarMathias Krause <minipli@googlemail.com>
      Cc: Marcel Holtmann <marcel@holtmann.org>
      Cc: Gustavo Padovan <gustavo@padovan.org>
      Cc: Johan Hedberg <johan.hedberg@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      79690021
    • Mathias Krause's avatar
      Bluetooth: RFCOMM - Fix info leak via getsockname() · 18fc748c
      Mathias Krause authored
      [ Upstream commit 9344a972 ]
      
      The RFCOMM code fails to initialize the trailing padding byte of struct
      sockaddr_rc added for alignment. It that for leaks one byte kernel stack
      via the getsockname() syscall. Add an explicit memset(0) before filling
      the structure to avoid the info leak.
      Signed-off-by: default avatarMathias Krause <minipli@googlemail.com>
      Cc: Marcel Holtmann <marcel@holtmann.org>
      Cc: Gustavo Padovan <gustavo@padovan.org>
      Cc: Johan Hedberg <johan.hedberg@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      18fc748c
    • Mathias Krause's avatar
      Bluetooth: RFCOMM - Fix info leak in ioctl(RFCOMMGETDEVLIST) · 2ab341d7
      Mathias Krause authored
      [ Upstream commit f9432c5e ]
      
      The RFCOMM code fails to initialize the two padding bytes of struct
      rfcomm_dev_list_req inserted for alignment before copying it to
      userland. Additionally there are two padding bytes in each instance of
      struct rfcomm_dev_info. The ioctl() that for disclosures two bytes plus
      dev_num times two bytes uninitialized kernel heap memory.
      
      Allocate the memory using kzalloc() to fix this issue.
      Signed-off-by: default avatarMathias Krause <minipli@googlemail.com>
      Cc: Marcel Holtmann <marcel@holtmann.org>
      Cc: Gustavo Padovan <gustavo@padovan.org>
      Cc: Johan Hedberg <johan.hedberg@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      2ab341d7
    • Mathias Krause's avatar
      Bluetooth: RFCOMM - Fix info leak in getsockopt(BT_SECURITY) · 1621af48
      Mathias Krause authored
      [ Upstream commit 9ad2de43 ]
      
      The RFCOMM code fails to initialize the key_size member of struct
      bt_security before copying it to userland -- that for leaking one
      byte kernel stack. Initialize key_size with 0 to avoid the info
      leak.
      Signed-off-by: default avatarMathias Krause <minipli@googlemail.com>
      Cc: Marcel Holtmann <marcel@holtmann.org>
      Cc: Gustavo Padovan <gustavo@padovan.org>
      Cc: Johan Hedberg <johan.hedberg@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      1621af48
    • Mathias Krause's avatar
      Bluetooth: HCI - Fix info leak via getsockname() · 1ec70057
      Mathias Krause authored
      [ Upstream commit 3f68ba07 ]
      
      The HCI code fails to initialize the hci_channel member of struct
      sockaddr_hci and that for leaks two bytes kernel stack via the
      getsockname() syscall. Initialize hci_channel with 0 to avoid the
      info leak.
      Signed-off-by: default avatarMathias Krause <minipli@googlemail.com>
      Cc: Marcel Holtmann <marcel@holtmann.org>
      Cc: Gustavo Padovan <gustavo@padovan.org>
      Cc: Johan Hedberg <johan.hedberg@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      1ec70057
    • Mathias Krause's avatar
      Bluetooth: HCI - Fix info leak in getsockopt(HCI_FILTER) · 2c7571e8
      Mathias Krause authored
      [ Upstream commit e15ca9a0 ]
      
      The HCI code fails to initialize the two padding bytes of struct
      hci_ufilter before copying it to userland -- that for leaking two
      bytes kernel stack. Add an explicit memset(0) before filling the
      structure to avoid the info leak.
      Signed-off-by: default avatarMathias Krause <minipli@googlemail.com>
      Cc: Marcel Holtmann <marcel@holtmann.org>
      Cc: Gustavo Padovan <gustavo@padovan.org>
      Cc: Johan Hedberg <johan.hedberg@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      2c7571e8
    • Mathias Krause's avatar
      atm: fix info leak via getsockname() · 86cbb1ef
      Mathias Krause authored
      [ Upstream commit 3c0c5cfd ]
      
      The ATM code fails to initialize the two padding bytes of struct
      sockaddr_atmpvc inserted for alignment. Add an explicit memset(0)
      before filling the structure to avoid the info leak.
      Signed-off-by: default avatarMathias Krause <minipli@googlemail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      86cbb1ef
    • Mathias Krause's avatar
      atm: fix info leak in getsockopt(SO_ATMPVC) · 3d9e0c7f
      Mathias Krause authored
      [ Upstream commit e862f1a9 ]
      
      The ATM code fails to initialize the two padding bytes of struct
      sockaddr_atmpvc inserted for alignment. Add an explicit memset(0)
      before filling the structure to avoid the info leak.
      Signed-off-by: default avatarMathias Krause <minipli@googlemail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      3d9e0c7f
    • Ben Hutchings's avatar
      ipv6: addrconf: Avoid calling netdevice notifiers with RCU read-side lock · 86134afa
      Ben Hutchings authored
      [ Upstream commit 4acd4945 ]
      
      Cong Wang reports that lockdep detected suspicious RCU usage while
      enabling IPV6 forwarding:
      
       [ 1123.310275] ===============================
       [ 1123.442202] [ INFO: suspicious RCU usage. ]
       [ 1123.558207] 3.6.0-rc1+ #109 Not tainted
       [ 1123.665204] -------------------------------
       [ 1123.768254] include/linux/rcupdate.h:430 Illegal context switch in RCU read-side critical section!
       [ 1123.992320]
       [ 1123.992320] other info that might help us debug this:
       [ 1123.992320]
       [ 1124.307382]
       [ 1124.307382] rcu_scheduler_active = 1, debug_locks = 0
       [ 1124.522220] 2 locks held by sysctl/5710:
       [ 1124.648364]  #0:  (rtnl_mutex){+.+.+.}, at: [<ffffffff81768498>] rtnl_trylock+0x15/0x17
       [ 1124.882211]  #1:  (rcu_read_lock){.+.+.+}, at: [<ffffffff81871df8>] rcu_lock_acquire+0x0/0x29
       [ 1125.085209]
       [ 1125.085209] stack backtrace:
       [ 1125.332213] Pid: 5710, comm: sysctl Not tainted 3.6.0-rc1+ #109
       [ 1125.441291] Call Trace:
       [ 1125.545281]  [<ffffffff8109d915>] lockdep_rcu_suspicious+0x109/0x112
       [ 1125.667212]  [<ffffffff8107c240>] rcu_preempt_sleep_check+0x45/0x47
       [ 1125.781838]  [<ffffffff8107c260>] __might_sleep+0x1e/0x19b
      [...]
       [ 1127.445223]  [<ffffffff81757ac5>] call_netdevice_notifiers+0x4a/0x4f
      [...]
       [ 1127.772188]  [<ffffffff8175e125>] dev_disable_lro+0x32/0x6b
       [ 1127.885174]  [<ffffffff81872d26>] dev_forward_change+0x30/0xcb
       [ 1128.013214]  [<ffffffff818738c4>] addrconf_forward_change+0x85/0xc5
      [...]
      
      addrconf_forward_change() uses RCU iteration over the netdev list,
      which is unnecessary since it already holds the RTNL lock.  We also
      cannot reasonably require netdevice notifier functions not to sleep.
      Reported-by: default avatarCong Wang <amwang@redhat.com>
      Signed-off-by: default avatarBen Hutchings <bhutchings@solarflare.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      86134afa
    • danborkmann@iogearbox.net's avatar
      af_packet: remove BUG statement in tpacket_destruct_skb · 6c8caeb1
      danborkmann@iogearbox.net authored
      [ Upstream commit 7f5c3e3a ]
      
      Here's a quote of the comment about the BUG macro from asm-generic/bug.h:
      
       Don't use BUG() or BUG_ON() unless there's really no way out; one
       example might be detecting data structure corruption in the middle
       of an operation that can't be backed out of.  If the (sub)system
       can somehow continue operating, perhaps with reduced functionality,
       it's probably not BUG-worthy.
      
       If you're tempted to BUG(), think again:  is completely giving up
       really the *only* solution?  There are usually better options, where
       users don't need to reboot ASAP and can mostly shut down cleanly.
      
      In our case, the status flag of a ring buffer slot is managed from both sides,
      the kernel space and the user space. This means that even though the kernel
      side might work as expected, the user space screws up and changes this flag
      right between the send(2) is triggered when the flag is changed to
      TP_STATUS_SENDING and a given skb is destructed after some time. Then, this
      will hit the BUG macro. As David suggested, the best solution is to simply
      remove this statement since it cannot be used for kernel side internal
      consistency checks. I've tested it and the system still behaves /stable/ in
      this case, so in accordance with the above comment, we should rather remove it.
      Signed-off-by: default avatarDaniel Borkmann <daniel.borkmann@tik.ee.ethz.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      6c8caeb1
    • Alexey Khoroshilov's avatar
      net/core: Fix potential memory leak in dev_set_alias() · 47be27f0
      Alexey Khoroshilov authored
      [ Upstream commit 7364e445 ]
      
      Do not leak memory by updating pointer with potentially NULL realloc return value.
      
      Found by Linux Driver Verification project (linuxtesting.org).
      Signed-off-by: default avatarAlexey Khoroshilov <khoroshilov@ispras.ru>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      47be27f0
    • Gao feng's avatar
      pptp: lookup route with the proper net namespace · 3f37c3bd
      Gao feng authored
      [ Upstream commit 08252b32 ]
      
      pptp always use init_net as the net namespace to lookup
      route, this will cause route lookup failed in container.
      
      because we already set the correct net namespace to struct
      sock in pptp_create,so fix this by using sock_net(sk) to
      replace &init_net.
      Signed-off-by: default avatarGao feng <gaofeng@cn.fujitsu.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      3f37c3bd
    • Wu Fengguang's avatar
      isdnloop: fix and simplify isdnloop_init() · 748b6a42
      Wu Fengguang authored
      [ Upstream commit 77f00f63 ]
      
      Fix a buffer overflow bug by removing the revision and printk.
      
      [   22.016214] isdnloop-ISDN-driver Rev 1.11.6.7
      [   22.097508] isdnloop: (loop0) virtual card added
      [   22.174400] Kernel panic - not syncing: stack-protector: Kernel stack is corrupted in: ffffffff83244972
      [   22.174400]
      [   22.436157] Pid: 1, comm: swapper Not tainted 3.5.0-bisect-00018-gfa8bbb13-dirty #129
      [   22.624071] Call Trace:
      [   22.720558]  [<ffffffff832448c3>] ? CallcNew+0x56/0x56
      [   22.815248]  [<ffffffff8222b623>] panic+0x110/0x329
      [   22.914330]  [<ffffffff83244972>] ? isdnloop_init+0xaf/0xb1
      [   23.014800]  [<ffffffff832448c3>] ? CallcNew+0x56/0x56
      [   23.090763]  [<ffffffff8108e24b>] __stack_chk_fail+0x2b/0x30
      [   23.185748]  [<ffffffff83244972>] isdnloop_init+0xaf/0xb1
      Signed-off-by: default avatarFengguang Wu <fengguang.wu@intel.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      748b6a42
    • Hiroaki SHIMODA's avatar
      net_sched: gact: Fix potential panic in tcf_gact(). · e72c9bd7
      Hiroaki SHIMODA authored
      [ Upstream commit 696ecdc1 ]
      
      gact_rand array is accessed by gact->tcfg_ptype whose value
      is assumed to less than MAX_RAND, but any range checks are
      not performed.
      
      So add a check in tcf_gact_init(). And in tcf_gact(), we can
      reduce a branch.
      Signed-off-by: default avatarHiroaki SHIMODA <shimoda.hiroaki@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      e72c9bd7
    • Ben Hutchings's avatar
      tcp: Apply device TSO segment limit earlier · 9f871e88
      Ben Hutchings authored
      [ Upstream commit 1485348d ]
      
      Cache the device gso_max_segs in sock::sk_gso_max_segs and use it to
      limit the size of TSO skbs.  This avoids the need to fall back to
      software GSO for local TCP senders.
      Signed-off-by: default avatarBen Hutchings <bhutchings@solarflare.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      9f871e88
    • Ben Hutchings's avatar
      sfc: Fix maximum number of TSO segments and minimum TX queue size · 68cb695c
      Ben Hutchings authored
      [ Upstream commit 7e6d06f0 ]
      
      Currently an skb requiring TSO may not fit within a minimum-size TX
      queue.  The TX queue selected for the skb may stall and trigger the TX
      watchdog repeatedly (since the problem skb will be retried after the
      TX reset).  This issue is designated as CVE-2012-3412.
      
      Set the maximum number of TSO segments for our devices to 100.  This
      should make no difference to behaviour unless the actual MSS is less
      than about 700.  Increase the minimum TX queue size accordingly to
      allow for 2 worst-case skbs, so that there will definitely be space
      to add an skb after we wake a queue.
      
      To avoid invalidating existing configurations, change
      efx_ethtool_set_ringparam() to fix up values that are too small rather
      than returning -EINVAL.
      Signed-off-by: default avatarBen Hutchings <bhutchings@solarflare.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      68cb695c
    • Ben Hutchings's avatar
      net: Allow driver to limit number of GSO segments per skb · 99ea81ed
      Ben Hutchings authored
      [ Upstream commit 30b678d8 ]
      
      A peer (or local user) may cause TCP to use a nominal MSS of as little
      as 88 (actual MSS of 76 with timestamps).  Given that we have a
      sufficiently prodigious local sender and the peer ACKs quickly enough,
      it is nevertheless possible to grow the window for such a connection
      to the point that we will try to send just under 64K at once.  This
      results in a single skb that expands to 861 segments.
      
      In some drivers with TSO support, such an skb will require hundreds of
      DMA descriptors; a substantial fraction of a TX ring or even more than
      a full ring.  The TX queue selected for the skb may stall and trigger
      the TX watchdog repeatedly (since the problem skb will be retried
      after the TX reset).  This particularly affects sfc, for which the
      issue is designated as CVE-2012-3412.
      
      Therefore:
      1. Add the field net_device::gso_max_segs holding the device-specific
         limit.
      2. In netif_skb_features(), if the number of segments is too high then
         mask out GSO features to force fall back to software GSO.
      Signed-off-by: default avatarBen Hutchings <bhutchings@solarflare.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      99ea81ed
    • Axel Lin's avatar
      i2c-designware: Fix build error if CONFIG_I2C_DESIGNWARE_PLATFORM=y && CONFIG_I2C_DESIGNWARE_PCI=y · bc63e39c
      Axel Lin authored
      commit e68bb91b upstream.
      
      This patch adds config I2C_DESIGNWARE_CORE in Kconfig, and let
      I2C_DESIGNWARE_PLATFORM and I2C_DESIGNWARE_PCI select I2C_DESIGNWARE_CORE.
      
      Because both I2C_DESIGNWARE_PLATFORM and I2C_DESIGNWARE_PCI can be built as
      built-in or module, we also need to export the functions in i2c-designware-core.
      
      This fixes below build error when CONFIG_I2C_DESIGNWARE_PLATFORM=y &&
      CONFIG_I2C_DESIGNWARE_PCI=y:
      
        LD      drivers/i2c/busses/built-in.o
      drivers/i2c/busses/i2c-designware-pci.o: In function `i2c_dw_clear_int':
      i2c-designware-core.c:(.text+0xa10): multiple definition of `i2c_dw_clear_int'
      drivers/i2c/busses/i2c-designware-platform.o:i2c-designware-platdrv.c:(.text+0x928): first defined here
      drivers/i2c/busses/i2c-designware-pci.o: In function `i2c_dw_init':
      i2c-designware-core.c:(.text+0x178): multiple definition of `i2c_dw_init'
      drivers/i2c/busses/i2c-designware-platform.o:i2c-designware-platdrv.c:(.text+0x90): first defined here
      drivers/i2c/busses/i2c-designware-pci.o: In function `dw_readl':
      i2c-designware-core.c:(.text+0xe8): multiple definition of `dw_readl'
      drivers/i2c/busses/i2c-designware-platform.o:i2c-designware-platdrv.c:(.text+0x0): first defined here
      drivers/i2c/busses/i2c-designware-pci.o: In function `i2c_dw_isr':
      i2c-designware-core.c:(.text+0x724): multiple definition of `i2c_dw_isr'
      drivers/i2c/busses/i2c-designware-platform.o:i2c-designware-platdrv.c:(.text+0x63c): first defined here
      drivers/i2c/busses/i2c-designware-pci.o: In function `i2c_dw_xfer':
      i2c-designware-core.c:(.text+0x4b0): multiple definition of `i2c_dw_xfer'
      drivers/i2c/busses/i2c-designware-platform.o:i2c-designware-platdrv.c:(.text+0x3c8): first defined here
      drivers/i2c/busses/i2c-designware-pci.o: In function `i2c_dw_is_enabled':
      i2c-designware-core.c:(.text+0x9d4): multiple definition of `i2c_dw_is_enabled'
      drivers/i2c/busses/i2c-designware-platform.o:i2c-designware-platdrv.c:(.text+0x8ec): first defined here
      drivers/i2c/busses/i2c-designware-pci.o: In function `dw_writel':
      i2c-designware-core.c:(.text+0x124): multiple definition of `dw_writel'
      drivers/i2c/busses/i2c-designware-platform.o:i2c-designware-platdrv.c:(.text+0x3c): first defined here
      drivers/i2c/busses/i2c-designware-pci.o: In function `i2c_dw_xfer_msg':
      i2c-designware-core.c:(.text+0x2e8): multiple definition of `i2c_dw_xfer_msg'
      drivers/i2c/busses/i2c-designware-platform.o:i2c-designware-platdrv.c:(.text+0x200): first defined here
      drivers/i2c/busses/i2c-designware-pci.o: In function `i2c_dw_enable':
      i2c-designware-core.c:(.text+0x9c8): multiple definition of `i2c_dw_enable'
      drivers/i2c/busses/i2c-designware-platform.o:i2c-designware-platdrv.c:(.text+0x8e0): first defined here
      drivers/i2c/busses/i2c-designware-pci.o: In function `i2c_dw_read_comp_param':
      i2c-designware-core.c:(.text+0xa24): multiple definition of `i2c_dw_read_comp_param'
      drivers/i2c/busses/i2c-designware-platform.o:i2c-designware-platdrv.c:(.text+0x93c): first defined here
      drivers/i2c/busses/i2c-designware-pci.o: In function `i2c_dw_disable':
      i2c-designware-core.c:(.text+0x9dc): multiple definition of `i2c_dw_disable'
      drivers/i2c/busses/i2c-designware-platform.o:i2c-designware-platdrv.c:(.text+0x8f4): first defined here
      drivers/i2c/busses/i2c-designware-pci.o: In function `i2c_dw_func':
      i2c-designware-core.c:(.text+0x710): multiple definition of `i2c_dw_func'
      drivers/i2c/busses/i2c-designware-platform.o:i2c-designware-platdrv.c:(.text+0x628): first defined here
      drivers/i2c/busses/i2c-designware-pci.o: In function `i2c_dw_disable_int':
      i2c-designware-core.c:(.text+0xa18): multiple definition of `i2c_dw_disable_int'
      drivers/i2c/busses/i2c-designware-platform.o:i2c-designware-platdrv.c:(.text+0x930): first defined here
      make[3]: *** [drivers/i2c/busses/built-in.o] Error 1
      make[2]: *** [drivers/i2c/busses] Error 2
      make[1]: *** [drivers/i2c] Error 2
      make: *** [drivers] Error 2
      Signed-off-by: default avatarAxel Lin <axel.lin@gmail.com>
      Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
      Tested-by: default avatarJiri Slaby <jslaby@suse.cz>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      bc63e39c