Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6267632imu; Mon, 21 Jan 2019 06:07:12 -0800 (PST) X-Google-Smtp-Source: ALg8bN6MtEx48H6Q2V3Kg/Ny8cTAfl6IYQQ4nbh8fFhaayC5cvp7i/rGffXO30HePFHqImk2SUOt X-Received: by 2002:a63:9e19:: with SMTP id s25mr28259062pgd.203.1548079632426; Mon, 21 Jan 2019 06:07:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548079632; cv=none; d=google.com; s=arc-20160816; b=k/6eLr8un6MCobcAwwfS/FNQTPfbBNykQBXDqjUwOzO7AKPN6R2sQpCGaa5nenLOJ2 1v6B1GN1T9NbFQr4XnZgFes/XvnS6vOP+0Hb8vjSBGUrr+cZXPJ1IGaHVGXJKR7lfgz8 2e3zNKA3Ye6U7Y+UMm2K4IIlLi85MVY31BgFbONDI/lZOy1u4iFsb6rn1yBUGt1tboNw VU39m/753ZN/Zx8xDSFFbQc8tTiZWWfmsW1Y11gGvfhzpTb7PWINfdhNSOyP6gOY9nwt 9b7U1VLdWLCdufgVmIEe90GOkKz4cpX+KYCNVQej1gSe1LTR8qne3BSjYWS047/DOGuE oahQ== 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=JhlD5J3GloYjyXvH+JKuBt5M26B/kHkpfVTTXgtfJEw=; b=fTqsDbjyI9Tm7vt+zc3ILznSPa5hlD5YyCh3V8USgclGKEz2ntVVku2FG4MO7LBVhj A2gfjEB+RDlfnFrVwviNFQdPT5Zjg9v2mXPV/sCwZE+R9H3y2yHMcML9bQZiJjQphRco 4JrK5WSnOP9K3PKnx6IaDe+YMpVHgPmNdj4oS1EewzOGfu9gp1GZAgn4zSZtWgnNRV6E /0BY8enJ0MJeAQK+/O6h4zfCfcTWNzzh9EfaETRovR+nc5dDd46iXz7Vn+G/AnH+yHxi OHuANlUH49y7YHB1HcXq6Da+hCNZ6drv4+IK+T13GwcoO7dNXJp+IEf6Qe2hqM4y5QAu fBAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=y5luE4no; 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 w12si12694316pgl.122.2019.01.21.06.06.57; Mon, 21 Jan 2019 06:07:12 -0800 (PST) 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=y5luE4no; 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 S1731745AbfAUOFE (ORCPT + 99 others); Mon, 21 Jan 2019 09:05:04 -0500 Received: from mail.kernel.org ([198.145.29.99]:48524 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732640AbfAUOB1 (ORCPT ); Mon, 21 Jan 2019 09:01:27 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 A092C2089F; Mon, 21 Jan 2019 14:01:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548079287; bh=Jyt+9W8uKbUBKGNlD9c8zRkAcVhNGchBv0Vm5n8vGV0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=y5luE4noYeCb8vcTB92RaNa3H9GMTQZPBFrXdfBhCKZIsMEnFyL25qQ6KWh3R+DwB nVMzbZOMTvEVCIPedbCM0moOLj2iuJnoe4LJrVS+Vyq25s8KpTU+R033RV9wT9n5Rr Zj7wMCZUbj4PNm3raOrwVGpRgoMkK3iJdJBDrnYM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+6664500f0f18f07a5c0e@syzkaller.appspotmail.com, Stephen Smalley , Paul Moore Subject: [PATCH 4.19 71/99] selinux: fix GPF on invalid policy Date: Mon, 21 Jan 2019 14:49:03 +0100 Message-Id: <20190121134916.696654490@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190121134913.924726465@linuxfoundation.org> References: <20190121134913.924726465@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.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Stephen Smalley commit 5b0e7310a2a33c06edc7eb81ffc521af9b2c5610 upstream. levdatum->level can be NULL if we encounter an error while loading the policy during sens_read prior to initializing it. Make sure sens_destroy handles that case correctly. Reported-by: syzbot+6664500f0f18f07a5c0e@syzkaller.appspotmail.com Signed-off-by: Stephen Smalley Signed-off-by: Paul Moore Signed-off-by: Greg Kroah-Hartman --- security/selinux/ss/policydb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/security/selinux/ss/policydb.c +++ b/security/selinux/ss/policydb.c @@ -732,7 +732,8 @@ static int sens_destroy(void *key, void kfree(key); if (datum) { levdatum = datum; - ebitmap_destroy(&levdatum->level->cat); + if (levdatum->level) + ebitmap_destroy(&levdatum->level->cat); kfree(levdatum->level); } kfree(datum);