1. 26 4月, 2019 1 次提交
    • G
      cfg80211: Use struct_size() in kzalloc() · 9f8c7136
      Gustavo A. R. Silva 提交于
      One of the more common cases of allocation size calculations is finding
      the size of a structure that has a zero-sized array at the end, along
      with memory for some number of elements for that array. For example:
      
      struct foo {
          int stuff;
          struct boo entry[];
      };
      
      size = sizeof(struct foo) + count * sizeof(struct boo);
      instance = kzalloc(size, GFP_KERNEL)
      
      Instead of leaving these open-coded and prone to type mistakes, we can
      now use the new struct_size() helper:
      
      instance = kzalloc(struct_size(instance, entry, count), GFP_KERNEL)
      
      Notice that, in this case, variable size_of_regd is not necessary,
      hence it is removed.
      
      This code was detected with the help of Coccinelle.
      Signed-off-by: NGustavo A. R. Silva <gustavo@embeddedor.com>
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      9f8c7136
  2. 11 2月, 2019 1 次提交
    • J
      cfg80211: restore regulatory without calling userspace · e646a025
      Johannes Berg 提交于
      Jouni reports that in some cases it is possible that getting
      disconnected (or stopping AP, after previous patches) results
      in further operations hitting the window within the regulatory
      core restoring the regdomain to the defaults. The reason for
      this is that we have to call out to CRDA or otherwise do some
      asynchronous work, and thus can't do the restore atomically.
      
      However, we've previously seen all the data we need to do the
      restore, so we can hang on to that data and use it later for
      the restore. This makes the whole thing happen within a single
      locked section and thus atomic.
      
      However, we can't *always* do this - there are unfortunately
      cases where the restore needs to re-request, because this is
      also used (abused?) as an error recovery process, so make the
      new behaviour optional and only use it when doing a regular
      restore as described above.
      Reported-by: NJouni Malinen <j@w1.fi>
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      e646a025
  3. 25 1月, 2019 3 次提交
  4. 02 10月, 2018 1 次提交
  5. 01 10月, 2018 1 次提交
    • Y
      cfg80211: fix use-after-free in reg_process_hint() · 1db58529
      Yu Zhao 提交于
      reg_process_hint_country_ie() can free regulatory_request and return
      REG_REQ_ALREADY_SET. We shouldn't use regulatory_request after it's
      called. KASAN error was observed when this happens.
      
      BUG: KASAN: use-after-free in reg_process_hint+0x839/0x8aa [cfg80211]
      Read of size 4 at addr ffff8800c430d434 by task kworker/1:3/89
      <snipped>
      Workqueue: events reg_todo [cfg80211]
      Call Trace:
       dump_stack+0xc1/0x10c
       ? _atomic_dec_and_lock+0x1ad/0x1ad
       ? _raw_spin_lock_irqsave+0xa0/0xd2
       print_address_description+0x86/0x26f
       ? reg_process_hint+0x839/0x8aa [cfg80211]
       kasan_report+0x241/0x29b
       reg_process_hint+0x839/0x8aa [cfg80211]
       reg_todo+0x204/0x5b9 [cfg80211]
       process_one_work+0x55f/0x8d0
       ? worker_detach_from_pool+0x1b5/0x1b5
       ? _raw_spin_unlock_irq+0x65/0xdd
       ? _raw_spin_unlock_irqrestore+0xf3/0xf3
       worker_thread+0x5dd/0x841
       ? kthread_parkme+0x1d/0x1d
       kthread+0x270/0x285
       ? pr_cont_work+0xe3/0xe3
       ? rcu_read_unlock_sched_notrace+0xca/0xca
       ret_from_fork+0x22/0x40
      
      Allocated by task 2718:
       set_track+0x63/0xfa
       __kmalloc+0x119/0x1ac
       regulatory_hint_country_ie+0x38/0x329 [cfg80211]
       __cfg80211_connect_result+0x854/0xadd [cfg80211]
       cfg80211_rx_assoc_resp+0x3bc/0x4f0 [cfg80211]
      smsc95xx v1.0.6
       ieee80211_sta_rx_queued_mgmt+0x1803/0x7ed5 [mac80211]
       ieee80211_iface_work+0x411/0x696 [mac80211]
       process_one_work+0x55f/0x8d0
       worker_thread+0x5dd/0x841
       kthread+0x270/0x285
       ret_from_fork+0x22/0x40
      
      Freed by task 89:
       set_track+0x63/0xfa
       kasan_slab_free+0x6a/0x87
       kfree+0xdc/0x470
       reg_process_hint+0x31e/0x8aa [cfg80211]
       reg_todo+0x204/0x5b9 [cfg80211]
       process_one_work+0x55f/0x8d0
       worker_thread+0x5dd/0x841
       kthread+0x270/0x285
       ret_from_fork+0x22/0x40
      <snipped>
      Signed-off-by: NYu Zhao <yuzhao@google.com>
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      1db58529
  6. 05 9月, 2018 2 次提交
  7. 28 8月, 2018 3 次提交
  8. 20 8月, 2018 1 次提交
  9. 24 7月, 2018 1 次提交
  10. 22 5月, 2018 1 次提交
  11. 18 5月, 2018 1 次提交
  12. 08 5月, 2018 1 次提交
    • A
      cfg80211: Call reg_notifier for self managed hints conditionally · aced43ce
      Amar Singhal 提交于
      Currently the regulatory core does not call the regulatory callback
      reg_notifier for self managed wiphys, but regulatory_hint_user() call is
      independent of wiphy and is meant for all wiphys in the system. Even a
      self managed wiphy may be interested in regulatory_hint_user() to know
      the country code from a trusted regulatory domain change like a cellular
      base station. Therefore, for the regulatory source
      NL80211_REGDOM_SET_BY_USER and the user hint type
      NL80211_USER_REG_HINT_CELL_BASE, call the regulatory notifier.
      
      No current wlan driver uses the REGULATORY_WIPHY_SELF_MANAGED flag while
      also registering the reg_notifier regulatory callback, therefore there
      will be no impact on existing drivers without them being explicitly
      modified to take advantage of this new possibility.
      Signed-off-by: NAmar Singhal <asinghal@codeaurora.org>
      Signed-off-by: NJouni Malinen <jouni@codeaurora.org>
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      aced43ce
  13. 19 4月, 2018 2 次提交
  14. 29 3月, 2018 3 次提交
  15. 15 1月, 2018 1 次提交
  16. 20 11月, 2017 1 次提交
    • J
      cfg80211: initialize regulatory keys/database later · d7be102f
      Johannes Berg 提交于
      When cfg80211 is built as a module, everything is fine, and we
      can keep the code as is; in fact, we have to, because there can
      only be a single module_init().
      
      When cfg80211 is built-in, however, it needs to initialize
      before drivers (device_initcall/module_init), and thus used to
      be at subsys_initcall(). I'd moved it to fs_initcall() earlier,
      where it can remain. However, this is still too early because at
      that point the key infrastructure hasn't been initialized yet,
      so X.509 certificates can't be parsed yet.
      
      To work around this problem, load the regdb keys only later in
      a late_initcall(), at which point the necessary infrastructure
      has been initialized.
      
      Fixes: 90a53e44 ("cfg80211: implement regdb signature checking")
      Reported-by: NXiaolong Ye <xiaolong.ye@intel.com>
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      d7be102f
  17. 13 10月, 2017 1 次提交
  18. 11 10月, 2017 4 次提交
    • J
      cfg80211: implement regdb signature checking · 90a53e44
      Johannes Berg 提交于
      Currently CRDA implements the signature checking, and the previous
      commits added the ability to load the whole regulatory database
      into the kernel.
      
      However, we really can't lose the signature checking, so implement
      it in the kernel by loading a detached signature (regulatory.db.p7s)
      and check it against built-in keys.
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      90a53e44
    • J
      cfg80211: reg: remove support for built-in regdb · c8c240e2
      Johannes Berg 提交于
      Parsing and building C structures from a regdb is no longer needed
      since the "firmware" file (regulatory.db) can be linked into the
      kernel image to achieve the same effect.
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      c8c240e2
    • J
      cfg80211: support reloading regulatory database · 1ea4ff3e
      Johannes Berg 提交于
      If the regulatory database is loaded, and then updated, it may
      be necessary to reload it. Add an nl80211 command to do this.
      
      Note that this just reloads the database, it doesn't re-apply
      the rules from it immediately.
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      1ea4ff3e
    • J
      cfg80211: support loading regulatory database as firmware file · 007f6c5e
      Johannes Berg 提交于
      As the current regulatory database is only about 4k big, and already
      difficult to extend, we decided that overall it would be better to
      get rid of the complications with CRDA and load the database into the
      kernel directly, but in a new format that is extensible.
      
      The new file format can be extended since it carries a length field
      on all the structs that need to be extensible.
      
      In order to be able to request firmware when the module initializes,
      move cfg80211 from subsys_initcall() to the later fs_initcall(); the
      firmware loader is at the same level but linked earlier, so it can
      be called from there. Otherwise, when both the firmware loader and
      cfg80211 are built-in, the request will crash the kernel. We also
      need to be before device_initcall() so that cfg80211 is available
      for devices when they initialize.
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      007f6c5e
  19. 06 9月, 2017 1 次提交
  20. 26 4月, 2017 1 次提交
  21. 06 3月, 2017 2 次提交
    • V
      cfg80211: Share Channel DFS state across wiphys of same DFS domain · 89766727
      Vasanthakumar Thiagarajan 提交于
      Sharing DFS channel state across multiple wiphys (radios) could
      be useful with multiple radios on the system. When one radio
      completes CAC and markes the channel available another radio
      can use this information and start beaconing without really doing
      CAC.
      
      Whenever there is a state change in dfs channel associated to
      a particular wiphy the the same state change is propagated to
      other wiphys having the same DFS reg domain configuration.
      Also when a new wiphy is created the dfs channel state of
      other existing wiphys of same DFS domain is copied.
      Signed-off-by: NVasanthakumar Thiagarajan <vthiagar@qti.qualcomm.com>
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      89766727
    • V
      cfg80211: Make pre-CAC results valid only for ETSI domain · b35a51c7
      Vasanthakumar Thiagarajan 提交于
      DFS requirement for ETSI domain (section 4.7.1.4 in
      ETSI EN 301 893 V1.8.1) is the only one which explicitly
      states that once DFS channel is marked as available afer
      the CAC, this channel will remain in available state even
      moving to a different operating channel. But the same is
      not explicitly stated in FCC DFS requirement. Also, Pre-CAC
      requriements are not explicitly mentioned in FCC requirement.
      Current implementation in keeping DFS channel in available
      state is same as described in ETSI domain.
      
      For non-ETSI DFS domain, this patch gives a grace period of 2 seconds
      since the completion of successful CAC before moving the channel's
      DFS state to 'usable' from 'available' state. The same grace period
      is checked against the channel's dfs_state_entered timestamp while
      deciding if a DFS channel is available for operation. There is a new
      radar event, NL80211_RADAR_PRE_CAC_EXPIRED, reported when DFS channel
      is moved from available to usable state after the grace period. Also
      make sure the DFS channel state is reset to usable once the beaconing
      operation on that channel is brought down (like stop_ap, leave_ibss
      and leave_mesh) in non-ETSI domain.
      Signed-off-by: NVasanthakumar Thiagarajan <vthiagar@qti.qualcomm.com>
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      b35a51c7
  22. 06 1月, 2017 1 次提交
  23. 12 5月, 2016 1 次提交
  24. 12 4月, 2016 1 次提交
  25. 14 1月, 2016 3 次提交
    • J
      cfg80211: remove CFG80211_REG_DEBUG · c799ba6e
      Johannes Berg 提交于
      Instead of having this Kconfig option, which just *floods* the
      kernel log,
       * remove the per-channel prints that are fairly useless anyway
       * convert the conditional printing to pr_debug()
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      c799ba6e
    • J
      regulatory: fix world regulatory domain data · c3826807
      Johannes Berg 提交于
      The rule definitions here aren't really valid, they would
      be rejected if it came from userspace due to the bandwidth
      specified being bigger than the rule's width.
      
      This is fairly much inconsequential since the other rules
      around them do enable the bandwidth, but express that better
      using the NL80211_RRF_AUTO_BW flag.
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      c3826807
    • D
      wireless: change cfg80211 regulatory domain info as debug messages · 94c4fd64
      Dave Young 提交于
      cfg80211 module prints a lot of messages like below. Actually printing
      once is acceptable but sometimes it will print again and again, it looks
      very annoying. It is better to change these detail messages to debugging
      only.
      
      cfg80211: World regulatory domain updated:
      cfg80211:  DFS Master region: unset
      cfg80211:   (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp), (dfs_cac_time)
      cfg80211:   (2402000 KHz - 2472000 KHz @ 40000 KHz), (N/A, 2000 mBm), (N/A)
      cfg80211:   (2457000 KHz - 2482000 KHz @ 40000 KHz), (N/A, 2000 mBm), (N/A)
      cfg80211:   (2474000 KHz - 2494000 KHz @ 20000 KHz), (N/A, 2000 mBm), (N/A)
      cfg80211:   (5170000 KHz - 5250000 KHz @ 80000 KHz, 160000 KHz AUTO), (N/A, 2000 mBm), (N/A)
      cfg80211:   (5250000 KHz - 5330000 KHz @ 80000 KHz, 160000 KHz AUTO), (N/A, 2000 mBm), (0 s)
      cfg80211:   (5490000 KHz - 5730000 KHz @ 160000 KHz), (N/A, 2000 mBm), (0 s)
      cfg80211:   (5735000 KHz - 5835000 KHz @ 80000 KHz), (N/A, 2000 mBm), (N/A)
      cfg80211:   (57240000 KHz - 63720000 KHz @ 2160000 KHz), (N/A, 0 mBm), (N/A)
      
      The changes in this patch is to replace pr_info with pr_debug in function
      print_rd_rules and print_regdomain_info
      Signed-off-by: NDave Young <dyoung@redhat.com>
      [change some pr_err() statements to at least keep the alpha2]
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      94c4fd64
  26. 15 12月, 2015 1 次提交