]> git.baikalelectronics.ru Git - kernel.git/commit
mac80211: fix radiotap header generation
authorJohannes Berg <johannes.berg@intel.com>
Tue, 9 Nov 2021 09:02:04 +0000 (10:02 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 15 Nov 2021 09:55:20 +0000 (10:55 +0100)
commitc3e0486f68aa11439360deca01e0d3b62b248a84
tree7c7ec98b2093bfd48076c50feb64ebae59e8b81d
parent1456a5c1ad8bd4fa8bb17828541f5a7d0897dbcd
mac80211: fix radiotap header generation

In commit a02b365d630f ("mac80211: Use flex-array for radiotap header
bitmap") we accidentally pointed the position to the wrong place, so
we overwrite a present bitmap, and thus cause all kinds of trouble.

To see the issue, note that the previous code read:

  pos = (void *)(it_present + 1);

The requirement now is that we need to calculate pos via it_optional,
to not trigger the compiler hardening checks, as:

  pos = (void *)&rthdr->it_optional[...];

Rewriting the original expression, we get (obviously, since that just
adds "+ x - x" terms):

  pos = (void *)(it_present + 1 + rthdr->it_optional - rthdr->it_optional)

and moving the "+ rthdr->it_optional" outside to be used as an array:

  pos = (void *)&rthdr->it_optional[it_present + 1 - rthdr->it_optional];

The original is off by one, fix it.

Cc: stable@vger.kernel.org
Fixes: a02b365d630f ("mac80211: Use flex-array for radiotap header bitmap")
Reported-by: Sid Hayn <sidhayn@gmail.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Tested-by: Sid Hayn <sidhayn@gmail.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20211109100203.c61007433ed6.I1dade57aba7de9c4f48d68249adbae62636fd98c@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/rx.c