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, 10 Jul 2019 07:55:37 +0000 (09:55 +0200)
commit99af179af9cfb7695e285e2298a3aed1e40dd6b3
treefd89416818fb2bb31e9b4893d673e71365dd1f63
parentc01ddaa54d7411e964ffd250c018d8469c5852f2
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