Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752076Ab2HGFHS (ORCPT ); Tue, 7 Aug 2012 01:07:18 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:45242 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751019Ab2HGFHQ (ORCPT ); Tue, 7 Aug 2012 01:07:16 -0400 Date: Mon, 6 Aug 2012 22:05:02 -0700 From: Anton Vorontsov To: Linus Torvalds Cc: Andrew Morton , Stephen Rothwell , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Randy Dunlap , Tony Luck , Colin Cross , Kees Cook Subject: [GIT PULL] linux-pstore.git Message-ID: <20120807050501.GA21435@lizard> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 7692 Lines: 216 Hello Linus, This pull request includes a few fixes for pstore that I posted some time ago, plus Randy's printk format fix. Also, now pstore has a dedicated git tree, and a few people (including me) ready to review any further changes to the code, the fact is now reflected in the maintainers file. Since the fixes are pretty small, for convenience I include all of them in the end of this email. Thanks! The following changes since commit 0d7614f09c1ebdbaa1599a5aba7593f147bf96ee: Linux 3.6-rc1 (2012-08-02 16:38:10 -0700) are available in the git repository at: git://git.infradead.org/users/cbou/linux-pstore.git tags/v3.6-rc1-fixes for you to fetch changes up to 8defe59969cb8d863fe46867809316350ec0fc8f: MAINTAINERS: Add pstore maintainers (2012-08-06 21:16:19 -0700) ---------------------------------------------------------------- Just a few fixes for v3.6-rc1, plus added maintainers for pstore. ---------------------------------------------------------------- Anton Vorontsov (3): pstore/ram: Fix possible NULL dereference pstore/ram: Mark ramoops_pstore_write_buf() as notrace MAINTAINERS: Add pstore maintainers Randy Dunlap (1): pstore/ram: Fix printk format warning MAINTAINERS | 12 ++++++++++++ fs/pstore/ram.c | 27 ++++++++++++++------------- 2 files changed, 26 insertions(+), 13 deletions(-) commit 8defe59969cb8d863fe46867809316350ec0fc8f Author: Anton Vorontsov Date: Fri Aug 3 18:07:20 2012 -0700 MAINTAINERS: Add pstore maintainers Signed-off-by: Anton Vorontsov Acked-by: Tony Luck Acked-by: Kees Cook diff --git a/MAINTAINERS b/MAINTAINERS index 94b823f..9aa40c1 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -5496,6 +5496,18 @@ L: cbe-oss-dev@lists.ozlabs.org S: Maintained F: drivers/block/ps3vram.c +PSTORE FILESYSTEM +M: Anton Vorontsov +M: Colin Cross +M: Kees Cook +M: Tony Luck +S: Maintained +T: git git://git.infradead.org/users/cbou/linux-pstore.git +F: fs/pstore/ +F: include/linux/pstore* +F: drivers/firmware/efivars.c +F: drivers/acpi/apei/erst.c + PTP HARDWARE CLOCK SUPPORT M: Richard Cochran S: Maintained commit 242030365eacb649161023a3a024373198c34d59 Author: Anton Vorontsov Date: Tue Jul 17 19:49:37 2012 -0700 pstore/ram: Mark ramoops_pstore_write_buf() as notrace write_buf() should be marked as notrace, otherwise it is prone to recursion. Though, yet the issue is never triggered in real life, because we run inside the function tracer, where ftrace does its own recurse protection. But it's still no good, plus soon we might switch to our own tracer ops, and then the issue will be fatal. So, let's fix it. Signed-off-by: Anton Vorontsov diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index fba8c72..9101604 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #define RAMOOPS_KERNMSG_HDR "====" @@ -181,12 +182,11 @@ static size_t ramoops_write_kmsg_hdr(struct persistent_ram_zone *prz) return len; } - -static int ramoops_pstore_write_buf(enum pstore_type_id type, - enum kmsg_dump_reason reason, - u64 *id, unsigned int part, - const char *buf, size_t size, - struct pstore_info *psi) +static int notrace ramoops_pstore_write_buf(enum pstore_type_id type, + enum kmsg_dump_reason reason, + u64 *id, unsigned int part, + const char *buf, size_t size, + struct pstore_info *psi) { struct ramoops_context *cxt = psi->data; struct persistent_ram_zone *prz = cxt->przs[cxt->dump_write_cnt]; commit 0427193b691edc81c846c7d0ebd2561cae8709d8 Author: Randy Dunlap Date: Fri Aug 3 17:02:48 2012 -0700 pstore/ram: Fix printk format warning Fix printk format warning (on i386) in pstore: fs/pstore/ram.c:409:3: warning: format '%lu' expects type 'long unsigned int', but argument 2 has type 'size_t' Signed-off-by: Randy Dunlap Acked-by: Kees Cook Signed-off-by: Anton Vorontsov diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index bcd1bbd..fba8c72 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c @@ -406,7 +406,7 @@ static int __devinit ramoops_probe(struct platform_device *pdev) goto fail_init_fprz; if (!cxt->przs && !cxt->cprz && !cxt->fprz) { - pr_err("memory size too small, minimum is %lu\n", + pr_err("memory size too small, minimum is %zu\n", cxt->console_size + cxt->record_size + cxt->ftrace_size); goto fail_cnt; commit a384f6411734e763daa4bae30e8ff170d7d4c3e2 Author: Anton Vorontsov Date: Thu Jul 19 15:47:11 2012 -0700 pstore/ram: Fix possible NULL dereference We can dereference 'cxt->cprz' if console and dump logging are disabled (which is unlikely, but still possible to do). This patch fixes the issue by changing the code so that we don't dereference przs at all, we can just calculate bufsize from console_size and record_size values. Plus, while at it, the patch improves the buffer size calculation. After Kay's printk rework, we know the optimal buffer size for console logging -- it is LOG_LINE_MAX (defined privately in printk.c). Previously, if only console logging was enabled, we would allocate unnecessary large buffer in pstore, while we only need LOG_LINE_MAX. (Pstore console logging is still capable of handling buffers > LOG_LINE_MAX, it will just do multiple calls to psinfo->write). Note that I don't export the constant, since we will do even a better thing soon: we will switch console logging to a new write_buf API, which will eliminate the need for the additional buffer; and so we won't need the constant. Reported-by: Dan Carpenter Signed-off-by: Anton Vorontsov Acked-by: Kees Cook diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index 0b311bc..bcd1bbd 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c @@ -414,13 +414,14 @@ static int __devinit ramoops_probe(struct platform_device *pdev) cxt->pstore.data = cxt; /* - * Console can handle any buffer size, so prefer dumps buffer - * size since usually it is smaller. + * Console can handle any buffer size, so prefer LOG_LINE_MAX. If we + * have to handle dumps, we must have at least record_size buffer. And + * for ftrace, bufsize is irrelevant (if bufsize is 0, buf will be + * ZERO_SIZE_PTR). */ - if (cxt->przs) - cxt->pstore.bufsize = cxt->przs[0]->buffer_size; - else - cxt->pstore.bufsize = cxt->cprz->buffer_size; + if (cxt->console_size) + cxt->pstore.bufsize = 1024; /* LOG_LINE_MAX */ + cxt->pstore.bufsize = max(cxt->record_size, cxt->pstore.bufsize); cxt->pstore.buf = kmalloc(cxt->pstore.bufsize, GFP_KERNEL); spin_lock_init(&cxt->pstore.buf_lock); if (!cxt->pstore.buf) { -- Anton Vorontsov Email: cbouatmailru@gmail.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/