Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp6645664imm; Tue, 24 Jul 2018 00:01:48 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdMWZQ64GpudjzsOev97jSz8+AYgIF0VnVRo4Ma0FbCuG9+qNkkTp331KnW44X2wANcpKBn X-Received: by 2002:a17:902:8a90:: with SMTP id p16-v6mr6991682plo.106.1532415708011; Tue, 24 Jul 2018 00:01:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532415707; cv=none; d=google.com; s=arc-20160816; b=NsSzror2KGbedlqHOUqzUGdQ8ogxr787wa92vHCChtxWUlyER7xV//SG8Jk3DLFxpQ y0x8Ordkna6oiSDKN3CnY/anPqRSjfjeQZnD50MGPiMZCACQI7k6J99nrEeemTaLr40W YSWhmhEOTYRrdzRyXsUQysTVeaMPKZ2CXHk7kokKZ+2PyLvlnKMuuD3v5FWR5o4GwnPx Ykntx+ymQzhlWjQrdFStxjF9XUWifk5dYmJiqP+a1HvrRCzoXnGuZFCga9vlYEjIFwkw vhxesNDo/wnLt0KVhuLME9k5pfyUt2KYQYD/mFq1pcM+hQZUq9zrDlzD1gdnabmUKMwb +PWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=DjZGq5WnpjvJN9iGuoJut9k6LjLfxTrv7tJcxElB2q4=; b=cn7lzQptoYBVhkFuNxa31tyGH555ihFfdxeN7QrvutNFO7l6CGr9nCddUjSbWKDu9Y IOk6t8pL/oAZdhpQ3ajmS+JWiYmIiYjVRvdmcgpKZAXgwyq46PNZx41qGXRptr5Uy1q1 /pt4xStFqfGvG+8CDTZgRk+fSYySByzGhEFpL5SOj1wzX4rpX62xkPNR42kyb3bG0ca6 GjN+nVAPvxrYYbPzWx+HHXkYx7Xpv6fn7YtnZ3MsHey26vufxVVNOKl9JKf9jTbg5pKU qUtFeLifvDuPaQ8MDu2ojymhNEy6mNPSxj6/j50wKj7DTQ91YBSJ+M9qUI91ay9Qi6iN rNeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LOBGvQ46; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u14-v6si9166213pgv.180.2018.07.24.00.01.33; Tue, 24 Jul 2018 00:01:47 -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; dkim=pass header.i=@linaro.org header.s=google header.b=LOBGvQ46; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388589AbeGXIET (ORCPT + 99 others); Tue, 24 Jul 2018 04:04:19 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:37639 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388264AbeGXIET (ORCPT ); Tue, 24 Jul 2018 04:04:19 -0400 Received: by mail-pg1-f194.google.com with SMTP id n7-v6so2192898pgq.4 for ; Mon, 23 Jul 2018 23:59:21 -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=DjZGq5WnpjvJN9iGuoJut9k6LjLfxTrv7tJcxElB2q4=; b=LOBGvQ46EyOi/qHw58fwmvardQ5MtYZdZsKI2bhd3NPyZ5Ngm05h1zVfpxB28HzYsy cC4OHjfFrWjqeyA6R50p272ExOYbm2fuM7josvLnYlfJCXoyHAdXS4h6od0vIP6qBJNY +HYqMAUASv9ZTXy+It/cFonObSZhmrKAg+Pqo= 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=DjZGq5WnpjvJN9iGuoJut9k6LjLfxTrv7tJcxElB2q4=; b=pdE6aXCp54pgPajzfqX9F41/H0FDXmIF5YegGs7/jr2b2wAYaK9AuEmFE8dF8lpT0K sVplZhER+oQTVTf0e5ccRRbJfZl4Lag88e+owO5lVRfvDCcfr93rXvPyVZaqNijAk5Bw +UYIZj9Nqj8rGOiSfw4iY0pnL5YEQSBXLAyV0rlDBQNGPwNV0sE/0pXrCsN+NqfEEn/A iGamXZgTXYDlsLP8bv1Ns+EQUOXN9lKYqQ+D1n28lmmRF2H0EV7uxW9N0O/f0A8JIJ9R aL9LfRWC8JMOacU/ExxzxrFUi3EI8ZAWZ4Qa+wLjV8p7VH1P7iXYe+Rm4pFQG4R6XKKz dSDw== X-Gm-Message-State: AOUpUlG5XTO+VXC0cdVP26gNhggjusa1qmHXtfSeKVSAyuopeiOFvjXC NKQc/+m5Tp52Ln8gB6WjsbwEqw== X-Received: by 2002:a63:db05:: with SMTP id e5-v6mr15062646pgg.152.1532415560822; Mon, 23 Jul 2018 23:59:20 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id c6-v6sm2027520pfg.138.2018.07.23.23.59.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Jul 2018 23:59:20 -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, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com Cc: ard.biesheuvel@linaro.org, james.morse@arm.com, bhsharma@redhat.com, kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, AKASHI Takahiro Subject: [PATCH v12 16/16] arm64: kexec_file: add kaslr support Date: Tue, 24 Jul 2018 15:57:59 +0900 Message-Id: <20180724065759.19186-17-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180724065759.19186-1-takahiro.akashi@linaro.org> References: <20180724065759.19186-1-takahiro.akashi@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 | 8 ++++++++ 1 file changed, 8 insertions(+) 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 @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -46,6 +47,7 @@ static int setup_dtb(struct kimage *image, void *buf = NULL; size_t buf_size, range_size; int nodeoffset; + u64 value; int ret; /* check ranges against root's #address-cells and #size-cells */ @@ -158,6 +160,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; -- 2.18.0