From: Rusty Russell <rusty@rustcorp.com.au>
To: "David S. Miller" <davem@redhat.com>
Cc: torvalds@transmeta.com, linux-kernel@vger.kernel.org
Subject: Re: AUDIT: copy_from_user is a deathtrap.
Date: Fri, 17 May 2002 22:26:22 +1000 [thread overview]
Message-ID: <E178gok-0001Ln-00@wagner.rustcorp.com.au> (raw)
In-Reply-To: Your message of "Fri, 17 May 2002 02:35:06 MST." <20020517.023506.105129697.davem@redhat.com>
In message <20020517.023506.105129697.davem@redhat.com> you write:
> From: Rusty Russell <rusty@rustcorp.com.au>
> Date: Fri, 17 May 2002 19:49:40 +1000
>
> Sorry I wasn't clear: I'm saying *replace*, not add,
>
> I don't understand what you are proposing then. There are some
> instances that do want to know how many bytes did make it before
> the -EFAULT event.
Yes. There are 52 places which care. Most of these are unneccessary
attempts to return eg. number of bytes written in read call before we
hit the fault, instead of -EFAULT.
The one case I found which obviously needed it was the mount options
code, and I proposed a simple (slow) gradually_copy_from_user for this
case:
static inline unsigned long
gradual_copy_from_user(void *to, const void *from, unsigned long n)
{
unsigned long i;
for (i = 0; i < n; i++, to++, from++) {
if (copy_from_user(from, to, 1) != 0)
break;
}
return n - i;
}
Here is the list of places in 2.5.15 which actually use the return
values other than zero:
./fs/proc/generic.c:108: n -= copy_to_user(buf, start < page ? page : start, n);
./fs/hfs/file.c:263: i = copy_from_user(data, buf, count);
./fs/hfs/file.c:390: chars -= copy_to_user(buf, p, chars);
./fs/hfs/file.c:472: copy_from_user(p, buf, c);
./fs/hfs/file_cap.c:162: memcount -= copy_to_user(buf, ((char *)&meta) + pos, memcount);
./fs/hfs/file_cap.c:234: mem_count -= copy_from_user(((char *)&meta) + pos, buf, mem_count);
./fs/hfs/file_hdr.c:422: left -= copy_to_user(buf, ((char *)&meta) + pos, left);
./fs/hfs/file_hdr.c:592: left -= copy_to_user(buf, p + offset, left);
./fs/hfs/file_hdr.c:671: left -= copy_from_user(((char *)&meta) + pos, buf, left);
./fs/hfs/file_hdr.c:703: left -= copy_from_user(((char *)&meta) + pos, buf, left);
./fs/hfs/file_hdr.c:868: left -= copy_from_user(p + offset, buf, left);
./fs/namespace.c:670: i = size - copy_from_user((void *)page, data, size);
./mm/filemap.c:1189: left = __copy_to_user(desc->buf, kaddr + offset, size);
./drivers/char/pty.c:158: n -= copy_from_user(temp_buffer, buf, n);
./drivers/char/esp.c:1332: c -= copy_from_user(tmp_buf, buf, c);
./drivers/char/serial.c:1876: c -= copy_from_user(tmp_buf, buf, c);
./drivers/char/n_tty.c:922: retval = copy_to_user(*b, &tty->read_buf[tty->read_tail], n);
./drivers/char/vc_screen.c:251: ret = copy_to_user(buf, con_buf_start, orig_count);
./drivers/char/vc_screen.c:325: ret = copy_from_user(con_buf, buf, this_round);
./drivers/char/rocket.c:1606: c -= copy_from_user(tmp_buf, buf, c);
./drivers/char/rocket.c:1643: c -= copy_from_user(tmp_buf, buf, c);
./drivers/char/random.c:1362: i -= copy_to_user(buf, (__u8 const *)tmp, i);
./drivers/char/random.c:1589: bytes -= copy_from_user(&buf, p, bytes);
./drivers/char/riscom8.c:1247: c -= copy_from_user(tmp_buf, buf, c);
./drivers/char/specialix.c:1626: c -= copy_from_user(tmp_buf, buf, c);
./drivers/char/serial_amba.c:888: c -= copy_from_user(tmp_buf, buf, c);
./drivers/char/dz.c:706: c -= copy_from_user (tmp_buf, buf, c);
./drivers/char/mxser.c:931: c -= copy_from_user(mxvar_tmp_buf, buf, c);
./drivers/char/generic_serial.c:237: c -= copy_from_user(tmp_buf, buf, c);
./drivers/char/serial167.c:1257: c -= copy_from_user(tmp_buf, buf, c);
./drivers/char/amiserial.c:958: c -= copy_from_user(tmp_buf, buf, c);
./drivers/sbus/char/zs.c:1112: c -= copy_from_user(tmp_buf, buf, c);
./drivers/sbus/char/sab82532.c:1127: c -= copy_from_user(tmp_buf, buf, c);
./drivers/sbus/char/su.c:1234: c -= copy_from_user(tmp_buf, buf, c);
./drivers/sbus/char/aurora.c:1627: c -= copy_from_user(tmp_buf, buf, c);
./drivers/video/fbmem.c:386: count -= copy_to_user(buf, base_addr+p, count);
./drivers/video/fbmem.c:422: count -= copy_from_user(base_addr+p, buf, count);
./drivers/macintosh/macserial.c:1551: c -= copy_from_user(tmp_buf, buf, c);
./drivers/s390/char/con3215.c:596: c -= copy_from_user(raw->buffer + raw->head,
./drivers/s390/char/tuball.c:329: len2 -= copy_from_user(ob->bc_buf + ob->bc_wr,
./arch/i386/kernel/vm86.c:79: tmp = copy_to_user(¤t->thread.vm86_info->regs,regs, VM86_REGS_SIZE1);
./arch/i386/kernel/vm86.c:80: tmp += copy_to_user(¤t->thread.vm86_info->regs.VM86_REGS_PART2,
./arch/i386/kernel/vm86.c:147: tmp = copy_from_user(&info, v86, VM86_REGS_SIZE1);
./arch/i386/kernel/vm86.c:148: tmp += copy_from_user(&info.regs.VM86_REGS_PART2, &v86->regs.VM86_REGS_PART2,
./arch/i386/kernel/vm86.c:148: tmp += copy_from_user(&info.regs.VM86_REGS_PART2, &v86->regs.VM86_REGS_PART2,
./arch/i386/kernel/vm86.c:195: tmp = copy_from_user(&info, v86, VM86_REGS_SIZE1);
./arch/i386/kernel/vm86.c:196: tmp += copy_from_user(&info.regs.VM86_REGS_PART2, &v86->regs.VM86_REGS_PART2,
./arch/mips/baget/vacserial.c:1085: c -= copy_from_user(tmp_buf, buf, c);
./arch/mips/au1000/common/serial.c:1212: c -= copy_from_user(tmp_buf, buf, c);
./arch/ppc/4xx_io/serial_sicc.c:988: c -= copy_from_user(tmp_buf, buf, c);
./arch/ia64/hp/sim/simserial.c:328: c -= copy_from_user(tmp_buf, buf, c);
./arch/cris/drivers/serial.c:2355: c -= copy_from_user(tmp_buf, buf, c);
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
next prev parent reply other threads:[~2002-05-17 12:23 UTC|newest]
Thread overview: 83+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-05-17 9:27 Rusty Russell
2002-05-17 9:21 ` David S. Miller
2002-05-17 9:49 ` Rusty Russell
2002-05-17 9:35 ` David S. Miller
2002-05-17 12:26 ` Rusty Russell [this message]
2002-05-17 17:42 ` Denis Vlasenko
2002-05-17 12:17 ` Alan Cox
2002-05-17 12:21 ` Rusty Russell
2002-05-17 12:58 ` Alan Cox
2002-05-17 12:58 ` Rusty Russell
2002-05-17 13:13 ` John Levon
2002-05-17 14:52 ` Alan Cox
2002-05-18 1:26 ` Rusty Russell
2002-05-17 17:58 ` Denis Vlasenko
2002-05-18 2:37 ` Linus Torvalds
2002-05-18 15:06 ` John Alvord
2002-05-17 10:20 ` Christoph Hellwig
[not found] <mailman.1021642692.12772.linux-kernel2news@redhat.com>
2002-05-17 17:36 ` Pete Zaitcev
2002-05-18 1:05 ` Rusty Russell
2002-05-18 2:57 ` Alan Cox
2002-05-16 23:27 ` Pavel Machek
[not found] ` <200205191212.g4JCCLY25867@Port.imtp.ilyichevsk.odessa.ua>
[not found] ` <20020520112232.A8983@devserv.devel.redhat.com>
2002-05-21 10:57 ` Denis Vlasenko
2002-05-21 6:21 ` Arnaldo Carvalho de Melo
2002-05-21 8:33 ` Christoph Hellwig
2002-05-21 19:02 ` Albert D. Cahalan
2002-05-22 14:27 ` Denis Vlasenko
[not found] <E178eMm-0000NO-00@wagner.rustcorp.com.au.suse.lists.linux.kernel>
[not found] ` <Pine.LNX.4.44.0205171936220.1524-100000@home.transmeta.com.suse.lists.linux.kernel>
2002-05-18 10:16 ` Andi Kleen
2002-05-18 16:14 ` Linus Torvalds
2002-05-19 2:10 ` Rusty Russell
2002-05-19 3:01 ` Linus Torvalds
2002-05-19 3:05 ` Larry McVoy
2002-05-19 4:01 ` Rusty Russell
2002-05-19 4:02 ` Larry McVoy
2002-05-16 23:56 ` Pavel Machek
2002-05-16 23:56 ` Pavel Machek
2002-05-19 3:31 ` Rusty Russell
2002-05-19 3:34 ` Linus Torvalds
2002-05-16 23:53 ` Pavel Machek
2002-05-21 20:47 ` Linus Torvalds
2002-05-21 21:17 ` Pavel Machek
2002-05-21 21:25 ` Linus Torvalds
2002-05-21 21:44 ` Alan Cox
2002-05-21 21:46 ` Andrew Morton
2002-05-21 22:04 ` Linus Torvalds
2002-05-21 22:21 ` Pavel Machek
2002-05-22 13:47 ` Alan Cox
2002-05-22 14:13 ` Pavel Machek
2002-05-22 14:54 ` Alan Cox
2002-05-22 14:42 ` Pavel Machek
2002-05-22 15:27 ` Alan Cox
2002-05-22 18:58 ` Kasper Dupont
2002-05-22 22:02 ` Alan Cox
2002-05-23 3:54 ` Rusty Russell
2002-05-23 11:15 ` Edgar Toernig
2002-05-22 16:09 ` Linus Torvalds
2002-05-22 20:28 ` Pavel Machek
2002-05-22 0:47 ` Andrea Arcangeli
2002-05-22 5:01 ` Rusty Russell
2002-05-22 6:28 ` Rusty Russell
2002-05-22 4:57 ` Rusty Russell
2002-05-22 13:30 ` Alan Cox
2002-05-22 18:43 ` Marco Colombo
2002-05-19 20:23 ` Edgar Toernig
2002-05-19 22:44 ` Alan Cox
2002-05-19 3:38 Rusty Russell
2002-05-19 5:23 ` Linus Torvalds
2002-05-17 0:00 ` Pavel Machek
2002-05-18 21:47 ` Benjamin Herrenschmidt
2002-05-19 12:22 ` Alan Cox
2002-05-19 18:29 ` Linus Torvalds
2002-05-19 19:57 ` Roman Zippel
2002-05-20 2:06 ` Rusty Russell
2002-05-20 2:54 ` Linus Torvalds
2002-05-20 4:53 ` Rusty Russell
2002-05-19 20:12 ` Arnaldo Carvalho de Melo
2002-05-20 16:00 ` Linus Torvalds
2002-05-19 11:41 ` Alan Cox
[not found] <Pine.LNX.4.44.0205191951460.22433-100000@home.transmeta.com.suse.lists.linux.kernel>
[not found] ` <E179fAd-0005vs-00@wagner.rustcorp.com.au.suse.lists.linux.kernel>
2002-05-20 10:59 ` Andi Kleen
2002-05-22 10:08 Petr Vandrovec
2002-05-22 16:23 ` Denis Vlasenko
2002-05-22 13:40 Petr Vandrovec
2002-05-22 18:58 ` Denis Vlasenko
2002-05-22 14:13 ` Ruth Ivimey-Cook
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E178gok-0001Ln-00@wagner.rustcorp.com.au \
--to=rusty@rustcorp.com.au \
--cc=davem@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®