Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Jan 2016 15:05:42 +0000
From:      bugzilla-noreply@freebsd.org
To:        freebsd-bugs@FreeBSD.org
Subject:   [Bug 206678] OGIO_KEYMAP command does not restore priority level
Message-ID:  <bug-206678-8@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D206678

            Bug ID: 206678
           Summary: OGIO_KEYMAP command does not restore priority level
           Product: Base System
           Version: 11.0-CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: kern
          Assignee: freebsd-bugs@FreeBSD.org
          Reporter: ecturt@gmail.com

`genkbd_commonioctl` function from `sys/dev/kbd/kbd.c` begins by calling
`spltty()` to block hard interrupts from TTY:

int
genkbd_commonioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
{
        keymap_t *mapp;
        okeymap_t *omapp;
        keyarg_t *keyp;
        fkeyarg_t *fkeyp;splx
        int s;
        int i, j;
        int error;

        s =3D spltty();
        switch (cmd) {

It should always restore the original priority level using the `splx` funct=
ion
before returning. For example at the end of the function:

        splx(s);
        return (0);
}

And for any commands which need to return early:

        case GIO_KEYMAP:        /* get keyboard translation table */
                error =3D copyout(kbd->kb_keymap, *(void **)arg,
                    sizeof(keymap_t));
                splx(s);
                return (error);

The problem is that for the `OGIO_KEYMAP` command, this does not happen:

        case OGIO_KEYMAP:       /* get keyboard translation table (compat) =
*/
                mapp =3D kbd->kb_keymap;
                omapp =3D (okeymap_t *)arg;
                omapp->n_keys =3D mapp->n_keys;
                for (i =3D 0; i < NUM_KEYS; i++) {
                        for (j =3D 0; j < NUM_STATES; j++)
                                omapp->key[i].map[j] =3D
                                    mapp->key[i].map[j];
                        omapp->key[i].spcl =3D mapp->key[i].spcl;
                        omapp->key[i].flgs =3D mapp->key[i].flgs;
                }
                return (0);

My guess is that since this is a compatibility command, it was copied into =
here
from somewhere else, which is why the call to `splx` is missing.

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-206678-8>