lp int copy_to_user replaced
Andrew,
Here's a patch to have standard __put_user for integer transfers in lp
driver.Is it correct ?
Regards,
FabF
drivers/char/lp.c +5 -5
@@ -31,6 +31,8 @@* Obsoleted and removed all the lowlevel stuff implemented in the last * month to use the IEEE1284 functions (that handle the _new_ compatibilty * mode fine). +* +* 27-MAY-2004 Replace int copy_to_user with put_user (Fabian Frederick) */ /* This driver should, in theory, work with any parallel port that has an
@@ -603,16 +605,14 @@return -EINVAL ;break ;case LPGETIRQ : -if (copy_to_user ((int *) arg, &LP_IRQ (minor), -sizeof (int ))) +if (__put_user (LP_IRQ (minor), (int *) arg))return -EFAULT ;break ;case LPGETSTATUS :lp_claim_parport_or_block (&lp_table[minor]); status =r_str (minor);lp_release_parport (&lp_table[minor]); - -if (copy_to_user ((int *) arg, &status,sizeof (int ))) +if (__put_user (status, (int *) arg))return -EFAULT ;break ;case LPRESET :
@@ -630,7 +630,7 @@#endif case LPGETFLAGS : status =LP_F (minor); -if (copy_to_user ((int *) arg, &status,sizeof (int ))) +if (__put_user (status, (int *) arg))return -EFAULT ;break ;
Quoted 4 lines · FabF
Andrew,
Here's a patch to have standard
__put_userfor integer transfers in lp
driver.Is it correct ?
no it's not. You need to use put_user() not __put_user() at least, to make sure the destination address is checked to not be in kernel space...
Here it is.
FabF
Quoted 10 lines · Arjan van de Ven
Quoted 4 lines · FabF
Andrew,
Here's a patch to have standard
__put_userfor integer transfers in lp
driver.Is it correct ?no it's not. You need to use
put_user()not__put_user()at least, to make sure the destination address is checked to not be in kernel space...
drivers/char/lp.c +5 -5
@@ -31,6 +31,8 @@* Obsoleted and removed all the lowlevel stuff implemented in the last * month to use the IEEE1284 functions (that handle the _new_ compatibilty * mode fine). +* +* 27-MAY-2004 Replace int copy_to_user with put_user (Fabian Frederick) */ /* This driver should, in theory, work with any parallel port that has an
@@ -603,16 +605,14 @@return -EINVAL ;break ;case LPGETIRQ : -if (copy_to_user ((int *) arg, &LP_IRQ (minor), -sizeof (int ))) +if (put_user (LP_IRQ (minor), (int *) arg))return -EFAULT ;break ;case LPGETSTATUS :lp_claim_parport_or_block (&lp_table[minor]); status =r_str (minor);lp_release_parport (&lp_table[minor]); - -if (copy_to_user ((int *) arg, &status,sizeof (int ))) +if (put_user (status, (int *) arg))return -EFAULT ;break ;case LPRESET :
@@ -630,7 +630,7 @@#endif case LPGETFLAGS : status =LP_F (minor); -if (copy_to_user ((int *) arg, &status,sizeof (int ))) +if (put_user (status, (int *) arg))return -EFAULT ;break ;
Quoted 4 lines · * FabF ([email protected]) wrote:
Andrew,
Here's a patch to have standard
__put_userfor integer transfers in lp
driver.Is it correct ?
No, you've removed the security check but using __put_user. put_user maintains the access_ok() check.
thanks,
-chris
Signature · 1 line
Linux Security Modules http://lsm.immunix.org http://lsm.bkbits.net
Quoted 4 lines · FabF
Andrew,
Here's a patch to have standard
__put_userfor integer transfers in lp
driver.Is it correct ?
What the hell for? copy_to_user()/copy_from_user() is perfectly OK here.
Quoted 8 lines · On Thu, 2004-05-27 at 20:01, [email protected] wrote:
Quoted 4 lines · FabF
Andrew,
Here's a patch to have standard
__put_userfor integer transfers in lp
driver.Is it correct ?What the hell for? copy_to_user()/copy_from_user() is perfectly OK here.
And why the hell use generic functions when we have neat small type exchange macros ?
FabF
Quoted 5 lines · FabF
Quoted 3 lines · On Thu, 2004-05-27 at 20:01, [email protected] wrote:
Quoted 2 lines · FabF
Andrew,
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Here's a patch to have standard
__put_userfor integer transfers in lp
driver.Is it correct ?What the hell for? copy_to_user()/copy_from_user() is perfectly OK here.
And why the hell use generic functions when we have neat small type exchange macros ?
We have different definitions of "neat", apparently.
Quoted 6 lines · FabF
Quoted 3 lines · On Thu, 2004-05-27 at 20:01, [email protected] wrote:
Quoted 2 lines · FabF
Andrew,
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Here's a patch to have standard
__put_userfor integer transfers in lp
driver.Is it correct ?What the hell for? copy_to_user()/copy_from_user() is perfectly OK here.
And why the hell use generic functions when we have neat small type exchange macros ?
copy_*_user() has special-case code to handle 1, 2 and 4-byte copies, so your patch should make no difference on x86. Other architectures do not have that optimisation.
So the patch is a tiny optimisation for some architectures. However, it's of very small benefit - we could make a million such changes. Would prefer more substantial things at this time, please.
Quoted 7 lines · On Thu, 27 May 2004 [email protected] wrote:
Quoted 4 lines · FabF
Andrew,
Here's a patch to have standard
__put_userfor integer transfers in lp
driver.Is it correct ?What the hell for? copy_to_user()/copy_from_user() is perfectly OK here.
Andrew love __put_user() against __copy_to_user() :-) We had a similar discussion last week.
- Davide