From patchwork Tue Feb 20 19:21:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jann Horn X-Patchwork-Id: 203771 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp616614dyc; Tue, 20 Feb 2024 11:22:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWKoCAjzlMsDlI4QZrNaorYwFEuCfhOUMCDMKXV7eJLU4WvXOWj+C8cm1gfMRHPZzn4uFwNjEvi5OaaNldRFVbL4tYGKw== X-Google-Smtp-Source: AGHT+IG6zTaz6qIeaS8sJKn0B6AKF5QLAB/faicJX2dKEYComLPeOwGlZ1IxXRZ13DMelAu0z7Qz X-Received: by 2002:a17:906:414e:b0:a3e:eeab:d01e with SMTP id l14-20020a170906414e00b00a3eeeabd01emr2191984ejk.65.1708456951608; Tue, 20 Feb 2024 11:22:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708456951; cv=pass; d=google.com; s=arc-20160816; b=gSDozXi67hVfx9m9u73dhziLJnrgEoIJcX8kM10CX5hBkRLB/oHJRqKbYh8ToNqyPR 939N89CuApVzFjbO/x1TOHlHq2T8MSL51Cs3pVaKOBHj7bwKmHHW21X3T5lvMHopFqlo 5xPaEv4r56iHGTqTkW2DDMLUePWqyOMiD9PnMIYPvwEg5Gw35trhvtnR7iNLZe9tE0Oj Gezv/kOI3H+dE/JR8Cn9rj9e6lqemWaqPHxX38Rn7cl494I/2SqpQ9ausIakFDMC6wyM YQfZTDb7VUziIyDBqCO8wZb0+dTT83YiAMjPvbzSrUBxlcfZDv7GmVBHoHyqPgpavQXc WxQg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=cA2O3Llhx71J8bGYTlEPNCq93E6hVPmmgkxfFVoSWL8=; fh=Nq/nElPHZ530SN64UDyPlwN1O1UpctBMmMkrRqI4A/0=; b=D6PfGLzzzbGd9C2McQH9VFnlcohC/C23aozh/nF4/H66c/DUqk+6YpNSbRPUNESHpQ KyZkuLuWjrFSxmmZB8QGkk8OjFA5i9ATfAN/IkhpjGZxwWH0TsCtTUNuU+fVQJCrDq83 xEnM5ZjokOGvgs0WI8ncKl9svMczvw3IPvcPELjU+88MiW/f5nVwc6xkwdKzgrQJCTBl 9EbGUa07lM+XOrhml1c7pxOkmjnqxrZcrUSpyFerS8S2WDf1cOmxNgn2vgN07WEScDC/ NzTbVdPxxTaRl8bOimpT5sBK2M9xbDoz4TnIju54HnQWiPX6/Jg+C3xrKogZQOScjAab M7Kg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=tnZrOTMc; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-73587-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73587-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id hd17-20020a170907969100b00a3e3633cf8esi3442938ejc.435.2024.02.20.11.22.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 11:22:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-73587-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=tnZrOTMc; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-73587-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73587-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 0C1551F25190 for ; Tue, 20 Feb 2024 19:22:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1912814A4D7; Tue, 20 Feb 2024 19:22:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="tnZrOTMc" Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D3A301353EF for ; Tue, 20 Feb 2024 19:21:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708456921; cv=none; b=aczp8FsWVq6QSXWClH+nN4h2wzWmefs2J3R96+J9r80+bfmJ2cksKaWJXVhgktnwVRvMjuZ5bAd1HIegKhhSYaA4S0LqYqMagaYoj3Si3bAmK/xB2IvghicRgeOUSYFKD57FOH0MHfyGSflF6JIoPO7X7CCqynZOnpuCMEOlsGw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708456921; c=relaxed/simple; bh=O0CZLNJD1ve6sw6w5oRCfLQxN+HSkwW+t7kr5ppkfwg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ihFiaJmdrDYlf3IyOZypKr4wZ8H/x5paJ2jxYyb968wMf5RXJziQgRtZsWcZ1AUtJm+Ud9OLRbYdTXmGVQny453QqK8ixH+fS7G0Kgbk/fZPPpqYWESBEyRCN5nxtsdJzLXIrJXp4RKcfVFdxzAgzrJpEtcNT4uekE/xoyM+nXs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=tnZrOTMc; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4120933b710so13515e9.0 for ; Tue, 20 Feb 2024 11:21:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708456918; x=1709061718; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cA2O3Llhx71J8bGYTlEPNCq93E6hVPmmgkxfFVoSWL8=; b=tnZrOTMcWD0ycnpdKVDgyG9dxlGI97Y7Q2sEQFGvm75XGZFTsp8Yaol/xwkuRcH56w L9MEFB69D33psdUp++bkmwrUWSl6pCCDEYvTeA5XuXGL3BbnGQKt2xizotVnSrdfro+h +B8hHBfhWWyHDShdlfXSdJ2LImi89tIZ30RHFNNdqS/2Ofc6nU5Fa1gd+7+sX0dHQpQF scff3/tuv8SkN9i/sb+6lTD652c31aK+5NQtm5i9V+RLNIGMI/oXadgk8aGlizk8lU0F kVQt2tM/c1FcS7JXYc9mz1DA7yHjOdEmTcLSjMc7DMN+DKA9MRym7J+RuKx13f5WzWZm 1NdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708456918; x=1709061718; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cA2O3Llhx71J8bGYTlEPNCq93E6hVPmmgkxfFVoSWL8=; b=pAoq3/t8+1VpiJ0FlLo3fxx7atWaTdUDLBNcoyXL/OLCUiPM7kVkKEwXH6PSbjy5GE jTeFv/okrEFwEzAsa6BpPpexfvWEIaefrcg17xaocFl0PPVC31FldZv3fLyjNJkpcJl5 EJbJIslUnd31gw2mseO0wgbKey9UgP/+t1rhNa9VF9XGxAF51PvZLEMYFEGnVw0ySmdM P94wOTzhMLKTFYBar2bdMY44IzvQMgVel/nQ1u2hoiQNHlusckklmnf2iU3N/OYRU4d4 m5XCFhpNiL5i265WPphs6uMLIPYTXGltNOJuEE6Z4QrURtx4w0KwJxQVAQ+ZiHiO0Lo/ pzsA== X-Forwarded-Encrypted: i=1; AJvYcCVPqSx1n4vHqtAd2YyEqVOfsUZWO2qvivaKZBj6eYs0uwz434fJW+kIwGwGshSzdThY0Xo5cLIrMo6OXJY3lmYuTELiQ0ErELQmSxGW X-Gm-Message-State: AOJu0Yybk8ZXeSL8U4JRElwr1HxFlqNZsBQWH0/NGET6cbxK/VoiRiRZ HB/wW/Lnq8ChC8q3F8WcAsG4+342ClZ19EH3Kl0rJSO3QfTlgyYhosWwbDaCMg== X-Received: by 2002:a05:600c:5187:b0:412:730d:ab69 with SMTP id fa7-20020a05600c518700b00412730dab69mr13734wmb.4.1708456918160; Tue, 20 Feb 2024 11:21:58 -0800 (PST) Received: from localhost ([2a02:168:96c5:1:cba0:1b55:6833:859e]) by smtp.gmail.com with ESMTPSA id u22-20020a05600c211600b00412706c3ddasm1723wml.18.2024.02.20.11.21.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 11:21:57 -0800 (PST) From: Jann Horn To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org Cc: "H. Peter Anvin" , linux-kernel@vger.kernel.org, Kees Cook , Jann Horn Subject: [PATCH 1/3] x86/boot: fix KASLR hashing to use full input Date: Tue, 20 Feb 2024 20:21:42 +0100 Message-ID: <20240220192144.2050167-2-jannh@google.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog In-Reply-To: <20240220192144.2050167-1-jannh@google.com> References: <20240220192144.2050167-1-jannh@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791446956327333810 X-GMAIL-MSGID: 1791446956327333810 rotate_xor() currently ignores up to 7 bytes of input. That likely doesn't really matter but it's still kinda wrong, so fix it. Signed-off-by: Jann Horn --- arch/x86/boot/compressed/kaslr.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c index dec961c6d16a..3ede59ad67eb 100644 --- a/arch/x86/boot/compressed/kaslr.c +++ b/arch/x86/boot/compressed/kaslr.c @@ -42,17 +42,30 @@ extern unsigned long get_cmd_line_ptr(void); static const char build_str[] = UTS_RELEASE " (" LINUX_COMPILE_BY "@" LINUX_COMPILE_HOST ") (" LINUX_COMPILER ") " UTS_VERSION; +static unsigned long rotate_xor_one(unsigned long hash, unsigned long val) +{ + /* Rotate by odd number of bits and XOR. */ + hash = (hash << ((sizeof(hash) * 8) - 7)) | (hash >> 7); + hash ^= val; + return hash; +} + static unsigned long rotate_xor(unsigned long hash, const void *area, size_t size) { size_t i; unsigned long *ptr = (unsigned long *)area; + unsigned long rest = 0; + + for (i = 0; i < size / sizeof(hash); i++) + hash = rotate_xor_one(hash, ptr[i]); - for (i = 0; i < size / sizeof(hash); i++) { - /* Rotate by odd number of bits and XOR. */ - hash = (hash << ((sizeof(hash) * 8) - 7)) | (hash >> 7); - hash ^= ptr[i]; + i = i * sizeof(hash); + for (; i < size; i++) { + rest <<= 8; + rest |= ((unsigned char *)area)[i]; } + hash = rotate_xor_one(hash, rest); return hash; } From patchwork Tue Feb 20 19:21:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jann Horn X-Patchwork-Id: 203772 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp616727dyc; Tue, 20 Feb 2024 11:22:45 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVWlXNcUYW/kvjEAeB+5WbtJY6gf/weKfbtjfNYMMpYCxA8o4kxIHOKxBEJ4Xhmhc/1EumjL5NAGo8DagJSxr8auPYy/Q== X-Google-Smtp-Source: AGHT+IE7RTkJMZ0cMdJxxBrWyPqX9dC3OTkr6XWf7gRzss3JASgGE4wkXsAIR1mo9Ftrz2xhmkpG X-Received: by 2002:a05:6214:4001:b0:68f:5ac3:8af3 with SMTP id kd1-20020a056214400100b0068f5ac38af3mr9391079qvb.22.1708456965698; Tue, 20 Feb 2024 11:22:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708456965; cv=pass; d=google.com; s=arc-20160816; b=UyHo4E2x3+iy43Pc0StBq1pkPzFZaO87lM4Dc4lxZFjLrUD0QYT59NhG9WFuQo0YkO iyme+FAEVkPE6B0R0qLTYiuEUQ/8aORLAh+i+ELHJGAsQqWX/AUVQE1hmXWik3Mqc1Aa dVfGPF9GHBfGMGTzfAoi1Ohzz8S7E0UPfpt7UDJG/m1r6thcqkQiv7eY6WAVJO1WGctS ngPbtqzZrmvq4z0snQ9f57Rsggz3f23z86SNSzdRz5tFqImxChh1VLNZnXi7Wv8Z8bd4 LxyCrmFai95s+QoELTzzPFO1np75DNTU6+YiGJm76D5VRcUP1xFBwN47SyxRlO3eHXio 1U4Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=ah2+kizpm1MHuuLA0gzHwJWSSIWURWYNeGGYOg4ToNY=; fh=Hj2i9kyhXwFKCeqfJV+RZ4kXJyhTL67vH99FeWlp5y4=; b=WNZsiJ6I28U2E1R6ty8Raa4QGHaM+e+7H10bv31gb62VJYubwEJ2KNYN6GNbnf1qV4 r1KSx46P7xUak7lZUIyf0KiN2wCFGFEnEyct12aYwn5b+G1Nq2aANsrzWD2TmhfFs8HK 3XmOqxq61ekzEpyfxcPdJKYdU0T6jTzqiLXh0gCV/X28GDVO6Y1/r8rxeTE3AKJpky63 GLZAEPphAppQ5ZwTIu9FHXIMRqWxfhpbqIHWB7TbP7dzRrCmdafMeFZW7/ixYT8pss95 yyflr+lGZja/BOGyxoms1UIhkwYLOLA2Vz/xnU+J0W9BtKkWAf+U6B2W8uI6tbJDo0+C SEiQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=u5hyRRlD; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-73588-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73588-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id a2-20020a056214062200b0068f041f354csi9002969qvx.498.2024.02.20.11.22.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 11:22:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-73588-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=u5hyRRlD; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-73588-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73588-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 6EF131C21819 for ; Tue, 20 Feb 2024 19:22:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D9F8114AD00; Tue, 20 Feb 2024 19:22:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="u5hyRRlD" Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3621414A0B2 for ; Tue, 20 Feb 2024 19:22:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708456924; cv=none; b=rN+FLP40pGklrsSx/HiY7cd9cDREgaIya5GQKprmVmffAN6nbpI2WonzVNT2FV2vmx9abJuGbnRYfy32oSiq2F2pQc3s4GPfcbeS9D7KO5qotMREoVn+lkKkPzy5n0oQv6vuzUi6UJn1BDgo/JE7GKLNHVg0KIlM6QaRwngsZnU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708456924; c=relaxed/simple; bh=37+UeHfbaDdGookO0QGGmnoCJCoWAfLqrxDYxUd6jj0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OeCnCRFpD9p863NgpEfOYjFEsHgZsZ0wgGWm7dyKAP7dTPOVLmHlrX0c7LWMKA/2P3j7JeHhc7BUB40Bnj5OLNdAEMQRyrHiflQ9r6IrDmVhpBgAtqkitdb69E/IfcO+mZzbdA/MqoFWWMjX2ILcNqNPXKCsjo9cQ7BGqWjB64M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=u5hyRRlD; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-4126df1e7bbso12955e9.0 for ; Tue, 20 Feb 2024 11:22:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708456920; x=1709061720; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ah2+kizpm1MHuuLA0gzHwJWSSIWURWYNeGGYOg4ToNY=; b=u5hyRRlDJ5tTD41TlVL/eEcLdqhBVkcXd/nFbviYoXj/o1PCW0bVBzyBFf/nhy4sIR EVZPHE2Q+B8lopTWJpmZ4PKn0JzN0w4W/+Gcd6kZkY01kSplbmxeux3yvXzGtOiYmbim 0LRuNTLVf4ETg9hQgGaVKlOZf7YhJkDqL7jMV2ekX88nHl98zCLrYnNEqb6biKHB3iJT w4FnowJhKEuPyK+NQvV9Cyrs8Fkpsd4Y0nbR7oBja/PjBbUOI5UlL4rsd1uoMYTV8RwH rDnoT05vi9xH/nD0cJQaO+6Ug5xWXLfRcEeIPMcxEYrKQOqfikVBl62zyvJj6WPu6IAU wDug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708456920; x=1709061720; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ah2+kizpm1MHuuLA0gzHwJWSSIWURWYNeGGYOg4ToNY=; b=WMneCUq3QIMe7cFPD4JDhYIMdXU64tWi+Ws2Av413dumy5nvJ5ekParDJhTsL8up5M 9BVO4f2WskW7WoK/PtR47yrPZZuhMyYqLTnyFhB0S7/bmZ8zjJi6UbYFtwzA3bNeoWsm ojdTVQ7nt8pbKYRdGKMOGLO6Oobynf0itYAcSJUGOyCt/mqXucUsdTZVDdQNTQpb+JLX JxNoYOFlE+CJV0MdVMyN9hCmtth+XIZkwWgusBGCWHrzEnjj8aTvv2GE5r5cHrKwEYsK IHaGWZt+1fz/nIz+MHea99+HK9qcOR9oB5B3Gp8Wvwe41xwqxGZon5nKGtenkPfW/1q2 ZbAg== X-Forwarded-Encrypted: i=1; AJvYcCV1LAiHkAkKyNyQ+SsgDFshye5MJRu6CIVQW02j0eSBxfC6qyW4WqL/yxLbDOunYqSm8wKw6bHU7s22ASkhKZSMjgccsAbmBz+JHbkr X-Gm-Message-State: AOJu0YwqVy5brmC0B+/fFV5HRSb2ko+xwaRvJB8TjyPpeZO9+i4L3Pyu nxH8D9ApJJV6I95dXp63UjJS/N8GOEyCJQxljRxOifyhx743XLCCME0J1CN4Nw== X-Received: by 2002:a05:600c:600f:b0:412:6d66:81d8 with SMTP id az15-20020a05600c600f00b004126d6681d8mr10163wmb.7.1708456920465; Tue, 20 Feb 2024 11:22:00 -0800 (PST) Received: from localhost ([2a02:168:96c5:1:cba0:1b55:6833:859e]) by smtp.gmail.com with ESMTPSA id y17-20020a05600c365100b004126101915esm4500wmq.4.2024.02.20.11.21.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 11:22:00 -0800 (PST) From: Jann Horn To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org Cc: "H. Peter Anvin" , linux-kernel@vger.kernel.org, Kees Cook , Jann Horn Subject: [PATCH 2/3] x86/boot: avoid recompiling misc.c for incremental rebuilds Date: Tue, 20 Feb 2024 20:21:43 +0100 Message-ID: <20240220192144.2050167-3-jannh@google.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog In-Reply-To: <20240220192144.2050167-1-jannh@google.com> References: <20240220192144.2050167-1-jannh@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791446971206274900 X-GMAIL-MSGID: 1791446971206274900 Currently, we rebuild misc.c on every incremental compilation because the generated header voffset.h (containing kernel image offsets) changes on every build. Turn the three macros we need from that header into external variables that we can separately store in another C file. Signed-off-by: Jann Horn --- arch/x86/boot/compressed/Makefile | 4 ++-- arch/x86/boot/compressed/dynamic_vars.c | 9 +++++++++ arch/x86/boot/compressed/dynamic_vars.h | 11 +++++++++++ arch/x86/boot/compressed/misc.c | 6 ++---- 4 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 arch/x86/boot/compressed/dynamic_vars.c create mode 100644 arch/x86/boot/compressed/dynamic_vars.h diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile index f19c038409aa..d18a553c16fa 100644 --- a/arch/x86/boot/compressed/Makefile +++ b/arch/x86/boot/compressed/Makefile @@ -94,11 +94,11 @@ targets += ../voffset.h $(obj)/../voffset.h: vmlinux FORCE $(call if_changed,voffset) -$(obj)/misc.o: $(obj)/../voffset.h +$(obj)/dynamic_vars.o: $(obj)/../voffset.h vmlinux-objs-y := $(obj)/vmlinux.lds $(obj)/kernel_info.o $(obj)/head_$(BITS).o \ $(obj)/misc.o $(obj)/string.o $(obj)/cmdline.o $(obj)/error.o \ - $(obj)/piggy.o $(obj)/cpuflags.o + $(obj)/piggy.o $(obj)/cpuflags.o $(obj)/dynamic_vars.o vmlinux-objs-$(CONFIG_EARLY_PRINTK) += $(obj)/early_serial_console.o vmlinux-objs-$(CONFIG_RANDOMIZE_BASE) += $(obj)/kaslr.o diff --git a/arch/x86/boot/compressed/dynamic_vars.c b/arch/x86/boot/compressed/dynamic_vars.c new file mode 100644 index 000000000000..cda64ff4b6da --- /dev/null +++ b/arch/x86/boot/compressed/dynamic_vars.c @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include "dynamic_vars.h" +#include "../voffset.h" + +const unsigned long vo__text = VO__text; +const unsigned long vo___bss_start = VO___bss_start; +const unsigned long vo__end = VO__end; +const unsigned long kernel_total_size = VO__end - VO__text; diff --git a/arch/x86/boot/compressed/dynamic_vars.h b/arch/x86/boot/compressed/dynamic_vars.h new file mode 100644 index 000000000000..a0f7dc359cb6 --- /dev/null +++ b/arch/x86/boot/compressed/dynamic_vars.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * This header defines some variables that change on every compilation and are + * stored separately in the small file dynamic-vars.c, so that we can avoid + * rebuilding some of the other C files in this directory on every incremental + * rebuild. + */ + +/* Variables containing VO__text, VO___bss_start, VO__end */ +extern const unsigned long vo__text, vo___bss_start, vo__end; +extern const unsigned long kernel_total_size; diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c index b99e08e6815b..ff13cc3e703d 100644 --- a/arch/x86/boot/compressed/misc.c +++ b/arch/x86/boot/compressed/misc.c @@ -15,8 +15,8 @@ #include "misc.h" #include "error.h" #include "pgtable.h" +#include "dynamic_vars.h" #include "../string.h" -#include "../voffset.h" #include /* @@ -188,7 +188,7 @@ static void handle_relocations(void *output, unsigned long output_len, int *reloc; unsigned long delta, map, ptr; unsigned long min_addr = (unsigned long)output; - unsigned long max_addr = min_addr + (VO___bss_start - VO__text); + unsigned long max_addr = min_addr + (vo___bss_start - vo__text); /* * Calculate the delta between where vmlinux was linked to load @@ -330,8 +330,6 @@ static size_t parse_elf(void *output) return ehdr.e_entry - LOAD_PHYSICAL_ADDR; } -const unsigned long kernel_total_size = VO__end - VO__text; - static u8 boot_heap[BOOT_HEAP_SIZE] __aligned(4); extern unsigned char input_data[]; From patchwork Tue Feb 20 19:21:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jann Horn X-Patchwork-Id: 203773 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp616814dyc; Tue, 20 Feb 2024 11:23:00 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX4SZHEAmGfzmeEZ6q8ZWMuwD1BIEoXPJqkTrPz5QlbnmxCOjRjQtduw9S6sd7UfUtEzRiS+1/JHqj/uy4gz68z9swBug== X-Google-Smtp-Source: AGHT+IEiY0e0mcxlQzoo+FKW7I87tCjDIK6vmo4vAs1GIjre21eq36zzAqS0+viTc4+zk8PjSO+Y X-Received: by 2002:a17:902:dacd:b0:1db:e792:bb25 with SMTP id q13-20020a170902dacd00b001dbe792bb25mr9686651plx.25.1708456980105; Tue, 20 Feb 2024 11:23:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708456980; cv=pass; d=google.com; s=arc-20160816; b=i+kKLzs6Amj3632JPya34sqH53h7uhvlCHtrecBhylYPHzHBuld4LeSHcNFJAZaFt6 TCezjP48HG4weAV3dYuVrszJfmnwfBtzPtwqtsIdDEnP9x9RWLebE57Q8T9XYhmsJr2K D8W3+jvMm3WFmhNefctEWx2ntU7mgRt4T6ZL2FBiZOow+QExbarmZrBAe/2boDGqx6HI 1Wb3HeXxG6VdrV3l1Pb0nNdgVTa9SOjFti2CQR42zTY0aSmT71zY+18aXdTqRUkyO/3Q 8q8uDXY3T3pHQFjQJto5W/5174TpEJYeq/6YX+FsOtm+WFPZGzAWVofg3kseDIDQ3Bbg 7axw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=J7U0RSylINsLRGIXJSZNu+mJjZueu22Q0XGcAKOsxOI=; fh=swB6l1vlqJzzuX2kFo7DlUPzLgJekTHudUB8ZSV+tJs=; b=O+KSil0T4pxTfjibSuISUCIllpWmmZPRIQu4qfHvlQCabrmJRFEK4cS0/ta9lfdSCJ TAl3s4f90H4RINpmRqqRYi3UhnaLbZ2TW8epkyeGNjOOfkQ52KaNkdaGcdzjkseqCjFV EFdRZoeCJi/Xrye2l63R440MyiY/NGPtFD7fwcpMkYIUwLKEpqR4RUKLN5iCSFWjZGpS 2z2ZND24Uobz/2WP1sgvdn8IXPxAwJT/RZ25fVaOeLJyqnd60e3KchFyS4b0FQCmT0sL eyZlN0da3us4Ze14zfzQyCLllVdpJMVRsIX9yxNRXFasF1mq38IyV0nfoY/krxl3bT8J rneA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=wa8glPLf; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-73589-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73589-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id t4-20020a170902e84400b001dbf6a7e767si3855538plg.59.2024.02.20.11.23.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 11:23:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-73589-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=wa8glPLf; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-73589-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73589-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id E0626283A79 for ; Tue, 20 Feb 2024 19:22:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7BF5A14AD2F; Tue, 20 Feb 2024 19:22:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="wa8glPLf" Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0237C14A4E7 for ; Tue, 20 Feb 2024 19:22:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708456926; cv=none; b=euWIAhLBpL1h4D0y7Qh4YEMpdrORiANffaGY5P8X4oaNuHSS+txYUyd4bUvq+nffEoBzYZujOUf5Yo3sQYsEVhG8QbPn05mRhs9G7yqZWMX4Adx7yuiPZPo2Iw5dSAvGDk6kRBQg7Q+1EBrUFZEU5ssr8upgirfPT3mp9QoHJEM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708456926; c=relaxed/simple; bh=YvRYM8i58qO9GNFhuBTMfwU9co90ceu+7bZFp+D65vk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IeZY2KEjEvBB/3PqpzDjvJDdNtv5OY0Bb5gMrQ8snPVzqmbNww2XrhfcPIIDy2kygvgAajnPHNpu5fJYJP2vWDsqf9OKvdIIDKjCIxAfAI48X1LdF6hiF9GeZ0LB042Wf0XDZ/7tyF+YFHD9Z5njVWCBQSodY4YRgcIvANaFjJM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=wa8glPLf; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4126df1e7bbso12975e9.0 for ; Tue, 20 Feb 2024 11:22:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708456923; x=1709061723; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=J7U0RSylINsLRGIXJSZNu+mJjZueu22Q0XGcAKOsxOI=; b=wa8glPLfZ+Bwsh+1VK4LO57lm7yVCI0FwJx/9vin8TanQVJY6lF8KDt+5gPcUT1ACG BuibXbBvbbeB3xPoD6OTLhpABVRyXm/jRqwJKtm8UlQ9xZjE3XCIvoovAa3Ky96FApqU vMkhwQJHULKTWPFX6Ejjn25VauRgNYlhII23euBhoUDH2hD9+rZ6XajiNVi3YdfnMa4r C08QAse5SZr41VjYy6auGlDresAVKsHWhm+Li4mGL+Aw8hBn++5yZGynKvmQ+F9FYhCq 7C8yHH/2D5NDK3gohxSvXijaiQ0u7TMAwFgq3lPN1NLyX6DctJ+SfucQsyJJ0inxFhO1 xe1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708456923; x=1709061723; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=J7U0RSylINsLRGIXJSZNu+mJjZueu22Q0XGcAKOsxOI=; b=Mpc1pUhT+Otxm4QtiEyjQAxSg9YHiLYI+l15TVIheSrNcQnyYFBBVrk0fRKar8raIV Zx//EzAp1NyTvCNyP5y7gH+WTxaa5oj/d2RQfbf5FHQg0I/HOsLOpXcD4Q4Mr5zEeYVT Kim4HN0DtE3LxEtWimOCnBSsBg56excr9tuNeTxTVLt/6tD1Uqd48AvmWmWn4eajRCMF 81mSmXjuVgOs0W5MrCvsUhkOU1mfxOOheeZ5wyI06qT7yhchKOMve8Fr+UHh3OhQakBd lpOiJofzs8V5BwKUTKIogWuKSDrMvAEGitOmBNtU5yqzwi5qpgRzSnxFJQRzo8YObxVz +hdw== X-Forwarded-Encrypted: i=1; AJvYcCXTcX0c7HmMt8p1TvNGNqsJtB3xtvge1ToAgtASlnROc9F3xXw2v5Upj37gNDlU8ec56FsM+z3hSRsl8MBzuhLoE2ROhTCVWx20Elc/ X-Gm-Message-State: AOJu0Yx9xS2U3Lid9o/cMozKsoIEKLgp9OgvwbBTw2vH4CJ3lF8Jxmwy VCSBcTivoaN7znq19LzvlWMLXMW5L45D4lP/9V2kIz1od7kYe1KqSN6jV8KaCg== X-Received: by 2002:a05:600c:b86:b0:412:689a:10f0 with SMTP id fl6-20020a05600c0b8600b00412689a10f0mr16973wmb.2.1708456923408; Tue, 20 Feb 2024 11:22:03 -0800 (PST) Received: from localhost ([2a02:168:96c5:1:cba0:1b55:6833:859e]) by smtp.gmail.com with ESMTPSA id ay23-20020a05600c1e1700b004120c78fc39sm5048wmb.3.2024.02.20.11.22.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 11:22:01 -0800 (PST) From: Jann Horn To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org Cc: "H. Peter Anvin" , linux-kernel@vger.kernel.org, Kees Cook , Jann Horn Subject: [PATCH 3/3] x86/boot: avoid recompiling kaslr.c for incremental rebuilds Date: Tue, 20 Feb 2024 20:21:44 +0100 Message-ID: <20240220192144.2050167-4-jannh@google.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog In-Reply-To: <20240220192144.2050167-1-jannh@google.com> References: <20240220192144.2050167-1-jannh@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791446986560619558 X-GMAIL-MSGID: 1791446986560619558 Currently, every kernel rebuild needs to compile kaslr.c again because UTS_VERSION changes on every rebuild. Move the build string into a separate object file to speed things up. Signed-off-by: Jann Horn --- arch/x86/boot/compressed/dynamic_vars.c | 8 ++++++++ arch/x86/boot/compressed/dynamic_vars.h | 3 +++ arch/x86/boot/compressed/kaslr.c | 10 ++-------- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/arch/x86/boot/compressed/dynamic_vars.c b/arch/x86/boot/compressed/dynamic_vars.c index cda64ff4b6da..15a57fbb05e3 100644 --- a/arch/x86/boot/compressed/dynamic_vars.c +++ b/arch/x86/boot/compressed/dynamic_vars.c @@ -1,9 +1,17 @@ // SPDX-License-Identifier: GPL-2.0 #include #include "dynamic_vars.h" +#include +#include +#include #include "../voffset.h" const unsigned long vo__text = VO__text; const unsigned long vo___bss_start = VO___bss_start; const unsigned long vo__end = VO__end; const unsigned long kernel_total_size = VO__end - VO__text; + +/* Simplified build-specific string for starting entropy. */ +const char build_str[] = UTS_RELEASE " (" LINUX_COMPILE_BY "@" + LINUX_COMPILE_HOST ") (" LINUX_COMPILER ") " UTS_VERSION; +unsigned long build_str_len = sizeof(build_str)-1; diff --git a/arch/x86/boot/compressed/dynamic_vars.h b/arch/x86/boot/compressed/dynamic_vars.h index a0f7dc359cb6..3ebc4a3144d4 100644 --- a/arch/x86/boot/compressed/dynamic_vars.h +++ b/arch/x86/boot/compressed/dynamic_vars.h @@ -9,3 +9,6 @@ /* Variables containing VO__text, VO___bss_start, VO__end */ extern const unsigned long vo__text, vo___bss_start, vo__end; extern const unsigned long kernel_total_size; + +extern const char build_str[]; +extern unsigned long build_str_len; diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c index 3ede59ad67eb..c14e4e7a6b08 100644 --- a/arch/x86/boot/compressed/kaslr.c +++ b/arch/x86/boot/compressed/kaslr.c @@ -23,14 +23,12 @@ #include "error.h" #include "../string.h" #include "efi.h" +#include "dynamic_vars.h" -#include #include #include #include #include -#include -#include #define _SETUP #include /* For COMMAND_LINE_SIZE */ @@ -38,10 +36,6 @@ extern unsigned long get_cmd_line_ptr(void); -/* Simplified build-specific string for starting entropy. */ -static const char build_str[] = UTS_RELEASE " (" LINUX_COMPILE_BY "@" - LINUX_COMPILE_HOST ") (" LINUX_COMPILER ") " UTS_VERSION; - static unsigned long rotate_xor_one(unsigned long hash, unsigned long val) { /* Rotate by odd number of bits and XOR. */ @@ -75,7 +69,7 @@ static unsigned long get_boot_seed(void) { unsigned long hash = 0; - hash = rotate_xor(hash, build_str, sizeof(build_str)); + hash = rotate_xor(hash, build_str, build_str_len); hash = rotate_xor(hash, boot_params_ptr, sizeof(*boot_params_ptr)); return hash;