Commit Graph

964415 Commits

Author SHA1 Message Date
Luiz Augusto von Dentz
098e07ef00 Bluetooth: L2CAP: Fix use-after-free caused by l2cap_chan_put
commit d0be8347c623e0ac4202a1d4e0373882821f56b0 upstream.

This fixes the following trace which is caused by hci_rx_work starting up
*after* the final channel reference has been put() during sock_close() but
*before* the references to the channel have been destroyed, so instead
the code now rely on kref_get_unless_zero/l2cap_chan_hold_unless_zero to
prevent referencing a channel that is about to be destroyed.

  refcount_t: increment on 0; use-after-free.
  BUG: KASAN: use-after-free in refcount_dec_and_test+0x20/0xd0
  Read of size 4 at addr ffffffc114f5bf18 by task kworker/u17:14/705

  CPU: 4 PID: 705 Comm: kworker/u17:14 Tainted: G S      W
  4.14.234-00003-g1fb6d0bd49a4-dirty #28
  Hardware name: Qualcomm Technologies, Inc. SM8150 V2 PM8150
  Google Inc. MSM sm8150 Flame DVT (DT)
  Workqueue: hci0 hci_rx_work
  Call trace:
   dump_backtrace+0x0/0x378
   show_stack+0x20/0x2c
   dump_stack+0x124/0x148
   print_address_description+0x80/0x2e8
   __kasan_report+0x168/0x188
   kasan_report+0x10/0x18
   __asan_load4+0x84/0x8c
   refcount_dec_and_test+0x20/0xd0
   l2cap_chan_put+0x48/0x12c
   l2cap_recv_frame+0x4770/0x6550
   l2cap_recv_acldata+0x44c/0x7a4
   hci_acldata_packet+0x100/0x188
   hci_rx_work+0x178/0x23c
   process_one_work+0x35c/0x95c
   worker_thread+0x4cc/0x960
   kthread+0x1a8/0x1c4
   ret_from_fork+0x10/0x18

Cc: stable@kernel.org
Reported-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Tested-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-08-03 11:59:37 +02:00
Kai Xing
7015ffdd0b disp: msm: add msm framebuffer emulation
This change copies msm_fbdev.c from msm-5.14 kernel, which adds
frame buffer support to display driver. And this file is from
msm-5.4 commit <5fce077d> ("drm: msm: Fix the format prints in
display driver").

Change-Id: I113cb6441334ff6b61cfd15cf863c325d51091b4
Signed-off-by: Kai Xing <quic_kxing@quicinc.com>
2022-08-03 15:06:14 +05:30
Vulupala Shashank Reddy
796e14de23 qcacmn: Update dp_get_pdev_param for Channel and frequency
Add provision to get channel and frequency from pdev.

Change-Id: I73f291ebf1517f7f2885853d43b873cfdbd86a93
CRs-Fixed: 3248485
2022-08-03 14:25:41 +05:30
Surabhi Vishnoi
f502b47633 qcacld-3.0: Allow monitor mode vendor cmd only if mon iface is created
QCA_NL80211_VENDOR_SUBCMD_SET_MONITOR_MODE is used to set the
config for packet capture feature on STA interface.
Currently this vendor command is allowed even if monitor interface
which will be used in packet capture mode is not created, which is
wrong.

To fix this, allow monitor mode config related to packet capture
feature only if monitor interface is created.

Change-Id: Iea94b4cd5f21d8ce13643c209d4027972d7a16d3
CRs-Fixed: 3256298
2022-08-03 14:00:44 +05:30
Yash Upadhyay
336163ddec msm: camera: memmgr: Avoid TOCTOU buffer access on multiple use of same fd
Fd is a user-accessible value, referring it multiple times
leads to TOCTOU issues. Dma_buf can be freed after the 1st
use of fd and userspace can create another dma_buf but with
same fd. In such scenario, during 2nd use of fd, we may get
a different dma_buf with different length. To avoid this, we
can use same dma_buf instead of retrieving it twice using same
fd. In this change FD is accessed only once in syscall.

CRs-Fixed: 3159446
Change-Id: I00eb6dd3d798165f5c6c0bd59feabe80a68592b1
Signed-off-by: Yash Upadhyay <quic_yupadhya@quicinc.com>
2022-08-03 10:04:47 +05:30
Rohith Kollalsi
1be4ae7011 usb: gadget: cdev: Requeue the request in cser_resume if start_rx fails
Consider a case where dut enters suspend before port_bridge is started.
In that case, ep_queue in start_rx function fails as dut is in suspend
mode. The expectation is that when host resumes the DUT, the request
must be requeued in cser_resume as ep_queue of start_rx which was
called earlier was a failure.

Change-Id: I87015f00267af20450d625e2ea7a19a9de45c79a
Signed-off-by: Rohith Kollalsi <quic_rkollals@quicinc.com>
2022-08-02 21:28:28 -07:00
qctecmdr
4ba8167c03 Merge "msm: ep_pcie: Avoid polling for ltssm state if perst is asserted" 2022-08-02 15:29:39 -07:00
Carlos Llamas
458b37a82d FROMLIST: binder: fix UAF of ref->proc caused by race condition
A transaction of type BINDER_TYPE_WEAK_HANDLE can fail to increment the
reference for a node. In this case, the target proc normally releases
the failed reference upon close as expected. However, if the target is
dying in parallel the call will race with binder_deferred_release(), so
the target could have released all of its references by now leaving the
cleanup of the new failed reference unhandled.

The transaction then ends and the target proc gets released making the
ref->proc now a dangling pointer. Later on, ref->node is closed and we
attempt to take spin_lock(&ref->proc->inner_lock), which leads to the
use-after-free bug reported below. Let's fix this by cleaning up the
failed reference on the spot instead of relying on the target to do so.

  ==================================================================
  BUG: KASAN: use-after-free in _raw_spin_lock+0xa8/0x150
  Write of size 4 at addr ffff5ca207094238 by task kworker/1:0/590

  CPU: 1 PID: 590 Comm: kworker/1:0 Not tainted 5.19.0-rc8 #10
  Hardware name: linux,dummy-virt (DT)
  Workqueue: events binder_deferred_func
  Call trace:
   dump_backtrace.part.0+0x1d0/0x1e0
   show_stack+0x18/0x70
   dump_stack_lvl+0x68/0x84
   print_report+0x2e4/0x61c
   kasan_report+0xa4/0x110
   kasan_check_range+0xfc/0x1a4
   __kasan_check_write+0x3c/0x50
   _raw_spin_lock+0xa8/0x150
   binder_deferred_func+0x5e0/0x9b0
   process_one_work+0x38c/0x5f0
   worker_thread+0x9c/0x694
   kthread+0x188/0x190
   ret_from_fork+0x10/0x20

Signed-off-by: Carlos Llamas <cmllamas@google.com>
Acked-by: Christian Brauner (Microsoft) <brauner@kernel.org>

Bug: 239630375
Link: https://lore.kernel.org/all/20220801182511.3371447-1-cmllamas@google.com/
Signed-off-by: Carlos Llamas <cmllamas@google.com>
Change-Id: I5085dd0dc805a780a64c057e5819f82dd8f02868
(cherry picked from commit ae3fa5d16a02ba7c7b170e0e1ab56d6f0ba33964)
2022-08-02 22:15:29 +00:00
Sai Chaitanya Kaveti
b2b584fee2 msm: ep_pcie: Avoid polling for ltssm state if perst is asserted
Device polls for ltssm state by reading PCIE status register as part
of ep_pcie_core_enable_endpoint. If it receives a perst assertion
event during polling, device completes polling and then handles perst
assertion with the existing logic. But polling for ltssm state is not
necessary here as the L0 link state is not possible after perst
assertion. This delays the handling of perst assertion and subsequent
perst deaasertion events.

To avoid this delay, avoiding polling for ltssm state if perst is
asserted. Added check for perst during polling of ltssm state and
breaking the loop if perst is asserted.

Change-Id: I38dc82070749751cfd14661ac95eb95eb8dcb665
Signed-off-by: Sai Chaitanya Kaveti <quic_skaveti@quicinc.com>
2022-08-02 06:31:01 -07:00
spuligil
de88a134d9 fw-api: CL 19047183 - update fw common interface files
Change-Id: I8d1e875c7833b710f4683859295c37e98bd059e0
WMI: add IPA_LINK_STATS_EVENT msg def
CRs-Fixed: 2262693
2022-08-02 06:01:53 -07:00
Vijayanand Jitta
3a4f3d2090 mem_buf: Validate n_acl_entries
Validate n_acl_entries specified by the requesting VM.

Limiting n_acl_entries to 1 for now based on the existing check in
mem_buf_alloc().

Change-Id: I802219ada9ee9109d18a42b2a80539d1cbd4df64
Signed-off-by: Vijayanand Jitta <quic_vjitta@quicinc.com>
2022-08-02 04:13:35 -07:00
qctecmdr
46ca04c77a Merge "i2c: i2c-msm-geni: NULL check before accessing i2c message" 2022-08-01 23:53:34 -07:00
Jing Wang
50e0fe7b19 dsp: dyn mclk support enable/disable in afe_set_lpass_clock_v2
dyn mclk support enable/disable in afe_set_lpass_clock_v2

Change-Id: Idb793961135ddc2bcdefe2c8367abce93a4ce164
Signed-off-by: Jing Wang <quic_jingwa@quicinc.com>
2022-08-01 19:30:48 -07:00
Madan Koyyalamudi
be6039dd5a Release 2.0.8.30Z
Release 2.0.8.30Z

Change-Id: I82cf6425475eacae538eddf6ba26c79e8b96fd17
CRs-Fixed: 774533
2022-08-01 19:28:52 -07:00
qctecmdr
11efa8f35a Merge "msm: ipa: Add easymesh R2 support in header" 2022-08-01 13:51:01 -07:00
Priyansh Jain
e186eb0c0c drivers: thermal: Dynamic cpu's support in cpu voltage cooling driver
Add support for dynamic cpu's in cpu voltage cooling driver.

Change-Id: Id8dd7800d230e657c16d853da673cb5e9aaf3ca6
Signed-off-by: Priyansh Jain <quic_priyjain@quicinc.com>
2022-08-01 05:23:22 -07:00
spuligil
d3a23e19f1 fw-api: CL 19029549 - update fw common interface files
Change-Id: Ia83641174e04f0f7976349f32963bc78489ee54e
WMI: add PEER_TX_FILTER_ACTION ADD_AND_ENABLE,REMOVE_AND_CLEAR defs
CRs-Fixed: 2262693
2022-08-01 04:09:14 -07:00
spuligil
723e99ec1b fw-api: CL 19024619 - update fw common interface files
HTT stats: add ODD mandatory stats TLV

Change-Id: I873737a44ed5fe1d1a2ce7bd0f825e438e8d7564
CRs-Fixed: 2262693
2022-08-01 04:09:12 -07:00
spuligil
cc393b5f3a fw-api: CL 19024615 - update fw common interface files
Change-Id: I396174aec29466bb5bc6a0af53135c1a535dad0d
WMI: add mac_tsf_id field in vdev_start_resp, roam_sync evt msgs
CRs-Fixed: 2262693
2022-08-01 04:09:10 -07:00
spuligil
4e6bebbfad fw-api: CL 19010813 - update fw common interface files
add WMI_SCAN_FLAG_EXT_INCL_MLIE_PRB_REQ def

Change-Id: Ic916be9699521ab5300853155e1802d17a94ab70
CRs-Fixed: 2262693
2022-08-01 04:09:07 -07:00
spuligil
895e5c4f8b fw-api: CL 18998456 - update fw common interface files
Change-Id: I7d63dc33fa1bd418d3ba35662276186e4f6e0d4e
WMI: add UL_MU_MIMO target capability flags
CRs-Fixed: 2262693
2022-08-01 04:09:04 -07:00
spuligil
9fb276fa24 fw-api: CL 18987039 - update fw common interface files
Change-Id: I10e6ed238c9010e6dd8711dfd92d71dd55f9eb54
WMI: add var arg to WMI_GET_BITS_FROM_ARRAY_LEN32_BYTES macro calls
CRs-Fixed: 2262693
2022-08-01 04:09:02 -07:00
spuligil
7f9ac2aeec fw-api: CL 18966584 - update fw common interface files
Change-Id: I4f72a06855e2bce2970cbfe432c8a7fcfe20dd9b
WMI: add medium-synchronization fields to peer_assoc_mlo_params TLV
CRs-Fixed: 2262693
2022-08-01 04:09:00 -07:00
spuligil
e49bf29d92 fw-api: CL 18946469 - update fw common interface files
add WMI_CONTROL_DBR_SVC service ID

Change-Id: I5112bdf8a02206321363d3c6e62c14ece580bb33
CRs-Fixed: 2262693
2022-08-01 04:08:59 -07:00
spuligil
2b8d399bbe fw-api: CL 18946444 - update fw common interface files
add WMI_SPECTRAL_SCAN_MAX_MODE def

Change-Id: I3bd4f42cac387788b936dc60053a096e13bde8a9
CRs-Fixed: 2262693
2022-08-01 04:08:57 -07:00
spuligil
53bc77df59 fw-api: CL 18916860 - update fw common interface files
add WMI_VDEV_PARAM_VDEVID_UPDATE def

Change-Id: I80000acc596777302b8b6d64e6da93d613f0f2ad
CRs-Fixed: 2262693
2022-08-01 04:08:55 -07:00
Kai Xing
29a7eac491 makefile: add gki config support for display techpack for kona
Add required changes to makefile and enable the gki
config keys for kona target compilation.

Change-Id: I39422750ac6000078278ddc7705e7148f6b0ae6b
Signed-off-by: Kai Xing <quic_kxing@quicinc.com>
2022-08-01 14:04:31 +05:30
Greg Kroah-Hartman
5b72a540b0 ANDROID: restore some removed refcount functions
Due to the refcount functions being cleaned up and majorly simplified in
5.4.208, a number of previously exported functions that were part of
inline functions were removed and the real functions used instead.  As
those were part of the Android ABI, restore functions for these
"checked" refcount abis so that existing code continues to build
properly, while anything that is rebuilt, will be able to take advantage
of the new inline functions instead.

The functions restored are:
	refcount_inc_checked
	refcount_inc_not_zero_checked
	refcount_dec_checked
	refcount_dec_and_test_checked

Bug: 161946584
Fixes: d0d583484d ("locking/refcount: Consolidate implementations of refcount_t")
Cc: Will Deacon <willdeacon@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Ic080315ac173da8b374e0e5f2394cf2b6c1c109c
2022-07-30 15:19:41 +02:00
Greg Kroah-Hartman
380aec8a64 ANDROID: add tty_schedule_flip() back to the kernel
Commit 2ea77b0b6d ("tty: drop tty_schedule_flip()") removed
tty_schedule_flip() as all in-kernel users were properly converted over
to use tty_flip_buffer_push(), but this function still needs to be here
for older out-of-tree Android-only drivers to preserve the ABI.

So provide a wrapper function for it to keep them alive for now.

Bug: 161946584
Fixes: 2ea77b0b6d ("tty: drop tty_schedule_flip()")
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I8893f07cf68bc3502ac6f0f7f0a26b0eec3726a2
2022-07-30 14:34:42 +02:00
Greg Kroah-Hartman
b1e3be07f2 This is the 5.4.208 stable release
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEZH8oZUiU471FcZm+ONu9yGCSaT4FAmLj+VAACgkQONu9yGCS
 aT4kpQ//YdoyxUW1lOvPk9PIRm67ZADUXUwKKTTTO9hvOt886YkOaYghZj+nfTQ/
 SKsEFCh+jKRSG2bvnwUBh/sTTBBwUZeMpvfZZl2polhQT6JhJbBOt9+P/5enXN1O
 9grqt2i2QWA4+l52vnDAA7v5UD+td310GiyKmxiKqzAGaVte29kNLPwujZJM7J+Y
 8PUMI9gGEI8skCtjz7VsSIdvqB+p4B67iNnrDRKubOVUlXdr9f8xKj02DbiQxcnR
 TWc1+h7GIjD/Uibsne+pxAi90/V9A3RsNviZ7U3Igf3kCQ+HS7RH4hcSlU0v6GKy
 HDQrr/BHhGtPFtVCR0HJLbHVYmp/J+7H8V7LFY2mTd0lfkT1q58NRfUuGgRmDETI
 Ug3Dx8uxtUHgBPD1hsbyoSo0nYnleoCQZV+DFWTOF26nb1/85fyC+16U6uvagNw5
 Cdpt8ZVW9/qD8WnxnOuP6yvqw4MFZ0pFyhdQxxsyZpBj2sp5gLz6wRKLgUJX3a8q
 hrbWuR17cg+EA86EKZHxa5y4Wzv02FvljfTD60KvXqY67L4iPzrZWDV+ql9FVm/0
 wEYTLCjfDgDG9iY1e7Ns8ajD6KsBGfs0zO0vUFU4/LmX+EsJzJhfJ3c3zJhwrnDA
 ys2N1tvuSoef/4+JKhVfuxuGGl+mFdT+2yzKYCv3g16sX1OVcbA=
 =UvEH
 -----END PGP SIGNATURE-----

Merge 5.4.208 into android11-5.4-lts

Changes in 5.4.208
	pinctrl: stm32: fix optional IRQ support to gpios
	riscv: add as-options for modules with assembly compontents
	mlxsw: spectrum_router: Fix IPv4 nexthop gateway indication
	lockdown: Fix kexec lockdown bypass with ima policy
	xen/gntdev: Ignore failure to unmap INVALID_GRANT_HANDLE
	PCI: hv: Fix multi-MSI to allow more than one MSI vector
	PCI: hv: Fix hv_arch_irq_unmask() for multi-MSI
	PCI: hv: Reuse existing IRTE allocation in compose_msi_msg()
	PCI: hv: Fix interrupt mapping for multi-MSI
	serial: mvebu-uart: correctly report configured baudrate value
	xfrm: xfrm_policy: fix a possible double xfrm_pols_put() in xfrm_bundle_lookup()
	power/reset: arm-versatile: Fix refcount leak in versatile_reboot_probe
	pinctrl: ralink: Check for null return of devm_kcalloc
	perf/core: Fix data race between perf_event_set_output() and perf_mmap_close()
	igc: Reinstate IGC_REMOVED logic and implement it properly
	ip: Fix data-races around sysctl_ip_no_pmtu_disc.
	ip: Fix data-races around sysctl_ip_fwd_use_pmtu.
	ip: Fix data-races around sysctl_ip_nonlocal_bind.
	ip: Fix a data-race around sysctl_fwmark_reflect.
	tcp/dccp: Fix a data-race around sysctl_tcp_fwmark_accept.
	tcp: Fix data-races around sysctl_tcp_mtu_probing.
	tcp: Fix data-races around sysctl_tcp_base_mss.
	tcp: Fix data-races around sysctl_tcp_min_snd_mss.
	tcp: Fix a data-race around sysctl_tcp_mtu_probe_floor.
	tcp: Fix a data-race around sysctl_tcp_probe_threshold.
	tcp: Fix a data-race around sysctl_tcp_probe_interval.
	i2c: cadence: Change large transfer count reset logic to be unconditional
	net: stmmac: fix dma queue left shift overflow issue
	net/tls: Fix race in TLS device down flow
	igmp: Fix data-races around sysctl_igmp_llm_reports.
	igmp: Fix a data-race around sysctl_igmp_max_memberships.
	tcp: Fix data-races around sysctl_tcp_syncookies.
	tcp: Fix data-races around sysctl_tcp_reordering.
	tcp: Fix data-races around some timeout sysctl knobs.
	tcp: Fix a data-race around sysctl_tcp_notsent_lowat.
	tcp: Fix a data-race around sysctl_tcp_tw_reuse.
	tcp: Fix data-races around sysctl_max_syn_backlog.
	tcp: Fix data-races around sysctl_tcp_fastopen.
	iavf: Fix handling of dummy receive descriptors
	i40e: Fix erroneous adapter reinitialization during recovery process
	ixgbe: Add locking to prevent panic when setting sriov_numvfs to zero
	gpio: pca953x: only use single read/write for No AI mode
	be2net: Fix buffer overflow in be_get_module_eeprom
	ipv4: Fix a data-race around sysctl_fib_multipath_use_neigh.
	udp: Fix a data-race around sysctl_udp_l3mdev_accept.
	tcp: Fix data-races around sysctl knobs related to SYN option.
	tcp: Fix a data-race around sysctl_tcp_early_retrans.
	tcp: Fix data-races around sysctl_tcp_recovery.
	tcp: Fix a data-race around sysctl_tcp_thin_linear_timeouts.
	tcp: Fix data-races around sysctl_tcp_slow_start_after_idle.
	tcp: Fix a data-race around sysctl_tcp_retrans_collapse.
	tcp: Fix a data-race around sysctl_tcp_stdurg.
	tcp: Fix a data-race around sysctl_tcp_rfc1337.
	tcp: Fix data-races around sysctl_tcp_max_reordering.
	spi: bcm2835: bcm2835_spi_handle_err(): fix NULL pointer deref for non DMA transfers
	mm/mempolicy: fix uninit-value in mpol_rebind_policy()
	bpf: Make sure mac_header was set before using it
	dlm: fix pending remove if msg allocation fails
	ima: remove the IMA_TEMPLATE Kconfig option
	locking/refcount: Define constants for saturation and max refcount values
	locking/refcount: Ensure integer operands are treated as signed
	locking/refcount: Remove unused refcount_*_checked() variants
	locking/refcount: Move the bulk of the REFCOUNT_FULL implementation into the <linux/refcount.h> header
	locking/refcount: Improve performance of generic REFCOUNT_FULL code
	locking/refcount: Move saturation warnings out of line
	locking/refcount: Consolidate REFCOUNT_{MAX,SATURATED} definitions
	locking/refcount: Consolidate implementations of refcount_t
	x86: get rid of small constant size cases in raw_copy_{to,from}_user()
	x86/uaccess: Implement macros for CMPXCHG on user addresses
	mmap locking API: initial implementation as rwsem wrappers
	x86/mce: Deduplicate exception handling
	bitfield.h: Fix "type of reg too small for mask" test
	ALSA: memalloc: Align buffer allocations in page size
	Bluetooth: Add bt_skb_sendmsg helper
	Bluetooth: Add bt_skb_sendmmsg helper
	Bluetooth: SCO: Replace use of memcpy_from_msg with bt_skb_sendmsg
	Bluetooth: RFCOMM: Replace use of memcpy_from_msg with bt_skb_sendmmsg
	Bluetooth: Fix passing NULL to PTR_ERR
	Bluetooth: SCO: Fix sco_send_frame returning skb->len
	Bluetooth: Fix bt_skb_sendmmsg not allocating partial chunks
	tty: drivers/tty/, stop using tty_schedule_flip()
	tty: the rest, stop using tty_schedule_flip()
	tty: drop tty_schedule_flip()
	tty: extract tty_flip_buffer_commit() from tty_flip_buffer_push()
	tty: use new tty_insert_flip_string_and_push_buffer() in pty_write()
	net: usb: ax88179_178a needs FLAG_SEND_ZLP
	x86: drop bogus "cc" clobber from __try_cmpxchg_user_asm()
	Linux 5.4.208

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Ia53caf9bc847b0bb332a5b14972142d46ae5a740
2022-07-30 14:33:25 +02:00
Greg Kroah-Hartman
77ba2b9b46 Linux 5.4.208
Link: https://lore.kernel.org/r/20220727161008.993711844@linuxfoundation.org
Tested-by: Florian Fainelli <f.fainelli@gmail.com>
Tested-by: Linux Kernel Functional Testing <lkft@linaro.org>
Tested-by: Jon Hunter <jonathanh@nvidia.com>
Tested-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
Tested-by: Shuah Khan <skhan@linuxfoundation.org>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-29 17:14:20 +02:00
Jan Beulich
ca5762c589 x86: drop bogus "cc" clobber from __try_cmpxchg_user_asm()
commit 1df931d95f4dc1c11db1123e85d4e08156e46ef9 upstream.

As noted (and fixed) a couple of times in the past, "=@cc<cond>" outputs
and clobbering of "cc" don't work well together. The compiler appears to
mean to reject such, but doesn't - in its upstream form - quite manage
to yet for "cc". Furthermore two similar macros don't clobber "cc", and
clobbering "cc" is pointless in asm()-s for x86 anyway - the compiler
always assumes status flags to be clobbered there.

Fixes: 989b5db215a2 ("x86/uaccess: Implement macros for CMPXCHG on user addresses")
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Message-Id: <485c0c0b-a3a7-0b7c-5264-7d00c01de032@suse.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-29 17:14:20 +02:00
Jose Alonso
f88d8c1882 net: usb: ax88179_178a needs FLAG_SEND_ZLP
commit 36a15e1cb134c0395261ba1940762703f778438c upstream.

The extra byte inserted by usbnet.c when
 (length % dev->maxpacket == 0) is causing problems to device.

This patch sets FLAG_SEND_ZLP to avoid this.

Tested with: 0b95:1790 ASIX Electronics Corp. AX88179 Gigabit Ethernet

Problems observed:
======================================================================
1) Using ssh/sshfs. The remote sshd daemon can abort with the message:
   "message authentication code incorrect"
   This happens because the tcp message sent is corrupted during the
   USB "Bulk out". The device calculate the tcp checksum and send a
   valid tcp message to the remote sshd. Then the encryption detects
   the error and aborts.
2) NETDEV WATCHDOG: ... (ax88179_178a): transmit queue 0 timed out
3) Stop normal work without any log message.
   The "Bulk in" continue receiving packets normally.
   The host sends "Bulk out" and the device responds with -ECONNRESET.
   (The netusb.c code tx_complete ignore -ECONNRESET)
Under normal conditions these errors take days to happen and in
intense usage take hours.

A test with ping gives packet loss, showing that something is wrong:
ping -4 -s 462 {destination}	# 462 = 512 - 42 - 8
Not all packets fail.
My guess is that the device tries to find another packet starting
at the extra byte and will fail or not depending on the next
bytes (old buffer content).
======================================================================

Signed-off-by: Jose Alonso <joalonsof@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-29 17:14:20 +02:00
Jiri Slaby
f7785092cb tty: use new tty_insert_flip_string_and_push_buffer() in pty_write()
commit a501ab75e7624d133a5a3c7ec010687c8b961d23 upstream.

There is a race in pty_write(). pty_write() can be called in parallel
with e.g. ioctl(TIOCSTI) or ioctl(TCXONC) which also inserts chars to
the buffer. Provided, tty_flip_buffer_push() in pty_write() is called
outside the lock, it can commit inconsistent tail. This can lead to out
of bounds writes and other issues. See the Link below.

To fix this, we have to introduce a new helper called
tty_insert_flip_string_and_push_buffer(). It does both
tty_insert_flip_string() and tty_flip_buffer_commit() under the port
lock. It also calls queue_work(), but outside the lock. See
71a174b39f10 (pty: do tty_flip_buffer_push without port->lock in
pty_write) for the reasons.

Keep the helper internal-only (in drivers' tty.h). It is not intended to
be used widely.

Link: https://seclists.org/oss-sec/2022/q2/155
Fixes: 71a174b39f10 (pty: do tty_flip_buffer_push without port->lock in pty_write)
Cc: 一只狗 <chennbnbnb@gmail.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Suggested-by: Hillf Danton <hdanton@sina.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20220707082558.9250-2-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-29 17:14:20 +02:00
Jiri Slaby
815d936e92 tty: extract tty_flip_buffer_commit() from tty_flip_buffer_push()
commit 716b10580283fda66f2b88140e3964f8a7f9da89 upstream.

We will need this new helper in the next patch.

Cc: Hillf Danton <hdanton@sina.com>
Cc: 一只狗 <chennbnbnb@gmail.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20220707082558.9250-1-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-29 17:14:19 +02:00
Jiri Slaby
2ea77b0b6d tty: drop tty_schedule_flip()
commit 5db96ef23bda6c2a61a51693c85b78b52d03f654 upstream.

Since commit a9c3f68f3c (tty: Fix low_latency BUG) in 2014,
tty_flip_buffer_push() is only a wrapper to tty_schedule_flip(). All
users were converted in the previous patches, so remove
tty_schedule_flip() completely while inlining its body into
tty_flip_buffer_push().

One less exported function.

Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20211122111648.30379-4-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-29 17:14:19 +02:00
Jiri Slaby
f20912215c tty: the rest, stop using tty_schedule_flip()
commit b68b914494df4f79b4e9b58953110574af1cb7a2 upstream.

Since commit a9c3f68f3c (tty: Fix low_latency BUG) in 2014,
tty_flip_buffer_push() is only a wrapper to tty_schedule_flip(). We are
going to remove the latter (as it is used less), so call the former in
the rest of the users.

Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: William Hubbs <w.d.hubbs@gmail.com>
Cc: Chris Brannon <chris@the-brannons.com>
Cc: Kirk Reiser <kirk@reisers.ca>
Cc: Samuel Thibault <samuel.thibault@ens-lyon.org>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20211122111648.30379-3-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-29 17:14:19 +02:00
Jiri Slaby
aa60c0cce8 tty: drivers/tty/, stop using tty_schedule_flip()
commit 5f6a85158ccacc3f09744b3aafe8b11ab3b6c6f6 upstream.

Since commit a9c3f68f3c (tty: Fix low_latency BUG) in 2014,
tty_flip_buffer_push() is only a wrapper to tty_schedule_flip(). We are
going to remove the latter (as it is used less), so call the former in
drivers/tty/.

Cc: Vladimir Zapolskiy <vz@mleia.com>
Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20211122111648.30379-2-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-29 17:14:19 +02:00
Luiz Augusto von Dentz
126137a53d Bluetooth: Fix bt_skb_sendmmsg not allocating partial chunks
commit 29fb608396d6a62c1b85acc421ad7a4399085b9f upstream.

Since bt_skb_sendmmsg can be used with the likes of SOCK_STREAM it
shall return the partial chunks it could allocate instead of freeing
everything as otherwise it can cause problems like bellow.

Fixes: 81be03e026dc ("Bluetooth: RFCOMM: Replace use of memcpy_from_msg with bt_skb_sendmmsg")
Reported-by: Paul Menzel <pmenzel@molgen.mpg.de>
Link: https://lore.kernel.org/r/d7206e12-1b99-c3be-84f4-df22af427ef5@molgen.mpg.de
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=215594
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Tested-by: Paul Menzel <pmenzel@molgen.mpg.de> (Nokia N9 (MeeGo/Harmattan)
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Cc: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-29 17:14:19 +02:00
Luiz Augusto von Dentz
836b47e643 Bluetooth: SCO: Fix sco_send_frame returning skb->len
commit 037ce005af6b8a3e40ee07c6e9266c8997e6a4d6 upstream.

The skb in modified by hci_send_sco which pushes SCO headers thus
changing skb->len causing sco_sock_sendmsg to fail.

Fixes: 0771cbb3b97d ("Bluetooth: SCO: Replace use of memcpy_from_msg with bt_skb_sendmsg")
Tested-by: Tedd Ho-Jeong An <tedd.an@intel.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Cc: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-29 17:14:19 +02:00
Luiz Augusto von Dentz
aa2d34cab3 Bluetooth: Fix passing NULL to PTR_ERR
commit 266191aa8d14b84958aaeb5e96ee4e97839e3d87 upstream.

Passing NULL to PTR_ERR will result in 0 (success), also since the likes of
bt_skb_sendmsg does never return NULL it is safe to replace the instances of
IS_ERR_OR_NULL with IS_ERR when checking its return.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Tested-by: Tedd Ho-Jeong An <tedd.an@intel.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Cc: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-29 17:14:19 +02:00
Luiz Augusto von Dentz
10bacb8917 Bluetooth: RFCOMM: Replace use of memcpy_from_msg with bt_skb_sendmmsg
commit 81be03e026dc0c16dc1c64e088b2a53b73caa895 upstream.

This makes use of bt_skb_sendmmsg instead using memcpy_from_msg which
is not considered safe to be used when lock_sock is held.

Also make rfcomm_dlc_send handle skb with fragments and queue them all
atomically.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Cc: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-29 17:14:19 +02:00
Luiz Augusto von Dentz
bf46574d46 Bluetooth: SCO: Replace use of memcpy_from_msg with bt_skb_sendmsg
commit 0771cbb3b97d3c1d68eecd7f00055f599954c34e upstream.

This makes use of bt_skb_sendmsg instead of allocating a different
buffer to be used with memcpy_from_msg which cause one extra copy.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Cc: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-29 17:14:18 +02:00
Luiz Augusto von Dentz
f00b06003b Bluetooth: Add bt_skb_sendmmsg helper
commit 97e4e80299844bb5f6ce5a7540742ffbffae3d97 upstream.

This works similarly to bt_skb_sendmsg but can split the msg into
multiple skb fragments which is useful for stream sockets.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Cc: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-29 17:14:18 +02:00
Luiz Augusto von Dentz
55bf99849b Bluetooth: Add bt_skb_sendmsg helper
commit 38f64f650dc0e44c146ff88d15a7339efa325918 upstream.

bt_skb_sendmsg helps takes care of allocation the skb and copying the
the contents of msg over to the skb while checking for possible errors
so it should be safe to call it without holding lock_sock.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Cc: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-29 17:14:18 +02:00
Takashi Iwai
015af30d37 ALSA: memalloc: Align buffer allocations in page size
commit 5c1733e33c888a3cb7f576564d8ad543d5ad4a9e upstream.

Currently the standard memory allocator (snd_dma_malloc_pages*())
passes the byte size to allocate as is.  Most of the backends
allocates real pages, hence the actual allocations are aligned in page
size.  However, the genalloc doesn't seem assuring the size alignment,
hence it may result in the access outside the buffer when the whole
memory pages are exposed via mmap.

For avoiding such inconsistencies, this patch makes the allocation
size always to be aligned in page size.

Note that, after this change, snd_dma_buffer.bytes field contains the
aligned size, not the originally requested size.  This value is also
used for releasing the pages in return.

Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20201218145625.2045-2-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-29 17:14:18 +02:00
Peter Zijlstra
352affc31e bitfield.h: Fix "type of reg too small for mask" test
[ Upstream commit bff8c3848e071d387d8b0784dc91fa49cd563774 ]

The test: 'mask > (typeof(_reg))~0ull' only works correctly when both
sides are unsigned, consider:

 - 0xff000000 vs (int)~0ull
 - 0x000000ff vs (int)~0ull

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lore.kernel.org/r/20211110101324.950210584@infradead.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-07-29 17:14:18 +02:00
Thomas Gleixner
0a0fbbd6cb x86/mce: Deduplicate exception handling
[ Upstream commit e42404afc4ca856c48f1e05752541faa3587c472 ]

Prepare code for further simplification. No functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20210908132525.096452100@linutronix.de
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-07-29 17:14:18 +02:00
Michel Lespinasse
b524137fa1 mmap locking API: initial implementation as rwsem wrappers
[ Upstream commit 9740ca4e95b43b91a4a848694a20d01ba6818f7b ]

This patch series adds a new mmap locking API replacing the existing
mmap_sem lock and unlocks.  Initially the API is just implemente in terms
of inlined rwsem calls, so it doesn't provide any new functionality.

There are two justifications for the new API:

- At first, it provides an easy hooking point to instrument mmap_sem
  locking latencies independently of any other rwsems.

- In the future, it may be a starting point for replacing the rwsem
  implementation with a different one, such as range locks.  This is
  something that is being explored, even though there is no wide concensus
  about this possible direction yet.  (see
  https://patchwork.kernel.org/cover/11401483/)

This patch (of 12):

This change wraps the existing mmap_sem related rwsem calls into a new
mmap locking API.  There are two justifications for the new API:

- At first, it provides an easy hooking point to instrument mmap_sem
  locking latencies independently of any other rwsems.

- In the future, it may be a starting point for replacing the rwsem
  implementation with a different one, such as range locks.

Signed-off-by: Michel Lespinasse <walken@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Daniel Jordan <daniel.m.jordan@oracle.com>
Reviewed-by: Davidlohr Bueso <dbueso@suse.de>
Reviewed-by: Laurent Dufour <ldufour@linux.ibm.com>
Reviewed-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Liam Howlett <Liam.Howlett@oracle.com>
Cc: Jerome Glisse <jglisse@redhat.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Ying Han <yinghan@google.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Michel Lespinasse <walken@google.com>
Link: http://lkml.kernel.org/r/20200520052908.204642-1-walken@google.com
Link: http://lkml.kernel.org/r/20200520052908.204642-2-walken@google.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-07-29 17:14:18 +02:00
Peter Zijlstra
592a1c6066 x86/uaccess: Implement macros for CMPXCHG on user addresses
[ Upstream commit 989b5db215a2f22f89d730b607b071d964780f10 ]

Add support for CMPXCHG loops on userspace addresses.  Provide both an
"unsafe" version for tight loops that do their own uaccess begin/end, as
well as a "safe" version for use cases where the CMPXCHG is not buried in
a loop, e.g. KVM will resume the guest instead of looping when emulation
of a guest atomic accesses fails the CMPXCHG.

Provide 8-byte versions for 32-bit kernels so that KVM can do CMPXCHG on
guest PAE PTEs, which are accessed via userspace addresses.

Guard the asm_volatile_goto() variation with CC_HAS_ASM_GOTO_TIED_OUTPUT,
the "+m" constraint fails on some compilers that otherwise support
CC_HAS_ASM_GOTO_OUTPUT.

Cc: stable@vger.kernel.org
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Co-developed-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20220202004945.2540433-3-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-07-29 17:14:17 +02:00