From patchwork Wed Apr 25 06:26:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 10361753 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 7DEC1601D3 for ; Wed, 25 Apr 2018 06:39:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6DE1928F60 for ; Wed, 25 Apr 2018 06:39:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6237928F64; Wed, 25 Apr 2018 06:39:05 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 EA06428F60 for ; Wed, 25 Apr 2018 06:39:04 +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=doOks6fiT3Vx2+lJiTbP3DepNoRVdN/kgMxrChDoI+g=; b=Z8QVa5HEZfal53Uz5iMb1hAhAj /4uLco13T9MfEKpcNawCLpov+YA9K32s7dZ1E2MArLFptW8jsr5km+Bfd0kcQkbQmP2AmmQGqBi+E 9Qrmcx8gPwa1EneFcZPgN3ORv2zDWuhe2KETGLUcGe+2SPpiypdt7NSks9qeIHRilCYNMMdtgLtLJ DIkImh9Aq/4G9rXC2+TILo7RtfTB1t0kKFRQnxFNOjk7w0hnBQUR67Qe5G3f+oN1H0aD/siwp3Ys3 Zx+tG6o+QGeURoiANVL8PwsRnSdsNXQRh9nHUmr4fDQO/HgXmbSHjhOCy+FM+GqAPKhnuW86ug3o1 LHxcjl1g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fBE4w-0005ZD-8B; Wed, 25 Apr 2018 06:38:58 +0000 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fBDu6-0006ZL-RM for linux-arm-kernel@lists.infradead.org; Wed, 25 Apr 2018 06:27:54 +0000 Received: by mail-pg0-x244.google.com with SMTP id e9so12602079pgr.7 for ; Tue, 24 Apr 2018 23:27:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jBK3ptBP+kuxlmMWHAiBOcRa6D76/Wey0R++OHp+zjo=; b=LQV1RFpfWihgSWvjd4LkN4ClTBNu1yJrc0cOx7pJpL2g03gGuBSjVdJa2MC4SsY89E 8k677THLK5jU6Ih9tCqDUQdfSix/BAAB4DgGRuDf473/VYmxOG2V2sPgUU8C/pw2jfMc T448EKBnTcFZ63X4iKxLX7n00RXTXo96Mvwwg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=jBK3ptBP+kuxlmMWHAiBOcRa6D76/Wey0R++OHp+zjo=; b=uExD4rrB6WczkViPBiEbnNg9njEnX0Q5ekmRAff4PDcurQ6HO/bu3olo0UnIZlYCEe qUE4B9RYl8AYF/IjbVsX0loDLsBYlirKbLSG8UugbshdAZOag2WgR8ps5EpkaHnFUeFg uLQd87SNGoL+MVwTyaEdAduoFz+FAdt/wPVUCL1ybYxDaqAaW7jz79Lr/KVj+RjlSRUs bKONoDNXPUjicgVmyVhwjzdXkIhXeauwnbyDOmCTFaGa6HMUbRea+RR5/795oWZXbTCl mSQnTCDFPcVKw+F/4BVQDfqgctCN4xOY5n7X0+BKNTKlKihngDJKZMHIurFL/5Y7Cw2T AgoA== X-Gm-Message-State: ALQs6tDxmyHn4U1NBYOO2enO79qjLy2o53P02QxPLO/W8s+b2uuDpIuz eO3ji1fSJIoopbHgzKIvehTm+d5t3eQ= X-Google-Smtp-Source: AIpwx4+iT3UL2I+orqomQFE4FxL2ClRMGsTWuhNqfa8WDfnNIeGpfx1RJGX6Ht1Hxi/yYm5OPm+V+Q== X-Received: by 2002:a17:902:2924:: with SMTP id g33-v6mr25575162plb.26.1524637655330; Tue, 24 Apr 2018 23:27:35 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id v16sm8888380pfk.164.2018.04.24.23.27.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Apr 2018 23:27:34 -0700 (PDT) From: AKASHI Takahiro To: 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 Subject: [PATCH v9 11/11] arm64: kexec_file: add kaslr support Date: Wed, 25 Apr 2018 15:26:29 +0900 Message-Id: <20180425062629.29404-12-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180425062629.29404-1-takahiro.akashi@linaro.org> References: <20180425062629.29404-1-takahiro.akashi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180424_232746_993487_1E3C9D51 X-CRM114-Status: GOOD ( 13.31 ) 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: ard.biesheuvel@linaro.org, bhsharma@redhat.com, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, AKASHI Takahiro , james.morse@arm.com, 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 Adding "kalsr-seed" to dtb enables triggering kaslr, or kernel virtual address randomization, at secondary kernel boot. We always do this as it wll 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. Signed-off-by: AKASHI Takahiro Cc: Catalin Marinas Cc: Will Deacon --- arch/arm64/kernel/machine_kexec_file.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/arm64/kernel/machine_kexec_file.c b/arch/arm64/kernel/machine_kexec_file.c index ec674f4d267c..762f9102899c 100644 --- a/arch/arm64/kernel/machine_kexec_file.c +++ b/arch/arm64/kernel/machine_kexec_file.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -246,6 +247,12 @@ static int setup_dtb(struct kimage *image, goto out_err; } + /* add kaslr-seed */ + get_random_bytes(&value, sizeof(value)); + ret = fdt_setprop(buf, nodeoffset, "kaslr-seed", &value, sizeof(value)); + if (ret) + goto out_err; + /* trim a buffer */ fdt_pack(buf); *dtb_buf = buf;