From: Kees Cook <kees@kernel.org>
To: Jakub Kicinski <kuba@kernel.org>
Cc: Kees Cook <kees@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
Xuanqiang Luo <luoxuanqiang@kylinos.cn>,
Tim Bird <tim.bird@sony.com>, Zihan Xi <zihanx@nebusec.ai>,
linux-kernel@vger.kernel.org,
syzbot+628f93722c08dc5aabe0@syzkaller.appspotmail.com,
netdev@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: [PATCH net-next 0/3] llc: do not run the state machine on out of service connections
Date: Tue, 1 Sep 2026 14:03:02 -0700 [thread overview]
Message-ID: <20260901210300.i.590-kees@kernel.org> (raw)
Hi,
syzbot found a KASAN/UBSAN out of bounds report in the LLC connection
state machine, and has now bisected a reproducer for it:
https://lore.kernel.org/all/6a95888b.4d659fcc.734b4.0051.GAE@google.com
BUG: KASAN: global-out-of-bounds in llc_qualify_conn_ev net/llc/llc_conn.c:394
The buggy address belongs to the variable:
llc_temp_state_transitions+0x58/0x60
UBSAN: array-index-out-of-bounds in net/llc/llc_conn.c:681:8
index -1 is out of range for type 'int[12][5]'
llc_conn_state_table[] and llc_offset_table[] are indexed with
"llc->state - 1" because connection states are 1-based, and
LLC_CONN_OUT_OF_SVC is 0, so a connection in that pseudo state indexes
both tables with -1.
Add bounds checking, regularize connect(2) errno, and add KUnit tests
for it all. See the respective patches for way more details. :)
While I did build testing and convinced myself that the KUnit tests
(which pass only with the fixes applied) are sensible, I would like
more eyes on these changes, as I'm not entirely sure the best way to
test them in the real world.
Note that this collides with proposed patch[1] which also noted we
needed to do better sanity checking of llc->state in llc_conn_service().
Since this check is needed in llc_conn_state_process() as well, I made
it a common function and did other work of keeping the sizes of things
double-checked with static asserts.
-Kees
[1] https://lore.kernel.org/all/8fa3c9e6d5dcf328979ed2bdc27817c11a5eff91.1787752861.git.zihanx@nebusec.ai/
Kees Cook (3):
llc: do not run the state machine on out of service connections
llc: report a closed connection for out of service sockets
llc: add KUnit tests for the connection state machine bounds
net/llc/Kconfig | 14 ++++
include/net/llc_c_st.h | 2 +-
net/llc/llc_conn.c | 42 ++++++++++-
net/llc/llc_if.c | 12 ++-
net/llc/tests/conn_kunit.c | 146 +++++++++++++++++++++++++++++++++++++
5 files changed, 213 insertions(+), 3 deletions(-)
create mode 100644 net/llc/tests/conn_kunit.c
--
2.34.1
next reply other threads:[~2026-09-01 21:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 21:03 Kees Cook [this message]
2026-09-01 21:03 ` [PATCH net-next 1/3] llc: do not run the state machine on out of service connections Kees Cook
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
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=20260901210300.i.590-kees@kernel.org \
--to=kees@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@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