From: Alexander Duyck <alexander.duyck@gmail.com>
To: bsauce <bsauce00@gmail.com>
Cc: "Duyck, Alexander H" <alexander.h.duyck@intel.com>,
Vlastimil Babka <vbabka@suse.cz>, Mel Gorman <mgorman@suse.de>,
h <l.stach@pengutronix.de>,
vdavydov.dev@gmail.com,
Andrew Morton <akpm@linux-foundation.org>,
alex@ghiti.fr, adobriyan@gmail.com, mike.kravetz@oracle.com,
David Rientjes <rientjes@google.com>,
rppt@linux.vnet.ibm.com, Michal Hocko <mhocko@suse.com>,
ksspiers@google.com, linux-mm <linux-mm@kvack.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] fs/seq_file.c: Fix a UAF vulnerability in seq_release()
Date: Wed, 10 Jul 2019 08:01:47 -0700 [thread overview]
Message-ID: <CAKgT0UcWy9kpwhkk9zPbdgj896GzqLV0P7dGMQAUAPr9rURApw@mail.gmail.com> (raw)
In-Reply-To: <1562754389-29217-1-git-send-email-bsauce00@gmail.com>
On Wed, Jul 10, 2019 at 3:26 AM bsauce <bsauce00@gmail.com> wrote:
>
> In seq_release(), 'm->buf' points to a chunk. It is freed but not cleared to null right away. It can be reused by seq_read() or srm_env_proc_write().
> For example, /arch/alpha/kernel/srm_env.c provide several interfaces to userspace, like 'single_release', 'seq_read' and 'srm_env_proc_write'.
> Thus in userspace, one can exploit this UAF vulnerability to escape privilege.
> Even if 'm->buf' is cleared by kmem_cache_free(), one can still create several threads to exploit this vulnerability.
> And 'm->buf' should be cleared right after being freed.
>
> Signed-off-by: bsauce <bsauce00@gmail.com>
So I am pretty sure this "Signed-off-by" line is incorrect. Take a
look in Documentation/process/submitting-patches.rst for more
information. It specifically it calls out that you need to use your
real name, no pseudonyms.
> ---
> fs/seq_file.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/fs/seq_file.c b/fs/seq_file.c
> index abe27ec..de5e266 100644
> --- a/fs/seq_file.c
> +++ b/fs/seq_file.c
> @@ -358,6 +358,7 @@ int seq_release(struct inode *inode, struct file *file)
> {
> struct seq_file *m = file->private_data;
> kvfree(m->buf);
> + m->buf = NULL;
> kmem_cache_free(seq_file_cache, m);
> return 0;
> }
As has already been pointed out we are calling kmem_cache_free on m in
the very next line. As such setting m->buf to NULL would have no
effect as m will be freed and could be reused/overwritten at that
point.
prev parent reply other threads:[~2019-07-10 15:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-10 10:26 bsauce
2019-07-10 10:58 ` Eric Dumazet
2019-07-10 12:25 ` Matthew Wilcox
2019-07-10 15:01 ` Alexander Duyck [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAKgT0UcWy9kpwhkk9zPbdgj896GzqLV0P7dGMQAUAPr9rURApw@mail.gmail.com \
--to=alexander.duyck@gmail.com \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=alex@ghiti.fr \
--cc=alexander.h.duyck@intel.com \
--cc=bsauce00@gmail.com \
--cc=ksspiers@google.com \
--cc=l.stach@pengutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=mhocko@suse.com \
--cc=mike.kravetz@oracle.com \
--cc=rientjes@google.com \
--cc=rppt@linux.vnet.ibm.com \
--cc=vbabka@suse.cz \
--cc=vdavydov.dev@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox