Re: [PATCH] x86_64: fix delayed signals
From: Linus Torvalds
Date: Sun Jul 13 2008 - 14:37:44 EST
On Sun, 13 Jul 2008, Oleg Nesterov wrote:
>
> SETFL_MASK doesn't have O_RDWR, and in any case setfl() changes ->f_flags,
> not ->f_mode.
I think you can still read a write-only file descriptor on some systems:
doing a mmap( PROT_WRITE ) on it can sometimes do it.
The reason - PROT_WRITE often implies PROT_READ (because on many CPU's you
have to do unaligned writes with a read-modify-write cycle - on some like
old alphas you have to do even normal byte and word writes that way).
So if the OS checks just the asked-for protections against the file
descriptor protections, you'll essentially get read access for free when
you do the mmap.
At least current versions of Linux won't ever allow a file mapping of a
non-readable fd, but I won't guarantee we always did that, nor that other
OS's always do it.
Anyway, I misunderstood Edwins idea to actually throw away the writes if
the file isn't linked anywhere and is only open for writing. I guess we
could optimize that, but it's such an unrealistic specialc case that it
really isn't worth it except for some benchmark-gaming kind of thing
(which I don't like doing anyway).
Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/