Skip to content

Commit beafc54

Browse files
keesKernel Patches Daemon
authored andcommitted
net/l2tp: Add missing sa_family validation in pppol2tp_sockaddr_get_info
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 <[email protected]>
1 parent 1c2cd38 commit beafc54

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

net/l2tp/l2tp_ppp.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,13 @@ struct l2tp_connect_info {
535535
static int pppol2tp_sockaddr_get_info(const void *sa, int sa_len,
536536
struct l2tp_connect_info *info)
537537
{
538+
const struct sockaddr_unspec *sockaddr = sa;
539+
540+
if (sa_len < offsetofend(struct sockaddr, sa_family))
541+
return -EINVAL;
542+
if (sockaddr->sa_family != AF_PPPOX)
543+
return -EAFNOSUPPORT;
544+
538545
switch (sa_len) {
539546
case sizeof(struct sockaddr_pppol2tp):
540547
{

0 commit comments

Comments
 (0)