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>] [day] [month] [year] [list]
Message-Id: <20090619072828.6575.84295.sendpatchset@localhost.localdomain>
Date:	Fri, 19 Jun 2009 03:26:13 -0400
From:	Amerigo Wang <amwang@...hat.com>
To:	linux-kernel@...r.kernel.org
Cc:	akpm@...ux-foundation.org, paulmck@...ux.vnet.ibm.com,
	Amerigo Wang <amwang@...hat.com>, mingo@...e.hu
Subject: [Resend Patch] RCU trace: use scnprintf instead of snprintf


snprintf can return more than the size of buffer, this case
is not expected here, obviously. Use scnprintf instead.

Reviewed-by: Paul E. McKenney <paulmck@...ux.vnet.ibm.com>
Signed-off-by: WANG Cong <amwang@...hat.com>
Cc: Ingo Molnar <mingo@...e.hu>

---
diff --git a/kernel/rcupreempt_trace.c b/kernel/rcupreempt_trace.c
index 7c2665c..4ea4300 100644
--- a/kernel/rcupreempt_trace.c
+++ b/kernel/rcupreempt_trace.c
@@ -234,11 +234,11 @@ static ssize_t rcuctrs_read(struct file *filp, char __user *buffer,
 
 	mutex_lock(&rcupreempt_trace_mutex);
 
-	cnt += snprintf(&rcupreempt_trace_buf[cnt], RCUPREEMPT_TRACE_BUF_SIZE,
+	cnt += scnprintf(&rcupreempt_trace_buf[cnt], RCUPREEMPT_TRACE_BUF_SIZE,
 				"CPU last cur F M\n");
 	for_each_online_cpu(cpu) {
 		long *flipctr = rcupreempt_flipctr(cpu);
-		cnt += snprintf(&rcupreempt_trace_buf[cnt],
+		cnt += scnprintf(&rcupreempt_trace_buf[cnt],
 				RCUPREEMPT_TRACE_BUF_SIZE - cnt,
 					"%3d %4ld %3ld %d %d\n",
 			       cpu,
@@ -247,12 +247,12 @@ static ssize_t rcuctrs_read(struct file *filp, char __user *buffer,
 			       rcupreempt_flip_flag(cpu),
 			       rcupreempt_mb_flag(cpu));
 	}
-	cnt += snprintf(&rcupreempt_trace_buf[cnt],
+	cnt += scnprintf(&rcupreempt_trace_buf[cnt],
 			RCUPREEMPT_TRACE_BUF_SIZE - cnt,
 			"ggp = %ld, state = %s\n",
 			rcu_batches_completed(),
 			rcupreempt_try_flip_state_name());
-	cnt += snprintf(&rcupreempt_trace_buf[cnt],
+	cnt += scnprintf(&rcupreempt_trace_buf[cnt],
 			RCUPREEMPT_TRACE_BUF_SIZE - cnt,
 			"\n");
 	bcount = simple_read_from_buffer(buffer, count, ppos,
--
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