net/smc: use memcpy instead of snprintf to avoid out of bounds read
authorKarsten Graul <kgraul@linux.ibm.com>
Fri, 8 Apr 2022 15:10:33 +0000 (17:10 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Apr 2022 07:36:15 +0000 (09:36 +0200)
commita2027dcf197fc6c6dc745a3f197e13185fa9b5c1
tree588b61c34b1a487b55a775ab497d964343987822
parent833759b3aadbbe9137cf026236037c979a183756
net/smc: use memcpy instead of snprintf to avoid out of bounds read

[ Upstream commit b1871fd48efc567650dbdc974e5a2342a03fe0d2 ]

Using snprintf() to convert not null-terminated strings to null
terminated strings may cause out of bounds read in the source string.
Therefore use memcpy() and terminate the target string with a null
afterwards.

Fixes: fa0866625543 ("net/smc: add support for user defined EIDs")
Fixes: 3c572145c24e ("net/smc: add generic netlink support for system EID")
Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/smc/smc_clc.c