From patchwork Fri Nov 22 11:25:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 11257863 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AF0F714DB for ; Fri, 22 Nov 2019 11:26:35 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7B8FF20679 for ; Fri, 22 Nov 2019 11:26:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="HUDNTw52" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7B8FF20679 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 13E2F6B04C3; Fri, 22 Nov 2019 06:26:34 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 050176B04C4; Fri, 22 Nov 2019 06:26:34 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E57D76B04C5; Fri, 22 Nov 2019 06:26:33 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0118.hostedemail.com [216.40.44.118]) by kanga.kvack.org (Postfix) with ESMTP id C63056B04C3 for ; Fri, 22 Nov 2019 06:26:33 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id 6F6FB180AD82F for ; Fri, 22 Nov 2019 11:26:33 +0000 (UTC) X-FDA: 76183685466.16.grade40_908471b034b2b X-Spam-Summary: 2,0,0,dde21d33fe2c2a30,d41d8cd98f00b204,36mxxxqykcmctyvqr4t11tyr.p1zyv07a-zzx8npx.14t@flex--glider.bounces.google.com,:vegard.nossum@oracle.com:dvyukov@google.com:sergey.senozhatsky@gmail.com:arnd@arndb.de:aryabinin@virtuozzo.com::glider@google.com:viro@zeniv.linux.org.uk:adilger.kernel@dilger.ca:akpm@linux-foundation.org:andreyknvl@google.com:luto@kernel.org:ard.biesheuvel@linaro.org:hch@infradead.org:hch@lst.de:darrick.wong@oracle.com:davem@davemloft.net:dmitry.torokhov@gmail.com:ebiggers@google.com:edumazet@google.com:ericvh@gmail.com:gregkh@linuxfoundation.org:harry.wentland@amd.com:herbert@gondor.apana.org.au:iii@linux.ibm.com:mingo@elte.hu:jasowang@redhat.com:axboe@kernel.dk:m.szyprowski@samsung.com:elver@google.com:mark.rutland@arm.com:martin.petersen@oracle.com:schwidefsky@de.ibm.com:willy@infradead.org:mst@redhat.com:monstr@monstr.eu:pmladek@suse.com:cai@lca.pw:rdunlap@infradead.org:robin.murphy@arm.com:rostedt@goodmis.org:tiwai@suse.com:tytso@mit.edu :tglx@li X-HE-Tag: grade40_908471b034b2b X-Filterd-Recvd-Size: 5426 Received: from mail-qt1-f202.google.com (mail-qt1-f202.google.com [209.85.160.202]) by imf19.hostedemail.com (Postfix) with ESMTP for ; Fri, 22 Nov 2019 11:26:32 +0000 (UTC) Received: by mail-qt1-f202.google.com with SMTP id h15so4419227qtn.6 for ; Fri, 22 Nov 2019 03:26:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=r6y4EMIcBGt5hQSuRpY0IuAq6odB1OSfmVZeiqUPevY=; b=HUDNTw52Z2QiifXxuWZrrErUzDwJOTgVXmDSYb8P7ULtE7sbqS+Jgsg7oGhy87Bn7m 1efuffsixHnLSpOtU7TEiJWrqMcW42E7THdDt2JDqpngxDbiNWHqtjRDs+9SUZK2VwEz F1nRjWEydjT7eL1+P0TMjIi1Ka3si56o1UdcBvlt+0DLOwlfJVdxIsuUNtHURyltjDFk cORP2sUzQ+VEWyYslo3gp1hcd0tTzrFQsQo4XOJEwB+l+EsefYIA3NmOwdXgaZTklPjL eMvSYInQpDL0l1Xiq5Y19/A+NnCSSfSYUfhL4iw7w2VDBpiEyG53c+iWltWpDRy3UXx0 nRLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=r6y4EMIcBGt5hQSuRpY0IuAq6odB1OSfmVZeiqUPevY=; b=QywFZt+2Tv6iiLB1o/LxoRWkuWqj/qzpY9aFwjL68ufyna1NHefb1pkl89jZQHhUfZ gxw0opBbZW8pRJ/58Bw48VyyYx/JQnOCbMpdWOzqTn/AwH1V7Ow10yZBOUHnhvGllFUc JsXNs+M4OVrDay6gKp+hVfl+2gwNdhiAoZG4qfvyk6yGrV/PYYnXWjbH+3U77CpYxL5P lU7/zQsc9x579WkgoPZSdVwcDoVOt7RMiArTgeimCz4f2KXUgkLe+588l8J2WlvbwDHo qLE0f0HPzgCyT+vu5nPMgyvsECEGzL3alYCmJYliSHyJ4s2oEaJ8FUNGmyhWILa65xs/ ELJw== X-Gm-Message-State: APjAAAUBHKAvrUwW4Tt9frgqR9ebCm326Ui2G/XT13fZl0+kwkfJMmMQ 3pGazKRjLkeaX04PhG1tXLwac/XUNyM= X-Google-Smtp-Source: APXvYqwsmqFn51m2mf+K1j16MEgUmUqjtBDPhysNPQw5pwVdxB7vXwtLo5RvEPZYay6acmfu90zEg8fCrz0= X-Received: by 2002:ac8:5557:: with SMTP id o23mr13874217qtr.378.1574421992246; Fri, 22 Nov 2019 03:26:32 -0800 (PST) Date: Fri, 22 Nov 2019 12:25:47 +0100 In-Reply-To: <20191122112621.204798-1-glider@google.com> Message-Id: <20191122112621.204798-3-glider@google.com> Mime-Version: 1.0 References: <20191122112621.204798-1-glider@google.com> X-Mailer: git-send-email 2.24.0.432.g9d3f5f5b63-goog Subject: [PATCH RFC v3 02/36] stackdepot: build with -fno-builtin From: glider@google.com To: Vegard Nossum , Dmitry Vyukov , Sergey Senozhatsky , Arnd Bergmann , Andrey Ryabinin , linux-mm@kvack.org Cc: glider@google.com, viro@zeniv.linux.org.uk, adilger.kernel@dilger.ca, akpm@linux-foundation.org, andreyknvl@google.com, luto@kernel.org, ard.biesheuvel@linaro.org, hch@infradead.org, hch@lst.de, darrick.wong@oracle.com, davem@davemloft.net, dmitry.torokhov@gmail.com, ebiggers@google.com, edumazet@google.com, ericvh@gmail.com, gregkh@linuxfoundation.org, harry.wentland@amd.com, herbert@gondor.apana.org.au, iii@linux.ibm.com, mingo@elte.hu, jasowang@redhat.com, axboe@kernel.dk, m.szyprowski@samsung.com, elver@google.com, mark.rutland@arm.com, martin.petersen@oracle.com, schwidefsky@de.ibm.com, willy@infradead.org, mst@redhat.com, monstr@monstr.eu, pmladek@suse.com, cai@lca.pw, rdunlap@infradead.org, robin.murphy@arm.com, rostedt@goodmis.org, tiwai@suse.com, tytso@mit.edu, tglx@linutronix.de, gor@linux.ibm.com, wsa@the-dreams.de 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: Clang may replace stackdepot_memcmp() with a call to instrumented bcmp(), which is exactly what we wanted to avoid creating stackdepot_memcmp(). Building the file with -fno-builtin prevents such optimizations. Signed-off-by: Alexander Potapenko To: Alexander Potapenko Cc: Vegard Nossum Cc: Dmitry Vyukov Cc: Sergey Senozhatsky Cc: Arnd Bergmann Cc: Andrey Ryabinin Cc: linux-mm@kvack.org --- This patch was previously called "stackdepot: prevent Clang from optimizing away stackdepot_memcmp()". v3: - use -fno-builtin instead of a barrier Change-Id: I4495b617b15c0ab003a61c1f0d54d0026fa8b144 --- lib/Makefile | 4 ++++ lib/stackdepot.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Makefile b/lib/Makefile index c5892807e06f..58a3e1b1a868 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -215,6 +215,10 @@ obj-$(CONFIG_SG_POOL) += sg_pool.o obj-$(CONFIG_STMP_DEVICE) += stmp_device.o obj-$(CONFIG_IRQ_POLL) += irq_poll.o +# stackdepot.c should not be instrumented or call instrumented functions. +# Prevent the compiler from calling builtins like memcmp() or bcmp() from this +# file. +CFLAGS_stackdepot.o += -fno-builtin obj-$(CONFIG_STACKDEPOT) += stackdepot.o KASAN_SANITIZE_stackdepot.o := n KCOV_INSTRUMENT_stackdepot.o := n diff --git a/lib/stackdepot.c b/lib/stackdepot.c index 0bc6182bc7a6..6d1123123e56 100644 --- a/lib/stackdepot.c +++ b/lib/stackdepot.c @@ -163,7 +163,7 @@ int stackdepot_memcmp(const unsigned long *u1, const unsigned long *u2, unsigned int n) { for ( ; n-- ; u1++, u2++) { - if (*u1 != *u2) + if ((*u1) != (*u2)) return 1; } return 0;