From patchwork Wed Mar 28 19:57:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Popov X-Patchwork-Id: 10313999 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3A440605B4 for ; Wed, 28 Mar 2018 19:59:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A57F29598 for ; Wed, 28 Mar 2018 19:59:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2801D27EED; Wed, 28 Mar 2018 19:59:29 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED 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 BB5A429598 for ; Wed, 28 Mar 2018 19:59:21 +0000 (UTC) Received: (qmail 21724 invoked by uid 550); 28 Mar 2018 19:58:00 -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 Received: (qmail 20458 invoked from network); 28 Mar 2018 19:57:48 -0000 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=yG8WI64gesDH1VxIEInLOPqtrbP0jMf2nhukF0giWlE=; b=h6K1BzM8R7WwFHs/Ijkj1gHi6wV+RTPAgASubISwiJVg4YUov5oc2gkzY230drFuYo bh8cEXSme0MnFX5IK2tvlw3Q0/YqanJT2Vb1Ux4IZqNlzidKteW/5Xoq8Bois+H00V3D HlxOgmui9QFBsUgPCdUDPFj+aie/fQEodGPYJeNOvnjO2WaPrSbemYgJaikT99hWo7G5 mGHjyv1urBUBmgZHwBTmrTRqzoxbhO2CVE1n0Ydpaah+1NcQdSAO5lLdKElQQXNTvP52 S0GbDp6zbUjcN/JUhiWHwiTHJsG9Nu/IooqfQ5xq+CB83JOdMy7a/TrCf/An3uU2VVN7 kCQw== X-Gm-Message-State: AElRT7GnZSZ1uhqyejHX/J2wtWQYXSCzemN+DwKR5RNwnKeCrHGvh74C J9psvUeLhA24uw4izdPSsUdrXmZJ X-Google-Smtp-Source: AIpwx4+TM5REWsPPokQvJYysJ1DvIivEkI6Vqv2zN1mq2GyNj64AyfPqFaqIHXhHh3X4rZpYdRNuSQ== X-Received: by 2002:a19:e202:: with SMTP id z2-v6mr3442579lfg.58.1522267056715; Wed, 28 Mar 2018 12:57:36 -0700 (PDT) From: Alexander Popov To: kernel-hardening@lists.openwall.com, Kees Cook , PaX Team , Brad Spengler , Ingo Molnar , Andy Lutomirski , Tycho Andersen , Laura Abbott , Mark Rutland , Ard Biesheuvel , Borislav Petkov , Richard Sandiford , Thomas Gleixner , "H . Peter Anvin" , Peter Zijlstra , "Dmitry V . Levin" , Emese Revfy , Jonathan Corbet , Andrey Ryabinin , "Kirill A . Shutemov" , Thomas Garnier , Andrew Morton , Alexei Starovoitov , Josef Bacik , Masami Hiramatsu , Nicholas Piggin , Al Viro , "David S . Miller" , Ding Tianhong , David Woodhouse , Josh Poimboeuf , Steven Rostedt , Dominik Brodowski , Juergen Gross , Greg Kroah-Hartman , Dan Williams , Dave Hansen , Mathias Krause , Vikas Shivappa , Kyle Huey , Dmitry Safonov , Will Deacon , Arnd Bergmann , Florian Weimer , Boris Lukashev , x86@kernel.org, linux-kernel@vger.kernel.org, alex.popov@linux.com Subject: [PATCH RFC v10 6/6] doc: self-protection: Add information about STACKLEAK feature Date: Wed, 28 Mar 2018 22:57:12 +0300 Message-Id: <1522267032-6603-7-git-send-email-alex.popov@linux.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522267032-6603-1-git-send-email-alex.popov@linux.com> References: <1522267032-6603-1-git-send-email-alex.popov@linux.com> X-Virus-Scanned: ClamAV using ClamSMTP Add information about STACKLEAK feature to "Stack depth overflow" and "Memory poisoning" sections of self-protection.rst. Signed-off-by: Alexander Popov --- Documentation/security/self-protection.rst | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/Documentation/security/self-protection.rst b/Documentation/security/self-protection.rst index 0f53826..b685f18 100644 --- a/Documentation/security/self-protection.rst +++ b/Documentation/security/self-protection.rst @@ -165,10 +165,15 @@ Stack depth overflow A less well understood attack is using a bug that triggers the kernel to consume stack memory with deep function calls or large stack allocations. With this attack it is possible to write beyond the end of -the kernel's preallocated stack space and into sensitive structures. Two -important changes need to be made for better protections: moving the -sensitive thread_info structure elsewhere, and adding a faulting memory -hole at the bottom of the stack to catch these overflows. +the kernel's preallocated stack space and into sensitive structures. +The combination of the following measures gives better protection: + +* moving the sensitive thread_info structure off the stack + (``CONFIG_THREAD_INFO_IN_TASK``); +* adding a faulting memory hole at the bottom of the stack to catch + these overflows (``CONFIG_VMAP_STACK``); +* runtime checking that alloca() calls don't overstep the stack boundary + (``CONFIG_GCC_PLUGIN_STACKLEAK``). Heap memory integrity --------------------- @@ -302,11 +307,11 @@ sure structure holes are cleared. Memory poisoning ---------------- -When releasing memory, it is best to poison the contents (clear stack on -syscall return, wipe heap memory on a free), to avoid reuse attacks that -rely on the old contents of memory. This frustrates many uninitialized -variable attacks, stack content exposures, heap content exposures, and -use-after-free attacks. +When releasing memory, it is best to poison the contents, to avoid reuse +attacks that rely on the old contents of memory. E.g., clear stack on a +syscall return (``CONFIG_GCC_PLUGIN_STACKLEAK``), wipe heap memory on a +free. This frustrates many uninitialized variable attacks, stack content +exposures, heap content exposures, and use-after-free attacks. Destination tracking --------------------