From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 10824 invoked from network); 8 Apr 1999 08:13:08 -0000 Received: from mail.redhat.com (199.183.24.239) by lists.redhat.com with SMTP; 8 Apr 1999 08:13:08 -0000 Received: from smtpde01.sap-ag.de (smtpde01.sap-ag.de [194.39.131.165]) by mail.redhat.com (8.8.7/8.8.7) with ESMTP id DAA28330 for ; Thu, 8 Apr 1999 03:53:07 -0400 Received: from sap-ag.de ([194.39.131.3]) by smtpde01.sap-ag.de (out) with ESMTP id JAA03692 for ; Thu, 8 Apr 1999 09:51:54 +0200 (MESZ) Received: from sharon.qkal.sap-ag.de (sharon.qkal.sap-ag.de [10.55.144.3]) by sap-ag.de (8.8.8/8.8.8) with SMTP id JAA13563 for ; Thu, 8 Apr 1999 09:50:07 +0200 (MET DST) Received: from storm.qkal.sap-ag.de by sharon.qkal.sap-ag.de (5.65v4.0/1.1.19.2/20Jan99-0715PM) id AA26529; Thu, 8 Apr 1999 09:52:31 +0200 From: Andreas Krebs Received: from localhost by storm.qkal.sap-ag.de (8.8.8/1.1.19.2/15Jan99-1021AM) id JAA0000007399; Thu, 8 Apr 1999 09:52:30 +0200 (MET DST) Message-Id: <199904080752.JAA0000007399@storm.qkal.sap-ag.de> X-Mailer: exmh version 2.0.2 2/24/98 To: axp-list@redhat.com Subject: BUG kernel macro: copy_to_user Mime-Version: 1.0 Content-Type: multipart/mixed ; boundary="==_Exmh_48651809430" Date: Thu, 08 Apr 1999 09:52:30 +0200 X-Mts: smtp This is a multipart MIME message. --==_Exmh_48651809430 Content-Type: text/plain; charset=us-ascii 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. --==_Exmh_48651809430 Content-Type: application/x-gzip ; name="alpha-uaccess.patch.gz" Content-Description: alpha-uaccess.patch.gz Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="alpha-uaccess.patch.gz" H4sICEpbDDcCA2FscGhhLXVhY2Nlc3MucGF0Y2gAnZJbb5tAEIWf4VeM3FRawoKN7djGqStX ah/6mqTqS6UVhcFsAyzaC2mUP99dbMe5qFXbeUHsznfOGYaClyVEBqJIYm6k4j1CzVvzM5rG 0/giyvJ53GU6r7AY8zavTYHjTDVRVndVNjZZnqNScfWS+VOvH0XR/3h4N5WBD50EWMEkXU+X 64sEkjRN/TAM/yWA9xWLvdASksl6tlgn6V5ou4VoThcQzukStlsf3hxk4N2gP0YpWxFX71/f KBd/uPFDH8bnPsA53FQIpYI+qw1CgRplw1tUcFehrlBCJnemwVa7Dl5wfQ9WJb/l7Q5UJUxd wHcchDqUpZCNzS0ktELHAJ9L2KFmpSIBbDbw5frTFft4TU8KXJ0wCndcV8N8s1VCkwmEs9WU psOQdpgCSxsMGMtFd8+0KKVomFEoiRbUvdCW9oHnCmx984E8eMfan0SexB1XdkaohbVnTDcd q7GFDZA2uHwKn1p7wQs7nzU21tY+7b4YI6OzxShwoBYD+YrLRav0M9qlfMIv97w7dQq/y2hB F/HETQbuMfylBwc2/Fv2MOwxMi+B2Jbh32PilhDi8ID0QUCPGvS4ySCAhxPqHaStRS/qTPMa rc+zD+l5ox9Kwtl0Rcnb2aDoNuhWN3ps+wWnc50v5QMAAA== --==_Exmh_48651809430 Content-Type: text/plain; charset=us-ascii _____________________________________________________________________________ Andreas S. Krebs CEC Karlsruhe, SAP AG, krebs@qkal.sap-ag.de _____________________________________________________________________________ --==_Exmh_48651809430--