Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp7030965ybi; Thu, 13 Jun 2019 08:25:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqy3FVFZ+xHLSTmgD4ad4WGPmPRmtPTDo62f6oYQSnIv9gShvbwaxC9gHWGEo+zGt9BGwfZO X-Received: by 2002:a17:90a:2008:: with SMTP id n8mr6097024pjc.4.1560439521879; Thu, 13 Jun 2019 08:25:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560439521; cv=none; d=google.com; s=arc-20160816; b=xeAZQYG5wcoZ2xU909acBSQAohKMMpf1G/HoZfDBrk0BitxC/QZHbmOSPJ/Jh962hJ n8U14ebcOztq+1doYB6BFGGemTaUjOUnaewIuBvI0l41QM0riHVzp7W+lVQq4DYK3hO7 S0CHifaHarpkG5e7xrtNmOXzETkPyJ0ItYQsV6cAaeW+Wg9PrptDouUYA9nF0XW1Y4Jw htPSY4LZ7G8HaE0etcswFsBatwNk1nDUf+5LZ4sG7ZP7XDv+ybexNPBH6XloGfT1kL7b yov5fNqUNC2vkyd7a5GsOV7NDhR5qG8gN6MAPgQanydPSvU/P67pBLP0wZr1OVo3hILL vjTQ== 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=odgDtuS4Pz09+zc7wgiVUlzZ7gbjNw0joU36SILLNfo=; b=MlX1UX/cYk4XIx+l0N7w8Ijf1MH/LgUfIQwXLLtBSGBeVwJdTRCo94FxJuHr5Zdf7c In2xmL9VvUmK+gIqEkIISH/YLtO+Kd3Ws0cOKaX2e0/gXtldQO2VE82Y0B1PDQ+7oQFN EtIBZJiDBGjlVxHZYRYOnhGNUBhSqtPMoyb72j/IFiUl0I01Wjdj11Pyx4E7y+W+eiK0 8lrhcxiJ+T5YhiofR8LN4Z3uq5TLUsMh+kSisw0kHx7DWJ7F0MyjV26RGPUIsVKiaXsH 7hRPGU8ygjmqFJ6jcm7YVyZEdG4p8t/SBqe7e2VIThc/3KravpyEFIcEoS+m2PKrZV5k Nd7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=bHlwS3VP; 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 w5si63344pgh.430.2019.06.13.08.25.06; Thu, 13 Jun 2019 08:25:21 -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=bHlwS3VP; 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 S1731972AbfFMPWq (ORCPT + 99 others); Thu, 13 Jun 2019 11:22:46 -0400 Received: from mail-oi1-f194.google.com ([209.85.167.194]:41357 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731969AbfFMMfa (ORCPT ); Thu, 13 Jun 2019 08:35:30 -0400 Received: by mail-oi1-f194.google.com with SMTP id g7so11090594oia.8 for ; Thu, 13 Jun 2019 05:35:29 -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=odgDtuS4Pz09+zc7wgiVUlzZ7gbjNw0joU36SILLNfo=; b=bHlwS3VP2wcXGi3xrYIozsGT3vGUQfd+kcxKhlv9uBlcTERbuhQhhF0kEMY7ho5Hej uVpGjc6DyuIOGUHDvn1P8gVzlLSf9MUF0DVRM/o94o3wbGbpzqz6m4CYglgA6sT/gkpo mj6FXp8dvOKeKFiVAeLOFyPm75BMOIpquGdY28vCs0CmJlT1RaV/eCWCfsiIyldSOd4z RZrTm9Gll7iFkdl3vS1NSCNhQh/rwSYneUdTpBXlsyqqzTgXGWCTTS5hCi4WUGXUcWAw /gjS1zgIMPGcztWl/Qo6cVIEnA0H+dPh4xh40fc9EMjQWUA0M+Ek7A+5ua5bNZH9pz3U FBnQ== 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=odgDtuS4Pz09+zc7wgiVUlzZ7gbjNw0joU36SILLNfo=; b=ihELQVqJWjX7MzGeOObv/erjc98gwsXi6XM9Eu5UKIUNg1ezqcQeb6Mza4lo1og9Nv QYUCnDmu9t7yk20TCyiYaP76KNA9QlF3NGM/wo3d9b+1jvpdrCTiIpI1sD0t2IhOOfao YBy1YPHD/+1xbMVFzdIFgfjmX1iRTXPpCpZg62IR5B0M3/ALcPf4kk+W1NxdEWStlwJA pCaeHT/ktJxhSUBCB4KTDSkJrx6NxImf6Y06qzWATXdti6VCMSLlTn6EtkefQP7SVrH9 F+hLosHdTArlCeAl/gyr7aIG4dAPFmHGE++FQfrWtcQqvBPo7LPaUTZ6EHLUsJBf8d8e 9srg== X-Gm-Message-State: APjAAAWJLMxmzmFjPkTkBM7sztaP0LiwsTgzZ0PUku+OGUmgJRlXxojB WMXGZQdwN4xdlPISwEXhNlQlQxZeMkZsEJONV2z7HQ== X-Received: by 2002:aca:530f:: with SMTP id h15mr2627831oib.155.1560429328714; Thu, 13 Jun 2019 05:35:28 -0700 (PDT) MIME-Version: 1.0 References: <20190531150828.157832-1-elver@google.com> <20190531150828.157832-2-elver@google.com> <5c35bc08-749f-dbc4-09d0-fcf14b1da1b3@virtuozzo.com> In-Reply-To: <5c35bc08-749f-dbc4-09d0-fcf14b1da1b3@virtuozzo.com> From: Marco Elver Date: Thu, 13 Jun 2019 14:35:17 +0200 Message-ID: Subject: Re: [PATCH v3 1/3] lib/test_kasan: Add bitops tests To: Andrey Ryabinin Cc: Peter Zijlstra , Dmitry Vyukov , Alexander Potapenko , Andrey Konovalov , Mark Rutland , "H. Peter Anvin" , Jonathan Corbet , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "the arch/x86 maintainers" , Arnd Bergmann , Josh Poimboeuf , "open list:DOCUMENTATION" , LKML , linux-arch , kasan-dev 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 Thanks, I've sent v4. On Thu, 13 Jun 2019 at 12:49, Andrey Ryabinin wrote: > > > > On 5/31/19 6:08 PM, Marco Elver wrote: > > This adds bitops tests to the test_kasan module. In a follow-up patch, > > support for bitops instrumentation will be added. > > > > Signed-off-by: Marco Elver > > --- > > Changes in v3: > > * Use kzalloc instead of kmalloc. > > * Use sizeof(*bits). > > > > Changes in v2: > > * Use BITS_PER_LONG. > > * Use heap allocated memory for test, as newer compilers (correctly) > > warn on OOB stack access. > > --- > > lib/test_kasan.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++-- > > 1 file changed, 72 insertions(+), 3 deletions(-) > > > > diff --git a/lib/test_kasan.c b/lib/test_kasan.c > > index 7de2702621dc..1ef9702327d2 100644 > > --- a/lib/test_kasan.c > > +++ b/lib/test_kasan.c > > @@ -11,16 +11,17 @@ > > > > #define pr_fmt(fmt) "kasan test: %s " fmt, __func__ > > > > +#include > > #include > > +#include > > #include > > -#include > > #include > > +#include > > +#include > > #include > > #include > > #include > > #include > > -#include > > -#include > > > > /* > > * Note: test functions are marked noinline so that their names appear in > > @@ -623,6 +624,73 @@ static noinline void __init kasan_strings(void) > > strnlen(ptr, 1); > > } > > > > +static noinline void __init kasan_bitops(void) > > +{ > > + long *bits = kzalloc(sizeof(*bits), GFP_KERNEL); > > It would be safer to do kzalloc(sizeof(*bits) + 1, GFP_KERNEL) and change tests accordingly to: set_bit(BITS_PER_LONG + 1, bits) ... > kmalloc will internally round up allocation to 16-bytes, so we won't be actually corrupting someone elses memory. > > > > + if (!bits) > > + return; > > + > > + pr_info("within-bounds in set_bit"); > > + set_bit(0, bits); > > + > > + pr_info("within-bounds in set_bit"); > > + set_bit(BITS_PER_LONG - 1, bits); > > > I'd remove these two. There are plenty of within bounds set_bit() in the kernel so they are well tested already. > > -- > 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 post to this group, send email to kasan-dev@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/kasan-dev/5c35bc08-749f-dbc4-09d0-fcf14b1da1b3%40virtuozzo.com. > For more options, visit https://groups.google.com/d/optout.