I recently wrote a module implementing these functions.
What is the difference between the two? From my understanding, the copy_..._user
functions are more secure. Please correct me if I'm mistaken.
Furthermore, is it a bad idea to mix the two functions in one program? For example, I used simple_read_from_buffer
in my misc dev read
function, and copy_from_user
in my write function.
Edit: I believe I've found the answer to my question from reading fs/libfs.c
(I wasn't aware that this was where the source code was located for these functions); from my understanding the simple_...()
functions are essentially a wrapper around the copy_...()
functions. I think it was appropriate in my case to use copy_from_user
for the misc device write function as I needed to validate that the input matched a specific string before returning it to the user buffer.
I will still leave this question open though in case someone has a better explanation or wants to correct me!