This is a note to let you know that I've just added the patch titled ipv4: accept u8 in IP_TOS ancillary data to the 4.4-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: ipv4-accept-u8-in-ip_tos-ancillary-data.patch and it can be found in the queue-4.4 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From e895cdce683161081e3626c4f5a5c55cb72089f8 Mon Sep 17 00:00:00 2001 From: Eric Dumazet <edumazet@xxxxxxxxxx> Date: Wed, 7 Sep 2016 21:52:56 -0700 Subject: ipv4: accept u8 in IP_TOS ancillary data From: Eric Dumazet <edumazet@xxxxxxxxxx> commit e895cdce683161081e3626c4f5a5c55cb72089f8 upstream. In commit f02db315b8d8 ("ipv4: IP_TOS and IP_TTL can be specified as ancillary data") Francesco added IP_TOS values specified as integer. However, kernel sends to userspace (at recvmsg() time) an IP_TOS value in a single byte, when IP_RECVTOS is set on the socket. It can be very useful to reflect all ancillary options as given by the kernel in a subsequent sendmsg(), instead of aborting the sendmsg() with EINVAL after Francesco patch. So this patch extends IP_TOS ancillary to accept an u8, so that an UDP server can simply reuse same ancillary block without having to mangle it. Jesper can then augment https://github.com/netoptimizer/network-testing/blob/master/src/udp_example02.c to add TOS reflection ;) Fixes: f02db315b8d8 ("ipv4: IP_TOS and IP_TTL can be specified as ancillary data") Signed-off-by: Eric Dumazet <edumazet@xxxxxxxxxx> Cc: Francesco Fusco <ffusco@xxxxxxxxxx> Cc: Jesper Dangaard Brouer <brouer@xxxxxxxxxx> Acked-by: Jesper Dangaard Brouer <brouer@xxxxxxxxxx> Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- net/ipv4/ip_sockglue.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -279,9 +279,12 @@ int ip_cmsg_send(struct net *net, struct ipc->ttl = val; break; case IP_TOS: - if (cmsg->cmsg_len != CMSG_LEN(sizeof(int))) + if (cmsg->cmsg_len == CMSG_LEN(sizeof(int))) + val = *(int *)CMSG_DATA(cmsg); + else if (cmsg->cmsg_len == CMSG_LEN(sizeof(u8))) + val = *(u8 *)CMSG_DATA(cmsg); + else return -EINVAL; - val = *(int *)CMSG_DATA(cmsg); if (val < 0 || val > 255) return -EINVAL; ipc->tos = val; Patches currently in stable-queue which might be from edumazet@xxxxxxxxxx are queue-4.4/bonding-prevent-out-of-bound-accesses.patch queue-4.4/ipv4-do-not-abuse-gfp_atomic-in-inet_netconf_notify_devconf.patch queue-4.4/net-get-rid-of-an-signed-integer-overflow-in-ip_idents_reserve.patch queue-4.4/ipv4-accept-u8-in-ip_tos-ancillary-data.patch queue-4.4/ipv6-do-not-abuse-gfp_atomic-in-inet6_netconf_notify_devconf.patch queue-4.4/udp-restore-udplite-many-cast-delivery.patch queue-4.4/ipv4-fix-memory-leak-in-exception-case-for-splitting-tries.patch queue-4.4/tcp-do-not-set-rtt_min-to-1.patch