Commit Graph

1156013 Commits

Author SHA1 Message Date
Joel Fernandes (Google)
52193e9489 UPSTREAM: rcu/rcutorture: Use call_rcu_hurry() where needed
call_rcu() changes to save power will change the behavior of rcutorture
tests. Use the call_rcu_hurry() API instead which reverts to the old
behavior.

[ paulmck: Apply s/call_rcu_flush/call_rcu_hurry/ feedback from Tejun Heo. ]

Reported-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
(cherry picked from commit 405d8e91f0)

Bug: 258241771
Signed-off-by: Joel Fernandes <joelaf@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/4909035
Reviewed-by: Sean Paul <sean@poorly.run>
Reviewed-by: Vineeth Pillai <vineethrp@google.com>
Signed-off-by: Qais Yousef <qyousef@google.com>
Change-Id: I8008990dfe7e64f511aada006e736b15cdd0d61e
2024-01-19 00:10:44 +00:00
Joel Fernandes (Google)
83f8ba569f UPSTREAM: rcu/rcuscale: Use call_rcu_hurry() for async reader test
rcuscale uses call_rcu() to queue async readers. With recent changes to
save power, the test will have fewer async readers in flight. Use the
call_rcu_hurry() API instead to revert to the old behavior.

[ paulmck: Apply s/call_rcu_flush/call_rcu_hurry/ feedback from Tejun Heo. ]

Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
(cherry picked from commit 723df859d8)

Bug: 258241771
Signed-off-by: Joel Fernandes <joelaf@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/4909034
Reviewed-by: Sean Paul <sean@poorly.run>
Reviewed-by: Vineeth Pillai <vineethrp@google.com>
Signed-off-by: Qais Yousef <qyousef@google.com>
Change-Id: I680dacb44e81e210e2e4455f28e50b9b516222a8
2024-01-19 00:10:44 +00:00
Joel Fernandes (Google)
9b625f4978 UPSTREAM: rcu/sync: Use call_rcu_hurry() instead of call_rcu
call_rcu() changes to save power will slow down rcu sync. Use the
call_rcu_hurry() API instead which reverts to the old behavior.

[ paulmck: Apply s/call_rcu_flush/call_rcu_hurry/ feedback from Tejun Heo. ]

Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
(cherry picked from commit 7651d6b250)

Bug: 258241771
Signed-off-by: Joel Fernandes <joelaf@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/4909033
Reviewed-by: Vineeth Pillai <vineethrp@google.com>
Reviewed-by: Sean Paul <sean@poorly.run>
Signed-off-by: Qais Yousef <qyousef@google.com>
Change-Id: I5123ba52f47676305dbcfa1233bf3b41f140766c
2024-01-19 00:10:44 +00:00
Vineeth Pillai
c570c8fea3 BACKPORT: rcu: Shrinker for lazy rcu
The shrinker is used to speed up the free'ing of memory potentially held
by RCU lazy callbacks. RCU kernel module test cases show this to be
effective. Test is introduced in a later patch.

Signed-off-by: Vineeth Pillai <vineeth@bitbyteword.org>
Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
(cherry picked from commit c945b4da7a)

Conflicts:
   kernel/rcu/tree_nocb.h

Trivial conflict due to: "rcu/nocb: Add an option to offload all CPUs on boot"

Bug: 258241771
Signed-off-by: Joel Fernandes <joelaf@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/4909032
Reviewed-by: Vineeth Pillai <vineethrp@google.com>
Signed-off-by: Qais Yousef <qyousef@google.com>
Change-Id: I6a73a9dae79ff35feca37abe2663e55a0f46dda8
2024-01-19 00:10:44 +00:00
Joel Fernandes (Google)
4957579439 UPSTREAM: rcu: Refactor code a bit in rcu_nocb_do_flush_bypass()
This consolidates the code a bit and makes it cleaner. Functionally it
is the same.

Reported-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
(cherry picked from commit 3d222a0c0c)

Bug: 258241771
Signed-off-by: Joel Fernandes <joelaf@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/4909031
Reviewed-by: Sean Paul <sean@poorly.run>
Reviewed-by: Vineeth Pillai <vineethrp@google.com>
Signed-off-by: Qais Yousef <qyousef@google.com>
Change-Id: I8422c7138edd6a476fc46374beefdf46dd76b8b0
2024-01-19 00:10:44 +00:00
Joel Fernandes (Google)
66a832fe38 UPSTREAM: rcu: Make call_rcu() lazy to save power
Implement timer-based RCU callback batching (also known as lazy
callbacks). With this we save about 5-10% of power consumed due
to RCU requests that happen when system is lightly loaded or idle.

By default, all async callbacks (queued via call_rcu) are marked
lazy. An alternate API call_rcu_hurry() is provided for the few users,
for example synchronize_rcu(), that need the old behavior.

The batch is flushed whenever a certain amount of time has passed, or
the batch on a particular CPU grows too big. Also memory pressure will
flush it in a future patch.

To handle several corner cases automagically (such as rcu_barrier() and
hotplug), we re-use bypass lists which were originally introduced to
address lock contention, to handle lazy CBs as well. The bypass list
length has the lazy CB length included in it. A separate lazy CB length
counter is also introduced to keep track of the number of lazy CBs.

[ paulmck: Fix formatting of inline call_rcu_lazy() definition. ]
[ paulmck: Apply Zqiang feedback. ]
[ paulmck: Apply s/call_rcu_flush/call_rcu_hurry/ feedback from Tejun Heo. ]

Suggested-by: Paul McKenney <paulmck@kernel.org>
Acked-by: Frederic Weisbecker <frederic@kernel.org>
Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
(cherry picked from commit 3cb278e73b)

Bug: 258241771
Signed-off-by: Joel Fernandes <joelaf@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/4909030
Reviewed-by: Vineeth Pillai <vineethrp@google.com>
Signed-off-by: Qais Yousef <qyousef@google.com>
Change-Id: I557d5af2a5d317bd66e9ec55ed40822bb5c54390
2024-01-19 00:10:44 +00:00
Frederic Weisbecker
4fb09fb4f7 UPSTREAM: rcu: Fix missing nocb gp wake on rcu_barrier()
In preparation for RCU lazy changes, wake up the RCU nocb gp thread if
needed after an entrain.  This change prevents the RCU barrier callback
from waiting in the queue for several seconds before the lazy callbacks
in front of it are serviced.

Reported-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
(cherry picked from commit b8f7aca3f0)

Bug: 258241771
Signed-off-by: Joel Fernandes <joelaf@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/4909029
Reviewed-by: Sean Paul <sean@poorly.run>
Reviewed-by: Vineeth Pillai <vineethrp@google.com>
Signed-off-by: Qais Yousef <qyousef@google.com>
Change-Id: Ib55c5886764b74df22531eca35f076ef7acc08dd
2024-01-19 00:10:44 +00:00
Joel Fernandes (Google)
64c59ad2c3 UPSTREAM: rcu: Fix late wakeup when flush of bypass cblist happens
When the bypass cblist gets too big or its timeout has occurred, it is
flushed into the main cblist. However, the bypass timer is still running
and the behavior is that it would eventually expire and wake the GP
thread.

Since we are going to use the bypass cblist for lazy CBs, do the wakeup
soon as the flush for "too big or too long" bypass list happens.
Otherwise, long delays can happen for callbacks which get promoted from
lazy to non-lazy.

This is a good thing to do anyway (regardless of future lazy patches),
since it makes the behavior consistent with behavior of other code paths
where flushing into the ->cblist makes the GP kthread into a
non-sleeping state quickly.

[ Frederic Weisbecker: Changes to avoid unnecessary GP-thread wakeups plus
		    comment changes. ]

Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
(cherry picked from commit b50606f35f)

Bug: 258241771
Signed-off-by: Joel Fernandes <joelaf@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/4909028
Reviewed-by: Vineeth Pillai <vineethrp@google.com>
Reviewed-by: Sean Paul <sean@poorly.run>
Signed-off-by: Qais Yousef <qyousef@google.com>
Change-Id: If8da96d7ba6ed90a2a70f7d56f7bb03af44fd649
2024-01-19 00:10:44 +00:00
Vamsidhar reddy Gaddam
0799ace265 ANDROID: Update the ABI symbol list
Adding the following symbols:
 - dma_buf_map_attachment_unlocked
 - dma_buf_unmap_attachment_unlocked
 - register_kretprobe
 - unregister_kretprobe

Bug: 315267052
Change-Id: I676d5634d8e7903a12bfa2c036ce938272382aef
Signed-off-by: Vamsidhar reddy Gaddam <gvamsi@google.com>
2024-01-18 23:58:21 +00:00
dae.seo
65db2f8ed3 ANDROID: GKI: add GKI symbol list for Exynosauto SoC
This patch adds GKI symbol list for Exynosauto Soc.
We need to add 1 function(flush_signals) symbol to send buffer
to other domains.

1 function symbol(s) added
  'void flush_signals(struct task_struct*)'

Bug: 320368458
Signed-off-by: Daehyun Seo <dae.seo@samsung.com>
Change-Id: I66a9264b70dc24f30029b413077363996b3339cd
2024-01-18 23:42:51 +00:00
Yabin Cui
cfe8cce4e8 UPSTREAM: coresight: tmc: Don't enable TMC when it's not ready.
If TMC ETR is enabled without being ready, in later use we may
see AXI bus errors caused by accessing invalid addresses.

Bug: 256184860
Change-Id: I9c0b8c7af63a2e2e7469a8537bc721ec6ae6679c
Signed-off-by: Yabin Cui <yabinc@google.com>
[ Tweak error message ]
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Link: https://lore.kernel.org/r/20230127231001.1920947-1-yabinc@google.com
(cherry picked from commit 669c461423)
2024-01-17 15:07:33 -08:00
Pablo Neira Ayuso
899194d7e9 UPSTREAM: netfilter: nf_tables: bail out on mismatching dynset and set expressions
[ Upstream commit 3701cd390fd731ee7ae8b8006246c8db82c72bea ]

If dynset expressions provided by userspace is larger than the declared
set expressions, then bail out.

Bug: 316085841
Fixes: 48b0ae046e ("netfilter: nftables: netlink support for several set element expressions")
Reported-by: Xingyuan Mo <hdthky0@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit cf5f113c41)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I4bd3f7e9148d4bc12bbc67ecdd605c2957eb8010
2024-01-17 16:48:40 +00:00
songfeng
e6712ed4f0 ANDROID: ABI: Update oplus symbol list
5 function symbol(s) added
  'int __traceiter_android_vh_binder_has_special_work_ilocked(void*, struct binder_thread*, bool, bool*)'
  'int __traceiter_android_vh_binder_ioctl_end(void*, struct task_struct*, unsigned int, unsigned long, struct binder_thread*, struct binder_proc*, int*)'
  'int __traceiter_android_vh_binder_looper_exited(void*, struct binder_thread*, struct binder_proc*)'
  'int __traceiter_android_vh_binder_spawn_new_thread(void*, struct binder_thread*, struct binder_proc*, bool*)'
  'int __traceiter_android_vh_binder_select_special_worklist(void*, struct list_head**, struct binder_thread*, struct binder_proc*, int, bool*)'

5 variable symbol(s) added
  'struct tracepoint __tracepoint_android_vh_binder_has_special_work_ilocked'
  'struct tracepoint __tracepoint_android_vh_binder_ioctl_end'
  'struct tracepoint __tracepoint_android_vh_binder_looper_exited'
  'struct tracepoint __tracepoint_android_vh_binder_spawn_new_thread'
  'struct tracepoint __tracepoint_android_vh_binder_select_special_worklist'

Bug: 318782978
Change-Id: I0598a329a4d4c455450c9d47973103f04f9e3790
Signed-off-by: songfeng <songfeng@oppo.com>
2024-01-17 02:22:48 +00:00
songfeng
24bb8fc82e ANDROID: vendor_hooks: add hooks in driver/android/binder.c
Add hooks to support oem's binder feature of improving certain
scenarios sched priority by moving these scenarios' work to
a fixed binder thread.

Add the following new vendor hooks to drivers/android/binder.c:
1 trace_android_vh_binder_spawn_new_thread
	in our os, some binder_transaction will be marked as vip flag,
	it can be named vip transaction, the binder_work within the vip
	transaction can be named vip work.
	here will force a thread (named vip thread) to be spawned and
	skip the normal conditions to spawn a thread. vip thread will
	just select vip transaction to process.
2 trace_android_vh_binder_ioctl_end
	in our os, in binder_proc, about binder threads,special thread
	(called vip thread) will work for special binder_transaction
	(called vip transaction).
	here  will expand one ioctl cmd for binder driver, it will
	set the max count about special thread (called vip thread) in
	binder_proc, and if it has vip thread in the binder_proc.
3 trace_android_vh_binder_looper_exited
	while BC_REGISTER_LOOPER cmd, will set special thread as vip
	thread. the flag saved in binder_thread:looper
	here will unset the vip flag saved in binder_thread,
	while BC_EXIT_LOOPER cmd,  if the thread is vip thread(reference
	above about vip thread)
4 trace_android_vh_binder_has_special_work_ilocked
	for special binder thread(called vip thread), it will deal with
	special binder_work (called vip work) within special transaction
	(call vip transaction),
	here, if the thread is vip thread, it will check the vip work if
	exist or not.
5 trace_android_vh_binder_select_special_worklist
	for special binder thread(called vip thread), it will select the
	worklist for special binder_work(called vip work) within special
	binder_transaction(called vip transaction)
	here, it will make sure the selected worklist, the head of it is
	vip work within vip transaction

Bug: 318782978

Change-Id: I8e544d9be2644a6144a9cfbd477e087d46b0073f
Signed-off-by: songfeng <songfeng@oppo.com>
2024-01-17 02:22:48 +00:00
Norihiko Hama
55930b39ca ANDROID: GKI: Update honda symbol list for xt_LOG
9 function symbol(s) added
  'int nf_log_buf_add(struct nf_log_buf*, const char*, ...)'
  'void nf_log_buf_close(struct nf_log_buf*)'
  'struct nf_log_buf* nf_log_buf_open()'
  'int nf_log_register(u_int8_t, struct nf_logger*)'
  'int nf_log_set(struct net*, u_int8_t, const struct nf_logger*)'
  'void nf_log_unregister(struct nf_logger*)'
  'void nf_log_unset(struct net*, const struct nf_logger*)'
  'int nf_logger_find_get(int, enum nf_log_type)'
  'void nf_logger_put(int, enum nf_log_type)'

Bug: 319451108

Change-Id: I300644b6a9221874e29ff97bd2937361c353af03
Signed-off-by: Norihiko Hama <Norihiko.Hama@alpsalpine.com>
2024-01-17 01:26:43 +00:00
Norihiko Hama
3160b69e20 ANDROID: GKI: Update honda symbol list for ebt filter
2 function symbol(s) added
  'void arp_send(int, int, __be32, struct net_device*, __be32, const unsigned char*, const unsigned char*, const unsigned char*)'
  'void nf_log_packet(struct net*, u_int8_t, unsigned int, const struct sk_buff*, const struct net_device*, const struct net_device*, const struct nf_loginfo*, const char*, ...)'

1 variable symbol(s) added
  'int sysctl_nf_log_all_netns'

Bug: 319451108

Change-Id: I5194eb32b01d66db1744c17e45ff1e1451a9f350
Signed-off-by: Norihiko Hama <Norihiko.Hama@alpsalpine.com>
2024-01-17 01:26:43 +00:00
Norihiko Hama
4dc7f98815 ANDROID: GKI: Update honda symbol list for ebtables
18 function symbol(s) added
  'void __audit_log_nfcfg(const char*, u8, unsigned int, enum audit_nfcfgop, gfp_t)'
  'int nf_register_sockopt(struct nf_sockopt_ops*)'
  'void nf_unregister_sockopt(struct nf_sockopt_ops*)'
  'void* vmalloc_node(unsigned long, int)'
  'int xt_check_match(struct xt_mtchk_param*, unsigned int, u16, bool)'
  'int xt_check_target(struct xt_tgchk_param*, unsigned int, u16, bool)'
  'int xt_compat_add_offset(u_int8_t, unsigned int, int)'
  'int xt_compat_calc_jump(u_int8_t, unsigned int)'
  'void xt_compat_flush_offsets(u_int8_t)'
  'int xt_compat_init_offsets(u8, unsigned int)'
  'void xt_compat_lock(u_int8_t)'
  'int xt_compat_match_offset(const struct xt_match*)'
  'int xt_compat_target_offset(const struct xt_target*)'
  'void xt_compat_unlock(u_int8_t)'
  'int xt_data_to_user(void*, const void*, int, int, int)'
  'struct xt_match* xt_find_match(u8, const char*, u8)'
  'struct xt_match* xt_request_find_match(uint8_t, const char*, uint8_t)'
  'struct xt_target* xt_request_find_target(u8, const char*, u8)'

1 variable symbol(s) added
  'u32 audit_enabled'

Bug: 319451108

Change-Id: I5e8b449b63100da21939b7f74c8db1df0eae1947
Signed-off-by: Norihiko Hama <Norihiko.Hama@alpsalpine.com>
2024-01-17 01:26:43 +00:00
Norihiko Hama
39a0823340 ANDROID: GKI: Update honda symbol list for net scheduler
31 function symbol(s) added
  'int __skb_vlan_pop(struct sk_buff*, u16*)'
  'struct flow_rule* flow_rule_alloc(unsigned int)'
  'clock_t jiffies_to_clock_t(unsigned long)'
  'int skb_eth_pop(struct sk_buff*)'
  'int skb_eth_push(struct sk_buff*, const unsigned char*, const unsigned char*)'
  'void skb_flow_dissect_ct(const struct sk_buff*, struct flow_dissector*, void*, u16*, size_t, bool, u16)'
  'void skb_flow_dissect_hash(const struct sk_buff*, struct flow_dissector*, void*)'
  'void skb_flow_dissect_meta(const struct sk_buff*, struct flow_dissector*, void*)'
  'void skb_flow_dissect_tunnel_info(const struct sk_buff*, struct flow_dissector*, void*)'
  'void skb_flow_dissector_init(struct flow_dissector*, const struct flow_dissector_key*, unsigned int)'
  'int skb_vlan_pop(struct sk_buff*)'
  'int skb_vlan_push(struct sk_buff*, __be16, u16)'
  'int tc_setup_cb_add(struct tcf_block*, struct tcf_proto*, enum tc_setup_type, void*, bool, u32*, unsigned int*, bool)'
  'int tc_setup_cb_call(struct tcf_block*, enum tc_setup_type, void*, bool, bool)'
  'int tc_setup_cb_destroy(struct tcf_block*, struct tcf_proto*, enum tc_setup_type, void*, bool, u32*, unsigned int*, bool)'
  'int tc_setup_cb_reoffload(struct tcf_block*, struct tcf_proto*, bool, flow_setup_cb_t*, enum tc_setup_type, void*, void*, u32*, unsigned int*)'
  'int tcf_action_check_ctrlact(int, struct tcf_proto*, struct tcf_chain**, struct netlink_ext_ack*)'
  'struct tcf_chain* tcf_action_set_ctrlact(struct tc_action*, int, struct tcf_chain*)'
  'void tcf_action_update_stats(struct tc_action*, u64, u64, u64, bool)'
  'void tcf_chain_put_by_act(struct tcf_chain*)'
  'unsigned int tcf_exts_num_actions(struct tcf_exts*)'
  'int tcf_exts_terse_dump(struct sk_buff*, struct tcf_exts*)'
  'int tcf_generic_walker(struct tc_action_net*, struct sk_buff*, struct netlink_callback*, int, const struct tc_action_ops*, struct netlink_ext_ack*)'
  'int tcf_idr_check_alloc(struct tc_action_net*, u32*, struct tc_action**, int)'
  'void tcf_idr_cleanup(struct tc_action_net*, u32)'
  'int tcf_idr_create_from_flags(struct tc_action_net*, u32, struct nlattr*, struct tc_action**, const struct tc_action_ops*, int, u32)'
  'int tcf_idr_release(struct tc_action*, bool)'
  'int tcf_idr_search(struct tc_action_net*, struct tc_action**, u32)'
  'void tcf_idrinfo_destroy(const struct tc_action_ops*, struct tcf_idrinfo*)'
  'int tcf_register_action(struct tc_action_ops*, struct pernet_operations*)'
  'int tcf_unregister_action(struct tc_action_ops*, struct pernet_operations*)'

Bug: 319451108

Change-Id: I8cd204b87577972e35d29c0a992c8b6c0adefd58
Signed-off-by: Norihiko Hama <Norihiko.Hama@alpsalpine.com>
2024-01-17 01:26:43 +00:00
Norihiko Hama
dd0098bdb4 ANDROID: GKI: Update honda symbol list for led-trigger
2 function symbol(s) added
  'void led_blink_set_oneshot(struct led_classdev*, unsigned long*, unsigned long*, int)'
  'void led_stop_software_blink(struct led_classdev*)'

Bug: 319451108

Change-Id: I25f44f730780d41dc68cfb8697844e12fb4ea189
Signed-off-by: Norihiko Hama <Norihiko.Hama@alpsalpine.com>
2024-01-17 01:26:43 +00:00
Norihiko Hama
66a20ed4b8 ANDROID: GKI: Add initial symbol list for honda
Initial add for oem specific symbol list

2 function symbol(s) added
  'void* devres_find(struct device*, dr_release_t, dr_match_t, void*)'
  'bool input_device_enabled(struct input_dev*)'

Bug: 319451108

Change-Id: I09d922aa61b7c50ad6a6c8e22f8798f0bc786832
Signed-off-by: Norihiko Hama <Norihiko.Hama@alpsalpine.com>
2024-01-17 01:26:43 +00:00
Lianjun Huang
28dbe4d613 ANDROID: GKI: add symbols to ABI
After demand paging is captured during APP launch,
we can do it in advance before next launch.
Add the symbols for it here.

INFO: 4 function symbol(s) added
  'unsigned int filemap_get_folios(struct address_space*, unsigned long*, unsigned long, struct folio_batch*)'
  'unsigned int find_get_pages_range_tag(struct address_space*, unsigned long*, unsigned long, xa_mark_t, unsigned int, struct page**)'
  'void page_cache_async_ra(struct readahead_control*, struct folio*, unsigned long)'
  'void page_cache_sync_ra(struct readahead_control*, unsigned long)'

Bug: 315913896
Signed-off-by: Lianjun Huang <huanglianjun@xiaomi.com>
Signed-off-by: Lianjun Huang <huanglianjun@xiaomi.corp-partner.google.com>
Change-Id: I3f42c39c6432303e69f1fbae56fabf620381d8c5
2024-01-16 22:07:39 +00:00
Uttkarsh Aggarwal
97100e867e FROMGIT: usb: dwc: ep0: Update request status in dwc3_ep0_stall_restart
Current implementation blocks the running operations when Plug-out and
Plug-In is performed continuously, process gets stuck in
dwc3_thread_interrupt().

Code Flow:

	CPU1

	->Gadget_start
	->dwc3_interrupt
	->dwc3_thread_interrupt
	->dwc3_process_event_buf
	->dwc3_process_event_entry
	->dwc3_endpoint_interrupt
	->dwc3_ep0_interrupt
	->dwc3_ep0_inspect_setup
	->dwc3_ep0_stall_and_restart

By this time if pending_list is not empty, it will get the next request
on the given list and calls dwc3_gadget_giveback which will unmap request
and call its complete() callback to notify upper layers that it has
completed. Currently dwc3_gadget_giveback status is set to -ECONNRESET,
whereas it should be -ESHUTDOWN based on condition if not dwc->connected
is true.

Cc:  <stable@vger.kernel.org>
Fixes: d742220b35 ("usb: dwc3: ep0: giveback requests on stall_and_restart")
Signed-off-by: Uttkarsh Aggarwal <quic_uaggarwa@quicinc.com>
Link: https://lore.kernel.org/r/20231222094704.20276-1-quic_uaggarwa@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 320413810
(cherry picked from commit e9d40b215e38480fd94c66b06d79045717a59e9c
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/ usb-next)

Change-Id: I7f0afebbcfa88b6b4e622a708b9838dd461661fc
Signed-off-by: Sriram Dash <quic_sriramd@quicinc.com>
2024-01-16 19:39:36 +00:00
Frank Wang
36248a15a7 FROMGIT: usb: dwc3: set pm runtime active before resume common
For device mode, if PM runtime autosuspend feature enabled, the
runtime power status of dwc3 may be suspended when run dwc3_resume(),
and dwc3 gadget would not be configured in dwc3_gadget_run_stop().
It would cause gadget connected failed if USB cable has been plugged
before PM resume. So move forward pm_runtime_set_active() to fix it.

Bug: 300024866
Change-Id: I53d07c7bfb86d4ae8d60e07096dff0fd68e30eff
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
Link: https://lore.kernel.org/r/20231206065939.16958-1-frank.wang@rock-chips.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 68c26fe58182f5af56bfa577d1cc0c949740baab https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
2024-01-16 19:39:12 +00:00
Qian-Hao Huang
df1cdb0a70 ANDROID: Update the pixel symbol list
These symbols are needed as part of an upgrade to v6.1:
- add_uevent_var
- aes_encrypt
- aes_expandkey
- alloc_skb_with_frags
- cpufreq_quick_get_max
- cpuidle_governor_latency_req
- cpu_topology
- crypto_shash_final
- datagram_poll
- debugfs_create_blob
- dev_pm_qos_add_notifier
- dev_pm_qos_add_request
- dev_pm_qos_remove_notifier
- dev_pm_qos_remove_request
- dma_direct_alloc
- dma_direct_free
- dma_get_sgtable_attrs
- firmware_request_nowarn
- idr_alloc_cyclic
- in_egroup_p
- init_user_ns
- iov_iter_revert
- __ipv6_addr_type
- kernel_bind
- kernel_connect
- kernel_getsockname
- kernel_recvmsg
- kernel_sendmsg
- kmem_cache_create_usercopy
- ksize
- lock_sock_nested
- mempool_alloc
- mempool_alloc_slab
- mempool_create
- mempool_destroy
- mempool_free
- mempool_free_slab
- napi_gro_flush
- netif_tx_lock
- netif_tx_unlock
- ns_capable_noaudit
- param_get_string
- param_set_copystring
- param_set_int
- pci_disable_msi
- pcie_capability_read_word
- pci_iomap
- pci_iounmap
- pci_irq_vector
- pci_release_region
- pci_request_region
- pm_system_wakeup
- proto_register
- proto_unregister
- radix_tree_iter_delete
- radix_tree_next_chunk
- _raw_read_lock_irq
- _raw_read_unlock_irq
- _raw_write_lock_bh
- _raw_write_unlock_bh
- refcount_dec_not_one
- register_netevent_notifier
- regulator_set_load
- release_sock
- seq_vprintf
- sk_alloc
- skb_coalesce_rx_frag
- skb_copy_datagram_iter
- skb_free_datagram
- __skb_pad
- skb_recv_datagram
- skb_set_owner_w
- skb_store_bits
- sk_free
- sock_alloc_send_pskb
- sock_create_kern
- sock_gettstamp
- sock_init_data
- sock_no_accept
- sock_no_listen
- sock_no_mmap
- sock_no_sendpage
- sock_no_shutdown
- sock_no_socketpair
- sock_queue_rcv_skb_reason
- sock_register
- sock_setsockopt
- sock_unregister
- strchrnul
- unregister_netevent_notifier
- vscnprintf
- wait_for_completion_killable
- wireless_send_event
- __xa_insert
- xa_store

Bug: 303533633
Bug: 308924989
Change-Id: Ifbc09d5025f1bd3416f136fabd344ef2452390a8
Signed-off-by: Qian-Hao Huang <qhhuang@google.com>
2024-01-15 16:11:44 +00:00
Stephen Boyd
66cd99ccdb BACKPORT: UPSTREAM: phy: qcom-qmp: Introduce Kconfig symbols for discrete drivers
Introduce a config option for each QMP PHY driver now that the QMP PHY
mega-driver has been split up into different modules. This allows kernel
configurators to limit the binary size of the kernel by only compiling
in the QMP PHY driver that they need.

Leave the old config QCOM_QMP in place and make it into a menuconfig so
that 'make olddefconfig' continues to work. Furthermore, set the default
of the new Kconfig symbols to be QCOM_QMP so that the transition is
smooth.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Johan Hovold <johan+linaro@kernel.org>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>

Link: https://lore.kernel.org/all/20230202215330.2152726-1-swboyd@chromium.org/

Bug: 319064658
Change-Id: I633e6e1bbc3e79292bfde927e46f84219f0178ae
(cherry picked from commit d1abd69534)
[quic_kuruva: Resolved minor conflict in drivers/phy/qualcomm/Kconfig ]
Signed-off-by: Rajashekar kuruva <quic_kuruva@quicinc.com>
2024-01-12 22:16:42 +00:00
Lianjun Huang
a70d3b7bdd ANDROID: GKI: add symbols of vendor hooks to ABI for swapping in ahead
Add symbols of vendor hooks to capture demand paging during APP launch,
so we can do it in advance in next launch.
INFO: 1 function symbol(s) added
  'int __traceiter_android_vh_read_pages(void*, struct readahead_control*)'

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

Bug: 315913896
Signed-off-by: Lianjun Huang <huanglianjun@xiaomi.com>
Signed-off-by: Lianjun Huang <huanglianjun@xiaomi.corp-partner.google.com>
Change-Id: Ibb1e31b6912f7b6b92b76727f7e5043897434def
2024-01-12 18:47:42 +00:00
Lianjun Huang
d4db0d5d08 ANDROID: GKI: add vendor hooks for swapping in ahead
Add vendor hooks to capture demand paging during APP launch,
so we can do it in advance in next launch.

Bug: 315913896
Signed-off-by: Lianjun Huang <huanglianjun@xiaomi.com>
Signed-off-by: Lianjun Huang <huanglianjun@xiaomi.corp-partner.google.com>
Change-Id: I2698fefd347745fb4ff84b111caedbb3bb365ce3
2024-01-12 18:47:42 +00:00
Nikita Ioffe
fd40c1d901 ANDROID: add 16k targets for Microdroid kernel
Bug: 317201718
Test: tools/bazel run //common:kernel_aarch64_microdroid_16k_dist

Change-Id: I542f07d1d0b4f2b6a3c4c58185eee16b2b7f1667
Signed-off-by: Nikita Ioffe <ioffe@google.com>
2024-01-12 09:14:09 +00:00
Kalesh Singh
82bf9e7625 FROMGIT: BACKPORT: mm/cma: fix placement of trace_cma_alloc_start/finish
The current placement of trace_cma_alloc_start/finish misses the fail
cases: !cma || !cma->count || !cma->bitmap.

trace_cma_alloc_finish is also not emitted for the failure case
where bitmap_count > bitmap_maxno.

Fix these missed cases by moving the start event before the failure
checks and moving the finish event to the out label.

Link: https://lkml.kernel.org/r/20240110012234.3793639-1-kaleshsingh@google.com
Fixes: 7bc1aec5e2 ("mm: cma: add trace events for CMA alloc perf testing")
Change-Id: I61153fe078da4f9f3338147f1fbb7697a5554078
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Liam Mark <lmark@codeaurora.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit 3b08ab9a811caebe1327f25f51557f95200d94bf https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-unstable)
Bug: 315897033
[ Remove ret arg from trace_cma_alloc_finish - Kalesh Singh ]
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
2024-01-11 17:56:51 +00:00
Vinayak Yadawad
800cac4b33 FROMGIT: wifi: nl80211: Extend del pmksa support for SAE and OWE security
Current handling of del pmksa with SSID is limited to FILS
security. In the current change the del pmksa support is extended
to SAE/OWE security offloads as well. For OWE/SAE offloads, the
PMK is generated and cached at driver/FW, so user app needs the
capability to request cache deletion based on SSID for drivers
supporting SAE/OWE offload.

Signed-off-by: Vinayak Yadawad <vinayak.yadawad@broadcom.com>
Link: https://msgid.link/ecdae726459e0944c377a6a6f6cb2c34d2e057d0.1701262123.git.vinayak.yadawad@broadcom.com
[drop whitespace-damaged rdev_ops pointer completely, enabling tracing]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Bug: 301410304
(cherry picked from commit aa0887c4f18e280f8c2aa6964af602bd16c37f54
https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git main)
Change-Id: Ia665b9760279eb77347e79c97d177cba3beaa107
Signed-off-by: Paul Chen <chenpaul@google.com>
2024-01-11 05:46:54 +00:00
liangjlee
a41a4ee370 ANDROID: Update the ABI symbol list
Adding the following symbols:
  - dump_tasks

Bug: 316372318
Change-Id: Iddaed980a227d8beb966cf0fae24947f5bf8b473
Signed-off-by: liangjlee <liangjlee@google.com>
2024-01-10 23:50:22 +00:00
liangjlee
0801d8a89d ANDROID: mm: export dump_tasks symbol.
Export dump_tasks to dump per-task memory status when ramdump.

Bug: 316372318
Change-Id: Ie0dd1a4c7ada280dc0c7696781b4b9a5e2a100ab
Signed-off-by: liangjlee <liangjlee@google.com>
2024-01-10 23:50:22 +00:00
Bart Van Assche
7c91752f5d FROMLIST: scsi: ufs: Remove the ufshcd_hba_exit() call from ufshcd_async_scan()
Calling ufshcd_hba_exit() from a function that is called asynchronously
from ufshcd_init() is wrong because this triggers multiple race
conditions. Instead of calling ufshcd_hba_exit(), log an error message.

Reported-by: Daniel Mentz <danielmentz@google.com>
Closes: https://b.corp.google.com/issues/310401362
Fixes: 1d337ec2f3 ("ufs: improve init sequence")
Change-Id: I1c056c2e42889301f69107468f2b3eb38bf3d734
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Bug: 310401362
Link: https://lore.kernel.org/linux-scsi/20231218225229.2542156-3-bvanassche@acm.org/
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2024-01-10 23:15:00 +00:00
Bart Van Assche
28154afe74 FROMLIST: scsi: ufs: Simplify power management during async scan
ufshcd_init() calls pm_runtime_get_sync() before it calls
async_schedule(). ufshcd_async_scan() calls pm_runtime_put_sync()
directly or indirectly from ufshcd_add_lus(). Simplify
ufshcd_async_scan() by always calling pm_runtime_put_sync() from
ufshcd_async_scan().

Cc: stable@vger.kernel.org
Change-Id: I4b6ede95360c665594963fff0962742728064fb0
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Bug: 310401362
Link: https://lore.kernel.org/linux-scsi/20231218225229.2542156-2-bvanassche@acm.org/
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2024-01-10 23:14:57 +00:00
Aran Dalton
febcf1429f ANDROID: gki_defconfig: Set CONFIG_IDLE_INJECT and CONFIG_CPU_IDLE_THERMAL into y
Under certain circumstances a SoC can reach a critical temperaturelimit
and is unable to stabilize the temperature around a temperaturecontrol.
The system may ask for a specific power budget butbecause of the OPP
density, we can only choose an OPP with a powerbudget lower than the
requested one and under-utilize the CPU, thuslosing performance. In
other words, one OPP under-utilizes the CPUwith a power less than the
requested power budget and the next OPPexceeds the power budget. The
cpu idle cooling can solve this problem.

Bug: 299411923
Signed-off-by: Aran Dalton <arda@allwinnertech.com>
Change-Id: I1c17b340617e88be075097dc47f30ce94be2a4d7
2024-01-10 00:12:51 +00:00
Norihiko Hama
bc4d82ee40 ANDROID: KMI workaround for CONFIG_NETFILTER_FAMILY_BRIDGE
Enabling CONFIG_NETFILTER_FAMILY_BRIDGE causes the new element,
hooks_bridge[] to be added to netns_nf. Since the KMI is frozen
this could not be added.

The only instantiation of struct netns_nf is as an embedded field
of struct net. So instead of adding the field to struct netns_nf,
a new "struct ext_net" is added that contains struct net and
the new hooks_bridge[] field. An accessor function,
get_nf_hooks_bridge() is added to get a pointer to the new
field.

There is a global init_net of type struct net which must be special
cased since it is not a member of a struct ext_net. All other
instances of struct net are allocated via net_alloc() which now
allocates a struct ext_net.

Since CONFIG_NETFILTER_FAMILY_BRIDGE is a hidden config that is
needed for vendor modules, it is enabled via init/Kconfig.gki.

Bug: 316040984
Fixes: 0145780bfc78 ("fix KASAN-related kernel crash by KMI W/A for NETFILTER_FAMILY_BRIDGE")

Change-Id: I2c7384e3df9b88f12464dc0138986fed12ca626a
Signed-off-by: Norihiko Hama <Norihiko.Hama@alpsalpine.com>
2024-01-09 23:37:43 +00:00
Pavankumar Kondeti
227b55a7a3 ANDROID: dma-buf: don't re-purpose kobject as work_struct
The commit 5aec776ef8 ("BACKPORT: ANDROID: dma-buf: Move sysfs work
out of DMA-BUF export path) re-purposed kobject as work_struct temporarily
to create the sysfs entries asynchronously. The author knows what he is
doing and rightly added a build assert if kobject struct size is smaller than
the work_struct size. We are hitting this build assert on a non-GKI platform
where CONFIG_ANDROID_KABI_RESERVE is not set. Fix this problem by allocating
a new union with dma_buf_sysfs_entry structure and temporary structure as
members. We only end up allocating more memory (because of union) only when
kobject size is smaller than work_struct which the original patch any way
assumed would never be true.

Bug: 261818147
Bug: 262666413
Change-Id: Ifb089bf80d8a3a44ece9f05fc0b99ee76cb11645
Signed-off-by: Pavankumar Kondeti <quic_pkondeti@quicinc.com>
(cherry picked from commit ce18af9b5d)
Signed-off-by: T.J. Mercier <tjmercier@google.com>
2024-01-09 17:43:59 +00:00
Dezhi Huang
c1b1201d39 BACKPORT: FROMLIST: dma-buf: Move sysfs work out of DMA-BUF export path
We have identified an animation lag issue on our Android 14-6.1 product
which seems to be caused by contention in the rwsem lock during the
dmabuf request process. It appears that other processes are holding
sysfs read locks, resulting in the blocking of dmabuf sysfs node
creation. We encountered an issue in android14-6.1 that is similar to
the problem described in [1]. So we cherry-pick this commit to
android14-6.1.

[1] https://android-review.googlesource.com/c/kernel/common/+/2111974

Bug: 311282169
Bug: 206979019
Link: https://lore.kernel.org/lkml/CABdmKX2dNYhgOYdrrJU6-jt6F=LjCidbKhR6t4F7yaa0SPr+-A@mail.gmail.com/T/
Signed-off-by: Dezhi Huang <huangdezhi@hihonor.com>
Conflicts:
	include/linux/dma-buf.h

1. The android14-6.1 KMI is frozen, and the modification to struct
   dma_buf_sysfs_entry in the original patch triggers ABI check
   failures. Instead of an anonymous union, use the existing struct
   kobject directly as a work_struct with type punning.
Signed-off-by: T.J. Mercier <tjmercier@google.com>
Change-Id: Ic0386849b6b248b0a72215633fc1a50782455bac
2024-01-09 17:43:59 +00:00
Pablo Neira Ayuso
928b3b5dde UPSTREAM: netfilter: nf_tables: skip set commit for deleted/destroyed sets
commit 7315dc1e122c85ffdfc8defffbb8f8b616c2eb1a upstream.

NFT_MSG_DELSET deactivates all elements in the set, skip
set->ops->commit() to avoid the unnecessary clone (for the pipapo case)
as well as the sync GC cycle, which could deactivate again expired
elements in such set.

Bug: 318548348
Fixes: 5f68718b34 ("netfilter: nf_tables: GC transaction API to avoid race with control plane")
Reported-by: Kevin Rich <kevinrich1337@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 0105571f80)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: Ie733688e27d9568d797fc1bc477261883b7dc8c1
2024-01-09 16:21:20 +00:00
Quentin Perret
031f804149 ANDROID: KVM: arm64: Avoid BUG-ing from the host abort path
Under certain circumstances __get_fault_info() may resolve the faulting
address using the AT instruction. Given that this is being done outside
of the host lock critical section, it is racy and the resolution via AT
may fail. We currently BUG() in this situation, which is obviously less
than ideal. Moving the address resolution to the critical section may
have a performance impact, so let's keep it where it is, but bail out
and return to the host to try a second time.

Bug: 311830307
Change-Id: I26d61b04a4ccf040bd31802abb3c6b998ff4a48b
Signed-off-by: Quentin Perret <qperret@google.com>
2024-01-09 16:00:03 +00:00
Jia-Shiuan Chen
c5dc4b4b3d ANDROID: Update the ABI symbol list
Adding the following symbols:
  - dma_fence_array_ops

Bug: 319196045
Change-Id: Id65c62e0aedd65c9c72d71c8e39f7fae1e1de740
Signed-off-by: Jia-Shiuan Chen <chenjs@google.com>
2024-01-09 12:33:54 +00:00
Zhengchao Shao
5070b3b594 UPSTREAM: ipv4: igmp: fix refcnt uaf issue when receiving igmp query packet
[ Upstream commit e2b706c691905fe78468c361aaabc719d0a496f1 ]

When I perform the following test operations:
1.ip link add br0 type bridge
2.brctl addif br0 eth0
3.ip addr add 239.0.0.1/32 dev eth0
4.ip addr add 239.0.0.1/32 dev br0
5.ip addr add 224.0.0.1/32 dev br0
6.while ((1))
    do
        ifconfig br0 up
        ifconfig br0 down
    done
7.send IGMPv2 query packets to port eth0 continuously. For example,
./mausezahn ethX -c 0 "01 00 5e 00 00 01 00 72 19 88 aa 02 08 00 45 00 00
1c 00 01 00 00 01 02 0e 7f c0 a8 0a b7 e0 00 00 01 11 64 ee 9b 00 00 00 00"

The preceding tests may trigger the refcnt uaf issue of the mc list. The
stack is as follows:
	refcount_t: addition on 0; use-after-free.
	WARNING: CPU: 21 PID: 144 at lib/refcount.c:25 refcount_warn_saturate (lib/refcount.c:25)
	CPU: 21 PID: 144 Comm: ksoftirqd/21 Kdump: loaded Not tainted 6.7.0-rc1-next-20231117-dirty #80
	Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011
	RIP: 0010:refcount_warn_saturate (lib/refcount.c:25)
	RSP: 0018:ffffb68f00657910 EFLAGS: 00010286
	RAX: 0000000000000000 RBX: ffff8a00c3bf96c0 RCX: ffff8a07b6160908
	RDX: 00000000ffffffd8 RSI: 0000000000000027 RDI: ffff8a07b6160900
	RBP: ffff8a00cba36862 R08: 0000000000000000 R09: 00000000ffff7fff
	R10: ffffb68f006577c0 R11: ffffffffb0fdcdc8 R12: ffff8a00c3bf9680
	R13: ffff8a00c3bf96f0 R14: 0000000000000000 R15: ffff8a00d8766e00
	FS:  0000000000000000(0000) GS:ffff8a07b6140000(0000) knlGS:0000000000000000
	CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
	CR2: 000055f10b520b28 CR3: 000000039741a000 CR4: 00000000000006f0
	Call Trace:
	<TASK>
	igmp_heard_query (net/ipv4/igmp.c:1068)
	igmp_rcv (net/ipv4/igmp.c:1132)
	ip_protocol_deliver_rcu (net/ipv4/ip_input.c:205)
	ip_local_deliver_finish (net/ipv4/ip_input.c:234)
	__netif_receive_skb_one_core (net/core/dev.c:5529)
	netif_receive_skb_internal (net/core/dev.c:5729)
	netif_receive_skb (net/core/dev.c:5788)
	br_handle_frame_finish (net/bridge/br_input.c:216)
	nf_hook_bridge_pre (net/bridge/br_input.c:294)
	__netif_receive_skb_core (net/core/dev.c:5423)
	__netif_receive_skb_list_core (net/core/dev.c:5606)
	__netif_receive_skb_list (net/core/dev.c:5674)
	netif_receive_skb_list_internal (net/core/dev.c:5764)
	napi_gro_receive (net/core/gro.c:609)
	e1000_clean_rx_irq (drivers/net/ethernet/intel/e1000/e1000_main.c:4467)
	e1000_clean (drivers/net/ethernet/intel/e1000/e1000_main.c:3805)
	__napi_poll (net/core/dev.c:6533)
	net_rx_action (net/core/dev.c:6735)
	__do_softirq (kernel/softirq.c:554)
	run_ksoftirqd (kernel/softirq.c:913)
	smpboot_thread_fn (kernel/smpboot.c:164)
	kthread (kernel/kthread.c:388)
	ret_from_fork (arch/x86/kernel/process.c:153)
	ret_from_fork_asm (arch/x86/entry/entry_64.S:250)
	</TASK>

The root causes are as follows:
Thread A					Thread B
...						netif_receive_skb
br_dev_stop					...
    br_multicast_leave_snoopers			...
        __ip_mc_dec_group			...
            __igmp_group_dropped		igmp_rcv
                igmp_stop_timer			    igmp_heard_query         //ref = 1
                ip_ma_put			        igmp_mod_timer
                    refcount_dec_and_test	            igmp_start_timer //ref = 0
			...                                     refcount_inc //ref increases from 0
When the device receives an IGMPv2 Query message, it starts the timer
immediately, regardless of whether the device is running. If the device is
down and has left the multicast group, it will cause the mc list refcount
uaf issue.

Bug: 316932391
Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit 94445d9583)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I277be2304e564994e05b981ccd6cd8cbb9dc85be
2024-01-09 12:23:52 +00:00
Sagi Grimberg
02aa72665c UPSTREAM: nvmet-tcp: Fix a possible UAF in queue intialization setup
commit d920abd1e7 upstream.

From Alon:
"Due to a logical bug in the NVMe-oF/TCP subsystem in the Linux kernel,
a malicious user can cause a UAF and a double free, which may lead to
RCE (may also lead to an LPE in case the attacker already has local
privileges)."

Hence, when a queue initialization fails after the ahash requests are
allocated, it is guaranteed that the queue removal async work will be
called, hence leave the deallocation to the queue removal.

Also, be extra careful not to continue processing the socket, so set
queue rcv_state to NVMET_TCP_RECV_ERR upon a socket error.

Bug: 310114968
Cc: stable@vger.kernel.org
Reported-by: Alon Zahavi <zahavi.alon@gmail.com>
Tested-by: Alon Zahavi <zahavi.alon@gmail.com>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit e985d78bdcf37f7ef73666a43b0d2407715f00d3)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: Ifd7ec8294182a6bf6d8c261aeda5d989e909f7ff
2024-01-09 11:42:31 +00:00
Wesley Cheng
d6554d1262 FROMGIT: usb: dwc3: gadget: Handle EP0 request dequeuing properly
Current EP0 dequeue path will share the same as other EPs.  However, there
are some special considerations that need to be made for EP0 transfers:

  - EP0 transfers never transition into the started_list
  - EP0 only has one active request at a time

In case there is a vendor specific control message for a function over USB
FFS, then there is no guarantee on the timeline which the DATA/STATUS stage
is responded to.  While this occurs, any attempt to end transfers on
non-control EPs will end up having the DWC3_EP_DELAY_STOP flag set, and
defer issuing of the end transfer command.  If the USB FFS application
decides to timeout the control transfer, or if USB FFS AIO path exits, the
USB FFS driver will issue a call to usb_ep_dequeue() for the ep0 request.

In case of the AIO exit path, the AIO FS blocks until all pending USB
requests utilizing the AIO path is completed.  However, since the dequeue
of ep0 req does not happen properly, all non-control EPs with the
DWC3_EP_DELAY_STOP flag set will not be handled, and the AIO exit path will
be stuck waiting for the USB FFS data endpoints to receive a completion
callback.

Fix is to utilize dwc3_ep0_reset_state() in the dequeue API to ensure EP0
is brought back to the SETUP state, and ensures that any deferred end
transfer commands are handled.  This also will end any active transfers
on EP0, compared to the previous implementation which directly called
giveback only.

Fixes: fcd2def663 ("usb: dwc3: gadget: Refactor dwc3_gadget_ep_dequeue")
Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com>

Bug: 318577849
Change-Id: Ic00684db4b502f1aab128f7e49f22510dda24f60
(cherry picked from commit 730e12fbec53ab59dd807d981a204258a4cfb29a https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing)
Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com>
2024-01-08 18:03:53 +00:00
Zhipeng Wang
29544d4157 ANDROID: ABI: Update symbol list for imx
1 function symbol(s) added
  'bool iio_trigger_using_own(struct iio_dev*)'

Bug: 318788290

Change-Id: I5b17b2380f7087dabf51f4ed207e9ea4cab1ba38
Signed-off-by: Zhipeng Wang <zhipeng.wang_1@nxp.com>
2024-01-08 17:50:38 +00:00
Jens Axboe
02f444ba07 UPSTREAM: io_uring/fdinfo: lock SQ thread while retrieving thread cpu/pid
commit 7644b1a1c9 upstream.

We could race with SQ thread exit, and if we do, we'll hit a NULL pointer
dereference when the thread is cleared. Grab the SQPOLL data lock before
attempting to get the task cpu and pid for fdinfo, this ensures we have a
stable view of it.

Bug: 309790656
Cc: stable@vger.kernel.org
Link: https://bugzilla.kernel.org/show_bug.cgi?id=218032
Reviewed-by: Gabriel Krisman Bertazi <krisman@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit 9236d2ea64)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I044e0285d4535440606ff593230b873e3145db91
2024-01-08 17:33:38 +00:00
Jiri Olsa
ec46fe0ac7 UPSTREAM: bpf: Fix prog_array_map_poke_run map poke update
commit 4b7de801606e504e69689df71475d27e35336fb3 upstream.

Lee pointed out issue found by syscaller [0] hitting BUG in prog array
map poke update in prog_array_map_poke_run function due to error value
returned from bpf_arch_text_poke function.

There's race window where bpf_arch_text_poke can fail due to missing
bpf program kallsym symbols, which is accounted for with check for
-EINVAL in that BUG_ON call.

The problem is that in such case we won't update the tail call jump
and cause imbalance for the next tail call update check which will
fail with -EBUSY in bpf_arch_text_poke.

I'm hitting following race during the program load:

  CPU 0                             CPU 1

  bpf_prog_load
    bpf_check
      do_misc_fixups
        prog_array_map_poke_track

                                    map_update_elem
                                      bpf_fd_array_map_update_elem
                                        prog_array_map_poke_run

                                          bpf_arch_text_poke returns -EINVAL

    bpf_prog_kallsyms_add

After bpf_arch_text_poke (CPU 1) fails to update the tail call jump, the next
poke update fails on expected jump instruction check in bpf_arch_text_poke
with -EBUSY and triggers the BUG_ON in prog_array_map_poke_run.

Similar race exists on the program unload.

Fixing this by moving the update to bpf_arch_poke_desc_update function which
makes sure we call __bpf_arch_text_poke that skips the bpf address check.

Each architecture has slightly different approach wrt looking up bpf address
in bpf_arch_text_poke, so instead of splitting the function or adding new
'checkip' argument in previous version, it seems best to move the whole
map_poke_run update as arch specific code.

  [0] https://syzkaller.appspot.com/bug?extid=97a4fe20470e9bc30810

Bug: 309551558
Fixes: ebf7d1f508 ("bpf, x64: rework pro/epilogue and tailcall handling in JIT")
Reported-by: syzbot+97a4fe20470e9bc30810@syzkaller.appspotmail.com
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
Cc: Lee Jones <lee@kernel.org>
Cc: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Link: https://lore.kernel.org/bpf/20231206083041.1306660-2-jolsa@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 57a6b0a464)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I251c3da579e5d48cd7de4043913fd42d0671d6b5
2024-01-08 17:00:17 +00:00
Mathias Nyman
98b0e4cf09 BACKPORT: xhci: track port suspend state correctly in unsuccessful resume cases
xhci-hub.c tracks suspended ports in a suspended_port bitfield.
This is checked when responding to a Get_Status(PORT) request to see if a
port in running U0 state was recently resumed, and adds the required
USB_PORT_STAT_C_SUSPEND change bit in those cases.

The suspended_port bit was left uncleared if a device is disconnected
during suspend. The bit remained set even when a new device was connected
and enumerated. The set bit resulted in a incorrect Get_Status(PORT)
response with a bogus USB_PORT_STAT_C_SUSPEND change
bit set once the new device reached U0 link state.

USB_PORT_STAT_C_SUSPEND change bit is only used for USB2 ports, but
xhci-hub keeps track of both USB2 and USB3 suspended ports.

Cc: stable@vger.kernel.org
Reported-by: Wesley Cheng <quic_wcheng@quicinc.com>
Closes: https://lore.kernel.org/linux-usb/d68aa806-b26a-0e43-42fb-b8067325e967@quicinc.com/
Fixes: 1d5810b692 ("xhci: Rework port suspend structures for limited ports.")
Tested-by: Wesley Cheng <quic_wcheng@quicinc.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://lore.kernel.org/r/20230915143108.1532163-3-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 200589374
(cherry picked from commit d7cdfc319b https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
[wcheng: modified change to remove dependency on updated resume timestamp tracking]
Change-Id: Icccc1778a1f193b4b4c03532d291db88772bd454
Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com>
2024-01-08 14:02:10 +00:00
Rick Yiu
ac90f08292 ANDROID: Update the ABI symbol list
Adding the following symbols:
  - sysctl_sched_idle_min_granularity
  - sysctl_sched_min_granularity

Bug: 316276520
Change-Id: I8e33c3105a3ca62d168a6289ceafc31404757453
Signed-off-by: Rick Yiu <rickyiu@google.com>
2024-01-05 18:06:32 +00:00
Rick Yiu
ef67750d99 ANDROID: sched: Export symbols for vendor modules
Export sysctl_sched_min_granularity and
sysctl_sched_idle_min_granularity. In the vendor module, it will use
several static function in GKI, while we do not want to export these
static functions, which will need to make them not static, we copied
them to the vendor module, so we need the export the symbols used in
those static functions. For example, sysctl_sched_min_granularity
and sysctl_sched_idle_min_granularity are referred in sched_slice(),
and they are only used as read-only.

Bug: 316276520
Change-Id: I976d0a1f3a70e8e60099e55fdd3cc99a90053fbb
Signed-off-by: Rick Yiu <rickyiu@google.com>
2024-01-05 18:06:32 +00:00