Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patches for kernel 5.19 #4

Merged
merged 2 commits into from
Sep 11, 2022
Merged

Patches for kernel 5.19 #4

merged 2 commits into from
Sep 11, 2022

Conversation

Thesola10
Copy link

@Thesola10 Thesola10 commented Aug 8, 2022

This update reflects the signature change in close_fd_get_file_ptr from int close_fd_get_file_ptr(unsigned int fd, struct file **res) to struct file *close_fd_get_file_ptr(unsigned int fd).

@Thesola10 Thesola10 changed the title Patches for kernel 5.19 WIP: Patches for kernel 5.19 Aug 9, 2022
@Thesola10 Thesola10 changed the title WIP: Patches for kernel 5.19 Patches for kernel 5.19 Aug 9, 2022
@Thesola10

This comment was marked as resolved.

@Thesola10 Thesola10 marked this pull request as draft August 9, 2022 16:10
@Etaash-mathamsetty
Copy link

check here if you want to make it a bit easier on yourself: https://github.com/torvalds/linux/blob/master/drivers/android/binder.c

@Thesola10
Copy link
Author

that's what I meant by "cross-referencing with the in-tree version". My changes should reflect those in the mainline kernel, save for the versioning macros...

@Thesola10
Copy link
Author

Okay, I think it may have been the return parameter on the dynamic func pointer that was still using an int return type, truncating the pointer on 64-bit and leading to segfault, mb

@Thesola10
Copy link
Author

Thesola10 commented Aug 12, 2022

nvm it works!!!

@Thesola10 Thesola10 marked this pull request as ready for review August 12, 2022 12:21
@jingxu9x
Copy link

jingxu9x commented Aug 22, 2022

I have test a patch, which works well. patch file as follow

--- /usr/src/anbox-binder-r38.8148a16/deps.c	2022-07-04 00:18:45.000000000 +0800
+++ deps.c	2022-08-21 01:19:24.013614356 +0800
@@ -69,7 +69,16 @@ static unsigned long kallsyms_lookup_nam
 #endif
 }
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,19,0))
+static struct file *(*close_fd_get_file_ptr)(unsigned int fd) = NULL;
 
+struct file * close_fd_get_file(unsigned int fd)
+{
+	if (!close_fd_get_file_ptr)
+		close_fd_get_file_ptr = kallsyms_lookup_name_wrapper("close_fd_get_file");
+	return close_fd_get_file_ptr(fd);
+}
+#else
 static int (*close_fd_get_file_ptr)(unsigned int fd, struct file **res) = NULL;
 
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,11,0))
@@ -86,6 +95,7 @@ int __close_fd_get_file(unsigned int fd,
 #endif
 	return close_fd_get_file_ptr(fd, res);
 }
+#endif
 
 static int (*can_nice_ptr)(const struct task_struct *, const int) = NULL;
 
--- /usr/src/anbox-binder-r38.8148a16/binder.c	2022-07-04 00:18:45.000000000 +0800
+++ binder.c	2022-08-22 01:15:31.871108563 +0800
@@ -2236,12 +2236,17 @@ static void binder_deferred_fd_close(int
 	if (!twcb)
 		return;
 	init_task_work(&twcb->twork, binder_do_fd_close);
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,11,0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,19,0))
+	twcb->file = close_fd_get_file(fd);
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(5,11,0))
 	close_fd_get_file(fd, &twcb->file);
 #else
 	__close_fd_get_file(fd, &twcb->file);
 #endif
 	if (twcb->file) {
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,19,0))
+		get_file(twcb->file);
+#endif
 		filp_close(twcb->file, current->files);
 		task_work_add(current, &twcb->twork, TWA_RESUME);
 	} else {

hope it will help you! ^-^

@Thesola10
Copy link
Author

Thanks but I already got it working!

@gholmann16
Copy link

Currently not working on 5.19 so I hope this fixes it! I'm just waiting for it to be approved.

@Etaash-mathamsetty
Copy link

maybe his notification settings are still bad, so let me try pinging him
@choff

@choff
Copy link
Owner

choff commented Aug 25, 2022

Hello all,

actually, I was able to fix my notification settings :-) ..

Thanks a lot for all your contributions that make everything work with newer kernels. I will review also this patch, but as I am about to travel, I need to ask for another 1-2 weeks of patience. Then, I will be able to review it.

Best regards,

Christian

@ricklambrechts
Copy link

Thanks! This works!

@choff choff merged commit 2325d6f into choff:master Sep 11, 2022
@choff
Copy link
Owner

choff commented Sep 11, 2022

Thank you very much, @Thesola10 for your contribution for kernel 5.19 support! I have merged your PR now. I want to apologize for the long review period - unfortunately, I have been very busy during the last weeks :-(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants