net80211: fix a race between ieee80211_sta_join and scan entries
We were seeing panics during ieee80211_sta_join() which seemed that
the ni->ni_chan was not valid anymore, which was true.
We also saw errors indicating data put into ni_ies became inalid.
The problem was that the ieee80211_scan_entry passed into
ieee80211_sta_join() (in the observed case from setmlme_assoc_sta())
became invalid during ieee80211_alloc_node().
As a result for the ni_chan case the the rateset and len in rates[1]
became invalid. Similarly for the IEs.
Make a (deep)copy of the scan entry in setmlme_assoc_sta() and return
the copy as once we leave ieee80211_scan_iterate() we can no longer
rely on the scan entry to be valid.
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reported by: rm, ziaee, bz
Tested by: rm, ziaee, bz
PR: 286063
Reviewed by: adrian (,emaste)
Differential Revision: https://reviews.freebsd.org/D49865