Copy_to_user undefined on Linux kernel version 4.12.8

In my project, I use the char driver to communicate between user space and kernel space. I use a function copy_to_user(void user *to, const void *from, unsigned long n)to copy data from kernel space to a user space buffer. We can find this function in the header file #include < asm/uaccess.h >. I completed a project using Linux Kernel version 4.4.0-59-generic, Ubuntu OS version 16.04 LTS and its performance without any errors or warnings. I get the desired result.

I compiled the same project using the Linux kernel version 4.12.8, Ubuntu OS version 16.04.2 LTS, and it gives me a warning at compile time WARNING: "copy_to_user" [/home/ldrv1/Desktop/Vijay/code/build/uts.ko] undefined!. When I do an insmod of my module, I get an error as follows insmod: ERROR: could not insert module uts.ko: Unknown symbol in module. I think the header file #include <asm/uaccess.h>is still supported in kernel version 4.12.8 else. I would have had a fatal error: at compile time, such a file or a catalog error. I tried updating the Linux kernel headers using the command apt-get install linux-headers-$(uname -r)and got the following response:

Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package linux-headers-4.12.8
E: Couldn't find any package by glob 'linux-headers-4.12.8'
E: Couldn't find any package by regex 'linux-headers-4.12.8'

This OS version 16.04.2 LTS has linux-headers-4.10.0-35. How to get rid of this warning? Suggestions and support appreciated. If further information is required, feel free to ask.

+4
3
  • #include <linux/uaccess.h> 4.12.8. .

    4.4 #include <asm/uaccess.h>, #include <linux/uaccess.h>.

    #include <linux/uaccess.h> , .

  • apt-get update, apt-get install linux-headers-generic.

+4

copy_to_user copy_from_user asm/uaccess.h. , , . . github: . , , , :). 3. , 1 2

0

, , . #include < asm/uaccess.h > #include < linux/uaccess.h > . #include < asm/uaccess.h > _copy_to_user (void user * to, const void * from, unsigned long n) copy_to_user (void user * to, const void * from, unsigned long n). _ .

0
source

Source: https://habr.com/ru/post/1685960/


All Articles