Skip to content
Commit fdafed45 authored by Cong Wang's avatar Cong Wang Committed by Jakub Kicinski
Browse files

ip_gre: set dev->hard_header_len and dev->needed_headroom properly



GRE tunnel has its own header_ops, ipgre_header_ops, and sets it
conditionally. When it is set, it assumes the outer IP header is
already created before ipgre_xmit().

This is not true when we send packets through a raw packet socket,
where L2 headers are supposed to be constructed by user. Packet
socket calls dev_validate_header() to validate the header. But
GRE tunnel does not set dev->hard_header_len, so that check can
be simply bypassed, therefore uninit memory could be passed down
to ipgre_xmit(). Similar for dev->needed_headroom.

dev->hard_header_len is supposed to be the length of the header
created by dev->header_ops->create(), so it should be used whenever
header_ops is set, and dev->needed_headroom should be used when it
is not set.

Reported-and-tested-by: default avatar <syzbot+4a2c52677a8a1aa283cb@syzkaller.appspotmail.com>
Cc: William Tu <u9012063@gmail.com>
Acked-by: default avatarWillem de Bruijn <willemb@google.com>
Signed-off-by: default avatarCong Wang <xiyou.wangcong@gmail.com>
Acked-by: default avatarXie He <xie.he.0141@gmail.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 4e3bbb33
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment