From patchwork Wed Jul 11 07:42:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 10519049 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 3E0546032C for ; Wed, 11 Jul 2018 07:44:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E64F28756 for ; Wed, 11 Jul 2018 07:44:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2148628E7C; Wed, 11 Jul 2018 07:44:15 +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 C59F328756 for ; Wed, 11 Jul 2018 07:44:14 +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=x6QHFbu21tiG4tFa76wvztqRR72xVYrx3T9KGtzJ0ZY=; b=aoPjgghkPYzDJcc50j4DQfijrI WeTSvVGEFVPnbA338BFURuGEdh1cmOCe2Tv68tlhc8ucTrD5m8zZnNlPiPURX7ZVSKuXkNXjZI9wo +YosQ2ex3T5cE29Ow6rj+ZBYHhXGHKiADT5xq1O4+Hx5Lgx5GrEjzNi+FInojL32hOcB93QKbHcoo wXxxErZDZXuOewBaY2MGGlWCtHHNQpEENokwuv5rjoLfAWXKYKT4MlpljwPpq8X7OpAnyeLFtmtW4 uO0LscOtIR/LmspeqJ2RAJPvyd+4+mzY3rmFAMahGw13X54e27IswrEdbc3aVzD7a52P8afT6zDZQ GcthvHLg==; 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 1fd9nH-00072s-Kg; Wed, 11 Jul 2018 07:44:11 +0000 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fd9mo-0006Kx-3V for linux-arm-kernel@lists.infradead.org; Wed, 11 Jul 2018 07:44:02 +0000 Received: by mail-pg1-x544.google.com with SMTP id v13-v6so2688363pgr.10 for ; Wed, 11 Jul 2018 00:43:32 -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=uQoziQZkHVnlrNNUZNXAOepb9dTdnP1dZcnkI2L9pzA=; b=SIE6TkGLdOsMdh5DXKeCj9XxFa424kGQP+vU592YrheWapegYtykabNa2h6p3Z7ZF+ uzo2EzV2GsH+kHAU04n4Co1PZrY9NY8bZywVXdpjE8EK1OWGKT6nzGW0sVsj0dm4VnMg 1ag1YVyppqMmEmMrgjDIGpJscQzPOylYVhunA= 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=uQoziQZkHVnlrNNUZNXAOepb9dTdnP1dZcnkI2L9pzA=; b=lwamzXJlOnFKHTTPwfrhuTmC5ic/qM/hTOp8+On8BFi44KDbio8kdr3r0srDI65zBB ET7BV1FQia2zI6E5UFuTN6VaIWhFKASfN757lvH+kbp6DnXj3+p7aKozyGDSZKU0HN0g NKOraKVaji+HulgTIfu7W2XPT2bveTwPJh0zb6x9lX2aw28H4Z+e4KXyKk+sBzD+v/hb PQDiW2dLiWi/N6WOjUVZXF5HgkTfwqdWKGTflXUPaZPzsoXs6GrwktT5qAHdP1/jwACc 0tC52NFv0HzXRLSnML8/B9pXMRKL8ZGu99z4/VEH4IPuWpBWjWAeLC+fFOy7/wpAVUkg NKTQ== X-Gm-Message-State: APt69E1lUKaV412wsR1QRc2n1MqLvxSiZDGC93WZW3iVhspLi/ixAoUG 17dh2YXMWtYKfnSgbFk3+dIjqA== X-Google-Smtp-Source: AAOMgpfWQarGW1LorSif8/icF25nRC6CYXWDUVFHIkKPbEH7SMNCec8AqB8zgGnarK26K81pXQzWoA== X-Received: by 2002:a63:f:: with SMTP id 15-v6mr19477044pga.430.1531295011680; Wed, 11 Jul 2018 00:43:31 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id v17-v6sm23357015pfn.177.2018.07.11.00.43.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Jul 2018 00:43:31 -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 v11 15/15] arm64: kexec_file: add kaslr support Date: Wed, 11 Jul 2018 16:42:03 +0900 Message-Id: <20180711074203.3019-16-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180711074203.3019-1-takahiro.akashi@linaro.org> References: <20180711074203.3019-1-takahiro.akashi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180711_004342_635153_600A4015 X-CRM114-Status: GOOD ( 12.94 ) 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 "kaslr-seed" to dtb enables triggering kaslr, or kernel virtual address randomization, at secondary kernel boot. 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. 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 261564df7210..99d771afe88e 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 @@ -161,6 +162,12 @@ static int setup_dtb(struct kimage *image, } } + /* 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;