]> git.baikalelectronics.ru Git - kernel.git/commit
arch: sparc: kernel: check the memory length before use strcpy().
authorChen Gang <gang.chen@asianux.com>
Sat, 22 Jun 2013 05:26:09 +0000 (13:26 +0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 10 Jul 2013 20:35:51 +0000 (13:35 -0700)
commit2bb72be92b372680787542ff6e35e61a91a06dd3
treef5c58406820460df5083e5352c26cca6b87adac9
parentb4a77178e5ffc3dc7000615912ac7fd37bf6614b
arch: sparc: kernel: check the memory length before use strcpy().

For the related next strcpy(), the destination length is less than 512,
but the source maximize length may be 'OPROMMAXPARAM' (4096) which is
more than 512.

One work flow may:
  openprom_sunos_ioctl() ->  if (cmd == OPROMSETOPT)
    getstrings() ->  will alloc buffer with size 'OPROMMAXPARAM'.
    opromsetopt() ->  devide the buffer into 'var' and 'value'
      of_set_property() -> pass
        prom_setprop() -> pass
          ldom_set_var()

And do not mind the additional 4 alignment buffer increasing, since
'sizeof(pkt) - sizeof(pkt.header)' is 4 alignment at least.

Signed-off-by: Chen Gang <gang.chen@asianux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
arch/sparc/kernel/ds.c