From patchwork Tue Jul 24 06:57:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 142702 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp6919357ljj; Mon, 23 Jul 2018 23:59:24 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdQsRrVOEnI9u8R1pPO8vJzWb0H3GzTB5jBhdwxuSKEcrsDKvfRuJtn9KB4v2lb6RVmh2eA X-Received: by 2002:a17:902:22:: with SMTP id 31-v6mr15973440pla.332.1532415564342; Mon, 23 Jul 2018 23:59:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532415564; cv=none; d=google.com; s=arc-20160816; b=SOlD9Z5TYQdaOsvgM9bwUFyDTrJkZRS8ky+KIG6fzeFeLOAeMpeDrl3Oe1bt6b9wom v6NLmHvW8Dv54ZLiMYElJiG9LE4p9dLKpdUFWuSkGnSvWfkMCQ0vUiwPittR8XSYAho2 OCBlL9Pba+2KVhQMJEy+MVuzI8BqWNX+nVEUHUW0Kj3SW1usctengNKHXos+hTvsdYTA KoMfYCrTaOEtwWmH91pLQzDntnNLf5WjmQbBbfEOfAaZcjEKCpSzptZMVaIVTZvR9R2a PuzbQ6JPVeUJ9pvV4TITQSvnN5EegzUbWmfcSsrN+BJ3mWuG8NOICLTfm66tLBbeJoGJ VVBQ== 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 l18-v6si9465021pfk.78.2018.07.23.23.59.24; Mon, 23 Jul 2018 23:59:24 -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 S2388592AbeGXIET (ORCPT + 31 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(+) -- 2.18.0 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;