mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Wang Long <long.wanglong@huawei.com>
To: <a.ryabinin@samsung.com>, <ryabinin.a.a@gmail.com>
Cc: <akpm@linux-foundation.org>, <adech.fo@gmail.com>,
	<linux-kernel@vger.kernel.org>, <wanglong@laoqinren.net>,
	<peifeiyue@huawei.com>, <long.wanglong@huawei.com>
Subject: [RFC PATCH] test_kasan: make kmalloc_oob_krealloc_less more correctly
Date: Fri, 21 Aug 2015 08:56:51 +0000	[thread overview]
Message-ID: <1440147411-129581-1-git-send-email-long.wanglong@huawei.com> (raw)

In kmalloc_oob_krealloc_less, I think it is better to test
the size2 boundary.

If we do not call krealloc, the access of position size1 will
still cause out-of-bounds and access of position size2 does not.
After call krealloc, the access of position size2 cause
out-of-bounds. So, use size2 is more correctly.

Signed-off-by: Wang Long <long.wanglong@huawei.com>
---
 lib/test_kasan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/test_kasan.c b/lib/test_kasan.c
index 044c54d..c1efb1b 100644
--- a/lib/test_kasan.c
+++ b/lib/test_kasan.c
@@ -114,7 +114,7 @@ static noinline void __init kmalloc_oob_krealloc_less(void)
 		kfree(ptr1);
 		return;
 	}
-	ptr2[size1] = 'x';
+	ptr2[size2] = 'x';
 	kfree(ptr2);
 }
 
-- 
1.8.3.4


                 reply	other threads:[~2015-08-21  8:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1440147411-129581-1-git-send-email-long.wanglong@huawei.com \
    --to=long.wanglong@huawei.com \
    --cc=a.ryabinin@samsung.com \
    --cc=adech.fo@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peifeiyue@huawei.com \
    --cc=ryabinin.a.a@gmail.com \
    --cc=wanglong@laoqinren.net \
    /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®