Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp648630img; Fri, 22 Mar 2019 05:54:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqyWlxgCtCH9hfxLT8LIpeWXZ/VY2qEyXlCyPmb7L0wXGwuxFsJodSrphuUU7UVTzWVMZG7z X-Received: by 2002:aa7:8518:: with SMTP id v24mr8990955pfn.219.1553259281728; Fri, 22 Mar 2019 05:54:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553259281; cv=none; d=google.com; s=arc-20160816; b=Ur1rqpTFz11ZWe7vztbzXOAmPKL8mYHSZvIg4OYcJsE6YWzgEaOyqTYrbtyMAVOsvk 1TDour4LvcqORiBOulIImxRCw5VdIEmUDcgeEG5FfP+RG9dePZKbRbj2ousRgyBLL+Bv sAGv14kT53QiTN8wW9WjWTtxflyaM9mPalpPKXiKbpyG2aQCZvrNi3yFhKsra7CRam+4 qMe3az5Ble+LPg14PtM0sPnZYe8HRVeyzOAQ2r3hJfIx2pyRQbbhxKxzGJFbG1YE69g8 G2vmocjzZOqXRufeLK2o2zWFh93kcjbNg1xS9WSHb+vWWiF82pDk+oXWbcys0To66+c/ R5Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0UNHN6Z5m3QKjX7RQSMFh/1url//8rxNtBJYVKJZIIU=; b=PqpplLL8dQJhUenD9YJvQUt8zrK5R/LxPBAA41Tz1LWh3ICkrBsWqLb4r+DGyjcaMr WU+amDAl8olzqrf8RqoPolQlyNK0yKUSz3pIALrLIECUEAuu0Hx9sTK4j1QSzmtJ8Gmb M4I5ZZxckGccLxo+xx4TGdZQodbdY1qBU0GL52gVAeF58iPntm9P6OzcbdDsT4BUi9vy DT6V1mWxbeqpeJkDJUvB8bW4AayfcJ9PbpXj9Fi0z1Az9ezuK/EpiW38mbnKnG7mDqsH 0SNbjDHtUtPS56WF4pL0XQHwJ6aJFLUaaCxa8rdUD4C6Zodwm5gy3lFqUAoZmqSwDdF7 ePdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NADD6XkJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q17si6478251pgq.392.2019.03.22.05.54.24; Fri, 22 Mar 2019 05:54:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NADD6XkJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733135AbfCVMxb (ORCPT + 99 others); Fri, 22 Mar 2019 08:53:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:55998 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732625AbfCVLwF (ORCPT ); Fri, 22 Mar 2019 07:52:05 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7C8ED2192B; Fri, 22 Mar 2019 11:52:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553255525; bh=JWsR8sGhA0PzfEGVOQ5Leq9jElduVvKAo0hd2TnJpcE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NADD6XkJBe6yKB+LSF0QVspbmZVe3c3QFd7gTNISf6mktetmUrbmHxZhcTDdO8WC2 cH5IMneu4fGdrfhgJ/YNCFkoZmNow7k7YCZhBwbQoMpZLVj4zj8CCOfrnP5rOfKySi aAN76CYFA2zozyGh3iA4LFXwnxtFNeY7/W/2RcEw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nikolay Borisov , Filipe Manana , David Sterba Subject: [PATCH 4.14 102/183] Btrfs: setup a nofs context for memory allocation at __btrfs_set_acl Date: Fri, 22 Mar 2019 12:15:30 +0100 Message-Id: <20190322111249.087888968@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111241.819468003@linuxfoundation.org> References: <20190322111241.819468003@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Filipe Manana 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 Signed-off-by: Filipe Manana Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/acl.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- a/fs/btrfs/acl.c +++ b/fs/btrfs/acl.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include "ctree.h" @@ -89,8 +90,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;