Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2187371lqb; Mon, 27 May 2024 10:33:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUD9krilFDks26JWrTbpb+9LQctIIm8r9y266nbVeoyZG1ttYTGcyxh+ycqQn2GlQadcWc2fC6ONMQDJEHz623rIpLLXCjoxtLSOAuAgQ== X-Google-Smtp-Source: AGHT+IHvip9f9x9c3SrVLzbsbKG46KFKIOUn57M4BYAtN+dnM+wn4+jGRTWdSdiR3tZqRkNufOzN X-Received: by 2002:a19:8c5e:0:b0:51d:bbb:7a4e with SMTP id 2adb3069b0e04-529645e344bmr6181664e87.24.1716831186025; Mon, 27 May 2024 10:33:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716831185; cv=pass; d=google.com; s=arc-20160816; b=LnO6p0IfGhN0vfE50m/2CboAMvjhyUK4XztP4pGgLUDJOMimib/XUklFlMy+53FvRa sMdhPhcT6NCfYZQDINNGKrNfCTQzQJl8smM/XVxDzTU9htB5gcd+4lTuXjEMwGlvnXaL 7oxhGv7QkWrVfPcVPF5Hkw0znS5bbx13nEb70o8Ha8SnhjUlGIKL9fngDsr5zOwzE/MG Mtc+reDJBNVWiNNwr6Ejklbb2fo1QxoiToTgMsyq2PQUmk05YYs/cexWq3940RvruH1X qdOgCcl+pls0UNIDNCtGtY6wJ9qUUT51LbmaFE3R4klI2ZOoazHXxG/aZwsg5mDvGjN8 E+Bw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=WZYBMdLsa9K+LrzU0iHckKHgocxEKbi3cQi6MxeWuU0=; fh=6cFa3IzDqpcdpBdu9WkmunixBQ+D/8HcU3nQQXDfP9g=; b=GHhPchEB5FYZNEJdWSBlDHADs8gEey4UKMs5MLj6koQ9xeM0SJfyw+2P1TvUL/GsGL zv3xtYj7433+KM5+ljYsmqid1Ol/3ZhWO4HKFYr3hSdZPj4SUi1Cu0WTU5vC+XJ2mwVX 9tJpxIBCQOdjcik2jKrPIxhoUJ4b/nPogvickVSrQeoZaNBSU2Nv+LojNkhexFPowak+ SF48M8f9OBtIBzB9zV+wC18bat7pkA8rm/8nKCL743uOt6iBJw4kFCTbECoxEhm/SqAm sPw5AJzwT4g4NTGJ5bF5UQBBcBe6O2zQiGprObkTtECCdIKZ106BrzIiV3aOp6bQU7dD N4IA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=T2PKLJt8; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=roJU0M78; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-191292-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191292-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-578524d1b18si4001910a12.628.2024.05.27.10.33.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 10:33:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-191292-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=T2PKLJt8; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=roJU0M78; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-191292-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191292-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de 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 9F7FF1F22593 for ; Mon, 27 May 2024 17:32:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3206C15EFBA; Mon, 27 May 2024 17:32:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="T2PKLJt8"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="roJU0M78" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B5C052628B; Mon, 27 May 2024 17:32:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716831167; cv=none; b=fZUaizmFAIubhZvyHh6/LnoBF/mr6g27GTr3ZvVjo/2it62QgkbUfORpLv6uAZ3Xn3WAA1Hpibe7s3r4JvzbNhTj6h2zATPGMg/gfJ9HpQlH/n0ne8TU40Ul0cLS+MKQJnnXxE4fFAx+DTVL1B77d8Jry4GXwShXqFH4mrsNzJE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716831167; c=relaxed/simple; bh=xph9HqOHF5oSvesYzia/6qvqMq+qW1FJiEOBj3pWlwA=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=rZC4zVcAgnipIe89HabivevN3YMESsUxEtz2fjC3iStJAQNfOBYTSgHg3M/iM/U10lj4wfKoB8YpEE5zKKVFzLs/s/xpYALLDTwl1ODCfjJu7YfF/SKIXjfUZeuTd1DXiS8F8dI+vJIqn/Msvs7k4+YQdCyw70wmhpOnB5uj8PE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=T2PKLJt8; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=roJU0M78; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Date: Mon, 27 May 2024 17:32:43 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1716831163; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WZYBMdLsa9K+LrzU0iHckKHgocxEKbi3cQi6MxeWuU0=; b=T2PKLJt8A0ya+cdneAJZghIMI+Ufyqy8Og5R+HoIg+TN+eo/gBw5wtKDQzEgmPudtkquNn MqVNJ455ICsb/hxyybFQLLxK10ICXRRDUHsdhD87x2leR6I1eHz73TG2AMhENz4w4W/PfX mqcD5Rxm2uGFHQF5PTfaYqS0aaTQysYiE++A+EL686NHnx3AEEfzQACbJ1j9RbinEQP7+Y Iws/R+mdQoawi46z5+/rFG683JZTQKaxdL3GFqB7PFFtLdOv5555v8gDWJRgXAohITzWWj FBfNFQFJSeoG45j5VtUiLz8YMNOOUwMi33MCEMsZ1Us8lHKV1fVNCjn9BQV/tw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1716831163; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WZYBMdLsa9K+LrzU0iHckKHgocxEKbi3cQi6MxeWuU0=; b=roJU0M78DsrjHXvOu4z9J8gDck/c+/+ebaKBbbLtB2SAsjMKzuut/kqoHDXRGbvJNBZ/sP p1Ascho7w2flNqDw== From: "tip-bot2 for Borislav Petkov (AMD)" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/boot] x86/setup: Warn when option parsing is done too early Cc: "Borislav Petkov (AMD)" , Ingo Molnar , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240409152541.GCZhVd9XIPXyTNd9vc@fat_crate.local> References: <20240409152541.GCZhVd9XIPXyTNd9vc@fat_crate.local> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <171683116337.10875.5456098859763818369.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit The following commit has been merged into the x86/boot branch of tip: Commit-ID: 0c40b1c7a897bd9733e72aca2396fd3a62f1db17 Gitweb: https://git.kernel.org/tip/0c40b1c7a897bd9733e72aca2396fd3a62f1db17 Author: Borislav Petkov (AMD) AuthorDate: Mon, 08 Apr 2024 19:46:03 +02:00 Committer: Borislav Petkov (AMD) CommitterDate: Mon, 27 May 2024 18:54:45 +02:00 x86/setup: Warn when option parsing is done too early Commit 4faa0e5d6d79 ("x86/boot: Move kernel cmdline setup earlier in the boot process (again)") fixed and issue where cmdline parsing would happen before the final boot_command_line string has been built from the builtin and boot cmdlines and thus cmdline arguments would get lost. Add a check to catch any future wrong use ordering so that such issues can be caught in time. Signed-off-by: Borislav Petkov (AMD) Acked-by: Ingo Molnar Link: https://lore.kernel.org/r/20240409152541.GCZhVd9XIPXyTNd9vc@fat_crate.local --- arch/x86/include/asm/setup.h | 8 ++++++++ arch/x86/kernel/setup.c | 2 ++ arch/x86/lib/cmdline.c | 8 ++++++++ 3 files changed, 18 insertions(+) diff --git a/arch/x86/include/asm/setup.h b/arch/x86/include/asm/setup.h index e61e68d..0667b2a 100644 --- a/arch/x86/include/asm/setup.h +++ b/arch/x86/include/asm/setup.h @@ -28,6 +28,8 @@ #define NEW_CL_POINTER 0x228 /* Relative to real mode data */ #ifndef __ASSEMBLY__ +#include + #include #include @@ -133,6 +135,12 @@ asmlinkage void __init __noreturn x86_64_start_reservations(char *real_mode_data #endif /* __i386__ */ #endif /* _SETUP */ +#ifdef CONFIG_CMDLINE_BOOL +extern bool builtin_cmdline_added __ro_after_init; +#else +#define builtin_cmdline_added 0 +#endif + #else /* __ASSEMBLY */ .macro __RESERVE_BRK name, size diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index 05c5aa9..728927e 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -165,6 +165,7 @@ unsigned long saved_video_mode; static char __initdata command_line[COMMAND_LINE_SIZE]; #ifdef CONFIG_CMDLINE_BOOL static char __initdata builtin_cmdline[COMMAND_LINE_SIZE] = CONFIG_CMDLINE; +bool builtin_cmdline_added __ro_after_init; #endif #if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE) @@ -765,6 +766,7 @@ void __init setup_arch(char **cmdline_p) strscpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE); } #endif + builtin_cmdline_added = true; #endif strscpy(command_line, boot_command_line, COMMAND_LINE_SIZE); diff --git a/arch/x86/lib/cmdline.c b/arch/x86/lib/cmdline.c index 80570eb..384da1f 100644 --- a/arch/x86/lib/cmdline.c +++ b/arch/x86/lib/cmdline.c @@ -6,8 +6,10 @@ #include #include #include + #include #include +#include static inline int myisspace(u8 c) { @@ -205,12 +207,18 @@ __cmdline_find_option(const char *cmdline, int max_cmdline_size, int cmdline_find_option_bool(const char *cmdline, const char *option) { + if (IS_ENABLED(CONFIG_CMDLINE_BOOL)) + WARN_ON_ONCE(!builtin_cmdline_added); + return __cmdline_find_option_bool(cmdline, COMMAND_LINE_SIZE, option); } int cmdline_find_option(const char *cmdline, const char *option, char *buffer, int bufsize) { + if (IS_ENABLED(CONFIG_CMDLINE_BOOL)) + WARN_ON_ONCE(!builtin_cmdline_added); + return __cmdline_find_option(cmdline, COMMAND_LINE_SIZE, option, buffer, bufsize); }