From patchwork Thu Apr 18 15:42:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 10907663 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3C0FD13B5 for ; Thu, 18 Apr 2019 16:33:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 29C6428D24 for ; Thu, 18 Apr 2019 16:33:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1E0CB28D55; Thu, 18 Apr 2019 16:33:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 508CB28D24 for ; Thu, 18 Apr 2019 16:33:13 +0000 (UTC) Received: (qmail 29752 invoked by uid 550); 18 Apr 2019 16:33:01 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Delivered-To: moderator for kernel-hardening@lists.openwall.com Received: (qmail 9345 invoked from network); 18 Apr 2019 15:42:38 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=c6cte1GA0N3UXNBho2QutaVeM3bmO26Ex5C2Za+9lAo=; b=AR5AIo/FYzzbLDe/+9fNlgTRd1JlWeeO5nMeBPeV46W1GkksSc+qaMrdyXrh5Do9QE JrAtIvsVVJYnQicJlXhQWt6iN8wTEm+Zqyxz68lkMJv3246rOgmqdPmxWUZ3jloUjdIm 1+UN9Hq82jsq3ts0wfHArPjrYSr916UnXKE1cST6NOrZaHvJUxwdwq9X4Pw9HAeX+fbT s2IWr2t82RK50Pd/YxBLEWUZI18RibVNAJ98YbilJoXUdXr/aLXfT+cZ3in1fV5ZC3fE POKFx+4dSkY2PAvonxY4ahEyxLlH7ueLjdZnRhhaZbB3BNqsWAYxHqkgeEMvFGkVGFnC t8cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=c6cte1GA0N3UXNBho2QutaVeM3bmO26Ex5C2Za+9lAo=; b=CX/DSNT1wYUDbfKvVYsA12lfS6q4XzLd3CVHYJxjjeZxPJZANa/zT38QdmO8Y8mm9O lHOqCNlHAHj+iGqEnJ/JKfHJzNmoi5CPJa0uu0aEHXS4HmzbqzhAhKX1Lo2o5MYUqcLc cWY2nZLEZ7RmkCJWfNysE52ehll4ErNa0LTzeks72RBE1Nym3DoNlsVHn/q1q1Xgixo8 w2fzxAGEdvVnAcJrIFFxs45+Nk+CBF58kcTSV1/2tcr9kkDe3U25Yyi22On7IKL7TL7B CnONABA49c/H7Yr3VLhos4flSW3sSvn5/SrUzJzaouwS1ZVYtE6Biv8sWNUgVMoDw5ki u6GQ== X-Gm-Message-State: APjAAAW7KJZZsmdqIp+a5heN9+2BUmSl2il/AOTGV+WEgPvwlCmhugwr rEjiUpfWQoeDXL/j6f/UTg7nvMSLkFY= X-Google-Smtp-Source: APXvYqzlWFUlYk1TyzNFNdkmxacEV9kEkpY+WAHWzfS82vhaZYY6jgkKpDzAz2ONekaghvjOar/WrEYb+3w= X-Received: by 2002:a63:170d:: with SMTP id x13mr90021965pgl.169.1555602145919; Thu, 18 Apr 2019 08:42:25 -0700 (PDT) Date: Thu, 18 Apr 2019 17:42:05 +0200 Message-Id: <20190418154208.131118-1-glider@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.21.0.392.gf8f6787159e-goog Subject: [PATCH 0/3] RFC: add init_allocations=1 boot option From: Alexander Potapenko To: akpm@linux-foundation.org, cl@linux.com, dvyukov@google.com, keescook@chromium.org, labbott@redhat.com Cc: linux-mm@kvack.org, linux-security-module@vger.kernel.org, kernel-hardening@lists.openwall.com X-Virus-Scanned: ClamAV using ClamSMTP Following the recent discussions here's another take at initializing pages and heap objects with zeroes. This is needed to prevent possible information leaks and make the control-flow bugs that depend on uninitialized values more deterministic. The patchset introduces a new boot option, init_allocations, which makes page allocator and SL[AOU]B initialize newly allocated memory. init_allocations=0 doesn't (hopefully) add any overhead to the allocation fast path (no noticeable slowdown on hackbench). With only the the first of the proposed patches the slowdown numbers are: - 1.1% (stdev 0.2%) sys time slowdown building Linux kernel - 3.1% (stdev 0.3%) sys time slowdown on af_inet_loopback benchmark - 9.4% (stdev 0.5%) sys time slowdown on hackbench The second patch introduces a GFP flag that allows to disable initialization for certain allocations. The third page is an example of applying it to af_unix.c, which helps hackbench greatly. Slowdown numbers for the whole patchset are: - 1.8% (stdev 0.8%) on kernel build - 6.5% (stdev 0.2%) on af_inet_loopback - 0.12% (stdev 0.6%) on hackbench Alexander Potapenko (3): mm: security: introduce the init_allocations=1 boot option gfp: mm: introduce __GFP_NOINIT net: apply __GFP_NOINIT to AF_UNIX sk_buff allocations drivers/infiniband/core/uverbs_ioctl.c | 2 +- include/linux/gfp.h | 6 ++++- include/linux/mm.h | 8 +++++++ include/linux/slab_def.h | 1 + include/linux/slub_def.h | 1 + include/net/sock.h | 5 +++++ kernel/kexec_core.c | 4 ++-- mm/dmapool.c | 2 +- mm/page_alloc.c | 18 ++++++++++++++- mm/slab.c | 14 ++++++------ mm/slab.h | 1 + mm/slab_common.c | 15 +++++++++++++ mm/slob.c | 3 ++- mm/slub.c | 9 ++++---- net/core/sock.c | 31 +++++++++++++++++++++----- net/unix/af_unix.c | 13 ++++++----- 16 files changed, 104 insertions(+), 29 deletions(-)