Skip to content

Commit

Permalink
selinux: set next pointer before attaching to list
Browse files Browse the repository at this point in the history
commit 70d91dc 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: <stable@vger.kernel.org>
Fixes: 4300590 ("selinux: implement new format of filename transitions")
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
cgzones authored and gregkh committed Aug 30, 2023
1 parent 14fa028 commit 21cd994
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion security/selinux/ss/policydb.c
Original file line number Diff line number Diff line change
Expand Up @@ -2005,6 +2005,7 @@ static int filename_trans_read_helper(struct policydb *p, void *fp)
if (!datum)
goto out;

datum->next = NULL;
*dst = datum;

/* ebitmap_read() will at least init the bitmap */
Expand All @@ -2017,7 +2018,6 @@ static int filename_trans_read_helper(struct policydb *p, void *fp)
goto out;

datum->otype = le32_to_cpu(buf[0]);
datum->next = NULL;

dst = &datum->next;
}
Expand Down

0 comments on commit 21cd994

Please sign in to comment.