netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bonding: fix a buffer overflow in bonding_show_queue_id.
@ 2010-07-14 22:24 Nicolas de Pesloüan
  2010-07-15  1:25 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Nicolas de Pesloüan @ 2010-07-14 22:24 UTC (permalink / raw)
  To: bonding-devel, andy, fubar, davem, netdev; +Cc: Nicolas de Pesloüan

The test for buffer overflow ensures we have room for 6 more bytes.
sprintf, called with %s:%d, slave->dev->name, slave->queue_id may yield
far more than 6 bytes.

The correct test is res > (PAGE_SIZE - IFNAMSIZ - 6) .

Signed-off-by: Nicolas de Pesloüan <nicolas.2p.debian@free.fr>
---
 drivers/net/bonding/bond_sysfs.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index f9a0343..1a99764 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -1427,8 +1427,8 @@ static ssize_t bonding_show_queue_id(struct device *d,
 
 	read_lock(&bond->lock);
 	bond_for_each_slave(bond, slave, i) {
-		if (res > (PAGE_SIZE - 6)) {
-			/* not enough space for another interface name */
+		if (res > (PAGE_SIZE - IFNAMSIZ - 6)) {
+			/* not enough space for another interface_name:queue_id pair */
 			if ((PAGE_SIZE - res) > 10)
 				res = PAGE_SIZE - 10;
 			res += sprintf(buf + res, "++more++ ");
-- 
1.7.1




^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] bonding: fix a buffer overflow in bonding_show_queue_id.
  2010-07-14 22:24 [PATCH] bonding: fix a buffer overflow in bonding_show_queue_id Nicolas de Pesloüan
@ 2010-07-15  1:25 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2010-07-15  1:25 UTC (permalink / raw)
  To: nicolas.2p.debian; +Cc: bonding-devel, andy, fubar, netdev

From: Nicolas de Pesloüan <nicolas.2p.debian@free.fr>
Date: Thu, 15 Jul 2010 00:24:37 +0200

> The test for buffer overflow ensures we have room for 6 more bytes.
> sprintf, called with %s:%d, slave->dev->name, slave->queue_id may yield
> far more than 6 bytes.
> 
> The correct test is res > (PAGE_SIZE - IFNAMSIZ - 6) .
> 
> Signed-off-by: Nicolas de Pesloüan <nicolas.2p.debian@free.fr>

Applied to net-next-2.6, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-07-15  1:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-14 22:24 [PATCH] bonding: fix a buffer overflow in bonding_show_queue_id Nicolas de Pesloüan
2010-07-15  1:25 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).