Commit fc434a53 authored by Ronnie Sahlberg's avatar Ronnie Sahlberg Committed by Stefan Bader

cifs: check ntwrk_buf_start for NULL before dereferencing it

BugLink: https://bugs.launchpad.net/bugs/1818813

[ Upstream commit 59a63e47 ]

RHBZ: 1021460

There is an issue where when multiple threads open/close the same directory
ntwrk_buf_start might end up being NULL, causing the call to smbCalcSize
later to oops with a NULL deref.

The real bug is why this happens and why this can become NULL for an
open cfile, which should not be allowed.
This patch tries to avoid a oops until the time when we fix the underlying
issue.
Signed-off-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarJuerg Haefliger <juergh@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent 30d6110f
...@@ -652,7 +652,14 @@ find_cifs_entry(const unsigned int xid, struct cifs_tcon *tcon, loff_t pos, ...@@ -652,7 +652,14 @@ find_cifs_entry(const unsigned int xid, struct cifs_tcon *tcon, loff_t pos,
/* scan and find it */ /* scan and find it */
int i; int i;
char *cur_ent; char *cur_ent;
char *end_of_smb = cfile->srch_inf.ntwrk_buf_start + char *end_of_smb;
if (cfile->srch_inf.ntwrk_buf_start == NULL) {
cifs_dbg(VFS, "ntwrk_buf_start is NULL during readdir\n");
return -EIO;
}
end_of_smb = cfile->srch_inf.ntwrk_buf_start +
server->ops->calc_smb_size( server->ops->calc_smb_size(
cfile->srch_inf.ntwrk_buf_start); cfile->srch_inf.ntwrk_buf_start);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment