Commit Graph

1150234 Commits

Author SHA1 Message Date
Jack Lee
b783e85610 ANDROID: Update the ABI symbol list
Adding the following symbols:
  - __traceiter_android_vh_meminfo_proc_show
  - __traceiter_mm_vmscan_direct_reclaim_begin
  - __traceiter_mm_vmscan_direct_reclaim_end
  - __tracepoint_android_vh_meminfo_proc_show
  - __tracepoint_mm_vmscan_direct_reclaim_begin
  - __tracepoint_mm_vmscan_direct_reclaim_end

Bug: 303160914
Change-Id: I404fbfc9ed70d4411123250edb4c7449c22ad5e5
Signed-off-by: Jack Lee <liangjlee@google.com>
2023-10-26 16:30:07 +00:00
Martin Liu
2c609cab0b UPSTREAM: of: reserved-mem: print out reserved-mem details during boot
It's important to know reserved-mem information in mobile world
since reserved memory via device tree keeps increased in platform
(e.g., 45% in our platform). Therefore, it's crucial to know the
reserved memory sizes breakdown for the memory accounting.

This patch prints out reserved memory details during boot to make
them visible.

Below is an example output:

[    0.000000] OF: reserved mem: 0x00000009f9400000..0x00000009fb3fffff ( 32768 KB ) map reusable test1
[    0.000000] OF: reserved mem: 0x00000000ffdf0000..0x00000000ffffffff ( 2112 KB ) map non-reusable test2
[    0.000000] OF: reserved mem: 0x0000000091000000..0x00000000912fffff ( 3072 KB ) nomap non-reusable test3

Bug: 269588564
Change-Id: Idf77b3a9de70ed13c806d3b03d1886b5ae89da62
Signed-off-by: Martin Liu <liumartin@google.com>
Link: https://lore.kernel.org/r/20230209160954.1471909-1-liumartin@google.com
Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Richard Chang <richardycc@google.com>
(cherry picked from commit aeb9267eb6)
2023-10-26 13:17:35 +00:00
wanghongjing
ff2563f384 ANDROID: GKI: Update symbol list for xiaomi "abi_gki_aarch64_xiaomi"
2 function symbol(s) added
  'bioset_init'
  'bioset_exit'

Bug: 307868722
Change-Id: I603003a42b5bb495f657ce155b0fb52463bdfd9d
Signed-off-by: wanghongjing <wanghongjing@xiaomi.com>
2023-10-26 12:44:13 +00:00
Maulik Shah
7542b3bef7 ANDROID: Update symbols list and ABI for qcom
Whitelist pm_suspend_target_state and pm_suspend_global_flags.
Update ABI representation accordingly.

Adding the following symbols:
  - pm_suspend_target_state

Bug: 306080942
Change-Id: I78083bdd2ac5bb662f59b2592aa167cae4a7dc30
Signed-off-by: Maulik Shah <quic_mkshah@quicinc.com>
Signed-off-by: Shreyas K K <quic_shrekk@quicinc.com>
2023-10-25 11:50:59 +05:30
liujinbao1
63d4231d85 ANDROID: fuse-bpf: Add NULL pointer check in fuse_entry_revalidate
If userspace tried to add a backing file in a fuse_dentry_revalidate
where there wasn't one originally, this would trigger a crash. Disallow
this operation for now.

Bug: 296013218
Fixes: 57f3ff9648 ("ANDROID: fuse-bpf v1.1")

Test: fuse_test passes, following script no longer crashes:

adb shell su root setenforce 0
adb shell su root chmod ug+w /data/media
adb shell su root rm /data/media/Android -rf
adb shell su root mkdir -p /storage/emulated/Android/data/test
adb shell su root ls -l /storage/emulated/Android/data/test

Change-Id: Id8a67c43d1edfa010403d5f17e31109b796998cf
Signed-off-by: liujinbao1 <liujinbao1@xiaomi.corp-partner.google.com>
2023-10-25 04:47:13 +00:00
liwei1234
09641ca77f ANDROID: GKI: Update oplus symbol list
update oplus symbol list for Addding hooks for adjusting alloc_flags

1 function symbol(s) added
  'int __traceiter_android_vh_adjust_alloc_flags(void*, unsigned int, gfp_t*)'

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

Bug: 300857012
Change-Id: Ic18ed77b3f86d1e8e8aaeb90d8965a84c7713d4a
Signed-off-by: liwei1234 <liwei1234@oppo.com>
2023-10-24 19:34:17 +00:00
lvwenhuan
0b20035778 ANDROID: vendor_hooks: Add hooks for adjusting alloc_flags
the reason why we add a vendor hook adjusting alloc_flags:
1 the user only pass parameter size and gfp_flags once. if we mask the __GFP_RECLAIM, we can't distinguish high-order and low-order, they all will not rise reclaim behavior, it's wrong.

2 for __iommu_dma_alloc_pages, there is a loop to try to alloc pages from high-order to low-order fallback, and we add hook callsite to only change the high-order( > costly order) alloc behavior(which high probability will result more overhead than benifit).
which allow low order alloc to do reclaim behavior still, otherwise may end up with alloc fail.

3 in android ION(drivers/dma-buf/heaps/system_heap.c )
there is same logic, high-order alloc will not do reclaim behavior.

so this change and a vendor hook for adjusting alloc_flags, and add a callsite in __iommu_dma_alloc_pages to turn the reclaim behavior.

Bug: 300857012
Change-Id: I30bd634d8ede1cc29c83d52bdd9276c8cf72ac1e
Signed-off-by: lvwenhuan <lvwenhuan@oppo.com>
(cherry picked from commit d6c24c3a63567676de818011403abe5b9b3d38b0)
2023-10-24 19:34:17 +00:00
Ilya Dryomov
367ce30ddc UPSTREAM: libceph: harden msgr2.1 frame segment length checks
commit a282a2f105 upstream.

ceph_frame_desc::fd_lens is an int array.  decode_preamble() thus
effectively casts u32 -> int but the checks for segment lengths are
written as if on unsigned values.  While reading in HELLO or one of the
AUTH frames (before authentication is completed), arithmetic in
head_onwire_len() can get duped by negative ctrl_len and produce
head_len which is less than CEPH_PREAMBLE_LEN but still positive.
This would lead to a buffer overrun in prepare_read_control() as the
preamble gets copied to the newly allocated buffer of size head_len.

Bug: 303173400
Cc: stable@vger.kernel.org
Fixes: cd1a677cad ("libceph, ceph: implement msgr2.1 protocol (crc and secure modes)")
Reported-by: Thelford Williams <thelford@google.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit db8ca8d9b4)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I49eacd72317664d920b13e3fec087d0e14802b93
2023-10-24 17:39:17 +00:00
liangjlee
debc1e0486 ANDROID: Update the ABI symbol list
Adding the following symbols:
  - __traceiter_android_vh_filemap_get_folio
  - __tracepoint_android_vh_filemap_get_folio

Bug: 303161359
Change-Id: I50a35cae6ea04a50570ba415ebfeee9284cd67e4
Signed-off-by: liangjlee <liangjlee@google.com>
2023-10-24 17:34:00 +00:00
Chiawei Wang
401b78ce87 ANDROID: mm: Add vendor hook in filemap_get_folio()
Add a vendor hook for pagecache hit/miss and other
vendor specific functions.

Bug: 174088128
Bug: 172987241
Signed-off-by: Chiawei Wang <chiaweiwang@google.com>
Change-Id: Ie9f14a69a86b8ed81de766e44e30f2eba1d9bd84
Signed-off-by: Richard Chang <richardycc@google.com>
(cherry picked from commit db158b4ae0)
Signed-off-by: Jack Lee <liangjlee@google.com>
2023-10-24 17:34:00 +00:00
Jozsef Kadlecsik
1b3269beea UPSTREAM: netfilter: ipset: Fix race between IPSET_CMD_CREATE and IPSET_CMD_SWAP
[ Upstream commit 7433b6d2af ]

Kyle Zeng reported that there is a race between IPSET_CMD_ADD and IPSET_CMD_SWAP
in netfilter/ip_set, which can lead to the invocation of `__ip_set_put` on a
wrong `set`, triggering the `BUG_ON(set->ref == 0);` check in it.

The race is caused by using the wrong reference counter, i.e. the ref counter instead
of ref_netlink.

Bug: 303172721
Fixes: 24e227896b ("netfilter: ipset: Add schedule point in call_ad().")
Reported-by: Kyle Zeng <zengyhkyle@gmail.com>
Closes: https://lore.kernel.org/netfilter-devel/ZPZqetxOmH+w%2Fmyc@westworld/#r
Tested-by: Kyle Zeng <zengyhkyle@gmail.com>
Signed-off-by: Jozsef Kadlecsik <kadlec@netfilter.org>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit ea5a61d588)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I33a6a6234830c600a4ebd62ed1fee3a48876b98d
2023-10-24 15:14:45 +01:00
Kuniyuki Iwashima
a9c65c7efb UPSTREAM: netfilter: ipset: Add schedule point in call_ad().
[ Upstream commit 24e227896b ]

syzkaller found a repro that causes Hung Task [0] with ipset.  The repro
first creates an ipset and then tries to delete a large number of IPs
from the ipset concurrently:

  IPSET_ATTR_IPADDR_IPV4 : 172.20.20.187
  IPSET_ATTR_CIDR        : 2

The first deleting thread hogs a CPU with nfnl_lock(NFNL_SUBSYS_IPSET)
held, and other threads wait for it to be released.

Previously, the same issue existed in set->variant->uadt() that could run
so long under ip_set_lock(set).  Commit 5e29dc36bd ("netfilter: ipset:
Rework long task execution when adding/deleting entries") tried to fix it,
but the issue still exists in the caller with another mutex.

While adding/deleting many IPs, we should release the CPU periodically to
prevent someone from abusing ipset to hang the system.

Note we need to increment the ipset's refcnt to prevent the ipset from
being destroyed while rescheduling.

[0]:
INFO: task syz-executor174:268 blocked for more than 143 seconds.
      Not tainted 6.4.0-rc1-00145-gba79e9a73284 #1
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:syz-executor174 state:D stack:0     pid:268   ppid:260    flags:0x0000000d
Call trace:
 __switch_to+0x308/0x714 arch/arm64/kernel/process.c:556
 context_switch kernel/sched/core.c:5343 [inline]
 __schedule+0xd84/0x1648 kernel/sched/core.c:6669
 schedule+0xf0/0x214 kernel/sched/core.c:6745
 schedule_preempt_disabled+0x58/0xf0 kernel/sched/core.c:6804
 __mutex_lock_common kernel/locking/mutex.c:679 [inline]
 __mutex_lock+0x6fc/0xdb0 kernel/locking/mutex.c:747
 __mutex_lock_slowpath+0x14/0x20 kernel/locking/mutex.c:1035
 mutex_lock+0x98/0xf0 kernel/locking/mutex.c:286
 nfnl_lock net/netfilter/nfnetlink.c:98 [inline]
 nfnetlink_rcv_msg+0x480/0x70c net/netfilter/nfnetlink.c:295
 netlink_rcv_skb+0x1c0/0x350 net/netlink/af_netlink.c:2546
 nfnetlink_rcv+0x18c/0x199c net/netfilter/nfnetlink.c:658
 netlink_unicast_kernel net/netlink/af_netlink.c:1339 [inline]
 netlink_unicast+0x664/0x8cc net/netlink/af_netlink.c:1365
 netlink_sendmsg+0x6d0/0xa4c net/netlink/af_netlink.c:1913
 sock_sendmsg_nosec net/socket.c:724 [inline]
 sock_sendmsg net/socket.c:747 [inline]
 ____sys_sendmsg+0x4b8/0x810 net/socket.c:2503
 ___sys_sendmsg net/socket.c:2557 [inline]
 __sys_sendmsg+0x1f8/0x2a4 net/socket.c:2586
 __do_sys_sendmsg net/socket.c:2595 [inline]
 __se_sys_sendmsg net/socket.c:2593 [inline]
 __arm64_sys_sendmsg+0x80/0x94 net/socket.c:2593
 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
 invoke_syscall+0x84/0x270 arch/arm64/kernel/syscall.c:52
 el0_svc_common+0x134/0x24c arch/arm64/kernel/syscall.c:142
 do_el0_svc+0x64/0x198 arch/arm64/kernel/syscall.c:193
 el0_svc+0x2c/0x7c arch/arm64/kernel/entry-common.c:637
 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
 el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:591

Bug: 303172721
Reported-by: syzkaller <syzkaller@googlegroups.com>
Fixes: a7b4f989a6 ("netfilter: ipset: IP set core support")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Acked-by: Jozsef Kadlecsik <kadlec@netfilter.org>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit fea199dbf6)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I7d2c299b1d7d298b5abd76306821320546338a77
2023-10-24 15:14:15 +01:00
Lin Ma
cd4ea97d2a UPSTREAM: net: xfrm: Fix xfrm_address_filter OOB read
[ Upstream commit dfa73c17d5 ]

We found below OOB crash:

[   44.211730] ==================================================================
[   44.212045] BUG: KASAN: slab-out-of-bounds in memcmp+0x8b/0xb0
[   44.212045] Read of size 8 at addr ffff88800870f320 by task poc.xfrm/97
[   44.212045]
[   44.212045] CPU: 0 PID: 97 Comm: poc.xfrm Not tainted 6.4.0-rc7-00072-gdad9774deaf1-dirty #4
[   44.212045] Call Trace:
[   44.212045]  <TASK>
[   44.212045]  dump_stack_lvl+0x37/0x50
[   44.212045]  print_report+0xcc/0x620
[   44.212045]  ? __virt_addr_valid+0xf3/0x170
[   44.212045]  ? memcmp+0x8b/0xb0
[   44.212045]  kasan_report+0xb2/0xe0
[   44.212045]  ? memcmp+0x8b/0xb0
[   44.212045]  kasan_check_range+0x39/0x1c0
[   44.212045]  memcmp+0x8b/0xb0
[   44.212045]  xfrm_state_walk+0x21c/0x420
[   44.212045]  ? __pfx_dump_one_state+0x10/0x10
[   44.212045]  xfrm_dump_sa+0x1e2/0x290
[   44.212045]  ? __pfx_xfrm_dump_sa+0x10/0x10
[   44.212045]  ? __kernel_text_address+0xd/0x40
[   44.212045]  ? kasan_unpoison+0x27/0x60
[   44.212045]  ? mutex_lock+0x60/0xe0
[   44.212045]  ? __pfx_mutex_lock+0x10/0x10
[   44.212045]  ? kasan_save_stack+0x22/0x50
[   44.212045]  netlink_dump+0x322/0x6c0
[   44.212045]  ? __pfx_netlink_dump+0x10/0x10
[   44.212045]  ? mutex_unlock+0x7f/0xd0
[   44.212045]  ? __pfx_mutex_unlock+0x10/0x10
[   44.212045]  __netlink_dump_start+0x353/0x430
[   44.212045]  xfrm_user_rcv_msg+0x3a4/0x410
[   44.212045]  ? __pfx__raw_spin_lock_irqsave+0x10/0x10
[   44.212045]  ? __pfx_xfrm_user_rcv_msg+0x10/0x10
[   44.212045]  ? __pfx_xfrm_dump_sa+0x10/0x10
[   44.212045]  ? __pfx_xfrm_dump_sa_done+0x10/0x10
[   44.212045]  ? __stack_depot_save+0x382/0x4e0
[   44.212045]  ? filter_irq_stacks+0x1c/0x70
[   44.212045]  ? kasan_save_stack+0x32/0x50
[   44.212045]  ? kasan_save_stack+0x22/0x50
[   44.212045]  ? kasan_set_track+0x25/0x30
[   44.212045]  ? __kasan_slab_alloc+0x59/0x70
[   44.212045]  ? kmem_cache_alloc_node+0xf7/0x260
[   44.212045]  ? kmalloc_reserve+0xab/0x120
[   44.212045]  ? __alloc_skb+0xcf/0x210
[   44.212045]  ? netlink_sendmsg+0x509/0x700
[   44.212045]  ? sock_sendmsg+0xde/0xe0
[   44.212045]  ? __sys_sendto+0x18d/0x230
[   44.212045]  ? __x64_sys_sendto+0x71/0x90
[   44.212045]  ? do_syscall_64+0x3f/0x90
[   44.212045]  ? entry_SYSCALL_64_after_hwframe+0x72/0xdc
[   44.212045]  ? netlink_sendmsg+0x509/0x700
[   44.212045]  ? sock_sendmsg+0xde/0xe0
[   44.212045]  ? __sys_sendto+0x18d/0x230
[   44.212045]  ? __x64_sys_sendto+0x71/0x90
[   44.212045]  ? do_syscall_64+0x3f/0x90
[   44.212045]  ? entry_SYSCALL_64_after_hwframe+0x72/0xdc
[   44.212045]  ? kasan_save_stack+0x22/0x50
[   44.212045]  ? kasan_set_track+0x25/0x30
[   44.212045]  ? kasan_save_free_info+0x2e/0x50
[   44.212045]  ? __kasan_slab_free+0x10a/0x190
[   44.212045]  ? kmem_cache_free+0x9c/0x340
[   44.212045]  ? netlink_recvmsg+0x23c/0x660
[   44.212045]  ? sock_recvmsg+0xeb/0xf0
[   44.212045]  ? __sys_recvfrom+0x13c/0x1f0
[   44.212045]  ? __x64_sys_recvfrom+0x71/0x90
[   44.212045]  ? do_syscall_64+0x3f/0x90
[   44.212045]  ? entry_SYSCALL_64_after_hwframe+0x72/0xdc
[   44.212045]  ? copyout+0x3e/0x50
[   44.212045]  netlink_rcv_skb+0xd6/0x210
[   44.212045]  ? __pfx_xfrm_user_rcv_msg+0x10/0x10
[   44.212045]  ? __pfx_netlink_rcv_skb+0x10/0x10
[   44.212045]  ? __pfx_sock_has_perm+0x10/0x10
[   44.212045]  ? mutex_lock+0x8d/0xe0
[   44.212045]  ? __pfx_mutex_lock+0x10/0x10
[   44.212045]  xfrm_netlink_rcv+0x44/0x50
[   44.212045]  netlink_unicast+0x36f/0x4c0
[   44.212045]  ? __pfx_netlink_unicast+0x10/0x10
[   44.212045]  ? netlink_recvmsg+0x500/0x660
[   44.212045]  netlink_sendmsg+0x3b7/0x700
[   44.212045]  ? __pfx_netlink_sendmsg+0x10/0x10
[   44.212045]  ? __pfx_netlink_sendmsg+0x10/0x10
[   44.212045]  sock_sendmsg+0xde/0xe0
[   44.212045]  __sys_sendto+0x18d/0x230
[   44.212045]  ? __pfx___sys_sendto+0x10/0x10
[   44.212045]  ? rcu_core+0x44a/0xe10
[   44.212045]  ? __rseq_handle_notify_resume+0x45b/0x740
[   44.212045]  ? _raw_spin_lock_irq+0x81/0xe0
[   44.212045]  ? __pfx___rseq_handle_notify_resume+0x10/0x10
[   44.212045]  ? __pfx_restore_fpregs_from_fpstate+0x10/0x10
[   44.212045]  ? __pfx_blkcg_maybe_throttle_current+0x10/0x10
[   44.212045]  ? __pfx_task_work_run+0x10/0x10
[   44.212045]  __x64_sys_sendto+0x71/0x90
[   44.212045]  do_syscall_64+0x3f/0x90
[   44.212045]  entry_SYSCALL_64_after_hwframe+0x72/0xdc
[   44.212045] RIP: 0033:0x44b7da
[   44.212045] RSP: 002b:00007ffdc8838548 EFLAGS: 00000246 ORIG_RAX: 000000000000002c
[   44.212045] RAX: ffffffffffffffda RBX: 00007ffdc8839978 RCX: 000000000044b7da
[   44.212045] RDX: 0000000000000038 RSI: 00007ffdc8838770 RDI: 0000000000000003
[   44.212045] RBP: 00007ffdc88385b0 R08: 00007ffdc883858c R09: 000000000000000c
[   44.212045] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001
[   44.212045] R13: 00007ffdc8839968 R14: 00000000004c37d0 R15: 0000000000000001
[   44.212045]  </TASK>
[   44.212045]
[   44.212045] Allocated by task 97:
[   44.212045]  kasan_save_stack+0x22/0x50
[   44.212045]  kasan_set_track+0x25/0x30
[   44.212045]  __kasan_kmalloc+0x7f/0x90
[   44.212045]  __kmalloc_node_track_caller+0x5b/0x140
[   44.212045]  kmemdup+0x21/0x50
[   44.212045]  xfrm_dump_sa+0x17d/0x290
[   44.212045]  netlink_dump+0x322/0x6c0
[   44.212045]  __netlink_dump_start+0x353/0x430
[   44.212045]  xfrm_user_rcv_msg+0x3a4/0x410
[   44.212045]  netlink_rcv_skb+0xd6/0x210
[   44.212045]  xfrm_netlink_rcv+0x44/0x50
[   44.212045]  netlink_unicast+0x36f/0x4c0
[   44.212045]  netlink_sendmsg+0x3b7/0x700
[   44.212045]  sock_sendmsg+0xde/0xe0
[   44.212045]  __sys_sendto+0x18d/0x230
[   44.212045]  __x64_sys_sendto+0x71/0x90
[   44.212045]  do_syscall_64+0x3f/0x90
[   44.212045]  entry_SYSCALL_64_after_hwframe+0x72/0xdc
[   44.212045]
[   44.212045] The buggy address belongs to the object at ffff88800870f300
[   44.212045]  which belongs to the cache kmalloc-64 of size 64
[   44.212045] The buggy address is located 32 bytes inside of
[   44.212045]  allocated 36-byte region [ffff88800870f300, ffff88800870f324)
[   44.212045]
[   44.212045] The buggy address belongs to the physical page:
[   44.212045] page:00000000e4de16ee refcount:1 mapcount:0 mapping:000000000 ...
[   44.212045] flags: 0x100000000000200(slab|node=0|zone=1)
[   44.212045] page_type: 0xffffffff()
[   44.212045] raw: 0100000000000200 ffff888004c41640 dead000000000122 0000000000000000
[   44.212045] raw: 0000000000000000 0000000080200020 00000001ffffffff 0000000000000000
[   44.212045] page dumped because: kasan: bad access detected
[   44.212045]
[   44.212045] Memory state around the buggy address:
[   44.212045]  ffff88800870f200: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
[   44.212045]  ffff88800870f280: 00 00 00 00 00 fc fc fc fc fc fc fc fc fc fc fc
[   44.212045] >ffff88800870f300: 00 00 00 00 04 fc fc fc fc fc fc fc fc fc fc fc
[   44.212045]                                ^
[   44.212045]  ffff88800870f380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   44.212045]  ffff88800870f400: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   44.212045] ==================================================================

By investigating the code, we find the root cause of this OOB is the lack
of checks in xfrm_dump_sa(). The buggy code allows a malicious user to pass
arbitrary value of filter->splen/dplen. Hence, with crafted xfrm states,
the attacker can achieve 8 bytes heap OOB read, which causes info leak.

  if (attrs[XFRMA_ADDRESS_FILTER]) {
    filter = kmemdup(nla_data(attrs[XFRMA_ADDRESS_FILTER]),
        sizeof(*filter), GFP_KERNEL);
    if (filter == NULL)
      return -ENOMEM;
    // NO MORE CHECKS HERE !!!
  }

This patch fixes the OOB by adding necessary boundary checks, just like
the code in pfkey_dump() function.

Bug: 304913834
Fixes: d3623099d3 ("ipsec: add support of limited SA dump")
Signed-off-by: Lin Ma <linma@zju.edu.cn>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit 1960f46807)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: Iee18d8ee7e2b99ce5cf4e1ff7137f5b31531b890
2023-10-24 14:05:07 +00:00
Radoslaw Tyl
a4ccba8bdc UPSTREAM: igb: set max size RX buffer when store bad packet is enabled
commit bb5ed01cd2 upstream.

Increase the RX buffer size to 3K when the SBP bit is on. The size of
the RX buffer determines the number of pages allocated which may not
be sufficient for receive frames larger than the set MTU size.

Bug: 306483516
Cc: stable@vger.kernel.org
Fixes: 89eaefb61d ("igb: Support RX-ALL feature flag.")
Reported-by: Manfred Rudigier <manfred.rudigier@omicronenergy.com>
Signed-off-by: Radoslaw Tyl <radoslawx.tyl@intel.com>
Tested-by: Arpana Arland <arpanax.arland@intel.com> (A Contingent worker at Intel)
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit be7353af5b)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I3f05b369cd9ac24643af3e37e2ce1d099c63bc02
2023-10-24 11:52:31 +01:00
Greg Kroah-Hartman
8a67c06094 ANDROID: GKI: fix ABI breakage in struct hid_device
In commit 74b95023619b ("UPSTREAM: HID: input: map battery system
charging"), which is in the 6.1.60 release, struct hid_device gets a new
field, which breaks the abi.  Fix this up by using one of the reserved
slots for upstream changes and update the .stg file to preserve the
build.

type 'struct hid_device' changed
  member 'union { struct { __s32 battery_charge_status; u32 padding; }; struct { u64 android_kabi_reserved1; }; union { }; }' was added
  member 'u64 android_kabi_reserved1' was removed

Bug: 305125317
Bug: 161946584
Fixes: 74b95023619b ("UPSTREAM: HID: input: map battery system charging")
Cc: Lu Guohong <luguohong@xiaomi.corp-partner.google.com>
Change-Id: I9ac8ffc758563285f88feb6d592471a555f71c14
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-10-23 21:52:42 +00:00
José Expósito
28ee91ed2b UPSTREAM: HID: input: map battery system charging
HID descriptors with Battery System (0x85) Charging (0x44) usage are
ignored and POWER_SUPPLY_STATUS_DISCHARGING is always reported to user
space, even when the device is charging.

Map this usage and when it is reported set the right charging status.

In addition, add KUnit tests to make sure that the charging status is
correctly set and reported. They can be run with the usual command:

    $ ./tools/testing/kunit/kunit.py run --kunitconfig=drivers/hid

Change-Id: Ib42e823c5fccfe0c281d8855e124c03b20978132
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
(cherry picked from commit a608dc1c06)
Bug: 305125317
Cc: Lu Guohong <luguohong@xiaomi.corp-partner.google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-10-23 21:52:42 +00:00
JohnHsu
2dd1c535d1 FROMGIT: maple_tree: add GFP_KERNEL to allocations in mas_expected_entries()
Users complained about OOM errors during fork without triggering
compaction.  This can be fixed by modifying the flags used in
mas_expected_entries() so that the compaction will be triggered in low
memory situations.  Since mas_expected_entries() is only used during
fork, the extra argument does not need to be passed through.

Additionally, the two test_maple_tree test cases and one benchmark test
were altered to use the correct locking type so that allocations would
not trigger sleeping and thus fail.  Testing was completed with lockdep
atomic sleep detection.

The additional locking change requires rwsem support additions to the
tools/ directory through the use of pthreads pthread_rwlock_t.  With
this change test_maple_tree works in userspace, as a module, and
in-kernel.

Users may notice that the system gave up early on attempting to start
new processes instead of attempting to reclaim memory.

Link: https://lore.kernel.org/linux-mm/20231012155233.2272446-1-Liam.Howlett@oracle.com/
Fixes: 54a611b605 ("Maple Tree: add new data structure")
Cc: <stable@vger.kernel.org>
Cc: jason.sim@samsung.com
Cc: Peng Zhang <zhangpeng.00@bytedance.com>
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
(cherry picked from commit 099d7439ce
https: //git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-unstable)

Bug: 305860603
Change-Id: I1ea250b37198fb3234136da4737b75c6ee3d9817
Signed-off-by: john.hsu <john.hsu@mediatek.com>
2023-10-23 19:44:16 +00:00
Liam R. Howlett
faa4efd6b1 UPSTREAM: maple_tree: replace data before marking dead in split and spanning store
Reorder the operations for split and spanning stores so that new data is
placed in the tree prior to marking the old data as dead.  This will limit
re-walks on dead data to just once instead of a retry loop.

The order of operations is as follows: Create the new data, put the new
data in place, mark the top node of the old data as dead.

Then repair parent links in the reused nodes through all levels of the
tree, following the new nodes downwards.  Finally walk the top dead node
looking for nodes that are no longer used, or subtrees that should be
destroyed (marked dead throughout then freed), follow the partially used
nodes downwards to discover other dead nodes and subtrees.

Link: https://lkml.kernel.org/r/20230804165951.2661157-7-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Paul E. McKenney <paulmck@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit 530f745c76)
Bug: 305159730
Signed-off-by: Hyesoo Yu <hyesoo.yu@samsung.com>
Change-Id: I145450351adbf8d379dfb0bfa09f4d41e12f177e
2023-10-23 19:07:25 +00:00
Liam R. Howlett
47e3b4920d UPSTREAM: maple_tree: change mas_adopt_children() parent usage
All calls to mas_adopt_children() currently pass the parent as the node in
the maple state.  Allow for the parent pointer that is passed in to be
used instead.

Link: https://lkml.kernel.org/r/20230804165951.2661157-6-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Paul E. McKenney <paulmck@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit 068bafcac0)
Bug: 305159730
Signed-off-by: Hyesoo Yu <hyesoo.yu@samsung.com>
Change-Id: I34100dada9367e2bfe00c6a921c581455a0b4f54
2023-10-23 19:07:25 +00:00
Liam R. Howlett
e0f829b74b UPSTREAM: maple_tree: introduce mas_tree_parent() definition
Add a definition to shorten long code lines and clarify what the code is
doing.  Use the new definition to get the maple tree parent pointer from
the maple state where possible.

Link: https://lkml.kernel.org/r/20230804165951.2661157-5-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Paul E. McKenney <paulmck@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit 4ffc2ee2cf)
Bug: 305159730
Signed-off-by: Hyesoo Yu <hyesoo.yu@samsung.com>
Change-Id: I4d5ff0c8d3089dfa005a7ae31329b3ce8681fc4f
2023-10-23 19:07:25 +00:00
Liam R. Howlett
e69d6570ed UPSTREAM: maple_tree: introduce mas_put_in_tree()
mas_replace() has a single user that takes a flag which is now always
true.  Replace this function with mas_put_in_tree() to better align with
mas_replace_node().  Inline the remaining logic into the only caller;
mas_wmb_replace().

Link: https://lkml.kernel.org/r/20230804165951.2661157-4-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Paul E. McKenney <paulmck@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit 1238f6a226)
Bug: 305159730
Signed-off-by: Hyesoo Yu <hyesoo.yu@samsung.com>
Change-Id: I180c94f3b57320787c5e2da55566a05193ead6b5
2023-10-23 19:07:25 +00:00
Liam R. Howlett
d2e45cee2d UPSTREAM: maple_tree: reorder replacement of nodes to avoid live lock
Replacing nodes may cause a live lock-up if CPU resources are saturated by
write operations on the tree by continuously retrying on dead nodes.  To
avoid the continuous retry scenario, ensure the new node is inserted into
the tree prior to marking the old data as dead.  This will define a window
where old and new data is swapped.

When reusing lower level nodes, ensure the parent pointer is updated after
the parent is marked dead.  This ensures that the child is still reachable
from the top of the tree, but walking up to a dead node will result in a
single retry that will start a fresh walk from the top down through the
new node.

Link: https://lkml.kernel.org/r/20230804165951.2661157-3-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Paul E. McKenney <paulmck@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit 72bcf4aa86)
Bug: 305159730
Signed-off-by: Hyesoo Yu <hyesoo.yu@samsung.com>
Change-Id: Ib052ccf4a73dfe68a0662185226891d59f98b51a
2023-10-23 19:07:25 +00:00
Sanghoon Bae
545cc51b9f ANDROID: GKI: add allowed list for Exynosauto SoC
This patch adds GKI symbol list for Exynosauto SoC. We need to add
below 8 function symbols and it required by PCIe RC/EP driver.

8 function symbol(s) added
  'int pci_epc_map_addr(struct pci_epc*, u8, u8, phys_addr_t, u64, size_t)'
  'void* pci_epc_mem_alloc_addr(struct pci_epc*, phys_addr_t*, size_t)'
  'void pci_epc_mem_free_addr(struct pci_epc*, phys_addr_t, void*, size_t)'
  'int pci_epc_set_bar(struct pci_epc*, u8, u8, struct pci_epf_bar*)'
  'void pci_epc_unmap_addr(struct pci_epc*, u8, u8, phys_addr_t)'
  'void* pci_ioremap_wc_bar(struct pci_dev*, int)'
  'int pci_num_vf(struct pci_dev*)'
  'int pci_request_regions(struct pci_dev*, const char*)'

Bug: 306538715
Change-Id: If1498963ab1bba9383d42459e67add1576fe71ee
Signed-off-by: Sanghoon Bae <sh86.bae@samsung.com>
2023-10-23 18:20:36 +00:00
Rick Yiu
f51787dfb7 ANDROID: Update the ABI symbol list
Adding the following symbols:
  - __traceiter_android_rvh_update_misfit_status
  - __traceiter_sched_wakeup
  - __tracepoint_android_rvh_update_misfit_status
  - __tracepoint_sched_wakeup
  - __write_overflow_field

Bug: 297343949
Change-Id: I6084399cce623dc6b71e2aa9d927245ae69c7bbb
Signed-off-by: Rick Yiu <rickyiu@google.com>
2023-10-23 16:24:59 +00:00
liangjlee
1b71e8ef45 ANDROID: Update the ABI symbol list
Adding the following symbols:
  - __traceiter_android_vh_mm_compaction_begin
  - __traceiter_android_vh_mm_compaction_end
  - __traceiter_android_vh_si_meminfo_adjust
  - __tracepoint_android_vh_mm_compaction_begin
  - __tracepoint_android_vh_mm_compaction_end
  - __tracepoint_android_vh_si_meminfo_adjust

Bug: 303160914
Change-Id: I3a5c377817608f1be56e3792eb9458212e9cbca8
Signed-off-by: liangjlee <liangjlee@google.com>
2023-10-23 16:23:43 +00:00
Kalesh Singh
908a530787 ANDROID: KVM: Update nVHE stack size to 8KB
In order to make the nVHE stack size easily configurable,
introduce NVHE_STACK_SHIFT which must be >= PAGE_SHIFT.

Increase the stack size to 8KB if PAGE_SIZE is 4KB, since
some vendors require a larger stack in the hypervisor.

Bug: 305486112
Change-Id: Ic7612d5d5bf9d20db811ce67b177bbda192adf92
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
2023-10-23 15:42:08 +00:00
liangjlee
53771c1826 ANDROID: Update the ABI symbol list
Adding the following symbols:
  - __traceiter_android_vh_rmqueue
  - __tracepoint_android_vh_rmqueue

Bug: 303160914
Change-Id: I3404c54f80440ce65e71ad01a2400f4ab0a584a7
Signed-off-by: liangjlee <liangjlee@google.com>
2023-10-20 18:14:09 +00:00
Chiawei Wang
a22ff19ff6 ANDROID: mm: Add vendor hook in rmqueue()
Add a vendor hook for costly order page counting
and other vendor specific functions.

Bug: 174521902
Bug: 172987241
Signed-off-by: Chiawei Wang <chiaweiwang@google.com>
Change-Id: I89206727a462548cc3500b695d85c83ff003eec7
Signed-off-by: Richard Chang <richardycc@google.com>
(cherry picked from commit 369de37804)
Signed-off-by: liangjlee <liangjlee@google.com>
2023-10-20 18:14:09 +00:00
Yi-De Wu
09ca291e0a FROMLIST: virt: geniezone: Add memory pin/unpin support
Protected VM's memory cannot be swapped out because the memory pages are
protected from host access.

Once host accesses to those protected pages, the hardware exception is
triggered and may crash the host. So, we have to make those protected
pages be ineligible for swapping or merging by the host kernel to avoid
host access. To do so, we pin the page when it is assigned (donated) to
VM and unpin when VM relinquish the pages or is destroyed. Besides, the
protected VM’s memory requires hypervisor to clear the content before
returning to host, but VMM may free those memory before clearing, it
will result in those memory pages are reclaimed and reused before
totally clearing. Using pin/unpin can also avoid the above problems.

The implementation is described as follows.
- Use rb_tree to store pinned memory pages.
- Pin the page when handling page fault.

Change-Id: I1c4338e409821cf1f8df46a4951803c4f4728f94
Signed-off-by: Jerry Wang <ze-yu.wang@mediatek.com>
Signed-off-by: Yingshiuan Pan <yingshiuan.pan@mediatek.com>
Signed-off-by: Liju-Clr Chen <liju-clr.chen@mediatek.com>
Signed-off-by: Yi-De Wu <yi-de.wu@mediatek.com>
Bug: 301179926
Link: https://lore.kernel.org/all/20230919111210.19615-15-yi-de.wu@mediatek.com/
2023-10-20 16:31:15 +00:00
Yi-De Wu
7cc3767c2a FROMLIST: virt: geniezone: Add block-based demand paging support
To balance memory usage and performance, GenieZone supports larger
granularity demand paging, called block-based demand paging.
Gzvm driver uses enable_cap to query the hypervisor if it supports
block-based demand paging and the given granularity or not. Meanwhile,
the gzvm driver allocates a shared buffer for storing the physical
pages later.

If the hypervisor supports, every time the gzvm driver handles guest
page faults, it allocates more memory in advance (default: 2MB) for
demand paging. And fills those physical pages into the allocated shared
memory, then calls the hypervisor to map to guest's memory.

The physical pages allocated for block-based demand paging is not
necessary to be contiguous because in many cases, 2MB block is not
followed. 1st, the memory is allocated because of VMM's page fault
(VMM loads kernel image to guest memory before running). In this case,
the page is allocated by the host kernel and using PAGE_SIZE. 2nd is
that guest may return memory to host via ballooning and that is still
4KB (or PAGE_SIZE) granularity. Therefore, we do not have to allocate
physically contiguous 2MB pages.

Change-Id: Id101da5a8ff73dbf5c9a3ab03526cdf5d2f6006e
Signed-off-by: Yingshiuan Pan <yingshiuan.pan@mediatek.com>
Signed-off-by: kevenny hsieh <kevenny.hsieh@mediatek.com>
Signed-off-by: Liju-Clr Chen <liju-clr.chen@mediatek.com>
Signed-off-by: Yi-De Wu <yi-de.wu@mediatek.com>
Bug: 301179926
Link: https://lore.kernel.org/all/20230919111210.19615-16-yi-de.wu@mediatek.com/
2023-10-20 16:31:15 +00:00
Yi-De Wu
3fcc07ee5f FROMLIST: virt: geniezone: Add demand paging support
This page fault handler helps GenieZone hypervisor to do demand paging.
On a lower level translation fault, GenieZone hypervisor will first
check the fault GPA (guest physical address or IPA in ARM) is valid
e.g. within the registered memory region, then it will setup the
vcpu_run->exit_reason with necessary information for returning to
gzvm driver.

With the fault information, the gzvm driver looks up the physical
address and call the MT_HVC_GZVM_MAP_GUEST to request the hypervisor
maps the found PA to the fault GPA (IPA).

There is one exception, for protected vm, we will populate full VM's
memory region in advance in order to improve performance.

Change-Id: Ia295ef4c43201d731202d03e74889fa6403e7176
Signed-off-by: Yingshiuan Pan <yingshiuan.pan@mediatek.com>
Signed-off-by: Jerry Wang <ze-yu.wang@mediatek.com>
Signed-off-by: Yi-De Wu <yi-de.wu@mediatek.com>
Bug: 301179926
Link: https://lore.kernel.org/all/20230919111210.19615-14-yi-de.wu@mediatek.com/
2023-10-20 16:31:15 +00:00
Yi-De Wu
6a1a30896d ANDROID: virt: geniezone: Refactoring memory region support
- Consolidate address translation functions to gzvm_mmu.c.
- To improve performance (especially for booting) we allocate memory
  pages in advance for protected VM. When the virtual machine monitor
  (e.g., crosvm) sets the virtual machine as protected via
  enable_cap ioctl, we allocate full memory pages in advance for the VM.

Change-Id: Ifee061e55e8cfa0e46d2b6dd4b84388a875580cb
Signed-off-by: Jerry Wang <ze-yu.wang@mediatek.com>
Signed-off-by: Yingshiuan Pan <yingshiuan.pan@mediatek.com>
Signed-off-by: Liju-Clr Chen <liju-clr.chen@mediatek.com>
Signed-off-by: Yi-De Wu <yi-de.wu@mediatek.com>
Bug: 301179926
Link: https://lore.kernel.org/all/20230919111210.19615-12-yi-de.wu@mediatek.com/
2023-10-20 16:31:15 +00:00
Yi-De Wu
9f64b18da1 ANDROID: virt: geniezone: Refactor code comments from mainline v6 accordingly
Sync changes to align with upstream-v6
[Detail]
- Response to reviewers and fix bugs accordingly

Change-Id: I4ba05da2875542f067b8b275ce68a4869dcf9ca0
Signed-off-by: Yingshiuan Pan <yingshiuan.pan@mediatek.com>
Signed-off-by: Liju-Clr Chen <liju-clr.chen@mediatek.com>
Signed-off-by: Yi-De Wu <yi-de.wu@mediatek.com>
Bug: 301179926
Link: https://lore.kernel.org/all/20230919111210.19615-1-yi-de.wu@mediatek.com/
2023-10-20 16:31:15 +00:00
Yi-De Wu
544b128747 ANDROID: virt: geniezone: Refactoring vgic to align with upstream v6
Refactor the implementation of virtual gic as below.
- Remove the codes related to vgic ppi because the virtual interrupt
  injection interface is only exposed to VMM which does peripheral
  device emulation, we can assume only spi is used.
- Simplify the api for virtual interrupt injection.

Change-Id: I18ece99f8a678b72483a93ab47b080871d2bb81c
Signed-off-by: kevenny hsieh <kevenny.hsieh@mediatek.com>
Signed-off-by: Yingshiuan Pan <yingshiuan.pan@mediatek.com>
Signed-off-by: Liju-Clr Chen <liju-clr.chen@mediatek.com>
Signed-off-by: Yi-De Wu <yi-de.wu@mediatek.com>
Bug: 301179926
Link: https://lore.kernel.org/all/20230919111210.19615-9-yi-de.wu@mediatek.com/
2023-10-20 16:31:15 +00:00
Yi-De Wu
f9291d7af0 ANDROID: virt: geniezone: Refactoring vcpu to align with upstream v6
The used definitions related to GZVM_REG_* are below and move them to
uapi header file `gzvm.h`.
- Keep `GZVM_REG_SIZE_SHIFT` and `GZVM_REG_SIZE_MASK` so that we can
  determine the reg size.
- The other definitions related to GZVM_REG_* are used by crosvm.
- Rename the definitions to make it easy to understand.

Also removed the unused definitions related to GZVM_REG_* in
gzvm_arch.h and fixed sparse warnings.

Change-Id: I7f709f2532b95d418d22beeb4a46257afa4d92f2
Signed-off-by: kevenny hsieh <kevenny.hsieh@mediatek.com>
Signed-off-by: Yingshiuan Pan <yingshiuan.pan@mediatek.com>
Signed-off-by: Liju-Clr Chen <liju-clr.chen@mediatek.com>
Signed-off-by: Yi-De Wu <yi-de.wu@mediatek.com>
Bug: 301179926
Link: https://lore.kernel.org/all/20230919111210.19615-8-yi-de.wu@mediatek.com/
2023-10-20 16:31:15 +00:00
Yi-De Wu
e348fe6d2d ANDROID: virt: geniezone: Refactoring vm capability to align with upstream v6
- Move the vm capability's definitions to uapi header file `gzvm.h`
- Move the definitions of GZVM_CAP_ARM_PROTECTED_VM's subcommands to
  uapi header file `gzvm.h`
- Rename, remove the substring containing `ARM`, and change "IPA" to
  "GPA"

Change-Id: I89dd810d4bc3cd31ae7ff76e731ff62d7412fa9a
Signed-off-by: kevenny hsieh <kevenny.hsieh@mediatek.com>
Signed-off-by: Yingshiuan Pan <yingshiuan.pan@mediatek.com>
Signed-off-by: Liju-Clr Chen <liju-clr.chen@mediatek.com>
Signed-off-by: Yi-De Wu <yi-de.wu@mediatek.com>
Bug: 301179926
Link: https://lore.kernel.org/all/20230919111210.19615-7-yi-de.wu@mediatek.com/
2023-10-20 16:31:15 +00:00
Yi-De Wu
fb3444af07 ANDROID: virt: geniezone: Refactoring irqfd to align with upstream v6
[Detail]
- remove register/unregister ack notifier
- remove spi setting
- remove resamplerfd
- remove resampler_link

Change-Id: I7c641ba16ebcba208592dc78337501014a832ddf
Signed-off-by: Yingshiuan Pan <yingshiuan.pan@mediatek.com>
Signed-off-by: Yi-De Wu <yi-de.wu@mediatek.com>
Bug: 301179926
Link: https://lore.kernel.org/all/20230919111210.19615-10-yi-de.wu@mediatek.com/
2023-10-20 16:31:15 +00:00
Ziyi Cui
7e1cb3bdec ANDROID: sched: Add EXPORT_SYMBOL_GPL for sched_wakeup
The purpose of the symbol is for getting runnable latency.

Bug: 275806676
Change-Id: I34d8450df16f63d133aaf3e9773a1f5436cbae58
Signed-off-by: Ziyi Cui <ziyic@google.com>
2023-10-19 19:38:47 +00:00
Martin Liu
73cee74111 ANDROID: vendor_hooks: Export direct reclaim trace points
Get direct reclaim info.

Bug: 190795589
Signed-off-by: Martin Liu <liumartin@google.com>
Change-Id: Ie66a3c87484a364a918c19b8e044c82f1afd6749
Signed-off-by: Jack Lee <liangjlee@google.com>
(cherry picked from commit d705ab99ab)
2023-10-19 16:06:25 +00:00
Minchan Kim
fca353bdc0 ANDROID: mm: freeing MIGRATE_ISOLATE page instantly
Since Android has pcp list for MIGRATE_CMA[1], it could cause
CMA allocation latency due to not freeing the MIGRATE_ISOLATE
page immediately.

Originally, MIGRATE_ISOLATED page is supposed to go buddy list
with skipping pcp list. Otherwise, the page could be reallocated
from pcp list or staying on the pcp list until the pcp is drained
so that CMA keeps retrying since it couldn't find the freed page
from buddy list. That worked before since the CMA pfnblocks changed
only from MIGRATE_CMA to MIGRATE_ISOLATE and free function logic
in page allocator has checked MIGRATE_ISOLATEness on every CMA
pages using below.

  free_unref_page_commit
    if (migratetype >= MIGRATE_PCPTYPES)
      if(is_migrate_isolate(migratetype))
        free_one_page(page);

It worked since enum MIGRATE_CMA was bigger than enum
MIGRATE_PCPTYPES but since [1], the enum MIGRATE_CMA is less than
MIGRATE_PCPTYPES so the logic above doesn't work any more.

It could cause following race

         CPU 0	                          CPU 1
  free_unref_page
  migratetype = get_pfnblock_migratetype()
  set_pcppage_migratetype(MIGRATE_CMA)

                                cma_alloc
				alloc_contig_range
                              	set_migrate_isolate(MIGRATE_ISOLATE)
  add the page into pcp list
  the page could be reallocated

This patch couldn't fix the race completely due to missing zone->lock
in order-0 page free(for performance reason). However, it's not a new
problem so we need to deal with the issue separately.

[1] ANDROID: mm: add cma pcp list

Bug: 218731671
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: Ibea20085ce5bfb4b74b83b041f9bda9a380120f9
(cherry picked from commit d9e4b67784)
Signed-off-by: Richard Chang <richardycc@google.com>
2023-10-19 14:07:53 +00:00
Vincent Donnefort
08351370ec ANDROID: KVM: arm64: Allow setting device attr in stage-2 PTEs
Allow pKVM to set device attributes (nGnRE) on stage-2 entries when
KVM_PGTABLE_PROT_DEVICE is used.

Bug: 303529066
Change-Id: I19ddbd627cb67fb4ad295af6ea5fff129d7a94f7
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
2023-10-19 13:29:10 +00:00
Vincent Donnefort
b25aabd50a ANDROID: KVM: arm64: Fix hyp tracing build dependencies
The hyp tracing support depends on CONFIG_TRACING, not CONFIG_FTRACE.
Also, TRACING might be selected while FTRACE is not leading to a build
error.

Bug: 306320920
Change-Id: I69614b6d1eb0e3d9013e00c2d10836b37034b929
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
2023-10-19 10:24:48 +01:00
Venkata Rao Kakani
f82e080810 ANDROID: abi_gki_aarch64_qcom: update abi symbols
add android_vh_bus_iommu_probe symbol to support manipulation
of iommu device register for smmu devices.

Symbols added:
	__traceiter_android_vh_bus_iommu_probe
	__tracepoint_android_vh_bus_iommu_probe

Bug: 305648820

Signed-off-by: Venkata Rao Kakani <quic_vkakani@quicinc.com>
Change-Id: I6ba84f05bb786c06a946ffd3a755e0605441e115
2023-10-18 18:47:09 +00:00
Venkata Rao Kakani
2fff9f7cd4 ANDROID: vendor hooks: Enable Vendor hook to register smmu driver to dedicated iommu bus defined by vendor.
Current implementation of iommu busses driver has temporarily enforce global restriction to a single driver.
This was already the de-facto behaviour, since any possible combination of existing drivers would compete
for at least the PCI or platform bus. Due to this restriction we are not able to probe SMMU v3 driver for PCI bus.

There is an ongoing work in upstream(https://lore.kernel.org/linux-iommu/cover.1696253096.git.robin.murphy@arm.com/#t)
to fix this but we can't backport now as still review in progress.

However, Some of our targets have both SMMU v2 (used by all peripherals except PCIe) and SMMU v3 (PCie) and
they are expected to co-exit in current kernel version.
To cater this requirement, we have implemented a vendor hook, which will skip the pci bus probe for smmuv2 and in
smmuv3 skips all iommu buses execept pcie bus.

Bug: 305648820
Signed-off-by: Venkata Rao Kakani <vkakani@qti.qualcomm.com>
Change-Id: I9304962a7fc7afad93295cc08b3c68f8e340ffe8
2023-10-18 18:47:09 +00:00
Wander Lairson Costa
fadd504206 UPSTREAM: netfilter: xt_sctp: validate the flag_info count
commit e994764976 upstream.

sctp_mt_check doesn't validate the flag_count field. An attacker can
take advantage of that to trigger a OOB read and leak memory
information.

Add the field validation in the checkentry function.

Bug: 304913898
Fixes: 2e4e6a17af ("[NETFILTER] x_tables: Abstraction layer for {ip,ip6,arp}_tables")
Cc: stable@vger.kernel.org
Reported-by: Lucas Leong <wmliang@infosec.exchange>
Signed-off-by: Wander Lairson Costa <wander@redhat.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 4921f9349b)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: Ife4e69f6218fdaca2a8647b5ed00d875a5ed0d34
2023-10-18 15:49:14 +01:00
Yu Zhao
1c90408931 UPSTREAM: mm/mglru: make memcg_lru->lock irq safe
lru_gen_rotate_memcg() can happen in softirq if memory.soft_limit_in_bytes
is set.  This requires memcg_lru->lock to be irq safe.  Lockdep warns on
this.

This problem only affects memcg v1.

Bug: 254441685
Link: https://lkml.kernel.org/r/20230619193821.2710944-1-yuzhao@google.com
Fixes: e4dde56cd2 ("mm: multi-gen LRU: per-node lru_gen_folio lists")
Signed-off-by: Yu Zhao <yuzhao@google.com>
Reported-by: syzbot+87c490fd2be656269b6a@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=87c490fd2be656269b6a
Reviewed-by: Yosry Ahmed <yosryahmed@google.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit 814bc1de03)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I8ae02e92135faad78be6509c3bf18109b0f97a13
2023-10-18 13:18:12 +01:00
Su Hui
87cd3d689e UPSTREAM: iommu/amd: Fix possible memory leak of 'domain'
Move allocation code down to avoid memory leak.

Bug: 254441685
Fixes: 29f54745f2 ("iommu/amd: Add missing domain type checks")
Signed-off-by: Su Hui <suhui@nfschina.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Jerry Snitselaar <jsnitsel@redhat.com>
Reviewed-by: Vasant Hegde <vasant.hegde@amd.com>
Link: https://lore.kernel.org/r/20230608021933.856045-1-suhui@nfschina.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
(cherry picked from commit 5b00369fcf)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: If78fac206bfdc899bed14335ed46eda3946591a2
2023-10-18 13:18:12 +01:00
Vlad Buslov
e5f37a2c46 UPSTREAM: selftests/tc-testing: Remove configs that no longer exist
Some qdiscs and classifiers have recently been retired from kernel.
However, tc-testing config is still cluttered with them which causes noise
when using merge_config.sh script to update existing config for tc-testing
compatibility. Remove the config settings for affected qdiscs and
classifiers.

Bug: 254441685
Fixes: fb38306ceb ("net/sched: Retire ATM qdisc")
Fixes: 051d442098 ("net/sched: Retire CBQ qdisc")
Fixes: bbe77c14ee ("net/sched: Retire dsmark qdisc")
Fixes: 265b4da82d ("net/sched: Retire rsvp classifier")
Fixes: 8c710f7525 ("net/sched: Retire tcindex classifier")
Signed-off-by: Vlad Buslov <vladbu@nvidia.com>
Reviewed-by: Pedro Tammela <pctammela@mojatatu.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
(cherry picked from commit 11b8b2e70a)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: Ifd5de69f462686075f43c7c98937eb7999a4bd17
2023-10-18 13:18:12 +01:00
Ashay Jaiswal
7c793b4d8f ANDROID: abi_gki_aarch64_qcom: update abi symbols
add android_vh_alter_mutex_list_add symbol to support manipulation
of mutex waiter list.

Symbols added:
	__traceiter_android_vh_alter_mutex_list_add
	__tracepoint_android_vh_alter_mutex_list_add

Bug: 305864342
Change-Id: Ic423dc37b5cbe7bb3345c95cdbe8ebb4445dfa85
Signed-off-by: Ashay Jaiswal <quic_ashayj@quicinc.com>
2023-10-17 19:49:11 +00:00
Jindong Yue
bf51ba7b3c ANDROID: ABI: Update symbol list for imx
1 function symbol(s) added
  'long schedule_timeout_idle(long)'

Bug: 283014063
Signed-off-by: Jindong Yue <jindong.yue@nxp.com>
Change-Id: I252020da470046ed5562ead6dec5aee0a5e111ab
2023-10-17 19:34:07 +00:00