From patchwork Fri May 19 21:26:35 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: 9738197 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 291C2601C2 for ; Fri, 19 May 2017 21:28:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D74628474 for ; Fri, 19 May 2017 21:28:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 00ADD284B3; Fri, 19 May 2017 21:28: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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8D58B28474 for ; Fri, 19 May 2017 21:28:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=QLDfEY+qc51g2ccCFDOityamtSXXAKJ81u63mDj8ODA=; b=LNxxYpAbG8yv50c8HvMaV1kicn QqeU6t/NjlxZVm43ClfVAAq/p7JVi0D7bXZW+Vom7rtfLuA+UECpB/+td7JGvlBP0pS3ZfvcNDVm7 wYOa2Fc6U8Kn2DBbevEG5EhKgPDes795OORhp/avsOIbQWj/rF0gy0+73N9bAGhu2oUZgp6i1/CEk AWlI4AtlQ/rEKys7TR5zGn9fuwfgA25KIr9WCLT1h0tmmiWncgFSBZVGbyMP2z0gPolesj4z41gxs UrscvFi8JvYhcaEVfNDwyzoC3RfvasbjTciHnCnzhpMEuBxOj/H4xLShNwEdP43vurMYQOOsPY7lv 5ysWdtnw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dBpRr-0002M5-Ed; Fri, 19 May 2017 21:28:35 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dBpR1-0001TK-HD for linux-arm-kernel@bombadil.infradead.org; Fri, 19 May 2017 21:27:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=F5eRWL9xbPdoe5YsXAFWNnHqpM69o1FtssxLo5SXe5w=; b=u0D3HApE9EiPJuNCNXdHN8QpD XrfTUy7XqcHL+rSky44zgOjgGkgxEf5oMzOYjg+0dmDjoM7FRIJ2/zE2zI3vyxyx7bq2+adCp22f7 4bZB0dJSDiAOWtDwWZzRktfoBYX9PmQcrcqb1OvtUhp4O1E+orHrwXUM7UO/8VMZ3yCMWD4FGsT6+ VszbqWUMlX1rhSPU1A5mwiY0WdqXWCrTf1Obcv6XLZRE0o+XMkpWf+9+onWA+hQnEHXmcwhorO/Vc C/jBa1F5NdNO1M+Bngc29Ph2Hz+vaEJN+SihFHNyJJjND0u5zJfthoYZ40O5OH4WEMdvZ+hmBPSaO /d3/qTz3Q==; Received: from shelob.surriel.com ([96.67.55.147]) by casper.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dBpQw-0000Mw-Jj for linux-arm-kernel@lists.infradead.org; Fri, 19 May 2017 21:27:42 +0000 Received: from [2603:3005:d05:2b00:224:e8ff:fe38:995c] (helo=annuminas.surriel.com) by shelob.surriel.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1dBpQ0-000492-QO; Fri, 19 May 2017 17:26:40 -0400 Received: from annuminas.surriel.com (localhost.localdomain [127.0.0.1]) by annuminas.surriel.com (8.15.2/8.14.5) with ESMTP id v4JLQeGS000765; Fri, 19 May 2017 17:26:40 -0400 Received: (from riel@localhost) by annuminas.surriel.com (8.15.2/8.15.2/Submit) id v4JLQeOj000764; Fri, 19 May 2017 17:26:40 -0400 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 Subject: [PATCH 4/5] arm64: ascii armor the arm64 boot init stack canary Date: Fri, 19 May 2017 17:26:35 -0400 Message-Id: <20170519212636.30440-5-riel@redhat.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170519212636.30440-1-riel@redhat.com> References: <20170519212636.30440-1-riel@redhat.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170519_222738_769936_BA4241E1 X-CRM114-Status: UNSURE ( 8.81 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tytso@mit.edu, keescook@chromium.org, ysato@users.sourceforge.jp, linux-sh@vger.kernel.org, catalin.marinas@arm.com, x86@kernel.org, luto@amacapital.net, danielmicay@gmail.com, hpa@zytor.com, mingo@kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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 PaX/grsecurity. Signed-off-by: Rik van Riel --- arch/arm64/include/asm/stackprotector.h | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/include/asm/stackprotector.h b/arch/arm64/include/asm/stackprotector.h index fe5e287dc56b..b86a0865ddf1 100644 --- a/arch/arm64/include/asm/stackprotector.h +++ b/arch/arm64/include/asm/stackprotector.h @@ -30,6 +30,7 @@ static __always_inline void boot_init_stack_canary(void) /* Try to get a semi random initial value. */ get_random_bytes(&canary, sizeof(canary)); canary ^= LINUX_VERSION_CODE; + canary &= CANARY_MASK; current->stack_canary = canary; __stack_chk_guard = current->stack_canary;