From patchwork Wed May 24 15:57:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rik van Riel X-Patchwork-Id: 9746311 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 EE8A9601C2 for ; Wed, 24 May 2017 15:58:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE7C22236A for ; Wed, 24 May 2017 15:58:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D34B828985; Wed, 24 May 2017 15:58:36 +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 1A2E02236A for ; Wed, 24 May 2017 15:58:35 +0000 (UTC) Received: (qmail 32304 invoked by uid 550); 24 May 2017 15:58:19 -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 32224 invoked from network); 24 May 2017 15:58:17 -0000 X-Authentication-Warning: annuminas.surriel.com: riel set sender to riel@redhat.com using -f From: riel@redhat.com To: linux-kernel@vger.kernel.org Cc: danielmicay@gmail.com, tytso@mit.edu, keescook@chromium.org, hpa@zytor.com, luto@amacapital.net, mingo@kernel.org, x86@kernel.org, linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, linux-sh@vger.kernel.org, ysato@users.sourceforge.jp, kernel-hardening@lists.openwall.com Date: Wed, 24 May 2017 11:57:48 -0400 Message-Id: <20170524155751.424-3-riel@redhat.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170524155751.424-1-riel@redhat.com> References: <20170524155751.424-1-riel@redhat.com> Subject: [kernel-hardening] [PATCH 2/5] fork, random: use get_random_canary to set tsk->stack_canary X-Virus-Scanned: ClamAV using ClamSMTP From: Rik van Riel Use the ascii-armor canary to prevent unterminated C string overflows from being able to successfully overwrite the canary, even if they somehow obtain the canary value. Inspired by execshield ascii-armor and Daniel Micay's linux-hardened tree. Signed-off-by: Rik van Riel Acked-by: Kees Cook --- kernel/fork.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/fork.c b/kernel/fork.c index aa1076c5e4a9..b3591e9250a8 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -560,7 +560,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig, int node) set_task_stack_end_magic(tsk); #ifdef CONFIG_CC_STACKPROTECTOR - tsk->stack_canary = get_random_long(); + tsk->stack_canary = get_random_canary(); #endif /*