From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) (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 770C43EAC61 for ; Tue, 25 Aug 2026 09:11:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787649081; cv=none; b=hLKku1nEoJnXcryec8k4PqyB4awj3WXTd46z74i1NSmtEt0zWffaL0L2hRM3fx6bGvBctdTBYC+syEC6plWzbFqGebgIx+z5SmO6CR19fm2LHmurmJajahICw2Kj9F/Ko94MjydPvgkGNkudOyxVFCSMcQyq8KXf2yjdxDY4+Gc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787649081; c=relaxed/simple; bh=tQEWaKE/wh78V7ecDhceF4ssI56SP4PKEbQQgOg7yio=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=SmHHeBvdl+iz9KEg/x7zY/HBDIwqDsK2UYUcBwM9TFVUQx95P+tMWddABogvQSFYFWr+UIrfjorsRCvYEfvYvrEY1a9/8QPPKFeIY0xGlORBnNmWvLUuXd7WE6bYfRs/v4EMxa3pP121RTthpTUfCNzt8jPdxpi0JJr2+j0juk0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=QDjigP82; arc=none smtp.client-ip=209.85.218.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="QDjigP82" Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-c15e2dab83eso838918666b.1 for ; Tue, 25 Aug 2026 02:11:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1787649077; x=1788253877; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=0mlwi5/eUS/zccQyXyc1naDz4zuh23kT0Olm9HhiAUM=; b=QDjigP82HyY1UZgYIyJVDS7zzL36XKHjkKbN2b8/zbSxIq1/q9VGOJ4QU8McaNzsNQ bpfM355OIsjQeGkvhvaMnckGm/oGx5hqrZYPDnR6mLbalppKpxaRyVBCXy1aD2Bm2Lvt wyCEg43l7snDG+HuTk3RP8HsyxFTSi3n8unhOAgBtS81WgF6PW7JIbVcXES7LbV/qUgw U7aj1QDKC/mvxr4mRW3beNgYJ0uJEHjsstbLUs97Y1ckEjYTF2RZoTOF1vahZiRYtd5U qFXULGgEN6/fUdNApbsII61w1yjj0fvqTQL1OpMytsmsT95HcMx9zzqgndSxU0OkpLoZ pNSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787649077; x=1788253877; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=0mlwi5/eUS/zccQyXyc1naDz4zuh23kT0Olm9HhiAUM=; b=A7GyV9Sko1/tTPPcSMtHXDG1/ubEHB15sg+UBkuv2LfRhp9W7PU8akiT8GGUJ1FN0B wgFBJkmJYBZLBUP5iGf77eoKK4tyTggcndcLhP6X+IWRIa6LHGyAGllZWP1/4+1kHLaP YBqGJ+woH9iU3uf+HHwuiI6GjooUeYJjT3ZsyTGtRjirf5KeyYS5SVs1TlPfc5RdA4Hc 57Uss9rvS/0Yesd3is6C57IWtkdu2charkzGuldiXujfWq4y038JzOS1o/2ufVj7BjVT W1fsmSIjegry8/4cBQx47gcn1WNmypFis8NrwfTJLFCtB/kIoZs2hzXELic9dD8PAyXo x+Zg== X-Forwarded-Encrypted: i=1; AHgh+RqZRgJx0JsbZfdsbfzbAm3VohYxpmt6hVqqnX9G0Er9T7akOUzNHDfxm1pV0+++nwCv1aQ3gx8sjQJfpvI=@vger.kernel.org X-Gm-Message-State: AFuF++kHZb+pmjR7AyasfDkM+62Otd7CFc3A6YNPuKYlGs7Or+1Tz1/+ L/lBor5LsAHLkB00rWxASV4GirXLWEBZq6elPCJ1cyphAspMANjGU0je9yoDR0aZWy0= X-Gm-Gg: AR+sD13BZgkvOgBTl6RfTJNlhDl1N8GBUOZOalnYviAj/iW1TZKE/R26lJ47evd9AWG Rme+tqATDXwR+W9+vnNOlqaPvOW+VhanahAQ+ArPujjR6UomwXhOOpcC0E2Qbs03crdvrJgV4JV 1KvfLeWSv7BZX3ArZjEl26iKPkNBviyHl/iVLU5K5KCXj4yhDSuxpEyxazHxk8Nx2EkGjOdaqlc fwH4t1B26pupYfkOeCJEvENQpDEJxu8JNQNTFwqQTsXwN4O+9e53w+oSq9J5GYBtPoV1lPmromp s8iGUeFjX9cnGZ0BuXJkM6xZr10jPSrp2GjtvWTV94Qj/ZaOoPUqO9xVXeWtNTXMWXVf/6ZzwW6 8JJI+H0J31SWG8eMKib5m6VzmqEGT6PhSwE1OheLz+DbRlYUEjv2hIuCU/mWypxBxzjj+dSdBYl +0Oqo/lmE0tiwb//fvOaCCG924TgyySPSSPUJ95LTvUcQBQV8cjpryIjpBV7NFnA== X-Received: by 2002:a17:907:3e98:b0:c16:8adf:f183 with SMTP id a640c23a62f3a-c24e5fc4f6emr562080166b.14.1787649077567; Tue, 25 Aug 2026 02:11:17 -0700 (PDT) Received: from pathway.suse.cz ([176.114.240.130]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c249673d43bsm1574630266b.47.2026.08.25.02.11.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2026 02:11:17 -0700 (PDT) Date: Tue, 25 Aug 2026 11:11:14 +0200 From: Petr Mladek To: Bradley Morgan Cc: Andrew Morton , Jinchao Wang , Feng Tang , Rio , Pnina Feder , Petr Pavlu , Sergey Senozhatsky , linux-kernel@vger.kernel.org, Sashiko , stable@vger.kernel.org Subject: Re: [PATCH v6 4/6] panic: restore variable arguments to nmi_panic() Message-ID: References: <20260818163806.17460-1-include@grrlz.net> <20260818163806.17460-5-include@grrlz.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20260818163806.17460-5-include@grrlz.net> On Tue 2026-08-18 16:38:04, Bradley Morgan wrote: > nmi_panic() used to accept variable arguments until commit > ebc41f20d77f ("panic: change nmi_panic from macro to function") > flattened it to a final message string. vpanic() did not exist back > then, so the function had to format through panic("%s", msg). > > Bring the variable arguments back and format with vpanic() directly. > The next patch makes nmi_panic() try the panic_force_cpu= redirect > before claiming panic_cpu, which needs the arguments twice: once to > format the message for the redirected CPU and once for vpanic() when > no redirect happens. Passing a final string would lose that. > > Every existing caller passes a plain string literal with no format > specifiers, so nothing changes for them. Sashiko AI complains, see https://sashiko.dev/#/patchset/20260818163806.17460-1-include%40grrlz.net | Is this assertion accurate? Looking at hpwdt_pretimeout() in | drivers/watchdog/hpwdt.c, it constructs a dynamic string before passing it: | | drivers/watchdog/hpwdt.c:hpwdt_pretimeout() { | ... | hex_byte_pack(panic_msg, nmistat); | nmi_panic(regs, panic_msg); | ... | } It is true that @panic_msg is a pointer to a string. But there are only two variants and both are plain strings with no format specifiers. Well, we will update the commit message anyway, see below. > Signed-off-by: Bradley Morgan > --- a/include/linux/panic.h > +++ b/include/linux/panic.h > @@ -13,7 +13,8 @@ __printf(1, 2) > void panic(const char *fmt, ...) __noreturn __cold; > __printf(1, 0) > void vpanic(const char *fmt, va_list args) __noreturn __cold; > -void nmi_panic(struct pt_regs *regs, const char *msg); > +__printf(2, 3) > +void nmi_panic(struct pt_regs *regs, const char *fmt, ...); Here Sashiko says: | Will this __printf() annotation cause a -Wformat-security build failure in | hpwdt_pretimeout() when compiled with CONFIG_HPWDT_NMI_DECODING, since | panic_msg is passed directly as the format argument without a "%s" | specifier? And it is right. I have reproduced it. I have explictitely added -Wformat-security and got: # CC drivers/watchdog/hpwdt.o drivers/watchdog/hpwdt.c: In function ‘hpwdt_pretimeout’: drivers/watchdog/hpwdt.c:202:9: warning: format not a string literal and no format arguments [-Wformat-security] 202 | nmi_panic(regs, panic_msg); | ^~~~~~~~~ So, we should add the %s format to be on the safe side. The following works: --- a/drivers/watchdog/hpwdt.c +++ b/drivers/watchdog/hpwdt.c @@ -199,7 +199,7 @@ static int hpwdt_pretimeout(unsigned int ulReason, struct pt_regs *regs) } hex_byte_pack(panic_msg, nmistat); - nmi_panic(regs, panic_msg); + nmi_panic(regs, "%s", panic_msg); return NMI_HANDLED; } We should do this change in this patch and mention it in the commit message which should prevent the earlier complaint. > void check_panic_on_warn(const char *origin); > extern void oops_enter(void); > extern void oops_exit(void); > diff --git a/kernel/panic.c b/kernel/panic.c > index 6b5728c3c9ce..bc142485faa4 100644 > --- a/kernel/panic.c > +++ b/kernel/panic.c > @@ -518,13 +518,20 @@ EXPORT_SYMBOL(panic_on_other_cpu); > * nmi_panic_self_stop() which can provide architecture dependent code such > * as saving register state for crash dump. > */ > -void nmi_panic(struct pt_regs *regs, const char *msg) > +__printf(2, 3) This is not needed. It is enough to declare __printf() in the header file. > +void nmi_panic(struct pt_regs *regs, const char *fmt, ...) > { > + va_list args; > + > + va_start(args, fmt); > + > if (panic_try_start()) > - panic("%s", msg); > + vpanic(fmt, args); > > if (panic_on_other_cpu()) > nmi_panic_self_stop(regs); > + > + va_end(args); > } > EXPORT_SYMBOL(nmi_panic); Otherwise, it looks good to me. Best Regards, Petr