From: Andreas Krebs <krebs@qkal.sap-ag.de>
To: axp-list@redhat.com
Subject: BUG kernel macro: copy_to_user
Date: Thu, 08 Apr 1999 09:52:30 +0200 [thread overview]
Message-ID: <199904080752.JAA0000007399@storm.qkal.sap-ag.de> (raw)
[-- 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
_____________________________________________________________________________
next reply other threads:[~1999-04-08 8:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-04-08 7:52 Andreas Krebs [this message]
1999-04-08 16:44 ` BUG kernel macro: copy_to_user 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
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox