Commit Graph

393 Commits

Author SHA1 Message Date
maxv
f412fe9bd5 Improve an XXX of mine, and fix one stat. 2018-04-10 07:53:36 +00:00
maxv
6cbd9d0315 Switch sp_timoff to u_int16_t, to prevent possible overflow in
ieee80211_recv_mgmt_beacon(). Actually this field is unused.
2018-01-21 14:18:21 +00:00
maxv
03cb445009 Appease the overflow check, 4 is enough. 2018-01-21 14:13:49 +00:00
maxv
64b112643a Style, no functional change. 2018-01-19 07:58:25 +00:00
maxv
5b9905a59d Style, and check the return value of m_append. 2018-01-19 07:57:50 +00:00
maxv
5e3a8040f2 Style, no functional change. 2018-01-19 07:53:46 +00:00
maxv
fd8bca6477 Style, and make sure that there is a header+trailer included in the
packet. The crypto functions can touch the trailer, but they don't check
whether it's there in the first place.
2018-01-19 07:52:37 +00:00
maxv
c153ca3cd5 Style, no functional change. 2018-01-18 17:59:29 +00:00
maxv
f43b144132 Style, and zero out 'ns' entirely, otherwise some bytes get leaked to
userland (eg ns_rsvd0).
2018-01-18 17:57:49 +00:00
maxv
b37f61bc9b Several changes:
* Make the code more readable.

 * Add a panic in ieee80211_compute_duration(). I'm not sure there's
   a bug here - I don't have the hardware -, but looking at the code, it
   may be possible for 'paylen' to go negative. Obviously that's not the
   correct way to fix it, but at least we'll see if it happens.
2018-01-18 16:23:43 +00:00
maxv
4d4ed9988c Several changes:
* Make the code more readable. In particular, declare variables as const
   along the way.

 * Explain what we're doing in ieee80211_send_mgmt(). The
   IEEE80211_FC0_SUBTYPE_PROBE_RESP case has some inconsistencies, but
   they are not inherently wrong so I'm not changing that.

 * When sending IEEE80211_FC0_SUBTYPE_REASSOC_RESP frames, make sure to
   zero out the 'association ID', otherwise two bytes are leaked.

 * Fix a possible memory leak in ieee80211_send_probereq().
2018-01-18 13:24:01 +00:00
maxv
d89ae4bbdd Style, and fix two pretty bad mistakes in the crypto functions:
* They call M_PREPEND, but don't pass the updated pointer back to the
   caller.

 * They use memmove on the mbuf data, but they don't ensure that the
   area they touch is contiguous.

This fix is not complete, ieee80211_crypto_encap too needs to pass back
the updated pointer. This will be done in another commit.
2018-01-17 17:41:38 +00:00
maxv
a45976c272 Several changes:
* Style in several places, to make the code more readable or easier to
   understand.

 * Instead of checking m->m_pkthdr.len, check m->m_len. m_pkthdr.len is
   the total size of the packet, not the size of the current mbuf (which
   may be smaller).

 * Add a missing length check when handling QoS frames.

 * Cast the lengths passed in IEEE80211_VERIFY_LENGTH to size_t.

 * Remove the length check on scan.sp_xrates, that I added yesterday.
   xrates gets silently truncated in ieee80211_setup_rates().

 * Fix several buffer overflows in the parsers of the MANAGEMENT frames.
2018-01-17 16:03:16 +00:00
maxv
11a42b5c1a Various fixes: style, remove tiring XXXs, and prevent integer overflow in
ieee80211_setup_rates (normally it already can't happen, because I added a
length check on xrates in ieee80211_recv_mgmt_beacon).
2018-01-16 18:53:32 +00:00
maxv
1df75eef54 Prepend 'sp_' to the name of the fields, so that they can easily be found
via NXR or grep.
2018-01-16 18:42:43 +00:00
maxv
3b005d6b1f Add comments about the length checks, and check xrates. 2018-01-16 16:54:54 +00:00
maxv
1551d983f8 Gather related code. 2018-01-16 16:31:37 +00:00
maxv
0170309ae1 Style on the new functions. 2018-01-16 16:20:57 +00:00
maxv
82e96ed75b Introduce ieee80211_recv_mgmt_disassoc. 2018-01-16 16:09:30 +00:00
maxv
e51554e17b Introduce ieee80211_recv_mgmt_deauth. 2018-01-16 16:04:16 +00:00
maxv
24023c750d Introduce ieee80211_recv_mgmt_assoc_resp. 2018-01-16 16:00:17 +00:00
maxv
6d9e139ff1 Introduce ieee80211_recv_mgmt_assoc_req. 2018-01-16 15:55:14 +00:00
maxv
f940273b30 Introduce ieee80211_recv_mgmt_auth. 2018-01-16 15:48:32 +00:00
maxv
85acfa9c16 Start splitting ieee80211_recv_mgmt. 2018-01-16 15:42:52 +00:00
maxv
e54b750f47 More overflows... 2018-01-16 15:18:37 +00:00
maxv
24fb50b383 Fix overflow. 2018-01-16 14:37:24 +00:00
maxv
bea24f0ecf Fix memory leak. If m1 == m, m = NULL, so it's safe to just call m_freem. 2018-01-16 14:01:13 +00:00
maxv
01f382e322 Style, remove pointless XXXs, and add a comment about LLC. 2018-01-16 09:42:11 +00:00
maxv
6cfd170308 Update the mbuf pointer when m_pullup succeeds, I forgot this in my last
revision (I only fixed the UAF in one branch). Meanwhile, style.
2018-01-16 09:04:30 +00:00
maxv
1151dedd75 Split ieee80211_input into three sub-functions, that parse received
packets depending on their type:

	DATA       -> ieee80211_input_data
	MANAGEMENT -> ieee80211_input_management
	CONTROL    -> ieee80211_input_control

No real functional change, but makes the code much clearer.
2018-01-16 08:39:29 +00:00
maxv
6d2a143a1f Start cleaning up this mess. 2018-01-16 07:53:02 +00:00
maxv
0b0687d87e Fix use-after-free: ieee80211_crypto_decap does a pullup on the mbuf but
the updated pointer is not passed back. Looks like it is triggerable
remotely.
2017-12-10 08:56:23 +00:00
maxv
e63bca16c2 Update the pointer after m_pullup, otherwise possible use-after-free. 2017-12-10 08:48:15 +00:00
knakahara
a6e88d7809 VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.
I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html

XXX need pullup to -8 branch
2017-09-26 07:42:05 +00:00
ozaki-r
edaa29b022 Fix incrementing wrong counter 2017-03-06 08:36:20 +00:00
nonaka
5ffb0503f3 wlan interfaces make interrupt routine running on softint context.
see http://mail-index.netbsd.org/tech-kern/2016/12/06/msg021281.html

tested device:
 * ath at pci: AR5212, AR5424
 * athn at pci: AR9287
 * ipw at pci: 2100BG
 * iwi at pci: 2915ABG
 * iwm at pci: 3165, 7260, 8260
 * iwn at pci: 4945, 6235
 * ral at pci: RT2560
 * rtwn at pci: RTL8192CE
2017-02-02 10:05:35 +00:00
maya
fe2925feed appease coverity by using strlcpy instead of strncpy
ok riastradh
2017-01-14 16:34:44 +00:00
nonaka
08620666eb Export some 802.11 IE manipulate functions. 2017-01-04 03:05:24 +00:00
ozaki-r
dd8638eea5 Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input
The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
  - Where/When if_ipackets is counted up
  - Note that some drivers still update packet statistics in their own
    way (periodical update)
- Moved bpf_mtap run in softint
  - This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net
2016-12-15 09:28:02 +00:00
christos
9015c01fa3 PR/51540: Henning Petersen: replace , with ; 2016-10-09 14:49:51 +00:00
christos
c2ec58382b - use ether_snprintf() so that we don't overwrite our buffer for printing
ethernet-like addresses
- make this compile againw without IEEE80211_DEBUG.
2016-09-27 20:20:06 +00:00
mlelstv
faca41fb2b Merge enough FreeBSD code to make RT5592 work. 2016-09-16 09:25:30 +00:00
msaitoh
8bc54e5be6 KNF. Remove extra spaces. No functional change. 2016-07-07 06:55:38 +00:00
ozaki-r
bdb88f5405 Get rid of invalid KASSERT
The mbuf being checked is allocated in ieee80211_getmgtframe just above,
so checking NULL of its CTX is meaningless.

Pointed out by mlelstv@
2016-06-20 08:57:18 +00:00
knakahara
69c0ff04b9 apply if_start_lock() to L2 callers which call ifp->if_start() of device derivers 2016-06-20 08:30:58 +00:00
ozaki-r
cef59834c4 Use M_GETCTX and M_SETCTX instead of open-coding rcvif
No functional change.
2016-05-16 09:53:59 +00:00
mlelstv
f3c013cf09 In station mode filter packets that or not for us in case the
interface is in promiscous mode or doesn't filter packets itself.
2016-05-14 13:35:40 +00:00
mlelstv
28f11d6152 Don't check sequence number on multicast packets in station mode.
Handle overflow of 12bit sequence number.
2016-05-07 12:36:50 +00:00
christos
7da1320f48 Add 80211n ht frame. 2016-04-27 20:17:00 +00:00
knakahara
b76ec0b083 IFQ_ENQUEUE refactor (3/3) : eliminate pktattr argument from IFQ_ENQUEUE caller 2016-04-20 09:01:03 +00:00