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
[ Upstream commit df14afe ]

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: Sasha Levin <sashal@kernel.org>
  • Loading branch information
namjaejeon authored and gregkh committed Jan 5, 2024
1 parent 6d4e21e commit 30a1344
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions fs/smb/server/smb2pdu.c
Original file line number Diff line number Diff line change
Expand Up @@ -5559,7 +5559,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 @@ -5592,8 +5592,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 30a1344

Please sign in to comment.