Compile fixes for kernels 5.11, 5.12 & 5.13

This commit is contained in:
Christian Hoff 2021-10-29 17:50:10 +02:00
parent 0338a34979
commit 516144c6a0
3 changed files with 32 additions and 4 deletions

View File

@ -66,6 +66,7 @@
#include <linux/syscalls.h>
#include <linux/task_work.h>
#include <linux/sizes.h>
#include <linux/version.h>
#include <uapi/linux/android/binder.h>
#include <uapi/linux/android/binderfs.h>
@ -2225,7 +2226,11 @@ static void binder_deferred_fd_close(int fd)
if (!twcb)
return;
init_task_work(&twcb->twork, binder_do_fd_close);
#if (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) {
filp_close(twcb->file, current->files);
task_work_add(current, &twcb->twork, TWA_RESUME);
@ -3089,7 +3094,11 @@ static void binder_transaction(struct binder_proc *proc,
u32 secid;
size_t added_size;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 13, 0)
security_task_getsecid_obj(proc->tsk, &secid);
#else
security_task_getsecid(proc->tsk, &secid);
#endif
ret = security_secid_to_secctx(secid, &secctx, &secctx_sz);
if (ret) {
return_error = BR_FAILED_REPLY;

View File

@ -29,6 +29,7 @@
#include <linux/types.h>
#include <linux/uaccess.h>
#include <linux/user_namespace.h>
#include <linux/version.h>
#include <linux/xarray.h>
#include <uapi/asm-generic/errno-base.h>
#include <uapi/linux/android/binder.h>
@ -356,15 +357,25 @@ static inline bool is_binderfs_control_device(const struct dentry *dentry)
return info->control_dentry == dentry;
}
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,12,0))
static int binderfs_rename(struct user_namespace *namespace, struct inode *old_dir,
struct dentry *old_dentry, struct inode *new_dir,
struct dentry *new_dentry, unsigned int flags)
#else
static int binderfs_rename(struct inode *old_dir, struct dentry *old_dentry,
struct inode *new_dir, struct dentry *new_dentry,
unsigned int flags)
#endif
{
if (is_binderfs_control_device(old_dentry) ||
is_binderfs_control_device(new_dentry))
return -EPERM;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,12,0))
return simple_rename(namespace, old_dir, old_dentry, new_dir, new_dentry, flags);
#else
return simple_rename(old_dir, old_dentry, new_dir, new_dentry, flags);
#endif
}
static int binderfs_unlink(struct inode *dir, struct dentry *dentry)

View File

@ -69,13 +69,21 @@ static unsigned long kallsyms_lookup_name_wrapper(const char *name)
}
static int (*__close_fd_get_file_ptr)(unsigned int fd, struct file **res) = NULL;
static int (*close_fd_get_file_ptr)(unsigned int fd, struct file **res) = NULL;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,11,0))
int close_fd_get_file(unsigned int fd, struct file **res)
#else
int __close_fd_get_file(unsigned int fd, struct file **res)
#endif
{
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, res);
if (!close_fd_get_file_ptr)
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,11,0))
close_fd_get_file_ptr = kallsyms_lookup_name_wrapper("close_fd_get_file");
#else
close_fd_get_file_ptr = kallsyms_lookup_name_wrapper("__close_fd_get_file");
#endif
return close_fd_get_file_ptr(fd, res);
}
static int (*can_nice_ptr)(const struct task_struct *, const int) = NULL;