From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 A7370125AC for ; Fri, 28 Jun 2024 07:13:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719558800; cv=none; b=K5oH4tPDPtElqA1vXV7S1VsoKGCvDjp6uwapNrz0kKselIMrRaZdR0yViP2ORxibsp2wGnMIvR5Dni7QfAJekq6dCuwT3aqNnjSER1ooGsTwb3r5xtCR7rYzniNps7LcSH1qF3FmWbSDnEgVPnm5NAl1ryClRCU3im6RaxtsCk4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719558800; c=relaxed/simple; bh=RwA6DNAy80mutbsLBHzLNYjy0s1N5E3RGjgs2E4XDr8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=jVVQrv4ME31mvtrtAMPNjW81fZwI5GNZVciikxNnaNs+PSeuh49TH4zAwnjm2uP52DazH7IReeS+eTjrkifaCNgx0TSmOZBQT5Hqe406cLzXFil1mS+xHRoMJMkde76oR7Yu7pElHMvLJ8CR2Y9CsnGcG3QHMvsvY6WbktljUsc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=G1BZhPGj; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="G1BZhPGj" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1719558797; h=from:from: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=uBCG6Aq7g5s4IKz6cGy3Qa4TvJeSerIQI/YPWTkVSgw=; b=G1BZhPGj/8qN5SKsEVi7e/Jm+KGYZSJNRAoVmN20uX8fXJBklm3ddTsPsMsl75RnZx9G0v afKmC6LEmIKh+1W0ozlhypsvV8ePyVtsBxRUGWm+A1CL4mqy746KH2qA/xidmJGVGscw6Q 1irbj3/EvYV8Cplzq4dds5wN1HstA/g= Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-193-ic_gFl_LP4aW_uxtI0fcXg-1; Fri, 28 Jun 2024 03:13:15 -0400 X-MC-Unique: ic_gFl_LP4aW_uxtI0fcXg-1 Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-52d174e26baso306727e87.2 for ; Fri, 28 Jun 2024 00:13:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558794; x=1720163594; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=uBCG6Aq7g5s4IKz6cGy3Qa4TvJeSerIQI/YPWTkVSgw=; b=o8wmVhoZMUu51KP7nyP67U70PynasALD9gSO7HXK5KTtNRYKx8ONzhlNqJwZqhMCmK H169u1vlqvexZvf33+TeTtx9KJ1xxMLRasEUSrLrWAR/sgmXpnxytmlRTdNRo0saXo+c uNwtV/JltZm1Alg+zWXo2CnNIkTrUw7Vg9551znzaRWjjWFfoC9A2XnPi7J6YOWsLyE9 FLV6XVSJb/rjVxrzCuwgNNmqC0qaGoiH3wUcpQNyXBcTydEAVDAkLq6masniPLzEQaPj lI74ommfANncPEaSdvTUxJcNrFm1UT/iD2cg4Q3/8dydWkqQJhMeZz4ZeMqbqImS4qvm 5JpQ== X-Forwarded-Encrypted: i=1; AJvYcCXRRiJYt8BalV+nxPBFjk6u48yxkvixDHOqt1eJa9cIWI2NG8D/eyt9kAJYlt8QOZn/w/kalgLTchvOQ8+EhuwsEDEdKSiB/P9aHFs3AeHe X-Gm-Message-State: AOJu0YxlXwpzULBLmAl324/wmeqeNxMcCjHbmLZXLUaQWUQRdTpcrqAL FgXlvYrfTqrJ5dE6hLX81YfF0IOMDIEhFW5SBqWU0mA0tWVy3j46g2pn9D7c5ahPZakQ1yMidnP QNsTneY8y8LzKdhuWKQ7ylwdxJGgQ2NtVFTMsTwPSJYHkIzKRPcesqr2n4wZo702faQ== X-Received: by 2002:a05:6512:398f:b0:52e:6d6e:5770 with SMTP id 2adb3069b0e04-52e6d6e580emr4883284e87.14.1719558794360; Fri, 28 Jun 2024 00:13:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGRNgxsh6SyinhqzjcyCteF/29SBwjZ8FpGkU83w6uoSo0McICUu/E5sqzerM5X1kwtLLuEIw== X-Received: by 2002:a05:6512:398f:b0:52e:6d6e:5770 with SMTP id 2adb3069b0e04-52e6d6e580emr4883265e87.14.1719558793916; Fri, 28 Jun 2024 00:13:13 -0700 (PDT) Received: from ?IPV6:2a01:e0a:c:37e0:38da:a7d9:7cc9:db3e? ([2a01:e0a:c:37e0:38da:a7d9:7cc9:db3e]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b0642acsm22012305e9.25.2024.06.28.00.13.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 28 Jun 2024 00:13:13 -0700 (PDT) Message-ID: <06899fda-de75-4d44-bda5-dcbb3e35d037@redhat.com> Date: Fri, 28 Jun 2024 09:13:11 +0200 Precedence: bulk X-Mailing-List: linux-hardening@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] printk: Add a short description string to kmsg_dump() To: Kees Cook Cc: Michael Ellerman , Nicholas Piggin , Christophe Leroy , "Naveen N. Rao" , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Tony Luck , "Guilherme G. Piccoli" , Petr Mladek , Steven Rostedt , John Ogness , Sergey Senozhatsky , Andrew Morton , Jani Nikula , Greg Kroah-Hartman , Kefeng Wang , Thomas Gleixner , Uros Bizjak , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-hyperv@vger.kernel.org, linux-mtd@lists.infradead.org, linux-hardening@vger.kernel.org References: <20240625123954.211184-1-jfalempe@redhat.com> <202406260906.533095B1@keescook> From: Jocelyn Falempe In-Reply-To: <202406260906.533095B1@keescook> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US, fr Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 26/06/2024 18:26, Kees Cook wrote: > On Tue, Jun 25, 2024 at 02:39:29PM +0200, Jocelyn Falempe wrote: >> kmsg_dump doesn't forward the panic reason string to the kmsg_dumper >> callback. >> This patch adds a new parameter "const char *desc" to the kmsg_dumper >> dump() callback, and update all drivers that are using it. >> >> To avoid updating all kmsg_dump() call, it adds a kmsg_dump_desc() >> function and a macro for backward compatibility. >> >> I've written this for drm_panic, but it can be useful for other >> kmsg_dumper. >> It allows to see the panic reason, like "sysrq triggered crash" >> or "VFS: Unable to mount root fs on xxxx" on the drm panic screen. > > Seems reasonable. Given the prototype before/after: > > dump(struct kmsg_dumper *dumper, enum kmsg_dump_reason reason) > > dump(struct kmsg_dumper *dumper, enum kmsg_dump_reason reason, > const char *desc) > > Perhaps this should instead be a struct that the panic fills in? Then > it'll be easy to adjust the struct in the future: yes that's a good idea, so it's a bit more flexible. > > struct kmsg_dump_detail { > enum kmsg_dump_reason reason; > const char *description; > }; > > dump(struct kmsg_dumper *dumper, struct kmsg_dump *detail) > > This .cocci could do the conversion: > > > @ dump_func @ > identifier DUMPER, CALLBACK; > @@ > > struct kmsg_dumper DUMPER = { > .dump = CALLBACK, > }; > > @ detail @ > identifier dump_func.CALLBACK; > identifier DUMPER, REASON; > @@ > > CALLBACK(struct kmsg_dumper *DUMPER, > - enum kmsg_dump_reason REASON > + struct kmsg_dump_detail *detail > ) > { > <... > - REASON > + detail->reason > ...> > } > > > Also, just to double-check, doesn't the panic reason show up in the > kmsg_dump log itself (at the end?) I ask since for pstore, "desc" is > likely redundant since it's capturing the entire console log. It is present in the kdump log, but before all the register dumps. So to retrieve it you need to parse the last 30~40 lines of logs, and search for a line starting with "Kernel panic - not syncing". https://elixir.bootlin.com/linux/v6.10-rc5/source/kernel/panic.c#L341 But I think that's a bit messy, and I prefer having a kmsg_dump parameter. -- Jocelyn > > -Kees > > Here's the patch from the above cocci: > > > diff -u -p a/drivers/hv/hv_common.c b/drivers/hv/hv_common.c > --- a/drivers/hv/hv_common.c > +++ b/drivers/hv/hv_common.c > @@ -207,13 +207,13 @@ static int hv_die_panic_notify_crash(str > * buffer and call into Hyper-V to transfer the data. > */ > static void hv_kmsg_dump(struct kmsg_dumper *dumper, > - enum kmsg_dump_reason reason) > + struct kmsg_dump_detail *detail) > { > struct kmsg_dump_iter iter; > size_t bytes_written; > > /* We are only interested in panics. */ > - if (reason != KMSG_DUMP_PANIC || !sysctl_record_panic_msg) > + if (detail->reason != KMSG_DUMP_PANIC || !sysctl_record_panic_msg) > return; > > /* > diff -u -p a/arch/powerpc/platforms/powernv/opal-kmsg.c b/arch/powerpc/platforms/powernv/opal-kmsg.c > --- a/arch/powerpc/platforms/powernv/opal-kmsg.c > +++ b/arch/powerpc/platforms/powernv/opal-kmsg.c > @@ -20,13 +20,13 @@ > * message, it just ensures that OPAL completely flushes the console buffer. > */ > static void kmsg_dump_opal_console_flush(struct kmsg_dumper *dumper, > - enum kmsg_dump_reason reason) > + struct kmsg_dump_detail *detail) > { > /* > * Outside of a panic context the pollers will continue to run, > * so we don't need to do any special flushing. > */ > - if (reason != KMSG_DUMP_PANIC) > + if (detail->reason != KMSG_DUMP_PANIC) > return; > > opal_flush_console(0); > diff -u -p a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c > --- a/arch/powerpc/kernel/nvram_64.c > +++ b/arch/powerpc/kernel/nvram_64.c > @@ -73,7 +73,7 @@ static const char *nvram_os_partitions[] > }; > > static void oops_to_nvram(struct kmsg_dumper *dumper, > - enum kmsg_dump_reason reason); > + struct kmsg_dump_detail *detail); > > static struct kmsg_dumper nvram_kmsg_dumper = { > .dump = oops_to_nvram > @@ -643,7 +643,7 @@ void __init nvram_init_oops_partition(in > * partition. If that's too much, go back and capture uncompressed text. > */ > static void oops_to_nvram(struct kmsg_dumper *dumper, > - enum kmsg_dump_reason reason) > + struct kmsg_dump_detail *detail) > { > struct oops_log_info *oops_hdr = (struct oops_log_info *)oops_buf; > static unsigned int oops_count = 0; > @@ -655,7 +655,7 @@ static void oops_to_nvram(struct kmsg_du > unsigned int err_type = ERR_TYPE_KERNEL_PANIC_GZ; > int rc = -1; > > - switch (reason) { > + switch (detail->reason) { > case KMSG_DUMP_SHUTDOWN: > /* These are almost always orderly shutdowns. */ > return; > @@ -671,7 +671,7 @@ static void oops_to_nvram(struct kmsg_du > break; > default: > pr_err("%s: ignoring unrecognized KMSG_DUMP_* reason %d\n", > - __func__, (int) reason); > + __func__, (int) detail->reason); > return; > } > > warning: detail, node 59: record.reason = ... ;[1,2,21,22,32] in pstore_dump may be inconsistently modified > warning: detail, node 105: if[1,2,21,22,54] in pstore_dump may be inconsistently modified > diff -u -p a/fs/pstore/platform.c b/fs/pstore/platform.c > --- a/fs/pstore/platform.c > +++ b/fs/pstore/platform.c > @@ -275,7 +275,7 @@ void pstore_record_init(struct pstore_re > * end of the buffer. > */ > static void pstore_dump(struct kmsg_dumper *dumper, > - enum kmsg_dump_reason reason) > + struct kmsg_dump_detail *detail) > { > struct kmsg_dump_iter iter; > unsigned long total = 0; > @@ -285,9 +285,9 @@ static void pstore_dump(struct kmsg_dump > int saved_ret = 0; > int ret; > > - why = kmsg_dump_reason_str(reason); > + why = kmsg_dump_reason_str(detail->reason); > > - if (pstore_cannot_block_path(reason)) { > + if (pstore_cannot_block_path(detail->reason)) { > if (!spin_trylock_irqsave(&psinfo->buf_lock, flags)) { > pr_err("dump skipped in %s path because of concurrent dump\n", > in_nmi() ? "NMI" : why); > @@ -311,7 +311,7 @@ static void pstore_dump(struct kmsg_dump > pstore_record_init(&record, psinfo); > record.type = PSTORE_TYPE_DMESG; > record.count = oopscount; > - record.reason = reason; > + record.reason = detail->reason; > record.part = part; > record.buf = psinfo->buf; > > @@ -352,7 +352,7 @@ static void pstore_dump(struct kmsg_dump > } > > ret = psinfo->write(&record); > - if (ret == 0 && reason == KMSG_DUMP_OOPS) { > + if (ret == 0 && detail->reason == KMSG_DUMP_OOPS) { > pstore_new_entry = 1; > pstore_timer_kick(); > } else { > diff -u -p a/arch/um/kernel/kmsg_dump.c b/arch/um/kernel/kmsg_dump.c > --- a/arch/um/kernel/kmsg_dump.c > +++ b/arch/um/kernel/kmsg_dump.c > @@ -8,7 +8,7 @@ > #include > > static void kmsg_dumper_stdout(struct kmsg_dumper *dumper, > - enum kmsg_dump_reason reason) > + struct kmsg_dump_detail *detail) > { > static struct kmsg_dump_iter iter; > static DEFINE_SPINLOCK(lock); > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1A214C2BBCA for ; Fri, 28 Jun 2024 07:13:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ouPCSe1isUUar0NC/pgiiE+JZG7LHZ15OL6zBBA257U=; b=hTXnLONVOFhM3h vYinGSYZp2OGYSnazpL++rhO5ZBex2mTMZ5PolOjlmOSvaZyxTkXJzIhs4HbZhpYibTaGKptd/SFO rGMtb3kneI59D07e+s6Sxs81/wk2gs9JBhr4h9TJgDsXA9oanKWHWgybePWnqEFt86DoMqxpCDvkG 4YW1gueTXaAuT/WMqCl3eyHtQV1HWgeRtufta5b2NQa0abeWc/MrMNf10cDgprxaq763Eu0gv8zet 97to2QRyKhCxtsVuPdYqpBOMPVt+/4OQrmuvM4AHjWMP2tay7eVaPAFzmEYZuI3TcvRE3ZpO6YqeW t5bknkVxf3+DhFKNiZWg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sN5nP-0000000CrRV-1Sbh; Fri, 28 Jun 2024 07:13:23 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sN5nL-0000000CrQu-1Cvx for linux-mtd@lists.infradead.org; Fri, 28 Jun 2024 07:13:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1719558797; h=from:from: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=uBCG6Aq7g5s4IKz6cGy3Qa4TvJeSerIQI/YPWTkVSgw=; b=G1BZhPGj/8qN5SKsEVi7e/Jm+KGYZSJNRAoVmN20uX8fXJBklm3ddTsPsMsl75RnZx9G0v afKmC6LEmIKh+1W0ozlhypsvV8ePyVtsBxRUGWm+A1CL4mqy746KH2qA/xidmJGVGscw6Q 1irbj3/EvYV8Cplzq4dds5wN1HstA/g= Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-169-kHRB8egrNw2w3mBIXssHPg-1; Fri, 28 Jun 2024 03:13:15 -0400 X-MC-Unique: kHRB8egrNw2w3mBIXssHPg-1 Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-52e76856405so253308e87.1 for ; Fri, 28 Jun 2024 00:13:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558794; x=1720163594; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=uBCG6Aq7g5s4IKz6cGy3Qa4TvJeSerIQI/YPWTkVSgw=; b=LJ2C4B2V0qnuwTgJSfNuqWrsGS3eKMVz6C4NZYhRx+uBi7gFcAGP86ueYL5qPPhPkE Ai1xILmRJTPXkoctg4xVqOsqIku7tv4kNZ51Zxc80HAKiFByJnSbSXZrE+EBNPPjm128 GM7QN/obk7z8PH1UkItB8BhvLKKTlhGIMPpeTgoltiZ9RCUjn0O6QyM4aQTTuR8O7MAC AyaIA45s+fw1LDK77onbPjSBq9g/MsloCzUiPUL/EhLSc/ZOn2GJpwMFcL5kjhO1+XPS tDgFFlqB389OxqbkfKhRT8PGFrFD9CLG774U5YbeSiTZP1tEU/hcz5FK2hL/MCNAqmld mzxQ== X-Forwarded-Encrypted: i=1; AJvYcCXczI9ZAYM9E8c664Ocz2v8eALhOftsdSCPpLzbuSGFgPSCYymlQKupWWeNKtpE/F43ueJAv7ZcV6EOmqUlKIXx5L+5CZMmyxaZ0FzaZg== X-Gm-Message-State: AOJu0Yz9leTGn+Obs2kWJymj0Otr3qpeFw3NRvIx8K58En0pCetwyGOW xZLZhbkfzm0dz4tpJfOxUes3QdcZBBLJAsonOI1baQRqpyV7LGPmVb/N3M/LMoBPERhBtYDC3J/ E8CtWp87AFwJT8pMUX8Lyh+6YP63Mkj9H8eG6Kjy2DGVyldThVBm1Psl9a6Rnr/g= X-Received: by 2002:a05:6512:398f:b0:52e:6d6e:5770 with SMTP id 2adb3069b0e04-52e6d6e580emr4883302e87.14.1719558794368; Fri, 28 Jun 2024 00:13:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGRNgxsh6SyinhqzjcyCteF/29SBwjZ8FpGkU83w6uoSo0McICUu/E5sqzerM5X1kwtLLuEIw== X-Received: by 2002:a05:6512:398f:b0:52e:6d6e:5770 with SMTP id 2adb3069b0e04-52e6d6e580emr4883265e87.14.1719558793916; Fri, 28 Jun 2024 00:13:13 -0700 (PDT) Received: from ?IPV6:2a01:e0a:c:37e0:38da:a7d9:7cc9:db3e? ([2a01:e0a:c:37e0:38da:a7d9:7cc9:db3e]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b0642acsm22012305e9.25.2024.06.28.00.13.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 28 Jun 2024 00:13:13 -0700 (PDT) Message-ID: <06899fda-de75-4d44-bda5-dcbb3e35d037@redhat.com> Date: Fri, 28 Jun 2024 09:13:11 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] printk: Add a short description string to kmsg_dump() To: Kees Cook Cc: Michael Ellerman , Nicholas Piggin , Christophe Leroy , "Naveen N. Rao" , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Tony Luck , "Guilherme G. Piccoli" , Petr Mladek , Steven Rostedt , John Ogness , Sergey Senozhatsky , Andrew Morton , Jani Nikula , Greg Kroah-Hartman , Kefeng Wang , Thomas Gleixner , Uros Bizjak , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-hyperv@vger.kernel.org, linux-mtd@lists.infradead.org, linux-hardening@vger.kernel.org References: <20240625123954.211184-1-jfalempe@redhat.com> <202406260906.533095B1@keescook> From: Jocelyn Falempe In-Reply-To: <202406260906.533095B1@keescook> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US, fr X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240628_001319_449151_824F3608 X-CRM114-Status: GOOD ( 35.08 ) X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-mtd" Errors-To: linux-mtd-bounces+linux-mtd=archiver.kernel.org@lists.infradead.org On 26/06/2024 18:26, Kees Cook wrote: > On Tue, Jun 25, 2024 at 02:39:29PM +0200, Jocelyn Falempe wrote: >> kmsg_dump doesn't forward the panic reason string to the kmsg_dumper >> callback. >> This patch adds a new parameter "const char *desc" to the kmsg_dumper >> dump() callback, and update all drivers that are using it. >> >> To avoid updating all kmsg_dump() call, it adds a kmsg_dump_desc() >> function and a macro for backward compatibility. >> >> I've written this for drm_panic, but it can be useful for other >> kmsg_dumper. >> It allows to see the panic reason, like "sysrq triggered crash" >> or "VFS: Unable to mount root fs on xxxx" on the drm panic screen. > > Seems reasonable. Given the prototype before/after: > > dump(struct kmsg_dumper *dumper, enum kmsg_dump_reason reason) > > dump(struct kmsg_dumper *dumper, enum kmsg_dump_reason reason, > const char *desc) > > Perhaps this should instead be a struct that the panic fills in? Then > it'll be easy to adjust the struct in the future: yes that's a good idea, so it's a bit more flexible. > > struct kmsg_dump_detail { > enum kmsg_dump_reason reason; > const char *description; > }; > > dump(struct kmsg_dumper *dumper, struct kmsg_dump *detail) > > This .cocci could do the conversion: > > > @ dump_func @ > identifier DUMPER, CALLBACK; > @@ > > struct kmsg_dumper DUMPER = { > .dump = CALLBACK, > }; > > @ detail @ > identifier dump_func.CALLBACK; > identifier DUMPER, REASON; > @@ > > CALLBACK(struct kmsg_dumper *DUMPER, > - enum kmsg_dump_reason REASON > + struct kmsg_dump_detail *detail > ) > { > <... > - REASON > + detail->reason > ...> > } > > > Also, just to double-check, doesn't the panic reason show up in the > kmsg_dump log itself (at the end?) I ask since for pstore, "desc" is > likely redundant since it's capturing the entire console log. It is present in the kdump log, but before all the register dumps. So to retrieve it you need to parse the last 30~40 lines of logs, and search for a line starting with "Kernel panic - not syncing". https://elixir.bootlin.com/linux/v6.10-rc5/source/kernel/panic.c#L341 But I think that's a bit messy, and I prefer having a kmsg_dump parameter. -- Jocelyn > > -Kees > > Here's the patch from the above cocci: > > > diff -u -p a/drivers/hv/hv_common.c b/drivers/hv/hv_common.c > --- a/drivers/hv/hv_common.c > +++ b/drivers/hv/hv_common.c > @@ -207,13 +207,13 @@ static int hv_die_panic_notify_crash(str > * buffer and call into Hyper-V to transfer the data. > */ > static void hv_kmsg_dump(struct kmsg_dumper *dumper, > - enum kmsg_dump_reason reason) > + struct kmsg_dump_detail *detail) > { > struct kmsg_dump_iter iter; > size_t bytes_written; > > /* We are only interested in panics. */ > - if (reason != KMSG_DUMP_PANIC || !sysctl_record_panic_msg) > + if (detail->reason != KMSG_DUMP_PANIC || !sysctl_record_panic_msg) > return; > > /* > diff -u -p a/arch/powerpc/platforms/powernv/opal-kmsg.c b/arch/powerpc/platforms/powernv/opal-kmsg.c > --- a/arch/powerpc/platforms/powernv/opal-kmsg.c > +++ b/arch/powerpc/platforms/powernv/opal-kmsg.c > @@ -20,13 +20,13 @@ > * message, it just ensures that OPAL completely flushes the console buffer. > */ > static void kmsg_dump_opal_console_flush(struct kmsg_dumper *dumper, > - enum kmsg_dump_reason reason) > + struct kmsg_dump_detail *detail) > { > /* > * Outside of a panic context the pollers will continue to run, > * so we don't need to do any special flushing. > */ > - if (reason != KMSG_DUMP_PANIC) > + if (detail->reason != KMSG_DUMP_PANIC) > return; > > opal_flush_console(0); > diff -u -p a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c > --- a/arch/powerpc/kernel/nvram_64.c > +++ b/arch/powerpc/kernel/nvram_64.c > @@ -73,7 +73,7 @@ static const char *nvram_os_partitions[] > }; > > static void oops_to_nvram(struct kmsg_dumper *dumper, > - enum kmsg_dump_reason reason); > + struct kmsg_dump_detail *detail); > > static struct kmsg_dumper nvram_kmsg_dumper = { > .dump = oops_to_nvram > @@ -643,7 +643,7 @@ void __init nvram_init_oops_partition(in > * partition. If that's too much, go back and capture uncompressed text. > */ > static void oops_to_nvram(struct kmsg_dumper *dumper, > - enum kmsg_dump_reason reason) > + struct kmsg_dump_detail *detail) > { > struct oops_log_info *oops_hdr = (struct oops_log_info *)oops_buf; > static unsigned int oops_count = 0; > @@ -655,7 +655,7 @@ static void oops_to_nvram(struct kmsg_du > unsigned int err_type = ERR_TYPE_KERNEL_PANIC_GZ; > int rc = -1; > > - switch (reason) { > + switch (detail->reason) { > case KMSG_DUMP_SHUTDOWN: > /* These are almost always orderly shutdowns. */ > return; > @@ -671,7 +671,7 @@ static void oops_to_nvram(struct kmsg_du > break; > default: > pr_err("%s: ignoring unrecognized KMSG_DUMP_* reason %d\n", > - __func__, (int) reason); > + __func__, (int) detail->reason); > return; > } > > warning: detail, node 59: record.reason = ... ;[1,2,21,22,32] in pstore_dump may be inconsistently modified > warning: detail, node 105: if[1,2,21,22,54] in pstore_dump may be inconsistently modified > diff -u -p a/fs/pstore/platform.c b/fs/pstore/platform.c > --- a/fs/pstore/platform.c > +++ b/fs/pstore/platform.c > @@ -275,7 +275,7 @@ void pstore_record_init(struct pstore_re > * end of the buffer. > */ > static void pstore_dump(struct kmsg_dumper *dumper, > - enum kmsg_dump_reason reason) > + struct kmsg_dump_detail *detail) > { > struct kmsg_dump_iter iter; > unsigned long total = 0; > @@ -285,9 +285,9 @@ static void pstore_dump(struct kmsg_dump > int saved_ret = 0; > int ret; > > - why = kmsg_dump_reason_str(reason); > + why = kmsg_dump_reason_str(detail->reason); > > - if (pstore_cannot_block_path(reason)) { > + if (pstore_cannot_block_path(detail->reason)) { > if (!spin_trylock_irqsave(&psinfo->buf_lock, flags)) { > pr_err("dump skipped in %s path because of concurrent dump\n", > in_nmi() ? "NMI" : why); > @@ -311,7 +311,7 @@ static void pstore_dump(struct kmsg_dump > pstore_record_init(&record, psinfo); > record.type = PSTORE_TYPE_DMESG; > record.count = oopscount; > - record.reason = reason; > + record.reason = detail->reason; > record.part = part; > record.buf = psinfo->buf; > > @@ -352,7 +352,7 @@ static void pstore_dump(struct kmsg_dump > } > > ret = psinfo->write(&record); > - if (ret == 0 && reason == KMSG_DUMP_OOPS) { > + if (ret == 0 && detail->reason == KMSG_DUMP_OOPS) { > pstore_new_entry = 1; > pstore_timer_kick(); > } else { > diff -u -p a/arch/um/kernel/kmsg_dump.c b/arch/um/kernel/kmsg_dump.c > --- a/arch/um/kernel/kmsg_dump.c > +++ b/arch/um/kernel/kmsg_dump.c > @@ -8,7 +8,7 @@ > #include > > static void kmsg_dumper_stdout(struct kmsg_dumper *dumper, > - enum kmsg_dump_reason reason) > + struct kmsg_dump_detail *detail) > { > static struct kmsg_dump_iter iter; > static DEFINE_SPINLOCK(lock); > ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 453C2C2BBCA for ; Fri, 28 Jun 2024 07:14:06 +0000 (UTC) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=OdcrGxUJ; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=OdcrGxUJ; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4W9RWH4sNNz3cbL for ; Fri, 28 Jun 2024 17:14:03 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=OdcrGxUJ; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=OdcrGxUJ; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=redhat.com (client-ip=170.10.129.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=jfalempe@redhat.com; receiver=lists.ozlabs.org) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4W9RVV32Bqz2yvx for ; Fri, 28 Jun 2024 17:13:21 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1719558798; h=from:from: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=uBCG6Aq7g5s4IKz6cGy3Qa4TvJeSerIQI/YPWTkVSgw=; b=OdcrGxUJ9oSJ6XDMdNkxUd/Ou152i5CFPu/oGaWbYHJCiIA5lpU6yIAf+RbZFm8yTI1OpP Ctq2+YE0UqNYR7As1arsh8uLP8rnZ1A1UTX4WAvkkxUaln2MFhWEyJ47sMhInHU711F4Nu 5zSwDGx5t5a5ev2gveh0ybAtRYHlKKo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1719558798; h=from:from: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=uBCG6Aq7g5s4IKz6cGy3Qa4TvJeSerIQI/YPWTkVSgw=; b=OdcrGxUJ9oSJ6XDMdNkxUd/Ou152i5CFPu/oGaWbYHJCiIA5lpU6yIAf+RbZFm8yTI1OpP Ctq2+YE0UqNYR7As1arsh8uLP8rnZ1A1UTX4WAvkkxUaln2MFhWEyJ47sMhInHU711F4Nu 5zSwDGx5t5a5ev2gveh0ybAtRYHlKKo= Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-179-BEyqT_ChN5OREvvEhxVQPA-1; Fri, 28 Jun 2024 03:13:16 -0400 X-MC-Unique: BEyqT_ChN5OREvvEhxVQPA-1 Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-52cdc4a8f44so297436e87.0 for ; Fri, 28 Jun 2024 00:13:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558794; x=1720163594; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=uBCG6Aq7g5s4IKz6cGy3Qa4TvJeSerIQI/YPWTkVSgw=; b=iC0mdku1BU+E3wLe+XjRlOhNqMDEpk/Se1mGdJ413CtVEElOf4NWpG+ZqfCzGPll/E g6OCkdSVXCv7W7aWvX0j38mLxhiM+LBaKGGofCSbyRI9agFAEwuD4Mp9p5k/idEhZCT2 cyJUkoer1l0c864m4oFktkC001aX9KVMghcVnzsnq0WzwsbnNgT8IlYbrn2Fj3YXw5E1 mR17FCrF3sZMF5m6skyTcQXElJbqcs5sVkpA2ldJGaw3siCs1Rb8p8fPVHYruhG3bQK6 dRs0npFg599bTHZW6fefJLVRQ09DMbFNxTTm5yFEzLUy15IFHfHg74ioWF4HK0UleCSF SNMQ== X-Forwarded-Encrypted: i=1; AJvYcCWRTml5OWQ2q8PJjDaYk/yOS8YoG5GwOCmOUs7NVb4z+yeg3ABN8w5/L9R3uCDbVWmnRcg20DHGRdGj23Y1phvGoHDgS4mY94QkXU7tkA== X-Gm-Message-State: AOJu0YxaiZpos9t0XVDy1Abz5yYRjCpEF2R2KcgAr6QyQYaMoh6COy31 41DZ6bf7nC8sFyLnfxXo75w2Wil3wZLm2UnDQ84UFdWTw1flcODGBwgEMCu18x6fqt15IPaVSGl w9uIgfQuWyn71teqKOroZoXahTlPXcDl2kq9NjqoNoAZohPkcRb+pJip5cddC0ts= X-Received: by 2002:a05:6512:398f:b0:52e:6d6e:5770 with SMTP id 2adb3069b0e04-52e6d6e580emr4883303e87.14.1719558794368; Fri, 28 Jun 2024 00:13:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGRNgxsh6SyinhqzjcyCteF/29SBwjZ8FpGkU83w6uoSo0McICUu/E5sqzerM5X1kwtLLuEIw== X-Received: by 2002:a05:6512:398f:b0:52e:6d6e:5770 with SMTP id 2adb3069b0e04-52e6d6e580emr4883265e87.14.1719558793916; Fri, 28 Jun 2024 00:13:13 -0700 (PDT) Received: from ?IPV6:2a01:e0a:c:37e0:38da:a7d9:7cc9:db3e? ([2a01:e0a:c:37e0:38da:a7d9:7cc9:db3e]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b0642acsm22012305e9.25.2024.06.28.00.13.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 28 Jun 2024 00:13:13 -0700 (PDT) Message-ID: <06899fda-de75-4d44-bda5-dcbb3e35d037@redhat.com> Date: Fri, 28 Jun 2024 09:13:11 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] printk: Add a short description string to kmsg_dump() To: Kees Cook References: <20240625123954.211184-1-jfalempe@redhat.com> <202406260906.533095B1@keescook> From: Jocelyn Falempe In-Reply-To: <202406260906.533095B1@keescook> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US, fr Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kefeng Wang , Vignesh Raghavendra , Uros Bizjak , linux-hyperv@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mtd@lists.infradead.org, linux-hardening@vger.kernel.org, Miquel Raynal , "K. Y. Srinivasan" , David Airlie , Wei Liu , "Guilherme G. Piccoli" , Dexuan Cui , Christophe Leroy , "Naveen N. Rao" , Petr Mladek , Thomas Zimmermann , John Ogness , Jani Nikula , Haiyang Zhang , Maarten Lankhorst , Maxime Ripard , Steven Rostedt , Thomas Gleixner , Tony Luck , Greg Kroah-Hartman , Nicholas Piggin , linux-kernel@vger.kernel.org, Sergey Senozhatsky , Daniel Vetter , Richard Weinberger , Andrew Morton , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On 26/06/2024 18:26, Kees Cook wrote: > On Tue, Jun 25, 2024 at 02:39:29PM +0200, Jocelyn Falempe wrote: >> kmsg_dump doesn't forward the panic reason string to the kmsg_dumper >> callback. >> This patch adds a new parameter "const char *desc" to the kmsg_dumper >> dump() callback, and update all drivers that are using it. >> >> To avoid updating all kmsg_dump() call, it adds a kmsg_dump_desc() >> function and a macro for backward compatibility. >> >> I've written this for drm_panic, but it can be useful for other >> kmsg_dumper. >> It allows to see the panic reason, like "sysrq triggered crash" >> or "VFS: Unable to mount root fs on xxxx" on the drm panic screen. > > Seems reasonable. Given the prototype before/after: > > dump(struct kmsg_dumper *dumper, enum kmsg_dump_reason reason) > > dump(struct kmsg_dumper *dumper, enum kmsg_dump_reason reason, > const char *desc) > > Perhaps this should instead be a struct that the panic fills in? Then > it'll be easy to adjust the struct in the future: yes that's a good idea, so it's a bit more flexible. > > struct kmsg_dump_detail { > enum kmsg_dump_reason reason; > const char *description; > }; > > dump(struct kmsg_dumper *dumper, struct kmsg_dump *detail) > > This .cocci could do the conversion: > > > @ dump_func @ > identifier DUMPER, CALLBACK; > @@ > > struct kmsg_dumper DUMPER = { > .dump = CALLBACK, > }; > > @ detail @ > identifier dump_func.CALLBACK; > identifier DUMPER, REASON; > @@ > > CALLBACK(struct kmsg_dumper *DUMPER, > - enum kmsg_dump_reason REASON > + struct kmsg_dump_detail *detail > ) > { > <... > - REASON > + detail->reason > ...> > } > > > Also, just to double-check, doesn't the panic reason show up in the > kmsg_dump log itself (at the end?) I ask since for pstore, "desc" is > likely redundant since it's capturing the entire console log. It is present in the kdump log, but before all the register dumps. So to retrieve it you need to parse the last 30~40 lines of logs, and search for a line starting with "Kernel panic - not syncing". https://elixir.bootlin.com/linux/v6.10-rc5/source/kernel/panic.c#L341 But I think that's a bit messy, and I prefer having a kmsg_dump parameter. -- Jocelyn > > -Kees > > Here's the patch from the above cocci: > > > diff -u -p a/drivers/hv/hv_common.c b/drivers/hv/hv_common.c > --- a/drivers/hv/hv_common.c > +++ b/drivers/hv/hv_common.c > @@ -207,13 +207,13 @@ static int hv_die_panic_notify_crash(str > * buffer and call into Hyper-V to transfer the data. > */ > static void hv_kmsg_dump(struct kmsg_dumper *dumper, > - enum kmsg_dump_reason reason) > + struct kmsg_dump_detail *detail) > { > struct kmsg_dump_iter iter; > size_t bytes_written; > > /* We are only interested in panics. */ > - if (reason != KMSG_DUMP_PANIC || !sysctl_record_panic_msg) > + if (detail->reason != KMSG_DUMP_PANIC || !sysctl_record_panic_msg) > return; > > /* > diff -u -p a/arch/powerpc/platforms/powernv/opal-kmsg.c b/arch/powerpc/platforms/powernv/opal-kmsg.c > --- a/arch/powerpc/platforms/powernv/opal-kmsg.c > +++ b/arch/powerpc/platforms/powernv/opal-kmsg.c > @@ -20,13 +20,13 @@ > * message, it just ensures that OPAL completely flushes the console buffer. > */ > static void kmsg_dump_opal_console_flush(struct kmsg_dumper *dumper, > - enum kmsg_dump_reason reason) > + struct kmsg_dump_detail *detail) > { > /* > * Outside of a panic context the pollers will continue to run, > * so we don't need to do any special flushing. > */ > - if (reason != KMSG_DUMP_PANIC) > + if (detail->reason != KMSG_DUMP_PANIC) > return; > > opal_flush_console(0); > diff -u -p a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c > --- a/arch/powerpc/kernel/nvram_64.c > +++ b/arch/powerpc/kernel/nvram_64.c > @@ -73,7 +73,7 @@ static const char *nvram_os_partitions[] > }; > > static void oops_to_nvram(struct kmsg_dumper *dumper, > - enum kmsg_dump_reason reason); > + struct kmsg_dump_detail *detail); > > static struct kmsg_dumper nvram_kmsg_dumper = { > .dump = oops_to_nvram > @@ -643,7 +643,7 @@ void __init nvram_init_oops_partition(in > * partition. If that's too much, go back and capture uncompressed text. > */ > static void oops_to_nvram(struct kmsg_dumper *dumper, > - enum kmsg_dump_reason reason) > + struct kmsg_dump_detail *detail) > { > struct oops_log_info *oops_hdr = (struct oops_log_info *)oops_buf; > static unsigned int oops_count = 0; > @@ -655,7 +655,7 @@ static void oops_to_nvram(struct kmsg_du > unsigned int err_type = ERR_TYPE_KERNEL_PANIC_GZ; > int rc = -1; > > - switch (reason) { > + switch (detail->reason) { > case KMSG_DUMP_SHUTDOWN: > /* These are almost always orderly shutdowns. */ > return; > @@ -671,7 +671,7 @@ static void oops_to_nvram(struct kmsg_du > break; > default: > pr_err("%s: ignoring unrecognized KMSG_DUMP_* reason %d\n", > - __func__, (int) reason); > + __func__, (int) detail->reason); > return; > } > > warning: detail, node 59: record.reason = ... ;[1,2,21,22,32] in pstore_dump may be inconsistently modified > warning: detail, node 105: if[1,2,21,22,54] in pstore_dump may be inconsistently modified > diff -u -p a/fs/pstore/platform.c b/fs/pstore/platform.c > --- a/fs/pstore/platform.c > +++ b/fs/pstore/platform.c > @@ -275,7 +275,7 @@ void pstore_record_init(struct pstore_re > * end of the buffer. > */ > static void pstore_dump(struct kmsg_dumper *dumper, > - enum kmsg_dump_reason reason) > + struct kmsg_dump_detail *detail) > { > struct kmsg_dump_iter iter; > unsigned long total = 0; > @@ -285,9 +285,9 @@ static void pstore_dump(struct kmsg_dump > int saved_ret = 0; > int ret; > > - why = kmsg_dump_reason_str(reason); > + why = kmsg_dump_reason_str(detail->reason); > > - if (pstore_cannot_block_path(reason)) { > + if (pstore_cannot_block_path(detail->reason)) { > if (!spin_trylock_irqsave(&psinfo->buf_lock, flags)) { > pr_err("dump skipped in %s path because of concurrent dump\n", > in_nmi() ? "NMI" : why); > @@ -311,7 +311,7 @@ static void pstore_dump(struct kmsg_dump > pstore_record_init(&record, psinfo); > record.type = PSTORE_TYPE_DMESG; > record.count = oopscount; > - record.reason = reason; > + record.reason = detail->reason; > record.part = part; > record.buf = psinfo->buf; > > @@ -352,7 +352,7 @@ static void pstore_dump(struct kmsg_dump > } > > ret = psinfo->write(&record); > - if (ret == 0 && reason == KMSG_DUMP_OOPS) { > + if (ret == 0 && detail->reason == KMSG_DUMP_OOPS) { > pstore_new_entry = 1; > pstore_timer_kick(); > } else { > diff -u -p a/arch/um/kernel/kmsg_dump.c b/arch/um/kernel/kmsg_dump.c > --- a/arch/um/kernel/kmsg_dump.c > +++ b/arch/um/kernel/kmsg_dump.c > @@ -8,7 +8,7 @@ > #include > > static void kmsg_dumper_stdout(struct kmsg_dumper *dumper, > - enum kmsg_dump_reason reason) > + struct kmsg_dump_detail *detail) > { > static struct kmsg_dump_iter iter; > static DEFINE_SPINLOCK(lock); >