From patchwork Sat Jun 23 02:20:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 10483453 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 35D6C6023A for ; Sat, 23 Jun 2018 03:06:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 243CC28BDE for ; Sat, 23 Jun 2018 03:06:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1638129077; Sat, 23 Jun 2018 03:06:50 +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 AD15E28BDE for ; Sat, 23 Jun 2018 03:06:49 +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=yRM3ZRbVM4j4irEN4xGj7SjdBDD2yWSQNWno+pwQNS8=; b=e/6qLIwDkOW/Oyfx99kcxn0y8a oi4vR1vLjal8t2Q6/US8wV+ydB5MbKbrinRYLzHuTxZ7tJZwAOJCeXXhhF0CUpuDlz4JH3pdK2aWN 7S0vN0Q2nXO7FLLx7JI+84u2S51jfYUDotvvh3PJF3wqvtK7GRLbxeKOlKDrTqPHEiCxonkGFNQ4a 24aFy73fh0oV4iUUfL3UfKzrnsWw1KBsr+ZM828mWiFgFg8ofzLLPZO7jtbdzye2vVzSw0UJ6+gEY DjKCagMPn+ZNHaCD2rPZqcB5Xq5qIq3M8ZVkuzRW/K5JSTvTzqiDTZoKvcaf6FH2aiSUXTBifciUV EhI5VVWQ==; 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 1fWYsw-000843-I6; Sat, 23 Jun 2018 03:06:46 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fWYre-0007Fz-8f for linux-arm-kernel@bombadil.infradead.org; Sat, 23 Jun 2018 03:05:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=kjrhtHupdHh4T5Hnsk+P2sAae5O1LRvrUqSekVnnVSw=; b=y4r9/jV+OW28IsawysnpXmB7z BTK3twpyUPboZrdml6aqE3NQ3zMLEUP+xD4ywUP0D0OfCxurmwXKaib4WQuw0oqyIlP4N/UJrXhNg Wd8Fng73yp3MKefm61d+4o5QL+GkyBWgf0EdHkDAJOBU8X1AHqkdZoVjM9EwIIw/G1IOYl0JPdvka 967oPVWU+zqS0h1ZC40Rg+v3YoV6gWXeRIdnwEZsj+XmkawQ/dW9IXZD3b1SijK7rjWAEFYFHu2sO bWn47T+/QrmOhTgfRBPeiedmbIIzuj1VjldFbdaFAPDOIgUSW55wBkNfy6d1PhpF1FvzJRc6U9FLt jeBJNQIrQ==; Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fWYBh-0004aJ-1E for linux-arm-kernel@lists.infradead.org; Sat, 23 Jun 2018 02:22:05 +0000 Received: by mail-pf0-x244.google.com with SMTP id w7-v6so3995814pfn.9 for ; Fri, 22 Jun 2018 19:21:54 -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=kjrhtHupdHh4T5Hnsk+P2sAae5O1LRvrUqSekVnnVSw=; b=kNofj1H0U7Jw4ClKkIBEMiVX02MACndzKKCawpN+Ze9B3jo6c4pewzlZtXN+62sR87 p/niEICqNaT2bXBkULcysrad368qaB1aMcZznES1lHarEOYCJbBueMORBP5d5U7e8teN n4zukzR+/fEZ4yFinkoL/i316OWePqGkYwrhU= 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=kjrhtHupdHh4T5Hnsk+P2sAae5O1LRvrUqSekVnnVSw=; b=fCQTMn3pzUYoPgmmISxl0htmqCAh03nF15H83Yx03b3wbepZ3pKjZ3Wo82iHagt7Xd mlZggdcFU9PssL7FS06yeVQxF7mQWrd2xzy5kWfkQkEPnniEPHjyd/N8zHOyzlWjTeq9 Z//6LV2mn6txg23Ar45EVSz4NqE1pcOhZV1E6gXLPx6weZuixGhuMWNLf0lRvyvadGmV Oypc90ptZ4FxCS6AnuBnx8DeX3HWZPMsBgKB2OrkocQBZeUMlw9HXm6P7nSdWLuqxCQN RYtyxbmSdkRh7UkZmAKJja5hi51acIVsWa99PwjjOwsV6o4jC7iV94JYLbiuiRc6b6cD c7ZQ== X-Gm-Message-State: APt69E1WWCQytUkky1Uw+r4PMnxY2nFd7HaWdsJ+JuqBwL2dcsarZ/4U xu2UWiIu/a74HvmlDzVc54jYhQ== X-Google-Smtp-Source: ADUXVKKuYQTI4ZVrrOJAWwRe4rSjJIpAs2BYccNzkFVQpFkhzl+mZt8NFLdebP6YCqEV9gPVerIJPQ== X-Received: by 2002:a63:2b88:: with SMTP id r130-v6mr3349043pgr.170.1529720512561; Fri, 22 Jun 2018 19:21:52 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id e81-v6sm19973085pfb.62.2018.06.22.19.21.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Jun 2018 19:21:52 -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 v10 14/14] arm64: kexec_file: add kaslr support Date: Sat, 23 Jun 2018 11:20:58 +0900 Message-Id: <20180623022058.10935-15-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180623022058.10935-1-takahiro.akashi@linaro.org> References: <20180623022058.10935-1-takahiro.akashi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180622_222205_107643_76BEF246 X-CRM114-Status: GOOD ( 15.02 ) 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 6aec996d015a..1283c1d912f2 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 @@ -132,6 +133,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;