Skip to content
Snippets Groups Projects
  1. Jul 24, 2024
    • Florian Muller's avatar
      abox: Call pm_runtime_get() on pm_runtime_suspend() failure · 5e0f4b78
      Florian Muller authored
      
      If ABOX_QUIRK_OFF_ON_SUSPEND is used (which is
      the case on our device), we need to keep resume/suspend requests in
      sync. Because of this, if pm_runtime_suspend() fails in
      abox_pm_notifier(), we need to call pm_runtime_get() before returning
      with NOTIFY_BAD in order to avoid the power usage counter for the
      driver power runtime routines to get out of sync.
      
      Bug: 343048383
      Test: Manual
      Change-Id: I5e0cf8f89bf44ecfae7a6194ae868b1646d09f86
      Signed-off-by: default avatarFlorian Muller <mullerf@google.com>
      2 tags
      5e0f4b78
  2. Jul 22, 2024
    • Florian Muller's avatar
      abox: Properly advertise abox disable state · 16af18d5
      Florian Muller authored
      
      This is to prevent the power domain (pd) controlling the abox + display
      to try to disable itself when abox is still enabled, which would lead
      to issues such as crashes, freezes, or the system refusing to suspend.
      
      Also, in the case of PD trying to disable before Abox was suspended, we
      try one more time ~10 ms later to give an extra chance. It can happen
      rarely that PD happens at the same time Abox gets disabled, so a retry
      mechanism is preferred in order to give an extra chance to disable the
      power domain.
      
      Bug: 343048383
      Test: Manual
      Change-Id: I7c9de090b9b7f336d91c02894b8cc753de9416c8
      Signed-off-by: default avatarFlorian Muller <mullerf@google.com>
      16af18d5
  3. Jul 01, 2024
  4. Jun 24, 2024
  5. Jun 03, 2024
  6. Jun 01, 2024
    • Greg Kroah-Hartman's avatar
      Merge 4.19.315 into android-4.19-stable · 8ccbe208
      Greg Kroah-Hartman authored
      
      Changes in 4.19.315
      	Revert "selftests: mm: fix map_hugetlb failure on 64K page size systems"
      	dm: limit the number of targets and parameter size area
      	btrfs: add missing mutex_unlock in btrfs_relocate_sys_chunks()
      	tracing: Simplify creation and deletion of synthetic events
      	tracing: Add unified dynamic event framework
      	tracing: Use dyn_event framework for synthetic events
      	tracing: Remove unneeded synth_event_mutex
      	tracing: Consolidate trace_add/remove_event_call back to the nolock functions
      	string.h: Add str_has_prefix() helper function
      	tracing: Use str_has_prefix() helper for histogram code
      	tracing: Use str_has_prefix() instead of using fixed sizes
      	tracing: Have the historgram use the result of str_has_prefix() for len of prefix
      	tracing: Refactor hist trigger action code
      	tracing: Split up onmatch action data
      	tracing: Generalize hist trigger onmax and save action
      	tracing: Remove unnecessary var_ref destroy in track_data_destroy()
      	serial: kgdboc: Fix NMI-safety problems from keyboard reset code
      	docs: kernel_include.py: Cope with docutils 0.21
      	Linux 4.19.315
      
      Change-Id: I20fdf3ecd83c6f7654e6118390444de784a0b100
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
      8ccbe208
  7. May 25, 2024
  8. May 17, 2024
    • Michal Luczaj's avatar
      af_unix: Fix garbage collector racing against connect() · 04ec3df6
      Michal Luczaj authored
      
      [ Upstream commit 47d8ac011fe1c9251070e1bd64cb10b48193ec51 ]
      
      Garbage collector does not take into account the risk of embryo getting
      enqueued during the garbage collection. If such embryo has a peer that
      carries SCM_RIGHTS, two consecutive passes of scan_children() may see a
      different set of children. Leading to an incorrectly elevated inflight
      count, and then a dangling pointer within the gc_inflight_list.
      
      sockets are AF_UNIX/SOCK_STREAM
      S is an unconnected socket
      L is a listening in-flight socket bound to addr, not in fdtable
      V's fd will be passed via sendmsg(), gets inflight count bumped
      
      connect(S, addr)	sendmsg(S, [V]); close(V)	__unix_gc()
      ----------------	-------------------------	-----------
      
      NS = unix_create1()
      skb1 = sock_wmalloc(NS)
      L = unix_find_other(addr)
      unix_state_lock(L)
      unix_peer(S) = NS
      			// V count=1 inflight=0
      
       			NS = unix_peer(S)
       			skb2 = sock_alloc()
      			skb_queue_tail(NS, skb2[V])
      
      			// V became in-flight
      			// V count=2 inflight=1
      
      			close(V)
      
      			// V count=1 inflight=1
      			// GC candidate condition met
      
      						for u in gc_inflight_list:
      						  if (total_refs == inflight_refs)
      						    add u to gc_candidates
      
      						// gc_candidates={L, V}
      
      						for u in gc_candidates:
      						  scan_children(u, dec_inflight)
      
      						// embryo (skb1) was not
      						// reachable from L yet, so V's
      						// inflight remains unchanged
      __skb_queue_tail(L, skb1)
      unix_state_unlock(L)
      						for u in gc_candidates:
      						  if (u.inflight)
      						    scan_children(u, inc_inflight_move_tail)
      
      						// V count=1 inflight=2 (!)
      
      If there is a GC-candidate listening socket, lock/unlock its state. This
      makes GC wait until the end of any ongoing connect() to that socket. After
      flipping the lock, a possibly SCM-laden embryo is already enqueued. And if
      there is another embryo coming, it can not possibly carry SCM_RIGHTS. At
      this point, unix_inflight() can not happen because unix_gc_lock is already
      taken. Inflight graph remains unaffected.
      
      Bug: 336268889
      Fixes: 1fd05ba5 ("[AF_UNIX]: Rewrite garbage collector, fixes race.")
      Signed-off-by: default avatarMichal Luczaj <mhal@rbox.co>
      Reviewed-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
      Link: https://lore.kernel.org/r/20240409201047.1032217-1-mhal@rbox.co
      
      
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      (cherry picked from commit a36ae0ec)
      (cherry picked from https://partner-android-review.googlesource.com/q/commit:ff6eb0693d4de809bdb0f245f8d51390e5804584)
      Merged-In: I33a972b4033574fc9abce6b9b4270ed58976e32a
      Change-Id: I33a972b4033574fc9abce6b9b4270ed58976e32a
      04ec3df6
    • Kuniyuki Iwashima's avatar
      af_unix: Do not use atomic ops for unix_sk(sk)->inflight. · e58f40d0
      Kuniyuki Iwashima authored
      
      [ Upstream commit 97af84a6bba2ab2b9c704c08e67de3b5ea551bb2 ]
      
      When touching unix_sk(sk)->inflight, we are always under
      spin_lock(&unix_gc_lock).
      
      Let's convert unix_sk(sk)->inflight to the normal unsigned long.
      
      Bug: 336268889
      Signed-off-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Link: https://lore.kernel.org/r/20240123170856.41348-3-kuniyu@amazon.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      (cherry picked from commit c8a2b1f7)
      (cherry picked from https://partner-android-review.googlesource.com/q/commit:f387b3ea2b5feaf6bf655d117bb6712c42f4b840)
      Merged-In: I2adb852f82dc549d6f3d234259a0a9a00ff7df00
      Change-Id: I2adb852f82dc549d6f3d234259a0a9a00ff7df00
      e58f40d0
    • Greg Kroah-Hartman's avatar
      Merge 4.19.314 into android-4.19-stable · 65e58a86
      Greg Kroah-Hartman authored
      
      Changes in 4.19.314
      	dmaengine: pl330: issue_pending waits until WFP state
      	dmaengine: Revert "dmaengine: pl330: issue_pending waits until WFP state"
      	wifi: nl80211: don't free NULL coalescing rule
      	drm/amdkfd: change system memory overcommit limit
      	drm/amdgpu: Fix leak when GPU memory allocation fails
      	net: slightly optimize eth_type_trans
      	ethernet: add a helper for assigning port addresses
      	ethernet: Add helper for assigning packet type when dest address does not match device address
      	pinctrl: core: delete incorrect free in pinctrl_enable()
      	power: rt9455: hide unused rt9455_boost_voltage_values
      	pinctrl: devicetree: fix refcount leak in pinctrl_dt_to_map()
      	s390/mm: Fix storage key clearing for guest huge pages
      	s390/mm: Fix clearing storage keys for huge pages
      	bna: ensure the copied buf is NUL terminated
      	nsh: Restore skb->{protocol,data,mac_header} for outer header in nsh_gso_segment().
      	net l2tp: drop flow hash on forward
      	net: dsa: mv88e6xxx: Add number of MACs in the ATU
      	net: dsa: mv88e6xxx: Fix number of databases for 88E6141 / 88E6341
      	net: bridge: fix multicast-to-unicast with fraglist GSO
      	tipc: fix a possible memleak in tipc_buf_append
      	scsi: lpfc: Update lpfc_ramp_down_queue_handler() logic
      	gfs2: Fix invalid metadata access in punch_hole
      	wifi: mac80211: fix ieee80211_bss_*_flags kernel-doc
      	net: mark racy access on sk->sk_rcvbuf
      	scsi: bnx2fc: Remove spin_lock_bh while releasing resources after upload
      	ALSA: line6: Zero-initialize message buffers
      	net: bcmgenet: Reset RBUF on first open
      	ata: sata_gemini: Check clk_enable() result
      	firewire: ohci: mask bus reset interrupts between ISR and bottom half
      	tools/power turbostat: Fix added raw MSR output
      	tools/power turbostat: Fix Bzy_MHz documentation typo
      	btrfs: make btrfs_clear_delalloc_extent() free delalloc reserve
      	btrfs: always clear PERTRANS metadata during commit
      	scsi: target: Fix SELinux error when systemd-modules loads the target module
      	selftests: timers: Fix valid-adjtimex signed left-shift undefined behavior
      	fs/9p: only translate RWX permissions for plain 9P2000
      	fs/9p: translate O_TRUNC into OTRUNC
      	9p: explicitly deny setlease attempts
      	gpio: wcove: Use -ENOTSUPP consistently
      	gpio: crystalcove: Use -ENOTSUPP consistently
      	fs/9p: drop inodes immediately on non-.L too
      	net:usb:qmi_wwan: support Rolling modules
      	tcp: remove redundant check on tskb
      	tcp: defer shutdown(SEND_SHUTDOWN) for TCP_SYN_RECV sockets
      	tcp: Use refcount_inc_not_zero() in tcp_twsk_unique().
      	Bluetooth: Fix use-after-free bugs caused by sco_sock_timeout
      	Bluetooth: l2cap: fix null-ptr-deref in l2cap_chan_timeout
      	rtnetlink: Correct nested IFLA_VF_VLAN_LIST attribute validation
      	phonet: fix rtm_phonet_notify() skb allocation
      	net: bridge: fix corrupted ethernet header on multicast-to-unicast
      	ipv6: fib6_rules: avoid possible NULL dereference in fib6_rule_action()
      	af_unix: Do not use atomic ops for unix_sk(sk)->inflight.
      	af_unix: Fix garbage collector racing against connect()
      	firewire: nosy: ensure user_length is taken into account when fetching packet contents
      	usb: gadget: composite: fix OS descriptors w_value logic
      	usb: gadget: f_fs: Fix a race condition when processing setup packets.
      	tipc: fix UAF in error path
      	dyndbg: fix old BUG_ON in >control parser
      	drm/vmwgfx: Fix invalid reads in fence signaled events
      	net: fix out-of-bounds access in ops_init
      	af_unix: Suppress false-positive lockdep splat for spin_lock() in __unix_gc().
      	Linux 4.19.314
      
      Change-Id: Iee5ac090f6fe369f9faa89d92ad17b66b8a41bee
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
      65e58a86
    • Greg Kroah-Hartman's avatar
    • Kuniyuki Iwashima's avatar
      af_unix: Suppress false-positive lockdep splat for spin_lock() in __unix_gc(). · b29dcdd0
      Kuniyuki Iwashima authored
      
      commit 1971d13ffa84a551d29a81fdf5b5ec5be166ac83 upstream.
      
      syzbot reported a lockdep splat regarding unix_gc_lock and
      unix_state_lock().
      
      One is called from recvmsg() for a connected socket, and another
      is called from GC for TCP_LISTEN socket.
      
      So, the splat is false-positive.
      
      Let's add a dedicated lock class for the latter to suppress the splat.
      
      Note that this change is not necessary for net-next.git as the issue
      is only applied to the old GC impl.
      
      [0]:
      WARNING: possible circular locking dependency detected
      6.9.0-rc5-syzkaller-00007-g4d2008430ce8 #0 Not tainted
       -----------------------------------------------------
      kworker/u8:1/11 is trying to acquire lock:
      ffff88807cea4e70 (&u->lock){+.+.}-{2:2}, at: spin_lock include/linux/spinlock.h:351 [inline]
      ffff88807cea4e70 (&u->lock){+.+.}-{2:2}, at: __unix_gc+0x40e/0xf70 net/unix/garbage.c:302
      
      but task is already holding lock:
      ffffffff8f6ab638 (unix_gc_lock){+.+.}-{2:2}, at: spin_lock include/linux/spinlock.h:351 [inline]
      ffffffff8f6ab638 (unix_gc_lock){+.+.}-{2:2}, at: __unix_gc+0x117/0xf70 net/unix/garbage.c:261
      
      which lock already depends on the new lock.
      
      the existing dependency chain (in reverse order) is:
      
       -> #1 (unix_gc_lock){+.+.}-{2:2}:
             lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5754
             __raw_spin_lock include/linux/spinlock_api_smp.h:133 [inline]
             _raw_spin_lock+0x2e/0x40 kernel/locking/spinlock.c:154
             spin_lock include/linux/spinlock.h:351 [inline]
             unix_notinflight+0x13d/0x390 net/unix/garbage.c:140
             unix_detach_fds net/unix/af_unix.c:1819 [inline]
             unix_destruct_scm+0x221/0x350 net/unix/af_unix.c:1876
             skb_release_head_state+0x100/0x250 net/core/skbuff.c:1188
             skb_release_all net/core/skbuff.c:1200 [inline]
             __kfree_skb net/core/skbuff.c:1216 [inline]
             kfree_skb_reason+0x16d/0x3b0 net/core/skbuff.c:1252
             kfree_skb include/linux/skbuff.h:1262 [inline]
             manage_oob net/unix/af_unix.c:2672 [inline]
             unix_stream_read_generic+0x1125/0x2700 net/unix/af_unix.c:2749
             unix_stream_splice_read+0x239/0x320 net/unix/af_unix.c:2981
             do_splice_read fs/splice.c:985 [inline]
             splice_file_to_pipe+0x299/0x500 fs/splice.c:1295
             do_splice+0xf2d/0x1880 fs/splice.c:1379
             __do_splice fs/splice.c:1436 [inline]
             __do_sys_splice fs/splice.c:1652 [inline]
             __se_sys_splice+0x331/0x4a0 fs/splice.c:1634
             do_syscall_x64 arch/x86/entry/common.c:52 [inline]
             do_syscall_64+0xf5/0x240 arch/x86/entry/common.c:83
             entry_SYSCALL_64_after_hwframe+0x77/0x7f
      
       -> #0 (&u->lock){+.+.}-{2:2}:
             check_prev_add kernel/locking/lockdep.c:3134 [inline]
             check_prevs_add kernel/locking/lockdep.c:3253 [inline]
             validate_chain+0x18cb/0x58e0 kernel/locking/lockdep.c:3869
             __lock_acquire+0x1346/0x1fd0 kernel/locking/lockdep.c:5137
             lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5754
             __raw_spin_lock include/linux/spinlock_api_smp.h:133 [inline]
             _raw_spin_lock+0x2e/0x40 kernel/locking/spinlock.c:154
             spin_lock include/linux/spinlock.h:351 [inline]
             __unix_gc+0x40e/0xf70 net/unix/garbage.c:302
             process_one_work kernel/workqueue.c:3254 [inline]
             process_scheduled_works+0xa10/0x17c0 kernel/workqueue.c:3335
             worker_thread+0x86d/0xd70 kernel/workqueue.c:3416
             kthread+0x2f0/0x390 kernel/kthread.c:388
             ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
             ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
      
      other info that might help us debug this:
      
       Possible unsafe locking scenario:
      
             CPU0                    CPU1
             ----                    ----
        lock(unix_gc_lock);
                                     lock(&u->lock);
                                     lock(unix_gc_lock);
        lock(&u->lock);
      
       *** DEADLOCK ***
      
      3 locks held by kworker/u8:1/11:
       #0: ffff888015089148 ((wq_completion)events_unbound){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3229 [inline]
       #0: ffff888015089148 ((wq_completion)events_unbound){+.+.}-{0:0}, at: process_scheduled_works+0x8e0/0x17c0 kernel/workqueue.c:3335
       #1: ffffc90000107d00 (unix_gc_work){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3230 [inline]
       #1: ffffc90000107d00 (unix_gc_work){+.+.}-{0:0}, at: process_scheduled_works+0x91b/0x17c0 kernel/workqueue.c:3335
       #2: ffffffff8f6ab638 (unix_gc_lock){+.+.}-{2:2}, at: spin_lock include/linux/spinlock.h:351 [inline]
       #2: ffffffff8f6ab638 (unix_gc_lock){+.+.}-{2:2}, at: __unix_gc+0x117/0xf70 net/unix/garbage.c:261
      
      stack backtrace:
      CPU: 0 PID: 11 Comm: kworker/u8:1 Not tainted 6.9.0-rc5-syzkaller-00007-g4d2008430ce8 #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024
      Workqueue: events_unbound __unix_gc
      Call Trace:
       <TASK>
       __dump_stack lib/dump_stack.c:88 [inline]
       dump_stack_lvl+0x241/0x360 lib/dump_stack.c:114
       check_noncircular+0x36a/0x4a0 kernel/locking/lockdep.c:2187
       check_prev_add kernel/locking/lockdep.c:3134 [inline]
       check_prevs_add kernel/locking/lockdep.c:3253 [inline]
       validate_chain+0x18cb/0x58e0 kernel/locking/lockdep.c:3869
       __lock_acquire+0x1346/0x1fd0 kernel/locking/lockdep.c:5137
       lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5754
       __raw_spin_lock include/linux/spinlock_api_smp.h:133 [inline]
       _raw_spin_lock+0x2e/0x40 kernel/locking/spinlock.c:154
       spin_lock include/linux/spinlock.h:351 [inline]
       __unix_gc+0x40e/0xf70 net/unix/garbage.c:302
       process_one_work kernel/workqueue.c:3254 [inline]
       process_scheduled_works+0xa10/0x17c0 kernel/workqueue.c:3335
       worker_thread+0x86d/0xd70 kernel/workqueue.c:3416
       kthread+0x2f0/0x390 kernel/kthread.c:388
       ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
       ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
       </TASK>
      
      Fixes: 47d8ac011fe1 ("af_unix: Fix garbage collector racing against connect()")
      Reported-and-tested-by: default avatar <syzbot+fa379358c28cc87cc307@syzkaller.appspotmail.com>
      Closes: https://syzkaller.appspot.com/bug?extid=fa379358c28cc87cc307
      
      
      Signed-off-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
      Link: https://lore.kernel.org/r/20240424170443.9832-1-kuniyu@amazon.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b29dcdd0
    • Thadeu Lima de Souza Cascardo's avatar
      net: fix out-of-bounds access in ops_init · 3cdc34d7
      Thadeu Lima de Souza Cascardo authored
      
      commit a26ff37e624d12e28077e5b24d2b264f62764ad6 upstream.
      
      net_alloc_generic is called by net_alloc, which is called without any
      locking. It reads max_gen_ptrs, which is changed under pernet_ops_rwsem. It
      is read twice, first to allocate an array, then to set s.len, which is
      later used to limit the bounds of the array access.
      
      It is possible that the array is allocated and another thread is
      registering a new pernet ops, increments max_gen_ptrs, which is then used
      to set s.len with a larger than allocated length for the variable array.
      
      Fix it by reading max_gen_ptrs only once in net_alloc_generic. If
      max_gen_ptrs is later incremented, it will be caught in net_assign_generic.
      
      Signed-off-by: default avatarThadeu Lima de Souza Cascardo <cascardo@igalia.com>
      Fixes: 073862ba ("netns: fix net_alloc_generic()")
      Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
      Reviewed-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20240502132006.3430840-1-cascardo@igalia.com
      
      
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3cdc34d7
    • Zack Rusin's avatar
      drm/vmwgfx: Fix invalid reads in fence signaled events · 2f527e3e
      Zack Rusin authored
      
      commit a37ef7613c00f2d72c8fc08bd83fb6cc76926c8c upstream.
      
      Correctly set the length of the drm_event to the size of the structure
      that's actually used.
      
      The length of the drm_event was set to the parent structure instead of
      to the drm_vmw_event_fence which is supposed to be read. drm_read
      uses the length parameter to copy the event to the user space thus
      resuling in oob reads.
      
      Signed-off-by: default avatarZack Rusin <zack.rusin@broadcom.com>
      Fixes: 8b7de6aa ("vmwgfx: Rework fence event action")
      Reported-by: zdi-disclosures@trendmicro.com # ZDI-CAN-23566
      Cc: David Airlie <airlied@gmail.com>
      CC: Daniel Vetter <daniel@ffwll.ch>
      Cc: Zack Rusin <zack.rusin@broadcom.com>
      Cc: Broadcom internal kernel review list <bcm-kernel-feedback-list@broadcom.com>
      Cc: dri-devel@lists.freedesktop.org
      Cc: linux-kernel@vger.kernel.org
      Cc: <stable@vger.kernel.org> # v3.4+
      Reviewed-by: default avatarMaaz Mombasawala <maaz.mombasawala@broadcom.com>
      Reviewed-by: default avatarMartin Krastev <martin.krastev@broadcom.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20240425192748.1761522-1-zack.rusin@broadcom.com
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2f527e3e
    • Jim Cromie's avatar
      dyndbg: fix old BUG_ON in >control parser · 3c718bdd
      Jim Cromie authored
      
      commit 00e7d3be upstream.
      
      Fix a BUG_ON from 2009.  Even if it looks "unreachable" (I didn't
      really look), lets make sure by removing it, doing pr_err and return
      -EINVAL instead.
      
      Cc: stable <stable@kernel.org>
      Signed-off-by: default avatarJim Cromie <jim.cromie@gmail.com>
      Link: https://lore.kernel.org/r/20240429193145.66543-2-jim.cromie@gmail.com
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3c718bdd
    • Paolo Abeni's avatar
      tipc: fix UAF in error path · e19ec8ab
      Paolo Abeni authored
      
      commit 080cbb890286cd794f1ee788bbc5463e2deb7c2b upstream.
      
      Sam Page (sam4k) working with Trend Micro Zero Day Initiative reported
      a UAF in the tipc_buf_append() error path:
      
      BUG: KASAN: slab-use-after-free in kfree_skb_list_reason+0x47e/0x4c0
      linux/net/core/skbuff.c:1183
      Read of size 8 at addr ffff88804d2a7c80 by task poc/8034
      
      CPU: 1 PID: 8034 Comm: poc Not tainted 6.8.2 #1
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
      1.16.0-debian-1.16.0-5 04/01/2014
      Call Trace:
       <IRQ>
       __dump_stack linux/lib/dump_stack.c:88
       dump_stack_lvl+0xd9/0x1b0 linux/lib/dump_stack.c:106
       print_address_description linux/mm/kasan/report.c:377
       print_report+0xc4/0x620 linux/mm/kasan/report.c:488
       kasan_report+0xda/0x110 linux/mm/kasan/report.c:601
       kfree_skb_list_reason+0x47e/0x4c0 linux/net/core/skbuff.c:1183
       skb_release_data+0x5af/0x880 linux/net/core/skbuff.c:1026
       skb_release_all linux/net/core/skbuff.c:1094
       __kfree_skb linux/net/core/skbuff.c:1108
       kfree_skb_reason+0x12d/0x210 linux/net/core/skbuff.c:1144
       kfree_skb linux/./include/linux/skbuff.h:1244
       tipc_buf_append+0x425/0xb50 linux/net/tipc/msg.c:186
       tipc_link_input+0x224/0x7c0 linux/net/tipc/link.c:1324
       tipc_link_rcv+0x76e/0x2d70 linux/net/tipc/link.c:1824
       tipc_rcv+0x45f/0x10f0 linux/net/tipc/node.c:2159
       tipc_udp_recv+0x73b/0x8f0 linux/net/tipc/udp_media.c:390
       udp_queue_rcv_one_skb+0xad2/0x1850 linux/net/ipv4/udp.c:2108
       udp_queue_rcv_skb+0x131/0xb00 linux/net/ipv4/udp.c:2186
       udp_unicast_rcv_skb+0x165/0x3b0 linux/net/ipv4/udp.c:2346
       __udp4_lib_rcv+0x2594/0x3400 linux/net/ipv4/udp.c:2422
       ip_protocol_deliver_rcu+0x30c/0x4e0 linux/net/ipv4/ip_input.c:205
       ip_local_deliver_finish+0x2e4/0x520 linux/net/ipv4/ip_input.c:233
       NF_HOOK linux/./include/linux/netfilter.h:314
       NF_HOOK linux/./include/linux/netfilter.h:308
       ip_local_deliver+0x18e/0x1f0 linux/net/ipv4/ip_input.c:254
       dst_input linux/./include/net/dst.h:461
       ip_rcv_finish linux/net/ipv4/ip_input.c:449
       NF_HOOK linux/./include/linux/netfilter.h:314
       NF_HOOK linux/./include/linux/netfilter.h:308
       ip_rcv+0x2c5/0x5d0 linux/net/ipv4/ip_input.c:569
       __netif_receive_skb_one_core+0x199/0x1e0 linux/net/core/dev.c:5534
       __netif_receive_skb+0x1f/0x1c0 linux/net/core/dev.c:5648
       process_backlog+0x101/0x6b0 linux/net/core/dev.c:5976
       __napi_poll.constprop.0+0xba/0x550 linux/net/core/dev.c:6576
       napi_poll linux/net/core/dev.c:6645
       net_rx_action+0x95a/0xe90 linux/net/core/dev.c:6781
       __do_softirq+0x21f/0x8e7 linux/kernel/softirq.c:553
       do_softirq linux/kernel/softirq.c:454
       do_softirq+0xb2/0xf0 linux/kernel/softirq.c:441
       </IRQ>
       <TASK>
       __local_bh_enable_ip+0x100/0x120 linux/kernel/softirq.c:381
       local_bh_enable linux/./include/linux/bottom_half.h:33
       rcu_read_unlock_bh linux/./include/linux/rcupdate.h:851
       __dev_queue_xmit+0x871/0x3ee0 linux/net/core/dev.c:4378
       dev_queue_xmit linux/./include/linux/netdevice.h:3169
       neigh_hh_output linux/./include/net/neighbour.h:526
       neigh_output linux/./include/net/neighbour.h:540
       ip_finish_output2+0x169f/0x2550 linux/net/ipv4/ip_output.c:235
       __ip_finish_output linux/net/ipv4/ip_output.c:313
       __ip_finish_output+0x49e/0x950 linux/net/ipv4/ip_output.c:295
       ip_finish_output+0x31/0x310 linux/net/ipv4/ip_output.c:323
       NF_HOOK_COND linux/./include/linux/netfilter.h:303
       ip_output+0x13b/0x2a0 linux/net/ipv4/ip_output.c:433
       dst_output linux/./include/net/dst.h:451
       ip_local_out linux/net/ipv4/ip_output.c:129
       ip_send_skb+0x3e5/0x560 linux/net/ipv4/ip_output.c:1492
       udp_send_skb+0x73f/0x1530 linux/net/ipv4/udp.c:963
       udp_sendmsg+0x1a36/0x2b40 linux/net/ipv4/udp.c:1250
       inet_sendmsg+0x105/0x140 linux/net/ipv4/af_inet.c:850
       sock_sendmsg_nosec linux/net/socket.c:730
       __sock_sendmsg linux/net/socket.c:745
       __sys_sendto+0x42c/0x4e0 linux/net/socket.c:2191
       __do_sys_sendto linux/net/socket.c:2203
       __se_sys_sendto linux/net/socket.c:2199
       __x64_sys_sendto+0xe0/0x1c0 linux/net/socket.c:2199
       do_syscall_x64 linux/arch/x86/entry/common.c:52
       do_syscall_64+0xd8/0x270 linux/arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x6f/0x77 linux/arch/x86/entry/entry_64.S:120
      RIP: 0033:0x7f3434974f29
      Code: 00 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48
      89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d
      01 f0 ff ff 73 01 c3 48 8b 0d 37 8f 0d 00 f7 d8 64 89 01 48
      RSP: 002b:00007fff9154f2b8 EFLAGS: 00000212 ORIG_RAX: 000000000000002c
      RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f3434974f29
      RDX: 00000000000032c8 RSI: 00007fff9154f300 RDI: 0000000000000003
      RBP: 00007fff915532e0 R08: 00007fff91553360 R09: 0000000000000010
      R10: 0000000000000000 R11: 0000000000000212 R12: 000055ed86d261d0
      R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
       </TASK>
      
      In the critical scenario, either the relevant skb is freed or its
      ownership is transferred into a frag_lists. In both cases, the cleanup
      code must not free it again: we need to clear the skb reference earlier.
      
      Fixes: 1149557d ("tipc: eliminate unnecessary linearization of incoming buffers")
      Cc: stable@vger.kernel.org
      Reported-by: zdi-disclosures@trendmicro.com # ZDI-CAN-23852
      Acked-by: default avatarXin Long <lucien.xin@gmail.com>
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
      Link: https://lore.kernel.org/r/752f1ccf762223d109845365d07f55414058e5a3.1714484273.git.pabeni@redhat.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e19ec8ab
    • Chris Wulff's avatar
      usb: gadget: f_fs: Fix a race condition when processing setup packets. · af3f22e0
      Chris Wulff authored
      
      commit 0aea736ddb877b93f6d2dd8cf439840d6b4970a9 upstream.
      
      If the USB driver passes a pointer into the TRB buffer for creq, this
      buffer can be overwritten with the status response as soon as the event
      is queued. This can make the final check return USB_GADGET_DELAYED_STATUS
      when it shouldn't. Instead use the stored wLength.
      
      Fixes: 4d644abf ("usb: gadget: f_fs: Only return delayed status when len is 0")
      Cc: stable <stable@kernel.org>
      Signed-off-by: default avatarChris Wulff <chris.wulff@biamp.com>
      Link: https://lore.kernel.org/r/CO1PR17MB5419BD664264A558B2395E28E1112@CO1PR17MB5419.namprd17.prod.outlook.com
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      af3f22e0
    • Peter Korsgaard's avatar
      usb: gadget: composite: fix OS descriptors w_value logic · c037e0eb
      Peter Korsgaard authored
      commit ec6ce7075ef879b91a8710829016005dc8170f17 upstream.
      
      The OS descriptors logic had the high/low byte of w_value inverted, causing
      the extended properties to not be accessible for interface != 0.
      
      >From the Microsoft documentation:
      https://learn.microsoft.com/en-us/windows-hardware/drivers/usbcon/microsoft-os-1-0-descriptors-specification
      
      
      
      OS_Desc_CompatID.doc (w_index = 0x4):
      
      - wValue:
      
        High Byte = InterfaceNumber.  InterfaceNumber is set to the number of the
        interface or function that is associated with the descriptor, typically
        0x00.  Because a device can have only one extended compat ID descriptor,
        it should ignore InterfaceNumber, regardless of the value, and simply
        return the descriptor.
      
        Low Byte = 0.  PageNumber is used to retrieve descriptors that are larger
        than 64 KB.  The header section is 16 bytes, so PageNumber is set to 0 for
        this request.
      
      We currently do not support >64KB compat ID descriptors, so verify that the
      low byte is 0.
      
      OS_Desc_Ext_Prop.doc (w_index = 0x5):
      
      - wValue:
      
        High byte = InterfaceNumber.  The high byte of wValue is set to the number
        of the interface or function that is associated with the descriptor.
      
        Low byte = PageNumber.  The low byte of wValue is used to retrieve
        descriptors that are larger than 64 KB.  The header section is 10 bytes, so
        PageNumber is set to 0 for this request.
      
      We also don't support >64KB extended properties, so verify that the low byte
      is 0 and use the high byte for the interface number.
      
      Fixes: 37a3a533 ("usb: gadget: OS Feature Descriptors support")
      Cc: stable <stable@kernel.org>
      Signed-off-by: default avatarPeter Korsgaard <peter@korsgaard.com>
      Link: https://lore.kernel.org/r/20240404100635.3215340-1-peter@korsgaard.com
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c037e0eb
    • Thanassis Avgerinos's avatar
      firewire: nosy: ensure user_length is taken into account when fetching packet contents · 67f34f09
      Thanassis Avgerinos authored
      
      commit 38762a0763c10c24a4915feee722d7aa6e73eb98 upstream.
      
      Ensure that packet_buffer_get respects the user_length provided. If
      the length of the head packet exceeds the user_length, packet_buffer_get
      will now return 0 to signify to the user that no data were read
      and a larger buffer size is required. Helps prevent user space overflows.
      
      Signed-off-by: default avatarThanassis Avgerinos <thanassis.avgerinos@gmail.com>
      Signed-off-by: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      67f34f09
    • Michal Luczaj's avatar
      af_unix: Fix garbage collector racing against connect() · a36ae0ec
      Michal Luczaj authored
      
      [ Upstream commit 47d8ac011fe1c9251070e1bd64cb10b48193ec51 ]
      
      Garbage collector does not take into account the risk of embryo getting
      enqueued during the garbage collection. If such embryo has a peer that
      carries SCM_RIGHTS, two consecutive passes of scan_children() may see a
      different set of children. Leading to an incorrectly elevated inflight
      count, and then a dangling pointer within the gc_inflight_list.
      
      sockets are AF_UNIX/SOCK_STREAM
      S is an unconnected socket
      L is a listening in-flight socket bound to addr, not in fdtable
      V's fd will be passed via sendmsg(), gets inflight count bumped
      
      connect(S, addr)	sendmsg(S, [V]); close(V)	__unix_gc()
      ----------------	-------------------------	-----------
      
      NS = unix_create1()
      skb1 = sock_wmalloc(NS)
      L = unix_find_other(addr)
      unix_state_lock(L)
      unix_peer(S) = NS
      			// V count=1 inflight=0
      
       			NS = unix_peer(S)
       			skb2 = sock_alloc()
      			skb_queue_tail(NS, skb2[V])
      
      			// V became in-flight
      			// V count=2 inflight=1
      
      			close(V)
      
      			// V count=1 inflight=1
      			// GC candidate condition met
      
      						for u in gc_inflight_list:
      						  if (total_refs == inflight_refs)
      						    add u to gc_candidates
      
      						// gc_candidates={L, V}
      
      						for u in gc_candidates:
      						  scan_children(u, dec_inflight)
      
      						// embryo (skb1) was not
      						// reachable from L yet, so V's
      						// inflight remains unchanged
      __skb_queue_tail(L, skb1)
      unix_state_unlock(L)
      						for u in gc_candidates:
      						  if (u.inflight)
      						    scan_children(u, inc_inflight_move_tail)
      
      						// V count=1 inflight=2 (!)
      
      If there is a GC-candidate listening socket, lock/unlock its state. This
      makes GC wait until the end of any ongoing connect() to that socket. After
      flipping the lock, a possibly SCM-laden embryo is already enqueued. And if
      there is another embryo coming, it can not possibly carry SCM_RIGHTS. At
      this point, unix_inflight() can not happen because unix_gc_lock is already
      taken. Inflight graph remains unaffected.
      
      Fixes: 1fd05ba5 ("[AF_UNIX]: Rewrite garbage collector, fixes race.")
      Signed-off-by: default avatarMichal Luczaj <mhal@rbox.co>
      Reviewed-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
      Link: https://lore.kernel.org/r/20240409201047.1032217-1-mhal@rbox.co
      
      
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a36ae0ec
Loading