IB/uverbs: Fix possible oops with duplicate ioctl attributes
authorMatan Barak <matanb@mellanox.com>
Tue, 13 Feb 2018 10:18:35 +0000 (12:18 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 30 May 2018 05:51:56 +0000 (07:51 +0200)
commit5b0622bfe6371b132a4e54d1cb2e7534386fa801
treef9e968fe3e6b7c4b1a99e8dae00a3dc0e8ddaa67
parentcdd37f48d6a09caa30f35b3068e0922e604d8408
IB/uverbs: Fix possible oops with duplicate ioctl attributes

[ Upstream commit 4d39a959bc1f3d164b5a54147fdeb19f84b1ed58 ]

If the same attribute is listed twice by the user in the ioctl attribute
list then error unwind can cause the kernel to deref garbage.

This happens when an object with WRITE access is sent twice. The second
parse properly fails but corrupts the state required for the error unwind
it triggers.

Fixing this by making duplicates in the attribute list invalid. This is
not something we need to support.

The ioctl interface is currently recommended to be disabled in kConfig.

Signed-off-by: Matan Barak <matanb@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/infiniband/core/uverbs_ioctl.c