Ticket #566: 566.patch
| File 566.patch, 11.0 kB (added by eaton.lists@gmail.com, 6 years ago) |
|---|
-
net80211/ieee80211_ioctl.h
old new 591 591 IEEE80211_PARAM_EOSPDROP = 57, /* force uapsd EOSP drop (ap only) */ 592 592 IEEE80211_PARAM_MARKDFS = 58, /* mark a dfs interference channel when found */ 593 593 IEEE80211_PARAM_REGCLASS = 59, /* enable regclass ids in country IE */ 594 IEEE80211_PARAM_DROPUNENC_EAPOL = 60, /* drop unencrypted eapol frames */ 594 595 }; 595 596 596 597 #define SIOCG80211STATS (SIOCDEVPRIVATE+2) -
net80211/ieee80211_wireless.c
old new 2006 2006 } 2007 2007 switch (value) { 2008 2008 case IEEE80211_AUTH_WPA: /* WPA w/ 802.1x */ 2009 vap->iv_flags |= IEEE80211_F_PRIVACY;2010 2009 value = IEEE80211_AUTH_8021X; 2011 2010 break; 2012 2011 case IEEE80211_AUTH_OPEN: /* open */ 2013 vap->iv_flags &= ~(IEEE80211_F_WPA |IEEE80211_F_PRIVACY);2012 vap->iv_flags &= ~(IEEE80211_F_WPA); 2014 2013 break; 2015 2014 case IEEE80211_AUTH_SHARED: /* shared-key */ 2016 2015 case IEEE80211_AUTH_AUTO: /* auto */ 2017 2016 case IEEE80211_AUTH_8021X: /* 802.1x */ 2018 2017 vap->iv_flags &= ~IEEE80211_F_WPA; 2019 /* both require a key so mark the PRIVACY capability */2020 vap->iv_flags |= IEEE80211_F_PRIVACY;2021 2018 break; 2022 2019 } 2023 2020 /* NB: authenticator attach/detach happens on state change */ … … 2132 2129 else 2133 2130 vap->iv_flags &= ~IEEE80211_F_DROPUNENC; 2134 2131 break; 2132 case IEEE80211_PARAM_DROPUNENC_EAPOL: 2133 if (value) 2134 IEEE80211_VAP_DROPUNENC_EAPOL_ENABLE(vap); 2135 else 2136 IEEE80211_VAP_DROPUNENC_EAPOL_DISABLE(vap); 2137 break; 2135 2138 case IEEE80211_PARAM_COUNTERMEASURES: 2136 2139 if (value) { 2137 2140 if ((vap->iv_flags & IEEE80211_F_WPA) == 0) … … 2593 2596 case IEEE80211_PARAM_DROPUNENCRYPTED: 2594 2597 param[0] = (vap->iv_flags & IEEE80211_F_DROPUNENC) != 0; 2595 2598 break; 2599 case IEEE80211_PARAM_DROPUNENC_EAPOL: 2600 param[0] = IEEE80211_VAP_DROPUNENC_EAPOL(vap); 2601 break; 2596 2602 case IEEE80211_PARAM_COUNTERMEASURES: 2597 2603 param[0] = (vap->iv_flags & IEEE80211_F_COUNTERM) != 0; 2598 2604 break; … … 3939 3945 } 3940 3946 3941 3947 3942 /*3943 * The exact meaning of the IW_AUTH_ALG_* values is a little unclear.3944 * For example, wpa_supplicant uses IW_AUTH_ALG_OPEN_SYSTEM for WPA-PSK3945 * APs, unless you happen to set the auth_alg=SHARED option in your config3946 * file in which case it uses IW_AUTH_ALG_SHARED_KEY. Fortunately,3947 * neither makes a any difference to madwifi, so for now we ignore it.3948 */3949 3948 static int 3950 3949 siwauth_80211_auth_alg(struct net_device *dev, 3951 3950 struct iw_request_info *info, struct iw_param *erq, char *buf) 3952 3951 { 3953 return -EOPNOTSUPP; 3952 #define VALID_ALGS_MASK (IW_AUTH_ALG_OPEN_SYSTEM|IW_AUTH_ALG_SHARED_KEY|IW_AUTH_ALG_LEAP) 3953 int mode = erq->value; 3954 int args[2]; 3955 3956 args[0] = IEEE80211_PARAM_AUTHMODE; 3957 3958 if (mode & ~VALID_ALGS_MASK) { 3959 return -EINVAL; 3960 } 3961 if (mode & IW_AUTH_ALG_LEAP) { 3962 args[1] = IEEE80211_AUTH_8021X; 3963 } else if ((mode & IW_AUTH_ALG_SHARED_KEY) && 3964 (mode & IW_AUTH_ALG_OPEN_SYSTEM)) { 3965 args[1] = IEEE80211_AUTH_AUTO; 3966 } else if (mode & IW_AUTH_ALG_SHARED_KEY) { 3967 args[1] = IEEE80211_AUTH_SHARED; 3968 } else { 3969 args[1] = IEEE80211_AUTH_OPEN; 3970 } 3971 return ieee80211_ioctl_setparam(dev, NULL, NULL, (char*)args); 3954 3972 } 3955 3973 3956 3974 static int … … 3969 3987 return ieee80211_ioctl_setparam(dev, NULL, NULL, (char*)args); 3970 3988 } 3971 3989 3972 /*3973 * The wext API says that user space gets to decide whether EAPOL frames are3974 * supposed to be encrypted or in cleartext. The code in WPA supplicant3975 * indicates that if the AP is using 802.1x authentication but not WPA for3976 * key mgmt the eapol frames should be encrypted. However, even if I set3977 * up my AP (linkys WRT54G, fw 1.00.2) for that config, it sends eapol frames3978 * in the clear. I'm uncertain whether my AP is violating the specification,3979 * or if wpa_supplicant is doing the wrong thing. But if I let wpa_supplicant3980 * tell madwifi to drop unencrypted eapol frames, it breaks the authentication.3981 *3982 * Thus, madwifi ignores this parameter.3983 */3984 3990 static int 3985 3991 siwauth_rx_unencrypted_eapol(struct net_device *dev, 3986 3992 struct iw_request_info *info, struct iw_param *erq, char *buf) 3987 3993 { 3988 return -EOPNOTSUPP; 3994 int rxunenc = erq->value; 3995 int args[2]; 3996 3997 args[0] = IEEE80211_PARAM_DROPUNENC_EAPOL; 3998 if (rxunenc) 3999 args[1] = 1; 4000 else 4001 args[1] = 0; 4002 4003 return ieee80211_ioctl_setparam(dev, NULL, NULL, (char*)args); 3989 4004 } 3990 4005 3991 4006 static int … … 4765 4780 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "regclass" }, 4766 4781 { IEEE80211_PARAM_REGCLASS, 4767 4782 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_regclass" }, 4783 { IEEE80211_PARAM_DROPUNENC_EAPOL, 4784 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "dropunenceapol" }, 4785 { IEEE80211_PARAM_DROPUNENC_EAPOL, 4786 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_dropunencea" }, 4768 4787 /* 4769 4788 * NB: these should be roamrssi* etc, but iwpriv usurps all 4770 4789 * strings that start with roam! -
net80211/ieee80211_input.c
old new 118 118 static void ieee80211_send_error(struct ieee80211_node *, const u_int8_t *, 119 119 int, int); 120 120 static void ieee80211_recv_pspoll(struct ieee80211_node *, struct sk_buff *); 121 static int accept_data_frame(struct ieee80211vap *, struct ieee80211_node *, 122 struct ieee80211_key *, struct sk_buff *, struct ether_header *); 121 123 124 122 125 #ifdef ATH_SUPERG_FF 123 126 static void athff_decap(struct sk_buff *); 124 127 #endif … … 669 672 goto err; 670 673 } 671 674 eh = (struct ether_header *) skb->data; 672 if (!ieee80211_node_is_authorized(ni)) { 673 /* 674 * Deny any non-PAE frames received prior to 675 * authorization. For open/shared-key 676 * authentication the port is mark authorized 677 * after authentication completes. For 802.1x 678 * the port is not marked authorized by the 679 * authenticator until the handshake has completed. 680 */ 681 if (eh->ether_type != __constant_htons(ETHERTYPE_PAE)) { 682 IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_INPUT, 683 eh->ether_shost, "data", 684 "unauthorized port: ether type 0x%x len %u", 685 eh->ether_type, skb->len); 686 vap->iv_stats.is_rx_unauth++; 687 IEEE80211_NODE_STAT(ni, rx_unauth); 688 goto err; 689 } 690 } else { 691 /* 692 * When denying unencrypted frames, discard 693 * any non-PAE frames received without encryption. 694 */ 695 if ((vap->iv_flags & IEEE80211_F_DROPUNENC) && 696 key == NULL && 697 eh->ether_type != __constant_htons(ETHERTYPE_PAE)) { 698 /* 699 * Drop unencrypted frames. 700 */ 701 vap->iv_stats.is_rx_unencrypted++; 702 IEEE80211_NODE_STAT(ni, rx_unencrypted); 703 goto out; 704 } 705 } 675 676 if (! accept_data_frame(vap, ni, key, skb, eh)) 677 goto out; 678 706 679 vap->iv_devstats.rx_packets++; 707 680 vap->iv_devstats.rx_bytes += skb->len; 708 681 IEEE80211_NODE_STAT(ni, rx_data); … … 859 832 } 860 833 EXPORT_SYMBOL(ieee80211_input); 861 834 835 862 836 /* 837 * Determines whether a frame should be accepted, based on information 838 * about the frame's origin and encryption, and policy for this vap. 839 */ 840 static int accept_data_frame(struct ieee80211vap *vap, 841 struct ieee80211_node *ni, struct ieee80211_key *key, 842 struct sk_buff *skb, struct ether_header *eh) 843 { 844 #define IS_EAPOL(eh) ((eh)->ether_type == __constant_htons(ETHERTYPE_PAE)) 845 #define PAIRWISE_SET(vap) ((vap)->iv_nw_keys[0].wk_cipher != &ieee80211_cipher_none) 846 if (IS_EAPOL(eh)) { 847 /* encrypted eapol is always OK */ 848 if (key) 849 return 1; 850 /* cleartext eapol is OK if we don't have pairwise keys yet */ 851 if (! PAIRWISE_SET(vap)) 852 return 1; 853 /* cleartext eapol is OK if configured to allow it */ 854 if (! IEEE80211_VAP_DROPUNENC_EAPOL(vap)) 855 return 1; 856 /* cleartext eapol is OK if other unencrypted is OK */ 857 if (! (vap->iv_flags & IEEE80211_F_DROPUNENC)) 858 return 1; 859 /* not OK */ 860 vap->iv_stats.is_rx_unauth++; 861 vap->iv_devstats.rx_errors++; 862 IEEE80211_NODE_STAT(ni, rx_unauth); 863 return 0; 864 } 865 866 if (!ieee80211_node_is_authorized(ni)) { 867 /* 868 * Deny any non-PAE frames received prior to 869 * authorization. For open/shared-key 870 * authentication the port is mark authorized 871 * after authentication completes. For 802.1x 872 * the port is not marked authorized by the 873 * authenticator until the handshake has completed. 874 */ 875 IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_INPUT, 876 eh->ether_shost, "data", 877 "unauthorized port: ether type 0x%x len %u", 878 eh->ether_type, skb->len); 879 vap->iv_stats.is_rx_unauth++; 880 vap->iv_devstats.rx_errors++; 881 IEEE80211_NODE_STAT(ni, rx_unauth); 882 return 0; 883 } else { 884 /* 885 * When denying unencrypted frames, discard 886 * any non-PAE frames received without encryption. 887 */ 888 if ((vap->iv_flags & IEEE80211_F_DROPUNENC) && key == NULL) { 889 IEEE80211_NODE_STAT(ni, rx_unencrypted); 890 return 0; 891 } 892 } 893 return 1; 894 895 #undef IS_EAPOL 896 #undef PAIRWISE_SET 897 } 898 899 900 /* 863 901 * Context: softIRQ (tasklet) 864 902 */ 865 903 int -
net80211/ieee80211_var.h
old new 450 450 #define IEEE80211_FEXT_REGCLASS 0x00000100 /* CONF: send regclassids in country ie */ 451 451 #define IEEE80211_FEXT_ERPUPDATE 0x00000200 /* STATUS: update ERP element */ 452 452 #define IEEE80211_FEXT_SWBMISS 0x00000400 /* CONF: use software beacon timer */ 453 #define IEEE80211_FEXT_DROPUNENC_EAPOL 0x00000800 /* CONF: drop unencrypted eapol frames */ 453 454 454 455 #define IEEE80211_COM_UAPSD_ENABLE(_ic) ((_ic)->ic_flags_ext |= IEEE80211_FEXT_UAPSD) 455 456 #define IEEE80211_COM_UAPSD_DISABLE(_ic) ((_ic)->ic_flags_ext &= ~IEEE80211_FEXT_UAPSD) … … 467 468 #define IEEE80211_VAP_EOSPDROP_ENABLE(_v) ((_v)->iv_flags_ext |= IEEE80211_FEXT_EOSPDROP) 468 469 #define IEEE80211_VAP_EOSPDROP_DISABLE(_v) ((_v)->iv_flags_ext &= ~IEEE80211_FEXT_EOSPDROP) 469 470 #define IEEE80211_VAP_EOSPDROP_ENABLED(_v) ((_v)->iv_flags_ext & IEEE80211_FEXT_EOSPDROP) 471 #define IEEE80211_VAP_DROPUNENC_EAPOL_ENABLE(_v) ((_v)->iv_flags_ext |= IEEE80211_FEXT_DROPUNENC_EAPOL) 472 #define IEEE80211_VAP_DROPUNENC_EAPOL_DISABLE(_v) ((_v)->iv_flags_ext &= ~IEEE80211_FEXT_DROPUNENC_EAPOL) 473 #define IEEE80211_VAP_DROPUNENC_EAPOL(_v) ((_v)->iv_flags_ext & IEEE80211_FEXT_DROPUNENC_EAPOL) 470 474 475 471 476 /* ic_caps */ 472 477 #define IEEE80211_C_WEP 0x00000001 /* CAPABILITY: WEP available */ 473 478 #define IEEE80211_C_TKIP 0x00000002 /* CAPABILITY: TKIP available */
