Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1703145 > unrolled thread

drivers/s390/char/keyboard.c kernel stack infoleak

Started bysohu0106 <sohu0106@126.com>
First post2017-08-03 16:00 +0200
Last post2017-08-05 09:20 +0200
Articles 4 — 3 participants

Back to article view | Back to linux.kernel


Contents

  drivers/s390/char/keyboard.c kernel stack infoleak sohu0106 <sohu0106@126.com> - 2017-08-03 16:00 +0200
    Re: drivers/s390/char/keyboard.c kernel stack infoleak Thomas Huth <huth@tuxfamily.org> - 2017-08-04 11:10 +0200
      Re: drivers/s390/char/keyboard.c kernel stack infoleak Heiko Carstens <heiko.carstens@de.ibm.com> - 2017-08-04 11:30 +0200
        Re: drivers/s390/char/keyboard.c kernel stack infoleak Thomas Huth <huth@tuxfamily.org> - 2017-08-05 09:20 +0200

#1703145 — drivers/s390/char/keyboard.c kernel stack infoleak

Fromsohu0106 <sohu0106@126.com>
Date2017-08-03 16:00 +0200
Subjectdrivers/s390/char/keyboard.c kernel stack infoleak
Message-ID<uaoPn-Jx-15@gated-at.bofh.it>
The stack object "kbdiacr" has a total size of 4 bytes. Its last 1 bytes are padding bytes after "result" which are not initialized and leaked to userland via "copy_to_user".


diff --git a/keyboard.c b/keyboard.c
index ba0e4f9..76a6d35 100644
--- a/keyboard.c
+++ b/keyboard.c
@@ -480,6 +480,8 @@ int kbd_ioctl(struct kbd_data *kbd, unsigned int cmd, unsigned long arg)
                struct kbdiacr diacr;
                int i;
 
+               memset( &diacr, 0, sizeof(struct kbdiacr) );
+
                if (put_user(kbd->accent_table_size, &a->kb_cnt))
                        return -EFAULT;
                for (i = 0; i < kbd->accent_table_size; i++) {

[toc] | [next] | [standalone]


#1703811

FromThomas Huth <huth@tuxfamily.org>
Date2017-08-04 11:10 +0200
Message-ID<uaGMi-53u-25@gated-at.bofh.it>
In reply to#1703145
 Hi,

On 03.08.2017 15:59, sohu0106 wrote:
> 
> The stack object "kbdiacr" has a total size of 4 bytes. Its last 1 bytes are padding bytes after "result" which are not initialized and leaked to userland via "copy_to_user".
> 
> 
> diff --git a/keyboard.c b/keyboard.c
> index ba0e4f9..76a6d35 100644
> --- a/keyboard.c
> +++ b/keyboard.c
> @@ -480,6 +480,8 @@ int kbd_ioctl(struct kbd_data *kbd, unsigned int cmd, unsigned long arg)
>                 struct kbdiacr diacr;
>                 int i;
>  
> +               memset( &diacr, 0, sizeof(struct kbdiacr) );
> +

I think it would be nicer to simply init the struct with "= {}"
directly, i.e.:

		struct kbdiacr diacr = {};

And by the way, please have a look at the kernel patch submission
guidelines first, especially the COO part here:

 https://www.kernel.org/doc/html/v4.12/process/submitting-patches.html#sign-your-work-the-developer-s-certificate-of-origin

So looking at your patch, please try to send plain text mails, and sign
your patch with a Signed-off-by line (i.e. no anonymous contributions).

 Thanks!
  Thomas

[toc] | [prev] | [next] | [standalone]


#1703818

FromHeiko Carstens <heiko.carstens@de.ibm.com>
Date2017-08-04 11:30 +0200
Message-ID<uaH5D-5ax-11@gated-at.bofh.it>
In reply to#1703811
On Fri, Aug 04, 2017 at 11:09:24AM +0200, Thomas Huth wrote:
>  Hi,
> 
> On 03.08.2017 15:59, sohu0106 wrote:
> > 
> > The stack object "kbdiacr" has a total size of 4 bytes. Its last 1 bytes are padding bytes after "result" which are not initialized and leaked to userland via "copy_to_user".
> > 
> > 
> > diff --git a/keyboard.c b/keyboard.c
> > index ba0e4f9..76a6d35 100644
> > --- a/keyboard.c
> > +++ b/keyboard.c
> > @@ -480,6 +480,8 @@ int kbd_ioctl(struct kbd_data *kbd, unsigned int cmd, unsigned long arg)
> >                 struct kbdiacr diacr;
> >                 int i;
> >  
> > +               memset( &diacr, 0, sizeof(struct kbdiacr) );
> > +
> 
> I think it would be nicer to simply init the struct with "= {}"
> directly, i.e.:
> 
> 		struct kbdiacr diacr = {};
> 
> And by the way, please have a look at the kernel patch submission
> guidelines first, especially the COO part here:

The patch doesn't make sense. There is no padding and therefore no
information leak.

[toc] | [prev] | [next] | [standalone]


#1704593

FromThomas Huth <huth@tuxfamily.org>
Date2017-08-05 09:20 +0200
Message-ID<ub1xo-1Ae-7@gated-at.bofh.it>
In reply to#1703818
On 05.08.2017 03:57, sohu0106 wrote:
> My idea is 
> 
> struct kbdiacr {
>         unsigned char diacr, base, result;
> };
> 
> sizeof(struct kbdiacr)=4  
> 
> here we just set 3 bytes 
> case KDGKBDIACR:
> {
> struct kbdiacrs __user *a = argp;
> struct kbdiacr diacr;
> int i;
> 
> if (put_user(kbd->accent_table_size, &a->kb_cnt))
> return -EFAULT;
> for (i = 0; i < kbd->accent_table_size; i++) {
> diacr.diacr = kbd->accent_table[i].diacr;
> diacr.base = kbd->accent_table[i].base;
> diacr.result = kbd->accent_table[i].result;
> if (copy_to_user(a->kbdiacr + i, &diacr, sizeof(struct kbdiacr)))
> Is there anything I haven't noticed?

Yes: sizeof(struct kbdiacr) is 3 here.

 Thomas

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web