Re: seq_file dangerous assumption?

From: Al Viro
Date: Sat Jun 09 2012 - 01:26:07 EST


On Mon, Jun 04, 2012 at 10:07:20PM +0200, Jan Kara wrote:

> Also we don't usually put magics into our data structure just to stop bad
> use of interfaces. I agree that in this particular case the interface is
> easy to get wrong - but that should be solved by changing the interface to
> a more robust one. Actually, I'm not sure if anyone actually passes
> ->private_data != NULL since seq_open_private() seems to be a standard way
> of associating some additional data with seq_file. So maybe
> BUG_ON(file->private_data) would be a good robustification of the interface
> :).

*cough* /proc/mounts *cough*

I've just thrown a cleanup of that shite into #for-next (and posted it
upthread). The bottom line:
* seq_open() is fine with ->private_data pointing to struct seq_file
embedded into something.
* that's a supported use; just use container_of() to get to the
entire object by ->private_data (or similar container_of() by seq_file *
argument in seq_file methods).
--
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/