Commit Graph

985921 Commits

Author SHA1 Message Date
Marc Zyngier
be1849348b ANDROID: KVM: arm64: Save/restore virtual timer state from the shadow vcpu
Similar to the vgic state, make sure to sync and flush the virtual timer
state between the host and the hyp shadow vCPU structs when running in
nVHE protected mode.

Signed-off-by: Marc Zyngier <maz@kernel.org>
Bug: 209580772
Change-Id: Ib90273bb670d9d815dd9f542369dde00753655cf
Signed-off-by: Will Deacon <willdeacon@google.com>
2022-01-14 16:31:18 +00:00
Marc Zyngier
3784299dce ANDROID: KVM: arm64: Move vgic state between host and shadow vcpu structures
Now that protected VMs have a shadow state maintained at EL2 in nVHE
protected mode, make sure to sync and flush the vgic state between host
and hyp data structure upon entry and exit from a guest.

Signed-off-by: Marc Zyngier <maz@kernel.org>
Bug: 209580772
Change-Id: I8d7ab950041a5cd79217c9ee0e04742a27439a99
Signed-off-by: Will Deacon <willdeacon@google.com>
2022-01-14 16:31:18 +00:00
Marc Zyngier
7a2a87a002 ANDROID: KVM: arm64: Merge vmcr/apr save/restore
Merge the functions to save and restore vmcr and apr. This can in some
cases reduce the number of hypercalls necessary to load/put the vgic
state in nVHE and will also ease its management in protected mode later
on.

Signed-off-by: Marc Zyngier <maz@kernel.org>
Bug: 209580772
Change-Id: Id85f0698a7a346282e55c15993c274828bd5309c
Signed-off-by: Will Deacon <willdeacon@google.com>
2022-01-14 16:31:18 +00:00
Fuad Tabba
871ce72f04 ANDROID: KVM: arm64: Move pkvm_vcpu_init_traps to shadow vcpu init
Move the initialization of traps to the initialization of the
shadow vcpu, and remove the associated hypercall.

No functional change intended.

Signed-off-by: Fuad Tabba <tabba@google.com>
Bug: 209580772
Change-Id: I4bf45733972ac54c72c40b3ef1df32cfe7d04a70
Signed-off-by: Will Deacon <willdeacon@google.com>
2022-01-14 16:31:17 +00:00
Fuad Tabba
5bf9b540d4 ANDROID: KVM: arm64: Add handlers for entry/exit state
Add handlers to exchange information between the
host and the protected guest on vcpu entry and exit, which
most often would happen on running a vcpu.

Signed-off-by: Fuad Tabba <tabba@google.com>
Bug: 209580772
Change-Id: I1716f55f5a1cb75dcde26b58af8f78ee80e4a19e
Signed-off-by: Will Deacon <willdeacon@google.com>
2022-01-14 16:31:17 +00:00
Fuad Tabba
bd5993889e ANDROID: KVM: arm64: Shadow table for KVM EL2 state
Create and populate a shadow table that contains the state hyp
need for running protected VMs, i.e., struct kvm and struct
kvm_vcpu at EL2.

The memory for this is donated by the host and then unmapped from
the host at stage 1 and at stage 2 (by hyp).

This state is not used yet.

Signed-off-by: Fuad Tabba <tabba@google.com>
Bug: 209580772
Change-Id: Ie2d948f2a5f22a06d615d909de7a60d46944e6d8
Signed-off-by: Will Deacon <willdeacon@google.com>
2022-01-14 16:31:17 +00:00
Fuad Tabba
03c9459126 ANDROID: KVM: arm64: Reset sysregs for protected VMs
Create a framework for resetting protected VM system registers to
their architecturally defined reset values.

No functional change intended as these are not hooked in yet.

Signed-off-by: Fuad Tabba <tabba@google.com>
Bug: 209580772
Change-Id: Iafdab9f796897429f0fb8abd5d7df9ca576e1f91
Signed-off-by: Will Deacon <willdeacon@google.com>
2022-01-14 16:31:17 +00:00
Fuad Tabba
60ce953510 ANDROID: KVM: arm64: Refactor reset_mpidr to extract its computation
Move the computation of the mpidr to its own function in a shared
header, as the computation will be used by hyp in protected mode.

No functional change intended.

Signed-off-by: Fuad Tabba <tabba@google.com>
Bug: 209580772
Change-Id: I531795b43c9747dceea485843eed114675db9354
Signed-off-by: Will Deacon <willdeacon@google.com>
2022-01-14 16:31:17 +00:00
Fuad Tabba
044fffde53 ANDROID: KVM: arm64: Move pstate reset values to kvm_arm.h
Move the macro defines of the pstate reset values to a shared
header to be used by hyp in protected mode.

No functional change intended.

Signed-off-by: Fuad Tabba <tabba@google.com>
Bug: 209580772
Change-Id: Iafd31108675027a799ce9ff3c5c56b49e87ead67
Signed-off-by: Will Deacon <willdeacon@google.com>
2022-01-14 16:31:17 +00:00
Fuad Tabba
6847b104ec ANDROID: KVM: arm64: Fix initializing traps for protected VMs
The values of the trapping registers for protected VMs should be
computed from the ground up, and not depend on potentially
preexisting values.

No functional change intended.

Signed-off-by: Fuad Tabba <tabba@google.com>
Bug: 209580772
Change-Id: Iacd3916dd1bbfc8d9cc859f94a9d879e9d456ebc
Signed-off-by: Will Deacon <willdeacon@google.com>
2022-01-14 16:31:17 +00:00
Fuad Tabba
504bd4048c ANDROID: KVM: arm64: Add hyp_spinlock_t static initializer
Having a static initializer for hyp_spinlock_t simplifies its
use when there isn't an initializing function.

No functional change intended.

Signed-off-by: Fuad Tabba <tabba@google.com>
Bug: 209580772
Change-Id: Ib1eabe03f49013955a7afcbfcc6a7d3c4a31a736
Signed-off-by: Will Deacon <willdeacon@google.com>
2022-01-14 16:31:16 +00:00
Fuad Tabba
a3eccabf8e ANDROID: KVM: arm64: FAR_EL2 mask as a define
Create a macro definition for the FAR_EL2 mask and use it instead
of a hard-coded value, and put it in a share header to be used by
hyp.

No functional change intended.

Signed-off-by: Fuad Tabba <tabba@google.com>
Bug: 209580772
Change-Id: Ib83932d670cba6bf8f1ed45d2c0e1ed34331d98d
Signed-off-by: Will Deacon <willdeacon@google.com>
2022-01-14 16:31:16 +00:00
Fuad Tabba
8ddd782c98 ANDROID: KVM: arm64: Trap debug break and watch from guest
Debug and trace are not currently supported for protected guests.
Trap related exceptions and restrict access to related registers.

Signed-off-by: Fuad Tabba <tabba@google.com>
Bug: 209580772
Change-Id: If7483e5b38837d6e7d83c47657a94f16a34ba856
Signed-off-by: Will Deacon <willdeacon@google.com>
2022-01-14 16:31:16 +00:00
Will Deacon
6d78e34f75 ANDROID: KVM: arm64: Split up nvhe/fixed_config.h
In preparation for using some of the pKVM fixed configuration register
definitions to filter the available VM CAPs in the host, split the
nvhe/fixed_config.h header so that the definitions can be shared
with the host, while keeping the hypervisor function prototypes in
the nvhe/ namespace.

Signed-off-by: Will Deacon <will@kernel.org>
Bug: 209580772
Change-Id: I587bbcfebcc89633695fde9a5cfa1546fdca1018
Signed-off-by: Will Deacon <willdeacon@google.com>
2022-01-14 16:31:16 +00:00
Quentin Perret
9bf22b9622 ANDROID: KVM: arm64: Add helpers to pin memory shared with hyp
Add helpers allowing the hypervisor to check whether a range of pages
are currently shared by the host, and 'pin' them if so by blocking host
unshare operations until the memory has been unpinned. This will allow
the hypervisor to take references on host-provided data-structures
(struct kvm and such) and be guaranteed these pages will remain in a
stable state until it decides to release them, e.g. during guest
teardown.

Signed-off-by: Quentin Perret <qperret@google.com>
Bug: 209580772
Change-Id: I60ff204bd11e78e3e2ce21defc0d94ae916f5097
Signed-off-by: Will Deacon <willdeacon@google.com>
2022-01-14 16:31:16 +00:00
Quentin Perret
b6a704bc58 ANDROID: KVM: arm64: Back hyp_vmemmap for all of memory
The EL2 vmemmap in nVHE Protected mode is currently very sparse: only
memory pages owned by the hypervisor itself have a matching struct
hyp_page. But since the size of these structs has been reduced
significantly, it appears that we can afford backing the vmemmap for all
of memory.

This will simplify a lot memory tracking as the hypervisor will have a
place to store metadata (e.g. refcounts) that wouldn't otherwise fit in
the 4 SW bits we have in the host stage-2 page-table for instance.

Signed-off-by: Quentin Perret <qperret@google.com>
Bug: 209580772
Change-Id: Idaaf67ae6401765143fd7fe4b12f8f53e9cbf64b
Signed-off-by: Will Deacon <willdeacon@google.com>
2022-01-14 16:31:16 +00:00
Quentin Perret
3cb7feab5f ANDROID: KVM: arm64: Move hyp refcount manipulation helpers
We will soon need to manipulate struct hyp_page refcounts from outside
page_alloc.c, so move the helpers to a header file.

Signed-off-by: Quentin Perret <qperret@google.com>
Bug: 209580772
Change-Id: I5cfeeb1e3e6a61cbba70c242cf25e035b26149e7
Signed-off-by: Will Deacon <willdeacon@google.com>
2022-01-14 16:31:16 +00:00
Quentin Perret
7fbb472eb0 ANDROID: KVM: arm64: Add __pkvm_hyp_donate_host()
The hypervisor will soon need to donate memory pages to the host to
return pages backing guest VM metadata during guest teardown, so provide
a helper allowing hyp-to-host memory donations.

Signed-off-by: Quentin Perret <qperret@google.com>
Bug: 209580772
Change-Id: I3013e8f69e9d26fae751bb81cc1e66253f0f5039
Signed-off-by: Will Deacon <willdeacon@google.com>
2022-01-14 16:31:16 +00:00
Quentin Perret
feacf4afa1 ANDROID: KVM: arm64: Add __pkvm_host_donate_hyp()
The host will soon need to donate memory pages to the hypervisor to
store VM metadata, so provide a helper function allowing host-to-hyp
memory donations.

Signed-off-by: Quentin Perret <qperret@google.com>
Bug: 209580772
Change-Id: I246978d81bd5301dae13c1f9d3e546334ecd88ad
Signed-off-by: Will Deacon <willdeacon@google.com>
2022-01-14 16:31:15 +00:00
Quentin Perret
0c7255854e ANDROID: KVM: arm64: Implement hyp -> host memory donation
Returning memory ownership of KVM metadata pages to the host once it is
no longer required (i.e. after VM teardown) can be achieved using a
series of memory donations from the hypervisor to the host.

Implement hyp-to-host memory donation.

Signed-off-by: Quentin Perret <qperret@google.com>
Bug: 209580772
Change-Id: I7c77bf6dae0ee7f96cd032d06b1ced5502530786
Signed-off-by: Will Deacon <willdeacon@google.com>
2022-01-14 16:31:15 +00:00
Quentin Perret
c9f3c00ed4 ANDROID: KVM: arm64: Implement do_donate() helper for donating memory
Transferring ownership information of a memory region from one component
to another can be achieved using a "donate" operation, which results
in the previous owner losing access to the underlying pages entirely.

Implement a do_donate() helper, along the same lines as do_{un,}share,
to provide this functionality for the host-to-hyp case.

Signed-off-by: Quentin Perret <qperret@google.com>
Bug: 209580772
Change-Id: I426f8b068450e7e6b93ba05a0aea6ce8f93e6bf7
Signed-off-by: Will Deacon <willdeacon@google.com>
2022-01-14 16:31:15 +00:00
Marc Zyngier
9ad5e201c7 FROMLIST: KVM: arm64: pkvm: Use the mm_ops indirection for cache maintenance
CMOs issued from EL2 cannot directly use the kernel helpers,
as EL2 doesn't have a mapping of the guest pages. Oops.

Instead, use the mm_ops indirection to use helpers that will
perform a mapping at EL2 and allow the CMO to be effective.

Fixes: 25aa28691b ("KVM: arm64: Move guest CMOs to the fault handlers")
Signed-off-by: Marc Zyngier <maz@kernel.org>
Bug: 209777660
Link: https://lore.kernel.org/r/20220114125038.1336965-1-maz@kernel.org
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: I8cd221f7c89a20de28f0bea422641622b8320c1f
2022-01-14 16:31:15 +00:00
David Brazdil
e149939df2 ANDROID: KVM: arm64: Wait on S2MPU.STATUS after invalidation
The S2MPU must wait for a v9 device to finish invalidation before
accessing its SFRs. Failure to do so can result in memory transaction
timeouts.

Add a loop that polls the STATUS register while the return value has
the BUSY and ON_INVALIDATING bits set.

Test: builds, boots
Bug: 190463801
Bug: 206761586
Signed-off-by: David Brazdil <dbrazdil@google.com>
Change-Id: I00891dc3a8ad185d29757b8622a053a96237b803
2022-01-14 15:54:56 +00:00
David Brazdil
4377d9dea9 ANDROID: KVM: arm64: Remove kernel-doc in S2MPU driver
Comments in S2MPU driver code were mistakenly prefixed with /**,
denoting a kernel-doc comment. Since these do not match kernel-doc
syntax, replace them with regular /* comments.

Test: n/a
Bug: 190463801
Signed-off-by: David Brazdil <dbrazdil@google.com>
Change-Id: I81ed57f22c2cf9eaa5761f11b4f3b8ce1800f457
2022-01-14 12:08:41 +00:00
Daniel Rosenberg
c9c83164bf ANDROID: fsnotify: Fix Open Check
The previous version would miss if FS_OPEN_EXEC was set.

Change-Id: I52d55bed2ca029f8fae8576f831a0621f2d02804
Fixes: b99f858e42 ("ANDROID: fsnotify: Notify lower fs of open")
Bug: 70706497
Signed-off-by: Daniel Rosenberg <drosen@google.com>
2022-01-13 13:06:59 -08:00
Daniel Rosenberg
b99f858e42 ANDROID: fsnotify: Notify lower fs of open
If the filesystem being watched supports d_canonical_path,
notify the lower filesystem of the open as well.

Fixes: f37e05049b ("ANDROID: vfs: d_canonical_path for stacked FS")
Bug: 70706497
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Signed-off-by: Alessio Balsini <balsini@google.com>
Change-Id: I7c9d210e8e6ee99928ad9db0b41ffc3ac3371dc0
2022-01-13 16:29:20 +00:00
Paul Lawrence
b6f28f6377 ANDROID: fuse-bpf: Support inotify
Test: fuse_test, atest CtsOsTestCases:android.os.cts.FileObserverTest
Bug: 202785178
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Signed-off-by: Alessio Balsini <balsini@google.com>
Change-Id: I88719a8ab23c2042fb8f50462f023e247aa4b6c3
2022-01-13 16:29:13 +00:00
Daniel Rosenberg
53c77d7a8e ANDROID: fsnotify: Notify lower fs of open
If the filesystem being watched supports d_canonical_path,
notify the lower filesystem of the open as well.

Bug: 70706497
Fixes: f37e05049b ("ANDROID: vfs: d_canonical_path for stacked FS")
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Signed-off-by: Alessio Balsini <balsini@google.com>

Change-Id: I2b1739e068afbaf5eb39950516072bff8345ebfe
2022-01-13 15:27:50 +00:00
Paul Lawrence
aae548daec ANDROID: fuse-bpf: Support inotify
Test: fuse_test, atest CtsOsTestCases:android.os.cts.FileObserverTest
pass
Bug: 202785178
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Signed-off-by: Alessio Balsini <balsini@google.com>
Change-Id: I789238489899a69691e0def1a49288227e62461b
2022-01-13 15:27:33 +00:00
xieliujie
abaefd378c ANDROID: dma-buf: heaps: fix dma-buf heap pool pages stat
this critical region should be protected by pool->mutex.

Bug: 207658347
Fixes: e7dac4c323 ("ANDROID: dma-buf: heaps: Add a shrinker controlled page pool")
Signed-off-by: liuhailong <liuhailong@oppo.com>
Signed-off-by: xieliujie <xieliujie@oppo.com>
Change-Id: I6f129926c96176258a965964c24602fc647db61e
Signed-off-by: Hridya Valsaraju <hridya@google.com>
2022-01-13 00:48:04 +00:00
Roman Kiryanov
10df8502c6 ANDROID: Update abi_gki_aarch64_virtual_device
goldfish drivers were enabled and they require
additional symbols.

Bug: 213942757
Test: presubmit
Signed-off-by: Roman Kiryanov <rkir@google.com>
Change-Id: I9f4ba0f0bc278f3acf42aaafacb709b4bb25a65b
2022-01-12 11:07:35 -08:00
Paul Lawrence
df9986dcee ANDROID: fuse-bpf: Make compile with CONFIG_FUSE but no CONFIG_FUSE_BPF
Fixes: ANDROID: fuse-bpf: Fix perms on readdir
Test: Builds with and without CONFIG_FUSE_BPF
Bug: 202785178
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: If8b4603dd6f4bd159bfd68fc61c377dcb62ebcd0
2022-01-11 22:01:21 +00:00
Jeson Gao
c53f0e3530 ANDROID: thermal: Add vendor hook to get thermal zone device
Need to get temperature data and config info from thermal zone device.

Bug: 208946028

Signed-off-by: Jeson Gao <jeson.gao@unisoc.com>
Change-Id: I5945df5258181b4a441b6bbe09327099491418b3
2022-01-11 19:10:58 +00:00
Greg Kroah-Hartman
d6d42583fe Merge 5.10.91 into android13-5.10
Changes in 5.10.91
	f2fs: quota: fix potential deadlock
	selftests: x86: fix [-Wstringop-overread] warn in test_process_vm_readv()
	tracing: Fix check for trace_percpu_buffer validity in get_trace_buf()
	tracing: Tag trace_percpu_buffer as a percpu pointer
	ieee802154: atusb: fix uninit value in atusb_set_extended_addr
	i40e: Fix to not show opcode msg on unsuccessful VF MAC change
	iavf: Fix limit of total number of queues to active queues of VF
	RDMA/core: Don't infoleak GRH fields
	netrom: fix copying in user data in nr_setsockopt
	RDMA/uverbs: Check for null return of kmalloc_array
	mac80211: initialize variable have_higher_than_11mbit
	sfc: The RX page_ring is optional
	i40e: fix use-after-free in i40e_sync_filters_subtask()
	i40e: Fix for displaying message regarding NVM version
	i40e: Fix incorrect netdev's real number of RX/TX queues
	ftrace/samples: Add missing prototypes direct functions
	ipv4: Check attribute length for RTA_GATEWAY in multipath route
	ipv4: Check attribute length for RTA_FLOW in multipath route
	ipv6: Check attribute length for RTA_GATEWAY in multipath route
	ipv6: Check attribute length for RTA_GATEWAY when deleting multipath route
	lwtunnel: Validate RTA_ENCAP_TYPE attribute length
	batman-adv: mcast: don't send link-local multicast to mcast routers
	sch_qfq: prevent shift-out-of-bounds in qfq_init_qdisc
	net: ena: Fix undefined state when tx request id is out of bounds
	net: ena: Fix error handling when calculating max IO queues number
	xfs: map unwritten blocks in XFS_IOC_{ALLOC,FREE}SP just like fallocate
	power: supply: core: Break capacity loop
	power: reset: ltc2952: Fix use of floating point literals
	rndis_host: support Hytera digital radios
	phonet: refcount leak in pep_sock_accep
	power: bq25890: Enable continuous conversion for ADC at charging
	ipv6: Continue processing multipath route even if gateway attribute is invalid
	ipv6: Do cleanup if attribute validation fails in multipath route
	usb: mtu3: fix interval value for intr and isoc
	scsi: libiscsi: Fix UAF in iscsi_conn_get_param()/iscsi_conn_teardown()
	ip6_vti: initialize __ip6_tnl_parm struct in vti6_siocdevprivate
	net: udp: fix alignment problem in udp4_seq_show()
	atlantic: Fix buff_ring OOB in aq_ring_rx_clean
	mISDN: change function names to avoid conflicts
	drm/amd/display: Added power down for DCN10
	ipv6: raw: check passed optlen before reading
	ARM: dts: gpio-ranges property is now required
	Input: zinitix - make sure the IRQ is allocated before it gets enabled
	Linux 5.10.91

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I74a403f4fe8dff1a0b2e1e38888d9968a654e748
2022-01-11 15:45:50 +01:00
Greg Kroah-Hartman
df395c763b Linux 5.10.91
Link: https://lore.kernel.org/r/20220110071817.337619922@linuxfoundation.org
Tested-by: Jon Hunter <jonathanh@nvidia.com>
Tested-by: Salvatore Bonaccorso <carnil@debian.org>
Tested-by: Fox Chen <foxhlchen@gmail.com>
Tested-by: Florian Fainelli <f.fainelli@gmail.com>
Tested-by: Shuah Khan <skhan@linuxfoundation.org>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Tested-by: Hulk Robot <hulkrobot@huawei.com>
Tested-by: Linux Kernel Functional Testing <lkft@linaro.org>
Tested-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-01-11 15:25:03 +01:00
Nikita Travkin
674071c9eb Input: zinitix - make sure the IRQ is allocated before it gets enabled
commit cf73ed894e upstream.

Since irq request is the last thing in the driver probe, it happens
later than the input device registration. This means that there is a
small time window where if the open method is called the driver will
attempt to enable not yet available irq.

Fix that by moving the irq request before the input device registration.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Fixes: 26822652c8 ("Input: add zinitix touchscreen driver")
Signed-off-by: Nikita Travkin <nikita@trvn.ru>
Link: https://lore.kernel.org/r/20220106072840.36851-2-nikita@trvn.ru
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-01-11 15:25:02 +01:00
Phil Elwell
ef81f7d406 ARM: dts: gpio-ranges property is now required
[ Upstream commit c8013355ea ]

Since [1], added in 5.7, the absence of a gpio-ranges property has
prevented GPIOs from being restored to inputs when released.
Add those properties for BCM283x and BCM2711 devices.

[1] commit 2ab73c6d83 ("gpio: Support GPIO controllers without
    pin-ranges")

Link: https://lore.kernel.org/r/20220104170247.956760-1-linus.walleij@linaro.org
Fixes: 2ab73c6d83 ("gpio: Support GPIO controllers without pin-ranges")
Fixes: 266423e60e ("pinctrl: bcm2835: Change init order for gpio hogs")
Reported-by: Stefan Wahren <stefan.wahren@i2se.com>
Reported-by: Florian Fainelli <f.fainelli@gmail.com>
Reported-by: Jan Kiszka <jan.kiszka@web.de>
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20211206092237.4105895-3-phil@raspberrypi.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Olof Johansson <olof@lixom.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-01-11 15:25:02 +01:00
Tamir Duberstein
f63fa1a0d4 ipv6: raw: check passed optlen before reading
[ Upstream commit fb7bc92040 ]

Add a check that the user-provided option is at least as long as the
number of bytes we intend to read. Before this patch we would blindly
read sizeof(int) bytes even in cases where the user passed
optlen<sizeof(int), which would potentially read garbage or fault.

Discovered by new tests in https://github.com/google/gvisor/pull/6957 .

The original get_user call predates history in the git repo.

Signed-off-by: Tamir Duberstein <tamird@gmail.com>
Signed-off-by: Willem de Bruijn <willemb@google.com>
Link: https://lore.kernel.org/r/20211229200947.2862255-1-willemdebruijn.kernel@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-01-11 15:25:02 +01:00
Lai, Derek
cf07884e6b drm/amd/display: Added power down for DCN10
[ Upstream commit d97e631af2 ]

[Why]
The change of setting a timer callback on boot for 10 seconds is still
working, just lacked power down for DCN10.

[How]
Added power down for DCN10.

Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Reviewed-by: Anthony Koo <Anthony.Koo@amd.com>
Acked-by: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Signed-off-by: Derek Lai <Derek.Lai@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-01-11 15:25:02 +01:00
wolfgang huang
10b9ccd067 mISDN: change function names to avoid conflicts
[ Upstream commit 8b5fdfc57c ]

As we build for mips, we meet following error. l1_init error with
multiple definition. Some architecture devices usually marked with
l1, l2, lxx as the start-up phase. so we change the mISDN function
names, align with Isdnl2_xxx.

mips-linux-gnu-ld: drivers/isdn/mISDN/layer1.o: in function `l1_init':
(.text+0x890): multiple definition of `l1_init'; \
arch/mips/kernel/bmips_5xxx_init.o:(.text+0xf0): first defined here
make[1]: *** [home/mips/kernel-build/linux/Makefile:1161: vmlinux] Error 1

Signed-off-by: wolfgang huang <huangjinhui@kylinos.cn>
Reported-by: k2ci <kernel-bot@kylinos.cn>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-01-11 15:25:02 +01:00
Zekun Shen
dd8a09cfbb atlantic: Fix buff_ring OOB in aq_ring_rx_clean
[ Upstream commit 5f50153288 ]

The function obtain the next buffer without boundary check.
We should return with I/O error code.

The bug is found by fuzzing and the crash report is attached.
It is an OOB bug although reported as use-after-free.

[    4.804724] BUG: KASAN: use-after-free in aq_ring_rx_clean+0x1e88/0x2730 [atlantic]
[    4.805661] Read of size 4 at addr ffff888034fe93a8 by task ksoftirqd/0/9
[    4.806505]
[    4.806703] CPU: 0 PID: 9 Comm: ksoftirqd/0 Tainted: G        W         5.6.0 #34
[    4.809030] Call Trace:
[    4.809343]  dump_stack+0x76/0xa0
[    4.809755]  print_address_description.constprop.0+0x16/0x200
[    4.810455]  ? aq_ring_rx_clean+0x1e88/0x2730 [atlantic]
[    4.811234]  ? aq_ring_rx_clean+0x1e88/0x2730 [atlantic]
[    4.813183]  __kasan_report.cold+0x37/0x7c
[    4.813715]  ? aq_ring_rx_clean+0x1e88/0x2730 [atlantic]
[    4.814393]  kasan_report+0xe/0x20
[    4.814837]  aq_ring_rx_clean+0x1e88/0x2730 [atlantic]
[    4.815499]  ? hw_atl_b0_hw_ring_rx_receive+0x9a5/0xb90 [atlantic]
[    4.816290]  aq_vec_poll+0x179/0x5d0 [atlantic]
[    4.816870]  ? _GLOBAL__sub_I_65535_1_aq_pci_func_init+0x20/0x20 [atlantic]
[    4.817746]  ? __next_timer_interrupt+0xba/0xf0
[    4.818322]  net_rx_action+0x363/0xbd0
[    4.818803]  ? call_timer_fn+0x240/0x240
[    4.819302]  ? __switch_to_asm+0x40/0x70
[    4.819809]  ? napi_busy_loop+0x520/0x520
[    4.820324]  __do_softirq+0x18c/0x634
[    4.820797]  ? takeover_tasklets+0x5f0/0x5f0
[    4.821343]  run_ksoftirqd+0x15/0x20
[    4.821804]  smpboot_thread_fn+0x2f1/0x6b0
[    4.822331]  ? smpboot_unregister_percpu_thread+0x160/0x160
[    4.823041]  ? __kthread_parkme+0x80/0x100
[    4.823571]  ? smpboot_unregister_percpu_thread+0x160/0x160
[    4.824301]  kthread+0x2b5/0x3b0
[    4.824723]  ? kthread_create_on_node+0xd0/0xd0
[    4.825304]  ret_from_fork+0x35/0x40

Signed-off-by: Zekun Shen <bruceshenzk@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-01-11 15:25:02 +01:00
yangxingwu
c2f4bb251e net: udp: fix alignment problem in udp4_seq_show()
[ Upstream commit 6c25449e1a ]

$ cat /pro/net/udp

before:

  sl  local_address rem_address   st tx_queue rx_queue tr tm->when
26050: 0100007F:0035 00000000:0000 07 00000000:00000000 00:00000000
26320: 0100007F:0143 00000000:0000 07 00000000:00000000 00:00000000
27135: 00000000:8472 00000000:0000 07 00000000:00000000 00:00000000

after:

   sl  local_address rem_address   st tx_queue rx_queue tr tm->when
26050: 0100007F:0035 00000000:0000 07 00000000:00000000 00:00000000
26320: 0100007F:0143 00000000:0000 07 00000000:00000000 00:00000000
27135: 00000000:8472 00000000:0000 07 00000000:00000000 00:00000000

Signed-off-by: yangxingwu <xingwu.yang@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-01-11 15:25:02 +01:00
William Zhao
f82b48d1d8 ip6_vti: initialize __ip6_tnl_parm struct in vti6_siocdevprivate
[ Upstream commit c1833c3964 ]

The "__ip6_tnl_parm" struct was left uninitialized causing an invalid
load of random data when the "__ip6_tnl_parm" struct was used elsewhere.
As an example, in the function "ip6_tnl_xmit_ctl()", it tries to access
the "collect_md" member. With "__ip6_tnl_parm" being uninitialized and
containing random data, the UBSAN detected that "collect_md" held a
non-boolean value.

The UBSAN issue is as follows:
===============================================================
UBSAN: invalid-load in net/ipv6/ip6_tunnel.c:1025:14
load of value 30 is not a valid value for type '_Bool'
CPU: 1 PID: 228 Comm: kworker/1:3 Not tainted 5.16.0-rc4+ #8
Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011
Workqueue: ipv6_addrconf addrconf_dad_work
Call Trace:
<TASK>
dump_stack_lvl+0x44/0x57
ubsan_epilogue+0x5/0x40
__ubsan_handle_load_invalid_value+0x66/0x70
? __cpuhp_setup_state+0x1d3/0x210
ip6_tnl_xmit_ctl.cold.52+0x2c/0x6f [ip6_tunnel]
vti6_tnl_xmit+0x79c/0x1e96 [ip6_vti]
? lock_is_held_type+0xd9/0x130
? vti6_rcv+0x100/0x100 [ip6_vti]
? lock_is_held_type+0xd9/0x130
? rcu_read_lock_bh_held+0xc0/0xc0
? lock_acquired+0x262/0xb10
dev_hard_start_xmit+0x1e6/0x820
__dev_queue_xmit+0x2079/0x3340
? mark_lock.part.52+0xf7/0x1050
? netdev_core_pick_tx+0x290/0x290
? kvm_clock_read+0x14/0x30
? kvm_sched_clock_read+0x5/0x10
? sched_clock_cpu+0x15/0x200
? find_held_lock+0x3a/0x1c0
? lock_release+0x42f/0xc90
? lock_downgrade+0x6b0/0x6b0
? mark_held_locks+0xb7/0x120
? neigh_connected_output+0x31f/0x470
? lockdep_hardirqs_on+0x79/0x100
? neigh_connected_output+0x31f/0x470
? ip6_finish_output2+0x9b0/0x1d90
? rcu_read_lock_bh_held+0x62/0xc0
? ip6_finish_output2+0x9b0/0x1d90
ip6_finish_output2+0x9b0/0x1d90
? ip6_append_data+0x330/0x330
? ip6_mtu+0x166/0x370
? __ip6_finish_output+0x1ad/0xfb0
? nf_hook_slow+0xa6/0x170
ip6_output+0x1fb/0x710
? nf_hook.constprop.32+0x317/0x430
? ip6_finish_output+0x180/0x180
? __ip6_finish_output+0xfb0/0xfb0
? lock_is_held_type+0xd9/0x130
ndisc_send_skb+0xb33/0x1590
? __sk_mem_raise_allocated+0x11cf/0x1560
? dst_output+0x4a0/0x4a0
? ndisc_send_rs+0x432/0x610
addrconf_dad_completed+0x30c/0xbb0
? addrconf_rs_timer+0x650/0x650
? addrconf_dad_work+0x73c/0x10e0
addrconf_dad_work+0x73c/0x10e0
? addrconf_dad_completed+0xbb0/0xbb0
? rcu_read_lock_sched_held+0xaf/0xe0
? rcu_read_lock_bh_held+0xc0/0xc0
process_one_work+0x97b/0x1740
? pwq_dec_nr_in_flight+0x270/0x270
worker_thread+0x87/0xbf0
? process_one_work+0x1740/0x1740
kthread+0x3ac/0x490
? set_kthread_struct+0x100/0x100
ret_from_fork+0x22/0x30
</TASK>
===============================================================

The solution is to initialize "__ip6_tnl_parm" struct to zeros in the
"vti6_siocdevprivate()" function.

Signed-off-by: William Zhao <wizhao@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-01-11 15:25:02 +01:00
Lixiaokeng
8c87a83ef8 scsi: libiscsi: Fix UAF in iscsi_conn_get_param()/iscsi_conn_teardown()
[ Upstream commit 1b8d0300a3 ]

|- iscsi_if_destroy_conn            |-dev_attr_show
 |-iscsi_conn_teardown
  |-spin_lock_bh                     |-iscsi_sw_tcp_conn_get_param

  |-kfree(conn->persistent_address)   |-iscsi_conn_get_param
  |-kfree(conn->local_ipaddr)
                                       ==>|-read persistent_address
                                       ==>|-read local_ipaddr
  |-spin_unlock_bh

When iscsi_conn_teardown() and iscsi_conn_get_param() happen in parallel, a
UAF may be triggered.

Link: https://lore.kernel.org/r/046ec8a0-ce95-d3fc-3235-666a7c65b224@huawei.com
Reported-by: Lu Tixiong <lutianxiong@huawei.com>
Reviewed-by: Mike Christie <michael.christie@oracle.com>
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Lixiaokeng <lixiaokeng@huawei.com>
Signed-off-by: Linfeilong <linfeilong@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-01-11 15:25:02 +01:00
Chunfeng Yun
b798b677f9 usb: mtu3: fix interval value for intr and isoc
[ Upstream commit e3d4621c22 ]

Use the Interval value from isoc/intr endpoint descriptor, no need
minus one. The original code doesn't cause transfer error for
normal cases, but it may have side effect with respond time of ERDY
or tPingTimeout.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Link: https://lore.kernel.org/r/20211218095749.6250-1-chunfeng.yun@mediatek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-01-11 15:25:02 +01:00
David Ahern
498d77fc5e ipv6: Do cleanup if attribute validation fails in multipath route
[ Upstream commit 95bdba23b5 ]

As Nicolas noted, if gateway validation fails walking the multipath
attribute the code should jump to the cleanup to free previously
allocated memory.

Fixes: 1ff15a710a ("ipv6: Check attribute length for RTA_GATEWAY when deleting multipath route")
Signed-off-by: David Ahern <dsahern@kernel.org>
Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Link: https://lore.kernel.org/r/20220103170555.94638-1-dsahern@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-01-11 15:25:01 +01:00
David Ahern
72b0d14a0a ipv6: Continue processing multipath route even if gateway attribute is invalid
[ Upstream commit e30a845b03 ]

ip6_route_multipath_del loop continues processing the multipath
attribute even if delete of a nexthop path fails. For consistency,
do the same if the gateway attribute is invalid.

Fixes: 1ff15a710a ("ipv6: Check attribute length for RTA_GATEWAY when deleting multipath route")
Signed-off-by: David Ahern <dsahern@kernel.org>
Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Link: https://lore.kernel.org/r/20220103171911.94739-1-dsahern@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-01-11 15:25:01 +01:00
Yauhen Kharuzhy
5a7d650bb1 power: bq25890: Enable continuous conversion for ADC at charging
commit 80211be1b9 upstream.

Instead of one shot run of ADC at beginning of charging, run continuous
conversion to ensure that all charging-related values are monitored
properly (input voltage, input current, themperature etc.).

Signed-off-by: Yauhen Kharuzhy <jekhor@gmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-01-11 15:25:01 +01:00
Hangyu Hua
4f260ea553 phonet: refcount leak in pep_sock_accep
commit bcd0f93353 upstream.

sock_hold(sk) is invoked in pep_sock_accept(), but __sock_put(sk) is not
invoked in subsequent failure branches(pep_accept_conn() != 0).

Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
Link: https://lore.kernel.org/r/20211209082839.33985-1-hbh25y@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Aayush Agarwal <aayush.a.agarwal@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-01-11 15:25:01 +01:00
Thomas Toye
6195293460 rndis_host: support Hytera digital radios
commit 29262e1f77 upstream.

Hytera makes a range of digital (DMR) radios. These radios can be
programmed to a allow a computer to control them over Ethernet over USB,
either using NCM or RNDIS.

This commit adds support for RNDIS for Hytera radios. I tested with a
Hytera PD785 and a Hytera MD785G. When these radios are programmed to
set up a Radio to PC Network using RNDIS, an USB interface will be added
with class 2 (Communications), subclass 2 (Abstract Modem Control) and
an interface protocol of 255 ("vendor specific" - lsusb even hints "MSFT
RNDIS?").

This patch is similar to the solution of this StackOverflow user, but
that only works for the Hytera MD785:
https://stackoverflow.com/a/53550858

To use the "Radio to PC Network" functionality of Hytera DMR radios, the
radios need to be programmed correctly in CPS (Hytera's Customer
Programming Software). "Forward to PC" should be checked in "Network"
(under "General Setting" in "Conventional") and the "USB Network
Communication Protocol" should be set to RNDIS.

Signed-off-by: Thomas Toye <thomas@toye.io>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-01-11 15:25:01 +01:00