Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp3401047ybp; Sun, 6 Oct 2019 11:06:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqz7DoTfh7h/kdY4ZT6R4ZoCdCyKqEon1czvEt/dp3CkG9lrAIonG6Rg2pa8ibRthdzOfuRG X-Received: by 2002:a05:6402:794:: with SMTP id d20mr25434732edy.20.1570385190388; Sun, 06 Oct 2019 11:06:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570385190; cv=none; d=google.com; s=arc-20160816; b=VM2ILvz/neRxHxtf6f0Vo82M8N17Wv8OVJ+tjNah7nj1zABFOpgWsPaDQYz/O8+oQT xIHkMSuSc1gDOg3QzbEAA3RLTgqW/1DBTps5P0GaH8I4IJWt0i7znRidtC/5GMymIQer sJRF3gzXIr9u1Dpu4LDuAB4jip4BkWs9zSqjaCLCWWNdv8T4GwG2htYFQnEc3eCR6Ir8 uI+F2Eghyp7gB1BfLeCicRxJtpaySW3dY/X6CPMUxgm+4NFCspfiAIbpIDrmAxxipPzT sZnKuL2CJuR67Gag3FveiZ9QdmbZ+L8nDlKuIIK2DegDuLYtHr01UZxLvd2PrP6ec5an GMJA== 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=yCmij0ZSx3Lx5u22NqAzobbutxzWZ3y2clY8wdBc4kw=; b=Gn8nvbRJ1+gT0cW84cc2SzoZZaI94Ct8kUWDClesDKTUHf08CW45r4cuMc+i+Svg4M NyzSaK5nmtqPviJwPUdA+xugN1d3oOgnmAdxSdtrwBWR8BW/wrNTEpztB0Bav79QbZ0u mlRrTDJMmQXOcOsTU7qDbOJf26FHsWxkZymie5av7/rVxqyrixmGprBXH1bLbKscfkz0 Mcwn1e8hVXeOEsHpDCVQsxLO3x3u08E3+tlGivGonqSICQRHCrF/cN2bWpyvYsxQdtDs nJ9ivV4MBaOSy+5Fb2JHd0RqupmmZu52BlSFNG2nujmP0NaVUJ7A347vmbTZ0T0sR2CI A7nQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mhhleIcn; 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 l48si7446521edc.276.2019.10.06.11.06.06; Sun, 06 Oct 2019 11:06:30 -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=mhhleIcn; 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 S1727911AbfJFRYf (ORCPT + 99 others); Sun, 6 Oct 2019 13:24:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:49492 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727899AbfJFRYd (ORCPT ); Sun, 6 Oct 2019 13:24:33 -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 9913F20867; Sun, 6 Oct 2019 17:24:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570382673; bh=fHqOQJ6Mhd47oaOIPunjdLpumaaCH0jkysn3GhZIxdc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mhhleIcnxbpSRU6rX4/knKeteegmrhe4euL09lNW35/Dg7RfBya2rl9dUhNirUdqy 0nJvj3J76Wnzz/B4Y1GtKDLatOnhrCtHVCqIlOWRyJduJ3gBYkScjdv3zECeFQo8uc Tn/6iLb8MYPImBg8KIGpc3o5bh3bNrALYyMpwQaw= 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.9 46/47] smack: use GFP_NOFS while holding inode_smack::smk_lock Date: Sun, 6 Oct 2019 19:21:33 +0200 Message-Id: <20191006172019.312676905@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191006172016.873463083@linuxfoundation.org> References: <20191006172016.873463083@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 | 4 ++-- security/smack/smack_lsm.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) --- a/security/smack/smack_access.c +++ b/security/smack/smack_access.c @@ -474,7 +474,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); @@ -545,7 +545,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 @@ -268,7 +268,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);