Re: Fix UDF-FS potentially dereferencing null
From: Alexandre Oliva
Date: Fri Apr 23 2004 - 09:06:45 EST
On Apr 22, 2004, Linus Torvalds <torvalds@xxxxxxxx> wrote:
> In your example, both pointers were called "p", but they were obviously
> two different symbols from a compiler perspective. So there's a clear
> "assignment" from one "p" to the other "p" as part of the inline function
> call, so it's not like the back-end doesn't see that part - it's assigning
> from a non-safe pointer to a safe one _after_ doing the test on the
> non-safe one.
It does see the assignment, yes, but if the pointer happens to be a
constant, and constant propagation turns the assignment `p_i = p;'
into `p_i = constant;', you'd have to preserve the information that
this constant pointer can only be safely dereferenced after the test.
This is an admittedly convoluted example, since if p is constant and
the condition doesn't hold, the conditional dereferencing will
probably have already been optimized away by the time it could do any
damage, but it might not be depending on how the compiler orders its
optimization passes, and then you lose.
--
Alexandre Oliva http://www.ic.unicamp.br/~oliva/
Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org}
-
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/