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=-3.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT 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 2161BC54FD0 for ; Fri, 24 Apr 2020 14:55:29 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D9EF820767 for ; Fri, 24 Apr 2020 14:55:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=axtens.net header.i=@axtens.net header.b="o941UkGJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D9EF820767 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=axtens.net Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 61EF08E0005; Fri, 24 Apr 2020 10:55:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5D0A58E0003; Fri, 24 Apr 2020 10:55:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4E62F8E0005; Fri, 24 Apr 2020 10:55:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0237.hostedemail.com [216.40.44.237]) by kanga.kvack.org (Postfix) with ESMTP id 358A98E0003 for ; Fri, 24 Apr 2020 10:55:28 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id EC8DE181AC9B6 for ; Fri, 24 Apr 2020 14:55:27 +0000 (UTC) X-FDA: 76743047094.07.spark62_12911bd5f185a X-HE-Tag: spark62_12911bd5f185a X-Filterd-Recvd-Size: 4213 Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by imf50.hostedemail.com (Postfix) with ESMTP for ; Fri, 24 Apr 2020 14:55:27 +0000 (UTC) Received: by mail-pf1-f196.google.com with SMTP id z1so3223892pfn.3 for ; Fri, 24 Apr 2020 07:55:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axtens.net; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=SjOuEDkqyCRoQlGb4r++HBQnM1FePx7k1uf7opXgrlY=; b=o941UkGJMnQqHReNMbWxL/s8PxT7Ra9iuzc/rTi6AtklATqfagsoaIerZb4wffLG5F lzSYOwYjYqPg3Xr5oTHI3OmLPnG6PAnnyTlhS+ek2U1Qsq/ysubk0lB2C76z+e8TYhQY jay5eaXVB37EXo7ewPRPv1NSQ0Narw4Ofb/gw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=SjOuEDkqyCRoQlGb4r++HBQnM1FePx7k1uf7opXgrlY=; b=RtYltyDcU94D2hoRD1u/Ta1OkNf/iDvqc/A1Y70Vn5ukYA7XLcjduiHPwyHI07b+R8 8eTmsv8xZ3/m/zhHz0tfmVTQOjC5pKJOzr/gQXIeB2tTqW3CXlF5p2kvH1IzJrsGhkWr jWW07seyO7z8XODwXfGwO4cqL1Rg38leDpWxxrCtyN/QtAQH619xkfHPLhNfu7hGU8R4 SjZ2dl8lgNuk5VtSyORXImb4aqB5c30xNiAmiBtoyQBxWqQTAHnuM+Xv7yvwjZatbFVW Ru9Gd71QpzZoXfBd9y3dAQVO+A6jR+bFY9CgvRcv444UNu+9eL84+u+NUDv8zutwzNHl N2Lg== X-Gm-Message-State: AGi0PuYK8v68Sy82Bxu2jjxC6hvfudG3m4o2Ttb5eRpbWCC6UHxwEAQB SgwS492SgPb0vglCiqYru2k9Ww== X-Google-Smtp-Source: APiQypJAVNWj9fQBBoGPE6iHQ7TBvOGfksNnnLg93WhVg5iX6nGDZGRRCvk/6/c/yw/BgNehCNS2pw== X-Received: by 2002:aa7:92cc:: with SMTP id k12mr7642619pfa.184.1587740126558; Fri, 24 Apr 2020 07:55:26 -0700 (PDT) Received: from localhost (2001-44b8-1113-6700-fd06-aa7b-7508-4b8b.static.ipv6.internode.on.net. [2001:44b8:1113:6700:fd06:aa7b:7508:4b8b]) by smtp.gmail.com with ESMTPSA id 1sm5978738pff.151.2020.04.24.07.55.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2020 07:55:25 -0700 (PDT) From: Daniel Axtens To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, kasan-dev@googlegroups.com Cc: dvyukov@google.com, christophe.leroy@c-s.fr, Daniel Axtens Subject: [PATCH v4 0/2] Fix some incompatibilites between KASAN and FORTIFY_SOURCE Date: Sat, 25 Apr 2020 00:55:19 +1000 Message-Id: <20200424145521.8203-1-dja@axtens.net> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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: 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 tha= n emit a function call that goes out to a KASAN-instrumented implementation. The patches address each reason in turn. v4: Drop patch 3, it turns out I created that issue in patch 1! Include David's Tested-by. 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 (2): kasan: stop tests being eliminated as dead code with FORTIFY_SOURCE string.h: fix incompatibility between FORTIFY_SOURCE and KASAN include/linux/string.h | 60 +++++++++++++++++++++++++++++++++--------- lib/test_kasan.c | 29 +++++++++++++------- 2 files changed, 67 insertions(+), 22 deletions(-) --=20 2.20.1