All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv2] ibmveth: Fix off-by-one error in ibmveth_change_mtu()
@ 2015-04-21  1:07 ` David Gibson
  0 siblings, 0 replies; 8+ messages in thread
From: David Gibson @ 2015-04-21  1:07 UTC (permalink / raw)
  To: anton; +Cc: tlfalcon, michael, linux-kernel, linuxppc-dev, David Gibson

AFAIK the PAPR document which defines the virtual device interface used by
the ibmveth driver doesn't specify a specific maximum MTU.  So, in the
ibmveth driver, the maximum allowed MTU is determined by the maximum
allocated buffer size of 64k (corresponding to one page in the common case)
minus the per-buffer overhead IBMVETH_BUFF_OH (which has value 22 for 14
bytes of ethernet header, plus 8 bytes for an opaque handle).

This suggests a maximum allowable MTU of 65514 bytes, but in fact the
driver only permits a maximum MTU of 65513.  This is because there is a <
instead of an <= in ibmveth_change_mtu(), which only permits an MTU which
is strictly smaller than the buffer size, rather than allowing the buffer
to be completely filled.

This patch fixes the buglet.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>1
---
 drivers/net/ethernet/ibm/ibmveth.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Changes since v1:
 * Fixed a second instance of the same off-by-one error.  Thanks to
   Thomas Falcon for spotting this.

diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
index cd7675a..1813476 100644
--- a/drivers/net/ethernet/ibm/ibmveth.c
+++ b/drivers/net/ethernet/ibm/ibmveth.c
@@ -1238,7 +1238,7 @@ static int ibmveth_change_mtu(struct net_device *dev, int new_mtu)
 		return -EINVAL;
 
 	for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++)
-		if (new_mtu_oh < adapter->rx_buff_pool[i].buff_size)
+		if (new_mtu_oh <= adapter->rx_buff_pool[i].buff_size)
 			break;
 
 	if (i == IBMVETH_NUM_BUFF_POOLS)
@@ -1257,7 +1257,7 @@ static int ibmveth_change_mtu(struct net_device *dev, int new_mtu)
 	for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++) {
 		adapter->rx_buff_pool[i].active = 1;
 
-		if (new_mtu_oh < adapter->rx_buff_pool[i].buff_size) {
+		if (new_mtu_oh <= adapter->rx_buff_pool[i].buff_size) {
 			dev->mtu = new_mtu;
 			vio_cmo_set_dev_desired(viodev,
 						ibmveth_get_desired_dma
-- 
2.1.0


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

* [PATCHv2] ibmveth: Fix off-by-one error in ibmveth_change_mtu()
@ 2015-04-21  1:07 ` David Gibson
  0 siblings, 0 replies; 8+ messages in thread
From: David Gibson @ 2015-04-21  1:07 UTC (permalink / raw)
  To: anton; +Cc: michael, linuxppc-dev, tlfalcon, linux-kernel, David Gibson

AFAIK the PAPR document which defines the virtual device interface used by
the ibmveth driver doesn't specify a specific maximum MTU.  So, in the
ibmveth driver, the maximum allowed MTU is determined by the maximum
allocated buffer size of 64k (corresponding to one page in the common case)
minus the per-buffer overhead IBMVETH_BUFF_OH (which has value 22 for 14
bytes of ethernet header, plus 8 bytes for an opaque handle).

This suggests a maximum allowable MTU of 65514 bytes, but in fact the
driver only permits a maximum MTU of 65513.  This is because there is a <
instead of an <= in ibmveth_change_mtu(), which only permits an MTU which
is strictly smaller than the buffer size, rather than allowing the buffer
to be completely filled.

This patch fixes the buglet.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>1
---
 drivers/net/ethernet/ibm/ibmveth.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Changes since v1:
 * Fixed a second instance of the same off-by-one error.  Thanks to
   Thomas Falcon for spotting this.

diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
index cd7675a..1813476 100644
--- a/drivers/net/ethernet/ibm/ibmveth.c
+++ b/drivers/net/ethernet/ibm/ibmveth.c
@@ -1238,7 +1238,7 @@ static int ibmveth_change_mtu(struct net_device *dev, int new_mtu)
 		return -EINVAL;
 
 	for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++)
-		if (new_mtu_oh < adapter->rx_buff_pool[i].buff_size)
+		if (new_mtu_oh <= adapter->rx_buff_pool[i].buff_size)
 			break;
 
 	if (i == IBMVETH_NUM_BUFF_POOLS)
@@ -1257,7 +1257,7 @@ static int ibmveth_change_mtu(struct net_device *dev, int new_mtu)
 	for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++) {
 		adapter->rx_buff_pool[i].active = 1;
 
-		if (new_mtu_oh < adapter->rx_buff_pool[i].buff_size) {
+		if (new_mtu_oh <= adapter->rx_buff_pool[i].buff_size) {
 			dev->mtu = new_mtu;
 			vio_cmo_set_dev_desired(viodev,
 						ibmveth_get_desired_dma
-- 
2.1.0

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

* Re: [PATCHv2] ibmveth: Fix off-by-one error in ibmveth_change_mtu()
  2015-04-21  1:07 ` David Gibson
  (?)
@ 2015-04-22 21:42 ` Thomas Falcon
  2015-04-23 23:12   ` Tyrel Datwyler
  -1 siblings, 1 reply; 8+ messages in thread
From: Thomas Falcon @ 2015-04-22 21:42 UTC (permalink / raw)
  To: David Gibson, anton; +Cc: michael, linuxppc-dev, linux-kernel

On 04/20/2015 08:07 PM, David Gibson wrote:
> AFAIK the PAPR document which defines the virtual device interface used by
> the ibmveth driver doesn't specify a specific maximum MTU.  So, in the
> ibmveth driver, the maximum allowed MTU is determined by the maximum
> allocated buffer size of 64k (corresponding to one page in the common case)
> minus the per-buffer overhead IBMVETH_BUFF_OH (which has value 22 for 14
> bytes of ethernet header, plus 8 bytes for an opaque handle).
>
> This suggests a maximum allowable MTU of 65514 bytes, but in fact the
> driver only permits a maximum MTU of 65513.  This is because there is a <
> instead of an <= in ibmveth_change_mtu(), which only permits an MTU which
> is strictly smaller than the buffer size, rather than allowing the buffer
> to be completely filled.
>
> This patch fixes the buglet.

Thanks!

Acked-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>

>
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>1
> ---
>  drivers/net/ethernet/ibm/ibmveth.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> Changes since v1:
>  * Fixed a second instance of the same off-by-one error.  Thanks to
>    Thomas Falcon for spotting this.
>
> diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
> index cd7675a..1813476 100644
> --- a/drivers/net/ethernet/ibm/ibmveth.c
> +++ b/drivers/net/ethernet/ibm/ibmveth.c
> @@ -1238,7 +1238,7 @@ static int ibmveth_change_mtu(struct net_device *dev, int new_mtu)
>  		return -EINVAL;
>  
>  	for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++)
> -		if (new_mtu_oh < adapter->rx_buff_pool[i].buff_size)
> +		if (new_mtu_oh <= adapter->rx_buff_pool[i].buff_size)
>  			break;
>  
>  	if (i == IBMVETH_NUM_BUFF_POOLS)
> @@ -1257,7 +1257,7 @@ static int ibmveth_change_mtu(struct net_device *dev, int new_mtu)
>  	for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++) {
>  		adapter->rx_buff_pool[i].active = 1;
>  
> -		if (new_mtu_oh < adapter->rx_buff_pool[i].buff_size) {
> +		if (new_mtu_oh <= adapter->rx_buff_pool[i].buff_size) {
>  			dev->mtu = new_mtu;
>  			vio_cmo_set_dev_desired(viodev,
>  						ibmveth_get_desired_dma


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

* Re: [PATCHv2] ibmveth: Fix off-by-one error in ibmveth_change_mtu()
  2015-04-22 21:42 ` Thomas Falcon
@ 2015-04-23 23:12   ` Tyrel Datwyler
  0 siblings, 0 replies; 8+ messages in thread
From: Tyrel Datwyler @ 2015-04-23 23:12 UTC (permalink / raw)
  To: Thomas Falcon, David Gibson, anton; +Cc: michael, linuxppc-dev, linux-kernel

On 04/22/2015 02:42 PM, Thomas Falcon wrote:
> On 04/20/2015 08:07 PM, David Gibson wrote:
>> AFAIK the PAPR document which defines the virtual device interface used by
>> the ibmveth driver doesn't specify a specific maximum MTU.  So, in the

PAPR itself doesn't, but the max-frame-size property, which I understand
to be synonymous with max MTU, is required by PAPR to be present in the
Logical LAN OF node corresponding to the ibmveth device.

-Tyrel

>> ibmveth driver, the maximum allowed MTU is determined by the maximum
>> allocated buffer size of 64k (corresponding to one page in the common case)
>> minus the per-buffer overhead IBMVETH_BUFF_OH (which has value 22 for 14
>> bytes of ethernet header, plus 8 bytes for an opaque handle).
>>
>> This suggests a maximum allowable MTU of 65514 bytes, but in fact the
>> driver only permits a maximum MTU of 65513.  This is because there is a <
>> instead of an <= in ibmveth_change_mtu(), which only permits an MTU which
>> is strictly smaller than the buffer size, rather than allowing the buffer
>> to be completely filled.
>>
>> This patch fixes the buglet.
> 
> Thanks!
> 
> Acked-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
> 
>>
>> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>1
>> ---
>>  drivers/net/ethernet/ibm/ibmveth.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> Changes since v1:
>>  * Fixed a second instance of the same off-by-one error.  Thanks to
>>    Thomas Falcon for spotting this.
>>
>> diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
>> index cd7675a..1813476 100644
>> --- a/drivers/net/ethernet/ibm/ibmveth.c
>> +++ b/drivers/net/ethernet/ibm/ibmveth.c
>> @@ -1238,7 +1238,7 @@ static int ibmveth_change_mtu(struct net_device *dev, int new_mtu)
>>  		return -EINVAL;
>>  
>>  	for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++)
>> -		if (new_mtu_oh < adapter->rx_buff_pool[i].buff_size)
>> +		if (new_mtu_oh <= adapter->rx_buff_pool[i].buff_size)
>>  			break;
>>  
>>  	if (i == IBMVETH_NUM_BUFF_POOLS)
>> @@ -1257,7 +1257,7 @@ static int ibmveth_change_mtu(struct net_device *dev, int new_mtu)
>>  	for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++) {
>>  		adapter->rx_buff_pool[i].active = 1;
>>  
>> -		if (new_mtu_oh < adapter->rx_buff_pool[i].buff_size) {
>> +		if (new_mtu_oh <= adapter->rx_buff_pool[i].buff_size) {
>>  			dev->mtu = new_mtu;
>>  			vio_cmo_set_dev_desired(viodev,
>>  						ibmveth_get_desired_dma
> 
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
> 


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

* Re: [PATCHv2] ibmveth: Fix off-by-one error in ibmveth_change_mtu()
  2015-04-23  4:43 ` David Gibson
@ 2015-04-23 15:42   ` David Miller
  -1 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2015-04-23 15:42 UTC (permalink / raw)
  To: david; +Cc: anton, tlfalcon, michael, linux-kernel, linuxppc-dev, netdev

From: David Gibson <david@gibson.dropbear.id.au>
Date: Thu, 23 Apr 2015 14:43:05 +1000

> AFAIK the PAPR document which defines the virtual device interface used by
> the ibmveth driver doesn't specify a specific maximum MTU.  So, in the
> ibmveth driver, the maximum allowed MTU is determined by the maximum
> allocated buffer size of 64k (corresponding to one page in the common case)
> minus the per-buffer overhead IBMVETH_BUFF_OH (which has value 22 for 14
> bytes of ethernet header, plus 8 bytes for an opaque handle).
> 
> This suggests a maximum allowable MTU of 65514 bytes, but in fact the
> driver only permits a maximum MTU of 65513.  This is because there is a <
> instead of an <= in ibmveth_change_mtu(), which only permits an MTU which
> is strictly smaller than the buffer size, rather than allowing the buffer
> to be completely filled.
> 
> This patch fixes the buglet.
> 
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> Acked-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>

Applied, thank you.

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

* Re: [PATCHv2] ibmveth: Fix off-by-one error in ibmveth_change_mtu()
@ 2015-04-23 15:42   ` David Miller
  0 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2015-04-23 15:42 UTC (permalink / raw)
  To: david; +Cc: tlfalcon, netdev, anton, linux-kernel, michael, linuxppc-dev

From: David Gibson <david@gibson.dropbear.id.au>
Date: Thu, 23 Apr 2015 14:43:05 +1000

> AFAIK the PAPR document which defines the virtual device interface used by
> the ibmveth driver doesn't specify a specific maximum MTU.  So, in the
> ibmveth driver, the maximum allowed MTU is determined by the maximum
> allocated buffer size of 64k (corresponding to one page in the common case)
> minus the per-buffer overhead IBMVETH_BUFF_OH (which has value 22 for 14
> bytes of ethernet header, plus 8 bytes for an opaque handle).
> 
> This suggests a maximum allowable MTU of 65514 bytes, but in fact the
> driver only permits a maximum MTU of 65513.  This is because there is a <
> instead of an <= in ibmveth_change_mtu(), which only permits an MTU which
> is strictly smaller than the buffer size, rather than allowing the buffer
> to be completely filled.
> 
> This patch fixes the buglet.
> 
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> Acked-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>

Applied, thank you.

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

* [PATCHv2] ibmveth: Fix off-by-one error in ibmveth_change_mtu()
@ 2015-04-23  4:43 ` David Gibson
  0 siblings, 0 replies; 8+ messages in thread
From: David Gibson @ 2015-04-23  4:43 UTC (permalink / raw)
  To: anton; +Cc: tlfalcon, michael, linux-kernel, linuxppc-dev, netdev, David Gibson

AFAIK the PAPR document which defines the virtual device interface used by
the ibmveth driver doesn't specify a specific maximum MTU.  So, in the
ibmveth driver, the maximum allowed MTU is determined by the maximum
allocated buffer size of 64k (corresponding to one page in the common case)
minus the per-buffer overhead IBMVETH_BUFF_OH (which has value 22 for 14
bytes of ethernet header, plus 8 bytes for an opaque handle).

This suggests a maximum allowable MTU of 65514 bytes, but in fact the
driver only permits a maximum MTU of 65513.  This is because there is a <
instead of an <= in ibmveth_change_mtu(), which only permits an MTU which
is strictly smaller than the buffer size, rather than allowing the buffer
to be completely filled.

This patch fixes the buglet.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Acked-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
---
 drivers/net/ethernet/ibm/ibmveth.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Resending with Thomas Falcon's ACK included, since I previously forgot
to include the netdev list amongst the recipients.

diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
index cd7675a..1813476 100644
--- a/drivers/net/ethernet/ibm/ibmveth.c
+++ b/drivers/net/ethernet/ibm/ibmveth.c
@@ -1238,7 +1238,7 @@ static int ibmveth_change_mtu(struct net_device *dev, int new_mtu)
 		return -EINVAL;
 
 	for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++)
-		if (new_mtu_oh < adapter->rx_buff_pool[i].buff_size)
+		if (new_mtu_oh <= adapter->rx_buff_pool[i].buff_size)
 			break;
 
 	if (i == IBMVETH_NUM_BUFF_POOLS)
@@ -1257,7 +1257,7 @@ static int ibmveth_change_mtu(struct net_device *dev, int new_mtu)
 	for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++) {
 		adapter->rx_buff_pool[i].active = 1;
 
-		if (new_mtu_oh < adapter->rx_buff_pool[i].buff_size) {
+		if (new_mtu_oh <= adapter->rx_buff_pool[i].buff_size) {
 			dev->mtu = new_mtu;
 			vio_cmo_set_dev_desired(viodev,
 						ibmveth_get_desired_dma
-- 
2.1.0


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

* [PATCHv2] ibmveth: Fix off-by-one error in ibmveth_change_mtu()
@ 2015-04-23  4:43 ` David Gibson
  0 siblings, 0 replies; 8+ messages in thread
From: David Gibson @ 2015-04-23  4:43 UTC (permalink / raw)
  To: anton; +Cc: tlfalcon, netdev, linux-kernel, michael, linuxppc-dev, David Gibson

AFAIK the PAPR document which defines the virtual device interface used by
the ibmveth driver doesn't specify a specific maximum MTU.  So, in the
ibmveth driver, the maximum allowed MTU is determined by the maximum
allocated buffer size of 64k (corresponding to one page in the common case)
minus the per-buffer overhead IBMVETH_BUFF_OH (which has value 22 for 14
bytes of ethernet header, plus 8 bytes for an opaque handle).

This suggests a maximum allowable MTU of 65514 bytes, but in fact the
driver only permits a maximum MTU of 65513.  This is because there is a <
instead of an <= in ibmveth_change_mtu(), which only permits an MTU which
is strictly smaller than the buffer size, rather than allowing the buffer
to be completely filled.

This patch fixes the buglet.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Acked-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
---
 drivers/net/ethernet/ibm/ibmveth.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Resending with Thomas Falcon's ACK included, since I previously forgot
to include the netdev list amongst the recipients.

diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
index cd7675a..1813476 100644
--- a/drivers/net/ethernet/ibm/ibmveth.c
+++ b/drivers/net/ethernet/ibm/ibmveth.c
@@ -1238,7 +1238,7 @@ static int ibmveth_change_mtu(struct net_device *dev, int new_mtu)
 		return -EINVAL;
 
 	for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++)
-		if (new_mtu_oh < adapter->rx_buff_pool[i].buff_size)
+		if (new_mtu_oh <= adapter->rx_buff_pool[i].buff_size)
 			break;
 
 	if (i == IBMVETH_NUM_BUFF_POOLS)
@@ -1257,7 +1257,7 @@ static int ibmveth_change_mtu(struct net_device *dev, int new_mtu)
 	for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++) {
 		adapter->rx_buff_pool[i].active = 1;
 
-		if (new_mtu_oh < adapter->rx_buff_pool[i].buff_size) {
+		if (new_mtu_oh <= adapter->rx_buff_pool[i].buff_size) {
 			dev->mtu = new_mtu;
 			vio_cmo_set_dev_desired(viodev,
 						ibmveth_get_desired_dma
-- 
2.1.0

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

end of thread, other threads:[~2015-04-23 23:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-21  1:07 [PATCHv2] ibmveth: Fix off-by-one error in ibmveth_change_mtu() David Gibson
2015-04-21  1:07 ` David Gibson
2015-04-22 21:42 ` Thomas Falcon
2015-04-23 23:12   ` Tyrel Datwyler
2015-04-23  4:43 David Gibson
2015-04-23  4:43 ` David Gibson
2015-04-23 15:42 ` David Miller
2015-04-23 15:42   ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.