[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAH2r5mu-C3v-Tuz5E8nAFepSiCyypvw0g4ctTt2fjx1vEb9a_A@mail.gmail.com>
Date: Tue, 5 Jan 2021 22:11:41 -0600
From: Steve French <smfrench@...il.com>
To: Nathan Chancellor <natechancellor@...il.com>
Cc: trix@...hat.com, Steve French <sfrench@...ba.org>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Aurélien Aptel <aaptel@...e.com>,
Paulo Alcantara <palcantara@...e.de>,
CIFS <linux-cifs@...r.kernel.org>,
samba-technical <samba-technical@...ts.samba.org>,
LKML <linux-kernel@...r.kernel.org>,
clang-built-linux@...glegroups.com
Subject: Re: [PATCH] cifs: check pointer before freeing
merged into cifs-2.6.git for-next and added cc:stable
On Tue, Jan 5, 2021 at 5:08 PM Nathan Chancellor
<natechancellor@...il.com> wrote:
>
> On Tue, Jan 05, 2021 at 12:21:26PM -0800, trix@...hat.com wrote:
> > From: Tom Rix <trix@...hat.com>
> >
> > clang static analysis reports this problem
> >
> > dfs_cache.c:591:2: warning: Argument to kfree() is a constant address
> > (18446744073709551614), which is not memory allocated by malloc()
> > kfree(vi);
> > ^~~~~~~~~
> >
> > In dfs_cache_del_vol() the volume info pointer 'vi' being freed
> > is the return of a call to find_vol(). The large constant address
> > is find_vol() returning an error.
> >
> > Add an error check to dfs_cache_del_vol() similar to the one done
> > in dfs_cache_update_vol().
> >
> > Fixes: 54be1f6c1c37 ("cifs: Add DFS cache routines")
> > Signed-off-by: Tom Rix <trix@...hat.com>
>
> Reviewed-by: Nathan Chancellor <natechancellor@...il.com>
>
> > ---
> > fs/cifs/dfs_cache.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/fs/cifs/dfs_cache.c b/fs/cifs/dfs_cache.c
> > index 6ad6ba5f6ebe..0fdb0de7ff86 100644
> > --- a/fs/cifs/dfs_cache.c
> > +++ b/fs/cifs/dfs_cache.c
> > @@ -1260,7 +1260,8 @@ void dfs_cache_del_vol(const char *fullpath)
> > vi = find_vol(fullpath);
> > spin_unlock(&vol_list_lock);
> >
> > - kref_put(&vi->refcnt, vol_release);
> > + if (!IS_ERR(vi))
> > + kref_put(&vi->refcnt, vol_release);
> > }
> >
> > /**
> > --
> > 2.27.0
> >
--
Thanks,
Steve
Powered by blists - more mailing lists