1. 03 Jan, 2018 7 commits
    • Jacob Keller's avatar
      i40e: don't remove netdev->dev_addr when syncing uc list · 458867b2
      Jacob Keller authored
      In some circumstances, such as with bridging, it is possible that the
      stack will add a devices own MAC address to its unicast address list.
      
      If, later, the stack deletes this address, then the i40e driver will
      receive a request to remove this address.
      
      The driver stores its current MAC address as part of the MAC/VLAN hash
      array, since it is convenient and matches exactly how the hardware
      expects to be told which traffic to receive.
      
      This causes a problem, since for more devices, the MAC address is stored
      separately, and requests to delete a unicast address should not have the
      ability to remove the filter for the MAC address.
      
      Fix this by forcing a check on every address sync to ensure we do not
      remove the device address.
      
      There is a very narrow possibility of a race between .set_mac and
      .set_rx_mode, if we don't change netdev->dev_addr before updating our
      internal MAC list in .set_mac. This might be possible if .set_rx_mode is
      going to remove MAC "XYZ" from the list, at the same time as .set_mac
      changes our dev_addr to MAC "XYZ", we might possibly queue a delete,
      then an add in .set_mac, then queue a delete in .set_rx_mode's
      dev_uc_sync and then update netdev->dev_addr. We can avoid this by
      moving the copy into dev_addr prior to the changes to the MAC filter
      list.
      
      A similar race on the other side does not cause problems, as if we're
      changing our MAC form A to B, and we race with .set_rx_mode, it could
      queue a delete from A, we'd update our address, and allow the delete.
      This seems like a race, but in reality we're about to queue a delete of
      A anyways, so it would not cause any issues.
      
      A race in the initialization code is unlikely because the netdevice has
      not yet been fully initialized and the stack should not be adding or
      removing addresses yet.
      
      Note that we don't (yet) need similar code for the VF driver because it
      does not make use of __dev_uc_sync and __dev_mc_sync, but instead roles
      its own method for handling updates to the MAC/VLAN list, which already
      has code to protect against removal of the hardware address.
      Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
      Tested-by: default avatarAndrew Bowers <andrewx.bowers@intel.com>
      Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
      458867b2
    • Alexander Duyck's avatar
      i40e/i40evf: Account for frags split over multiple descriptors in check linearize · 248de22e
      Alexander Duyck authored
      The original code for __i40e_chk_linearize didn't take into account the
      fact that if a fragment is 16K in size or larger it has to be split over 2
      descriptors and the smaller of those 2 descriptors will be on the trailing
      edge of the transmit. As a result we can get into situations where we didn't
      catch requests that could result in a Tx hang.
      
      This patch takes care of that by subtracting the length of all but the
      trailing edge of the stale fragment before we test for sum. By doing this
      we can guarantee that we have all cases covered, including the case of a
      fragment that spans multiple descriptors. We don't need to worry about
      checking the inner portions of this since 12K is the maximum aligned DMA
      size and that is larger than any MSS will ever be since the MTU limit for
      jumbos is something on the order of 9K.
      Signed-off-by: default avatarAlexander Duyck <alexander.h.duyck@intel.com>
      Tested-by: default avatarAndrew Bowers <andrewx.bowers@intel.com>
      Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
      248de22e
    • Amritha Nambiar's avatar
      i40e: Remove UDP support for big buffer · 64e711ca
      Amritha Nambiar authored
      Since UDP based filters are not supported via big buffer cloud
      filters, remove UDP support.  Also change a few return types to
      indicate unsupported vs invalid configuration.
      Signed-off-by: default avatarAmritha Nambiar <amritha.nambiar@intel.com>
      Acked-by: default avatarAlexander Duyck <alexander.h.duyck@intel.com>
      Tested-by: default avatarAndrew Bowers <andrewx.bowers@intel.com>
      Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
      64e711ca
    • Mohamed Ghannam's avatar
      RDS: Heap OOB write in rds_message_alloc_sgs() · c0955087
      Mohamed Ghannam authored
      When args->nr_local is 0, nr_pages gets also 0 due some size
      calculation via rds_rm_size(), which is later used to allocate
      pages for DMA, this bug produces a heap Out-Of-Bound write access
      to a specific memory region.
      Signed-off-by: default avatarMohamed Ghannam <simo.ghannam@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c0955087
    • Felix Janda's avatar
      uapi libc compat: add fallback for unsupported libcs · c0bace79
      Felix Janda authored
      libc-compat.h aims to prevent symbol collisions between uapi and libc
      headers for each supported libc. This requires continuous coordination
      between them.
      
      The goal of this commit is to improve the situation for libcs (such as
      musl) which are not yet supported and/or do not wish to be explicitly
      supported, while not affecting supported libcs. More precisely, with
      this commit, unsupported libcs can request the suppression of any
      specific uapi definition by defining the correspondings _UAPI_DEF_*
      macro as 0. This can fix symbol collisions for them, as long as the
      libc headers are included before the uapi headers. Inclusion in the
      other order is outside the scope of this commit.
      
      All infrastructure in order to enable this fallback for unsupported
      libcs is already in place, except that libc-compat.h unconditionally
      defines all _UAPI_DEF_* macros to 1 for all unsupported libcs so that
      any previous definitions are ignored. In order to fix this, this commit
      merely makes these definitions conditional.
      
      This commit together with the musl libc commit
      
      http://git.musl-libc.org/cgit/musl/commit/?id=04983f2272382af92eb8f8838964ff944fbb8258
      
      fixes for example the following compiler errors when <linux/in6.h> is
      included after musl's <netinet/in.h>:
      
      ./linux/in6.h:32:8: error: redefinition of 'struct in6_addr'
      ./linux/in6.h:49:8: error: redefinition of 'struct sockaddr_in6'
      ./linux/in6.h:59:8: error: redefinition of 'struct ipv6_mreq'
      
      The comments referencing glibc are still correct, but this file is not
      only used for glibc any more.
      Signed-off-by: default avatarFelix Janda <felix.janda@posteo.de>
      Reviewed-by: default avatarHauke Mehrtens <hauke@hauke-m.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c0bace79
    • Jon Maloy's avatar
      tipc: fix problems with multipoint-to-point flow control · f9c935db
      Jon Maloy authored
      In commit 04d7b574 ("tipc: add multipoint-to-point flow control") we
      introduced a protocol for preventing buffer overflow when many group
      members try to simultaneously send messages to the same receiving member.
      
      Stress test of this mechanism has revealed a couple of related bugs:
      
      - When the receiving member receives an advertisement REMIT message from
        one of the senders, it will sometimes prematurely activate a pending
        member and send it the remitted advertisement, although the upper
        limit for active senders has been reached. This leads to accumulation
        of illegal advertisements, and eventually to messages being dropped
        because of receive buffer overflow.
      
      - When the receiving member leaves REMITTED state while a received
        message is being read, we miss to look at the pending queue, to
        activate the oldest pending peer. This leads to some pending senders
        being starved out, and never getting the opportunity to profit from
        the remitted advertisement.
      
      We fix the former in the function tipc_group_proto_rcv() by returning
      directly from the function once it becomes clear that the remitting
      peer cannot leave REMITTED state at that point.
      
      We fix the latter in the function tipc_group_update_rcv_win() by looking
      up and activate the longest pending peer when it becomes clear that the
      remitting peer now can leave REMITTED state.
      Signed-off-by: default avatarJon Maloy <jon.maloy@ericsson.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      f9c935db
    • Stephen Hemminger's avatar
      ethtool: do not print warning for applications using legacy API · 71891e2d
      Stephen Hemminger authored
      In kernel log ths message appears on every boot:
       "warning: `NetworkChangeNo' uses legacy ethtool link settings API,
        link modes are only partially reported"
      
      When ethtool link settings API changed, it started complaining about
      usages of old API. Ironically, the original patch was from google but
      the application using the legacy API is chrome.
      
      Linux ABI is fixed as much as possible. The kernel must not break it
      and should not complain about applications using legacy API's.
      This patch just removes the warning since using legacy API's
      in Linux is perfectly acceptable.
      
      Fixes: 3f1ac7a7 ("net: ethtool: add new ETHTOOL_xLINKSETTINGS API")
      Signed-off-by: default avatarStephen Hemminger <stephen@networkplumber.org>
      Signed-off-by: default avatarDavid Decotigny <decot@googlers.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      71891e2d
  2. 02 Jan, 2018 11 commits
  3. 29 Dec, 2017 5 commits
    • Linus Torvalds's avatar
      Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net · 2758b3e3
      Linus Torvalds authored
      Pull networking fixes from David Miller:
      
       1) IPv6 gre tunnels end up with different default features enabled
          depending upon whether netlink or ioctls are used to bring them up.
          Fix from Alexey Kodanev.
      
       2) Fix read past end of user control message in RDS< from Avinash
          Repaka.
      
       3) Missing RCU barrier in mini qdisc code, from Cong Wang.
      
       4) Missing policy put when reusing per-cpu route entries, from Florian
          Westphal.
      
       5) Handle nested PCI errors properly in bnx2x driver, from Guilherme G.
          Piccoli.
      
       6) Run nested transport mode IPSEC packets via tasklet, from Herbert
          Xu.
      
       7) Fix handling poll() for stream sockets in tipc, from Parthasarathy
          Bhuvaragan.
      
       8) Fix two stack-out-of-bounds issues in IPSEC, from Steffen Klassert.
      
       9) Another zerocopy ubuf handling fix, from Willem de Bruijn.
      
      * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (33 commits)
        strparser: Call sock_owned_by_user_nocheck
        sock: Add sock_owned_by_user_nocheck
        skbuff: in skb_copy_ubufs unclone before releasing zerocopy
        tipc: fix hanging poll() for stream sockets
        sctp: Replace use of sockets_allocated with specified macro.
        bnx2x: Improve reliability in case of nested PCI errors
        tg3: Enable PHY reset in MTU change path for 5720
        tg3: Add workaround to restrict 5762 MRRS to 2048
        tg3: Update copyright
        net: fec: unmap the xmit buffer that are not transferred by DMA
        tipc: fix tipc_mon_delete() oops in tipc_enable_bearer() error path
        tipc: error path leak fixes in tipc_enable_bearer()
        RDS: Check cmsg_len before dereferencing CMSG_DATA
        tcp: Avoid preprocessor directives in tracepoint macro args
        tipc: fix memory leak of group member when peer node is lost
        net: sched: fix possible null pointer deref in tcf_block_put
        tipc: base group replicast ack counter on number of actual receivers
        net_sched: fix a missing rcu barrier in mini_qdisc_pair_swap()
        net: phy: micrel: ksz9031: reconfigure autoneg after phy autoneg workaround
        ip6_gre: fix device features for ioctl setup
        ...
      2758b3e3
    • Linus Torvalds's avatar
      Merge tag 'drm-fixes-for-v4.15-rc6' of git://people.freedesktop.org/~airlied/linux · fd84b751
      Linus Torvalds authored
      Pull drm fixes from Dave Airlie:
       "nouveau and i915 regression fixes"
      
      * tag 'drm-fixes-for-v4.15-rc6' of git://people.freedesktop.org/~airlied/linux:
        drm/nouveau: fix race when adding delayed work items
        i915: Reject CCS modifiers for pipe C on Geminilake
        drm/i915/gvt: Fix pipe A enable as default for vgpu
      fd84b751
    • Linus Torvalds's avatar
      Merge tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux · c0208a33
      Linus Torvalds authored
      Pull clk fix from Stephen Boyd:
       "One more fix for the runtime PM clk patches. We're calling a runtime
        PM API that may schedule from somewhere that we can't do that. We
        change to the async version of pm_runtime_put() to fix it"
      
      * tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux:
        clk: use atomic runtime pm api in clk_core_is_enabled
      c0208a33
    • Linus Torvalds's avatar
      Merge tag 'led_fixes_for_4.15-rc6' of... · 4f2382f3
      Linus Torvalds authored
      Merge tag 'led_fixes_for_4.15-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds
      
      Pull LED fix from Jacek Anaszewski:
       "A single LED fix for brightness setting when delay_off is 0"
      
      * tag 'led_fixes_for_4.15-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds:
        led: core: Fix brightness setting when setting delay_off=0
      4f2382f3
    • Linus Torvalds's avatar
      Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma · 19286e4a
      Linus Torvalds authored
      Pull rdma fixes from Jason Gunthorpe:
       "This is the next batch of for-rc patches from RDMA. It includes the
        fix for the ipoib regression I mentioned last time, and the result of
        a fairly major debugging effort to get iser working reliably on cxgb4
        hardware - it turns out the cxgb4 driver was not handling QP error
        flushing properly causing iser to fail.
      
         - cxgb4 fix for an iser testing failure as debugged by Steve and
           Sagi. The problem was a driver bug in the handling of shutting down
           a QP.
      
         - Various vmw_pvrdma fixes for bogus WARN_ON, missed resource free on
           error unwind and a use after free bug
      
         - Improper congestion counter values on mlx5 when link aggregation is
           enabled
      
         - ipoib lockdep regression introduced in this merge window
      
         - hfi1 regression supporting the device in a VM introduced in a
           recent patch
      
         - Typo that breaks future uAPI compatibility in the verbs core
      
         - More SELinux related oops fixing
      
         - Fix an oops during error unwind in mlx5"
      
      * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma:
        IB/mlx5: Fix mlx5_ib_alloc_mr error flow
        IB/core: Verify that QP is security enabled in create and destroy
        IB/uverbs: Fix command checking as part of ib_uverbs_ex_modify_qp()
        IB/mlx5: Serialize access to the VMA list
        IB/hfi: Only read capability registers if the capability exists
        IB/ipoib: Fix lockdep issue found on ipoib_ib_dev_heavy_flush
        IB/mlx5: Fix congestion counters in LAG mode
        RDMA/vmw_pvrdma: Avoid use after free due to QP/CQ/SRQ destroy
        RDMA/vmw_pvrdma: Use refcount_dec_and_test to avoid warning
        RDMA/vmw_pvrdma: Call ib_umem_release on destroy QP path
        iw_cxgb4: when flushing, complete all wrs in a chain
        iw_cxgb4: reflect the original WR opcode in drain cqes
        iw_cxgb4: Only validate the MSN for successful completions
      19286e4a
  4. 28 Dec, 2017 6 commits
  5. 27 Dec, 2017 11 commits
    • Nitzan Carmi's avatar
      IB/mlx5: Fix mlx5_ib_alloc_mr error flow · 45e6ae7e
      Nitzan Carmi authored
      ibmr.device is being set only after ib_alloc_mr() is
      (successfully) complete. Therefore, in case mlx5_core_create_mkey()
      return with error, the error flow calls mlx5_free_priv_descs()
      which uses ibmr.device (which doesn't exist yet), causing
      a NULL dereference oops.
      
      To fix this, the IB device should be set in the mr struct earlier
      stage (e.g. prior to calling mlx5_core_create_mkey()).
      
      Fixes: 8a187ee5 ("IB/mlx5: Support the new memory registration API")
      Signed-off-by: default avatarMax Gurtovoy <maxg@mellanox.com>
      Signed-off-by: default avatarNitzan Carmi <nitzanc@mellanox.com>
      Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      45e6ae7e
    • Moni Shoua's avatar
      IB/core: Verify that QP is security enabled in create and destroy · 4a50881b
      Moni Shoua authored
      The XRC target QP create flow sets up qp_sec only if there is an IB link with
      LSM security enabled. However, several other related uAPI entry points blindly
      follow the qp_sec NULL pointer, resulting in a possible oops.
      
      Check for NULL before using qp_sec.
      
      Cc: <stable@vger.kernel.org> # v4.12
      Fixes: d291f1a6 ("IB/core: Enforce PKey security on QPs")
      Reviewed-by: default avatarDaniel Jurgens <danielj@mellanox.com>
      Signed-off-by: default avatarMoni Shoua <monis@mellanox.com>
      Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      4a50881b
    • Moni Shoua's avatar
      IB/uverbs: Fix command checking as part of ib_uverbs_ex_modify_qp() · 05d14e7b
      Moni Shoua authored
      If the input command length is larger than the kernel supports an error should
      be returned in case the unsupported bytes are not cleared, instead of the
      other way aroudn. This matches what all other callers of ib_is_udata_cleared
      do and will avoid user ABI problems in the future.
      
      Cc: <stable@vger.kernel.org> # v4.10
      Fixes: 189aba99 ("IB/uverbs: Extend modify_qp and support packet pacing")
      Reviewed-by: default avatarYishai Hadas <yishaih@mellanox.com>
      Signed-off-by: default avatarMoni Shoua <monis@mellanox.com>
      Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      05d14e7b
    • Majd Dibbiny's avatar
      IB/mlx5: Serialize access to the VMA list · ad9a3668
      Majd Dibbiny authored
      User-space applications can do mmap and munmap directly at
      any time.
      
      Since the VMA list is not protected with a mutex, concurrent
      accesses to the VMA list from the mmap and munmap can cause
      data corruption. Add a mutex around the list.
      
      Cc: <stable@vger.kernel.org> # v4.7
      Fixes: 7c2344c3 ("IB/mlx5: Implements disassociate_ucontext API")
      Reviewed-by: default avatarYishai Hadas <yishaih@mellanox.com>
      Signed-off-by: default avatarMajd Dibbiny <majd@mellanox.com>
      Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      ad9a3668
    • Linus Torvalds's avatar
      Merge tag 'trace-v4.15-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace · 5f520fc3
      Linus Torvalds authored
      Pull tracing fixes from Steven Rostedt:
       "While doing tests on tracing over the network, I found that the
        packets were getting corrupted.
      
        In the process I found three bugs.
      
        One was the culprit, but the other two scared me. After deeper
        investigation, they were not as major as I thought they were, due to a
        signed compared to an unsigned that prevented a negative number from
        doing actual harm.
      
        The two bigger bugs:
      
         - Mask the ring buffer data page length. There are data flags at the
           high bits of the length field. These were not cleared via the
           length function, and the length could return a negative number.
           (Although the number returned was unsigned, but was assigned to a
           signed number) Luckily, this value was compared to PAGE_SIZE which
           is unsigned and kept it from entering the path that could have
           caused damage.
      
         - Check the page usage before reusing the ring buffer reader page.
           TCP increments the page ref when passing the page off to the
           network. The page is passed back to the ring buffer for use on
           free. But the page could still be in use by the TCP stack.
      
        Minor bugs:
      
         - Related to the first bug. No need to clear out the unused ring
           buffer data before sending to user space. It is now done by the
           ring buffer code itself.
      
         - Reset pointers after free on error path. There were some cases in
           the error path that pointers were freed but not set to NULL, and
           could have them freed again, having a pointer freed twice"
      
      * tag 'trace-v4.15-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
        tracing: Fix possible double free on failure of allocating trace buffer
        tracing: Fix crash when it fails to alloc ring buffer
        ring-buffer: Do no reuse reader page if still in use
        tracing: Remove extra zeroing out of the ring buffer page
        ring-buffer: Mask out the info bits when returning buffer page length
      5f520fc3
    • Linus Torvalds's avatar
      Merge tag 'sound-4.15-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound · 9b957794
      Linus Torvalds authored
      Pull sound fixes from Takashi Iwai:
       "It seems that Santa overslept with a bunch of gifts; the majority of
        changes here are various device-specific ASoC fixes, most notably the
        revert of rcar IOMMU support and fsl_ssi AC97 fixes, but also lots of
        small fixes for codecs. Besides that, the usual HD-audio quirks and
        fixes are included, too"
      
      * tag 'sound-4.15-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound: (31 commits)
        ALSA: hda - Fix missing COEF init for ALC225/295/299
        ALSA: hda: Drop useless WARN_ON()
        ALSA: hda - change the location for one mic on a Lenovo machine
        ALSA: hda - fix headset mic detection issue on a Dell machine
        ALSA: hda - Add MIC_NO_PRESENCE fixup for 2 HP machines
        ASoC: rsnd: fixup ADG register mask
        ASoC: rt5514-spi: only enable wakeup when fully initialized
        ASoC: nau8825: fix issue that pop noise when start capture
        ASoC: rt5663: Fix the wrong result of the first jack detection
        ASoC: rsnd: ssi: fix race condition in rsnd_ssi_pointer_update
        ASoC: Intel: Change kern log level to avoid unwanted messages
        ASoC: atmel-classd: select correct Kconfig symbol
        ASoC: wm_adsp: Fix validation of firmware and coeff lengths
        ASoC: Intel: Skylake: Do not check dev_type for dmic link type
        ASoC: rockchip: disable clock on error
        ASoC: tlv320aic31xx: Fix GPIO1 register definition
        ASoC: codecs: msm8916-wcd: Fix supported formats
        ASoC: fsl_asrc: Fix typo in a field define
        ASoC: rsnd: ssiu: clear SSI_MODE for non TDM Extended modes
        ASoC: da7218: Correct IRQ level in DT binding example
        ...
      9b957794
    • Matthieu CASTET's avatar
      led: core: Fix brightness setting when setting delay_off=0 · 2b83ff96
      Matthieu CASTET authored
      With the current code, the following sequence won't work :
      echo timer > trigger
      
      echo 0 >  delay_off
      * at this point we call
      ** led_delay_off_store
      ** led_blink_set
      *** stop timer
      ** led_blink_setup
      ** led_set_software_blink
      *** if !delay_on, led off
      *** if !delay_off, set led_set_brightness_nosleep <--- LED_BLINK_SW is set but timer is stop
      *** otherwise start timer/set LED_BLINK_SW flag
      
      echo xxx > brightness
      * led_set_brightness
      ** if LED_BLINK_SW
      *** if brightness=0, led off
      *** else apply brightness if next timer <--- timer is stop, and will never apply new setting
      ** otherwise set led_set_brightness_nosleep
      
      To fix that, when we delete the timer, we should clear LED_BLINK_SW.
      
      Cc: linux-leds@vger.kernel.org
      Signed-off-by: default avatarMatthieu CASTET <matthieu.castet@parrot.com>
      Signed-off-by: default avatarJacek Anaszewski <jacek.anaszewski@gmail.com>
      2b83ff96
    • Steven Rostedt (VMware)'s avatar
      tracing: Fix possible double free on failure of allocating trace buffer · 4397f045
      Steven Rostedt (VMware) authored
      Jing Xia and Chunyan Zhang reported that on failing to allocate part of the
      tracing buffer, memory is freed, but the pointers that point to them are not
      initialized back to NULL, and later paths may try to free the freed memory
      again. Jing and Chunyan fixed one of the locations that does this, but
      missed a spot.
      
      Link: http://lkml.kernel.org/r/20171226071253.8968-1-chunyan.zhang@spreadtrum.com
      
      Cc: stable@vger.kernel.org
      Fixes: 737223fb ("tracing: Consolidate buffer allocation code")
      Reported-by: default avatarJing Xia <jing.xia@spreadtrum.com>
      Reported-by: default avatarChunyan Zhang <chunyan.zhang@spreadtrum.com>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      4397f045
    • Jing Xia's avatar
      tracing: Fix crash when it fails to alloc ring buffer · 24f2aaf9
      Jing Xia authored
      Double free of the ring buffer happens when it fails to alloc new
      ring buffer instance for max_buffer if TRACER_MAX_TRACE is configured.
      The root cause is that the pointer is not set to NULL after the buffer
      is freed in allocate_trace_buffers(), and the freeing of the ring
      buffer is invoked again later if the pointer is not equal to Null,
      as:
      
      instance_mkdir()
          |-allocate_trace_buffers()
              |-allocate_trace_buffer(tr, &tr->trace_buffer...)
      	|-allocate_trace_buffer(tr, &tr->max_buffer...)
      
                // allocate fail(-ENOMEM),first free
                // and the buffer pointer is not set to null
              |-ring_buffer_free(tr->trace_buffer.buffer)
      
             // out_free_tr
          |-free_trace_buffers()
              |-free_trace_buffer(&tr->trace_buffer);
      
      	      //if trace_buffer is not null, free again
      	    |-ring_buffer_free(buf->buffer)
                      |-rb_free_cpu_buffer(buffer->buffers[cpu])
                          // ring_buffer_per_cpu is null, and
                          // crash in ring_buffer_per_cpu->pages
      
      Link: http://lkml.kernel.org/r/20171226071253.8968-1-chunyan.zhang@spreadtrum.com
      
      Cc: stable@vger.kernel.org
      Fixes: 737223fb ("tracing: Consolidate buffer allocation code")
      Signed-off-by: default avatarJing Xia <jing.xia@spreadtrum.com>
      Signed-off-by: default avatarChunyan Zhang <chunyan.zhang@spreadtrum.com>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      24f2aaf9
    • Steven Rostedt (VMware)'s avatar
      ring-buffer: Do no reuse reader page if still in use · ae415fa4
      Steven Rostedt (VMware) authored
      To free the reader page that is allocated with ring_buffer_alloc_read_page(),
      ring_buffer_free_read_page() must be called. For faster performance, this
      page can be reused by the ring buffer to avoid having to free and allocate
      new pages.
      
      The issue arises when the page is used with a splice pipe into the
      networking code. The networking code may up the page counter for the page,
      and keep it active while sending it is queued to go to the network. The
      incrementing of the page ref does not prevent it from being reused in the
      ring buffer, and this can cause the page that is being sent out to the
      network to be modified before it is sent by reading new data.
      
      Add a check to the page ref counter, and only reuse the page if it is not
      being used anywhere else.
      
      Cc: stable@vger.kernel.org
      Fixes: 73a757e6 ("ring-buffer: Return reader page back into existing ring buffer")
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      ae415fa4
    • Steven Rostedt (VMware)'s avatar
      tracing: Remove extra zeroing out of the ring buffer page · 6b7e633f
      Steven Rostedt (VMware) authored
      The ring_buffer_read_page() takes care of zeroing out any extra data in the
      page that it returns. There's no need to zero it out again from the
      consumer. It was removed from one consumer of this function, but
      read_buffers_splice_read() did not remove it, and worse, it contained a
      nasty bug because of it.
      
      Cc: stable@vger.kernel.org
      Fixes: 2711ca23 ("ring-buffer: Move zeroing out excess in page to ring buffer code")
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      6b7e633f