9p: p9dirent_read: check network-provided name length
authorDominique Martinet <dominique.martinet@cea.fr>
Fri, 7 Sep 2018 15:36:08 +0000 (00:36 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 3 Jul 2019 11:14:42 +0000 (13:14 +0200)
commit6490cdf9d29db37628b73004d11844269a9f31ab
treefc84aa20f6b0fa8834538626b2bda69a64c2d622
parente48e7e27e4dfd00c81e0381e7cee610cce021452
9p: p9dirent_read: check network-provided name length

[ Upstream commit ef5305f1f72eb1cfcda25c382bb0368509c0385b ]

strcpy to dirent->d_name could overflow the buffer, use strscpy to check
the provided string length and error out if the size was too big.

While we are here, make the function return an error when the pdu
parsing failed, instead of returning the pdu offset as if it had been a
success...

Link: http://lkml.kernel.org/r/1536339057-21974-4-git-send-email-asmadeus@codewreck.org
Addresses-Coverity-ID: 139133 ("Copy into fixed size buffer")
Signed-off-by: Dominique Martinet <dominique.martinet@cea.fr>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/9p/protocol.c