hselasky 94dc322ef6 Fix panic in network stack due to use after free when receiving
partial fragmented packets before a network interface is detached.

When sending IPv4 or IPv6 fragmented packets and a fragment is lost
before the network device is freed, the mbuf making up the fragment
will remain in the temporary hashed fragment list and cause a panic
when it times out due to accessing a freed network interface
structure.


1) Make sure the m_pkthdr.rcvif always points to a valid network
interface. Else the rcvif field should be set to NULL.

2) Use the rcvif of the last received fragment as m_pkthdr.rcvif for
the fully defragged packet, instead of the first received fragment.

Panic backtrace for IPv6:

panic()
icmp6_reflect() # tries to access rcvif->if_afdata[AF_INET6]->xxx
icmp6_error()
frag6_freef()
frag6_slowtimo()
pfslowtimo()
softclock_call_cc()
softclock()
ithread_loop()

Reviewed by:	bz
Differential Revision:	https://reviews.freebsd.org/D19622
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2019-10-16 09:11:49 +00:00
..
2019-10-07 22:40:05 +00:00
2019-10-07 22:40:05 +00:00
2019-08-02 07:41:36 +00:00
2019-08-02 07:41:36 +00:00
2019-08-02 07:41:36 +00:00
2019-10-07 22:40:05 +00:00
2019-10-07 22:40:05 +00:00
2019-10-07 22:40:05 +00:00
2019-10-07 22:40:05 +00:00
2019-10-13 09:35:03 +00:00