From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19120ECE587 for ; Mon, 14 Oct 2019 10:41:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C420B20663 for ; Mon, 14 Oct 2019 10:41:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="rV8Qq1zT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C420B20663 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 72F8C8E000B; Mon, 14 Oct 2019 06:41:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6E0BA8E0001; Mon, 14 Oct 2019 06:41:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5F7298E000B; Mon, 14 Oct 2019 06:41:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0086.hostedemail.com [216.40.44.86]) by kanga.kvack.org (Postfix) with ESMTP id 3C6548E0001 for ; Mon, 14 Oct 2019 06:41:17 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id DDDF352B8 for ; Mon, 14 Oct 2019 10:41:16 +0000 (UTC) X-FDA: 76042048152.24.cub77_6275587bfa863 X-HE-Tag: cub77_6275587bfa863 X-Filterd-Recvd-Size: 4778 Received: from mail-qk1-f194.google.com (mail-qk1-f194.google.com [209.85.222.194]) by imf39.hostedemail.com (Postfix) with ESMTP for ; Mon, 14 Oct 2019 10:41:16 +0000 (UTC) Received: by mail-qk1-f194.google.com with SMTP id 4so15423936qki.6 for ; Mon, 14 Oct 2019 03:41:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/mDM4m3k7JTmmCNbrikY7f4R5yxUjjMcbeuuaXG2YC4=; b=rV8Qq1zTj/mqAQLscWN+hHRGrpBFQz7Ai/S3kljTyK03CLIDKNz06WjsMkRDVsYsx0 RmVY8DA/49HQb7MYt5x9SFGsNGllrTYgA8Ovt2566vYlaypERUdHVWTBPNcITZVSoLmo BGGZvgkak+eoLS+ItIs2jU/vbtOhRpj+wNGDv8oBZJdDAJhqswAdYxHnPw9z+5TtnNqK WYHnSi4riwQnvt4Bk49k83Uzw02VE3C3tXXs928y+Z31zQLVLT6QFlyN4xyMpMJx3tXg zk1r/piFdMHJZHMmL3EqZg0iQhcTu7aeT0UUv+nGv2eBB4sH+J4WwMGr/gOSrEWl0zZv tI3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/mDM4m3k7JTmmCNbrikY7f4R5yxUjjMcbeuuaXG2YC4=; b=idT+iO9AXVcuxf1x8xWI4UhCQZZACoMbLBzi1csGzFO0AzKfguZ+tkNixNyMDDFW91 +R/+0kPKn/aLpx5LNdlEIjl3S2OqTimwD83/nrs2uMx00xA8jjPJmi8eWXJYb9EHIsaY ls8uG5saY2S5zwCkKDWk4ivgEmjbDYZl0XAuyinDktGMmRcnnHV2V3Gfe7CCdComxpt2 uxtKERF8J0wGM9SDlb2qjvOHEV6NL6+iMKXUCmYRrevlXdDGXbEDYapeDOA0o37+sMpu Ba6xMt7UpQMVICxWGIeKm4fF7SIw8LYdAR3a1QNo25h3rCyEoOluXTvkrAn2QqFNabMG j+Wg== X-Gm-Message-State: APjAAAV1q8cejT7SwoZDfsd1fTg2RdtTtCwD6ZVh3tz+rDZ+snNAsfg3 upyHA0fMCozKbAIUpseuRYZB8VE6y+RlhyKqeJr9YQ== X-Google-Smtp-Source: APXvYqwwwX+oLoGrnp0iO7Ph5lNAvWQm97LqjGAYSHmqnVtQ7XHdlMS8rQnbz4rzIgZfjST0xq01CRRxqEDpLybjQrI= X-Received: by 2002:a37:4a87:: with SMTP id x129mr28464725qka.43.1571049675564; Mon, 14 Oct 2019 03:41:15 -0700 (PDT) MIME-Version: 1.0 References: <20191014103654.17982-1-walter-zh.wu@mediatek.com> In-Reply-To: <20191014103654.17982-1-walter-zh.wu@mediatek.com> From: Dmitry Vyukov Date: Mon, 14 Oct 2019 12:41:04 +0200 Message-ID: Subject: Re: [PATCH 2/2] kasan: add test for invalid size in memmove To: Walter Wu Cc: Andrey Ryabinin , Alexander Potapenko , Matthias Brugger , kasan-dev , Linux-MM , LKML , Linux ARM , linux-mediatek@lists.infradead.org, wsd_upstream Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Oct 14, 2019 at 12:37 PM Walter Wu wrote: > > Test size is negative numbers in memmove in order to verify > whether it correctly get KASAN report. > > Signed-off-by: Walter Wu Reviewed-by: Dmitry Vyukov Thanks! > --- > lib/test_kasan.c | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) > > diff --git a/lib/test_kasan.c b/lib/test_kasan.c > index 49cc4d570a40..06942cf585cc 100644 > --- a/lib/test_kasan.c > +++ b/lib/test_kasan.c > @@ -283,6 +283,23 @@ static noinline void __init kmalloc_oob_in_memset(void) > kfree(ptr); > } > > +static noinline void __init kmalloc_memmove_invalid_size(void) > +{ > + char *ptr; > + size_t size = 64; > + > + pr_info("invalid size in memmove\n"); > + ptr = kmalloc(size, GFP_KERNEL); > + if (!ptr) { > + pr_err("Allocation failed\n"); > + return; > + } > + > + memset((char *)ptr, 0, 64); > + memmove((char *)ptr, (char *)ptr + 4, -2); > + kfree(ptr); > +} > + > static noinline void __init kmalloc_uaf(void) > { > char *ptr; > @@ -773,6 +790,7 @@ static int __init kmalloc_tests_init(void) > kmalloc_oob_memset_4(); > kmalloc_oob_memset_8(); > kmalloc_oob_memset_16(); > + kmalloc_memmove_invalid_size(); > kmalloc_uaf(); > kmalloc_uaf_memset(); > kmalloc_uaf2(); > -- > 2.18.0 > > -- > You received this message because you are subscribed to the Google Groups "kasan-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an email to kasan-dev+unsubscribe@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/kasan-dev/20191014103654.17982-1-walter-zh.wu%40mediatek.com.