zoukankan      html  css  js  c++  java
  • 用户空间到内核空间为什么需要拷贝?

    The simple answer to that is, "Kernel Developers do not put blind faith in anything". When any data is passed to the kernel space from userspace, it is the responsibility of the kernel developer to make sure that everything is sanitized. Just as you check for corner conditions in the functions, it is something similar for the kernel developers. Its a hygienic practice to use copy_from_user() to read the userspace data.

    We all know that there are all kinds of people in the world, and the same generalization applies to us coders. The kernel developers have to be everything to everyone. So, even if you are a clumsy coder who actually passed a pointer pointing to address in the kernel space by mistake, or if you are a malicious hacker who just wants to fool around and passed malformed data, the kernel should still handle that and not crash. The functions copy_from_user() does all these checks and more before it copies the data from the userspace to kernel space.

    Just to make sure that the kernel dev does not have to manually check all these conditions, does not accidentally miss out on any and to abstract it for future use and extendability, the kernel architects have made a simple function that everyone can use. It just adds uniformity to the code and makes things that bit robust, simpler and cleaner.

    转载链接:传送门 

    保持更新,更多内容请关注cnblogs.com/xuyaowen;

     
  • 相关阅读:
    DICOM 协议学习笔记之 What is DICOM
    决策树(ID3,C4.5,CART)
    支持向量机(support vector machines, SVM)
    回归分析-线性回归与逻辑回归
    第8章 线程
    第7章 常用实用类
    第5章 语法制导翻译及中间代码生成
    第4章 语法分析
    第3章 词法分析
    第2章 形式语言基础知识
  • 原文地址:https://www.cnblogs.com/xuyaowen/p/copy_from_user.html
Copyright © 2011-2022 走看看