 if (!capable(CAP_SYS_TTY_CONFIG)) perm = 0; 
do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm, struct kbd_struct *kbd){	struct kbentry tmp;	ushort *key_map, val, ov;	if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))		return -EFAULT;	switch (cmd) {	case KDGKBENT:		key_map = key_maps[s];		if (key_map) {		    val = U(key_map[i]);		    if (kbd->kbdmode != VC_UNICODE && KTYP(val) >= NR_TYPES)			val = K_HOLE;		} else		    val = (i ? K_HOLE : K_NOSUCHMAP);		return put_user(val, &user_kbe->kb_value);	case KDSKBENT:		if (!perm)			return -EPERM;		if (!i && v == K_NOSUCHMAP) {			/* disallocate map */			key_map = key_maps[s];			if (s && key_map) {			    key_maps[s] = NULL;			    if (key_map[0] == U(K_ALLOCATED)) {					kfree(key_map);					keymap_count--;			    }			}			break;		}		if (KTYP(v) < NR_TYPES) {		    if (KVAL(v) > max_vals[KTYP(v)])				return -EINVAL;		} else		    if (kbd->kbdmode != VC_UNICODE)				return -EINVAL;		/* ++Geert: non-PC keyboards may generate keycode zero */#if !defined(__mc68000__) && !defined(__powerpc__)		/* assignment to entry 0 only tests validity of args */		if (!i)			break;#endif		if (!(key_map = key_maps[s])) {			int j;			if (keymap_count >= MAX_NR_OF_USER_KEYMAPS &&			    !capable(CAP_SYS_RESOURCE))				return -EPERM;			key_map = (ushort *) kmalloc(sizeof(plain_map),						     GFP_KERNEL);			if (!key_map)				return -ENOMEM;			key_maps[s] = key_map;			key_map[0] = U(K_ALLOCATED);			for (j = 1; j < NR_KEYS; j++)				key_map[j] = U(K_HOLE);			keymap_count++;		}		ov = U(key_map[i]);		if (v == ov)			break;	/* nothing to do */		/*		 * Attention Key.		 */		if (((ov == K_SAK) || (v == K_SAK)) && !capable(CAP_SYS_ADMIN))			return -EPERM;		key_map[i] = U(v);		if (!s && (KTYP(ov) == KT_SHIFT || KTYP(v) == KT_SHIFT))			compute_shiftstate();		break;	}	return 0;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/e3f17f0f6e98f58edb13cb38810d93e6d4808e68/vt_ioctl.c/buggy/drivers/char/vt_ioctl.c