Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp252479pxb; Wed, 13 Jan 2021 02:46:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJywOpzJLapxn/yAi5lYQlpG1QXujmeaRNcSaWGD6NWyO681xhfhwecSdn2qDzfBUKnOVoPC X-Received: by 2002:a50:eb44:: with SMTP id z4mr1233340edp.167.1610534813065; Wed, 13 Jan 2021 02:46:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610534813; cv=none; d=google.com; s=arc-20160816; b=gwIf6Wj+A10XV2YFPfhsNN+nTr3Xhy3mviXUiwhkZ3Edmr4AUTF5zTKLbdVzPljpAQ hGX4MOFAkkOx29Z7KGzMoTJV+5gdREP/XoRef1QA0hnsvBnGi7Jz+EHgj7Pz8kObViYf PEJaliIdluJ+1CNTg0HHdUlmlEZ/H6hhgLzegM1WwqZrFUVvYojphCblePhV1nBXrlWL p0fminhgc/1oK4oJZpydXIXlpmFNEfx6u22pwIQbi52FGOJ8doTGH4fvpp5hNOV7gf78 T1agR/6prhg6eyy1UhXkxFOV1piIa1AGEwzMbR7KJ0xGMcYDIc9u1gXWeDJvr2dXpm5b GRpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=zNZpEWPREJpKwbmPo2WxCr7GS6yVCmC3daAT1NcTKaE=; b=D2tDsbTigjnqgFnrVyN/18Xgnxh3wP1TSa5TA3O0rAgxIpX+e/Z1F5o5mnZhiXPzXA NbO8FxG+r1DKpdVYjmX+81gNkNvcSs6Abuh5iGmdSMAvu8Y4agjvfON4wp0utsTiZs4L 2NO0Bu55qlY43zoj1dLtyrCbTYA2b54ncaiTYmgGxxB0Ww1Wgd7kaTNoI3CsTMPc02oj dgjOnvkB3o5iny7LmQWpna9+Ug6oTFcqpo5iVujhz7zqndn+Y26Y5ckREztkGKiU8reM 85P55/AtDONFReVZnzlNCAX/PiBkFSsKAL2UxfRTT3FBi0qXOWpDMtOFAibpgxttPSmS GMOA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r9si526380eji.723.2021.01.13.02.46.29; Wed, 13 Jan 2021 02:46:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727744AbhAMKox (ORCPT + 99 others); Wed, 13 Jan 2021 05:44:53 -0500 Received: from elvis.franken.de ([193.175.24.41]:47768 "EHLO elvis.franken.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727655AbhAMKox (ORCPT ); Wed, 13 Jan 2021 05:44:53 -0500 Received: from uucp (helo=alpha) by elvis.franken.de with local-bsmtp (Exim 3.36 #1) id 1kzddE-00021m-06; Wed, 13 Jan 2021 11:44:04 +0100 Received: by alpha.franken.de (Postfix, from userid 1000) id EDBF6C02B1; Wed, 13 Jan 2021 11:43:54 +0100 (CET) Date: Wed, 13 Jan 2021 11:43:54 +0100 From: Thomas Bogendoerfer To: Alexander Lobakin Cc: Nathan Chancellor , Nick Desaulniers , Kees Cook , Jinyang He , Ralf Baechle , Matt Redfearn , linux-mips@vger.kernel.org, stable@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com Subject: Re: [PATCH mips-fixes] MIPS: relocatable: fix possible boot hangup with KASLR enabled Message-ID: <20210113104354.GA10505@alpha.franken.de> References: <20210110142023.185275-1-alobakin@pm.me> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210110142023.185275-1-alobakin@pm.me> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jan 10, 2021 at 02:21:05PM +0000, Alexander Lobakin wrote: > LLVM-built Linux triggered a boot hangup with KASLR enabled. > > arch/mips/kernel/relocate.c:get_random_boot() uses linux_banner, > which is a string constant, as a random seed, but accesses it > as an array of unsigned long (in rotate_xor()). > When the address of linux_banner is not aligned to sizeof(long), > such access emits unaligned access exception and hangs the kernel. > > Use PTR_ALIGN() to align input address to sizeof(long) and also > align down the input length to prevent possible access-beyond-end. > > Fixes: 405bc8fd12f5 ("MIPS: Kernel: Implement KASLR using CONFIG_RELOCATABLE") > Cc: stable@vger.kernel.org # 4.7+ > Signed-off-by: Alexander Lobakin > --- > arch/mips/kernel/relocate.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) applied to mips-fixes. Thomas. -- Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ]