AUDIT: copy_from_user is a deathtrap.
Quoted 5 lines · Denis Vlasenko
Quoted 2 lines
As Linus and others pointed out, copy_{to_from}_user has its uses and will stay, but something like:
I don't say 'kill it', I say 'rename it so that its name tells users what return value to expect'. However, one have to weigh
Why? OSF/1's copyin/copyout returns exactly same value which our current copy_{to,from}_user does. You should not penalize developers who read documentation.
Quoted 10 lines
I usually vote for
long_but_easy_to_understand_name(), but it's MHO only.Quoted 2 lines
#define copyin(...) (
copy_from_user(...)?-EFAULT: 0) #define copyout(...) (copy_to_user(...)?-EFAULT: 0)This falls in
cryptcnshrt()category.
Will "new programmer" grasp form the name alone that it returns EFAULT? /me in doubt. OTOH BSD folks may be happy.From copyin/out descriptions sent yesterday if you want same source code
running on all (BSD,SVR4,OSF/1) platforms, you must do
if (copyin()) return [-]EFAULT;
anyway, otherwise OSF/1 and SVR4 variants are wrong.
Petr Vandrovec [email protected]
Quoted 8 lines · Denis Vlasenko
Quoted 5 lines
Quoted 2 lines
As Linus and others pointed out, copy_{to_from}_user has its uses and will stay, but something like:
I don't say 'kill it', I say 'rename it so that its name tells users what return value to expect'. However, one have to weigh
Why?
Why what? Why rename copy_to_user? Because in its current form people misunderstand its return value and misuse it.
We can keep unmodified version of copy_to_user for some time for compatibility.
Or maybe your "why?" is related to something else, I fail to understand you in that case.
Quoted 4 lines
From copyin/out descriptions sent yesterday if you want same source code running on all (BSD,SVR4,OSF/1) platforms, you must do
if (
copyin()) return [-]EFAULT;
But if I am new to Linux and just want to write my first piece of kernel code, copyout() is even worse than copy_to_user():
it too lacks info of what it can return (0/1, 0/-EFAULT, # of copied bytes,
# of bytes remaining?) *and* copy direction become unclear: copy out of *what*? out of kernel memery? out of user memory? -- vda