From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1380E8BE0 for ; Mon, 28 Aug 2023 10:46:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 861A8C433C8; Mon, 28 Aug 2023 10:46:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1693219567; bh=2+wVQE+/kwQWBtEUGDRcxhs75ibXaVUSPBpH1IJVGkI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w4mhA9+P3z57lC5HLH3dNPMAfgSuOZjL15+Huy+PHwV65Cmmf9MB7JzJYAkMYEVW+ kMui+KyHZj3aGzjItstXvG999y4ofpqWNkmywcyVZ6dqexwXKXw3nNrsm8FvHzFAJK njx4oBD2kqGbZlSJV/JiwhGKf42b/nj8NKHjV5n4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, =?UTF-8?q?Christian=20G=C3=B6ttsche?= , Paul Moore Subject: [PATCH 5.15 54/89] selinux: set next pointer before attaching to list Date: Mon, 28 Aug 2023 12:13:55 +0200 Message-ID: <20230828101151.985548515@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230828101150.163430842@linuxfoundation.org> References: <20230828101150.163430842@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Christian Göttsche commit 70d91dc9b2ac91327d0eefd86163abc3548effa6 upstream. Set the next pointer in filename_trans_read_helper() before attaching the new node under construction to the list, otherwise garbage would be dereferenced on subsequent failure during cleanup in the out goto label. Cc: Fixes: 430059024389 ("selinux: implement new format of filename transitions") Signed-off-by: Christian Göttsche Signed-off-by: Paul Moore Signed-off-by: Greg Kroah-Hartman --- security/selinux/ss/policydb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/security/selinux/ss/policydb.c +++ b/security/selinux/ss/policydb.c @@ -2011,6 +2011,7 @@ static int filename_trans_read_helper(st if (!datum) goto out; + datum->next = NULL; *dst = datum; /* ebitmap_read() will at least init the bitmap */ @@ -2023,7 +2024,6 @@ static int filename_trans_read_helper(st goto out; datum->otype = le32_to_cpu(buf[0]); - datum->next = NULL; dst = &datum->next; }