From 53f21a8ea1d76a002103ce20abd168fe83b20ee7 Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Wed, 17 Oct 2012 09:39:49 +0200 Subject: pstore/ram: Fixup section annotations The compiler complained about missing section annotations. Fix it. Signed-off-by: Hannes Reinecke Cc: Colin Cross Cc: Tony Luck Acked-by: Kees Cook Signed-off-by: Anton Vorontsov --- fs/pstore/ram.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index 1a4f6da58eab..2b6ebbca3521 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c @@ -287,8 +287,9 @@ static void ramoops_free_przs(struct ramoops_context *cxt) kfree(cxt->przs); } -static int ramoops_init_przs(struct device *dev, struct ramoops_context *cxt, - phys_addr_t *paddr, size_t dump_mem_sz) +static int __devinit ramoops_init_przs(struct device *dev, + struct ramoops_context *cxt, + phys_addr_t *paddr, size_t dump_mem_sz) { int err = -ENOMEM; int i; @@ -326,9 +327,10 @@ fail_prz: return err; } -static int ramoops_init_prz(struct device *dev, struct ramoops_context *cxt, - struct persistent_ram_zone **prz, - phys_addr_t *paddr, size_t sz, u32 sig) +static int __devinit ramoops_init_prz(struct device *dev, + struct ramoops_context *cxt, + struct persistent_ram_zone **prz, + phys_addr_t *paddr, size_t sz, u32 sig) { if (!sz) return 0; -- cgit v1.2.3 From b042e47491ba5f487601b5141a3f1d8582304170 Mon Sep 17 00:00:00 2001 From: Maxime Bizon Date: Mon, 22 Oct 2012 11:19:28 +0200 Subject: pstore/ram: Fix undefined usage of rounddown_pow_of_two(0) record_size / console_size / ftrace_size can be 0 (this is how you disable the feature), but rounddown_pow_of_two(0) is undefined. As suggested by Kees Cook, use !is_power_of_2() as a condition to call rounddown_pow_of_two and avoid its undefined behavior on the value 0. This issue has been present since commit 1894a253 (ramoops: Move to fs/pstore/ram.c). Cc: stable@vger.kernel.org Signed-off-by: Maxime Bizon Signed-off-by: Florian Fainelli Acked-by: Kees Cook Signed-off-by: Anton Vorontsov --- fs/pstore/ram.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index 2b6ebbca3521..8741cea6253c 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c @@ -376,10 +376,14 @@ static int __devinit ramoops_probe(struct platform_device *pdev) goto fail_out; } - pdata->mem_size = rounddown_pow_of_two(pdata->mem_size); - pdata->record_size = rounddown_pow_of_two(pdata->record_size); - pdata->console_size = rounddown_pow_of_two(pdata->console_size); - pdata->ftrace_size = rounddown_pow_of_two(pdata->ftrace_size); + if (!is_power_of_2(pdata->mem_size)) + pdata->mem_size = rounddown_pow_of_two(pdata->mem_size); + if (!is_power_of_2(pdata->record_size)) + pdata->record_size = rounddown_pow_of_two(pdata->record_size); + if (!is_power_of_2(pdata->console_size)) + pdata->console_size = rounddown_pow_of_two(pdata->console_size); + if (!is_power_of_2(pdata->ftrace_size)) + pdata->ftrace_size = rounddown_pow_of_two(pdata->ftrace_size); cxt->dump_read_cnt = 0; cxt->size = pdata->mem_size; -- cgit v1.2.3 From c628937803c652132d21f383736375e2feee4bfb Mon Sep 17 00:00:00 2001 From: Arve Hjønnevåg Date: Tue, 11 Dec 2012 17:49:24 -0800 Subject: pstore/ram: Fix bounds checks for mem_size, record_size, console_size and ftrace_size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The bounds check in ramoops_init_prz was incorrect and ramoops_init_przs had no check. Additionally, ramoops_init_przs allows record_size to be 0, but ramoops_pstore_write_buf would always crash in this case. Signed-off-by: Arve Hjønnevåg Signed-off-by: Anton Vorontsov --- fs/pstore/ram.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index 8741cea6253c..dba70e53b72c 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c @@ -189,7 +189,7 @@ static int notrace ramoops_pstore_write_buf(enum pstore_type_id type, struct pstore_info *psi) { struct ramoops_context *cxt = psi->data; - struct persistent_ram_zone *prz = cxt->przs[cxt->dump_write_cnt]; + struct persistent_ram_zone *prz; size_t hlen; if (type == PSTORE_TYPE_CONSOLE) { @@ -226,6 +226,11 @@ static int notrace ramoops_pstore_write_buf(enum pstore_type_id type, if (part != 1) return -ENOSPC; + if (!cxt->przs) + return -ENOSPC; + + prz = cxt->przs[cxt->dump_write_cnt]; + hlen = ramoops_write_kmsg_hdr(prz); if (size + hlen > prz->buffer_size) size = prz->buffer_size - hlen; @@ -297,6 +302,11 @@ static int __devinit ramoops_init_przs(struct device *dev, if (!cxt->record_size) return 0; + if (*paddr + dump_mem_sz - cxt->phys_addr > cxt->size) { + dev_err(dev, "no room for dumps\n"); + return -ENOMEM; + } + cxt->max_dump_cnt = dump_mem_sz / cxt->record_size; if (!cxt->max_dump_cnt) return -ENOMEM; @@ -335,8 +345,12 @@ static int __devinit ramoops_init_prz(struct device *dev, if (!sz) return 0; - if (*paddr + sz > *paddr + cxt->size) + if (*paddr + sz - cxt->phys_addr > cxt->size) { + dev_err(dev, "no room for mem region (0x%zx@0x%llx) in (0x%lx@0x%llx)\n", + sz, (unsigned long long)*paddr, + cxt->size, (unsigned long long)cxt->phys_addr); return -ENOMEM; + } *prz = persistent_ram_new(*paddr, sz, sig, cxt->ecc_size); if (IS_ERR(*prz)) { -- cgit v1.2.3 From ebacfd1ece3bfa46296fc92c6f996cb5f7fc75e6 Mon Sep 17 00:00:00 2001 From: Anton Vorontsov Date: Wed, 14 Nov 2012 18:48:15 -0800 Subject: pstore/ftrace: Adjust for ftrace_ops->func prototype change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit fixes the following warning: fs/pstore/ftrace.c:51:2: warning: initialization from incompatible pointer type [enabled by default] fs/pstore/ftrace.c:51:2: warning: (near initialization for ‘pstore_ftrace_ops.func’) [enabled by defaula Signed-off-by: Anton Vorontsov --- fs/pstore/ftrace.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/pstore/ftrace.c b/fs/pstore/ftrace.c index 2d57e1ac0115..43b12807a51d 100644 --- a/fs/pstore/ftrace.c +++ b/fs/pstore/ftrace.c @@ -28,7 +28,9 @@ #include "internal.h" static void notrace pstore_ftrace_call(unsigned long ip, - unsigned long parent_ip) + unsigned long parent_ip, + struct ftrace_ops *op, + struct pt_regs *regs) { unsigned long flags; struct pstore_ftrace_record rec = {}; -- cgit v1.2.3