Skip to contentSkip to conversation

Is this a bug of vt_ioctl ??

PATCH bobl 2 participants 3 messages Nov 29, 2004 – Nov 30, 2004 Char and misc drivers

lore
Share & tools
lore

bobl

author
#0 lore raw

Hi,All:

I think this is a bug of vt_ioctl, who can give me a confirm?

In the man page of consolechars(v 0.3.3), we can see the describe
as follow:

---------------------------------------------------------------------
--tty=device
Use device as console device for ioctls, instead of
guessing which one to use, which usually chooses the current
tty. This can be useful for testing when under X, in
conjunction with --no-act - actual ioctls are refused for
some reason then.

--------------------------------------------------------------------

But when i use the command as follow,:
consolechars --sfm=/dir/name --tty=/dev/tty5 under tty1. The change happen on tty1, not on tty5! So i read the source code of consolechars and find the command as above use ioctl cmd PIO_UNIMAPCLR and PIO_UNIMAP. The source code of kernel 2.6.8.1 as follow:
(drivers/char/vt_ioctl.c)

        ...
        case PIO_UNIMAPCLR:
              { struct unimapinit ui;
                if (!perm)
                        return -EPERM;
                i = copy_from_user(&ui, (void *)arg, sizeof(struct 
unimapinit));
                if (i) return -EFAULT;
                con_clear_unimap(fg_console, &ui);
                return 0;
              }

        case PIO_UNIMAP:
        case GIO_UNIMAP:
                return do_unimap_ioctl(cmd, (struct unimapdesc *)arg, 
perm);
        ...

we can see in the case PIO_UNIMAPCLR, One parameter of con_clear_unimp is "fg_console"! it's current tty! In the implement of do_unimap_ioctl(), use "fg_console" too! Use "console" will be right!

The attachment is a patch against 2.6.8.1. If what i said is right, there also should do some other modify, such as in the case of GIO_SCRNMAP!

drivers/char/vt_ioctl.c renamed from drivers/char/vt_ioctl.c.orig +5 -5
@@ -332,7 +332,7 @@
 }
 
 static inline int 
-do_unimap_ioctl(int cmd, struct unimapdesc *user_ud,int perm)
+do_unimap_ioctl(int cmd, int con, struct unimapdesc *user_ud,int perm)
 {
 	struct unimapdesc tmp;
 	int i = 0; 
@@ -348,9 +348,9 @@
 	case PIO_UNIMAP:
 		if (!perm)
 			return -EPERM;
-		return con_set_unimap(fg_console, tmp.entry_ct, tmp.entries);
+		return con_set_unimap(con, tmp.entry_ct, tmp.entries);
 	case GIO_UNIMAP:
-		return con_get_unimap(fg_console, tmp.entry_ct, &(user_ud->entry_ct), tmp.entries);
+		return con_get_unimap(con, tmp.entry_ct, &(user_ud->entry_ct), tmp.entries);
 	}
 	return 0;
 }
@@ -966,13 +966,13 @@
 			return -EPERM;
 		i = copy_from_user(&ui, (void *)arg, sizeof(struct unimapinit));
 		if (i) return -EFAULT;
-		con_clear_unimap(fg_console, &ui);
+		con_clear_unimap(console, &ui);
 		return 0;
 	      }
 
 	case PIO_UNIMAP:
 	case GIO_UNIMAP:
-		return do_unimap_ioctl(cmd, (struct unimapdesc *)arg, perm);
+		return do_unimap_ioctl(cmd, console, (struct unimapdesc *)arg, perm);
 
 	case VT_LOCKSWITCH:
 		if (!capable(CAP_SYS_TTY_CONFIG))
#1 lore raw
Quoted 4 lines · bobl

we can see in the case PIO_UNIMAPCLR, One parameter of con_clear_unimp is "fg_console"! it's current tty! In the implement of do_unimap_ioctl(), use "fg_console" too! Use "console" will be right!

This was fixed almost a year ago.

Quoted 2 lines

The attachment is a patch against 2.6.8.1.

Maybe you're looking at a 2.4 kernel.

author
#2 lore raw
Quoted 5 lines · Andrew Morton
Quoted 1 line · bobl

we can see in the case PIO_UNIMAPCLR, One parameter of con_clear_unimp is "fg_console"! it's current tty! In the implement of do_unimap_ioctl(), use "fg_console" too! Use "console" will be right!

Quoted 8 lines

This was fixed almost a year ago.

Quoted 1 line

The attachment is a patch against 2.6.8.1.

Maybe you're looking at a 2.4 kernel.

Sorry!

It's my fault! What i am looking is 2.6.0!

So sorry!

Bob