* drivers/s390/char/keyboard.c kernel stack infoleak
@ 2017-08-03 13:59 sohu0106
2017-08-04 9:09 ` Thomas Huth
0 siblings, 1 reply; 4+ messages in thread
From: sohu0106 @ 2017-08-03 13:59 UTC (permalink / raw)
To: schwidefsky, heiko.carstens; +Cc: linux-s390, torvalds, linux-kernel
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++) {
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: drivers/s390/char/keyboard.c kernel stack infoleak
2017-08-03 13:59 drivers/s390/char/keyboard.c kernel stack infoleak sohu0106
@ 2017-08-04 9:09 ` Thomas Huth
2017-08-04 9:20 ` Heiko Carstens
0 siblings, 1 reply; 4+ messages in thread
From: Thomas Huth @ 2017-08-04 9:09 UTC (permalink / raw)
To: sohu0106; +Cc: schwidefsky, heiko.carstens, linux-s390, linux-kernel
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: drivers/s390/char/keyboard.c kernel stack infoleak
2017-08-04 9:09 ` Thomas Huth
@ 2017-08-04 9:20 ` Heiko Carstens
[not found] ` <78655e6a.d34.15db01cd5b8.Coremail.sohu0106@126.com>
0 siblings, 1 reply; 4+ messages in thread
From: Heiko Carstens @ 2017-08-04 9:20 UTC (permalink / raw)
To: Thomas Huth; +Cc: sohu0106, schwidefsky, linux-s390, linux-kernel
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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: drivers/s390/char/keyboard.c kernel stack infoleak
[not found] ` <78655e6a.d34.15db01cd5b8.Coremail.sohu0106@126.com>
@ 2017-08-05 7:12 ` Thomas Huth
0 siblings, 0 replies; 4+ messages in thread
From: Thomas Huth @ 2017-08-05 7:12 UTC (permalink / raw)
To: sohu0106; +Cc: Heiko Carstens, schwidefsky, linux-s390, linux-kernel
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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-08-05 7:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-03 13:59 drivers/s390/char/keyboard.c kernel stack infoleak sohu0106
2017-08-04 9:09 ` Thomas Huth
2017-08-04 9:20 ` Heiko Carstens
[not found] ` <78655e6a.d34.15db01cd5b8.Coremail.sohu0106@126.com>
2017-08-05 7:12 ` Thomas Huth
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.