]> git.baikalelectronics.ru Git - kernel.git/commit
netfilter: x_tables: fix possible ZERO_SIZE_PTR pointer dereferencing error.
authorXiubo Li <lixiubo@cmss.chinamobile.com>
Thu, 2 Jun 2016 02:59:56 +0000 (10:59 +0800)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 23 Jun 2016 10:13:06 +0000 (12:13 +0200)
commit45148c832281fc27a551a360d1a48e7ace683e89
tree934019b39ad601725e3c8ae1e75e1f334fa6865c
parent8adf419a528eeb6ac2db5e4aa07d8fde5e4ca48b
netfilter: x_tables: fix possible ZERO_SIZE_PTR pointer dereferencing error.

Since we cannot make sure that the 'hook_mask' will always be none
zero here. If it equals to zero, the num_hooks will be zero too,
and then kmalloc() will return ZERO_SIZE_PTR, which is (void *)16.

Then the following error check will fails:
  ops = kmalloc(sizeof(*ops) * num_hooks, GFP_KERNEL);
  if (ops == NULL)
          return ERR_PTR(-ENOMEM);

So this patch will fix this with just doing the zero check before
kmalloc() is called.

Maybe the case above will never happen here, but in theory.

Signed-off-by: Xiubo Li <lixiubo@cmss.chinamobile.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/x_tables.c