diff mbox series

cifs: use the correct max-length for dentry_path_raw()

Message ID 20210810063355.721945-1-lsahlber@redhat.com
State New
Headers show
Series cifs: use the correct max-length for dentry_path_raw() | expand

Commit Message

Ronnie Sahlberg Aug. 10, 2021, 6:33 a.m. UTC
RHBZ: 1972502

PATH_MAX is 4096 but PAGE_SIZE can be >4096 on some architectures
such as ppc and would thus write beyond the end of the actual object.

CC: Stable <stable@vger.kernel.org>
Reported-by: Xiaoli Feng <xifeng@redhat.com>
Suggested-by: Brian foster <bfoster@redhat.com>
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
---
 fs/cifs/dir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Paulo Alcantara Aug. 10, 2021, 2:44 p.m. UTC | #1
Ronnie Sahlberg <lsahlber@redhat.com> writes:

> RHBZ: 1972502
>
> PATH_MAX is 4096 but PAGE_SIZE can be >4096 on some architectures
> such as ppc and would thus write beyond the end of the actual object.
>
> CC: Stable <stable@vger.kernel.org>
> Reported-by: Xiaoli Feng <xifeng@redhat.com>
> Suggested-by: Brian foster <bfoster@redhat.com>
> Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
> ---
>  fs/cifs/dir.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
diff mbox series

Patch

diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index 79402ca0ddfa..5f8a302ffcb2 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -100,7 +100,7 @@  build_path_from_dentry_optional_prefix(struct dentry *direntry, void *page,
 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH)
 		pplen = cifs_sb->prepath ? strlen(cifs_sb->prepath) + 1 : 0;
 
-	s = dentry_path_raw(direntry, page, PAGE_SIZE);
+	s = dentry_path_raw(direntry, page, PATH_MAX);
 	if (IS_ERR(s))
 		return s;
 	if (!s[1])	// for root we want "", not "/"