Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 7 Aug 2023 14:24:14 GMT
From:      Dmitry Chagin <dchagin@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 4e15e32a60b6 - stable/13 - linux(4): Properly allocate buffer for kern_getdirentries in readdir
Message-ID:  <202308071424.377EOE5q025802@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by dchagin:

URL: https://cgit.FreeBSD.org/src/commit/?id=4e15e32a60b601f6e9b8eae7902ff8e958a62933

commit 4e15e32a60b601f6e9b8eae7902ff8e958a62933
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2023-07-18 21:44:15 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2023-08-07 14:22:58 +0000

    linux(4): Properly allocate buffer for kern_getdirentries in readdir
    
    Looks like prior to ino64 project the size of the struct linux_dirent
    was greater (or equal) to the size of the native struct dirent so the
    native dirent fit into the buffer. After ino64 project the size of the
    native struct dirent has increased.
    
    Spotted by gcc12.
    MFC after:              2 weeks
    
    (cherry picked from commit fc1c787aa0157090e765ebba484e6e290e99f177)
---
 sys/compat/linux/linux_file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c
index 3dfea8946e33..0def70e70581 100644
--- a/sys/compat/linux/linux_file.c
+++ b/sys/compat/linux/linux_file.c
@@ -603,7 +603,7 @@ linux_readdir(struct thread *td, struct linux_readdir_args *args)
 	struct l_dirent *linux_dirent;
 	int buflen, error;
 
-	buflen = LINUX_RECLEN(LINUX_NAME_MAX);
+	buflen = sizeof(*bdp);
 	buf = malloc(buflen, M_TEMP, M_WAITOK);
 
 	error = kern_getdirentries(td, args->fd, buf, buflen,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202308071424.377EOE5q025802>