From: Kees Cook <kees@kernel.org>
To: Jakub Kicinski <kuba@kernel.org>
Cc: Kees Cook <kees@kernel.org>, James Chapman <jchapman@katalix.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
netdev@vger.kernel.org, Kuniyuki Iwashima <kuniyu@google.com>,
Willem de Bruijn <willemb@google.com>
Subject: [PATCH 2/6 net-next] net/l2tp: Add missing sa_family validation in pppol2tp_sockaddr_get_info
Date: Wed, 23 Jul 2025 16:19:09 -0700 [thread overview]
Message-ID: <20250723231921.2293685-2-kees@kernel.org> (raw)
In-Reply-To: <20250723230354.work.571-kees@kernel.org>
While reviewing the struct proto_ops connect() and bind() callback
implementations, I noticed that there doesn't appear to be any
validation that AF_PPPOX sockaddr structures actually have sa_family set
to AF_PPPOX. The pppol2tp_sockaddr_get_info() checks only look at the
sizes.
I don't see any way that this might actually cause problems as specific
info fields are being populated, for which the existing size checks are
correct, but it stood out as a missing address family check.
Add the check and return -EAFNOSUPPORT on mismatch.
Signed-off-by: Kees Cook <kees@kernel.org>
---
Cc: James Chapman <jchapman@katalix.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Simon Horman <horms@kernel.org>
Cc: <netdev@vger.kernel.org>
---
net/l2tp/l2tp_ppp.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c
index fc5c2fd8f34c..767b393cbb78 100644
--- a/net/l2tp/l2tp_ppp.c
+++ b/net/l2tp/l2tp_ppp.c
@@ -545,6 +545,13 @@ struct l2tp_connect_info {
static int pppol2tp_sockaddr_get_info(const void *sa, int sa_len,
struct l2tp_connect_info *info)
{
+ const struct sockaddr_unspec *sockaddr = sa;
+
+ if (sa_len < offsetofend(struct sockaddr, sa_family))
+ return -EINVAL;
+ if (sockaddr->sa_family != AF_PPPOX)
+ return -EAFNOSUPPORT;
+
switch (sa_len) {
case sizeof(struct sockaddr_pppol2tp):
{
--
2.34.1
next prev parent reply other threads:[~2025-07-23 23:19 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-23 23:19 [PATCH 0/6 net-next] net: Introduce struct sockaddr_unspec Kees Cook
2025-07-23 23:19 ` [PATCH 1/6 net-next] net: uapi: Add __kernel_sockaddr_unspec for sockaddr of unknown length Kees Cook
2025-07-24 21:40 ` Jakub Kicinski
2025-07-24 22:28 ` Kees Cook
2025-07-23 23:19 ` Kees Cook [this message]
2025-07-23 23:19 ` [PATCH 3/6 net-next] net: Convert proto_ops bind() callbacks to use sockaddr_unspec Kees Cook
2025-07-24 11:29 ` kernel test robot
2025-07-24 13:31 ` Kees Cook
2025-07-24 13:02 ` kernel test robot
2025-07-23 23:19 ` [PATCH 4/6 net-next] net: Convert proto_ops connect() " Kees Cook
2025-07-24 12:00 ` kernel test robot
2025-07-23 23:19 ` [PATCH 5/6 net-next] net: Remove struct sockaddr from net.h Kees Cook
2025-07-23 23:19 ` [PATCH 6/6 net-next] net: Convert proto callbacks from sockaddr to sockaddr_unspec 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=20250723231921.2293685-2-kees@kernel.org \
--to=kees@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jchapman@katalix.com \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=willemb@google.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.