lkml.org 
[lkml]   [2019]   [Mar]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.19 169/280] Btrfs: setup a nofs context for memory allocation at __btrfs_set_acl
    Date
    4.19-stable review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Filipe Manana <fdmanana@suse.com>

    commit a0873490660246db587849a9e172f2b7b21fa88a upstream.

    We are holding a transaction handle when setting an acl, therefore we can
    not allocate the xattr value buffer using GFP_KERNEL, as we could deadlock
    if reclaim is triggered by the allocation, therefore setup a nofs context.

    Fixes: 39a27ec1004e8 ("btrfs: use GFP_KERNEL for xattr and acl allocations")
    CC: stable@vger.kernel.org # 4.9+
    Reviewed-by: Nikolay Borisov <nborisov@suse.com>
    Signed-off-by: Filipe Manana <fdmanana@suse.com>
    Reviewed-by: David Sterba <dsterba@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    ---
    fs/btrfs/acl.c | 9 +++++++++
    1 file changed, 9 insertions(+)

    --- a/fs/btrfs/acl.c
    +++ b/fs/btrfs/acl.c
    @@ -9,6 +9,7 @@
    #include <linux/posix_acl_xattr.h>
    #include <linux/posix_acl.h>
    #include <linux/sched.h>
    +#include <linux/sched/mm.h>
    #include <linux/slab.h>

    #include "ctree.h"
    @@ -72,8 +73,16 @@ static int __btrfs_set_acl(struct btrfs_
    }

    if (acl) {
    + unsigned int nofs_flag;
    +
    size = posix_acl_xattr_size(acl->a_count);
    + /*
    + * We're holding a transaction handle, so use a NOFS memory
    + * allocation context to avoid deadlock if reclaim happens.
    + */
    + nofs_flag = memalloc_nofs_save();
    value = kmalloc(size, GFP_KERNEL);
    + memalloc_nofs_restore(nofs_flag);
    if (!value) {
    ret = -ENOMEM;
    goto out;

    \
     
     \ /
      Last update: 2019-03-22 13:06    [W:4.168 / U:0.008 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site