infiniband/uverbs: Fix integer overflows
authorVlad Tsyrklevich <vlad@tsyrklevich.net>
Fri, 24 Mar 2017 19:55:17 +0000 (15:55 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 24 Mar 2018 10:00:15 +0000 (11:00 +0100)
commit81fa3239900f7fb378764318d200b5bb9c477cd6
treec95d5a83a473d695eec98a12782e7f00c77403c6
parent8a15303518c005ae63ce1e22053822ea43db6dd1
infiniband/uverbs: Fix integer overflows

[ Upstream commit 4f7f4dcfff2c19debbcdbcc861c325610a15e0c5 ]

The 'num_sge' variable is verfied to be smaller than the 'sge_count'
variable; however, since both are user-controlled it's possible to cause
an integer overflow for the kmalloc multiply on 32-bit platforms
(num_sge and sge_count are both defined u32). By crafting an input that
causes a smaller-than-expected allocation it's possible to write
controlled data out-of-bounds.

Signed-off-by: Vlad Tsyrklevich <vlad@tsyrklevich.net>
Signed-off-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/infiniband/core/uverbs_cmd.c