Skip to contentSkip to conversation

2.2 PATCH: check return from copy_*_user in fs/pipe.c

DISCUSSION Zack Weinberg 2 participants 3 messages Jun 21, 2001

lore
Share & tools
lore
#0 lore raw
Quoted 10 lines · Linus Torvalds

If somebody passes in a bad pointer to a system call, you've just invoced the rule of "the kernel _may_ be nice to you, but the kernel might just consider you a moron and tell you it worked".

There is no "lost data" or anything else. You've screwed yourself, and you threw the data away. Don't blame the kernel.

And before you say "it has to return EFAULT", check the standards, and think about the case of libraries vs system calls - and how do you tell them apart?

My reading of the standard is that it has to either return EFAULT or raise SIGSEGV. But I am not expert in XPG4-ese.

Whether or not the standard requires anything, I would much rather that the kernel not silently discard error conditions.

zw

#1 lore raw
Quoted 6 lines · Zack Weinberg
Quoted 3 lines · Linus Torvalds

And before you say "it has to return EFAULT", check the standards, and think about the case of libraries vs system calls - and how do you tell them apart?

My reading of the standard is that it has to either return EFAULT or

                                      ^^
Quoted 1 line

raise SIGSEGV. But I am not expert in XPG4-ese.

Linus is trying to point out: "what is this 'it'?" Is it glibc or what the kernel gives you?

Quoted 2 lines

Whether or not the standard requires anything, I would much rather that the kernel not silently discard error conditions.

But only perhaps from a "quality of implementation" perspective not a "correctness" one.

Later,
David S. Miller
[email protected]

#2 lore raw
Quoted 7 lines · David S. Miller
Quoted 5 lines · Zack Weinberg
Quoted 3 lines · Linus Torvalds

And before you say "it has to return EFAULT", check the standards, and think about the case of libraries vs system calls - and how do you tell them apart?

Quoted 6 lines
Quoted 1 line

My reading of the standard is that it has to either return EFAULT or

                                      ^^
Quoted 1 line

raise SIGSEGV. But I am not expert in XPG4-ese.

Linus is trying to point out: "what is this 'it'?" Is it glibc or what the kernel gives you?

POSIX/XPG doesn't make a distinction between kernel and C library as far as I see... which is why either a signal or an error return is permitted by the standard; it depends on where the thing really is implemented.

Quoted 5 lines
Quoted 2 lines

Whether or not the standard requires anything, I would much rather that the kernel not silently discard error conditions.

But only perhaps from a "quality of implementation" perspective not a "correctness" one.

Okay, I'll accept that.

zw