Ticket #566: 566.patch

File 566.patch, 11.0 kB (added by eaton.lists@gmail.com, 6 years ago)

fix for this bug

  • net80211/ieee80211_ioctl.h

    old new  
    591591        IEEE80211_PARAM_EOSPDROP        = 57,   /* force uapsd EOSP drop (ap only) */ 
    592592        IEEE80211_PARAM_MARKDFS         = 58,   /* mark a dfs interference channel when found */ 
    593593        IEEE80211_PARAM_REGCLASS        = 59,   /* enable regclass ids in country IE */ 
     594        IEEE80211_PARAM_DROPUNENC_EAPOL = 60,   /* drop unencrypted eapol frames */ 
    594595}; 
    595596 
    596597#define SIOCG80211STATS                 (SIOCDEVPRIVATE+2) 
  • net80211/ieee80211_wireless.c

    old new  
    20062006                } 
    20072007                switch (value) { 
    20082008                case IEEE80211_AUTH_WPA:        /* WPA w/ 802.1x */ 
    2009                         vap->iv_flags |= IEEE80211_F_PRIVACY; 
    20102009                        value = IEEE80211_AUTH_8021X; 
    20112010                        break; 
    20122011                case IEEE80211_AUTH_OPEN:       /* open */ 
    2013                         vap->iv_flags &= ~(IEEE80211_F_WPA|IEEE80211_F_PRIVACY); 
     2012                        vap->iv_flags &= ~(IEEE80211_F_WPA); 
    20142013                        break; 
    20152014                case IEEE80211_AUTH_SHARED:     /* shared-key */ 
    20162015                case IEEE80211_AUTH_AUTO:       /* auto */ 
    20172016                case IEEE80211_AUTH_8021X:      /* 802.1x */ 
    20182017                        vap->iv_flags &= ~IEEE80211_F_WPA; 
    2019                         /* both require a key so mark the PRIVACY capability */ 
    2020                         vap->iv_flags |= IEEE80211_F_PRIVACY; 
    20212018                        break; 
    20222019                } 
    20232020                /* NB: authenticator attach/detach happens on state change */ 
     
    21322129                else 
    21332130                        vap->iv_flags &= ~IEEE80211_F_DROPUNENC; 
    21342131                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; 
    21352138        case IEEE80211_PARAM_COUNTERMEASURES: 
    21362139                if (value) { 
    21372140                        if ((vap->iv_flags & IEEE80211_F_WPA) == 0) 
     
    25932596        case IEEE80211_PARAM_DROPUNENCRYPTED: 
    25942597                param[0] = (vap->iv_flags & IEEE80211_F_DROPUNENC) != 0; 
    25952598                break; 
     2599        case IEEE80211_PARAM_DROPUNENC_EAPOL: 
     2600                param[0] = IEEE80211_VAP_DROPUNENC_EAPOL(vap); 
     2601                break; 
    25962602        case IEEE80211_PARAM_COUNTERMEASURES: 
    25972603                param[0] = (vap->iv_flags & IEEE80211_F_COUNTERM) != 0; 
    25982604                break; 
     
    39393945} 
    39403946 
    39413947 
    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-PSK 
    3945  * APs, unless you happen to set the auth_alg=SHARED option in your config 
    3946  * 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  */ 
    39493948static int 
    39503949siwauth_80211_auth_alg(struct net_device *dev, 
    39513950        struct iw_request_info *info, struct iw_param *erq, char *buf) 
    39523951{ 
    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); 
    39543972} 
    39553973 
    39563974static int 
     
    39693987        return ieee80211_ioctl_setparam(dev, NULL, NULL, (char*)args); 
    39703988} 
    39713989 
    3972 /* 
    3973  * The wext API says that user space gets to decide whether EAPOL frames are  
    3974  * supposed to be encrypted or in cleartext.  The code in WPA supplicant  
    3975  * indicates that if the AP is using 802.1x authentication but not WPA for 
    3976  * key mgmt the eapol frames should be encrypted.  However, even if I set 
    3977  * up my AP (linkys WRT54G, fw 1.00.2) for that config, it sends eapol frames  
    3978  * 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_supplicant 
    3980  * tell madwifi to drop unencrypted eapol frames, it breaks the authentication. 
    3981  * 
    3982  * Thus, madwifi ignores this parameter. 
    3983  */ 
    39843990static int 
    39853991siwauth_rx_unencrypted_eapol(struct net_device *dev, 
    39863992        struct iw_request_info *info, struct iw_param *erq, char *buf) 
    39873993{ 
    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); 
    39894004} 
    39904005 
    39914006static int 
     
    47654780          IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "regclass" }, 
    47664781        { IEEE80211_PARAM_REGCLASS, 
    47674782          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" }, 
    47684787        /* 
    47694788         * NB: these should be roamrssi* etc, but iwpriv usurps all 
    47704789         *     strings that start with roam! 
  • net80211/ieee80211_input.c

    old new  
    118118static void ieee80211_send_error(struct ieee80211_node *, const u_int8_t *, 
    119119        int, int); 
    120120static void ieee80211_recv_pspoll(struct ieee80211_node *, struct sk_buff *); 
     121static int accept_data_frame(struct ieee80211vap *, struct ieee80211_node *, 
     122        struct ieee80211_key *, struct sk_buff *, struct ether_header *); 
    121123 
     124 
    122125#ifdef ATH_SUPERG_FF 
    123126static void athff_decap(struct sk_buff *); 
    124127#endif 
     
    669672                        goto err; 
    670673                } 
    671674                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 
    706679                vap->iv_devstats.rx_packets++; 
    707680                vap->iv_devstats.rx_bytes += skb->len; 
    708681                IEEE80211_NODE_STAT(ni, rx_data); 
     
    859832} 
    860833EXPORT_SYMBOL(ieee80211_input); 
    861834 
     835 
    862836/* 
     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 */ 
     840static 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/* 
    863901 * Context: softIRQ (tasklet) 
    864902 */ 
    865903int 
  • net80211/ieee80211_var.h

    old new  
    450450#define IEEE80211_FEXT_REGCLASS 0x00000100      /* CONF: send regclassids in country ie */ 
    451451#define IEEE80211_FEXT_ERPUPDATE 0x00000200     /* STATUS: update ERP element */ 
    452452#define IEEE80211_FEXT_SWBMISS 0x00000400       /* CONF: use software beacon timer */ 
     453#define IEEE80211_FEXT_DROPUNENC_EAPOL 0x00000800      /* CONF: drop unencrypted eapol frames */ 
    453454 
    454455#define IEEE80211_COM_UAPSD_ENABLE(_ic)         ((_ic)->ic_flags_ext |= IEEE80211_FEXT_UAPSD) 
    455456#define IEEE80211_COM_UAPSD_DISABLE(_ic)        ((_ic)->ic_flags_ext &= ~IEEE80211_FEXT_UAPSD) 
     
    467468#define IEEE80211_VAP_EOSPDROP_ENABLE(_v)  ((_v)->iv_flags_ext |= IEEE80211_FEXT_EOSPDROP) 
    468469#define IEEE80211_VAP_EOSPDROP_DISABLE(_v) ((_v)->iv_flags_ext &= ~IEEE80211_FEXT_EOSPDROP) 
    469470#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) 
    470474 
     475 
    471476/* ic_caps */ 
    472477#define IEEE80211_C_WEP         0x00000001      /* CAPABILITY: WEP available */ 
    473478#define IEEE80211_C_TKIP        0x00000002      /* CAPABILITY: TKIP available */