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=-8.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no 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 DB85BC2BA1A for ; Fri, 24 Apr 2020 06:54:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 96A7B2075A for ; Fri, 24 Apr 2020 06:54:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="XZE878Fe" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 96A7B2075A 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 2A6448E000B; Fri, 24 Apr 2020 02:54:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 256188E0003; Fri, 24 Apr 2020 02:54:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 16C058E000B; Fri, 24 Apr 2020 02:54:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 000068E0003 for ; Fri, 24 Apr 2020 02:54:56 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id A93975830 for ; Fri, 24 Apr 2020 06:54:56 +0000 (UTC) X-FDA: 76741836192.28.oven83_2b23b419a1f31 X-HE-Tag: oven83_2b23b419a1f31 X-Filterd-Recvd-Size: 5331 Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by imf28.hostedemail.com (Postfix) with ESMTP for ; Fri, 24 Apr 2020 06:54:56 +0000 (UTC) Received: by mail-wr1-f67.google.com with SMTP id g13so9391950wrb.8 for ; Thu, 23 Apr 2020 23:54:56 -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=suQ4RDO6wFMF7yNndDjyQyI4nxOZRUEOPb3EJG29NcI=; b=XZE878Fe3CvfJwClJO4OFMDn98hJmO2fQ6LWYqcDaiLo+3JL4q/Zd7jGgD5gmAm40v kKgK9DhGf3dTYA0zKn5Td5ADNw5PentPTkTwcYV75JjFS5DfR43viYXGpnjuWlz/VbUF IEEd8oDeVr+yil+plMELkeB58E6npuPNwf6UQpX2nY24JQ+pcS3uIOCNXjIxHIG7LVNG hfPP43NqUJ5f1R/97apyFagFwdeLBIpJKfRirjSaJE+pdgR10SlRSgPuUmEw9oaMi8uY JAw7Gd44uPR5tHfOA5CeDnZiixqymoffif8LsUBxRYsiutoM7/sr9RrU60VSRUueAeAf Ql7Q== 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=suQ4RDO6wFMF7yNndDjyQyI4nxOZRUEOPb3EJG29NcI=; b=A+zifX4haA/GbcBuhyUwMgLU0vcB4Gtty1VDwxYQY/C+lFi3dA+iuS2NIWBi1buJy0 WspshzgwlWJVM+fwVo91raTwLv8IViF6NKXi2C/n2vlgXxRNhDNUCg+wNST+6ZvvalKX d4Cl94EjnlY0esm+BfzVj6z8CE2adzmAO2RFMnK5q1U8EjA5SV1x26o1mibkUzL7BPYP N9vbHrkozjRf06fZnxgJdsowjc5OzxMZl4U8Hqk3DQvvlIj1ttPAF6XnL01Cmow80rOu aYIBvzvGUq1qYKgI6TV6/DB34apbPiU55WUb20Ym96ftXMinlkvE9Cq1cypa5m7Qe6ob nWPQ== X-Gm-Message-State: AGi0PuZV6+rigqR+0mXFr9b65fP6jZJxRpWcy+klICUaThXlo0KrdHP1 ZeMoYwNSdCIasefSuGZh9DvMzZg8q61DlK+OE96WlA== X-Google-Smtp-Source: APiQypK0X/llYwGmgoAx2FKi2APDvwatdgw54G+xdccmhBBObjobcT63Tc2IwOpD1Vd5LlrpanOhXQqK2MExJ3YVixM= X-Received: by 2002:a05:6000:10c4:: with SMTP id b4mr9377644wrx.203.1587711294889; Thu, 23 Apr 2020 23:54:54 -0700 (PDT) MIME-Version: 1.0 References: <20200423154503.5103-1-dja@axtens.net> In-Reply-To: <20200423154503.5103-1-dja@axtens.net> From: David Gow Date: Fri, 24 Apr 2020 14:54:43 +0800 Message-ID: Subject: Re: [PATCH v3 0/3] Fix some incompatibilites between KASAN and FORTIFY_SOURCE To: Daniel Axtens Cc: Linux Kernel Mailing List , linux-mm@kvack.org, Andrew Morton , kasan-dev , Dmitry Vyukov , christophe.leroy@c-s.fr Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000003, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Apr 23, 2020 at 11:45 PM Daniel Axtens wrote: > > 3 KASAN self-tests fail on a kernel with both KASAN and FORTIFY_SOURCE: > memchr, memcmp and strlen. I have observed this on x86 and powerpc. > > When FORTIFY_SOURCE is on, a number of functions are replaced with > fortified versions, which attempt to check the sizes of the > operands. However, these functions often directly invoke __builtin_foo() > once they have performed the fortify check. > > This breaks things in 2 ways: > > - the three function calls are technically dead code, and can be > eliminated. When __builtin_ versions are used, the compiler can detect > this. > > - Using __builtins may bypass KASAN checks if the compiler decides to > inline it's own implementation as sequence of instructions, rather than > emit a function call that goes out to a KASAN-instrumented > implementation. > > The patches address each reason in turn. Finally, test_memcmp used a > stack array without explicit initialisation, which can sometimes break > too, so fix that up. > > v3: resend with Reviewed-bys, hopefully for inclusion in 5.8. > > v2: - some cleanups, don't mess with arch code as I missed some wrinkles. > - add stack array init (patch 3) > > Daniel Axtens (3): > kasan: stop tests being eliminated as dead code with FORTIFY_SOURCE > string.h: fix incompatibility between FORTIFY_SOURCE and KASAN > kasan: initialise array in kasan_memcmp test > > include/linux/string.h | 60 +++++++++++++++++++++++++++++++++--------- > lib/test_kasan.c | 32 +++++++++++++--------- > 2 files changed, 68 insertions(+), 24 deletions(-) > > -- > 2.20.1 > > -- > 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/20200423154503.5103-1-dja%40axtens.net. Thanks, Daniel! For the series: Tested-by: David Gow (Though I will mirror Dmitry's comment[1] on patch 3 -- I also have a memset() already present in my branch...) I'd been digging into what turns out to be this issue, which we were seeing sporadically[2] with the KUnit port of these tests. v7 of the KUnit port[3] includes your changes, and fixes the issues. Cheers, -- David [1]: https://lkml.org/lkml/2020/4/23/838 [2]: https://lkml.org/lkml/2020/4/18/570 [3]: https://lkml.org/lkml/2020/4/24/80