From patchwork Wed Oct 4 22:55:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Popov X-Patchwork-Id: 9985865 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 9E168602B8 for ; Wed, 4 Oct 2017 22:55:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9036328C27 for ; Wed, 4 Oct 2017 22:55:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 852D528C3E; Wed, 4 Oct 2017 22:55:53 +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 6E5C628C27 for ; Wed, 4 Oct 2017 22:55:51 +0000 (UTC) Received: (qmail 11289 invoked by uid 550); 4 Oct 2017 22:55:27 -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 10154 invoked from network); 4 Oct 2017 22:55:25 -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=k+Xor7MdRQ/F+Vru095p3JqLE9jEZDmqmwZYJFYGqE0=; b=WZuIIOUZmtXe5xPw94jc5x1s0VYhUbp2eQVLFPZWchTFhwXa899vZm711FFivlYv3U DnaPGn0BytFrMhUjIbsq72+M71yEbhuQumsgEvXZ9/IJA4vUIM0L7WmSWwcTOFRaLZVv raxmcvLz3k+bEBiRCQmjxY3W06x5im3kl2lAadoE9IzGUgXDahh9JywJNIfypjcJDBpB OB4zdCb+Qf0MlA0fgSS+hxy8faD8bC12tNEX/FrCwdbv+6BjM/VWif5dhm+h4FFQvNWu 4WHcAIALgLHQueXGJx5q9P8EbGRq48wDIf9UQeMOSadI9dmd1lx9ptyzq/mlO2XccDep w32w== X-Gm-Message-State: AMCzsaU5gUGfpddqJEyFxbgs0kCf4Sd3GR21Xh9r8RDRPICI6Oeqzd/u wKyOQu+vkV75+yhTBCkDDWu8SA== X-Google-Smtp-Source: AOwi7QBHeP1SOtnMFCxRXopPqPEJSMj/R+ChKM4sTg779inxPgtH3raJmwEH7N/eRl4Q0O4tr7RUCg== X-Received: by 10.25.204.148 with SMTP id c142mr4696560lfg.49.1507157713740; Wed, 04 Oct 2017 15:55:13 -0700 (PDT) From: Alexander Popov To: kernel-hardening@lists.openwall.com, keescook@chromium.org, pageexec@freemail.hu, spender@grsecurity.net, tycho@docker.com, Laura Abbott , Mark Rutland , Ard Biesheuvel , Andy Lutomirski , x86@kernel.org, alex.popov@linux.com Date: Thu, 5 Oct 2017 01:55:03 +0300 Message-Id: <1507157703-14972-4-git-send-email-alex.popov@linux.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507157703-14972-1-git-send-email-alex.popov@linux.com> References: <1507157703-14972-1-git-send-email-alex.popov@linux.com> Subject: [kernel-hardening] [PATCH RFC v4 3/3] doc: self-protection: Add information about STACKLEAK feature 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 60c8bd8..9693a90 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 --------------------- @@ -287,11 +292,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 --------------------