copy_from_user中的len最大范围是多少

发布于 2022-09-26 12:55:13 字数 4216 浏览 29 评论 0

我写了个驱动,从用户空间拷贝数据到内核空间,buf[65536]   
copy_from_user(buf, data,65536)
这样可以吗?请问这是什么原因啊? 难道对数据最大长度有限制,还是我的程序出了问题?

谢谢!

板子抱错:Unable to handle kernel NULL pointer dereference at virtual address 00000070
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
Unable to handle kernel NULL pointer dereference at virtual address 0000001d
pgd = c0e481e8
[0000001d] *pgd=c0149008<1>Unable to handle kernel paging request at virtual address 80149800
Unable to handle kernel paging request at virtual address 8014981c
Unable to handle kernel NULL pointer dereference at virtual address 00000091
pgd = c0004000
[00000091] *pgd=00000000
Internal error: Oops: 3 [#1]
Modules linked in: ksflash

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

流云如水 2022-10-03 12:55:13

usigned long长度应该没有问题吧,确定问题是出在这个函数上?

请别遗忘我 2022-10-03 12:55:13

函数很简单,就是用了copy_from_user(buf, data,65536)
我把copy_from_user(buf, data,6144)就可以
就是数据长度小于7000的都不会抱错。
来测试数据的数据长度的,还会有什么会影响呢?

新雨望断虹 2022-10-03 12:55:13

buf[65536] ?行不行啊,用户栈空间也有大小限制的吧

梦中的蝴蝶 2022-10-03 12:55:13

buf[]要是在内核本上分配的会有问题。
copy_from_user()还没用过几次,ldd上说它会检测参数,并且可能会睡眠。
别的我就不知道了,还没看过别的书。

多孤肩上扛 2022-10-03 12:55:13

改用kmalloc分配buf试试~~

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文