Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp3395476ybp; Sun, 6 Oct 2019 11:00:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqwnPL8UqhgP+9UsXtysQ08yxdoF9pFuQBI8f0MihScsjGQjyZq605i0BZjIcOfiIose4yPo X-Received: by 2002:a17:906:b259:: with SMTP id ce25mr19928543ejb.229.1570384847969; Sun, 06 Oct 2019 11:00:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570384847; cv=none; d=google.com; s=arc-20160816; b=ulaj7SWwkWFFFz8wKVoqZJ70gJdMhb+WmArTATt6PXM/ZRRCZoOt/qbj09lxZ/93eH iZ9UNIFw86khdz0Elmn4bKfNRcRWHD4TuN0QCOgkQh/2ytAwyWI83RJTtAPj+cvVm1WE 7hzP8qKZGEr8ELJqNPm2+YiMZO64dpFu+Dav4MyyJtKtJJfyo6jeegnMgii9bhXtbFxo 16AbRw2lmc3ohqN5Za5wzeJTBLXwp7JHjup8lptxLf/gtJs0zTjLCyhvXmQgvku+wvpy Qgex15ZRsF9qeTxGFeAQKTqDixctGFVj1sQeUfurcZ4UVKFGKHqGthKm8shvJUD62Mni 6GsQ== 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=DV0QIMHoB68f3VzNEylQTDGYZF9TRcBGrB5Ui9J4GpI=; b=jkoR8aDRSCFhFhUG4Z07cc795JX9EbAmyIsA70PRFnXtPZT/kFfE0gE4dWvN9gbOed hPZwSa2jWIOMdAvOu6bE+bvursvUKA/Vgb4FJC9gd/Tx8chnf3xhyQwP8ljgxqpxWHKA //WBj/iOpX2HoyRGWLn+g2v3uoQjdvBf7wlfb/w6yStsH30GdDV6Z/gxtMwcvg3GfRFd auSBbslyT01otbZhTP68D6uZGrKE/8v+ve5f67NKoMrmuTPBxzCqB2MzLhEFj53rXqZ1 f+xoHotnqjzrzPbHHQIS3wsgsyrxvF2U707eD+cSNDnA5mmMtOMLE9+38ZpfTbeIhqym V+1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BgWRmkVX; 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 j2si6835447edp.114.2019.10.06.11.00.24; Sun, 06 Oct 2019 11:00:47 -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=BgWRmkVX; 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 S1729574AbfJFRc3 (ORCPT + 99 others); Sun, 6 Oct 2019 13:32:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:58900 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728825AbfJFRc0 (ORCPT ); Sun, 6 Oct 2019 13:32:26 -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 BF6CA2080F; Sun, 6 Oct 2019 17:32:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570383146; bh=8GBbfujbN5qbxEprt9h6ObWcbEMRO/futWt5+VuTE6M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BgWRmkVXdM5x9JZTQ2M93aON1+1j9Eyeu/NV4qNpA3dTODkkB+jUnGPcrOjI95pHv 9gGhMajJ8F5NXyOMiqvepR5WV2J6D1egWxy7s9Aa02sIgyNWiWPhdzfDBED59KpDQ7 NAXxGbU6/z91XV0fi0Da2xdCZAR5mTn+GySKZ6xg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+0eefc1e06a77d327a056@syzkaller.appspotmail.com, Eric Biggers , Casey Schaufler Subject: [PATCH 4.19 103/106] smack: use GFP_NOFS while holding inode_smack::smk_lock Date: Sun, 6 Oct 2019 19:21:49 +0200 Message-Id: <20191006171204.487770204@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191006171124.641144086@linuxfoundation.org> References: <20191006171124.641144086@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Eric Biggers commit e5bfad3d7acc5702f32aafeb388362994f4d7bd0 upstream. inode_smack::smk_lock is taken during smack_d_instantiate(), which is called during a filesystem transaction when creating a file on ext4. Therefore to avoid a deadlock, all code that takes this lock must use GFP_NOFS, to prevent memory reclaim from waiting for the filesystem transaction to complete. Reported-by: syzbot+0eefc1e06a77d327a056@syzkaller.appspotmail.com Cc: stable@vger.kernel.org Signed-off-by: Eric Biggers Signed-off-by: Casey Schaufler Signed-off-by: Greg Kroah-Hartman --- security/smack/smack_access.c | 6 +++--- security/smack/smack_lsm.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) --- a/security/smack/smack_access.c +++ b/security/smack/smack_access.c @@ -469,7 +469,7 @@ char *smk_parse_smack(const char *string if (i == 0 || i >= SMK_LONGLABEL) return ERR_PTR(-EINVAL); - smack = kzalloc(i + 1, GFP_KERNEL); + smack = kzalloc(i + 1, GFP_NOFS); if (smack == NULL) return ERR_PTR(-ENOMEM); @@ -504,7 +504,7 @@ int smk_netlbl_mls(int level, char *cats if ((m & *cp) == 0) continue; rc = netlbl_catmap_setbit(&sap->attr.mls.cat, - cat, GFP_KERNEL); + cat, GFP_NOFS); if (rc < 0) { netlbl_catmap_free(sap->attr.mls.cat); return rc; @@ -540,7 +540,7 @@ struct smack_known *smk_import_entry(con if (skp != NULL) goto freeout; - skp = kzalloc(sizeof(*skp), GFP_KERNEL); + skp = kzalloc(sizeof(*skp), GFP_NOFS); if (skp == NULL) { skp = ERR_PTR(-ENOMEM); goto freeout; --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c @@ -270,7 +270,7 @@ static struct smack_known *smk_fetch(con if (!(ip->i_opflags & IOP_XATTR)) return ERR_PTR(-EOPNOTSUPP); - buffer = kzalloc(SMK_LONGLABEL, GFP_KERNEL); + buffer = kzalloc(SMK_LONGLABEL, GFP_NOFS); if (buffer == NULL) return ERR_PTR(-ENOMEM);