Skip to content
  1. Feb 05, 2021
  2. Feb 04, 2021
    • Greg Kroah-Hartman's avatar
      Linux 4.4.255 · 2f9c581d
      Greg Kroah-Hartman authored
      
      
      Tested-by: default avatarPavel Machek (CIP) <pavel@denx.de>
      Tested-by: default avatarJon Hunter <jonathanh@nvidia.com>
      Tested-by: default avatarLinux Kernel Functional Testing <lkft@linaro.org>
      Tested-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Tested-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Link: https://lore.kernel.org/r/20210202132941.180062901@linuxfoundation.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      v4.4.255
      2f9c581d
    • Pan Bian's avatar
      NFC: fix possible resource leak · b6dac2c1
      Pan Bian authored
      commit d8f923c3 upstream.
      
      Put the device to avoid resource leak on path that the polling flag is
      invalid.
      
      Fixes: a831b913
      
       ("NFC: Do not return EBUSY when stopping a poll that's already stopped")
      Signed-off-by: default avatarPan Bian <bianpan2016@163.com>
      Link: https://lore.kernel.org/r/20210121153745.122184-1-bianpan2016@163.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b6dac2c1
    • Pan Bian's avatar
      NFC: fix resource leak when target index is invalid · 074013e1
      Pan Bian authored
      commit 3a30537c upstream.
      
      Goto to the label put_dev instead of the label error to fix potential
      resource leak on path that the target index is invalid.
      
      Fixes: c4fbb651
      
       ("NFC: The core part should generate the target index")
      Signed-off-by: default avatarPan Bian <bianpan2016@163.com>
      Link: https://lore.kernel.org/r/20210121152748.98409-1-bianpan2016@163.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      074013e1
    • Bartosz Golaszewski's avatar
      iommu/vt-d: Don't dereference iommu_device if IOMMU_API is not built · cf682c52
      Bartosz Golaszewski authored
      commit 9def3b1a upstream.
      
      Since commit c40aaaac ("iommu/vt-d: Gracefully handle DMAR units
      with no supported address widths") dmar.c needs struct iommu_device to
      be selected. We can drop this dependency by not dereferencing struct
      iommu_device if IOMMU_API is not selected and by reusing the information
      stored in iommu->drhd->ignored instead.
      
      This fixes the following build error when IOMMU_API is not selected:
      
      drivers/iommu/dmar.c: In function ‘free_iommu’:
      drivers/iommu/dmar.c:1139:41: error: ‘struct iommu_device’ has no member named ‘ops’
       1139 |  if (intel_iommu_enabled && iommu->iommu.ops) {
                                                      ^
      
      Fixes: c40aaaac
      
       ("iommu/vt-d: Gracefully handle DMAR units with no supported address widths")
      Signed-off-by: default avatarBartosz Golaszewski <bgolaszewski@baylibre.com>
      Acked-by: default avatarLu Baolu <baolu.lu@linux.intel.com>
      Acked-by: default avatarDavid Woodhouse <dwmw@amazon.co.uk>
      Link: https://lore.kernel.org/r/20201013073055.11262-1-brgl@bgdev.pl
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      [ - context change due to moving drivers/iommu/dmar.c to
          drivers/iommu/intel/dmar.c
        - set the drhr in the iommu like in upstream commit b1012ca8
      
      
          ("iommu/vt-d: Skip TE disabling on quirky gfx dedicated iommu") ]
      Signed-off-by: default avatarFilippo Sironi <sironi@amazon.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cf682c52
    • David Woodhouse's avatar
      iommu/vt-d: Gracefully handle DMAR units with no supported address widths · e4f10aec
      David Woodhouse authored
      commit c40aaaac
      
       upstream.
      
      Instead of bailing out completely, such a unit can still be used for
      interrupt remapping.
      
      Signed-off-by: default avatarDavid Woodhouse <dwmw@amazon.co.uk>
      Reviewed-by: default avatarLu Baolu <baolu.lu@linux.intel.com>
      Link: https://lore.kernel.org/linux-iommu/549928db2de6532117f36c9c810373c14cf76f51.camel@infradead.org/
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      [ - context change due to moving drivers/iommu/dmar.c to
          drivers/iommu/intel/dmar.c
        - remove the unused err_unmap label
        - use iommu->iommu_dev instead of iommu->iommu.ops to decide whether
          when freeing ]
      Signed-off-by: default avatarFilippo Sironi <sironi@amazon.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e4f10aec
    • Dan Carpenter's avatar
      can: dev: prevent potential information leak in can_fill_info() · ee607baa
      Dan Carpenter authored
      [ Upstream commit b552766c ]
      
      The "bec" struct isn't necessarily always initialized. For example, the
      mcp251xfd_get_berr_counter() function doesn't initialize anything if the
      interface is down.
      
      Fixes: 52c793f2
      
       ("can: netlink support for bus-error reporting and counters")
      Link: https://lore.kernel.org/r/YAkaRdRJncsJO8Ve@mwanda
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ee607baa
    • Johannes Berg's avatar
      mac80211: pause TX while changing interface type · 9f1f71f1
      Johannes Berg authored
      [ Upstream commit 054c9939 ]
      
      syzbot reported a crash that happened when changing the interface
      type around a lot, and while it might have been easy to fix just
      the symptom there, a little deeper investigation found that really
      the reason is that we allowed packets to be transmitted while in
      the middle of changing the interface type.
      
      Disallow TX by stopping the queues while changing the type.
      
      Fixes: 34d4bc4d
      
       ("mac80211: support runtime interface type changes")
      Reported-by: default avatar <syzbot+d7a3b15976bf7de2238a@syzkaller.appspotmail.com>
      Link: https://lore.kernel.org/r/20210122171115.b321f98f4d4f.I6997841933c17b093535c31d29355be3c0c39628@changeid
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9f1f71f1
    • Kamal Heib's avatar
      RDMA/cxgb4: Fix the reported max_recv_sge value · 8b97c8c9
      Kamal Heib authored
      [ Upstream commit a372173b ]
      
      The max_recv_sge value is wrongly reported when calling query_qp, This is
      happening due to a typo when assigning the max_recv_sge value, the value
      of sq_max_sges was assigned instead of rq_max_sges.
      
      Fixes: 3e5c02c9
      
       ("iw_cxgb4: Support query_qp() verb")
      Link: https://lore.kernel.org/r/20210114191423.423529-1-kamalheib1@gmail.com
      Signed-off-by: default avatarKamal Heib <kamalheib1@gmail.com>
      Reviewed-by: default avatarPotnuri Bharat Teja <bharat@chelsio.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8b97c8c9
    • Shmulik Ladkani's avatar
      xfrm: Fix oops in xfrm_replay_advance_bmp · bdf1634d
      Shmulik Ladkani authored
      [ Upstream commit 56ce7c25 ]
      
      When setting xfrm replay_window to values higher than 32, a rare
      page-fault occurs in xfrm_replay_advance_bmp:
      
        BUG: unable to handle page fault for address: ffff8af350ad7920
        #PF: supervisor write access in kernel mode
        #PF: error_code(0x0002) - not-present page
        PGD ad001067 P4D ad001067 PUD 0
        Oops: 0002 [#1] SMP PTI
        CPU: 3 PID: 30 Comm: ksoftirqd/3 Kdump: loaded Not tainted 5.4.52-050452-generic #202007160732
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.11.0-2.el7 04/01/2014
        RIP: 0010:xfrm_replay_advance_bmp+0xbb/0x130
        RSP: 0018:ffffa1304013ba40 EFLAGS: 00010206
        RAX: 000000000000010d RBX: 0000000000000002 RCX: 00000000ffffff4b
        RDX: 0000000000000018 RSI: 00000000004c234c RDI: 00000000ffb3dbff
        RBP: ffffa1304013ba50 R08: ffff8af330ad7920 R09: 0000000007fffffa
        R10: 0000000000000800 R11: 0000000000000010 R12: ffff8af29d6258c0
        R13: ffff8af28b95c700 R14: 0000000000000000 R15: ffff8af29d6258fc
        FS:  0000000000000000(0000) GS:ffff8af339ac0000(0000) knlGS:0000000000000000
        CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        CR2: ffff8af350ad7920 CR3: 0000000015ee4000 CR4: 00000000001406e0
        Call Trace:
         xfrm_input+0x4e5/0xa10
         xfrm4_rcv_encap+0xb5/0xe0
         xfrm4_udp_encap_rcv+0x140/0x1c0
      
      Analysis revealed offending code is when accessing:
      
      	replay_esn->bmp[nr] |= (1U << bitnr);
      
      with 'nr' being 0x07fffffa.
      
      This happened in an SMP system when reordering of packets was present;
      A packet arrived with a "too old" sequence number (outside the window,
      i.e 'diff > replay_window'), and therefore the following calculation:
      
      			bitnr = replay_esn->replay_window - (diff - pos);
      
      yields a negative result, but since bitnr is u32 we get a large unsigned
      quantity (in crash dump above: 0xffffff4b seen in ecx).
      
      This was supposed to be protected by xfrm_input()'s former call to:
      
      		if (x->repl->check(x, skb, seq)) {
      
      However, the state's spinlock x->lock is *released* after '->check()'
      is performed, and gets re-acquired before '->advance()' - which gives a
      chance for a different core to update the xfrm state, e.g. by advancing
      'replay_esn->seq' when it encounters more packets - leading to a
      'diff > replay_window' situation when original core continues to
      xfrm_replay_advance_bmp().
      
      An attempt to fix this issue was suggested in commit bcf66bf5
      ("xfrm: Perform a replay check after return from async codepaths"),
      by calling 'x->repl->recheck()' after lock is re-acquired, but fix
      applied only to asyncronous crypto algorithms.
      
      Augment the fix, by *always* calling 'recheck()' - irrespective if we're
      using async crypto.
      
      Fixes: 0ebea8ef
      
       ("[IPSEC]: Move state lock into x->type->input")
      Signed-off-by: default avatarShmulik Ladkani <shmulik.ladkani@gmail.com>
      Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bdf1634d
    • Pablo Neira Ayuso's avatar
      netfilter: nft_dynset: add timeout extension to template · bb3c0b31
      Pablo Neira Ayuso authored
      commit 0c5b7a50 upstream.
      
      Otherwise, the newly create element shows no timeout when listing the
      ruleset. If the set definition does not specify a default timeout, then
      the set element only shows the expiration time, but not the timeout.
      This is a problem when restoring a stateful ruleset listing since it
      skips the timeout policy entirely.
      
      Fixes: 22fe54d5
      
       ("netfilter: nf_tables: add support for dynamic set updates")
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bb3c0b31
    • Max Krummenacher's avatar
      ARM: imx: build suspend-imx6.S with arm instruction set · 73acc9bd
      Max Krummenacher authored
      commit a88afa46
      
       upstream.
      
      When the kernel is configured to use the Thumb-2 instruction set
      "suspend-to-memory" fails to resume. Observed on a Colibri iMX6ULL
      (i.MX 6ULL) and Apalis iMX6 (i.MX 6Q).
      
      It looks like the CPU resumes unconditionally in ARM instruction mode
      and then chokes on the presented Thumb-2 code it should execute.
      
      Fix this by using the arm instruction set for all code in
      suspend-imx6.S.
      
      Signed-off-by: default avatarMax Krummenacher <max.krummenacher@toradex.com>
      Fixes: df595746
      
       ("ARM: imx: add suspend in ocram support for i.mx6q")
      Acked-by: default avatarOleksandr Suvorov <oleksandr.suvorov@toradex.com>
      Signed-off-by: default avatarShawn Guo <shawnguo@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      73acc9bd
    • Thomas Gleixner's avatar
      futex: Prevent exit livelock · f2a9957e
      Thomas Gleixner authored
      commit 3ef240ea upstream.
      
      Oleg provided the following test case:
      
      int main(void)
      {
      	struct sched_param sp = {};
      
      	sp.sched_priority = 2;
      	assert(sched_setscheduler(0, SCHED_FIFO, &sp) == 0);
      
      	int lock = vfork();
      	if (!lock) {
      		sp.sched_priority = 1;
      		assert(sched_setscheduler(0, SCHED_FIFO, &sp) == 0);
      		_exit(0);
      	}
      
      	syscall(__NR_futex, &lock, FUTEX_LOCK_PI, 0,0,0);
      	return 0;
      }
      
      This creates an unkillable RT process spinning in futex_lock_pi() on a UP
      machine or if the process is affine to a single CPU. The reason is:
      
       parent	    	    			child
      
        set FIFO prio 2
      
        vfork()			->	set FIFO prio 1
         implies wait_for_child()	 	sched_setscheduler(...)
       			   		exit()
      					do_exit()
       					....
      					mm_release()
      					  tsk->futex_state = FUTEX_STATE_EXITING;
      					  exit_futex(); (NOOP in this case)
      					  complete() --> wakes parent
        sys_futex()
          loop infinite because
          tsk->futex_state == FUTEX_STATE_EXITING
      
      The same problem can happen just by regular preemption as well:
      
        task holds futex
        ...
        do_exit()
          tsk->futex_state = FUTEX_STATE_EXITING;
      
        --> preemption (unrelated wakeup of some other higher prio task, e.g. timer)
      
        switch_to(other_task)
      
        return to user
        sys_futex()
      	loop infinite as above
      
      Just for the fun of it the futex exit cleanup could trigger the wakeup
      itself before the task sets its futex state to DEAD.
      
      To cure this, the handling of the exiting owner is changed so:
      
         - A refcount is held on the task
      
         - The task pointer is stored in a caller visible location
      
         - The caller drops all locks (hash bucket, mmap_sem) and blocks
           on task::futex_exit_mutex. When the mutex is acquired then
           the exiting task has completed the cleanup and the state
           is consistent and can be reevaluated.
      
      This is not a pretty solution, but there is no choice other than returning
      an error code to user space, which would break the state consistency
      guarantee and open another can of problems including regressions.
      
      For stable backports the preparatory commits ac31c7ff .. ba31c1a4
      are required as well, but for anything older than 5.3.y the backports are
      going to be provided when this hits mainline as the other dependencies for
      those kernels are definitely not stable material.
      
      Fixes: 778e9a9c
      
       ("pi-futex: fix exit races and locking problems")
      Reported-by: default avatarOleg Nesterov <oleg@redhat.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: default avatarIngo Molnar <mingo@kernel.org>
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Stable Team <stable@vger.kernel.org>
      Link: https://lkml.kernel.org/r/20191106224557.041676471@linutronix.de
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f2a9957e
    • Thomas Gleixner's avatar
      futex: Provide distinct return value when owner is exiting · aa2f795a
      Thomas Gleixner authored
      commit ac31c7ff
      
       upstream.
      
      attach_to_pi_owner() returns -EAGAIN for various cases:
      
       - Owner task is exiting
       - Futex value has changed
      
      The caller drops the held locks (hash bucket, mmap_sem) and retries the
      operation. In case of the owner task exiting this can result in a live
      lock.
      
      As a preparatory step for seperating those cases, provide a distinct return
      value (EBUSY) for the owner exiting case.
      
      No functional change.
      
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: default avatarIngo Molnar <mingo@kernel.org>
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/20191106224556.935606117@linutronix.de
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      aa2f795a
    • Thomas Gleixner's avatar
      futex: Add mutex around futex exit · 26f05b30
      Thomas Gleixner authored
      commit 3f186d97
      
       upstream.
      
      The mutex will be used in subsequent changes to replace the busy looping of
      a waiter when the futex owner is currently executing the exit cleanup to
      prevent a potential live lock.
      
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: default avatarIngo Molnar <mingo@kernel.org>
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/20191106224556.845798895@linutronix.de
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      26f05b30
    • Thomas Gleixner's avatar
      futex: Provide state handling for exec() as well · 39947bfd
      Thomas Gleixner authored
      commit af8cbda2
      
       upstream.
      
      exec() attempts to handle potentially held futexes gracefully by running
      the futex exit handling code like exit() does.
      
      The current implementation has no protection against concurrent incoming
      waiters. The reason is that the futex state cannot be set to
      FUTEX_STATE_DEAD after the cleanup because the task struct is still active
      and just about to execute the new binary.
      
      While its arguably buggy when a task holds a futex over exec(), for
      consistency sake the state handling can at least cover the actual futex
      exit cleanup section. This provides state consistency protection accross
      the cleanup. As the futex state of the task becomes FUTEX_STATE_OK after the
      cleanup has been finished, this cannot prevent subsequent attempts to
      attach to the task in case that the cleanup was not successfull in mopping
      up all leftovers.
      
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: default avatarIngo Molnar <mingo@kernel.org>
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/20191106224556.753355618@linutronix.de
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      39947bfd
    • Thomas Gleixner's avatar
      futex: Sanitize exit state handling · 6eaebabf
      Thomas Gleixner authored
      commit 4a8e991b
      
       upstream.
      
      Instead of having a smp_mb() and an empty lock/unlock of task::pi_lock move
      the state setting into to the lock section.
      
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: default avatarIngo Molnar <mingo@kernel.org>
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/20191106224556.645603214@linutronix.de
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6eaebabf
    • Thomas Gleixner's avatar
      futex: Mark the begin of futex exit explicitly · 40da511f
      Thomas Gleixner authored
      commit 18f69438
      
       upstream.
      
      Instead of relying on PF_EXITING use an explicit state for the futex exit
      and set it in the futex exit function. This moves the smp barrier and the
      lock/unlock serialization into the futex code.
      
      As with the DEAD state this is restricted to the exit path as exec
      continues to use the same task struct.
      
      This allows to simplify that logic in a next step.
      
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: default avatarIngo Molnar <mingo@kernel.org>
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/20191106224556.539409004@linutronix.de
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      40da511f
    • Thomas Gleixner's avatar
      futex: Set task::futex_state to DEAD right after handling futex exit · da81e2f3
      Thomas Gleixner authored
      commit f24f2243
      
       upstream.
      
      Setting task::futex_state in do_exit() is rather arbitrarily placed for no
      reason. Move it into the futex code.
      
      Note, this is only done for the exit cleanup as the exec cleanup cannot set
      the state to FUTEX_STATE_DEAD because the task struct is still in active
      use.
      
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: default avatarIngo Molnar <mingo@kernel.org>
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/20191106224556.439511191@linutronix.de
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      da81e2f3
    • Thomas Gleixner's avatar
      futex: Split futex_mm_release() for exit/exec · 74937389
      Thomas Gleixner authored
      commit 150d7158
      
       upstream.
      
      To allow separate handling of the futex exit state in the futex exit code
      for exit and exec, split futex_mm_release() into two functions and invoke
      them from the corresponding exit/exec_mm_release() callsites.
      
      Preparatory only, no functional change.
      
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: default avatarIngo Molnar <mingo@kernel.org>
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/20191106224556.332094221@linutronix.de
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      74937389
    • Thomas Gleixner's avatar
      exit/exec: Seperate mm_release() · 93d2eb40
      Thomas Gleixner authored
      commit 4610ba7a
      
       upstream.
      
      mm_release() contains the futex exit handling. mm_release() is called from
      do_exit()->exit_mm() and from exec()->exec_mm().
      
      In the exit_mm() case PF_EXITING and the futex state is updated. In the
      exec_mm() case these states are not touched.
      
      As the futex exit code needs further protections against exit races, this
      needs to be split into two functions.
      
      Preparatory only, no functional change.
      
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: default avatarIngo Molnar <mingo@kernel.org>
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/20191106224556.240518241@linutronix.de
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      93d2eb40
    • Thomas Gleixner's avatar
      futex: Replace PF_EXITPIDONE with a state · 0838b827
      Thomas Gleixner authored
      commit 3d4775df
      
       upstream.
      
      The futex exit handling relies on PF_ flags. That's suboptimal as it
      requires a smp_mb() and an ugly lock/unlock of the exiting tasks pi_lock in
      the middle of do_exit() to enforce the observability of PF_EXITING in the
      futex code.
      
      Add a futex_state member to task_struct and convert the PF_EXITPIDONE logic
      over to the new state. The PF_EXITING dependency will be cleaned up in a
      later step.
      
      This prepares for handling various futex exit issues later.
      
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: default avatarIngo Molnar <mingo@kernel.org>
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/20191106224556.149449274@linutronix.de
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0838b827
    • Thomas Gleixner's avatar
      futex: Move futex exit handling into futex code · 8d2b511c
      Thomas Gleixner authored
      commit ba31c1a4
      
       upstream.
      
      The futex exit handling is #ifdeffed into mm_release() which is not pretty
      to begin with. But upcoming changes to address futex exit races need to add
      more functionality to this exit code.
      
      Split it out into a function, move it into futex code and make the various
      futex exit functions static.
      
      Preparatory only and no functional change.
      
      Folded build fix from Borislav.
      
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: default avatarIngo Molnar <mingo@kernel.org>
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/20191106224556.049705556@linutronix.de
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8d2b511c
    • Arnd Bergmann's avatar
      y2038: futex: Move compat implementation into futex.c · ad940f6d
      Arnd Bergmann authored
      commit 04e7712f
      
       upstream.
      
      We are going to share the compat_sys_futex() handler between 64-bit
      architectures and 32-bit architectures that need to deal with both 32-bit
      and 64-bit time_t, and this is easier if both entry points are in the
      same file.
      
      In fact, most other system call handlers do the same thing these days, so
      let's follow the trend here and merge all of futex_compat.c into futex.c.
      
      In the process, a few minor changes have to be done to make sure everything
      still makes sense: handle_futex_death() and futex_cmpxchg_enabled() become
      local symbol, and the compat version of the fetch_robust_entry() function
      gets renamed to compat_fetch_robust_entry() to avoid a symbol clash.
      
      This is intended as a purely cosmetic patch, no behavior should
      change.
      
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      [Lee: Back-ported to satisfy a build dependency]
      Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ad940f6d
    • Lorenzo Bianconi's avatar
      mt7601u: fix rx buffer refcounting · beffdc16
      Lorenzo Bianconi authored
      commit d24c7905 upstream.
      
      Fix the following crash due to erroneous page refcounting:
      
      [   32.445919] BUG: Bad page state in process swapper/1  pfn:11f65a
      [   32.447409] page:00000000938f0632 refcount:0 mapcount:-128 mapping:0000000000000000 index:0x0 pfn:0x11f65a
      [   32.449605] flags: 0x8000000000000000()
      [   32.450421] raw: 8000000000000000 ffffffff825b0148 ffffea00045ae988 0000000000000000
      [   32.451795] raw: 0000000000000000 0000000000000001 00000000ffffff7f 0000000000000000
      [   32.452999] page dumped because: nonzero mapcount
      [   32.453888] Modules linked in:
      [   32.454492] CPU: 1 PID: 0 Comm: swapper/1 Not tainted 5.11.0-rc2+ #1976
      [   32.455695] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.14.0-1.fc33 04/01/2014
      [   32.457157] Call Trace:
      [   32.457636]  <IRQ>
      [   32.457993]  dump_stack+0x77/0x97
      [   32.458576]  bad_page.cold+0x65/0x96
      [   32.459198]  get_page_from_freelist+0x46a/0x11f0
      [   32.460008]  __alloc_pages_nodemask+0x10a/0x2b0
      [   32.460794]  mt7601u_rx_tasklet+0x651/0x720
      [   32.461505]  tasklet_action_common.constprop.0+0x6b/0xd0
      [   32.462343]  __do_softirq+0x152/0x46c
      [   32.462928]  asm_call_irq_on_stack+0x12/0x20
      [   32.463610]  </IRQ>
      [   32.463953]  do_softirq_own_stack+0x5b/0x70
      [   32.464582]  irq_exit_rcu+0x9f/0xe0
      [   32.465028]  common_interrupt+0xae/0x1a0
      [   32.465536]  asm_common_interrupt+0x1e/0x40
      [   32.466071] RIP: 0010:default_idle+0x18/0x20
      [   32.468981] RSP: 0018:ffffc90000077f00 EFLAGS: 00000246
      [   32.469648] RAX: 0000000000000000 RBX: 0000000000000001 RCX: 0000000000000000
      [   32.470550] RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffffffff81aac3dd
      [   32.471463] RBP: ffff88810022ab00 R08: 0000000000000001 R09: 0000000000000001
      [   32.472335] R10: 0000000000000046 R11: 0000000000005aa0 R12: 0000000000000000
      [   32.473235] R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
      [   32.474139]  ? default_idle_call+0x4d/0x200
      [   32.474681]  default_idle_call+0x74/0x200
      [   32.475192]  do_idle+0x1d5/0x250
      [   32.475612]  cpu_startup_entry+0x19/0x20
      [   32.476114]  secondary_startup_64_no_verify+0xb0/0xbb
      [   32.476765] Disabling lock debugging due to kernel taint
      
      Fixes: c869f77d
      
       ("add mt7601u driver")
      Co-developed-by: default avatarFelix Fietkau <nbd@nbd.name>
      Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
      Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
      Acked-by: default avatarJakub Kicinski <kubakici@wp.pl>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/62b2380c8c2091834cfad05e1059b55f945bd114.1610643952.git.lorenzo@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      beffdc16
    • Lorenzo Bianconi's avatar
      mt7601u: fix kernel crash unplugging the device · 6f798bae
      Lorenzo Bianconi authored
      commit 0acb20a5 upstream.
      
      The following crash log can occur unplugging the usb dongle since,
      after the urb poison in mt7601u_free_tx_queue(), usb_submit_urb() will
      always fail resulting in a skb kfree while the skb has been already
      queued.
      
      Fix the issue enqueuing the skb only if usb_submit_urb() succeed.
      
      Hardware name: Hewlett-Packard 500-539ng/2B2C, BIOS 80.06 04/01/2015
      Workqueue: usb_hub_wq hub_event
      RIP: 0010:skb_trim+0x2c/0x30
      RSP: 0000:ffffb4c88005bba8 EFLAGS: 00010206
      RAX: 000000004ad483ee RBX: ffff9a236625dee0 RCX: 000000000000662f
      RDX: 000000000000000c RSI: 0000000000000000 RDI: ffff9a2343179300
      RBP: ffff9a2343179300 R08: 0000000000000001 R09: 0000000000000000
      R10: ffff9a23748f7840 R11: 0000000000000001 R12: ffff9a236625e4d4
      R13: ffff9a236625dee0 R14: 0000000000001080 R15: 0000000000000008
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00007fd410a34ef8 CR3: 00000001416ee001 CR4: 00000000001706f0
      Call Trace:
       mt7601u_tx_status+0x3e/0xa0 [mt7601u]
       mt7601u_dma_cleanup+0xca/0x110 [mt7601u]
       mt7601u_cleanup+0x22/0x30 [mt7601u]
       mt7601u_disconnect+0x22/0x60 [mt7601u]
       usb_unbind_interface+0x8a/0x270
       ? kernfs_find_ns+0x35/0xd0
       __device_release_driver+0x17a/0x230
       device_release_driver+0x24/0x30
       bus_remove_device+0xdb/0x140
       device_del+0x18b/0x430
       ? kobject_put+0x98/0x1d0
       usb_disable_device+0xc6/0x1f0
       usb_disconnect.cold+0x7e/0x20a
       hub_event+0xbf3/0x1870
       process_one_work+0x1b6/0x350
       worker_thread+0x53/0x3e0
       ? process_one_work+0x350/0x350
       kthread+0x11b/0x140
       ? __kthread_bind_mask+0x60/0x60
       ret_from_fork+0x22/0x30
      
      Fixes: 23377c20
      
       ("mt7601u: fix possible memory leak when the device is disconnected")
      Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
      Acked-by: default avatarJakub Kicinski <kubakici@wp.pl>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/3b85219f669a63a8ced1f43686de05915a580489.1610919247.git.lorenzo@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6f798bae
    • Like Xu's avatar
      KVM: x86/pmu: Fix HW_REF_CPU_CYCLES event pseudo-encoding in intel_arch_events[] · cb69f637
      Like Xu authored
      commit 98dd2f10 upstream.
      
      The HW_REF_CPU_CYCLES event on the fixed counter 2 is pseudo-encoded as
      0x0300 in the intel_perfmon_event_map[]. Correct its usage.
      
      Fixes: 62079d8a
      
       ("KVM: PMU: add proper support for fixed counter 2")
      Signed-off-by: default avatarLike Xu <like.xu@linux.intel.com>
      Message-Id: <20201230081916.63417-1-like.xu@linux.intel.com>
      Reviewed-by: default avatarSean Christopherson <seanjc@google.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cb69f637
    • Giacinto Cifelli's avatar
      net: usb: qmi_wwan: added support for Thales Cinterion PLSx3 modem family · eeaf7e8a
      Giacinto Cifelli authored
      commit 7e0e63d0
      
       upstream.
      
      Bus 003 Device 009: ID 1e2d:006f
      Device Descriptor:
        bLength                18
        bDescriptorType         1
        bcdUSB               2.00
        bDeviceClass          239 Miscellaneous Device
        bDeviceSubClass         2 ?
        bDeviceProtocol         1 Interface Association
        bMaxPacketSize0        64
        idVendor           0x1e2d
        idProduct          0x006f
        bcdDevice            0.00
        iManufacturer           3 Cinterion Wireless Modules
        iProduct                2 PLSx3
        iSerial                 4 fa3c1419
        bNumConfigurations      1
        Configuration Descriptor:
          bLength                 9
          bDescriptorType         2
          wTotalLength          303
          bNumInterfaces          9
          bConfigurationValue     1
          iConfiguration          1 Cinterion Configuration
          bmAttributes         0xe0
            Self Powered
            Remote Wakeup
          MaxPower              500mA
          Interface Association:
            bLength                 8
            bDescriptorType        11
            bFirstInterface         0
            bInterfaceCount         2
            bFunctionClass          2 Communications
            bFunctionSubClass       2 Abstract (modem)
            bFunctionProtocol       1 AT-commands (v.25ter)
            iFunction               0
          Interface Descriptor:
            bLength                 9
            bDescriptorType         4
            bInterfaceNumber        0
            bAlternateSetting       0
            bNumEndpoints           1
            bInterfaceClass         2 Communications
            bInterfaceSubClass      2 Abstract (modem)
            bInterfaceProtocol      1 AT-commands (v.25ter)
            iInterface              0
            CDC Header:
              bcdCDC               1.10
            CDC ACM:
              bmCapabilities       0x02
                line coding and serial state
            CDC Call Management:
              bmCapabilities       0x03
                call management
                use DataInterface
              bDataInterface          1
            CDC Union:
              bMasterInterface        0
              bSlaveInterface         1
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x81  EP 1 IN
              bmAttributes            3
                Transfer Type            Interrupt
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0040  1x 64 bytes
              bInterval               5
          Interface Descriptor:
            bLength                 9
            bDescriptorType         4
            bInterfaceNumber        1
            bAlternateSetting       0
            bNumEndpoints           2
            bInterfaceClass        10 CDC Data
            bInterfaceSubClass      0 Unused
            bInterfaceProtocol      0
            iInterface              0
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x82  EP 2 IN
              bmAttributes            2
                Transfer Type            Bulk
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0200  1x 512 bytes
              bInterval               0
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x01  EP 1 OUT
              bmAttributes            2
                Transfer Type            Bulk
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0200  1x 512 bytes
              bInterval               0
          Interface Association:
            bLength                 8
            bDescriptorType        11
            bFirstInterface         2
            bInterfaceCount         2
            bFunctionClass          2 Communications
            bFunctionSubClass       2 Abstract (modem)
            bFunctionProtocol       1 AT-commands (v.25ter)
            iFunction               0
          Interface Descriptor:
            bLength                 9
            bDescriptorType         4
            bInterfaceNumber        2
            bAlternateSetting       0
            bNumEndpoints           1
            bInterfaceClass         2 Communications
            bInterfaceSubClass      2 Abstract (modem)
            bInterfaceProtocol      1 AT-commands (v.25ter)
            iInterface              0
            CDC Header:
              bcdCDC               1.10
            CDC ACM:
              bmCapabilities       0x02
                line coding and serial state
            CDC Call Management:
              bmCapabilities       0x03
                call management
                use DataInterface
              bDataInterface          3
            CDC Union:
              bMasterInterface        2
              bSlaveInterface         3
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x83  EP 3 IN
              bmAttributes            3
                Transfer Type            Interrupt
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0040  1x 64 bytes
              bInterval               5
          Interface Descriptor:
            bLength                 9
            bDescriptorType         4
            bInterfaceNumber        3
            bAlternateSetting       0
            bNumEndpoints           2
            bInterfaceClass        10 CDC Data
            bInterfaceSubClass      0 Unused
            bInterfaceProtocol      0
            iInterface              0
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x84  EP 4 IN
              bmAttributes            2
                Transfer Type            Bulk
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0200  1x 512 bytes
              bInterval               0
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x02  EP 2 OUT
              bmAttributes            2
                Transfer Type            Bulk
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0200  1x 512 bytes
              bInterval               0
          Interface Association:
            bLength                 8
            bDescriptorType        11
            bFirstInterface         4
            bInterfaceCount         2
            bFunctionClass          2 Communications
            bFunctionSubClass       2 Abstract (modem)
            bFunctionProtocol       1 AT-commands (v.25ter)
            iFunction               0
          Interface Descriptor:
            bLength                 9
            bDescriptorType         4
            bInterfaceNumber        4
            bAlternateSetting       0
            bNumEndpoints           1
            bInterfaceClass         2 Communications
            bInterfaceSubClass      2 Abstract (modem)
            bInterfaceProtocol      1 AT-commands (v.25ter)
            iInterface              0
            CDC Header:
              bcdCDC               1.10
            CDC ACM:
              bmCapabilities       0x02
                line coding and serial state
            CDC Call Management:
              bmCapabilities       0x03
                call management
                use DataInterface
              bDataInterface          5
            CDC Union:
              bMasterInterface        4
              bSlaveInterface         5
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x85  EP 5 IN
              bmAttributes            3
                Transfer Type            Interrupt
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0040  1x 64 bytes
              bInterval               5
          Interface Descriptor:
            bLength                 9
            bDescriptorType         4
            bInterfaceNumber        5
            bAlternateSetting       0
            bNumEndpoints           2
            bInterfaceClass        10 CDC Data
            bInterfaceSubClass      0 Unused
            bInterfaceProtocol      0
            iInterface              0
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x86  EP 6 IN
              bmAttributes            2
                Transfer Type            Bulk
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0200  1x 512 bytes
              bInterval               0
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x03  EP 3 OUT
              bmAttributes            2
                Transfer Type            Bulk
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0200  1x 512 bytes
              bInterval               0
          Interface Association:
            bLength                 8
            bDescriptorType        11
            bFirstInterface         6
            bInterfaceCount         2
            bFunctionClass          2 Communications
            bFunctionSubClass       2 Abstract (modem)
            bFunctionProtocol       1 AT-commands (v.25ter)
            iFunction               0
          Interface Descriptor:
            bLength                 9
            bDescriptorType         4
            bInterfaceNumber        6
            bAlternateSetting       0
            bNumEndpoints           1
            bInterfaceClass         2 Communications
            bInterfaceSubClass      2 Abstract (modem)
            bInterfaceProtocol      1 AT-commands (v.25ter)
            iInterface              0
            CDC Header:
              bcdCDC               1.10
            CDC ACM:
              bmCapabilities       0x02
                line coding and serial state
            CDC Call Management:
              bmCapabilities       0x03
                call management
                use DataInterface
              bDataInterface          7
            CDC Union:
              bMasterInterface        6
              bSlaveInterface         7
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x87  EP 7 IN
              bmAttributes            3
                Transfer Type            Interrupt
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0040  1x 64 bytes
              bInterval               5
          Interface Descriptor:
            bLength                 9
            bDescriptorType         4
            bInterfaceNumber        7
            bAlternateSetting       0
            bNumEndpoints           2
            bInterfaceClass        10 CDC Data
            bInterfaceSubClass      0 Unused
            bInterfaceProtocol      0
            iInterface              0
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x88  EP 8 IN
              bmAttributes            2
                Transfer Type            Bulk
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0200  1x 512 bytes
              bInterval               0
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x04  EP 4 OUT
              bmAttributes            2
                Transfer Type            Bulk
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0200  1x 512 bytes
              bInterval               0
          Interface Descriptor:
            bLength                 9
            bDescriptorType         4
            bInterfaceNumber        8
            bAlternateSetting       0
            bNumEndpoints           3
            bInterfaceClass       255 Vendor Specific Class
            bInterfaceSubClass    255 Vendor Specific Subclass
            bInterfaceProtocol    255 Vendor Specific Protocol
            iInterface              0
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x89  EP 9 IN
              bmAttributes            3
                Transfer Type            Interrupt
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0040  1x 64 bytes
              bInterval               5
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x8a  EP 10 IN
              bmAttributes            2
                Transfer Type            Bulk
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0200  1x 512 bytes
              bInterval               0
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x05  EP 5 OUT
              bmAttributes            2
                Transfer Type            Bulk
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0200  1x 512 bytes
              bInterval               0
      Device Qualifier (for other device speed):
        bLength                10
        bDescriptorType         6
        bcdUSB               2.00
        bDeviceClass          239 Miscellaneous Device
        bDeviceSubClass         2 ?
        bDeviceProtocol         1 Interface Association
        bMaxPacketSize0        64
        bNumConfigurations      1
      Device Status:     0x0000
        (Bus Powered)
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarGiacinto Cifelli <gciofono@gmail.com>
      Acked-by: default avatarBjørn Mork <bjorn@mork.no>
      Link: https://lore.kernel.org/r/20210120045650.10855-1-gciofono@gmail.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      eeaf7e8a
    • Johannes Berg's avatar
      wext: fix NULL-ptr-dereference with cfg80211's lack of commit() · 65ffc738
      Johannes Berg authored
      commit 51225651
      
       upstream.
      
      Since cfg80211 doesn't implement commit, we never really cared about
      that code there (and it's configured out w/o CONFIG_WIRELESS_EXT).
      After all, since it has no commit, it shouldn't return -EIWCOMMIT to
      indicate commit is needed.
      
      However, EIWCOMMIT is actually an alias for EINPROGRESS, which _can_
      happen if e.g. we try to change the frequency but we're already in
      the process of connecting to some network, and drivers could return
      that value (or even cfg80211 itself might).
      
      This then causes us to crash because dev->wireless_handlers is NULL
      but we try to check dev->wireless_handlers->standard[0].
      
      Fix this by also checking dev->wireless_handlers. Also simplify the
      code a little bit.
      
      Cc: stable@vger.kernel.org
      Reported-by: default avatar <syzbot+444248c79e117bc99f46@syzkaller.appspotmail.com>
      Reported-by: default avatar <syzbot+8b2a88a09653d4084179@syzkaller.appspotmail.com>
      Link: https://lore.kernel.org/r/20210121171621.2076e4a37d5a.I5d9c72220fe7bb133fb718751da0180a57ecba4e@changeid
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      65ffc738
    • Kai-Heng Feng's avatar
      ACPI: sysfs: Prefer "compatible" modalias · 4bb12fd8
      Kai-Heng Feng authored
      commit 36af2d5c upstream.
      
      Commit 8765c5ba
      
       ("ACPI / scan: Rework modalias creation when
      "compatible" is present") may create two "MODALIAS=" in one uevent
      file if specific conditions are met.
      
      This breaks systemd-udevd, which assumes each "key" in one uevent file
      to be unique. The internal implementation of systemd-udevd overwrites
      the first MODALIAS with the second one, so its kmod rule doesn't load
      the driver for the first MODALIAS.
      
      So if both the ACPI modalias and the OF modalias are present, use the
      latter to ensure that there will be only one MODALIAS.
      
      Link: https://github.com/systemd/systemd/pull/18163
      Suggested-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
      Fixes: 8765c5ba
      
       ("ACPI / scan: Rework modalias creation when "compatible" is present")
      Signed-off-by: default avatarKai-Heng Feng <kai.heng.feng@canonical.com>
      Reviewed-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
      Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: 4.1+ <stable@vger.kernel.org> # 4.1+
      [ rjw: Subject and changelog edits ]
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4bb12fd8
  3. Jan 30, 2021
    • Greg Kroah-Hartman's avatar
      Linux 4.4.254 · 65554cac
      Greg Kroah-Hartman authored
      
      
      Tested-by: default avatarPavel Machek (CIP) <pavel@denx.de>
      Tested-by: default avatarLinux Kernel Functional Testing <lkft@linaro.org>
      Link: https://lore.kernel.org/r/20210129105909.630107942@linuxfoundation.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      v4.4.254
      65554cac
    • Arvind Sankar's avatar
      x86/boot/compressed: Disable relocation relaxation · d3979f16
      Arvind Sankar authored
      commit 09e43968
      
       upstream.
      
      The x86-64 psABI [0] specifies special relocation types
      (R_X86_64_[REX_]GOTPCRELX) for indirection through the Global Offset
      Table, semantically equivalent to R_X86_64_GOTPCREL, which the linker
      can take advantage of for optimization (relaxation) at link time. This
      is supported by LLD and binutils versions 2.26 onwards.
      
      The compressed kernel is position-independent code, however, when using
      LLD or binutils versions before 2.27, it must be linked without the -pie
      option. In this case, the linker may optimize certain instructions into
      a non-position-independent form, by converting foo@GOTPCREL(%rip) to $foo.
      
      This potential issue has been present with LLD and binutils-2.26 for a
      long time, but it has never manifested itself before now:
      
      - LLD and binutils-2.26 only relax
      	movq	foo@GOTPCREL(%rip), %reg
        to
      	leaq	foo(%rip), %reg
        which is still position-independent, rather than
      	mov	$foo, %reg
        which is permitted by the psABI when -pie is not enabled.
      
      - GCC happens to only generate GOTPCREL relocations on mov instructions.
      
      - CLang does generate GOTPCREL relocations on non-mov instructions, but
        when building the compressed kernel, it uses its integrated assembler
        (due to the redefinition of KBUILD_CFLAGS dropping -no-integrated-as),
        which has so far defaulted to not generating the GOTPCRELX
        relocations.
      
      Nick Desaulniers reports [1,2]:
      
        "A recent change [3] to a default value of configuration variable
         (ENABLE_X86_RELAX_RELOCATIONS OFF -> ON) in LLVM now causes Clang's
         integrated assembler to emit R_X86_64_GOTPCRELX/R_X86_64_REX_GOTPCRELX
         relocations. LLD will relax instructions with these relocations based
         on whether the image is being linked as position independent or not.
         When not, then LLD will relax these instructions to use absolute
         addressing mode (R_RELAX_GOT_PC_NOPIC). This causes kernels built with
         Clang and linked with LLD to fail to boot."
      
      Patch series [4] is a solution to allow the compressed kernel to be
      linked with -pie unconditionally, but even if merged is unlikely to be
      backported. As a simple solution that can be applied to stable as well,
      prevent the assembler from generating the relaxed relocation types using
      the -mrelax-relocations=no option. For ease of backporting, do this
      unconditionally.
      
      [0] https://gitlab.com/x86-psABIs/x86-64-ABI/-/blob/master/x86-64-ABI/linker-optimization.tex#L65
      [1] https://lore.kernel.org/lkml/20200807194100.3570838-1-ndesaulniers@google.com/
      [2] https://github.com/ClangBuiltLinux/linux/issues/1121
      [3] https://reviews.llvm.org/rGc41a18cf61790fc898dcda1055c3efbf442c14c0
      [4] https://lore.kernel.org/lkml/20200731202738.2577854-1-nivedita@alum.mit.edu/
      
      Reported-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarArvind Sankar <nivedita@alum.mit.edu>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Tested-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Tested-by: default avatarSedat Dilek <sedat.dilek@gmail.com>
      Acked-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20200812004308.1448603-1-nivedita@alum.mit.edu
      [nc: Backport to 4.4]
      Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d3979f16
    • Pawel Wieczorkiewicz's avatar
      xen-blkback: set ring->xenblkd to NULL after kthread_stop() · 241862be
      Pawel Wieczorkiewicz authored
      commit 1c728719 upstream.
      
      When xen_blkif_disconnect() is called, the kernel thread behind the
      block interface is stopped by calling kthread_stop(ring->xenblkd).
      The ring->xenblkd thread pointer being non-NULL determines if the
      thread has been already stopped.
      Normally, the thread's function xen_blkif_schedule() sets the
      ring->xenblkd to NULL, when the thread's main loop ends.
      
      However, when the thread has not been started yet (i.e.
      wake_up_process() has not been called on it), the xen_blkif_schedule()
      function would not be called yet.
      
      In such case the kthread_stop() call returns -EINTR and the
      ring->xenblkd remains dangling.
      When this happens, any consecutive call to xen_blkif_disconnect (for
      example in frontend_changed() callback) leads to a kernel crash in
      kthread_stop() (e.g. NULL pointer dereference in exit_creds()).
      
      This is XSA-350.
      
      Cc: <stable@vger.kernel.org> # 4.12
      Fixes: a24fa22c
      
       ("xen/blkback: don't use xen_blkif_get() in xen-blkback kthread")
      Reported-by: default avatarOlivier Benjamin <oliben@amazon.com>
      Reported-by: default avatarPawel Wieczorkiewicz <wipawel@amazon.de>
      Signed-off-by: default avatarPawel Wieczorkiewicz <wipawel@amazon.de>
      Reviewed-by: default avatarJulien Grall <jgrall@amazon.com>
      Reviewed-by: default avatarJuergen Gross <jgross@suse.com>
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      [iwamatsu: change from ring to blkif]
      Signed-off-by: default avatarNobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      241862be
    • Gaurav Kohli's avatar
      tracing: Fix race in trace_open and buffer resize call · a7c2dd44
      Gaurav Kohli authored
      commit bbeb9746 upstream.
      
      Below race can come, if trace_open and resize of
      cpu buffer is running parallely on different cpus
      CPUX                                CPUY
      				    ring_buffer_resize
      				    atomic_read(&buffer->resize_disabled)
      tracing_open
      tracing_reset_online_cpus
      ring_buffer_reset_cpu
      rb_reset_cpu
      				    rb_update_pages
      				    remove/insert pages
      resetting pointer
      
      This race can cause data abort or some times infinte loop in
      rb_remove_pages and rb_insert_pages while checking pages
      for sanity.
      
      Take buffer lock to fix this.
      
      Link: https://lkml.kernel.org/r/1601976833-24377-1-git-send-email-gkohli@codeaurora.org
      
      Cc: stable@vger.kernel.org
      Fixes: 83f40318
      
       ("ring-buffer: Make removal of ring buffer pages atomic")
      Reported-by: default avatarDenis Efremov <efremov@linux.com>
      Signed-off-by: default avatarGaurav Kohli <gkohli@codeaurora.org>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a7c2dd44
    • Wang Hai's avatar
      Revert "mm/slub: fix a memory leak in sysfs_slab_add()" · ab98f2e2
      Wang Hai authored
      commit 757fed1d upstream.
      
      This reverts commit dde3c6b7.
      
      syzbot report a double-free bug. The following case can cause this bug.
      
       - mm/slab_common.c: create_cache(): if the __kmem_cache_create() fails,
         it does:
      
      	out_free_cache:
      		kmem_cache_free(kmem_cache, s);
      
       - but __kmem_cache_create() - at least for slub() - will have done
      
      	sysfs_slab_add(s)
      		-> sysfs_create_group() .. fails ..
      		-> kobject_del(&s->kobj); .. which frees s ...
      
      We can't remove the kmem_cache_free() in create_cache(), because other
      error cases of __kmem_cache_create() do not free this.
      
      So, revert the commit dde3c6b7
      
       ("mm/slub: fix a memory leak in
      sysfs_slab_add()") to fix this.
      
      Reported-by: default avatar <syzbot+d0bd96b4696c1ef67991@syzkaller.appspotmail.com>
      Fixes: dde3c6b7
      
       ("mm/slub: fix a memory leak in sysfs_slab_add()")
      Acked-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Signed-off-by: default avatarWang Hai <wanghai38@huawei.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ab98f2e2
    • Eric Dumazet's avatar
      net_sched: avoid shift-out-of-bounds in tcindex_set_parms() · b5fb0ad9
      Eric Dumazet authored
      commit bcd0cf19 upstream.
      
      tc_index being 16bit wide, we need to check that TCA_TCINDEX_SHIFT
      attribute is not silly.
      
      UBSAN: shift-out-of-bounds in net/sched/cls_tcindex.c:260:29
      shift exponent 255 is too large for 32-bit type 'int'
      CPU: 0 PID: 8516 Comm: syz-executor228 Not tainted 5.10.0-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      Call Trace:
       __dump_stack lib/dump_stack.c:79 [inline]
       dump_stack+0x107/0x163 lib/dump_stack.c:120
       ubsan_epilogue+0xb/0x5a lib/ubsan.c:148
       __ubsan_handle_shift_out_of_bounds.cold+0xb1/0x181 lib/ubsan.c:395
       valid_perfect_hash net/sched/cls_tcindex.c:260 [inline]
       tcindex_set_parms.cold+0x1b/0x215 net/sched/cls_tcindex.c:425
       tcindex_change+0x232/0x340 net/sched/cls_tcindex.c:546
       tc_new_tfilter+0x13fb/0x21b0 net/sched/cls_api.c:2127
       rtnetlink_rcv_msg+0x8b6/0xb80 net/core/rtnetlink.c:5555
       netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2494
       netlink_unicast_kernel net/netlink/af_netlink.c:1304 [inline]
       netlink_unicast+0x533/0x7d0 net/netlink/af_netlink.c:1330
       netlink_sendmsg+0x907/0xe40 net/netlink/af_netlink.c:1919
       sock_sendmsg_nosec net/socket.c:652 [inline]
       sock_sendmsg+0xcf/0x120 net/socket.c:672
       ____sys_sendmsg+0x6e8/0x810 net/socket.c:2336
       ___sys_sendmsg+0xf3/0x170 net/socket.c:2390
       __sys_sendmsg+0xe5/0x1b0 net/socket.c:2423
       do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
       entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Link: https://lore.kernel.org/r/20210114185229.1742255-1-eric.dumazet@gmail.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b5fb0ad9
    • Matteo Croce's avatar
      ipv6: create multicast route with RTPROT_KERNEL · 69e42284
      Matteo Croce authored
      commit a826b043 upstream.
      
      The ff00::/8 multicast route is created without specifying the fc_protocol
      field, so the default RTPROT_BOOT value is used:
      
        $ ip -6 -d route
        unicast ::1 dev lo proto kernel scope global metric 256 pref medium
        unicast fe80::/64 dev eth0 proto kernel scope global metric 256 pref medium
        unicast ff00::/8 dev eth0 proto boot scope global metric 256 pref medium
      
      As the documentation says, this value identifies routes installed during
      boot, but the route is created when interface is set up.
      Change the value to RTPROT_KERNEL which is a better value.
      
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarMatteo Croce <mcroce@microsoft.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      69e42284
    • Alexander Lobakin's avatar
      skbuff: back tiny skbs with kmalloc() in __netdev_alloc_skb() too · c29efd70
      Alexander Lobakin authored
      commit 66c55602 upstream.
      
      Commit 3226b158 ("net: avoid 32 x truesize under-estimation for
      tiny skbs") ensured that skbs with data size lower than 1025 bytes
      will be kmalloc'ed to avoid excessive page cache fragmentation and
      memory consumption.
      However, the fix adressed only __napi_alloc_skb() (primarily for
      virtio_net and napi_get_frags()), but the issue can still be achieved
      through __netdev_alloc_skb(), which is still used by several drivers.
      Drivers often allocate a tiny skb for headers and place the rest of
      the frame to frags (so-called copybreak).
      Mirror the condition to __netdev_alloc_skb() to handle this case too.
      
      Since v1 [0]:
       - fix "Fixes:" tag;
       - refine commit message (mention copybreak usecase).
      
      [0] https://lore.kernel.org/netdev/20210114235423.232737-1-alobakin@pm.me
      
      Fixes: a1c7fff7
      
       ("net: netdev_alloc_skb() use build_skb()")
      Signed-off-by: default avatarAlexander Lobakin <alobakin@pm.me>
      Link: https://lore.kernel.org/r/20210115150354.85967-1-alobakin@pm.me
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c29efd70
    • Geert Uytterhoeven's avatar
      sh_eth: Fix power down vs. is_opened flag ordering · 17663f1a
      Geert Uytterhoeven authored
      commit f6a2e94b upstream.
      
      sh_eth_close() does a synchronous power down of the device before
      marking it closed.  Revert the order, to make sure the device is never
      marked opened while suspended.
      
      While at it, use pm_runtime_put() instead of pm_runtime_put_sync(), as
      there is no reason to do a synchronous power down.
      
      Fixes: 7fa2955f
      
       ("sh_eth: Fix sleeping function called from invalid context")
      Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Reviewed-by: default avatarSergei Shtylyov <sergei.shtylyov@gmail.com>
      Reviewed-by: default avatarNiklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
      Link: https://lore.kernel.org/r/20210118150812.796791-1-geert+renesas@glider.be
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      17663f1a
    • Necip Fazil Yildiran's avatar
      sh: dma: fix kconfig dependency for G2_DMA · 8a37f1cd
      Necip Fazil Yildiran authored
      commit f477a538 upstream.
      
      When G2_DMA is enabled and SH_DMA is disabled, it results in the following
      Kbuild warning:
      
      WARNING: unmet direct dependencies detected for SH_DMA_API
        Depends on [n]: SH_DMA [=n]
        Selected by [y]:
        - G2_DMA [=y] && SH_DREAMCAST [=y]
      
      The reason is that G2_DMA selects SH_DMA_API without depending on or
      selecting SH_DMA while SH_DMA_API depends on SH_DMA.
      
      When G2_DMA was first introduced with commit 40f49e7e
      ("sh: dma: Make G2 DMA configurable."), this wasn't an issue since
      SH_DMA_API didn't have such dependency, and this way was the only way to
      enable it since SH_DMA_API was non-visible. However, later SH_DMA_API was
      made visible and dependent on SH_DMA with commit d8902adc
      ("dmaengine: sh: Add Support SuperH DMA Engine driver").
      
      Let G2_DMA depend on SH_DMA_API instead to avoid Kbuild issues.
      
      Fixes: d8902adc
      
       ("dmaengine: sh: Add Support SuperH DMA Engine driver")
      Signed-off-by: default avatarNecip Fazil Yildiran <fazilyildiran@gmail.com>
      Signed-off-by: default avatarRich Felker <dalias@libc.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8a37f1cd