On Mon, Nov 27, 2017 at 02:33:59AM +0100, Stefan Sperling wrote:
> Most people I've talked to seem to be OK with never exposing
> these secrets to userland in the first place.

Better diff for the wireless part.
WEP keys showed up as 0x00000... instead of '<not displayed>' in
the previous diff.

Index: ieee80211_ioctl.c
===================================================================
RCS file: /cvs/src/sys/net80211/ieee80211_ioctl.c,v
retrieving revision 1.57
diff -u -p -r1.57 ieee80211_ioctl.c
--- ieee80211_ioctl.c   6 Nov 2017 11:34:29 -0000       1.57
+++ ieee80211_ioctl.c   27 Nov 2017 17:12:32 -0000
@@ -252,8 +252,7 @@ static int
 ieee80211_ioctl_getnwkeys(struct ieee80211com *ic,
     struct ieee80211_nwkey *nwkey)
 {
-       struct ieee80211_key *k;
-       int error, i;
+       int i;
 
        if (ic->ic_flags & IEEE80211_F_WEPON)
                nwkey->i_wepon = IEEE80211_NWKEY_WEP;
@@ -265,19 +264,8 @@ ieee80211_ioctl_getnwkeys(struct ieee802
        for (i = 0; i < IEEE80211_WEP_NKID; i++) {
                if (nwkey->i_key[i].i_keydat == NULL)
                        continue;
-               /* do not show any keys to non-root user */
-               if ((error = suser(curproc, 0)) != 0)
-                       return error;
-               k = &ic->ic_nw_keys[i];
-               if (k->k_cipher != IEEE80211_CIPHER_WEP40 &&
-                   k->k_cipher != IEEE80211_CIPHER_WEP104)
-                       nwkey->i_key[i].i_keylen = 0;
-               else
-                       nwkey->i_key[i].i_keylen = k->k_len;
-               error = copyout(k->k_key, nwkey->i_key[i].i_keydat,
-                   nwkey->i_key[i].i_keylen);
-               if (error != 0)
-                       return error;
+               /* do not show any keys to userland */
+               return EPERM;
        }
        return 0;
 }
@@ -491,14 +479,10 @@ ieee80211_ioctl(struct ifnet *ifp, u_lon
        case SIOCG80211WPAPSK:
                psk = (struct ieee80211_wpapsk *)data;
                if (ic->ic_flags & IEEE80211_F_PSK) {
-                       psk->i_enabled = 1;
-                       /* do not show any keys to non-root user */
-                       if (suser(curproc, 0) != 0) {
-                               psk->i_enabled = 2;
-                               memset(psk->i_psk, 0, sizeof(psk->i_psk));
-                               break;  /* return ok but w/o key */
-                       }
-                       memcpy(psk->i_psk, ic->ic_psk, sizeof(psk->i_psk));
+                       /* do not show any keys to userland */
+                       psk->i_enabled = 2;
+                       memset(psk->i_psk, 0, sizeof(psk->i_psk));
+                       break;  /* return ok but w/o key */
                } else
                        psk->i_enabled = 0;
                break;

Reply via email to