Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4375264ybp; Mon, 14 Oct 2019 03:45:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqzfAlLSWsZ2ogn9k5EX+R2ob2+p3A/udg0IKHgLMiK11Hiu17jpi9L2JzIdPEDmI/LFd6x2 X-Received: by 2002:a05:6402:2042:: with SMTP id bc2mr27788807edb.12.1571049905756; Mon, 14 Oct 2019 03:45:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571049905; cv=none; d=google.com; s=arc-20160816; b=wmV4BfqoevHIcBB7razstSSR2AhHKtMZLtjMEOusLTqITabQRI7NVpiN10M42iq/0a WVxxExoqWHSemQ6RoYmehAwWm58BZJfWYjIv8E2lZrviTMorQ1B33/2bmt9dNeCfLKvp fS+/gvG/aKEj9eEuvlxknSLuRzW+2hlCSs0Xe4+rmLDA9FEPsYql1knWBKBMUyQmTP0V rGDiKzpKtIx6pQv8JOvpqA0GJy8YfxcbUPemFOQFujsAjxf//EufzF0g+dEWTRE7Tw/7 sy4PfJ1h1TBjrndM285OHHFaZMz0mVIJGyQ8N+4y2sGx09soFqpMJlMz5VEjLHalqWuI Sg6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=/mDM4m3k7JTmmCNbrikY7f4R5yxUjjMcbeuuaXG2YC4=; b=NvbHi70RFTJtKqE8AB1CllNGcltVXXWmtzjPkJ4Gw5ydLbHRY+6MSqL7MeS7da0DPz PyaIyeIVmfbJHlKXq6LzH+yPdfAT4P/0teoKLhQanKV6Plor3W94tpc+BZmghLzFt1A2 HWhh6P8XB2NEKNVA+Zvu947SwWUhZn9LTWOrRwlC8FsCsODOMvIm75bx3Ym7CHsEQCJ2 EVQJCxoDHsIDgxd5Qf6w8ElAIiq7YVDSjt6ItdUd1WtKv0b2Qc89iSny24RAkw+zr9W2 mvNzN4HFrYOMSJjSJUJy73HFK7okwH9Ly+7d8JfWzr5oFhgsndGNo+Mz3qZc9Mp74Li4 +qAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=rV8Qq1zT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p40si13840492eda.334.2019.10.14.03.44.42; Mon, 14 Oct 2019 03:45:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=rV8Qq1zT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731640AbfJNKlR (ORCPT + 99 others); Mon, 14 Oct 2019 06:41:17 -0400 Received: from mail-qk1-f196.google.com ([209.85.222.196]:40703 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731461AbfJNKlQ (ORCPT ); Mon, 14 Oct 2019 06:41:16 -0400 Received: by mail-qk1-f196.google.com with SMTP id y144so15413154qkb.7 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=axFb5MzcEM87ZQWJ9nxAta6f3myFyB54lv53PHbDIpML2PCSK1Sd8tQhmmHUW9pa2Y 4cy10IfTSe10qfK69fJbysdnNx86Shre+xbZ2MlRSjSCPWixXrOfMAkiQMcLQNROH0lW PQI4/W3utXtsyR4IlzO+aWTQpFwBIRt3iYcXD5BIQDqasf/m4spt5IDW2io8k3PdraOF j4j1qOaOpLt3ooG2fjubT6pEN9GIa7FWUeVOxD3mDeoT662cTTBfFhyrnvWln3oSZBx1 gVBYrf+QVexrzRghA9XOo62Hga2lloJclF3WZCZCxraIhoS4JvXNiGvfbDechuL6pULG bXdg== X-Gm-Message-State: APjAAAX9ZpS/z/0PprdJCDxEdhvspWzweLSlK/KcSUCyso9gqKKqWjRb peNSf0LUaDBYs3qOF2CEfzcmIhHPmYak2HtUXylRkw== 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" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.