Skip to content

Commit

Permalink
ksmbd: fix uninitialized pointer read in smb2_create_link()
Browse files Browse the repository at this point in the history
commit df14afe upstream.

There is a case that file_present is true and path is uninitialized.
This patch change file_present is set to false by default and set to
true when patch is initialized.

Fixes: 74d7970 ("ksmbd: fix racy issue from using ->d_parent and ->d_name")
Reported-by: Coverity Scan <scan-admin@coverity.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Namjae Jeon authored and Greg Kroah-Hartman committed Jun 28, 2023
1 parent c526418 commit bf8355e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions fs/ksmbd/smb2pdu.c
Original file line number Diff line number Diff line change
Expand Up @@ -5560,7 +5560,7 @@ static int smb2_create_link(struct ksmbd_work *work,
{
char *link_name = NULL, *target_name = NULL, *pathname = NULL;
struct path path;
bool file_present = true;
bool file_present = false;
int rc;

if (buf_len < (u64)sizeof(struct smb2_file_link_info) +
Expand Down Expand Up @@ -5593,8 +5593,8 @@ static int smb2_create_link(struct ksmbd_work *work,
if (rc) {
if (rc != -ENOENT)
goto out;
file_present = false;
}
} else
file_present = true;

if (file_info->ReplaceIfExists) {
if (file_present) {
Expand Down

0 comments on commit bf8355e

Please sign in to comment.