* [PATCH RESEND] cifs: file: initialize oparms.reconnect before using it
@ 2013-07-29 8:58 Andi Shyti
2013-07-29 13:32 ` Jeff Layton
0 siblings, 1 reply; 5+ messages in thread
From: Andi Shyti @ 2013-07-29 8:58 UTC (permalink / raw)
To: smfrench-Re5JQEeQqe8AvxtiuMwx3w
Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, mikko.rapeli-X3B1VOXEql0,
jlayton-H+wXaHxf7aLQT0dZR+AlfA, pshilovsky-eUNUBHrolfbYtjvyW6yDsg
In the cifs_reopen_file function, if the following statement is
asserted:
(tcon->unix_ext && cap_unix(tcon->ses) &&
(CIFS_UNIX_POSIX_PATH_OPS_CAP &
(tcon->fsUnixInfo.Capability)))
and we succeed to open with cifs_posix_open, the function jumps
to the label reopen_success and checks for oparms.reconnect
which is not initialized.
To avoid this the oparms structure initialization is anticipated
before the if statement.
This issue has been reported by scan.coverity.com
Signed-off-by: Andi Shyti <andi-ahk0KpmfxKRAfugRpC6u6w@public.gmane.org>
---
fs/cifs/file.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 1e57f36..fbeaf45 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -632,6 +632,15 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush)
else
oplock = 0;
+ oparms.tcon = tcon;
+ oparms.cifs_sb = cifs_sb;
+ oparms.desired_access = desired_access;
+ oparms.create_options = create_options;
+ oparms.disposition = disposition;
+ oparms.path = full_path;
+ oparms.fid = &cfile->fid;
+ oparms.reconnect = true;
+
if (tcon->unix_ext && cap_unix(tcon->ses) &&
(CIFS_UNIX_POSIX_PATH_OPS_CAP &
le64_to_cpu(tcon->fsUnixInfo.Capability))) {
@@ -663,15 +672,6 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush)
if (server->ops->get_lease_key)
server->ops->get_lease_key(inode, &cfile->fid);
- oparms.tcon = tcon;
- oparms.cifs_sb = cifs_sb;
- oparms.desired_access = desired_access;
- oparms.create_options = create_options;
- oparms.disposition = disposition;
- oparms.path = full_path;
- oparms.fid = &cfile->fid;
- oparms.reconnect = true;
-
/*
* Can not refresh inode by passing in file_info buf to be returned by
* CIFSSMBOpen and then calling get_inode_info with returned buf since
--
1.8.3.2
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH RESEND] cifs: file: initialize oparms.reconnect before using it
2013-07-29 8:58 [PATCH RESEND] cifs: file: initialize oparms.reconnect before using it Andi Shyti
@ 2013-07-29 13:32 ` Jeff Layton
[not found] ` <20130729093241.437315e1-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Jeff Layton @ 2013-07-29 13:32 UTC (permalink / raw)
To: Andi Shyti; +Cc: smfrench, linux-cifs, linux-kernel, mikko.rapeli, pshilovsky
On Mon, 29 Jul 2013 10:58:13 +0200
Andi Shyti <andi@etezian.org> wrote:
> In the cifs_reopen_file function, if the following statement is
> asserted:
>
> (tcon->unix_ext && cap_unix(tcon->ses) &&
> (CIFS_UNIX_POSIX_PATH_OPS_CAP &
> (tcon->fsUnixInfo.Capability)))
>
> and we succeed to open with cifs_posix_open, the function jumps
> to the label reopen_success and checks for oparms.reconnect
> which is not initialized.
>
> To avoid this the oparms structure initialization is anticipated
> before the if statement.
>
> This issue has been reported by scan.coverity.com
>
> Signed-off-by: Andi Shyti <andi@etezian.org>
> ---
> fs/cifs/file.c | 18 +++++++++---------
> 1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/fs/cifs/file.c b/fs/cifs/file.c
> index 1e57f36..fbeaf45 100644
> --- a/fs/cifs/file.c
> +++ b/fs/cifs/file.c
> @@ -632,6 +632,15 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush)
> else
> oplock = 0;
>
> + oparms.tcon = tcon;
> + oparms.cifs_sb = cifs_sb;
> + oparms.desired_access = desired_access;
> + oparms.create_options = create_options;
This patch just moves the brokenness around. You're
setting .desired_access here to an unintialized variable.
create_options also looks like it may potentially be wrong at this
point.
It may be that the code won't trip over these bugs in its current form,
but it's not really doing much to "future-proof" it. I think this
function needs a bit more refactoring instead of increasing the level
of spaghetti.
> + oparms.disposition = disposition;
> + oparms.path = full_path;
> + oparms.fid = &cfile->fid;
> + oparms.reconnect = true;
> +
> if (tcon->unix_ext && cap_unix(tcon->ses) &&
> (CIFS_UNIX_POSIX_PATH_OPS_CAP &
> le64_to_cpu(tcon->fsUnixInfo.Capability))) {
> @@ -663,15 +672,6 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush)
> if (server->ops->get_lease_key)
> server->ops->get_lease_key(inode, &cfile->fid);
>
> - oparms.tcon = tcon;
> - oparms.cifs_sb = cifs_sb;
> - oparms.desired_access = desired_access;
> - oparms.create_options = create_options;
> - oparms.disposition = disposition;
> - oparms.path = full_path;
> - oparms.fid = &cfile->fid;
> - oparms.reconnect = true;
> -
> /*
> * Can not refresh inode by passing in file_info buf to be returned by
> * CIFSSMBOpen and then calling get_inode_info with returned buf since
--
Jeff Layton <jlayton@redhat.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-07-29 20:20 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-29 8:58 [PATCH RESEND] cifs: file: initialize oparms.reconnect before using it Andi Shyti
2013-07-29 13:32 ` Jeff Layton
[not found] ` <20130729093241.437315e1-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org>
2013-07-29 16:35 ` Andi Shyti
2013-07-29 18:04 ` [PATCH v2] " Andi Shyti
[not found] ` <1375121075-11239-1-git-send-email-andi-ahk0KpmfxKRAfugRpC6u6w@public.gmane.org>
2013-07-29 20:20 ` Jeff Layton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox