From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0CD55C83F1A for ; Mon, 28 Aug 2023 10:49:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232090AbjH1KtH (ORCPT ); Mon, 28 Aug 2023 06:49:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232178AbjH1Ksu (ORCPT ); Mon, 28 Aug 2023 06:48:50 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2B59B9 for ; Mon, 28 Aug 2023 03:48:40 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 83B64642C0 for ; Mon, 28 Aug 2023 10:48:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 934C0C433C8; Mon, 28 Aug 2023 10:48:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1693219719; bh=iPq+HiMXNaRWCzNX/MoaHghAp+eSbAsv/IFbAx/7aYU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=djrjNnClpBvyoBlhnY1HM5+jC4jNDOuCqz76CHpE+/PoMubonf9+/ohNJXvsgtBX1 xEzjrFPQbvKfuJFdkdRssfIHja/8ZuglkD3ihWRgay+pWx/LBBj3iJtjr1pdqWGFmm 8rpKHmC9ftn3cNvHAe8ca/ZoOz8IAGmVd5+yCeIE= 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.10 48/84] selinux: set next pointer before attaching to list Date: Mon, 28 Aug 2023 12:14:05 +0200 Message-ID: <20230828101150.904799944@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230828101149.146126827@linuxfoundation.org> References: <20230828101149.146126827@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 5.10-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; }