tcp repair: Fix unaligned access when repairing options
Subsystems (3)
PATCH 1/1 tcp repair: Fix unaligned access when repairing options
Don't pick __u8/__u16 values directly from raw pointers, but instead use an array of structures of code:value pairs. This is OK, since the buffer we take options from is not an skb memory, but a user-to-kernel one.
For those options which don't require any value now, require this to be zero (for potential future extension of this API).
--- include/linux/tcp.h | 5 ++++ net/ipv4/tcp.c | 60 +++++++++++++++++--------------------------------- 2 files changed, 26 insertions(+), 39 deletions(-)
include/linux/tcp.h +5 -0
@@ -111,6 +111,11 @@ enum {#define TCP_QUEUE_SEQ 21#define TCP_REPAIR_OPTIONS 22 +struct tcp_repair_opt { +__u8 opt_code; +__u16 opt_val; +}; +enum {TCP_NO_QUEUE ,TCP_RECV_QUEUE ,
net/ipv4/tcp.c +21 -39
88 lines not on this page · raw message
Signature · 1 line
1.5.5.6
include/linux/tcp.h enum { · line 117
Quoted 5 lines
include/linux/tcp.h +4
-0+struct tcp_repair_opt { +__u8 opt_code; +__u16 opt_val; +};
That structure has an implied pad field, probably best to either make it explicit or change the types.
I'd have thought it would do no harm to use two __u32 fields (unless you really need to save memory somewhere).
David
David Miller
maintainerFrom: "David Laight" <[email protected]>
Date: Wed, 25 Apr 2012 15:11:30 +0100
Quoted 8 lines
include/linux/tcp.h enum { · line 117
Quoted 5 lines
include/linux/tcp.h +4
-0+struct tcp_repair_opt { +__u8 opt_code; +__u16 opt_val; +};That structure has an implied pad field, probably best to either make it explicit or change the types.
Agreed.