• Yann Droneaud's avatar
    fs: use seq_open_private() for proc_mounts · ede1bf0d
    Yann Droneaud authored
    A patchset to remove support for passing pre-allocated struct seq_file to
    seq_open().  Such feature is undocumented and prone to error.
    
    In particular, if seq_release() is used in release handler, it will
    kfree() a pointer which was not allocated by seq_open().
    
    So this patchset drops support for pre-allocated struct seq_file: it's
    only of use in proc_namespace.c and can be easily replaced by using
    seq_open_private()/seq_release_private().
    
    Additionally, it documents the use of file->private_data to hold pointer
    to struct seq_file by seq_open().
    
    This patch (of 3):
    
    Since patch described below, from v2.6.15-rc1, seq_open() could use a
    struct seq_file already allocated by the caller if the pointer to the
    structure is stored in file->private_data before calling the function.
    
        Commit 1abe77b0
        Author: Al Viro <viro@zeniv.linux.org.uk>
        Date:   Mon Nov 7 17:15:34 2005 -0500
    
            [PATCH] allow callers of seq_open do allocation themselves
    
            Allow caller of seq_open() to kmalloc() seq_file + whatever else they
            want and set ->private_data to it.  seq_open() will then abstain from
            doing allocation itself.
    
    Such behavior is only used by mounts_open_common().
    
    In order to drop support for such uncommon feature, proc_mounts is
    converted to use seq_open_private(), which take care of allocating the
    proc_mounts structure, making it available through ->private in struct
    seq_file.
    
    Conversely, proc_mounts is converted to use seq_release_private(), in
    order to release the private structure allocated by seq_open_private().
    
    Then, ->private is used directly instead of proc_mounts() macro to access
    to the proc_mounts structure.
    
    Link: http://lkml.kernel.org/r/cover.1433193673.git.ydroneaud@opteya.comSigned-off-by: default avatarYann Droneaud <ydroneaud@opteya.com>
    Cc: Al Viro <viro@zeniv.linux.org.uk>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    ede1bf0d
namespace.c 79.6 KB