17 Jul, 2018

1 commit

  • This patch fixes a bug where configfs_register_group had added
    a group in a tree, and userspace has done a rmdir on a dir somewhere
    above that group and we hit a kernel crash. The problem is configfs_rmdir
    will detach everything under it and unlink groups on the default_groups
    list. It will not unlink groups added with configfs_register_group so when
    configfs_unregister_group is called to drop its references to the group/items
    we crash when we try to access the freed dentrys.

    The patch just adds a check for if a rmdir has been done above
    us and if so just does the unlink part of unregistration.

    Sorry if you are getting this multiple times. I thouhgt I sent
    this to some of you and lkml, but I do not see it.

    Signed-off-by: Mike Christie
    Cc: Christoph Hellwig
    Cc: Joel Becker
    Signed-off-by: Christoph Hellwig

    Mike Christie
     

02 Jul, 2018

1 commit

  • gcc 8.1.0 complains:

    fs/configfs/symlink.c:67:3: warning:
    'strncpy' output truncated before terminating nul copying as many
    bytes from a string as its length
    fs/configfs/symlink.c: In function 'configfs_get_link':
    fs/configfs/symlink.c:63:13: note: length computed here

    Using strncpy() is indeed less than perfect since the length of data to
    be copied has already been determined with strlen(). Replace strncpy()
    with memcpy() to address the warning and optimize the code a little.

    Signed-off-by: Guenter Roeck
    Signed-off-by: Christoph Hellwig

    Guenter Roeck
     

19 Jun, 2018

1 commit


06 Jun, 2018

1 commit

  • struct timespec is not y2038 safe. Transition vfs to use
    y2038 safe struct timespec64 instead.

    The change was made with the help of the following cocinelle
    script. This catches about 80% of the changes.
    All the header file and logic changes are included in the
    first 5 rules. The rest are trivial substitutions.
    I avoid changing any of the function signatures or any other
    filesystem specific data structures to keep the patch simple
    for review.

    The script can be a little shorter by combining different cases.
    But, this version was sufficient for my usecase.

    virtual patch

    @ depends on patch @
    identifier now;
    @@
    - struct timespec
    + struct timespec64
    current_time ( ... )
    {
    - struct timespec now = current_kernel_time();
    + struct timespec64 now = current_kernel_time64();
    ...
    - return timespec_trunc(
    + return timespec64_trunc(
    ... );
    }

    @ depends on patch @
    identifier xtime;
    @@
    struct \( iattr \| inode \| kstat \) {
    ...
    - struct timespec xtime;
    + struct timespec64 xtime;
    ...
    }

    @ depends on patch @
    identifier t;
    @@
    struct inode_operations {
    ...
    int (*update_time) (...,
    - struct timespec t,
    + struct timespec64 t,
    ...);
    ...
    }

    @ depends on patch @
    identifier t;
    identifier fn_update_time =~ "update_time$";
    @@
    fn_update_time (...,
    - struct timespec *t,
    + struct timespec64 *t,
    ...) { ... }

    @ depends on patch @
    identifier t;
    @@
    lease_get_mtime( ... ,
    - struct timespec *t
    + struct timespec64 *t
    ) { ... }

    @te depends on patch forall@
    identifier ts;
    local idexpression struct inode *inode_node;
    identifier i_xtime =~ "^i_[acm]time$";
    identifier ia_xtime =~ "^ia_[acm]time$";
    identifier fn_update_time =~ "update_time$";
    identifier fn;
    expression e, E3;
    local idexpression struct inode *node1;
    local idexpression struct inode *node2;
    local idexpression struct iattr *attr1;
    local idexpression struct iattr *attr2;
    local idexpression struct iattr attr;
    identifier i_xtime1 =~ "^i_[acm]time$";
    identifier i_xtime2 =~ "^i_[acm]time$";
    identifier ia_xtime1 =~ "^ia_[acm]time$";
    identifier ia_xtime2 =~ "^ia_[acm]time$";
    @@
    (
    (
    - struct timespec ts;
    + struct timespec64 ts;
    |
    - struct timespec ts = current_time(inode_node);
    + struct timespec64 ts = current_time(inode_node);
    )

    i_xtime, &ts)
    + timespec64_equal(&inode_node->i_xtime, &ts)
    |
    - timespec_equal(&ts, &inode_node->i_xtime)
    + timespec64_equal(&ts, &inode_node->i_xtime)
    |
    - timespec_compare(&inode_node->i_xtime, &ts)
    + timespec64_compare(&inode_node->i_xtime, &ts)
    |
    - timespec_compare(&ts, &inode_node->i_xtime)
    + timespec64_compare(&ts, &inode_node->i_xtime)
    |
    ts = current_time(e)
    |
    fn_update_time(..., &ts,...)
    |
    inode_node->i_xtime = ts
    |
    node1->i_xtime = ts
    |
    ts = inode_node->i_xtime
    |
    ia_xtime ...+> = ts
    |
    ts = attr1->ia_xtime
    |
    ts.tv_sec
    |
    ts.tv_nsec
    |
    btrfs_set_stack_timespec_sec(..., ts.tv_sec)
    |
    btrfs_set_stack_timespec_nsec(..., ts.tv_nsec)
    |
    - ts = timespec64_to_timespec(
    + ts =
    ...
    -)
    |
    - ts = ktime_to_timespec(
    + ts = ktime_to_timespec64(
    ...)
    |
    - ts = E3
    + ts = timespec_to_timespec64(E3)
    |
    - ktime_get_real_ts(&ts)
    + ktime_get_real_ts64(&ts)
    |
    fn(...,
    - ts
    + timespec64_to_timespec(ts)
    ,...)
    )
    ...+>
    (

    )
    |
    - timespec_equal(&node1->i_xtime1, &node2->i_xtime2)
    + timespec64_equal(&node1->i_xtime2, &node2->i_xtime2)
    |
    - timespec_equal(&node1->i_xtime1, &attr2->ia_xtime2)
    + timespec64_equal(&node1->i_xtime2, &attr2->ia_xtime2)
    |
    - timespec_compare(&node1->i_xtime1, &node2->i_xtime2)
    + timespec64_compare(&node1->i_xtime1, &node2->i_xtime2)
    |
    node1->i_xtime1 =
    - timespec_trunc(attr1->ia_xtime1,
    + timespec64_trunc(attr1->ia_xtime1,
    ...)
    |
    - attr1->ia_xtime1 = timespec_trunc(attr2->ia_xtime2,
    + attr1->ia_xtime1 = timespec64_trunc(attr2->ia_xtime2,
    ...)
    |
    - ktime_get_real_ts(&attr1->ia_xtime1)
    + ktime_get_real_ts64(&attr1->ia_xtime1)
    |
    - ktime_get_real_ts(&attr.ia_xtime1)
    + ktime_get_real_ts64(&attr.ia_xtime1)
    )

    @ depends on patch @
    struct inode *node;
    struct iattr *attr;
    identifier fn;
    identifier i_xtime =~ "^i_[acm]time$";
    identifier ia_xtime =~ "^ia_[acm]time$";
    expression e;
    @@
    (
    - fn(node->i_xtime);
    + fn(timespec64_to_timespec(node->i_xtime));
    |
    fn(...,
    - node->i_xtime);
    + timespec64_to_timespec(node->i_xtime));
    |
    - e = fn(attr->ia_xtime);
    + e = fn(timespec64_to_timespec(attr->ia_xtime));
    )

    @ depends on patch forall @
    struct inode *node;
    struct iattr *attr;
    identifier i_xtime =~ "^i_[acm]time$";
    identifier ia_xtime =~ "^ia_[acm]time$";
    identifier fn;
    @@
    {
    + struct timespec ts;
    i_xtime);
    fn (...,
    - &node->i_xtime,
    + &ts,
    ...);
    |
    + ts = timespec64_to_timespec(attr->ia_xtime);
    fn (...,
    - &attr->ia_xtime,
    + &ts,
    ...);
    )
    ...+>
    }

    @ depends on patch forall @
    struct inode *node;
    struct iattr *attr;
    struct kstat *stat;
    identifier ia_xtime =~ "^ia_[acm]time$";
    identifier i_xtime =~ "^i_[acm]time$";
    identifier xtime =~ "^[acm]time$";
    identifier fn, ret;
    @@
    {
    + struct timespec ts;
    i_xtime);
    ret = fn (...,
    - &node->i_xtime,
    + &ts,
    ...);
    |
    + ts = timespec64_to_timespec(node->i_xtime);
    ret = fn (...,
    - &node->i_xtime);
    + &ts);
    |
    + ts = timespec64_to_timespec(attr->ia_xtime);
    ret = fn (...,
    - &attr->ia_xtime,
    + &ts,
    ...);
    |
    + ts = timespec64_to_timespec(attr->ia_xtime);
    ret = fn (...,
    - &attr->ia_xtime);
    + &ts);
    |
    + ts = timespec64_to_timespec(stat->xtime);
    ret = fn (...,
    - &stat->xtime);
    + &ts);
    )
    ...+>
    }

    @ depends on patch @
    struct inode *node;
    struct inode *node2;
    identifier i_xtime1 =~ "^i_[acm]time$";
    identifier i_xtime2 =~ "^i_[acm]time$";
    identifier i_xtime3 =~ "^i_[acm]time$";
    struct iattr *attrp;
    struct iattr *attrp2;
    struct iattr attr ;
    identifier ia_xtime1 =~ "^ia_[acm]time$";
    identifier ia_xtime2 =~ "^ia_[acm]time$";
    struct kstat *stat;
    struct kstat stat1;
    struct timespec64 ts;
    identifier xtime =~ "^[acmb]time$";
    expression e;
    @@
    (
    ( node->i_xtime2 \| attrp->ia_xtime2 \| attr.ia_xtime2 \) = node->i_xtime1 ;
    |
    node->i_xtime2 = \( node2->i_xtime1 \| timespec64_trunc(...) \);
    |
    node->i_xtime2 = node->i_xtime1 = node->i_xtime3 = \(ts \| current_time(...) \);
    |
    node->i_xtime1 = node->i_xtime3 = \(ts \| current_time(...) \);
    |
    stat->xtime = node2->i_xtime1;
    |
    stat1.xtime = node2->i_xtime1;
    |
    ( node->i_xtime2 \| attrp->ia_xtime2 \) = attrp->ia_xtime1 ;
    |
    ( attrp->ia_xtime1 \| attr.ia_xtime1 \) = attrp2->ia_xtime2;
    |
    - e = node->i_xtime1;
    + e = timespec64_to_timespec( node->i_xtime1 );
    |
    - e = attrp->ia_xtime1;
    + e = timespec64_to_timespec( attrp->ia_xtime1 );
    |
    node->i_xtime1 = current_time(...);
    |
    node->i_xtime2 = node->i_xtime1 = node->i_xtime3 =
    - e;
    + timespec_to_timespec64(e);
    |
    node->i_xtime1 = node->i_xtime3 =
    - e;
    + timespec_to_timespec64(e);
    |
    - node->i_xtime1 = e;
    + node->i_xtime1 = timespec_to_timespec64(e);
    )

    Signed-off-by: Deepa Dinamani
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:

    Deepa Dinamani
     

19 Oct, 2017

2 commits

  • The ci_type field of the config_item structure do not modify the fields
    of the config_item_type structure it points to. And the other pointers
    initialized with ci_type do not modify the fields as well.
    So, make the ci_type field and the pointers initialized with ci_type
    as const.

    Make the struct config_item_type *type function argument of functions
    config_{item/group}_init_type_name const as the argument in both the
    functions is only stored in the ci_type field of a config_item structure
    which is now made const.
    Make the argument of configfs_register_default_group const as it is
    only passed to the argument of the function config_group_init_type_name
    which is now const.

    Signed-off-by: Bhumika Goyal
    Acked-by: Greg Kroah-Hartman
    Signed-off-by: Christoph Hellwig

    Bhumika Goyal
     
  • Bool initializations should use true and false. Bool tests don't need
    comparisons.

    Signed-off-by: Thomas Meyer
    Signed-off-by: Christoph Hellwig

    Thomas Meyer
     

12 Jun, 2017

2 commits

  • Signed-off-by: Bart Van Assche
    [hch: minor style tweak]
    Signed-off-by: Christoph Hellwig

    Bart Van Assche
     
  • This patch closes a long standing race in configfs between
    the creation of a new symlink in create_link(), while the
    symlink target's config_item is being concurrently removed
    via configfs_rmdir().

    This can happen because the symlink target's reference
    is obtained by config_item_get() in create_link() before
    the CONFIGFS_USET_DROPPING bit set by configfs_detach_prep()
    during configfs_rmdir() shutdown is actually checked..

    This originally manifested itself on ppc64 on v4.8.y under
    heavy load using ibmvscsi target ports with Novalink API:

    [ 7877.289863] rpadlpar_io: slot U8247.22L.212A91A-V1-C8 added
    [ 7879.893760] ------------[ cut here ]------------
    [ 7879.893768] WARNING: CPU: 15 PID: 17585 at ./include/linux/kref.h:46 config_item_get+0x7c/0x90 [configfs]
    [ 7879.893811] CPU: 15 PID: 17585 Comm: targetcli Tainted: G O 4.8.17-customv2.22 #12
    [ 7879.893812] task: c00000018a0d3400 task.stack: c0000001f3b40000
    [ 7879.893813] NIP: d000000002c664ec LR: d000000002c60980 CTR: c000000000b70870
    [ 7879.893814] REGS: c0000001f3b43810 TRAP: 0700 Tainted: G O (4.8.17-customv2.22)
    [ 7879.893815] MSR: 8000000000029033 CR: 28222242 XER: 00000000
    [ 7879.893820] CFAR: d000000002c664bc SOFTE: 1
    GPR00: d000000002c60980 c0000001f3b43a90 d000000002c70908 c0000000fbc06820
    GPR04: c0000001ef1bd900 0000000000000004 0000000000000001 0000000000000000
    GPR08: 0000000000000000 0000000000000001 d000000002c69560 d000000002c66d80
    GPR12: c000000000b70870 c00000000e798700 c0000001f3b43ca0 c0000001d4949d40
    GPR16: c00000014637e1c0 0000000000000000 0000000000000000 c0000000f2392940
    GPR20: c0000001f3b43b98 0000000000000041 0000000000600000 0000000000000000
    GPR24: fffffffffffff000 0000000000000000 d000000002c60be0 c0000001f1dac490
    GPR28: 0000000000000004 0000000000000000 c0000001ef1bd900 c0000000f2392940
    [ 7879.893839] NIP [d000000002c664ec] config_item_get+0x7c/0x90 [configfs]
    [ 7879.893841] LR [d000000002c60980] check_perm+0x80/0x2e0 [configfs]
    [ 7879.893842] Call Trace:
    [ 7879.893844] [c0000001f3b43ac0] [d000000002c60980] check_perm+0x80/0x2e0 [configfs]
    [ 7879.893847] [c0000001f3b43b10] [c000000000329770] do_dentry_open+0x2c0/0x460
    [ 7879.893849] [c0000001f3b43b70] [c000000000344480] path_openat+0x210/0x1490
    [ 7879.893851] [c0000001f3b43c80] [c00000000034708c] do_filp_open+0xfc/0x170
    [ 7879.893853] [c0000001f3b43db0] [c00000000032b5bc] do_sys_open+0x1cc/0x390
    [ 7879.893856] [c0000001f3b43e30] [c000000000009584] system_call+0x38/0xec
    [ 7879.893856] Instruction dump:
    [ 7879.893858] 409d0014 38210030 e8010010 7c0803a6 4e800020 3d220000 e94981e0 892a0000
    [ 7879.893861] 2f890000 409effe0 39200001 992a0000 4bffffd0 60000000 60000000
    [ 7879.893866] ---[ end trace 14078f0b3b5ad0aa ]---

    To close this race, go ahead and obtain the symlink's target
    config_item reference only after the existing CONFIGFS_USET_DROPPING
    check succeeds.

    This way, if configfs_rmdir() wins create_link() will return -ENONET,
    and if create_link() wins configfs_rmdir() will return -EBUSY.

    Reported-by: Bryant G. Ly
    Tested-by: Bryant G. Ly
    Signed-off-by: Nicholas Bellinger
    Signed-off-by: Christoph Hellwig
    Cc: stable@vger.kernel.org

    Nicholas Bellinger
     

25 Dec, 2016

1 commit


09 Dec, 2016

1 commit


11 Oct, 2016

1 commit


28 Sep, 2016

1 commit

  • current_fs_time() uses struct super_block* as an argument.
    As per Linus's suggestion, this is changed to take struct
    inode* as a parameter instead. This is because the function
    is primarily meant for vfs inode timestamps.
    Also the function was renamed as per Arnd's suggestion.

    Change all calls to current_fs_time() to use the new
    current_time() function instead. current_fs_time() will be
    deleted.

    Signed-off-by: Deepa Dinamani
    Signed-off-by: Al Viro

    Deepa Dinamani
     

16 Sep, 2016

1 commit


10 Jul, 2016

1 commit

  • A confgifs attribute's show() callback is called once the first time
    the user attempts to read from it. If it returns an error, that
    error is returned to the user. However, the open file's
    buffer_needs_fill is still set to zero and consecutive read() calls
    will find an empty buffer that doesn't need filling and return 0 to
    the user. This could give the user the wrong impression that the
    attribute was read successfully.

    Fix this by not setting buffer_needs_fill if show() returns an error,
    making consecutive read() calls call show() again and either get an
    error again or get data.

    Signed-off-by: Tal Shorer
    Signed-off-by: Christoph Hellwig

    Tal Shorer
     

30 Jun, 2016

1 commit

  • The simple_write_to_buffer() already increments the @ppos on success,
    see fs/libfs.c simple_write_to_buffer() comment:

    "
    On success, the number of bytes written is returned and the offset @ppos
    advanced by this number, or negative value is returned on error.
    "

    If the configfs_write_bin_file() is invoked with @count smaller than the
    total length of the written binary file, it will be invoked multiple times.
    Since configfs_write_bin_file() increments @ppos on success, after calling
    simple_write_to_buffer(), the @ppos is incremented twice.

    Subsequent invocation of configfs_write_bin_file() will result in the next
    piece of data being written to the offset twice as long as the length of
    the previous write, thus creating buffer with "holes" in it.

    The simple testcase using DTO follows:
    $ mkdir /sys/kernel/config/device-tree/overlays/1
    $ dd bs=1 if=foo.dtbo of=/sys/kernel/config/device-tree/overlays/1/dtbo
    Without this patch, the testcase will result in twice as big buffer in the
    kernel, which is then passed to the cfs_overlay_item_dtbo_write() .

    Signed-off-by: Marek Vasut
    Cc: Geert Uytterhoeven
    Cc: Christoph Hellwig
    Cc: Pantelis Antoniou

    Marek Vasut
     

09 May, 2016

1 commit


03 May, 2016

2 commits


05 Apr, 2016

1 commit

  • PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} macros were introduced *long* time
    ago with promise that one day it will be possible to implement page
    cache with bigger chunks than PAGE_SIZE.

    This promise never materialized. And unlikely will.

    We have many places where PAGE_CACHE_SIZE assumed to be equal to
    PAGE_SIZE. And it's constant source of confusion on whether
    PAGE_CACHE_* or PAGE_* constant should be used in a particular case,
    especially on the border between fs and mm.

    Global switching to PAGE_CACHE_SIZE != PAGE_SIZE would cause to much
    breakage to be doable.

    Let's stop pretending that pages in page cache are special. They are
    not.

    The changes are pretty straight-forward:

    - << (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> ;

    - >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> ;

    - PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} -> PAGE_{SIZE,SHIFT,MASK,ALIGN};

    - page_cache_get() -> get_page();

    - page_cache_release() -> put_page();

    This patch contains automated changes generated with coccinelle using
    script below. For some reason, coccinelle doesn't patch header files.
    I've called spatch for them manually.

    The only adjustment after coccinelle is revert of changes to
    PAGE_CAHCE_ALIGN definition: we are going to drop it later.

    There are few places in the code where coccinelle didn't reach. I'll
    fix them manually in a separate patch. Comments and documentation also
    will be addressed with the separate patch.

    virtual patch

    @@
    expression E;
    @@
    - E << (PAGE_CACHE_SHIFT - PAGE_SHIFT)
    + E

    @@
    expression E;
    @@
    - E >> (PAGE_CACHE_SHIFT - PAGE_SHIFT)
    + E

    @@
    @@
    - PAGE_CACHE_SHIFT
    + PAGE_SHIFT

    @@
    @@
    - PAGE_CACHE_SIZE
    + PAGE_SIZE

    @@
    @@
    - PAGE_CACHE_MASK
    + PAGE_MASK

    @@
    expression E;
    @@
    - PAGE_CACHE_ALIGN(E)
    + PAGE_ALIGN(E)

    @@
    expression E;
    @@
    - page_cache_get(E)
    + get_page(E)

    @@
    expression E;
    @@
    - page_cache_release(E)
    + put_page(E)

    Signed-off-by: Kirill A. Shutemov
    Acked-by: Michal Hocko
    Signed-off-by: Linus Torvalds

    Kirill A. Shutemov
     

20 Mar, 2016

1 commit

  • Pull vfs updates from Al Viro:

    - Preparations of parallel lookups (the remaining main obstacle is the
    need to move security_d_instantiate(); once that becomes safe, the
    rest will be a matter of rather short series local to fs/*.c

    - preadv2/pwritev2 series from Christoph

    - assorted fixes

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (32 commits)
    splice: handle zero nr_pages in splice_to_pipe()
    vfs: show_vfsstat: do not ignore errors from show_devname method
    dcache.c: new helper: __d_add()
    don't bother with __d_instantiate(dentry, NULL)
    untangle fsnotify_d_instantiate() a bit
    uninline d_add()
    replace d_add_unique() with saner primitive
    quota: use lookup_one_len_unlocked()
    cifs_get_root(): use lookup_one_len_unlocked()
    nfs_lookup: don't bother with d_instantiate(dentry, NULL)
    kill dentry_unhash()
    ceph_fill_trace(): don't bother with d_instantiate(dn, NULL)
    autofs4: don't bother with d_instantiate(dentry, NULL) in ->lookup()
    configfs: move d_rehash() into configfs_create() for regular files
    ceph: don't bother with d_rehash() in splice_dentry()
    namei: teach lookup_slow() to skip revalidate
    namei: massage lookup_slow() to be usable by lookup_one_len_unlocked()
    lookup_one_len_unlocked(): use lookup_dcache()
    namei: simplify invalidation logics in lookup_dcache()
    namei: change calling conventions for lookup_{fast,slow} and follow_managed()
    ...

    Linus Torvalds
     

14 Mar, 2016

1 commit


06 Mar, 2016

1 commit

  • Replace the current NULL-terminated array of default groups with a linked
    list. This gets rid of lots of nasty code to size and/or dynamically
    allocate the array.

    While we're at it also provide a conveniant helper to remove the default
    groups.

    Signed-off-by: Christoph Hellwig
    Acked-by: Felipe Balbi [drivers/usb/gadget]
    Acked-by: Joel Becker
    Acked-by: Nicholas Bellinger
    Reviewed-by: Sagi Grimberg

    Christoph Hellwig
     

26 Feb, 2016

1 commit


23 Jan, 2016

1 commit

  • parallel to mutex_{lock,unlock,trylock,is_locked,lock_nested},
    inode_foo(inode) being mutex_foo(&inode->i_mutex).

    Please, use those for access to ->i_mutex; over the coming cycle
    ->i_mutex will become rwsem, with ->lookup() done with it held
    only shared.

    Signed-off-by: Al Viro

    Al Viro
     

21 Jan, 2016

1 commit

  • Pull SCSI target updates from Nicholas Bellinger:
    "The highlights this round include:

    - Introduce configfs support for unlocked configfs_depend_item()
    (krzysztof + andrezej)
    - Conversion of usb-gadget target driver to new function registration
    interface (andrzej + sebastian)
    - Enable qla2xxx FC target mode support for Extended Logins (himansu +
    giridhar)
    - Enable qla2xxx FC target mode support for Exchange Offload (himansu +
    giridhar)
    - Add qla2xxx FC target mode irq affinity notification + selective
    command queuing. (quinn + himanshu)
    - Fix iscsi-target deadlock in se_node_acl configfs deletion (sagi +
    nab)
    - Convert se_node_acl configfs deletion + se_node_acl->queue_depth to
    proper se_session->sess_kref + target_get_session() usage. (hch +
    sagi + nab)
    - Fix long-standing race between se_node_acl->acl_kref get and
    get_initiator_node_acl() lookup. (hch + nab)
    - Fix target/user block-size handling, and make sure netlink reaches
    all network namespaces (sheng + andy)

    Note there is an outstanding bug-fix series for remote I_T nexus port
    TMR LUN_RESET has been posted and still being tested, and will likely
    become post -rc1 material at this point"

    * 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending: (56 commits)
    scsi: qla2xxxx: avoid type mismatch in comparison
    target/user: Make sure netlink would reach all network namespaces
    target: Obtain se_node_acl->acl_kref during get_initiator_node_acl
    target: Convert ACL change queue_depth se_session reference usage
    iscsi-target: Fix potential dead-lock during node acl delete
    ib_srpt: Convert acl lookup to modern get_initiator_node_acl usage
    tcm_fc: Convert acl lookup to modern get_initiator_node_acl usage
    tcm_fc: Wait for command completion before freeing a session
    target: Fix a memory leak in target_dev_lba_map_store()
    target: Support aborting tasks with a 64-bit tag
    usb/gadget: Remove set-but-not-used variables
    target: Remove an unused variable
    target: Fix indentation in target_core_configfs.c
    target/user: Allow user to set block size before enabling device
    iser-target: Fix non negative ERR_PTR isert_device_get usage
    target/fcoe: Add tag support to tcm_fc
    qla2xxx: Check for online flag instead of active reset when transmitting responses
    qla2xxx: Set all queues to 4k
    qla2xxx: Disable ZIO at start time.
    qla2xxx: Move atioq to a different lock to reduce lock contention
    ...

    Linus Torvalds
     

13 Jan, 2016

1 commit

  • Pull configfs updates from Christoph Hellwig:
    "I'm assisting Joel as co-maintainer and patch monkey now, and you will
    see pull reuquests from me for a while.

    Besides the MAINTAINERS update there is just a single change, which
    adds support for binary attributes to configfs, which are very similar
    to the sysfs binary attributes. Thanks to Pantelis Antoniou!

    You will see another actually bigger set of configfs changes in the
    SCSI target pull from Nic - those were merged before this new tree
    even existed"

    * tag 'configfs-for-linus' of git://git.infradead.org/users/hch/configfs:
    configfs: add myself as co-maintainer, updated git tree
    configfs: implement binary attributes

    Linus Torvalds
     

04 Jan, 2016

1 commit

  • ConfigFS lacked binary attributes up until now. This patch
    introduces support for binary attributes in a somewhat similar
    manner of sysfs binary attributes albeit with changes that
    fit the configfs usage model.

    Problems that configfs binary attributes fix are everything that
    requires a binary blob as part of the configuration of a resource,
    such as bitstream loading for FPGAs, DTBs for dynamically created
    devices etc.

    Look at Documentation/filesystems/configfs/configfs.txt for internals
    and howto use them.

    This patch is against linux-next as of today that contains
    Christoph's configfs rework.

    Signed-off-by: Pantelis Antoniou
    [hch: folded a fix from Geert Uytterhoeven ]
    [hch: a few tiny updates based on review feedback]
    Signed-off-by: Christoph Hellwig

    Pantelis Antoniou
     

31 Dec, 2015

1 commit


30 Dec, 2015

1 commit


21 Dec, 2015

4 commits

  • This change is necessary for the SCSI target usb gadget composed with
    configfs. In this case configfs will be used for two different purposes:
    to compose a usb gadget and to configure the target part. If an instance
    of tcm function is created in $CONFIGFS_ROOT/usb_gadget//functions
    a tpg can be created in $CONFIGFS_ROOT/target/usb_gadget//, but after
    a tpg is created the tcm function must not be removed until its
    corresponding tpg is gone. While the configfs_depend/undepend_item() are
    meant exactly for creating this kind of dependencies, they are not suitable
    if the other kernel subsystem happens to be another subsystem in configfs,
    so this patch adds unlocked versions meant for configfs callbacks.

    Above description has been provided by:
    Andrzej Pietrasiewicz

    In configfs_depend_item() we have to consider two possible cases:

    1) When we are called to depend another item in the same subsystem
    as caller
    In this case we should skip locking configfs root as we know
    that configfs is in valid state and our subsystem will not
    be unregistered during this call.

    2) When we are called to depend item in different subsystem than
    our caller
    In this case we are also sure that configfs is in valid state
    but we have to lock root of configfs to avoid unregistration
    of target's subsystem. As it is other than caller's subsystem,
    there may be nothing what protects us against unregistration
    of that subsystem.

    Signed-off-by: Krzysztof Opasiak
    Cc: Joel Becker
    Cc: Christoph Hellwig
    Signed-off-by: Nicholas Bellinger

    Krzysztof Opasiak
     
  • configfs_depend_item() is quite complicated and should
    be split up into smaller functions. This also allow to
    share this code with other functions.

    Signed-off-by: Krzysztof Opasiak
    Cc: Joel Becker
    Cc: Christoph Hellwig
    Signed-off-by: Nicholas Bellinger

    Krzysztof Opasiak
     
  • configfs_depend_item() is quite complicated and should
    be split up into smaller functions. This also allow to
    share this code with other functions.

    Signed-off-by: Krzysztof Opasiak
    Cc: Joel Becker
    Cc: Christoph Hellwig
    Signed-off-by: Nicholas Bellinger

    Krzysztof Opasiak
     
  • subsys parameter is never used by configfs_undepend_item()
    so there is no point in passing it to this function.

    Signed-off-by: Krzysztof Opasiak
    Cc: Joel Becker
    Cc: Christoph Hellwig
    Signed-off-by: Nicholas Bellinger

    Krzysztof Opasiak
     

09 Dec, 2015

1 commit

  • new method: ->get_link(); replacement of ->follow_link(). The differences
    are:
    * inode and dentry are passed separately
    * might be called both in RCU and non-RCU mode;
    the former is indicated by passing it a NULL dentry.
    * when called that way it isn't allowed to block
    and should return ERR_PTR(-ECHILD) if it needs to be called
    in non-RCU mode.

    It's a flagday change - the old method is gone, all in-tree instances
    converted. Conversion isn't hard; said that, so far very few instances
    do not immediately bail out when called in RCU mode. That'll change
    in the next commits.

    Signed-off-by: Al Viro

    Al Viro
     

21 Nov, 2015

1 commit

  • This patchset introduces IIO software triggers, offers a way of configuring
    them via configfs and adds the IIO hrtimer based interrupt source to be used
    with software triggers.

    The architecture is now split in 3 parts, to remove all IIO trigger specific
    parts from IIO configfs core:

    (1) IIO configfs - creates the root of the IIO configfs subsys.
    (2) IIO software triggers - software trigger implementation, dynamically
    creating /config/iio/triggers group.
    (3) IIO hrtimer trigger - is the first interrupt source for software triggers
    (with syfs to follow). Each trigger type can implement its own set of
    attributes.

    Lockdep seems to be happy with the locking in configfs patch.

    This patch (of 5):

    We don't want to hardcode default groups at subsystem
    creation time. We export:
    * configfs_register_group
    * configfs_unregister_group
    to allow drivers to programatically create/destroy groups
    later, after module init time.

    This is needed for IIO configfs support.

    (akpm: the other 4 patches to be merged via the IIO tree)

    Signed-off-by: Daniel Baluta
    Suggested-by: Lars-Peter Clausen
    Reviewed-by: Christoph Hellwig
    Acked-by: Joel Becker
    Cc: Hartmut Knaack
    Cc: Octavian Purdila
    Cc: Paul Bolle
    Cc: Adriana Reus
    Cc: Cristina Opriceana
    Cc: Peter Meerwald
    Cc: Alexander Viro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Daniel Baluta
     

14 Oct, 2015

2 commits

  • Remove the old show_attribute and store_attribute methods and update
    the documentation. Also replace the two C samples with a single new
    one in the proper samples directory where people expect to find it.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Nicholas Bellinger

    Christoph Hellwig
     
  • Add methods to struct configfs_attribute to directly show and store
    attributes without adding boilerplate code to every user. In addition
    to the methods this also adds 3 helper macros to define read/write,
    read-only and write-only attributes with a single line of code.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Nicholas Bellinger
    Acked-by: Greg Kroah-Hartman
    Signed-off-by: Nicholas Bellinger

    Christoph Hellwig
     

18 Jul, 2015

1 commit

  • Some modules call config_item_init_type_name() and config_group_init_type_name()
    with parameter "name" directly controlled by userspace. These two
    functions call config_item_set_name() with this name used as a format
    string, which can be used to leak information such as content of the
    stack to userspace.

    For example, make_netconsole_target() in netconsole module calls
    config_item_init_type_name() with the name of a newly-created directory.
    This means that the following commands give some unexpected output, with
    configfs mounted in /sys/kernel/config/ and on a system with a
    configured eth0 ethernet interface:

    # modprobe netconsole
    # mkdir /sys/kernel/config/netconsole/target_%lx
    # echo eth0 > /sys/kernel/config/netconsole/target_%lx/dev_name
    # echo 1 > /sys/kernel/config/netconsole/target_%lx/enabled
    # echo eth0 > /sys/kernel/config/netconsole/target_%lx/dev_name
    # dmesg |tail -n1
    [ 142.697668] netconsole: target (target_ffffffffc0ae8080) is
    enabled, disable to update parameters

    The directory name is correct but %lx has been interpreted in the
    internal item name, displayed here in the error message used by
    store_dev_name() in drivers/net/netconsole.c.

    To fix this, update every caller of config_item_set_name to use "%s"
    when operating on untrusted input.

    This issue was found using -Wformat-security gcc flag, once a __printf
    attribute has been added to config_item_set_name().

    Signed-off-by: Nicolas Iooss
    Acked-by: Greg Kroah-Hartman
    Acked-by: Felipe Balbi
    Acked-by: Joel Becker
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Nicolas Iooss
     

05 Jul, 2015

1 commit

  • Pull more vfs updates from Al Viro:
    "Assorted VFS fixes and related cleanups (IMO the most interesting in
    that part are f_path-related things and Eric's descriptor-related
    stuff). UFS regression fixes (it got broken last cycle). 9P fixes.
    fs-cache series, DAX patches, Jan's file_remove_suid() work"

    [ I'd say this is much more than "fixes and related cleanups". The
    file_table locking rule change by Eric Dumazet is a rather big and
    fundamental update even if the patch isn't huge. - Linus ]

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (49 commits)
    9p: cope with bogus responses from server in p9_client_{read,write}
    p9_client_write(): avoid double p9_free_req()
    9p: forgetting to cancel request on interrupted zero-copy RPC
    dax: bdev_direct_access() may sleep
    block: Add support for DAX reads/writes to block devices
    dax: Use copy_from_iter_nocache
    dax: Add block size note to documentation
    fs/file.c: __fget() and dup2() atomicity rules
    fs/file.c: don't acquire files->file_lock in fd_install()
    fs:super:get_anon_bdev: fix race condition could cause dev exceed its upper limitation
    vfs: avoid creation of inode number 0 in get_next_ino
    namei: make set_root_rcu() return void
    make simple_positive() public
    ufs: use dir_pages instead of ufs_dir_pages()
    pagemap.h: move dir_pages() over there
    remove the pointless include of lglock.h
    fs: cleanup slight list_entry abuse
    xfs: Correctly lock inode when removing suid and file capabilities
    fs: Call security_ops->inode_killpriv on truncate
    fs: Provide function telling whether file_remove_privs() will do anything
    ...

    Linus Torvalds
     

04 Jul, 2015

1 commit

  • Pull user namespace updates from Eric Biederman:
    "Long ago and far away when user namespaces where young it was realized
    that allowing fresh mounts of proc and sysfs with only user namespace
    permissions could violate the basic rule that only root gets to decide
    if proc or sysfs should be mounted at all.

    Some hacks were put in place to reduce the worst of the damage could
    be done, and the common sense rule was adopted that fresh mounts of
    proc and sysfs should allow no more than bind mounts of proc and
    sysfs. Unfortunately that rule has not been fully enforced.

    There are two kinds of gaps in that enforcement. Only filesystems
    mounted on empty directories of proc and sysfs should be ignored but
    the test for empty directories was insufficient. So in my tree
    directories on proc, sysctl and sysfs that will always be empty are
    created specially. Every other technique is imperfect as an ordinary
    directory can have entries added even after a readdir returns and
    shows that the directory is empty. Special creation of directories
    for mount points makes the code in the kernel a smidge clearer about
    it's purpose. I asked container developers from the various container
    projects to help test this and no holes were found in the set of mount
    points on proc and sysfs that are created specially.

    This set of changes also starts enforcing the mount flags of fresh
    mounts of proc and sysfs are consistent with the existing mount of
    proc and sysfs. I expected this to be the boring part of the work but
    unfortunately unprivileged userspace winds up mounting fresh copies of
    proc and sysfs with noexec and nosuid clear when root set those flags
    on the previous mount of proc and sysfs. So for now only the atime,
    read-only and nodev attributes which userspace happens to keep
    consistent are enforced. Dealing with the noexec and nosuid
    attributes remains for another time.

    This set of changes also addresses an issue with how open file
    descriptors from /proc//ns/* are displayed. Recently readlink of
    /proc//fd has been triggering a WARN_ON that has not been
    meaningful since it was added (as all of the code in the kernel was
    converted) and is not now actively wrong.

    There is also a short list of issues that have not been fixed yet that
    I will mention briefly.

    It is possible to rename a directory from below to above a bind mount.
    At which point any directory pointers below the renamed directory can
    be walked up to the root directory of the filesystem. With user
    namespaces enabled a bind mount of the bind mount can be created
    allowing the user to pick a directory whose children they can rename
    to outside of the bind mount. This is challenging to fix and doubly
    so because all obvious solutions must touch code that is in the
    performance part of pathname resolution.

    As mentioned above there is also a question of how to ensure that
    developers by accident or with purpose do not introduce exectuable
    files on sysfs and proc and in doing so introduce security regressions
    in the current userspace that will not be immediately obvious and as
    such are likely to require breaking userspace in painful ways once
    they are recognized"

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace:
    vfs: Remove incorrect debugging WARN in prepend_path
    mnt: Update fs_fully_visible to test for permanently empty directories
    sysfs: Create mountpoints with sysfs_create_mount_point
    sysfs: Add support for permanently empty directories to serve as mount points.
    kernfs: Add support for always empty directories.
    proc: Allow creating permanently empty directories that serve as mount points
    sysctl: Allow creating permanently empty directories that serve as mountpoints.
    fs: Add helper functions for permanently empty directories.
    vfs: Ignore unlocked mounts in fs_fully_visible
    mnt: Modify fs_fully_visible to deal with locked ro nodev and atime
    mnt: Refactor the logic for mounting sysfs and proc in a user namespace

    Linus Torvalds