Commit Graph

1153708 Commits

Author SHA1 Message Date
Jimmy Hu
bcb7dfe013 UPSTREAM: usb: typec: tcpm: Fix NULL pointer dereference in tcpm_pd_svdm()
It is possible that typec_register_partner() returns ERR_PTR on failure.
When port->partner is an error, a NULL pointer dereference may occur as
shown below.

[91222.095236][  T319] typec port0: failed to register partner (-17)
...
[91225.061491][  T319] Unable to handle kernel NULL pointer dereference
at virtual address 000000000000039f
[91225.274642][  T319] pc : tcpm_pd_data_request+0x310/0x13fc
[91225.274646][  T319] lr : tcpm_pd_data_request+0x298/0x13fc
[91225.308067][  T319] Call trace:
[91225.308070][  T319]  tcpm_pd_data_request+0x310/0x13fc
[91225.308073][  T319]  tcpm_pd_rx_handler+0x100/0x9e8
[91225.355900][  T319]  kthread_worker_fn+0x178/0x58c
[91225.355902][  T319]  kthread+0x150/0x200
[91225.355905][  T319]  ret_from_fork+0x10/0x30

Add a check for port->partner to avoid dereferencing a NULL pointer.

Fixes: 5e1d4c49fb ("usb: typec: tcpm: Determine common SVDM Version")
Cc: stable@vger.kernel.org
Signed-off-by: Jimmy Hu <hhhuuu@google.com>
Link: https://lore.kernel.org/r/20231020012132.100960-1-hhhuuu@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 280207787
(cherry picked from commit 4987daf86c152ff882d51572d154ad12e4ff3a4b)
Change-Id: I609640ff70258b8fd0e7f9eaad9eb60db35ccfad
Signed-off-by: Kyle Tso <kyletso@google.com>
2023-11-29 06:58:14 +00:00
liwei
61ca1246d9 ANDROID: GKI: Update oplus symbol list
add four symbol to oplus symbol list, which already EXPORTED
1. static_key_enable
2. static_key_disable
3. __traceiter_android_vh_alloc_pages_slowpath
4. __tracepoint_android_vh_alloc_pages_slowpath

Bug: 312913816
Change-Id: I2c5776c4b58b8b50e7e4c245492614412042cf9d
Signed-off-by: liwei <liwei1234@oppo.com>
2023-11-28 18:28:02 +00:00
Wander Lairson Costa
d3787b952a UPSTREAM: drm/qxl: fix UAF on handle creation
commit c611589b42 upstream.

qxl_mode_dumb_create() dereferences the qobj returned by
qxl_gem_object_create_with_handle(), but the handle is the only one
holding a reference to it.

A potential attacker could guess the returned handle value and closes it
between the return of qxl_gem_object_create_with_handle() and the qobj
usage, triggering a use-after-free scenario.

Reproducer:

int dri_fd =-1;
struct drm_mode_create_dumb arg = {0};

void gem_close(int handle);

void* trigger(void* ptr)
{
	int ret;
	arg.width = arg.height = 0x20;
	arg.bpp = 32;
	ret = ioctl(dri_fd, DRM_IOCTL_MODE_CREATE_DUMB, &arg);
	if(ret)
	{
		perror("[*] DRM_IOCTL_MODE_CREATE_DUMB Failed");
		exit(-1);
	}
	gem_close(arg.handle);
	while(1) {
		struct drm_mode_create_dumb args = {0};
		args.width = args.height = 0x20;
		args.bpp = 32;
		ret = ioctl(dri_fd, DRM_IOCTL_MODE_CREATE_DUMB, &args);
		if (ret) {
			perror("[*] DRM_IOCTL_MODE_CREATE_DUMB Failed");
			exit(-1);
		}

		printf("[*] DRM_IOCTL_MODE_CREATE_DUMB created, %d\n", args.handle);
		gem_close(args.handle);
	}
	return NULL;
}

void gem_close(int handle)
{
	struct drm_gem_close args;
	args.handle = handle;
	int ret = ioctl(dri_fd, DRM_IOCTL_GEM_CLOSE, &args); // gem close handle
	if (!ret)
		printf("gem close handle %d\n", args.handle);
}

int main(void)
{
	dri_fd= open("/dev/dri/card0", O_RDWR);
	printf("fd:%d\n", dri_fd);

	if(dri_fd == -1)
		return -1;

	pthread_t tid1;

	if(pthread_create(&tid1,NULL,trigger,NULL)){
		perror("[*] thread_create tid1\n");
		return -1;
	}
	while (1)
	{
		gem_close(arg.handle);
	}
	return 0;
}

This is a KASAN report:

==================================================================
BUG: KASAN: slab-use-after-free in qxl_mode_dumb_create+0x3c2/0x400 linux/drivers/gpu/drm/qxl/qxl_dumb.c:69
Write of size 1 at addr ffff88801136c240 by task poc/515

CPU: 1 PID: 515 Comm: poc Not tainted 6.3.0 #3
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.0-debian-1.16.0-4 04/01/2014
Call Trace:
<TASK>
__dump_stack linux/lib/dump_stack.c:88
dump_stack_lvl+0x48/0x70 linux/lib/dump_stack.c:106
print_address_description linux/mm/kasan/report.c:319
print_report+0xd2/0x660 linux/mm/kasan/report.c:430
kasan_report+0xd2/0x110 linux/mm/kasan/report.c:536
__asan_report_store1_noabort+0x17/0x30 linux/mm/kasan/report_generic.c:383
qxl_mode_dumb_create+0x3c2/0x400 linux/drivers/gpu/drm/qxl/qxl_dumb.c:69
drm_mode_create_dumb linux/drivers/gpu/drm/drm_dumb_buffers.c:96
drm_mode_create_dumb_ioctl+0x1f5/0x2d0 linux/drivers/gpu/drm/drm_dumb_buffers.c:102
drm_ioctl_kernel+0x21d/0x430 linux/drivers/gpu/drm/drm_ioctl.c:788
drm_ioctl+0x56f/0xcc0 linux/drivers/gpu/drm/drm_ioctl.c:891
vfs_ioctl linux/fs/ioctl.c:51
__do_sys_ioctl linux/fs/ioctl.c:870
__se_sys_ioctl linux/fs/ioctl.c:856
__x64_sys_ioctl+0x13d/0x1c0 linux/fs/ioctl.c:856
do_syscall_x64 linux/arch/x86/entry/common.c:50
do_syscall_64+0x5b/0x90 linux/arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x72/0xdc linux/arch/x86/entry/entry_64.S:120
RIP: 0033:0x7ff5004ff5f7
Code: 00 00 00 48 8b 05 99 c8 0d 00 64 c7 00 26 00 00 00 48 c7 c0 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 69 c8 0d 00 f7 d8 64 89 01 48

RSP: 002b:00007ff500408ea8 EFLAGS: 00000286 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007ff5004ff5f7
RDX: 00007ff500408ec0 RSI: 00000000c02064b2 RDI: 0000000000000003
RBP: 00007ff500408ef0 R08: 0000000000000000 R09: 000000000000002a
R10: 0000000000000000 R11: 0000000000000286 R12: 00007fff1c6cdafe
R13: 00007fff1c6cdaff R14: 00007ff500408fc0 R15: 0000000000802000
</TASK>

Allocated by task 515:
kasan_save_stack+0x38/0x70 linux/mm/kasan/common.c:45
kasan_set_track+0x25/0x40 linux/mm/kasan/common.c:52
kasan_save_alloc_info+0x1e/0x40 linux/mm/kasan/generic.c:510
____kasan_kmalloc linux/mm/kasan/common.c:374
__kasan_kmalloc+0xc3/0xd0 linux/mm/kasan/common.c:383
kasan_kmalloc linux/./include/linux/kasan.h:196
kmalloc_trace+0x48/0xc0 linux/mm/slab_common.c:1066
kmalloc linux/./include/linux/slab.h:580
kzalloc linux/./include/linux/slab.h:720
qxl_bo_create+0x11a/0x610 linux/drivers/gpu/drm/qxl/qxl_object.c:124
qxl_gem_object_create+0xd9/0x360 linux/drivers/gpu/drm/qxl/qxl_gem.c:58
qxl_gem_object_create_with_handle+0xa1/0x180 linux/drivers/gpu/drm/qxl/qxl_gem.c:89
qxl_mode_dumb_create+0x1cd/0x400 linux/drivers/gpu/drm/qxl/qxl_dumb.c:63
drm_mode_create_dumb linux/drivers/gpu/drm/drm_dumb_buffers.c:96
drm_mode_create_dumb_ioctl+0x1f5/0x2d0 linux/drivers/gpu/drm/drm_dumb_buffers.c:102
drm_ioctl_kernel+0x21d/0x430 linux/drivers/gpu/drm/drm_ioctl.c:788
drm_ioctl+0x56f/0xcc0 linux/drivers/gpu/drm/drm_ioctl.c:891
vfs_ioctl linux/fs/ioctl.c:51
__do_sys_ioctl linux/fs/ioctl.c:870
__se_sys_ioctl linux/fs/ioctl.c:856
__x64_sys_ioctl+0x13d/0x1c0 linux/fs/ioctl.c:856
do_syscall_x64 linux/arch/x86/entry/common.c:50
do_syscall_64+0x5b/0x90 linux/arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x72/0xdc linux/arch/x86/entry/entry_64.S:120

Freed by task 515:
kasan_save_stack+0x38/0x70 linux/mm/kasan/common.c:45
kasan_set_track+0x25/0x40 linux/mm/kasan/common.c:52
kasan_save_free_info+0x2e/0x60 linux/mm/kasan/generic.c:521
____kasan_slab_free linux/mm/kasan/common.c:236
____kasan_slab_free+0x180/0x1f0 linux/mm/kasan/common.c:200
__kasan_slab_free+0x12/0x30 linux/mm/kasan/common.c:244
kasan_slab_free linux/./include/linux/kasan.h:162
slab_free_hook linux/mm/slub.c:1781
slab_free_freelist_hook+0xd2/0x1a0 linux/mm/slub.c:1807
slab_free linux/mm/slub.c:3787
__kmem_cache_free+0x196/0x2d0 linux/mm/slub.c:3800
kfree+0x78/0x120 linux/mm/slab_common.c:1019
qxl_ttm_bo_destroy+0x140/0x1a0 linux/drivers/gpu/drm/qxl/qxl_object.c:49
ttm_bo_release+0x678/0xa30 linux/drivers/gpu/drm/ttm/ttm_bo.c:381
kref_put linux/./include/linux/kref.h:65
ttm_bo_put+0x50/0x80 linux/drivers/gpu/drm/ttm/ttm_bo.c:393
qxl_gem_object_free+0x3e/0x60 linux/drivers/gpu/drm/qxl/qxl_gem.c:42
drm_gem_object_free+0x5c/0x90 linux/drivers/gpu/drm/drm_gem.c:974
kref_put linux/./include/linux/kref.h:65
__drm_gem_object_put linux/./include/drm/drm_gem.h:431
drm_gem_object_put linux/./include/drm/drm_gem.h:444
qxl_gem_object_create_with_handle+0x151/0x180 linux/drivers/gpu/drm/qxl/qxl_gem.c:100
qxl_mode_dumb_create+0x1cd/0x400 linux/drivers/gpu/drm/qxl/qxl_dumb.c:63
drm_mode_create_dumb linux/drivers/gpu/drm/drm_dumb_buffers.c:96
drm_mode_create_dumb_ioctl+0x1f5/0x2d0 linux/drivers/gpu/drm/drm_dumb_buffers.c:102
drm_ioctl_kernel+0x21d/0x430 linux/drivers/gpu/drm/drm_ioctl.c:788
drm_ioctl+0x56f/0xcc0 linux/drivers/gpu/drm/drm_ioctl.c:891
vfs_ioctl linux/fs/ioctl.c:51
__do_sys_ioctl linux/fs/ioctl.c:870
__se_sys_ioctl linux/fs/ioctl.c:856
__x64_sys_ioctl+0x13d/0x1c0 linux/fs/ioctl.c:856
do_syscall_x64 linux/arch/x86/entry/common.c:50
do_syscall_64+0x5b/0x90 linux/arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x72/0xdc linux/arch/x86/entry/entry_64.S:120

The buggy address belongs to the object at ffff88801136c000
which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 576 bytes inside of
freed 1024-byte region [ffff88801136c000, ffff88801136c400)

The buggy address belongs to the physical page:
page:0000000089fc329b refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x11368
head:0000000089fc329b order:3 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0xfffffc0010200(slab|head|node=0|zone=1|lastcpupid=0x1fffff)
raw: 000fffffc0010200 ffff888007841dc0 dead000000000122 0000000000000000
raw: 0000000000000000 0000000080100010 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff88801136c100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88801136c180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88801136c200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88801136c280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88801136c300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
Disabling lock debugging due to kernel taint

Instead of returning a weak reference to the qxl_bo object, return the
created drm_gem_object and let the caller decrement the reference count
when it no longer needs it. As a convenience, if the caller is not
interested in the gobj object, it can pass NULL to the parameter and the
reference counting is descremented internally.

The bug and the reproducer were originally found by the Zero Day Initiative project (ZDI-CAN-20940).

Bug: 311571057
Link: https://www.zerodayinitiative.com/
Signed-off-by: Wander Lairson Costa <wander@redhat.com>
Cc: stable@vger.kernel.org
Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230814165119.90847-1-wander@redhat.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit d578c919de)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: If0e6ae00dd7e90f938beff9c6992ea37ba7bc4fa
2023-11-28 14:34:24 +00:00
Jayant Chowdhary
a2377cc135 FROMGIT: usb:gadget:uvc Do not use worker thread to pump isoc usb requests
When we use an async work queue to perform the function of pumping
usb requests to the usb controller, it is possible that amongst other
factors, thread scheduling affects at what cadence we're able to pump
requests. This could mean isoc usb requests miss their uframes - resulting
in video stream flickers on the host device.

To avoid this, we make the async_wq thread only produce isoc usb_requests
with uvc buffers encoded into them. The process of queueing to the
endpoint is done by the uvc_video_complete() handler. In case no
usb_requests are ready with encoded information, we just queue a zero
length request to the endpoint from the complete handler.

For bulk endpoints the async_wq thread still queues usb requests to the
endpoint.

Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Signed-off-by: Jayant Chowdhary <jchowdhary@google.com>
Suggested-by: Avichal Rakesh <arakesh@google.com>
Suggested-by: Alan Stern <stern@rowland.harvard.edu>
Link: https://lore.kernel.org/r/20231120062026.3759463-1-jchowdhary@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 301915972
(cherry picked from commit 6acba0345b68772830582ca1ca369a2f45631275
 https://kernel.googlesource.com/pub/scm/linux/kernel/git/gregkh/usb usb-next)
Change-Id: I5597cc29e9caec69e4f3575938d7d640857aaa28
Signed-off-by: Avichal Rakesh <arakesh@google.com>
2023-11-28 02:26:06 +00:00
Avichal Rakesh
82a411cec6 FROMGIT: usb: gadget: uvc: Fix use-after-free for inflight usb_requests
Currently, the uvc gadget driver allocates all uvc_requests as one array
and deallocates them all when the video stream stops. This includes
de-allocating all the usb_requests associated with those uvc_requests.
This can lead to use-after-free issues if any of those de-allocated
usb_requests were still owned by the usb controller.

This is patch 2 of 2 in fixing the use-after-free issue. It adds a new
flag to uvc_video to track when frames and requests should be flowing.
When disabling the video stream, the flag is tripped and, instead
of de-allocating all uvc_requests and usb_requests, the gadget
driver only de-allocates those usb_requests that are currently
owned by it (as present in req_free). Other usb_requests are left
untouched until their completion handler is called which takes care
of freeing the usb_request and its corresponding uvc_request.

Now that uvc_video does not depends on uvc->state, this patch removes
unnecessary upates to uvc->state that were made to accommodate uvc_video
logic. This should ensure that uvc gadget driver never accidentally
de-allocates a usb_request that it doesn't own.

Link: https://lore.kernel.org/7cd81649-2795-45b6-8c10-b7df1055020d@google.com
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Reviewed-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Suggested-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Tested-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Signed-off-by: Avichal Rakesh <arakesh@google.com>
Link: https://lore.kernel.org/r/20231109004104.3467968-4-arakesh@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 296925310
(cherry picked from commit da324ffce34c521b239f319d4051260444a3eb4a
 https://kernel.googlesource.com/pub/scm/linux/kernel/git/gregkh/usb usb-next)
Change-Id: Ib0378394dc20e894507f60c70f71c579d046cd7a
Signed-off-by: Avichal Rakesh <arakesh@google.com>
2023-11-28 02:25:57 +00:00
Avichal Rakesh
3c26a5d92f FROMGIT: usb: gadget: uvc: move video disable logic to its own function
This patch refactors the video disable logic in uvcg_video_enable
into its own separate function 'uvcg_video_disable'. This function
is now used anywhere uvcg_video_enable(video, 0) was used.

Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Suggested-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Signed-off-by: Avichal Rakesh <arakesh@google.com>
Link: https://lore.kernel.org/r/20231109004104.3467968-3-arakesh@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 296925310
(cherry picked from commit 2079b60bda3257146a4e8ed7525513865f7e6b3e
 https://kernel.googlesource.com/pub/scm/linux/kernel/git/gregkh/usb usb-next)
Change-Id: Ie8934e6fe1577373b01e3c66626e4239cf9f8c83
Signed-off-by: Avichal Rakesh <arakesh@google.com>
2023-11-28 02:25:57 +00:00
Avichal Rakesh
20853add09 FROMGIT: usb: gadget: uvc: Allocate uvc_requests one at a time
Currently, the uvc gadget driver allocates all uvc_requests as one array
and deallocates them all when the video stream stops. This includes
de-allocating all the usb_requests associated with those uvc_requests.
This can lead to use-after-free issues if any of those de-allocated
usb_requests were still owned by the usb controller.

This patch is 1 of 2 patches addressing the use-after-free issue.
Instead of bulk allocating all uvc_requests as an array, this patch
allocates uvc_requests one at a time, which should allows for similar
granularity when deallocating the uvc_requests. This patch has no
functional changes other than allocating each uvc_request separately,
and similarly freeing each of them separately.

Link: https://lore.kernel.org/7cd81649-2795-45b6-8c10-b7df1055020d@google.com
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Reviewed-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Suggested-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Tested-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Signed-off-by: Avichal Rakesh <arakesh@google.com>
Link: https://lore.kernel.org/r/20231109004104.3467968-2-arakesh@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 296925310
(cherry picked from commit aeb686a98a9e9743c4c0338957e59643a2708146
 https://kernel.googlesource.com/pub/scm/linux/kernel/git/gregkh/usb usb-next)
Change-Id: I33400ac6b28e72c6c10805e167e8bab7e2520a28
Signed-off-by: Avichal Rakesh <arakesh@google.com>
2023-11-28 02:25:57 +00:00
Avichal Rakesh
5f3550218b FROMGIT: usb: gadget: uvc: prevent use of disabled endpoint
Currently the set_alt callback immediately disables the endpoint and queues
the v4l2 streamoff event. However, as the streamoff event is processed
asynchronously, it is possible that the video_pump thread attempts to queue
requests to an already disabled endpoint.

This change moves disabling usb endpoint to the end of streamoff event
callback. As the endpoint's state can no longer be used, video_pump is
now guarded by uvc->state as well. To be consistent with the actual
streaming state, uvc->state is now toggled between CONNECTED and STREAMING
from the v4l2 event callback only.

Link: https://lore.kernel.org/20230615171558.GK741@pendragon.ideasonboard.com/
Link: https://lore.kernel.org/20230531085544.253363-1-dan.scally@ideasonboard.com/
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Reviewed-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Tested-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Signed-off-by: Avichal Rakesh <arakesh@google.com>
Link: https://lore.kernel.org/r/20231109004104.3467968-1-arakesh@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 296925310
(cherry picked from commit 991544dc579b636e69defa3eec486fd6f6191e59
 https://kernel.googlesource.com/pub/scm/linux/kernel/git/gregkh/usb usb-next)
Change-Id: Ic5631a526e72cbcf299dcb8167bb3d34468d37e9
Signed-off-by: Avichal Rakesh <arakesh@google.com>
2023-11-28 02:25:57 +00:00
Jonas Karlman
9673df54cd UPSTREAM: drm/fourcc: Add NV20 and NV30 YUV formats
DRM_FORMAT_NV20 and DRM_FORMAT_NV30 formats is the 2x1 and non-subsampled
variant of NV15, a 10-bit 2-plane YUV format that has no padding between
components. Instead, luminance and chrominance samples are grouped into 4s
so that each group is packed into an integer number of bytes:

YYYY = UVUV = 4 * 10 bits = 40 bits = 5 bytes

The '20' and '30' suffix refers to the optimum effective bits per pixel
which is achieved when the total number of luminance samples is a multiple
of 4.

V2: Added NV30 format

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Reviewed-by: Sandy Huang <hjc@rock-chips.com>
Reviewed-by: Christopher Obbard <chris.obbard@collabora.com>
Tested-by: Christopher Obbard <chris.obbard@collabora.com>
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20231023173718.188102-2-jonas@kwiboo.se

Bug: 300024866
(cherry picked from commit 728c15b4b5f3369cbde73d5e0f14701ab370f985)
Change-Id: Ia8fbb5b785c6fc2b4d188bbcef62e232c2ba8ce8
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
2023-11-28 00:13:07 +00:00
Yi-De Wu
3ee517981d FROMLIST: virt: geniezone: Add memory relinquish support
Unpin the pages when VM relinquish the pages or is destroyed.

Change-Id: I9729f6ea93fee50a812dd43016754fdf812daa74
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/20231116152756.4250-17-yi-de.wu@mediatek.com/
2023-11-27 19:03:01 +00:00
Biswarup Pal
c57b152c45 FROMGIT: Input: uinput - allow injecting event times
Currently, uinput doesn't use the input_set_timestamp API, so any
event injected using uinput is not accurately timestamped in terms of
measuring when the actual event happened. Hence, call the
input_set_timestamp API from uinput in order to provide a more
accurate sense of time for the event. Propagate only the timestamps
which are a) positive, b) within a pre-defined offset (10 secs) from
the current time, and c) not in the future.

Bug: 271946580
Bug: 277040837
Change-Id: I928be61d0114b78e2098995ee49eeb0376bef2a3
(cherry picked from commit 3a2df60200
https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git master)
Signed-off-by: Biswarup Pal <biswarupp@google.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Siarhei Vishniakou <svv@google.com>
Link: https://lore.kernel.org/r/20230427000152.1407471-1-biswarupp@google.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
(cherry picked from commit ee1f5fc55cc7bf1bca78edbb8a1f9d989d4ea03e)
2023-11-27 17:31:12 +00:00
Pavankumar Kondeti
df6e6fc38f UPSTREAM: PM: hibernate: Fix copying the zero bitmap to safe pages
The following crash is observed 100% of the time during resume from
the hibernation on a x86 QEMU system.

[   12.931887]  ? __die_body+0x1a/0x60
[   12.932324]  ? page_fault_oops+0x156/0x420
[   12.932824]  ? search_exception_tables+0x37/0x50
[   12.933389]  ? fixup_exception+0x21/0x300
[   12.933889]  ? exc_page_fault+0x69/0x150
[   12.934371]  ? asm_exc_page_fault+0x26/0x30
[   12.934869]  ? get_buffer.constprop.0+0xac/0x100
[   12.935428]  snapshot_write_next+0x7c/0x9f0
[   12.935929]  ? submit_bio_noacct_nocheck+0x2c2/0x370
[   12.936530]  ? submit_bio_noacct+0x44/0x2c0
[   12.937035]  ? hib_submit_io+0xa5/0x110
[   12.937501]  load_image+0x83/0x1a0
[   12.937919]  swsusp_read+0x17f/0x1d0
[   12.938355]  ? create_basic_memory_bitmaps+0x1b7/0x240
[   12.938967]  load_image_and_restore+0x45/0xc0
[   12.939494]  software_resume+0x13c/0x180
[   12.939994]  resume_store+0xa3/0x1d0

The commit being fixed introduced a bug in copying the zero bitmap
to safe pages. A temporary bitmap is allocated with PG_ANY flag in
prepare_image() to make a copy of zero bitmap after the unsafe pages
are marked. Freeing this temporary bitmap with PG_UNSAFE_KEEP later
results in an inconsistent state of unsafe pages. Since free bit is
left as is for this temporary bitmap after free, these pages are
treated as unsafe pages when they are allocated again. This results
in incorrect calculation of the number of pages pre-allocated for the
image.

nr_pages = (nr_zero_pages + nr_copy_pages) - nr_highmem - allocated_unsafe_pages;

The allocate_unsafe_pages is estimated to be higher than the actual
which results in running short of pages in safe_pages_list. Hence the
crash is observed in get_buffer() due to NULL pointer access of
safe_pages_list.

Fix this issue by creating the temporary zero bitmap from safe pages
(free bit not set) so that the corresponding free bits can be cleared
while freeing this bitmap.

Bug: 311131385
(cherry picked from commit b21f18ef96
 git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master)
Fixes: 005e8dddd4 ("PM: hibernate: don't store zero pages in the image file")
Suggested-by:: Brian Geffon <bgeffon@google.com>
Signed-off-by: Pavankumar Kondeti <quic_pkondeti@quicinc.com>
Reviewed-by: Brian Geffon <bgeffon@google.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Change-Id: Id68699710e40c5e8eec227bfe0d8311c1e788d5e
Signed-off-by: Pavankumar Kondeti <quic_pkondeti@quicinc.com>
Signed-off-by: Mukesh Pilaniya <quic_mpilaniy@quicinc.com>
2023-11-27 17:04:26 +00:00
Brian Geffon
7181d45e36 UPSTREAM: PM: hibernate: don't store zero pages in the image file
On ChromeOS we've observed a considerable number of in-use pages filled with
zeros. Today with hibernate it's entirely possible that saveable pages are just
zero filled. Since we're already copying pages word-by-word in do_copy_page it
becomes almost free to determine if a page was completely filled with zeros.

This change introduces a new bitmap which will track these zero pages. If a page
is zero it will not be included in the saved image, instead to track these zero
pages in the image file we will introduce a new flag which we will set on the
packed PFN list. When reading back in the image file we will detect these zero
page PFNs and rebuild the zero page bitmap.

When the image is being loaded through calls to write_next_page if we encounter
a zero page we will silently memset it to 0 and then continue on to the next
page. Given the implementation in snapshot_read_next/snapshot_write_next this
change  will be transparent to non-compressed/compressed and swsusp modes of
operation.

To provide some concrete numbers from simple ad-hoc testing, on a device which
was lightly in use we saw that:

PM: hibernation: Image created (964408 pages copied, 548304 zero pages)

Of the approximately 6.2GB of saveable pages 2.2GB (36%) were just zero filled
and could be tracked entirely within the packed PFN list. The savings would
obviously be much lower for lzo compressed images, but even in the case of
compression not copying pages across to the compression threads will still
speed things up. It's also possible that we would see better overall compression
ratios as larger regions of "real data" would improve the compressibility.

Finally, such an approach could dramatically improve swsusp performance
as each one of those zero pages requires a write syscall to reload, by
handling it as part of the packed PFN list we're able to fully avoid
that.

Bug: 311131385
(cherry picked from commit 005e8dddd4
 git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master)
Signed-off-by: Brian Geffon <bgeffon@google.com>
[ rjw: Whitespace adjustments, removal of redundant parentheses ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Change-Id: Ia42a965d10e3a9e3760c29eb1a31b48c575297b9
Signed-off-by: Pavankumar Kondeti <quic_pkondeti@quicinc.com>
Signed-off-by: Mukesh Pilaniya <quic_mpilaniy@quicinc.com>
2023-11-27 17:04:26 +00:00
Xueqin Luo
7385b83107 UPSTREAM: PM: hibernate: Complain about memory map mismatches during resume
The system memory map can change over a hibernation-restore cycle due
to a defect in the platform firmware, and some of the page frames used
by the kernel before hibernation may not be available any more during
the subsequent restore which leads to the error below.

[  T357] PM: Image loading progress:   0%
[  T357] PM: Read 2681596 kbytes in 0.03 seconds (89386.53 MB/s)
[  T357] PM: Error -14 resuming
[  T357] PM: Failed to load hibernation image, recovering.
[  T357] PM: Basic memory bitmaps freed
[  T357] OOM killer enabled.
[  T357] Restarting tasks ... done.
[  T357] PM: resume from hibernation failed (-14)
[  T357] PM: Hibernation image not present or could not be loaded.

Add an error message to the unpack() function to allow problematic
page frames to be identified and the source of the problem to be
diagnosed more easily. This can save developers quite a bit of
debugging time.

Bug: 311131385
(cherry picked from commit 3363e0adb3
  git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git)
Signed-off-by: Xueqin Luo <luoxueqin@kylinos.cn>
[ rjw: New subject, edited changelog ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Change-Id: I8283510db3d3217f679e3cda0c0991f3b9437c18
Signed-off-by: Pavankumar Kondeti <quic_pkondeti@quicinc.com>
Signed-off-by: Mukesh Pilaniya <quic_mpilaniy@quicinc.com>
2023-11-27 17:04:26 +00:00
Mukesh Ojha
d2c0f4c450 FROMLIST: devcoredump: Send uevent once devcd is ready
dev_coredumpm() creates a devcoredump device and adds it
to the core kernel framework which eventually end up
sending uevent to the user space and later creates a
symbolic link to the failed device. An application
running in userspace may be interested in this symbolic
link to get the name of the failed device.

In a issue scenario, once uevent sent to the user space
it start reading '/sys/class/devcoredump/devcdX/failing_device'
to get the actual name of the device which might not been
created and it is in its path of creation.

To fix this, suppress sending uevent till the failing device
symbolic link gets created and send uevent once symbolic
link is created successfully.

Bug: 311580372
Link: https://lore.kernel.org/lkml/1700232572-25823-1-git-send-email-quic_mojha@quicinc.com
Change-Id: Iee739e29492056df9d664ef2294a7e0cdcc4458e
Fixes: 833c95456a ("device coredump: add new device coredump class")
Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
Cc: stable@vger.kernel.org
Signed-off-by: Naman Jain <quic_namajain@quicinc.com>
2023-11-24 19:28:43 +00:00
Robin Murphy
95307ec5c8 FROMLIST: iommu: Avoid more races around device probe
It turns out there are more subtle races beyond just the main part of
__iommu_probe_device() itself running in parallel - the dev_iommu_free()
on the way out of an unsuccessful probe can still manage to trip up
concurrent accesses to a device's fwspec. Thus, extend the scope of
iommu_probe_device_lock() to also serialise fwspec creation and initial
retrieval.

Reported-by: Zhenhua Huang <quic_zhenhuah@quicinc.com>
Link: https://lore.kernel.org/linux-iommu/e2e20e1c-6450-4ac5-9804-b0000acdf7de@quicinc.com/
Fixes: 01657bc14a ("iommu: Avoid races around device probe")
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Bug: 308940593
Link: https://lore.kernel.org/all/16f433658661d7cadfea51e7c65da95826112a2b.1700071477.git.robin.murphy@arm.com/
Change-Id: I461df05b03644cb93bc93599cb9f5464bf893923
Signed-off-by: André Draszik <draszik@google.com>
2023-11-23 09:00:10 +00:00
Claire Chang
5c8e593916 ANDROID: Update the ABI symbol list
Adding the following symbols:
  - anon_inode_getfile

Bug: 312619042
Change-Id: I48be67c5fcaf441ad74793ab7e02b39ca284d528
Signed-off-by: Claire Chang <tientzu@google.com>
2023-11-22 13:53:07 +08:00
Peter Wang
94ddfc9ce4 FROMLIST: ufs: core: clear cmd if abort success in mcq mode
In mcq mode, if cmd is pending in device and abort success, response
will not return from device. So we need clear this cmd right now,
else command timeout happen and next time use same tag will have
warning. WARN_ON(lrbp->cmd).

Below is error log:
<3>[ 2277.447611][T21376] ufshcd-mtk 112b0000.ufshci: ufshcd_try_to_abort_task: cmd pending in the device. tag = 7
<3>[ 2277.476954][T21376] ufshcd-mtk 112b0000.ufshci: Aborting tag 7 / CDB 0x2a succeeded
<6>[ 2307.551263][T30974] ufshcd-mtk 112b0000.ufshci: ufshcd_abort: Device abort task at tag 7
<4>[ 2307.623264][  T327] WARNING: CPU: 5 PID: 327 at source/drivers/ufs/core/ufshcd.c:3021 ufshcd_queuecommand+0x66c/0xe34

Bug: 311330965
Link: https://lore.kernel.org/all/20231115131024.15829-1-peter.wang@mediatek.com/
[Peter: Resolved minor conflict in drivers/ufs/core/ufshcd.c ]
Change-Id: I8e5ed6774a68faa4a663cc602dac56faf5e3317c
Signed-off-by: Peter Wang <peter.wang@mediatek.com>
2023-11-21 22:04:42 +00:00
Vinayak Yadawad
8f46c34931 BACKPORT: wifi: cfg80211: Allow AP/P2PGO to indicate port authorization to peer STA/P2PClient
In 4way handshake offload, cfg80211_port_authorized enables driver
to indicate successful 4way handshake to cfg80211 layer. Currently
this path of port authorization is restricted to interface type
NL80211_IFTYPE_STATION and NL80211_IFTYPE_P2P_CLIENT. This patch
extends the support for NL80211_IFTYPE_AP and NL80211_IFTYPE_P2P_GO
interfaces to authorize peer STA/P2P_CLIENT, whenever authentication
is offloaded on the AP/P2P_GO interface.

Signed-off-by: Vinayak Yadawad <vinayak.yadawad@broadcom.com>
Link: https://lore.kernel.org/r/dee3b0a2b4f617e932c90bff4504a89389273632.1695721435.git.vinayak.yadawad@broadcom.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Bug: 301410304
(cherry picked from commit e4e7e3af73694380f0d9a742d13b80598a3393e9)
[chenpaul: adjust the format by checkpatch]
Signed-off-by: Paul Chen <chenpaul@google.com>
Change-Id: Id9704d7b412396f45e888895e42ba161ecb0ab56
2023-11-20 22:25:18 +00:00
Vinayak Yadawad
b3ccd8f092 BACKPORT: wifi: cfg80211: OWE DH IE handling offload
Introduce new feature flags for OWE offload that driver can
advertise to indicate kernel/application space to avoid DH IE
handling. When this flag is advertised, the driver/device will
take care of DH IE inclusion and processing of peer DH IE to
generate PMK.

Signed-off-by: Vinayak Yadawad <vinayak.yadawad@broadcom.com>
Link: https://lore.kernel.org/r/f891cce4b52c939dfc6b71bb2f73e560e8cad287.1695374530.git.vinayak.yadawad@broadcom.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Bug: 301410304
(cherry picked from commit 5482c0a28b2634e7a7d8ddaca7feac183e74b528)
[chenpaul: use reserved fields instead of adding new one]
Signed-off-by: Paul Chen <chenpaul@google.com>
Change-Id: I8322e53b74d995471411967aba846a2b712e5d85
2023-11-20 22:25:18 +00:00
Vincent Donnefort
daa7a3d95d ANDROID: KVM: arm64: mount procfs for pKVM module loading
modprobe needs /proc/cmdline to pass module arguments to the module
loader. Sadly, so early in the boot, nothing mounts that FS.

Bug: 301483379
Change-Id: Iaab3000e3b7f908fc81f7f36adf2f73c7d3129a4
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
2023-11-20 08:41:13 +00:00
Seiya Wang
1b639e97b8 ANDROID: GKI: Update symbol list for mtk
Add following symbols

bitmap_alloc
cpufreq_cpu_get_raw
cpufreq_get_driver_data
cpufreq_update_policy
cpufreq_update_util_data
devm_clk_get_optional_enabled
devm_gpiod_get_array
devm_pwmchip_add
dev_pm_opp_adjust_voltage
dev_pm_opp_disable
dev_pm_opp_enable
dev_set_threaded
dma_vmap_noncontiguous
drm_connector_set_panel_orientation
drm_panel_of_backlight
_find_first_and_bit
gpiod_set_array_value_cansleep
hid_debug
hid_driver_reset_resume
hid_driver_suspend
i2c_smbus_read_byte
irq_find_matching_fwspec
memdup_user_nul
mipi_dsi_dcs_enter_sleep_mode
mipi_dsi_dcs_set_display_off
mmc_pwrseq_register
mmc_pwrseq_unregister
of_drm_get_panel_orientation
pm_suspend_target_state
return_address
serial8250_do_pm
snd_vendor_set_ops
_trace_android_vh_record_pcpu_rwsem_time_early
__traceiter_android_rvh_cpufreq_transition
__traceiter_android_rvh_post_init_entity_util_avg
__traceiter_android_vh_binder_trans
__traceiter_android_vh_check_uninterrupt_tasks
__traceiter_android_vh_dump_throttled_rt_tasks
__traceiter_android_vh_setscheduler_uclamp
__tracepoint_android_rvh_cpufreq_transition
__tracepoint_android_rvh_post_init_entity_util_avg
__tracepoint_android_vh_binder_trans
__tracepoint_android_vh_check_uninterrupt_tasks
__tracepoint_android_vh_dump_throttled_rt_tasks
__tracepoint_android_vh_setscheduler_uclamp
ufshcd_mcq_poll_cqe_lock
ufshcd_mcq_write_cqis
unpin_user_pages_dirty_lock

Bug: 311514694
Signed-off-by: Seiya Wang <seiya.wang@mediatek.com>
Change-Id: Ibda780725c05cbd5fccf2716f107ba6fa308a1cb
2023-11-17 17:44:26 +00:00
liujing40
b496cc3115 ANDROID: fuse-bpf: Add NULL pointer check in fuse_release_in
If open request sent to classic fuse, backing_file is null.
In fuse_release_initialize, fput will trigger a crash.

Bug: 297831741
Change-Id: I2d54d99d62b54c39a6dc9064f8f62488433aff6f
Signed-off-by: liujing40 <liujing40@xiaomi.corp-partner.google.com>
2023-11-16 21:27:17 +00:00
Andy Shevchenko
8431e524d6 UPSTREAM: serial: 8250_port: Check IRQ data before use
In case the leaf driver wants to use IRQ polling (irq = 0) and
IIR register shows that an interrupt happened in the 8250 hardware
the IRQ data can be NULL. In such a case we need to skip the wake
event as we came to this path from the timer interrupt and quite
likely system is already awake.

Without this fix we have got an Oops:

    serial8250: ttyS0 at I/O 0x3f8 (irq = 0, base_baud = 115200) is a 16550A
    ...
    BUG: kernel NULL pointer dereference, address: 0000000000000010
    RIP: 0010:serial8250_handle_irq+0x7c/0x240
    Call Trace:
     ? serial8250_handle_irq+0x7c/0x240
     ? __pfx_serial8250_timeout+0x10/0x10

Fixes: 0ba9e3a13c ("serial: 8250: Add missing wakeup event reporting")
Cc: stable <stable@kernel.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Link: https://lore.kernel.org/r/20230831222555.614426-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 311265203
Change-Id: I36cdceb31da5a000f336a96347e99119df308064
(cherry picked from commit cce7fc8b29)
Signed-off-by: Yuan-Jen Cheng <cyuanjen@google.com>
2023-11-16 21:07:48 +00:00
Keir Fraser
825c17428a ANDROID: KVM: arm64: Fix error path in pkvm_mem_abort()
On one error path, pin_user_pages has succeeded and should be
undone.

Bug: 310131277
Change-Id: I92fe0c54bb5b8005f848491f5e9be1090b61fbd1
Signed-off-by: Keir Fraser <keirf@google.com>
2023-11-16 11:32:03 +00:00
Harshdeep Dhatt
22e9166465 ANDROID: abi_gki_aarch64_qcom: Update symbol list
The adreno graphics driver requires these two symbols
to enhance debugging.

Symbols added:
   trace_array_get_by_name
   trace_array_set_clr_event

Bug: 310950241
Change-Id: I232237983b19cbf9d0874913a11fdc2d6f5261cc
Signed-off-by: Harshdeep Dhatt <quic_hdhatt@quicinc.com>
2023-11-15 23:56:51 +00:00
Hang Wei
ca06bb1e93 ANDROID: GKI: add allowed list for Exynosauto SoC
This patch adds GKI symbol list for Exynosauto SoC. We need to add
below 3 function symbols and it required by VLX driver.

3 function symbol(s) added
  'struct work_struct* current_work()'
  'int sigprocmask(int, sigset_t*, sigset_t*)'
  'struct thermal_zone_device* thermal_of_zone_register(struct device_node*, int, void*, const struct thermal_zone_device_ops*)'

Bug: 310831391
Change-Id: Ibc0405f9e72eb1cc11095eab715130f4ec1ec0ee
Signed-off-by: Hang Wei <hang01.wei@samsung.com>
2023-11-15 22:28:41 +00:00
Chungkai Mei
fb91717581 ANDROID: Update the ABI symbol list
Adding the following symbols:
  - __traceiter_android_rvh_util_fits_cpu
  - __tracepoint_android_rvh_util_fits_cpu

Bug: 261704404
Change-Id: I3f3f42796c02b8403156d24faf3d3e4c45b7a1dc
Signed-off-by: Chungkai Mei <chungkai@google.com>
2023-11-15 22:01:23 +00:00
Chungkai Mei
ec3c9a1702 ANDROID: sched: Add vendor hook for util_fits_cpu
vendor may have the need to implement their own util_fits_cpu
function

Bug: 261704404
Change-Id: I0318f6cadd5c45a37f1acafdded479b25e520e6b
Signed-off-by: Chungkai Mei <chungkai@google.com>
2023-11-15 22:01:23 +00:00
Haonan Wang
c47043d65f ANDROID: update symbol for unisoc vendor_hooks
Add slab_folio_alloced

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

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

Bug: 302090264
Change-Id: I65c1e0e01b4140f39fae673a1b4a08e1a0d2d0c1
Signed-off-by: Haonan Wang <haonan.wang@unisoc.com>
2023-11-14 23:07:42 +00:00
Haonan Wang
6e881bf034 ANDROID: vendor_hooks: mm: add hook to count the number pages
allocated for each slab

We want to add an interface that can detect the number of pages
allocated by the slab, and if exceeds a threshold, trigger a
panic or other actions.

Bug: 302090264
Change-Id: I8fcae6a97046806376b95b66085dd5b852c2d1e8
Signed-off-by: Haonan Wang <haonan.wang@unisoc.com>
2023-11-14 23:07:42 +00:00
Krishna Kurapati
a59b32866c UPSTREAM: usb: gadget: udc: Handle gadget_connect failure during bind operation
In the event gadget_connect call (which invokes pullup) fails,
propagate the error to udc bind operation which in turn sends the
error to configfs. The userspace can then retry enumeration if
it chooses to.

Signed-off-by: Krishna Kurapati <quic_kriskura@quicinc.com>
Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
Link: https://lore.kernel.org/r/20230927073027.27952-1-quic_kriskura@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

(cherry picked from commit 0ea39e030a80be2b1b5f98d6b330a8b97dcf3342
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/ master)

Bug: 309886715
Change-Id: I454616a38e3eba1c358da0056057b585416af68c
Signed-off-by: Krishna Kurapati <quic_kriskura@quicinc.com>
2023-11-13 20:05:51 +00:00
Rick Yiu
7a33209b36 ANDROID: Update the ABI symbol list
Adding the following symbols:
  - __traceiter_softirq_entry
  - __traceiter_softirq_exit
  - __tracepoint_softirq_entry
  - __tracepoint_softirq_exit

Bug: 297343949
Change-Id: Ie0e3a8b891c1a3fbb764d18f54d0117e2162efc3
Signed-off-by: Rick Yiu <rickyiu@google.com>
2023-11-13 06:49:48 +00:00
Ziyi Cui
69b689971a ANDROID: softirq: Add EXPORT_SYMBOL_GPL for softirq and tasklet
The purpose of these symbols is for getting irq/softirq latency. Currently we only have symbols for irq_handler_entry and irq_handler_exit. We would use these latency for further monitoring and debugging.

The related tracepoints were defined in trace/events/irq.h. We would use these tracepoints in vendor kernel module.

Bug: 227809911
Signed-off-by: Ziyi Cui <ziyic@google.com>
Change-Id: Idf4ccdede5232689b2752283539aee54a5f67866
2023-11-13 06:49:41 +00:00
Lyon Wang
48c6c901fe ANDROID: fs/passthrough: Fix compatibility with R/O file system
Look at the passthrough file and check to see if its mount is read-only.

Bug: 297482438
Signed-off-by: Lyon Wang <lyon.wang@mediatek.com>
Change-Id: I0f483c6bcb1effe395eee07b6d721f343840d115
(cherry picked from commit dbeed23196)
2023-11-10 17:58:48 +00:00
Badhri Jagan Sridharan
abcd4c51e7 FROMLIST: usb: typec: tcpm: Fix sink caps op current check
TCPM checks for sink caps operational current even when PD is disabled.
This incorrectly sets tcpm_set_charge() when PD is disabled.
Check for sink caps only when PD is enabled.

[   97.572342] Start toggling
[   97.578949] CC1: 0 -> 0, CC2: 0 -> 0 [state TOGGLING, polarity 0, disconnected]
[   99.571648] CC1: 0 -> 0, CC2: 0 -> 4 [state TOGGLING, polarity 0, connected]
[   99.571658] state change TOGGLING -> SNK_ATTACH_WAIT [rev3 NONE_AMS]
[   99.571673] pending state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED @ 170 ms [rev3 NONE_AMS]
[   99.741778] state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED [delayed 170 ms]
[   99.789283] CC1: 0 -> 0, CC2: 4 -> 5 [state SNK_DEBOUNCED, polarity 0, connected]
[   99.789306] state change SNK_DEBOUNCED -> SNK_DEBOUNCED [rev3 NONE_AMS]
[   99.903584] VBUS on
[   99.903591] state change SNK_DEBOUNCED -> SNK_ATTACHED [rev3 NONE_AMS]
[   99.903600] polarity 1
[   99.910155] enable vbus discharge ret:0
[   99.910160] Requesting mux state 1, usb-role 2, orientation 2
[   99.946791] state change SNK_ATTACHED -> SNK_STARTUP [rev3 NONE_AMS]
[   99.946798] state change SNK_STARTUP -> SNK_DISCOVERY [rev3 NONE_AMS]
[   99.946800] Setting voltage/current limit 5000 mV 500 mA
[   99.946803] vbus=0 charge:=1
[  100.027139] state change SNK_DISCOVERY -> SNK_READY [rev3 NONE_AMS]
[  100.027145] Setting voltage/current limit 5000 mV 3000 mA
[  100.466830] VBUS on

Bug: 307718635
Bug: 304820253
Link: https://lore.kernel.org/all/20231101012845.2701348-1-badhri@google.com/
Cc: stable@vger.kernel.org
Fixes: 803b1c8a0c ("usb: typec: tcpm: not sink vbus if operational current is 0mA")
Change-Id: Id780b77a37b4c9d6cde286ae089ac41852633800
Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Tested-by: Will McVicker <willmcvicker@google.com>
Signed-off-by: Will McVicker <willmcvicker@google.com>
2023-11-09 13:10:48 +00:00
Bean Huo
9d6ac9dc6a UPSTREAM: scsi: ufs: core: Add advanced RPMB support where UFSHCI 4.0 does not support EHS length in UTRD
According to UFSHCI 4.0 specification:

5.2 Host Controller Capabilities Registers
5.2.1 Offset 00h: CAP – Controller Capabilities:

 "EHS Length in UTRD Supported (EHSLUTRDS): Indicates whether the host
  controller supports EHS Length field in UTRD.

  0 – Host controller takes EHS length from CMD UPIU, and SW driver use EHS
  Length field in CMD UPIU.

  1 – HW controller takes EHS length from UTRD, and SW driver use EHS
  Length field in UTRD.

  NOTE Recommend Host controllers move to taking EHS length from UTRD, and
  in UFS-5, it will be mandatory."

So, when UFSHCI 4.0 doesn't support EHS Length field in UTRD, we could use
EHS Length field in CMD UPIU. Remove the limitation that advanced RPMB only
works when EHS length is supported in UTRD.

Bug: 254441685
Fixes: 6ff265fc5e ("scsi: ufs: core: bsg: Add advanced RPMB support in ufs_bsg")
Co-developed-by: "jonghwi.rha" <jonghwi.rha@samsung.com>
Signed-off-by: "jonghwi.rha" <jonghwi.rha@samsung.com>
Signed-off-by: Bean Huo <beanhuo@micron.com>
Link: https://lore.kernel.org/r/20230809181847.102123-2-beanhuo@iokpp.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit c91e585cfb)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I10ec989b7d02bed7d828d756fd11078cf73ff371
2023-11-09 08:23:35 +00:00
Browse Zhang
beea09533d ANDROID: ABI: Update symbol list for MediatTek
Add android_vh_mmc_update_mmc_queue to MTK symbol list

1 function symbol(s) added
  'int __traceiter_android_vh_mmc_update_mmc_queue(void*, struct mmc_card*, struct mmc_queue*)'

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

Bug: 306334321
Change-Id: I4bf1ab86b273eaa4910f76d7deb7d8ddf5ded5cb
Signed-off-by: Qilin Tan <qilin.tan@mediatek.com>
Signed-off-by: Browse Zhang <browse.zhang@mediatek.com>
2023-11-07 20:48:00 +00:00
Browse Zhang
5683c2b460 ANDROID: vendor_hooks: Add hook for mmc queue
Add a mmc hook to support customizing mmc queue by vendor host
requirements

Bug: 306334321
Change-Id: I737485c3fc0438ef221cd3ffe81a66f7e3b66500
Signed-off-by: Qilin Tan <qilin.tan@mediatek.com>
Signed-off-by: Browse Zhang <browse.zhang@mediatek.com>
2023-11-07 19:16:27 +00:00
Todd Kjos
43a07d84da Revert "proc: allow pid_revalidate() during LOOKUP_RCU"
This reverts commit da4d6b9cf8.

Appears to cause stale dcache entries for inodes in /proc/$pid
filesystem resulting in ESRCH failures on access to files
under /proc/self

Bug: 305682813
Bug: 306055483
Signed-off-by: Todd Kjos <tkjos@google.com>
Change-Id: I004338c043d7e777fdfef343e45ccb20ff4d503b
2023-11-07 15:27:33 +00:00
Neil Armstrong
230d34da33 UPSTREAM: scsi: ufs: ufs-qcom: Clear qunipro_g4_sel for HW major version > 5
The qunipro_g4_sel clear is also needed for new platforms with major
version > 5. Fix the version check to take this into account.

Bug: 254441685
Fixes: 9c02aa24bf ("scsi: ufs: ufs-qcom: Clear qunipro_g4_sel for HW version major 5")
Acked-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: Nitin Rawat <quic_nitirawa@quicinc.com>
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
Link: https://lore.kernel.org/r/20230821-topic-sm8x50-upstream-ufs-major-5-plus-v2-1-f42a4b712e58@linaro.org
Reviewed-by: "Bao D. Nguyen" <quic_nguyenb@quicinc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit c422fbd5cb)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I1c67c49441d710b6e762d73ff87077febdee8f25
2023-11-07 08:29:16 +00:00
Oven
0920d4de75 ANDROID: GKI: Update symbols to symbol list
7 function symbol(s) added
  'int __traceiter_android_vh_free_unref_page_bypass(void*, struct page*, int, int, bool*)'
  'int __traceiter_android_vh_kvmalloc_node_use_vmalloc(void*, size_t, gfp_t*, bool*)'
  'int __traceiter_android_vh_ra_tuning_max_page(void*, struct readahead_control*, unsigned long*)'
  'int __traceiter_android_vh_rmqueue_bulk_bypass(void*, unsigned int, struct per_cpu_pages*, int, struct list_head*)'
  'int __traceiter_android_vh_should_alloc_pages_retry(void*, gfp_t, int, int*, int, struct zone*, struct page**, bool*)'
  'int __traceiter_android_vh_tune_mmap_readaround(void*, unsigned int, unsigned long, unsigned long*, unsigned int*, unsigned int*)'
  'int __traceiter_android_vh_unreserve_highatomic_bypass(void*, bool, struct zone*, bool*)'

7 variable symbol(s) added
  'struct tracepoint __tracepoint_android_vh_free_unref_page_bypass'
  'struct tracepoint __tracepoint_android_vh_kvmalloc_node_use_vmalloc'
  'struct tracepoint __tracepoint_android_vh_ra_tuning_max_page'
  'struct tracepoint __tracepoint_android_vh_rmqueue_bulk_bypass'
  'struct tracepoint __tracepoint_android_vh_should_alloc_pages_retry'
  'struct tracepoint __tracepoint_android_vh_tune_mmap_readaround'
  'struct tracepoint __tracepoint_android_vh_unreserve_highatomic_bypass'

Bug: 288216516
Change-Id: I85abefd786a0c7aadfe730f5c3485117e38d0a86
Signed-off-by: Oven <liyangouwen1@oppo.com>
2023-11-06 23:07:00 +00:00
Oven
019393a917 ANDROID: vendor_hook: Add hook to tune readaround size
In some situations, we want to decrease readaround size for better
performance. So we add this hook.

Bug: 288216516
Change-Id: If2f5f75976c99ff1f82ce29d370f9216926055ab
Signed-off-by: Oven <liyangouwen1@oppo.com>
2023-11-06 23:07:00 +00:00
liang zhang
0c859c2180 ANDROID: add for tuning readahead size
Tune ReadAhead size for better memory usage and performance.
accordding to Read-Ahead Efficiency on Mobile Devices: Observation,
Characterization, and Optimization form IEEE

Bug: 229839032
Change-Id: I91656bde5e616e181fd7557554d55e7ce1858136
Signed-off-by: liang zhang <liang.zhang@transsion.com>
Signed-off-by: Oven <liyangouwen1@oppo.com>
2023-11-06 23:07:00 +00:00
Oven
a8206e3023 ANDROID: vendor_hooks: Add hooks to avoid key threads stalled in
memory allocations

We add these hooks to avoid key threads blocked in memory allocation
path.
-android_vh_free_unref_page_bypass  ----We create a memory pool for the
key threads. This hook determines whether a page should be free to the
pool or to buddy freelist. It works with a existing hook
`android_vh_alloc_pages_reclaim_bypass`, which takes pages out of the
pool.

-android_vh_kvmalloc_node_use_vmalloc  ----For key threads, we perfer
not to run into direct reclaim. So we clear __GFP_DIRECT_RECLAIM flag.
For threads which are not that important, we perfer use vmalloc.

-android_vh_should_alloc_pages_retry  ----Before key threads run into
direct reclaim, we want to retry with a lower watermark.

-android_vh_unreserve_highatomic_bypass  ----We want to keep more
highatomic pages when unreserve them to avoid highatomic allocation
failures.

-android_vh_rmqueue_bulk_bypass  ----We found sometimes when key threads
run into rmqueue_bulk,  it took several milliseconds spinning at
zone->lock or filling per-cpu pages. We use this hook to take pages from
the mempool mentioned above,  rather than grab zone->lock and fill a
batch of pages to per-cpu.

Bug: 288216516
Change-Id: I1656032d6819ca627723341987b6094775bc345f
Signed-off-by: Oven <liyangouwen1@oppo.com>
2023-11-06 23:07:00 +00:00
liwei1234
ad9947dc8d ANDROID: GKI: Update oplus symbol list
1 function symbol(s) added
  'int __traceiter_android_vh_adjust_kvmalloc_flags(void*, unsigned int, gfp_t*)'

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

Bug: 300857012
Change-Id: Ifdcdd36ff47a0e0e3ecaa33b158d5b83ccb912a2
Signed-off-by: liwei <liwei1234@oppo.com>
2023-11-06 20:48:16 +00:00
liwei
71f3b61ee4 ANDROID: vendor_hooks: add hooks for adjust kvmalloc_node alloc_flags
since we can't control all kvmalloc_node callsite's gfp_flags, we add
a vendor hook in kvmalloc_node to tune the reclaim behavior for some
really high-order allocation

Bug: 300857012

Change-Id: I5f0c4c2921d204289911704e3a205f6a1dc50d04
Signed-off-by: liwei <liwei1234@oppo.com>
2023-11-06 20:48:16 +00:00
Kyle Zeng
fef66e8544 UPSTREAM: netfilter: ipset: add the missing IP_SET_HASH_WITH_NET0 macro for ip_set_hash_netportnet.c
commit 050d91c03b upstream.

The missing IP_SET_HASH_WITH_NET0 macro in ip_set_hash_netportnet can
lead to the use of wrong `CIDR_POS(c)` for calculating array offsets,
which can lead to integer underflow. As a result, it leads to slab
out-of-bound access.
This patch adds back the IP_SET_HASH_WITH_NET0 macro to
ip_set_hash_netportnet to address the issue.

Bug: 302199939
Fixes: 886503f34d ("netfilter: ipset: actually allow allowable CIDR 0 in hash:net,port,net")
Suggested-by: Jozsef Kadlecsik <kadlec@netfilter.org>
Signed-off-by: Kyle Zeng <zengyhkyle@gmail.com>
Acked-by: Jozsef Kadlecsik <kadlec@netfilter.org>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit a9e6142e5f)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I11cc1650e7df9d54041164b6bdb01f3a0de46de4
2023-11-06 18:59:19 +00:00
Zhipeng Wang
7bec8a8180 ANDROID: ABI: Update symbol list for imx
1 function symbol(s) added
  'int devm_regulator_get_enable_optional(struct device*, const char*)'

Bug: 307653069
Change-Id: I1e26da9575327170e50deedd95df605ef9d65714
Signed-off-by: Zhipeng Wang <zhipeng.wang_1@nxp.com>
2023-11-03 11:19:23 +00:00
Subash Abhinov Kasiviswanathan
af888bd2a1 ANDROID: abi_gki_aarch64_qcom: Add __netif_rx
Add the symbol __netif_rx which is needed by rmnet modules.

Symbols added:
   __netif_rx

Bug: 308756580
Change-Id: I26dfad610739a18764c9ac6dbd6edb798ba295b6
Signed-off-by: Subash Abhinov Kasiviswanathan <quic_subashab@quicinc.com>
2023-11-03 11:03:06 +00:00