From: Trond Myklebust trondmy@gmail.com
mainline inclusion from mainline-v5.6-rc1 commit 3803d6721baff3d5dd6cd6b8c7294e54d124bc41 category: bugfix bugzilla: NA CVE: NA
--------------------------------
The directory strings stored in the readdir cache may be used with printk(), so it is better to ensure they are nul-terminated.
Signed-off-by: Trond Myklebust trond.myklebust@hammerspace.com Reviewed-by: Benjamin Coddington bcodding@redhat.com Signed-off-by: Anna Schumaker Anna.Schumaker@Netapp.com Signed-off-by: Zhang Xiaoxu zhangxiaoxu5@huawei.com Reviewed-by: Zhang Yi yi.zhang@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- fs/nfs/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index d1234a7a42144..3908ff8672af1 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -198,7 +198,7 @@ static int nfs_readdir_make_qstr(struct qstr *string, const char *name, unsigned int len) { string->len = len; - string->name = kmemdup(name, len, GFP_KERNEL); + string->name = kmemdup_nul(name, len, GFP_KERNEL); if (string->name == NULL) return -ENOMEM; /*