lkml.org 
[lkml]   [2021]   [Jul]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH AUTOSEL 5.4 51/51] cifs: prevent NULL deref in cifs_compose_mount_options()
    Date
    From: Paulo Alcantara <pc@cjr.nz>

    [ Upstream commit 03313d1c3a2f086bb60920607ab79ac8f8578306 ]

    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: Paulo Alcantara (SUSE) <pc@cjr.nz>
    Signed-off-by: Steve French <stfrench@microsoft.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    fs/cifs/cifs_dfs_ref.c | 3 +++
    1 file changed, 3 insertions(+)

    diff --git a/fs/cifs/cifs_dfs_ref.c b/fs/cifs/cifs_dfs_ref.c
    index cc3ada12848d..42125601ebb1 100644
    --- a/fs/cifs/cifs_dfs_ref.c
    +++ b/fs/cifs/cifs_dfs_ref.c
    @@ -151,6 +151,9 @@ char *cifs_compose_mount_options(const char *sb_mountdata,
    return ERR_PTR(-EINVAL);

    if (ref) {
    + if (WARN_ON_ONCE(!ref->node_name || ref->path_consumed < 0))
    + return ERR_PTR(-EINVAL);
    +
    if (strlen(fullpath) - ref->path_consumed) {
    prepath = fullpath + ref->path_consumed;
    /* skip initial delimiter */
    --
    2.30.2
    \
     
     \ /
      Last update: 2021-07-14 22:11    [W:4.121 / U:0.376 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site