cifs: return ENAMETOOLONG for overlong names in cifs_open()/cifs_lookup()
authorRonnie Sahlberg <lsahlber@redhat.com>
Wed, 23 Aug 2017 04:48:14 +0000 (14:48 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 30 Aug 2017 08:21:49 +0000 (10:21 +0200)
commit5ed70f7db9afe5e4e5cc1fa2239676e3b2d2c5b2
tree717bd5f926645c325ae1d979857d51046947f2a3
parent8b053290ee20cce2a082c80fd2e654e3e533f802
cifs: return ENAMETOOLONG for overlong names in cifs_open()/cifs_lookup()

commit d3edede29f74d335f81d95a4588f5f136a9f7dcf upstream.

Add checking for the path component length and verify it is <= the maximum
that the server advertizes via FileFsAttributeInformation.

With this patch cifs.ko will now return ENAMETOOLONG instead of ENOENT
when users to access an overlong path.

To test this, try to cd into a (non-existing) directory on a CIFS share
that has a too long name:
cd /mnt/aaaaaaaaaaaaaaa...

and it now should show a good error message from the shell:
bash: cd: /mnt/aaaaaaaaaaaaaaaa...aaaaaa: File name too long

rh bz 1153996

Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: Steve French <smfrench@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/cifs/dir.c