This is a note to let you know that I've just added the patch titled sctp: sctp_sock_filter(): avoid list_entry() on possibly empty list to the 6.1-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: sctp-sctp_sock_filter-avoid-list_entry-on-possibly-empty-list.patch and it can be found in the queue-6.1 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From a1221703a0f75a9d81748c516457e0fc76951496 Mon Sep 17 00:00:00 2001 From: Pietro Borrello <borrello@xxxxxxxxxxxxxxxx> Date: Thu, 9 Feb 2023 12:13:05 +0000 Subject: sctp: sctp_sock_filter(): avoid list_entry() on possibly empty list From: Pietro Borrello <borrello@xxxxxxxxxxxxxxxx> commit a1221703a0f75a9d81748c516457e0fc76951496 upstream. Use list_is_first() to check whether tsp->asoc matches the first element of ep->asocs, as the list is not guaranteed to have an entry. Fixes: 8f840e47f190 ("sctp: add the sctp_diag.c file") Signed-off-by: Pietro Borrello <borrello@xxxxxxxxxxxxxxxx> Acked-by: Xin Long <lucien.xin@xxxxxxxxx> Link: https://lore.kernel.org/r/20230208-sctp-filter-v2-1-6e1f4017f326@xxxxxxxxxxxxxxxx Signed-off-by: Jakub Kicinski <kuba@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- net/sctp/diag.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) --- a/net/sctp/diag.c +++ b/net/sctp/diag.c @@ -343,11 +343,9 @@ static int sctp_sock_filter(struct sctp_ struct sctp_comm_param *commp = p; struct sock *sk = ep->base.sk; const struct inet_diag_req_v2 *r = commp->r; - struct sctp_association *assoc = - list_entry(ep->asocs.next, struct sctp_association, asocs); /* find the ep only once through the transports by this condition */ - if (tsp->asoc != assoc) + if (!list_is_first(&tsp->asoc->asocs, &ep->asocs)) return 0; if (r->sdiag_family != AF_UNSPEC && sk->sk_family != r->sdiag_family) Patches currently in stable-queue which might be from borrello@xxxxxxxxxxxxxxxx are queue-6.1/sctp-sctp_sock_filter-avoid-list_entry-on-possibly-empty-list.patch