lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 25 Apr 2012 10:23:38 +0200
From:	Jiri Olsa <jolsa@...hat.com>
To:	rostedt@...dmis.org, fweisbec@...il.com, mingo@...hat.com
Cc:	linux-kernel@...r.kernel.org, Jiri Olsa <jolsa@...hat.com>
Subject: [PATCH 3/4] ftrace: No return value for ftrace_process_locs

The return value of ftrace_process_locs is never checked. The function
tries to update as many calls as possible and in case of error there's
either warning output or ftrace_bug call.

Signed-off-by: Jiri Olsa <jolsa@...hat.com>
---
 kernel/trace/ftrace.c |   37 ++++++++++++++++---------------------
 1 files changed, 16 insertions(+), 21 deletions(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index b3ceecd..e67f5b3 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -1930,7 +1930,7 @@ static int ops_traces_mod(struct ftrace_ops *ops)
 	return ftrace_hash_empty(hash);
 }
 
-static int ftrace_update_code(struct module *mod)
+static void ftrace_update_code(struct module *mod)
 {
 	struct ftrace_page *pg;
 	struct dyn_ftrace *p;
@@ -1959,7 +1959,7 @@ static int ftrace_update_code(struct module *mod)
 		for (i = 0; i < pg->index; i++) {
 			/* If something went wrong, bail without enabling anything */
 			if (unlikely(ftrace_disabled))
-				return -1;
+				return;
 
 			p = &pg->records[i];
 			p->flags = ref;
@@ -1968,8 +1968,8 @@ static int ftrace_update_code(struct module *mod)
 			 * Do the initial record conversion from mcount jump
 			 * to the NOP instructions.
 			 */
-			if (!ftrace_code_disable(mod, p))
-				break;
+			if (WARN_ON_ONCE(!ftrace_code_disable(mod, p)))
+				return;
 
 			cnt++;
 
@@ -1992,7 +1992,6 @@ static int ftrace_update_code(struct module *mod)
 
 	ftrace_new_pgs = NULL;
 	ftrace_update_tot_cnt += cnt;
-	return 0;
 }
 
 static int ftrace_allocate_records(struct ftrace_page *pg, int count)
@@ -2041,11 +2040,11 @@ ftrace_allocate_pages(unsigned long num_to_init)
 	int cnt;
 
 	if (!num_to_init)
-		return 0;
+		return NULL;
 
 	start_pg = pg = kzalloc(sizeof(*pg), GFP_KERNEL);
 	if (!pg)
-		return NULL;
+		goto out;
 
 	/*
 	 * Try to allocate as much as possible in one continues
@@ -2078,6 +2077,7 @@ ftrace_allocate_pages(unsigned long num_to_init)
 		kfree(pg);
 		pg = start_pg;
 	}
+ out:
 	pr_info("ftrace: FAILED to allocate memory for functions\n");
 	return NULL;
 }
@@ -3589,25 +3589,23 @@ static void ftrace_swap_recs(void *a, void *b, int size)
 	*recb = t;
 }
 
-static int ftrace_process_locs(struct module *mod,
-			       unsigned long *start,
-			       unsigned long *end)
+static void ftrace_process_locs(struct module *mod,
+				unsigned long *start,
+				unsigned long *end)
 {
 	struct ftrace_page *pg;
 	unsigned long count;
 	unsigned long *p;
 	unsigned long addr;
 	unsigned long flags = 0; /* Shut up gcc */
-	int ret = -ENOMEM;
 
 	count = end - start;
-
 	if (!count)
-		return 0;
+		return;
 
 	pg = ftrace_allocate_pages(count);
 	if (!pg)
-		return -ENOMEM;
+		return;
 
 	mutex_lock(&ftrace_lock);
 
@@ -3621,7 +3619,7 @@ static int ftrace_process_locs(struct module *mod,
 		/* First initialization */
 		ftrace_pages = ftrace_pages_start = pg;
 	} else {
-		if (!ftrace_pages)
+		if (!WARN_ON_ONCE(ftrace_pages))
 			goto out;
 
 		if (WARN_ON(ftrace_pages->next)) {
@@ -3670,11 +3668,8 @@ static int ftrace_process_locs(struct module *mod,
 	ftrace_update_code(mod);
 	if (!mod)
 		local_irq_restore(flags);
-	ret = 0;
  out:
 	mutex_unlock(&ftrace_lock);
-
-	return ret;
 }
 
 #ifdef CONFIG_MODULES
@@ -3789,9 +3784,9 @@ void __init ftrace_init(void)
 
 	last_ftrace_enabled = ftrace_enabled = 1;
 
-	ret = ftrace_process_locs(NULL,
-				  __start_mcount_loc,
-				  __stop_mcount_loc);
+	ftrace_process_locs(NULL,
+			    __start_mcount_loc,
+			    __stop_mcount_loc);
 
 	ret = register_module_notifier(&ftrace_module_nb);
 	if (ret)
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ