Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Jul 2021 16:25:49 GMT
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 44de1834b53f - main - nfsclient: Avoid copying uninitialized bytes into statfs
Message-ID:  <202107151625.16FGPnnT046260@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=44de1834b53f4654cc2f6d76406f5705f8167927

commit 44de1834b53f4654cc2f6d76406f5705f8167927
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2021-07-15 16:18:17 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2021-07-15 16:18:17 +0000

    nfsclient: Avoid copying uninitialized bytes into statfs
    
    hst will be nul-terminated but the remaining space in the buffer is left
    uninitialized.  Avoid copying the entire buffer to ensure that
    uninitialized bytes are not leaked via statfs(2).
    
    Reported by:    KMSAN
    Reviewed by:    rmacklem
    MFC after:      2 weeks
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D31167
---
 sys/fs/nfsclient/nfs_clvfsops.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/fs/nfsclient/nfs_clvfsops.c b/sys/fs/nfsclient/nfs_clvfsops.c
index 57eae3f1f1cf..6323451adf54 100644
--- a/sys/fs/nfsclient/nfs_clvfsops.c
+++ b/sys/fs/nfsclient/nfs_clvfsops.c
@@ -1594,7 +1594,7 @@ mountnfs(struct nfs_args *argp, struct mount *mp, struct sockaddr *nam,
 	nmp->nm_fhsize = argp->fhsize;
 	if (nmp->nm_fhsize > 0)
 		bcopy((caddr_t)argp->fh, (caddr_t)nmp->nm_fh, argp->fhsize);
-	bcopy(hst, mp->mnt_stat.f_mntfromname, MNAMELEN);
+	strlcpy(mp->mnt_stat.f_mntfromname, hst, MNAMELEN);
 	nmp->nm_nam = nam;
 	/* Set up the sockets and per-host congestion */
 	nmp->nm_sotype = argp->sotype;



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