Skip to contentSkip to conversation

drivers/s390/char/keyboard.c NULL pointer reference

PATCH sohu0106 2 participants 4 messages Aug 3, 2017 – Aug 5, 2017 s390

lore
Share & tools
lore

sohu0106

author
#0 lore raw

Local users able to send the NULL arg argument to kbd_ioctl(), which could cause kernel crash

(quoted diff) +0 -0

b/keyboard.c
index ba0e4f9..3ec16b1 100644

keyboard.c +0 -0
@@ -456,6 +456,8 @@ int kbd_ioctl(struct kbd_data *kbd, unsigned int cmd, unsigned long arg)

        int perm;

        argp = (void __user *)arg;
+       if( !argp )
+               return -EFAULT;

        /*
         * To have permissions to do most of the vt ioctls, we either have

https://bugzilla.kernel.org/show_bug.cgi?id=196575

#1 lore raw
Quoted 14 lines · On Thu, Aug 03, 2017 at 09:57:38PM +0800, sohu0106 wrote:

Local users able to send the NULL arg argument to kbd_ioctl(), which could cause kernel crash

keyboard.c +0 -0
index ba0e4f9..3ec16b1 100644
@@ -456,6 +456,8 @@ int kbd_ioctl(struct kbd_data *kbd, unsigned int cmd, unsigned long arg)
         int perm;
Quoted 4 lines


        argp = (void __user *)arg;
+       if( !argp )
+               return -EFAULT;

This doesn't make sense as well. All uaccess functions are able to handle NULL pointers within user space.

author
#2 lore raw

I don't understand a bit,My idea is

in userland

fd=open("tty3270",O_RDONLY)
...
ret=ioctl(fd,KDGKBDIACR,NULL)
...

then here
drivers/s390/char/keyboard.c
477
case KDGKBDIACR:

	{
		struct kbdiacrs __user *a = argp;
		struct kbdiacr diacr;
		int i;
		
		//a is NULL,a->kb_cnt will crash
		if (put_user(kbd->accent_table_size, &a->kb_cnt))
Quoted 23 lines · Heiko Carstens
Quoted 14 lines · On Thu, Aug 03, 2017 at 09:57:38PM +0800, sohu0106 wrote:

Local users able to send the NULL arg argument to kbd_ioctl(), which could cause kernel crash

keyboard.c +0 -0
index ba0e4f9..3ec16b1 100644
@@ -456,6 +456,8 @@ int kbd_ioctl(struct kbd_data *kbd, unsigned int cmd, unsigned long arg)
         int perm;
Quoted 4 lines


        argp = (void __user *)arg;
+       if( !argp )
+               return -EFAULT;

This doesn't make sense as well. All uaccess functions are able to handle NULL pointers within user space.

#3 lore raw
Quoted 15 lines · On Sat, Aug 05, 2017 at 09:44:45AM +0800, sohu0106 wrote:

I don't understand a bit,My idea is

in userland

fd=open("tty3270",O_RDONLY)
...
ret=ioctl(fd,KDGKBDIACR,NULL)
...

then here
drivers/s390/char/keyboard.c
477
case KDGKBDIACR:

Quoted 7 lines
	{
		struct kbdiacrs __user *a = argp;
		struct kbdiacr diacr;
		int i;
		
		//a is NULL,a->kb_cnt will crash
		if (put_user(kbd->accent_table_size, &a->kb_cnt))

a->kb_cnt and &a->kb_cnt is not the same...