From: Simon Horman <horms@kernel.org>
To: kees@kernel.org
Cc: Simon Horman <horms@kernel.org>,
kuba@kernel.org,
syzbot+628f93722c08dc5aabe0@syzkaller.appspotmail.com,
davem@davemloft.net, edumazet@google.com, pabeni@redhat.com,
luoxuanqiang@kylinos.cn, tim.bird@sony.com, zihanx@nebusec.ai,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
linux-hardening@vger.kernel.org
Subject: Re: [PATCH net-next 3/3] llc: add KUnit tests for the connection state machine bounds
Date: Sat, 5 Sep 2026 16:58:01 +0100 [thread overview]
Message-ID: <20260905155801.110741-1-horms@kernel.org> (raw)
In-Reply-To: <20260901210308.1173180-3-kees@kernel.org>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
Full review at: https://sashiko.dev/#/patchset/20260901210308.1173180-3-kees@kernel.org?part=3
---
llc: add KUnit tests for the connection state machine bounds
This commit adds a KUnit test suite for the LLC type 2 connection state
machine. It introduces regression tests for state transitions and array
indexing invariants.
> diff --git a/net/llc/tests/conn_kunit.c b/net/llc/tests/conn_kunit.c
> new file mode 100644
> index 0000000000000..86d3f122df0a6
> --- /dev/null
> +++ b/net/llc/tests/conn_kunit.c
> @@ -0,0 +1,146 @@
[ ... ]
> +static struct sk_buff *llc_conn_test_rx_pdu(struct kunit *test, struct sock *sk)
> +{
> + struct llc_conn_state_ev *ev;
> + struct llc_pdu_sn *pdu;
> + struct sk_buff *skb;
> +
> + skb = alloc_skb(sizeof(*pdu), GFP_KERNEL);
> + KUNIT_ASSERT_NOT_NULL(test, skb);
[Severity: Medium]
Will this leak unmanaged resources if the assertion fails?
If alloc_skb() fails, KUNIT_ASSERT_NOT_NULL() terminates the test case
abruptly. Any previously allocated resources that are not registered with
KUnit's cleanup mechanism (like kunit_add_action()) will bypass their
manual cleanup routines.
[ ... ]
> +static void llc_conn_state_process_out_of_svc(struct kunit *test)
> +{
> + struct sk_buff *first, *second;
> + struct socket *sock;
> + struct sock *sk;
> +
> + sock = llc_conn_test_socket(test);
> + sk = sock->sk;
> +
> + first = llc_conn_test_rx_pdu(test, sk);
> + second = llc_conn_test_rx_pdu(test, sk);
[Severity: Medium]
For instance, if the second call to llc_conn_test_rx_pdu() triggers an
assertion failure, does this code leak the socket and the first sk_buff?
The sock is allocated in llc_conn_test_socket(), and the first sk_buff is
allocated just above. Because KUNIT_ASSERT_NOT_NULL() causes an immediate
abort on failure, the execution would skip the sock_release(sock) call at the
end of this function, permanently leaking both the socket and the sk_buff.
> +
> + lock_sock(sk);
> + KUNIT_EXPECT_EQ(test, llc_sk(sk)->state, LLC_CONN_STATE_ADM);
prev parent reply other threads:[~2026-09-05 15:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 21:03 [PATCH net-next 0/3] llc: do not run the state machine on out of service connections Kees Cook
2026-09-01 21:03 ` [PATCH net-next 1/3] " Kees Cook
2026-09-05 19:28 ` Jakub Kicinski
2026-09-01 21:03 ` [PATCH net-next 2/3] llc: report a closed connection for out of service sockets Kees Cook
2026-09-01 21:03 ` [PATCH net-next 3/3] llc: add KUnit tests for the connection state machine bounds Kees Cook
2026-09-05 15:58 ` Simon Horman [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260905155801.110741-1-horms@kernel.org \
--to=horms@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kees@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luoxuanqiang@kylinos.cn \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=syzbot+628f93722c08dc5aabe0@syzkaller.appspotmail.com \
--cc=tim.bird@sony.com \
--cc=zihanx@nebusec.ai \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®