Commit Graph

988439 Commits

Author SHA1 Message Date
Johannes Berg
d96c2b5944 UPSTREAM: wifi: cfg80211/mac80211: reject bad MBSSID elements
commit 8f033d2bec upstream.

Per spec, the maximum value for the MaxBSSID ('n') indicator is 8,
and the minimum is 1 since a multiple BSSID set with just one BSSID
doesn't make sense (the # of BSSIDs is limited by 2^n).

Limit this in the parsing in both cfg80211 and mac80211, rejecting
any elements with an invalid value.

This fixes potentially bad shifts in the processing of these inside
the cfg80211_gen_new_bssid() function later.

I found this during the investigation of CVE-2022-41674 fixed by the
previous patch.

Bug: 253641805
Fixes: 0b8fb8235b ("cfg80211: Parsing of Multiple BSSID information in scanning")
Fixes: 78ac51f815 ("mac80211: support multi-bssid")
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I7aa0b1a425fcf3a7797e83afa8ad6dd68b283b48
2022-10-24 16:48:42 +01:00
Johannes Berg
4ae8e2c20f UPSTREAM: wifi: cfg80211: fix u8 overflow in cfg80211_update_notlisted_nontrans()
commit aebe9f4639 upstream.

In the copy code of the elements, we do the following calculation
to reach the end of the MBSSID element:

	/* copy the IEs after MBSSID */
	cpy_len = mbssid[1] + 2;

This looks fine, however, cpy_len is a u8, the same as mbssid[1],
so the addition of two can overflow. In this case the subsequent
memcpy() will overflow the allocated buffer, since it copies 256
bytes too much due to the way the allocation and memcpy() sizes
are calculated.

Fix this by using size_t for the cpy_len variable.

This fixes CVE-2022-41674.

Bug: 253641805
Reported-by: Soenke Huster <shuster@seemoo.tu-darmstadt.de>
Tested-by: Soenke Huster <shuster@seemoo.tu-darmstadt.de>
Fixes: 0b8fb8235b ("cfg80211: Parsing of Multiple BSSID information in scanning")
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I70d3a1188609751797cbabe905028d92d1700f17
2022-10-24 16:48:42 +01:00
Minchan Kim
6e0df30312 ANDROID: Update the ABI representation
2 function symbol(s) added
  'int __traceiter_android_vh_bh_lru_install(void *, struct page *, bool *)'
  'int __traceiter_android_vh_skip_lru_disable(void *, bool *)'

2 variable symbol(s) added
  'struct tracepoint __tracepoint_android_vh_bh_lru_install'
  'struct tracepoint __tracepoint_android_vh_skip_lru_disable'

Bug: 238728493
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: I8969b67398496e69a816ad8cd5af081e2e90dbff
2022-10-21 09:49:34 -07:00
Minchan Kim
74e2ea264c ANDROID: vendor hook to control bh_lru and lru_cache_disable
Add vendor hook for bh_lru and lru_cache_disable

Bug: 238728493
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: I81bfad317cf6e8633186ebb3238644306d7a102d
2022-10-21 09:18:15 -07:00
Minchan Kim
f45d10e83b ANDROID: Update the ABI representation
3 function symbol(s) added
  'int __traceiter_android_vh_zap_pte_range_tlb_end(void *, void *)'
  'int __traceiter_android_vh_zap_pte_range_tlb_force_flush(void *, struct page *, bool *)'
  'int __traceiter_android_vh_zap_pte_range_tlb_start(void *, void *)'

3 variable symbol(s) added
  'struct tracepoint __tracepoint_android_vh_zap_pte_range_tlb_end'
  'struct tracepoint __tracepoint_android_vh_zap_pte_range_tlb_force_flush'
  'struct tracepoint __tracepoint_android_vh_zap_pte_range_tlb_start'

Bug: 238728493
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: Ic05e935faca01f8241af395726145966237708b4
2022-10-20 16:04:14 +00:00
Minchan Kim
d257ef6764 ANDROID: vendor hook for TLB batching control
Add vendor hook for flushing TLB batching in zap_pte_range.

Bug: 238728493
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: If2de5f070dd7b76624961f5a91440bf69a99ca2d
2022-10-20 16:04:14 +00:00
Helge Deller
2823b3889d UPSTREAM: fbcon: Prevent that screen size is smaller than font size
commit e64242caef upstream.

We need to prevent that users configure a screen size which is smaller than the
currently selected font size. Otherwise rendering chars on the screen will
access memory outside the graphics memory region.

This patch adds a new function fbcon_modechange_possible() which
implements this check and which later may be extended with other checks
if necessary.  The new function is called from the FBIOPUT_VSCREENINFO
ioctl handler in fbmem.c, which will return -EINVAL if userspace asked
for a too small screen size.

Signed-off-by: Helge Deller <deller@gmx.de>
Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: stable@vger.kernel.org # v5.4+
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Bug: b81212828a
Signed-off-by: Todd Kjos <tkjos@google.com>
Change-Id: I6ac4cce2aeea4dcca222ea2b395cc2baa1008894
2022-10-19 18:49:37 +00:00
Helge Deller
739b963eb8 UPSTREAM: fbcon: Disallow setting font bigger than screen size
commit 65a01e601d upstream.

Prevent that users set a font size which is bigger than the physical screen.
It's unlikely this may happen (because screens are usually much larger than the
fonts and each font char is limited to 32x32 pixels), but it may happen on
smaller screens/LCD displays.

Signed-off-by: Helge Deller <deller@gmx.de>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: stable@vger.kernel.org # v4.14+
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Bug: b81212828a
Signed-off-by: Todd Kjos <tkjos@google.com>
Change-Id: I47e139779ab835a16d0b6b060e798ad35cad9f9b
2022-10-19 18:49:37 +00:00
Helge Deller
cf3742cba4 UPSTREAM: fbmem: Check virtual screen sizes in fb_set_var()
commit 6c11df58fd upstream.

Verify that the fbdev or drm driver correctly adjusted the virtual
screen sizes. On failure report the failing driver and reject the screen
size change.

Signed-off-by: Helge Deller <deller@gmx.de>
Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: stable@vger.kernel.org # v5.4+
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Bug: b81212828a
Signed-off-by: Todd Kjos <tkjos@google.com>
Change-Id: Ia1a16bfbda7f62f1707a5a54ba774a058698a4e3
2022-10-19 18:49:37 +00:00
Kever Yang
788ba5e9de ANDROID: GKI: Add build for rockchip platform
This patch add build entry for rockchip platform

Bug: 239396464
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
Change-Id: I12a8619505ece318d3c890ab1253798f88780a9e
2022-10-19 16:30:31 +00:00
Minchan Kim
90db4c38b9 ANDROID: Update the ABI representation
1 function symbol(s) added
  'int __traceiter_android_vh_pagevec_drain(void *, struct page *, bool *)'

1 variable symbol(s) added
  'struct tracepoint __tracepoint_android_vh_pagevec_drain'

Bug: 251881967
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: I8a45e6aba2fbbc6a05ec7086f4ce009c57fe15ff
2022-10-18 15:03:17 -07:00
Minchan Kim
2f8253b7e6 ANDROID: vendor hook to control pagevec flush
The pagevec batching causes lru_add_drain_all which is too expensive
sometimes. This patch adds a new vendor hook to drain the pagevec
immediately depending on the page's type.

Bug: 251881967
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: Id17e14e69197993ddad511a40c96e51674c02834
2022-10-18 15:02:45 -07:00
David Brazdil
992b5f98ca ANDROID: KVM: arm64: s2mpu: Add SysMMU_SYNC timeout
The SysMMU_SYNC provides an invalidation-complete signal to the
hypervisor. Currently the hypervisor will wait indefinitely for the SYNC
to set the SYNC_COMP_COMPLETE bit. In practice, this case deadlock as
the hypervisor holds the host lock while waiting for the SYNC.

To avoid deadlock, adjust the algorithm to time out after a given number
of reads of the SYNC_COMP register (new constant SYNC_TIMEOUT_BASE).
This can be a small number as most attempts succeed after a single read
of the SFR.

If the wait-loop times out, the hypervisor will try again, multiplying
the maximum number of SFR reads with SYNC_TIMEOUT_MULTIPLIER each time.
This number was selected to grow quickly, in case there is a lot of DMA
traffic that would be slowing down the SYNC request.

Finally, if the hardware does not set the bit even after
SYNC_MAX_RETRIES, the algorithm will give up to avoid deadlock. The
value was selected so that the worst-case time spent in
__wait_for_invalidation_complete() remains tolerable.

Bug: 250727777
Signed-off-by: David Brazdil <dbrazdil@google.com>
Change-Id: I00098753bcc46a894943bbdb3a61acc3a8e5e5d2
2022-10-17 10:00:03 +00:00
Quentin Perret
19424168db ANDROID: KVM: arm64: Force CMOs with FWB when reclaiming guest pages
__clean_dcache_guest_page() is optimized to elide cache maintenance
operations on CPUs with FWB. The underlying assumption is that FWB is
always used by KVM when available. Although correct in the normal KVM
world, pKVM actively disables FWB for the host stage-2. As such,
omitting CMOs when guest memory is being reclaimed may provide a
malicious host with the ability to read the content of the recently
reclaimed pages.

Fix this by using the lower level kvm_flush_dcache_to_poc() helper
directly from the reclaim path.

Bug: 243501419
Reported-by: Will Deacon <willdeacon@google.com>
Signed-off-by: Quentin Perret <qperret@google.com>
Change-Id: I8e96ef7a8ccab2a59d3df46cd4d1a73190a2f457
2022-10-14 18:30:15 +00:00
Quentin Perret
f177a280b1 ANDROID: KVM: arm64: Fix MMIO guard map error handling
Pierre-Clément reports that the error codes returned by the MMIO guard
map hypercall may end up being incorrectly reported as positive to
callers who interpret them a signed 64-bit integers, as specified in the
SMCCC.

Fix this by storing the return value in a 64-bit variable instead.

Bug: 253586500
Reported-by: Pierre-Clément Tosi <ptosi@google.com>
Signed-off-by: Quentin Perret <qperret@google.com>
Change-Id: I3092856ec1a1fd1648a75c9e4ad4bfebd8830d14
2022-10-14 13:42:37 +00:00
Johannes Weiner
32bef95f91 UPSTREAM: psi: Fix psi state corruption when schedule() races with cgroup move
4117cebf1a ("psi: Optimize task switch inside shared cgroups")
introduced a race condition that corrupts internal psi state. This
manifests as kernel warnings, sometimes followed by bogusly high IO
pressure:

  psi: task underflow! cpu=1 t=2 tasks=[0 0 0 0] clear=c set=0
  (schedule() decreasing RUNNING and ONCPU, both of which are 0)

  psi: incosistent task state! task=2412744:systemd cpu=17 psi_flags=e clear=3 set=0
  (cgroup_move_task() clearing MEMSTALL and IOWAIT, but task is MEMSTALL | RUNNING | ONCPU)

What the offending commit does is batch the two psi callbacks in
schedule() to reduce the number of cgroup tree updates. When prev is
deactivated and removed from the runqueue, nothing is done in psi at
first; when the task switch completes, TSK_RUNNING and TSK_IOWAIT are
updated along with TSK_ONCPU.

However, the deactivation and the task switch inside schedule() aren't
atomic: pick_next_task() may drop the rq lock for load balancing. When
this happens, cgroup_move_task() can run after the task has been
physically dequeued, but the psi updates are still pending. Since it
looks at the task's scheduler state, it doesn't move everything to the
new cgroup that the task switch that follows is about to clear from
it. cgroup_move_task() will leak the TSK_RUNNING count in the old
cgroup, and psi_sched_switch() will underflow it in the new cgroup.

A similar thing can happen for iowait. TSK_IOWAIT is usually set when
a p->in_iowait task is dequeued, but again this update is deferred to
the switch. cgroup_move_task() can see an unqueued p->in_iowait task
and move a non-existent TSK_IOWAIT. This results in the inconsistent
task state warning, as well as a counter underflow that will result in
permanent IO ghost pressure being reported.

Fix this bug by making cgroup_move_task() use task->psi_flags instead
of looking at the potentially mismatching scheduler state.

[ We used the scheduler state historically in order to not rely on
  task->psi_flags for anything but debugging. But that ship has sailed
  anyway, and this is simpler and more robust.

  We previously already batched TSK_ONCPU clearing with the
  TSK_RUNNING update inside the deactivation call from schedule(). But
  that ordering was safe and didn't result in TSK_ONCPU corruption:
  unlike most places in the scheduler, cgroup_move_task() only checked
  task_current() and handled TSK_ONCPU if the task was still queued. ]

bug: b/253347377

Fixes: 4117cebf1a ("psi: Optimize task switch inside shared cgroups")
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20210503174917.38579-1-hannes@cmpxchg.org
(cherry picked from commit d583d360a6)
Change-Id: Id0a292058d4bffb716d8e1496f72139e8d435410
2022-10-13 17:59:37 +00:00
Pat Tjin
e4c738dd13 ANDROID: Update the ABI representation
4 function symbol(s) added
  'int __hid_register_driver(struct hid_driver *, struct module *, const char *)'
  'int hid_hw_start(struct hid_device *, unsigned int)'
  'int hid_open_report(struct hid_device *)'
  'void hid_unregister_driver(struct hid_driver *)'

Bug: 246795245
Signed-off-by: Pat Tjin <pattjin@google.com>
Change-Id: Ic9a4187a7215e5678b8196fad4d4350802d77a10
2022-10-12 19:01:24 +00:00
Lee Jones
07e046b996 BACKPORT: HID: steam: Prevent NULL pointer dereference in steam_{recv,send}_report
commit cd11d1a611 upstream.

It is possible for a malicious device to forgo submitting a Feature
Report.  The HID Steam driver presently makes no prevision for this
and de-references the 'struct hid_report' pointer obtained from the
HID devices without first checking its validity.  Let's change that.

Bug: 223455965
Cc: Jiri Kosina <jikos@kernel.org>
Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: linux-input@vger.kernel.org
Fixes: c164d6abf3 ("HID: add driver for Valve Steam Controller")
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: Ica12507b87309a7c46b4cab6fcfe4499cd96f45d
2022-10-11 11:25:48 +01:00
Quentin Perret
b366878684 ANDROID: KVM: arm64: Fix MMIO guard unmap
Pierre-Clément reports that the MMIO guard unmap hypercall exposed to
protected guests returns an error upon success. Indeed,
SMCCC_RET_SUCCESS is returned only if __pkvm_remove_ioguard_page()
failed, which doesn't match the expected behaviour.

Fix this by returning SMCCC_RET_INVALID_PARAMETER instead.

Bug: 251426790
Reported-by: Pierre-Clément Tosi <ptosi@google.com>
Signed-off-by: Quentin Perret <qperret@google.com>
Change-Id: Id746fa7d5d3a03ee5df6d114a07240822a0be93b
2022-10-07 12:27:51 +00:00
Stephan Müller
befd3e393e UPSTREAM: crypto: jitter - add oversampling of noise source
The output n bits can receive more than n bits of min entropy, of course,
but the fixed output of the conditioning function can only asymptotically
approach the output size bits of min entropy, not attain that bound.
Random maps will tend to have output collisions, which reduces the
creditable output entropy (that is what SP 800-90B Section 3.1.5.1.2
attempts to bound).

The value "64" is justified in Appendix A.4 of the current 90C draft,
and aligns with NIST's in "epsilon" definition in this document, which is
that a string can be considered "full entropy" if you can bound the min
entropy in each bit of output to at least 1-epsilon, where epsilon is
required to be <= 2^(-32).

Note, this patch causes the Jitter RNG to cut its performance in half in
FIPS mode because the conditioning function of the LFSR produces 64 bits
of entropy in one block. The oversampling requires that additionally 64
bits of entropy are sampled from the noise source. If the conditioner is
changed, such as using SHA-256, the impact of the oversampling is only
one fourth, because for the 256 bit block of the conditioner, only 64
additional bits from the noise source must be sampled.

This patch is derived from the user space jitterentropy-library.

Signed-off-by: Stephan Mueller <smueller@chronox.de>
Reviewed-by: Simo Sorce <simo@redhat.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Bug: 188620248
(cherry picked from commit 908dffaf88)
Change-Id: I7ae1fe58c1b5ea5f206a8f3675f0c20e255a97ec
Signed-off-by: Eric Biggers <ebiggers@google.com>
2022-10-07 08:41:13 +00:00
Rick Yiu
6ed90e9805 ANDROID: Update the ABI representation
1 function symbol(s) added
  'int __traceiter_android_vh_rebuild_root_domains_bypass(void *, bool, bool *)'

1 variable symbol(s) added
  'struct tracepoint __tracepoint_android_vh_rebuild_root_domains_bypass'

Bug: 238390134
Signed-off-by: Rick Yiu <rickyiu@google.com>
Change-Id: Ic03880e8ad87d07ce3560a1fd4ba456cdd510ab8
2022-10-06 15:05:37 +00:00
Chao Yu
9a8b45a9e4 FROMGIT: f2fs: support recording stop_checkpoint reason into super_block
This patch supports to record stop_checkpoint error into
f2fs_super_block.s_stop_reason[].

Bug: 247456379
Bug: 246094874
(cherry picked from commit 93523dddd98b9838896277fa9cad238a72214f02
https: //git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev)
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Change-Id: I3e5fb355a7a7413b1e4bb4937791491ca73e6853
2022-10-05 14:04:43 +00:00
Ziyi Cui
800870b6d4 ANDROID: Update the ABI representation
2 function symbol(s) added
  'int __traceiter_android_vh_early_resume_begin(void *, void *)'
  'int __traceiter_android_vh_resume_end(void *, void *)'

2 variable symbol(s) added
  'struct tracepoint __tracepoint_android_vh_early_resume_begin'
  'struct tracepoint __tracepoint_android_vh_resume_end'

Bug: 241946090
Signed-off-by: Ziyi Cui <ziyic@google.com>
Change-Id: Ie131055ec01e31a7b72ccb997215c67f71ce6bdc
2022-10-05 01:28:01 +00:00
Todd Kjos
b6a23be181 ANDROID: Fix for kernelci !CONFIG_SMP break-breaks
ab9c52146f ("ANDROID: cgroup: Add vendor hook for rebuild_root_domains_bypass")
introduced a hook that declared a parameter whose name collided with a
global variable. If !CONFIG_SMP, this global variable is instead a
compile-time constant which causes this error:

include/linux/cpu.h:101:28: error: expected ‘;’, ‘,’ or ‘)’ before numeric constant

Fixes: ab9c52146f ("ANDROID: cgroup: Add vendor hook for rebuild_root_domains_bypass")
Signed-off-by: Todd Kjos <tkjos@google.com>
Change-Id: I7831c5067be2ee548e8f6885eec99ab9085414fa
2022-10-04 23:33:19 +00:00
Paul Lawrence
9bc66fe57c ANDROID: fuse-bpf: set error_in to ENOENT in negative lookup
Bug: 250617797
Test: fuse-test passes, app installs
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I44544f8989d0ddf00a98eaddce5751df6598130f
2022-10-03 10:09:14 -07:00
Paul Lawrence
92fc848ef5 ANDROID: fuse-bpf: Add ability to run ranges of tests to fuse_test
Test: run various range options
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Bug: 248576331
Change-Id: I75bfa9b499b974250d4d3e375537de1807268c47
2022-10-03 10:08:15 -07:00
Duoming Zhou
cd9914280a BACKPORT: NFC: netlink: fix sleep in atomic bug when firmware download timeout
commit 4071bf121d upstream.

There are sleep in atomic bug that could cause kernel panic during
firmware download process. The root cause is that nlmsg_new with
GFP_KERNEL parameter is called in fw_dnld_timeout which is a timer
handler. The call trace is shown below:

BUG: sleeping function called from invalid context at include/linux/sched/mm.h:265
Call Trace:
kmem_cache_alloc_node
__alloc_skb
nfc_genl_fw_download_done
call_timer_fn
__run_timers.part.0
run_timer_softirq
__do_softirq
...

The nlmsg_new with GFP_KERNEL parameter may sleep during memory
allocation process, and the timer handler is run as the result of
a "software interrupt" that should not call any other function
that could sleep.

This patch changes allocation mode of netlink message from GFP_KERNEL
to GFP_ATOMIC in order to prevent sleep in atomic bug. The GFP_ATOMIC
flag makes memory allocation operation could be used in atomic context.

Bug: 245675148
Fixes: 9674da8759 ("NFC: Add firmware upload netlink command")
Fixes: 9ea7187c53 ("NFC: netlink: Rename CMD_FW_UPLOAD to CMD_FW_DOWNLOAD")
Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20220504055847.38026-1-duoming@zju.edu.cn
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I510b617174c0575cc6f438b2edf44f0262f9c09c
2022-10-03 16:53:31 +00:00
Fuad Tabba
e56825d048 ANDROID: KVM: arm64: Initialize ptr auth in protected mode
Ensure that pointer authentication is initialized when the vcpu
is initialized as well, and not only when the vcpu is reset.

Bug: 249192647
Signed-off-by: Fuad Tabba <tabba@google.com>
Change-Id: Ida39a3ee5e6b4b0d3255bfef95601890afd80709
2022-10-03 16:48:20 +00:00
Rick Yiu
ab9c52146f ANDROID: cgroup: Add vendor hook for rebuild_root_domains_bypass
Vendor could decide to bypass this function.

Bug: 238390134
Change-Id: Ia6bc71c7569d21da9ae226e5d8739f97b9ca1a4f
Signed-off-by: Rick Yiu <rickyiu@google.com>
2022-09-30 16:50:45 +00:00
Elliot Berman
8015dd49c0 FROMGIT: KVM: arm64: Ignore kvm-arm.mode if !is_hyp_mode_available()
Ignore kvm-arm.mode if !is_hyp_mode_available(). Specifically, we want
to avoid switching kvm_mode to KVM_MODE_PROTECTED if hypervisor mode is
not available. This prevents "Protected KVM" cpu capability being
reported when Linux is booting in EL1 and would not have KVM enabled.
Reasonably though, we should warn if the command line is requesting a
KVM mode at all if KVM isn't actually available. Allow
"kvm-arm.mode=none" to skip the warning since this would disable KVM
anyway.

Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20220920190658.2880184-1-quic_eberman@quicinc.com

Bug: 249052880
(cherry picked from commit b2a4d007c3
 https://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git next)
Change-Id: I196649fc00537e563a1fab0a22bf23c5b7abe00d
Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
2022-09-30 08:05:27 +00:00
Oleg Matcovschi
5495c19c30 ANDROID: Update the ABI symbol list and xml
1 symbol(s) added
  'bool drm_mode_parse_command_line_for_connector(const char *, const struct drm_connector *, struct drm_cmdline_mode *)'

Bug: 197774385
Signed-off-by: Oleg Matcovschi <omatcovschi@google.com>
Signed-off-by: Will McVicker <willmcvicker@google.com>
Change-Id: If1686604cc37be5698b4a80f574ad1c907d80137
2022-09-30 02:52:58 +00:00
Johannes Berg
9c24cb8704 UPSTREAM: wifi: mac80211_hwsim: use 32-bit skb cookie
commit cc5250cdb4 upstream.

We won't really have enough skbs to need a 64-bit cookie,
and on 32-bit platforms storing the 64-bit cookie into the
void *rate_driver_data doesn't work anyway. Switch back to
using just a 32-bit cookie and uintptr_t for the type to
avoid compiler warnings about all this.

Fixes: 4ee186fa7e ("wifi: mac80211_hwsim: fix race condition in pending packet")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Cc: Jeongik Cha <jeongik@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 6dece5ad6e)
Signed-off-by: Carlos Llamas <cmllamas@google.com>
Bug: 236994625
Change-Id: I81b075297ec2248f706aebc914cd5e2783665bbc
2022-09-29 21:49:40 +00:00
Johannes Berg
80c59100da UPSTREAM: wifi: mac80211_hwsim: add back erroneously removed cast
commit 58b6259d82 upstream.

The robots report that we're now casting to a differently
sized integer, which is correct, and the previous patch
had erroneously removed it.

Reported-by: kernel test robot <lkp@intel.com>
Fixes: 4ee186fa7e ("wifi: mac80211_hwsim: fix race condition in pending packet")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Cc: Jeongik Cha <jeongik@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit d400222f49)
Signed-off-by: Carlos Llamas <cmllamas@google.com>
Bug: 236994625
Change-Id: I4b5cfa77c47d4d03b46600f0b543e27340c228c0
2022-09-29 21:49:40 +00:00
Jeongik Cha
9fafd34f1d UPSTREAM: wifi: mac80211_hwsim: fix race condition in pending packet
commit 4ee186fa7e upstream.

A pending packet uses a cookie as an unique key, but it can be duplicated
because it didn't use atomic operators.

And also, a pending packet can be null in hwsim_tx_info_frame_received_nl
due to race condition with mac80211_hwsim_stop.

For this,
 * Use an atomic type and operator for a cookie
 * Add a lock around the loop for pending packets

Signed-off-by: Jeongik Cha <jeongik@google.com>
Link: https://lore.kernel.org/r/20220704084354.3556326-1-jeongik@google.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit eb8fc4277b)
Signed-off-by: Carlos Llamas <cmllamas@google.com>
Bug: 236994625
Change-Id: Ic6613c8869a51b5de303e40406f023af689b9d64
2022-09-29 21:49:40 +00:00
Leo Chen
d91e7b80d8 ANDROID: Update the ABI representation
1 symbol(s) added
  'void drm_atomic_bridge_chain_disable(struct drm_bridge *, struct drm_atomic_state *)'

Bug: 233709537
Signed-off-by: Leo Chen <yinchiuan@google.com>
Change-Id: I1e3e5c41f3c32404dc25c1f69f447efb3cbafb5d
2022-09-29 03:57:37 +00:00
John Stultz
14e1028389 ANDROID: sched: Fix off-by-one with cpupri MAX_RT_PRIO evaluation
This patch addresses an issue seen where SCHED_FIFO prio 99
tasks were being woken up on a cpu where a long-running softirq
was executing, and the RT task was not being migrated, causing
long (10+ms wakeup latencies).

Prior to upstream commit 934fc3314b ("sched/cpupri: Remap
CPUPRI_NORMAL to MAX_RT_PRIO-1") the task->prio -> cpupri
mapping is a little ackward.

For RT tasks, its calculated as:
  cpupri = MAX_RT_PRIO - prio + 1;

See:
https://android.googlesource.com/kernel/common/+/refs/heads/android13-5.10/kernel/sched/cpupri.c#39

This is added ontop of the also ackward detail that the
task->prio is inverted (RT prio99 -> 0), means the cpupri
mapping for RT tasks goes from 2->101. This makes it easy to
evaluate the cpupri incorrectly.

Which it turns out happened In commit 3adfd8e344 ("ANDROID:
sched: avoid placing RT threads on cores handling softirqs"):
  3adfd8e344%5E%21/

With the lines:
  int task_pri = convert_prio(p->prio);
  bool drop_nopreempts = task_pri <= MAX_RT_PRIO;

Where the added logic to decide to migrate a rt task off of a
cpu depended on this drop_nopreempts being true.

This works properly for rt tasks from prio 99 to 1, but for the
case of task->prio == 0 (userland rt prio 99 tasks) it breaks,
as the cpupri will be MAX_RT_PRIO - 0 + 1, which then gets
checked as <= MAX_RT_PRIO.

This prevents the cpu from being dropped from the scheduling
set and prevents the rt user prio 99 task from migrating, which
results in high priority rt tasks being left on cpus where long
running softirqs are executing, causing long latencies.

This patch fixes the off by one by changing the evaulation
to MAX_RT_PRIO + 1, so that user-prio 99 tasks will also be
migrated if appropriate.

Luckilly this odd cpupri mapping has been fixed upstream, making
this patch no longer necessary in 5.15 and newer kernels.

Fixes: 3adfd8e344 ("ANDROID: sched: avoid placing RT threads on cores handling softirqs")
Signed-off-by: John Stultz <jstultz@google.com>
Change-Id: Ia2db7cd461eb4c90f5850b791de1ae95582f7530
2022-09-28 22:14:40 +00:00
Greg Kroah-Hartman
7a6ea55aa0 Revert "ANDROID: workqueue: add vendor hook for wq lockup information"
This reverts commit 34f087452f.

The hook android_vh_wq_lockup_pool is not used by any vendor, so remove
it to help with merge issues with future LTS releases.

If this is needed by any real user, it can easily be reverted to add it
back and then the symbol should be added to the abi list at the same
time to prevent it from being removed again later.

Bug: 203756332
Bug: 169374262
Cc: Sangmoon Kim <sangmoon.kim@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I84eb7e1abc535a4efecd2b6071ef6d25fa2c1e2e
2022-09-27 20:04:43 +00:00
Jianqun Xu
7b19b0064b UPSTREAM: kernel/irq: export irq_gc_set_wake
Module driver may use irq_gc_set_wake.

Bug: 194515348
Change-Id: I52f43e1dff15d987532395e5151e65419b5904b2
Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
Acked-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20210305080658.2422114-1-jay.xu@rock-chips.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
(cherry picked from commit 024c79520f)
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
2022-09-27 16:41:34 +08:00
Hsiu-Chang Chen
1856a68952 ANDROID: Update the ABI representation
2 symbol(s) added
  'struct user_namespace init_user_ns'
  'bool ns_capable_noaudit(struct user_namespace *, int)'

Bug: 234311675
Signed-off-by: Hsiu-Chang Chen <hsiuchangchen@google.com>
Change-Id: I78851c0ada381095bbac338a331bcd2cc2cd8cde
2022-09-24 13:37:50 +00:00
Paul Lawrence
1bd5344779 ANDROID: fuse-bpf: Add test for lookup postfilter
Test: fuse_test passes
Bug: 219958836
Signed-off-by: Paul Lawrence <paullawrence@google.com>

Change-Id: I04a68af274ecf823a96e2f0ead49f56d2f1c1452
2022-09-23 12:42:02 +00:00
Paul Lawrence
494e7075c9 ANDROID: fuse-bpf: readddir postfilter fixes
Test: fuse_test passes, with appropriate user code directories can be
hidden
Bug: 219958836
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: Ia77d4bf9e63d0dd4535e53e9e07c3216fd4b8430
2022-09-23 12:42:02 +00:00
Bowgo Tsai
8483cc3a75 ANDROID: Enable BUILD_GKI_CERTIFICATION_TOOLS for x86_64 GKI
The tools are required to certify a x86_64 GKI boot.img.

Bug: 241497048
Test: BUILD_CONFIG=common/build.config.gki.x86_64 build/build.sh
Signed-off-by: Bowgo Tsai <bowgotsai@google.com>
Change-Id: I0a34b9c8376cdfd77fb9b58b1b50ac734696672f
(cherry picked from commit 35b34f2880)
2022-09-23 02:24:52 +00:00
Todd Kjos
f813694424 ANDROID: force struct cgroup_taskset to be defined in KMI
struct cgroup_taskset is defined in kernel/cgroup/cgroup-internal.h,
however libabigail is not finding its definition based on the
instantiation of the hooks, so force it to be defined by defining a
dummy exported symbol. Since cgroup_taskset is defined in a
subsystem-private header, create a new vendor_hooks.c file in
kernel/cgroup to define the dummy symbol.

Update the XML with the new type definitions

Bug: 233047575
Signed-off-by: Todd Kjos <tkjos@google.com>
Change-Id: I7a2bf2a722bf5aec0c702f215d572cc8e5336f9a
2022-09-23 01:00:15 +00:00
Todd Kjos
3dc6e416a1 ANDROID: force struct blk_mq_alloc_data to be defined in KMI
There were 3 remaining types directly referenced by vendor
hooks that were not fully-defined in the KMI:

struct blk_mq_alloc_data is defined in block/blk-mq.h, however
libabigail is not finding its definition based on the instantiation
of the hooks, so force it to be defined by defining a dummy exported
symbol. Since blk_mq_alloc_data is defined in a subsystem-private
header, create a new vendor_hooks.c file in block/ to define
the dummy symbol.

Bug: 233047575
Bug: 248263460
Signed-off-by: Todd Kjos <tkjos@google.com>
Change-Id: I6419caba1c6a159b7a64b9d28e983d753393af86
2022-09-23 01:00:15 +00:00
Hongyu Jin
af4d4153ca BACKPORT: erofs: fix use-after-free of on-stack io[]
The root cause is the race as follows:
Thread #1                              Thread #2(irq ctx)

z_erofs_runqueue()
  struct z_erofs_decompressqueue io_A[];
  submit bio A
  z_erofs_decompress_kickoff(,,1)
                                       z_erofs_decompressqueue_endio(bio A)
                                       z_erofs_decompress_kickoff(,,-1)
                                       spin_lock_irqsave()
                                       atomic_add_return()
  io_wait_event()	-> pending_bios is already 0
  [end of function]
                                       wake_up_locked(io_A[]) // crash

Referenced backtrace in kernel 5.4:

[   10.129422] Unable to handle kernel paging request at virtual address eb0454a4
[   10.364157] CPU: 0 PID: 709 Comm: getprop Tainted: G        WC O      5.4.147-ab09225 #1
[   11.556325] [<c01b33b8>] (__wake_up_common) from [<c01b3300>] (__wake_up_locked+0x40/0x48)
[   11.565487] [<c01b3300>] (__wake_up_locked) from [<c044c8d0>] (z_erofs_vle_unzip_kickoff+0x6c/0xc0)
[   11.575438] [<c044c8d0>] (z_erofs_vle_unzip_kickoff) from [<c044c854>] (z_erofs_vle_read_endio+0x16c/0x17c)
[   11.586082] [<c044c854>] (z_erofs_vle_read_endio) from [<c06a80e8>] (clone_endio+0xb4/0x1d0)
[   11.595428] [<c06a80e8>] (clone_endio) from [<c04a1280>] (blk_update_request+0x150/0x4dc)
[   11.604516] [<c04a1280>] (blk_update_request) from [<c06dea28>] (mmc_blk_cqe_complete_rq+0x144/0x15c)
[   11.614640] [<c06dea28>] (mmc_blk_cqe_complete_rq) from [<c04a5d90>] (blk_done_softirq+0xb0/0xcc)
[   11.624419] [<c04a5d90>] (blk_done_softirq) from [<c010242c>] (__do_softirq+0x184/0x56c)
[   11.633419] [<c010242c>] (__do_softirq) from [<c01051e8>] (irq_exit+0xd4/0x138)
[   11.641640] [<c01051e8>] (irq_exit) from [<c010c314>] (__handle_domain_irq+0x94/0xd0)
[   11.650381] [<c010c314>] (__handle_domain_irq) from [<c04fde70>] (gic_handle_irq+0x50/0xd4)
[   11.659641] [<c04fde70>] (gic_handle_irq) from [<c0101b70>] (__irq_svc+0x70/0xb0)

Bug: 246657836
Change-Id: Ieebf1c5abb48723538d05a5e65b5179a382dab3f
(cherry picked from commit 60b3005011)
[Hongyu: Resolved minor conflict in fs/erofs/zdata.c ]
Signed-off-by: Hongyu Jin <hongyu.jin@unisoc.com>
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Link: https://lore.kernel.org/r/20220401115527.4935-1-hongyu.jin.cn@gmail.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
2022-09-22 19:09:34 +00:00
Amit Pundir
aec8f79a0f ANDROID: GKI: db845c: Update symbols list and ABI
android13-5.10 is broken on Dragonboard 845c because of
recently added snd_pcm_* symbols.

So updated the symbols list by running:
  "BUILD_CONFIG=common/build.config.db845c \
    KMI_SYMBOL_LIST_ADD_ONLY=1 build/build_abi.sh -s"

And the abi_gki_aarch64 ABI by running:
  "BUILD_CONFIG=common/build.config.gki.aarch64 \
    ABI_DEFINITION=abi_gki_aarch64.xml KMI_SYMBOL_LIST_ADD_ONLY=1 \
     build/build_abi.sh --update --print-report"

========================================================
ABI DIFFERENCES HAVE BEEN DETECTED!

3 symbol(s) added
  'int snd_pcm_create_iec958_consumer_default(u8 *, size_t)'
  'int snd_pcm_fill_iec958_consumer(struct snd_pcm_runtime *, u8 *, size_t)'
  'int snd_pcm_fill_iec958_consumer_hw_params(struct snd_pcm_hw_params *, u8 *, size_t)'
========================================================

Bug: 146449535
Fixes: 8de9ae8605 ("UPSTREAM: ALSA: iec958: Split status creation and fill")
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
Change-Id: I0ae0be501faea03f67feb9358b8e44f70571f2df
2022-09-21 21:11:42 +05:30
Yifan Hong
7b87b9ddb4 ANDROID: kleaf: Explicit list of ABI files.
In BUILD.bazel, explicitly list abi_definition,
kmi_symbol_list, and additional_kmi_symbol_lists.
This avoids using the glob expression which may
accidentally match editor backup files.

Bug: 246344503
Test: TH
Change-Id: I3cd494dee47b68a0fe7c3c80dd379b5af6b060fe
Signed-off-by: Yifan Hong <elsk@google.com>
2022-09-20 19:19:36 +00:00
Weichao Guo
d25aa0dbae FROMLIST: f2fs: let FI_OPU_WRITE override FADVISE_COLD_BIT
Cold files may be fragmented due to SSR, defragment is needed as
sequential reads are dominant scenarios of these files. FI_OPU_WRITE
should override FADVISE_COLD_BIT to avoid defragment fails.

Bug: 246903585

Signed-off-by: Weichao Guo <guoweichao@oppo.com>
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Weichao Guo <guoweichao@oppo.corp-partner.google.com>
Link: https://lore.kernel.org/all/YxlTQ3H+PPKcvpyc@google.com/T/
Change-Id: I52ab86a15ec275772c5356bfc985803bbdde4408
2022-09-20 18:22:45 +00:00
Tadeusz Struk
5625e355a9 ANDROID: incfs: Add check for ATTR_KILL_SUID and ATTR_MODE in incfs_setattr
Add an explicite check for ATTR_KILL_SUID and ATTR_MODE in incfs_setattr.
Both of these attributes can not be set at the same time, otherwise
notify_change() function will check it and invoke BUG(), crashing
the system.

Bug: 243394930

Signed-off-by: Tadeusz Struk <tadeusz.struk@linaro.org>
Change-Id: I91080d68efbd62f1441e20a5c02feef3d1b06e4e
2022-09-20 18:12:59 +00:00
Bart Van Assche
0cf7d9ce9f Revert "UPSTREAM: scsi: ufs: core: Reduce the power mode change timeout"
This reverts commit 3d35c6b91d.

Patch "scsi: ufs: core: Reduce the power mode change timeout" caused a
spike in the number of UFS suspend timeouts. Hence revert that change
and also later UFS driver changes.

Bug: b/246990788
Change-Id: I5aae929f0598020dc5e7c440946eb0d2101b07cc
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-09-19 15:20:50 -07:00