From: Mark Rutland <mark.rutland@arm.com>
To: Weikang shi <swkhack@gmail.com>
Cc: keescook@chromium.org, arnd@arndb.de, gregkh@linuxfoundation.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] lkdtm: fix potential use after free
Date: Wed, 24 Apr 2019 13:24:51 +0100 [thread overview]
Message-ID: <20190424122451.GC24502@lakrids.cambridge.arm.com> (raw)
In-Reply-To: <20190424102103.11816-1-swkhack@gmail.com>
On Wed, Apr 24, 2019 at 06:21:03PM +0800, Weikang shi wrote:
> From: swkhack <swkhack@gmail.com>
>
> The function lkdtm_WRITE_AFTER_FREE calls kfree(base) to free the memory
> of base. However, following kfree(base),
> it write the memory which base point to via base[offset] = 0x0abcdef0. This may result in a
> use-after-free bug. This patch moves kfree(base) after the write.
As with lkdtm_READ_AFTER_FREE, this is deliberate, and we should not
make this change.
Thanks,
Mark.
>
> Signed-off-by: swkhack <swkhack@gmail.com>
> ---
> drivers/misc/lkdtm/heap.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/misc/lkdtm/heap.c b/drivers/misc/lkdtm/heap.c
> index 65026d7de..0b9141525 100644
> --- a/drivers/misc/lkdtm/heap.c
> +++ b/drivers/misc/lkdtm/heap.c
> @@ -40,8 +40,8 @@ void lkdtm_WRITE_AFTER_FREE(void)
> pr_info("Allocated memory %p-%p\n", base, &base[offset * 2]);
> pr_info("Attempting bad write to freed memory at %p\n",
> &base[offset]);
> - kfree(base);
> base[offset] = 0x0abcdef0;
> + kfree(base);
> /* Attempt to notice the overwrite. */
> again = kmalloc(len, GFP_KERNEL);
> kfree(again);
> --
> 2.17.1
>
next prev parent reply other threads:[~2019-04-24 12:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-24 10:21 Weikang shi
2019-04-24 12:24 ` Mark Rutland [this message]
-- strict thread matches above, loose matches on Subject: below --
2019-04-24 9:59 Weikang shi
2019-04-24 12:24 ` Mark Rutland
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=20190424122451.GC24502@lakrids.cambridge.arm.com \
--to=mark.rutland@arm.com \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=swkhack@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
all inboxes | Powered by JetHome®