From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752414AbdHPTJO (ORCPT ); Wed, 16 Aug 2017 15:09:14 -0400 Received: from mail-qk0-f171.google.com ([209.85.220.171]:34009 "EHLO mail-qk0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751847AbdHPTJM (ORCPT ); Wed, 16 Aug 2017 15:09:12 -0400 From: Laura Abbott To: Kees Cook Cc: Laura Abbott , linux-kernel@vger.kernel.org, Laura Abbott Subject: [PATCH] init: Move stack canary initialization after setup_arch Date: Wed, 16 Aug 2017 12:09:06 -0700 Message-Id: <20170816190906.11098-1-labbott@redhat.com> X-Mailer: git-send-email 2.13.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Laura Abbott Stack canary intialization involves getting a random number. Getting this random number may involve accessing caches or other architectural specific features which are not available until after the architecture is setup. Move the stack canary initialization later to accomodate this. Signed-off-by: Laura Abbott Signed-off-by: Laura Abbott --- This was a patch I did a while ago as part of some out of tree work to make the stack canary randomized on arm. The overall work didn't really go anywhere but there is interest in this part for other approaches to adding randomeness. I can re-send with more Cc for anyone else who might have opinions. --- init/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/init/main.c b/init/main.c index 052481fbe363..c71c4451094c 100644 --- a/init/main.c +++ b/init/main.c @@ -515,11 +515,7 @@ asmlinkage __visible void __init start_kernel(void) smp_setup_processor_id(); debug_objects_early_init(); - /* - * Set up the initial canary ASAP: - */ add_latent_entropy(); - boot_init_stack_canary(); cgroup_init_early(); @@ -534,6 +530,10 @@ asmlinkage __visible void __init start_kernel(void) page_address_init(); pr_notice("%s", linux_banner); setup_arch(&command_line); + /* + * Set up the the initial canary ASAP: + */ + boot_init_stack_canary(); mm_init_cpumask(&init_mm); setup_command_line(command_line); setup_nr_cpu_ids(); -- 2.13.0