Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1034205AbcJaUqS (ORCPT ); Mon, 31 Oct 2016 16:46:18 -0400 Received: from albireo.enyo.de ([5.158.152.32]:55815 "EHLO albireo.enyo.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S946789AbcJaUqQ (ORCPT ); Mon, 31 Oct 2016 16:46:16 -0400 From: Florian Weimer To: Jann Horn Cc: Kees Cook , kernel-hardening@lists.openwall.com, Andrew Morton , Michal Hocko , Ingo Molnar , Andy Lutomirski , LKML , Daniel Micay Subject: Re: [kernel-hardening] Re: [PATCH] fork: make whole stack_canary random References: <1477922641-2221-1-git-send-email-jann@thejh.net> <20161031162918.GA2994@pc.thejh.net> Date: Mon, 31 Oct 2016 21:45:59 +0100 In-Reply-To: <20161031162918.GA2994@pc.thejh.net> (Jann Horn's message of "Mon, 31 Oct 2016 17:29:18 +0100") Message-ID: <87mvhks0vs.fsf@mid.deneb.enyo.de> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1550 Lines: 34 * Jann Horn: > On Mon, Oct 31, 2016 at 09:04:02AM -0700, Kees Cook wrote: >> On Mon, Oct 31, 2016 at 7:04 AM, Jann Horn wrote: >> > On machines with sizeof(unsigned long)==8, this ensures that the more >> > significant 32 bits of stack_canary are random, too. >> > stack_canary is defined as unsigned long, all the architectures with stack >> > protector support already pick the stack_canary of init as a random >> > unsigned long, and get_random_long() should be as fast as get_random_int(), >> > so there seems to be no good reason against this. >> > >> > This should help if someone tries to guess a stack canary with brute force. >> > >> > (This change has been made in PaX already, with a different RNG.) >> > >> > Signed-off-by: Jann Horn >> >> Acked-by: Kees Cook >> >> (A separate change might be to make sure that the leading byte is >> zeroed. Entropy of the value, I think, is less important than blocking >> canary exposures from unbounded str* functions. Brute forcing kernel >> stack canaries isn't like it bruting them in userspace...) > > Yeah, makes sense. Especially on 64bit, 56 bits of entropy ought to be > enough anyway. So you two approve of the way glibc does this currently? (See the other thread.) I was under the impression that the kernel performs far less null-terminated string processing the average user space application, especially on the stack. (A lot of userspace code assumes large stacks and puts essentially arbitrarily long strings into VLAs.)