net: Fix recvmmsg timeout handling

As reported by Elie de Brauwer the timeout handling in the recvmmsg
syscall had issues that boil down to it not properly passing the
remaining time to each underlying recvmsg() call.

Fix it by adding a timeout pointer to the recvmsg implementations, so
that it can use that in a variation of sock_rcvtimeo() that overrides
the value in SO_RCVTIMEO with the timeout passed and returns the
remaining time in that pointer, this way each underlying recvmsg call
receives the remaining time.

It ends up in most cases being just a forward of this pointer from the
per protocol recvmsg() implementations to skb_recv_datagram().

Reported-by: Elie De Brauwer <>
Reported-by: Michael Kerrisk <>
Tested-by: Michael Kerrisk <>
Cc: Caitlin Bestler <>
Cc: Chris Friesen <>
Cc: Elie De Brauwer <>
Cc: Michael Kerrisk <>
Cc: Neil Horman <>
Cc: Ondřej Bílka <>
Cc: Paul Moore <>
Cc: Rémi Denis-Courmont <>
Cc: Steven Whitehouse <>
Signed-off-by: Arnaldo Carvalho de Melo <>
73 files changed