Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* BUG kernel macro: copy_to_user
@ 1999-04-08  7:52 Andreas Krebs
  1999-04-08 16:44 ` Richard Henderson
  1999-04-14  7:25 ` BUG kernel macro: copy_to_user Richard Henderson
  0 siblings, 2 replies; 5+ messages in thread
From: Andreas Krebs @ 1999-04-08  7:52 UTC (permalink / raw)
  To: axp-list

[-- Attachment #1: Type: text/plain, Size: 2175 bytes --]


i think i found a serious bug in the __copy_tofrom_user macro define
in include/asm-alpha/uaccess.h

i was trying to install isdn under alpha linux and noticed that some
ioctls from isdnctrl failed without any reason, so i looked into the
isdn_common.c code and notice that calls to copy_to_user failed.

all the calls that failed had in common that the size was NOT constant,
in this case the call was as follows:
          if (copy_to_user((char *) arg, s, strlen(s) + 1)){
                 ret = -EFAULT;
          } else {
                 ret = 0;                                                                                   }
          }

i checked all addresses, ranges and the statement failed all the time
until i changed strlen(s)+1 into a constant.

so i take a look at the copy_to_user macro and notice, that some
registers are used direct. i think the strlen() command somehow messes
up this registers and causes the following __access_ok to fail.
so i changed the macro a bit, by moving the length calc to the top
(the complete patch is attached below):

 #define __copy_tofrom_user(to,from,n,v)                                            \
 ({                                                                         \
-       register long __tmp_len = (n);                                      \
        register void * __cu_to __asm__("$6") = (to);                       \
        register const void * __cu_from __asm__("$7") = (from);             \
-       register long __cu_len __asm__("$0") = __tmp_len;                   \
+       register long __cu_len __asm__("$0") = (n);                         \
        if (__access_ok(((long)(v)),__cu_len,get_fs())) {                   \
 

this solved the problem and the isdnctrl ioctls now seem to work.

maybe someone how knows more about inline assembler should have a look.
i think this can cause a lot of trouble not only with isdn but with other 
drivers also. 

bye,
Andreas


PS:
my machine is a 164SX, the isdn card is a Eicon DIVA PCI. i experienced
the problem with ALL 2.2.* kernels and both egcs 1.0.2 and 1.1.2. 
the patch is against as 2.2.5-ac4 but should also work with other kernels.



[-- Attachment #2: alpha-uaccess.patch.gz --]
[-- Type: application/x-gzip , Size: 520 bytes --]

[-- Attachment #3: Type: text/plain, Size: 266 bytes --]

_____________________________________________________________________________

                               Andreas S. Krebs

                CEC Karlsruhe, SAP AG, krebs@qkal.sap-ag.de
_____________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1999-04-14  7:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-04-08  7:52 BUG kernel macro: copy_to_user Andreas Krebs
1999-04-08 16:44 ` Richard Henderson
1999-04-09 17:24   ` Matthew Jacob
1999-04-09 17:26     ` I *apologize* Matthew Jacob
1999-04-14  7:25 ` BUG kernel macro: copy_to_user Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox