* [PATCH][V2][cifs-next] cifs: fix dereference on ses before it is null checked
@ 2019-09-02 15:10 Colin King
2019-09-02 19:42 ` Steve French
0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2019-09-02 15:10 UTC (permalink / raw)
To: Steve French, linux-cifs, samba-technical; +Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
The assignment of pointer server dereferences pointer ses, however,
this dereference occurs before ses is null checked and hence we
have a potential null pointer dereference. Fix this by only
dereferencing ses after it has been null checked.
Addresses-Coverity: ("Dereference before null check")
Fixes: 2808c6639104 ("cifs: add new debugging macro cifs_server_dbg")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
fs/cifs/smb2pdu.c | 11 ++++++++---
fs/cifs/transport.c | 3 ++-
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index dbc6ef50dd45..0e92983de0b7 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -2759,8 +2759,10 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,
else
return -EIO;
+ if (!ses)
+ return -EIO;
server = ses->server;
- if (!ses || !(server))
+ if (!server)
return -EIO;
if (smb3_encryption_required(tcon))
@@ -3058,13 +3060,16 @@ query_info(const unsigned int xid, struct cifs_tcon *tcon,
int rc = 0;
int resp_buftype = CIFS_NO_BUFFER;
struct cifs_ses *ses = tcon->ses;
- struct TCP_Server_Info *server = ses->server;
+ struct TCP_Server_Info *server;
int flags = 0;
bool allocated = false;
cifs_dbg(FYI, "Query Info\n");
- if (!ses || !(server))
+ if (!ses)
+ return -EIO;
+ server = ses->server;
+ if (!server)
return -EIO;
if (smb3_encryption_required(tcon))
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
index 0d60bd2f4dca..a90bd4d75b4d 100644
--- a/fs/cifs/transport.c
+++ b/fs/cifs/transport.c
@@ -1242,12 +1242,13 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses,
struct kvec iov = { .iov_base = in_buf, .iov_len = len };
struct smb_rqst rqst = { .rq_iov = &iov, .rq_nvec = 1 };
struct cifs_credits credits = { .value = 1, .instance = 0 };
- struct TCP_Server_Info *server = ses->server;
+ struct TCP_Server_Info *server;
if (ses == NULL) {
cifs_dbg(VFS, "Null smb session\n");
return -EIO;
}
+ server = ses->server;
if (server == NULL) {
cifs_dbg(VFS, "Null tcp session\n");
return -EIO;
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH][V2][cifs-next] cifs: fix dereference on ses before it is null checked
2019-09-02 15:10 [PATCH][V2][cifs-next] cifs: fix dereference on ses before it is null checked Colin King
@ 2019-09-02 19:42 ` Steve French
0 siblings, 0 replies; 2+ messages in thread
From: Steve French @ 2019-09-02 19:42 UTC (permalink / raw)
To: Colin King; +Cc: Steve French, CIFS, samba-technical, kernel-janitors, LKML
Tentatively merged into cifs-2.6.git pending additional testing
Kicked off buildbot with rc7+patches in cifs for-next
See http://smb3-test-rhel-75.southcentralus.cloudapp.azure.com/#/builders/2/builds/247
On Mon, Sep 2, 2019 at 10:33 AM Colin King <colin.king@canonical.com> wrote:
>
> From: Colin Ian King <colin.king@canonical.com>
>
> The assignment of pointer server dereferences pointer ses, however,
> this dereference occurs before ses is null checked and hence we
> have a potential null pointer dereference. Fix this by only
> dereferencing ses after it has been null checked.
>
> Addresses-Coverity: ("Dereference before null check")
> Fixes: 2808c6639104 ("cifs: add new debugging macro cifs_server_dbg")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> fs/cifs/smb2pdu.c | 11 ++++++++---
> fs/cifs/transport.c | 3 ++-
> 2 files changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
> index dbc6ef50dd45..0e92983de0b7 100644
> --- a/fs/cifs/smb2pdu.c
> +++ b/fs/cifs/smb2pdu.c
> @@ -2759,8 +2759,10 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,
> else
> return -EIO;
>
> + if (!ses)
> + return -EIO;
> server = ses->server;
> - if (!ses || !(server))
> + if (!server)
> return -EIO;
>
> if (smb3_encryption_required(tcon))
> @@ -3058,13 +3060,16 @@ query_info(const unsigned int xid, struct cifs_tcon *tcon,
> int rc = 0;
> int resp_buftype = CIFS_NO_BUFFER;
> struct cifs_ses *ses = tcon->ses;
> - struct TCP_Server_Info *server = ses->server;
> + struct TCP_Server_Info *server;
> int flags = 0;
> bool allocated = false;
>
> cifs_dbg(FYI, "Query Info\n");
>
> - if (!ses || !(server))
> + if (!ses)
> + return -EIO;
> + server = ses->server;
> + if (!server)
> return -EIO;
>
> if (smb3_encryption_required(tcon))
> diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
> index 0d60bd2f4dca..a90bd4d75b4d 100644
> --- a/fs/cifs/transport.c
> +++ b/fs/cifs/transport.c
> @@ -1242,12 +1242,13 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses,
> struct kvec iov = { .iov_base = in_buf, .iov_len = len };
> struct smb_rqst rqst = { .rq_iov = &iov, .rq_nvec = 1 };
> struct cifs_credits credits = { .value = 1, .instance = 0 };
> - struct TCP_Server_Info *server = ses->server;
> + struct TCP_Server_Info *server;
>
> if (ses == NULL) {
> cifs_dbg(VFS, "Null smb session\n");
> return -EIO;
> }
> + server = ses->server;
> if (server == NULL) {
> cifs_dbg(VFS, "Null tcp session\n");
> return -EIO;
> --
> 2.20.1
>
--
Thanks,
Steve
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-09-02 19:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-02 15:10 [PATCH][V2][cifs-next] cifs: fix dereference on ses before it is null checked Colin King
2019-09-02 19:42 ` Steve French
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).