Skip to contentSkip to conversation

Patch "net/packet: check length in getsockopt() called with PACKET_HDRLEN" has been added to the 3.18-stable tree

PATCH [email protected] 1 participant 1 message Oct 5, 2017

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

net/packet: check length in getsockopt() called with PACKET_HDRLEN

to the 3.18-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:
net-packet-check-length-in-getsockopt-called-with-packet_hdrlen.patch
and it can be found in the queue-3.18 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From foo@baz Thu Oct 5 10:58:04 CEST 2017

From: Alexander Potapenko <[email protected]>
Date: Tue, 25 Apr 2017 18:51:46 +0200
Subject: net/packet: check length in getsockopt() called with PACKET_HDRLEN

From: Alexander Potapenko <[email protected]>

[ Upstream commit fd2c83b35752f0a8236b976978ad4658df14a59f ]

In the case getsockopt() is called with PACKET_HDRLEN and optlen < 4 |val| remains uninitialized and the syscall may behave differently depending on its value, and even copy garbage to userspace on certain architectures. To fix this we now return -EINVAL if optlen is too small.

This bug has been detected with KMSAN.

---
 net/packet/af_packet.c |    2 ++
 1 file changed, 2 insertions(+)
net/packet/af_packet.c +2 -0
@@ -3482,6 +3482,8 @@ static int packet_getsockopt(struct sock
 	case PACKET_HDRLEN:
 		if (len > sizeof(int))
 			len = sizeof(int);
+		if (len < sizeof(int))
+			return -EINVAL;
 		if (copy_from_user(&val, optval, len))
 			return -EFAULT;
 		switch (val) {

Patches currently in stable-queue which might be from [email protected] are

queue-3.18/net-packet-check-length-in-getsockopt-called-with-packet_hdrlen.patch