Re: [UPDATED PATCH] fix memory corruption from misinterpreted bad_inode_ops return values

From: Al Viro
Date: Thu Jan 04 2007 - 15:24:37 EST


On Thu, Jan 04, 2007 at 11:30:22AM -0800, Linus Torvalds wrote:
>
>
> On Thu, 4 Jan 2007, Al Viro wrote:
> >
> > How about "makes call graph analysis easier"? ;-) In principle, I have
> > no problem with force-casting, but it'd better be cast to the right
> > type...
>
> Do we really care in the kernel? We simply never use function pointer
> casts like this for anything non-trivial, so if the graph analysis just
> doesn't work for those cases, do we really even care?

Umm... Let me put it that way - amount of things that can be done to
void * is much more than what can be done to function pointers. So
keeping track of them gets easier if we never do casts to/from void *.
What's more, very few places in the kernel try to do that _and_ most
of those that do are simply too lazy to declare local variable with
the right type. bad_inode.c covers most of what remains.

IMO we ought to start checking for that kind of stuff; note that we _still_
have strugglers from pt_regs removal where interrupt handler still takes
3 arguments, but we don't notice since argument of request_irq() is cast
to void * ;-/

That's local stuff; however, when trying to do non-local work (e.g. deduce
that foo() may be called from BH, bar() is always called from process
context, etc. _without_ fuckloads of annotations all over the place), the
ban on mixing void * with function pointers helps a _lot_.

So my main issue with fs/bad_inode.c is not even cast per se; it's that
cast is to void *.
-
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/