Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp461771imm; Thu, 26 Jul 2018 06:42:01 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcbvRrTGxwT+VqaUcE7/kEA6yv3WiajchIfL4ElXZKj9C55c5ZGhPK/adnf4zjpSy0SkgIQ X-Received: by 2002:a17:902:bcc5:: with SMTP id o5-v6mr2027955pls.336.1532612521804; Thu, 26 Jul 2018 06:42:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532612521; cv=none; d=google.com; s=arc-20160816; b=PhezjTSxvARprqO5D1w6I31mWc0L4Sqd1xbtesUcDH17ZcszX/kpvucQW6bRkj85JN yNzgqbLBqA2CmtgLUUVnYE04Zg3W0fKjFr8Zk1iG54g2QBiG5AccgxnezygKF+fZM6BE inYTCaxw+FrZvRoYPIQ+HsnZaevFYFj0u4YpUJy9ewj/RjYMLKmYXw60/0jQKt0E2T/v K+IJDE3XOUeQ49UWzvPlYWNFxJJ6ehQZDXH/QsY+iiPXX6zXScA0RMkuhOV8DqK7yGDC dzW0EsJ7Iqn/FGgyGipfLtsXr5XqhsccIwm4E7MpsA/wOCUtk0Y1enG0wk+GXIobkJ/u L3wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=8Qv3pNmafIKcmOm3qCR7NGIAUpDfn/kBQ3ksIUSh670=; b=ZYLPv+IRzQPqgqHPY3SMRR9E0l8zXPck5UuMT4W4c3UWD+xOjsCQUVTKezFjr6YMNw rcZxbPXP2VhliwnBADYXUqPxFDx9bPjMiwllTMFwG8S++rJmgB9KUBjiJ75bEALgF73a Yi5k+UnboVnfi2j5N+fqSxE/AYuTZ9JWe+/CMvSfvLybgpms+kHJOvQr1xdCHRa83NbV e1xS6kiaAP0iF/U6BT6nylNI3SZaAOkEh5Rr9zfY26J7PatUiD2H7WOhjwFTNgW15SRP sl+Cxk6x44vbaVW69ZuYFfUxwgKgxs16BEt6p2n5uFl5BXPuY2R0ISZ5U1CxtTNgk2gE qQew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 60-v6si1301031ple.65.2018.07.26.06.41.47; Thu, 26 Jul 2018 06:42:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730293AbeGZO5t (ORCPT + 99 others); Thu, 26 Jul 2018 10:57:49 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:56178 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729506AbeGZO5t (ORCPT ); Thu, 26 Jul 2018 10:57:49 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B6B5515A2; Thu, 26 Jul 2018 06:40:53 -0700 (PDT) Received: from [10.4.12.81] (melchizedek.emea.arm.com [10.4.12.81]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 01A313F6A8; Thu, 26 Jul 2018 06:40:50 -0700 (PDT) Subject: Re: [PATCH v12 16/16] arm64: kexec_file: add kaslr support To: AKASHI Takahiro Cc: catalin.marinas@arm.com, will.deacon@arm.com, dhowells@redhat.com, vgoyal@redhat.com, herbert@gondor.apana.org.au, davem@davemloft.net, dyoung@redhat.com, bhe@redhat.com, arnd@arndb.de, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, ard.biesheuvel@linaro.org, bhsharma@redhat.com, kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20180724065759.19186-1-takahiro.akashi@linaro.org> <20180724065759.19186-17-takahiro.akashi@linaro.org> From: James Morse Message-ID: <50b31f17-fc85-aa72-06f5-d3b62060a91f@arm.com> Date: Thu, 26 Jul 2018 14:40:49 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180724065759.19186-17-takahiro.akashi@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Akashi, On 24/07/18 07:57, AKASHI Takahiro wrote: > Adding "kaslr-seed" to dtb enables triggering kaslr, or kernel virtual > address randomization, at secondary kernel boot. Hmm, there are three things that get moved by CONFIG_RANDOMIZE_BASE. The kernel physical placement when booted via the EFIstub, the kernel-text VAs and the location of memory in the linear-map region. Adding the kaslr-seed only does the last two. This means the physical placement of the new kernel is predictable from /proc/iomem ... but this also tells you the physical placement of the current kernel, so I don't think this is a problem. > We always do this as it will have no harm on kaslr-incapable kernel. > We don't have any "switch" to turn off this feature directly, but still > can suppress it by passing "nokaslr" as a kernel boot argument. > diff --git a/arch/arm64/kernel/machine_kexec_file.c b/arch/arm64/kernel/machine_kexec_file.c > index 7356da5a53d5..47a4fbd0dc34 100644 > --- a/arch/arm64/kernel/machine_kexec_file.c > +++ b/arch/arm64/kernel/machine_kexec_file.c > @@ -158,6 +160,12 @@ static int setup_dtb(struct kimage *image, Don't you need to reserve some space in the area you vmalloc()d for the DT? > + /* add kaslr-seed */ > + get_random_bytes(&value, sizeof(value)); What happens if the crng isn't ready? It looks like this will print a warning that these random-bytes aren't really up to standard, but the new kernel doesn't know this happened. crng_ready() isn't exposed, all we could do now is wait_for_random_bytes(), but that may wait forever because we do this unconditionally. I'd prefer to leave this feature until we can check crng_ready(), and skip adding a dodgy-seed if its not-ready. This avoids polluting the next-kernel's entropy pool. > + ret = fdt_setprop(buf, nodeoffset, "kaslr-seed", &value, sizeof(value)); Nit: It would be nice if this string were in a header file somewhere, to void future refactoring typos. Thanks, James