From: He Ying <heying24@huawei.com>
To: <davidcomponentone@gmail.com>, <keescook@chromium.org>
Cc: <arnd@arndb.de>, <gregkh@linuxfoundation.org>,
<linux-kernel@vger.kernel.org>,
Yang Guang <yang.guang5@zte.com.cn>,
Zeal Robot <zealci@zte.com.cn>
Subject: Re: [PATCH lkdtm] lkdtm: Fix reference preceded by free
Date: Fri, 22 Oct 2021 11:38:27 +0800 [thread overview]
Message-ID: <6eaee800-a88d-6810-ef0e-724e7e846e80@huawei.com> (raw)
In-Reply-To: <20211022012832.10644-1-yang.guang5@zte.com.cn>
在 2021/10/22 9:28, davidcomponentone@gmail.com 写道:
> From: Yang Guang <yang.guang5@zte.com.cn>
>
> The coccinelle check report:
> ./drivers/misc/lkdtm/heap.c:115:7-11:
> ERROR: reference preceded by free on line 112
> Moving the "kfree(base)" after using place to fix it.
Look at the name of the function "lkdtm_READ_AFTER_FREE". It's meant to
use after free to test something.
>
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Yang Guang <yang.guang5@zte.com.cn>
> ---
> drivers/misc/lkdtm/heap.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/misc/lkdtm/heap.c b/drivers/misc/lkdtm/heap.c
> index 8a92f5a800fa..4c6341e7bdca 100644
> --- a/drivers/misc/lkdtm/heap.c
> +++ b/drivers/misc/lkdtm/heap.c
> @@ -109,8 +109,6 @@ void lkdtm_READ_AFTER_FREE(void)
> base[offset] = *val;
> pr_info("Value in memory before free: %x\n", base[offset]);
>
> - kfree(base);
> -
> pr_info("Attempting bad read from freed memory\n");
> saw = base[offset];
> if (saw != *val) {
> @@ -121,6 +119,7 @@ void lkdtm_READ_AFTER_FREE(void)
> pr_expected_config_param(CONFIG_INIT_ON_FREE_DEFAULT_ON, "init_on_free");
> }
>
> + kfree(base);
> kfree(val);
> }
>
prev parent reply other threads:[~2021-10-22 3:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-22 1:28 davidcomponentone
[not found] ` <CA+E=9osPJSZDqHkd0j-JwL7Tufs3vG3tRtG94+Rsdo4kVgBjAg@mail.gmail.com>
2021-10-22 3:36 ` Kees Cook
2021-10-22 3:38 ` He Ying [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=6eaee800-a88d-6810-ef0e-724e7e846e80@huawei.com \
--to=heying24@huawei.com \
--cc=arnd@arndb.de \
--cc=davidcomponentone@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=yang.guang5@zte.com.cn \
--cc=zealci@zte.com.cn \
/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®