提交 d7890b17 编写于 作者: P Paulo Alcantara 提交者: Zheng Zengkai

cifs: prevent NULL deref in cifs_compose_mount_options()

stable inclusion
from stable-5.10.53
commit e58c162789becede894d3e94c0ce6695a2ef5796
bugzilla: 175574 https://gitee.com/openeuler/kernel/issues/I4DTUX

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=e58c162789becede894d3e94c0ce6695a2ef5796

--------------------------------

[ Upstream commit 03313d1c ]

The optional @ref parameter might contain an NULL node_name, so
prevent dereferencing it in cifs_compose_mount_options().

Addresses-Coverity: 1476408 ("Explicit null dereferenced")
Signed-off-by: NPaulo Alcantara (SUSE) <pc@cjr.nz>
Signed-off-by: NSteve French <stfrench@microsoft.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 55237fd2
...@@ -151,6 +151,9 @@ char *cifs_compose_mount_options(const char *sb_mountdata, ...@@ -151,6 +151,9 @@ char *cifs_compose_mount_options(const char *sb_mountdata,
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
if (ref) { if (ref) {
if (WARN_ON_ONCE(!ref->node_name || ref->path_consumed < 0))
return ERR_PTR(-EINVAL);
if (strlen(fullpath) - ref->path_consumed) { if (strlen(fullpath) - ref->path_consumed) {
prepath = fullpath + ref->path_consumed; prepath = fullpath + ref->path_consumed;
/* skip initial delimiter */ /* skip initial delimiter */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册