* [PATCH] Fix Kernel Panic in bonding driver debugfs file: rlb_hash_table
@ 2015-04-29 18:24 Pai
2015-04-29 18:51 ` Andy Gospodarek
2015-04-29 19:45 ` Nikolay Aleksandrov
0 siblings, 2 replies; 6+ messages in thread
From: Pai @ 2015-04-29 18:24 UTC (permalink / raw)
To: Jay Vosburgh, Veaceslav Falico, Andy Gospodarek, netdev,
linux-kernel, Vishwanath Pai
This patch fixes a Kernel Panic in bonding driver debugfs file: rlb_hash_table.
$> modprobe bonding mode=6
$> cat /sys/kernel/debug/bonding/bond0/rlb_hash_table
This will crash the kernel. The struct alb_bond_info is initialized only when
the bonding interface is initialized (ip link set bond0 up) and not at the time
it is allocated. If we try to read the table before that, it'll result in a
kernel panic.
The patch applies against both net and net-next
Signed-off-by: Vishwanath Pai <vpai@akamai.com>
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 089a402..806892a 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -4510,6 +4510,8 @@ unsigned int bond_get_num_tx_queues(void)
int bond_create(struct net *net, const char *name)
{
struct net_device *bond_dev;
+ struct bonding *bond;
+ struct alb_bond_info *bond_info;
int res;
rtnl_lock();
@@ -4523,6 +4525,14 @@ int bond_create(struct net *net, const char *name)
return -ENOMEM;
}
+ /*
+ * Initialize rx_hashtbl_used_head to RLB_NULL_INDEX.
+ * It is set to 0 by default which is wrong.
+ */
+ bond = netdev_priv(bond_dev);
+ bond_info = &(BOND_ALB_INFO(bond));
+ bond_info->rx_hashtbl_used_head = RLB_NULL_INDEX;
+
dev_net_set(bond_dev, net);
bond_dev->rtnl_link_ops = &bond_link_ops;
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix Kernel Panic in bonding driver debugfs file: rlb_hash_table
2015-04-29 18:24 [PATCH] Fix Kernel Panic in bonding driver debugfs file: rlb_hash_table Pai
@ 2015-04-29 18:51 ` Andy Gospodarek
2015-04-29 19:37 ` David Miller
2015-04-29 19:45 ` Nikolay Aleksandrov
1 sibling, 1 reply; 6+ messages in thread
From: Andy Gospodarek @ 2015-04-29 18:51 UTC (permalink / raw)
To: Pai; +Cc: Jay Vosburgh, Veaceslav Falico, Andy Gospodarek, netdev,
linux-kernel
On Wed, Apr 29, 2015 at 02:24:23PM -0400, Pai wrote:
> This patch fixes a Kernel Panic in bonding driver debugfs file: rlb_hash_table.
>
> $> modprobe bonding mode=6
> $> cat /sys/kernel/debug/bonding/bond0/rlb_hash_table
>
> This will crash the kernel. The struct alb_bond_info is initialized only when
> the bonding interface is initialized (ip link set bond0 up) and not at the time
> it is allocated. If we try to read the table before that, it'll result in a
> kernel panic.
Nice catch!
>
> The patch applies against both net and net-next
>
> Signed-off-by: Vishwanath Pai <vpai@akamai.com>
Signed-off-by: Andy Gospodarek <gospo@cumulusnetworks.com>
>
> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> index 089a402..806892a 100644
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
> @@ -4510,6 +4510,8 @@ unsigned int bond_get_num_tx_queues(void)
> int bond_create(struct net *net, const char *name)
> {
> struct net_device *bond_dev;
> + struct bonding *bond;
> + struct alb_bond_info *bond_info;
> int res;
>
> rtnl_lock();
> @@ -4523,6 +4525,14 @@ int bond_create(struct net *net, const char *name)
> return -ENOMEM;
> }
>
> + /*
> + * Initialize rx_hashtbl_used_head to RLB_NULL_INDEX.
> + * It is set to 0 by default which is wrong.
> + */
> + bond = netdev_priv(bond_dev);
> + bond_info = &(BOND_ALB_INFO(bond));
> + bond_info->rx_hashtbl_used_head = RLB_NULL_INDEX;
> +
> dev_net_set(bond_dev, net);
> bond_dev->rtnl_link_ops = &bond_link_ops;
>
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix Kernel Panic in bonding driver debugfs file: rlb_hash_table
2015-04-29 18:51 ` Andy Gospodarek
@ 2015-04-29 19:37 ` David Miller
0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2015-04-29 19:37 UTC (permalink / raw)
To: gospo; +Cc: vpai, j.vosburgh, vfalico, andy, netdev, linux-kernel
From: Andy Gospodarek <gospo@cumulusnetworks.com>
Date: Wed, 29 Apr 2015 14:51:07 -0400
> On Wed, Apr 29, 2015 at 02:24:23PM -0400, Pai wrote:
>> This patch fixes a Kernel Panic in bonding driver debugfs file: rlb_hash_table.
>>
>> $> modprobe bonding mode=6
>> $> cat /sys/kernel/debug/bonding/bond0/rlb_hash_table
>>
>> This will crash the kernel. The struct alb_bond_info is initialized only when
>> the bonding interface is initialized (ip link set bond0 up) and not at the time
>> it is allocated. If we try to read the table before that, it'll result in a
>> kernel panic.
>
> Nice catch!
>
>>
>> The patch applies against both net and net-next
>>
>> Signed-off-by: Vishwanath Pai <vpai@akamai.com>
>
> Signed-off-by: Andy Gospodarek <gospo@cumulusnetworks.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix Kernel Panic in bonding driver debugfs file: rlb_hash_table
2015-04-29 18:24 [PATCH] Fix Kernel Panic in bonding driver debugfs file: rlb_hash_table Pai
2015-04-29 18:51 ` Andy Gospodarek
@ 2015-04-29 19:45 ` Nikolay Aleksandrov
2015-04-29 20:30 ` Vishwanath Pai
1 sibling, 1 reply; 6+ messages in thread
From: Nikolay Aleksandrov @ 2015-04-29 19:45 UTC (permalink / raw)
To: Pai, Jay Vosburgh, Veaceslav Falico, Andy Gospodarek, netdev,
linux-kernel
On 04/29/2015 08:24 PM, Pai wrote:
> This patch fixes a Kernel Panic in bonding driver debugfs file: rlb_hash_table.
>
> $> modprobe bonding mode=6
> $> cat /sys/kernel/debug/bonding/bond0/rlb_hash_table
>
> This will crash the kernel. The struct alb_bond_info is initialized only when
> the bonding interface is initialized (ip link set bond0 up) and not at the time
> it is allocated. If we try to read the table before that, it'll result in a
> kernel panic.
>
> The patch applies against both net and net-next
>
> Signed-off-by: Vishwanath Pai <vpai@akamai.com>
>
Good catch, a few cosmetic nits below.
> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> index 089a402..806892a 100644
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
> @@ -4510,6 +4510,8 @@ unsigned int bond_get_num_tx_queues(void)
> int bond_create(struct net *net, const char *name)
> {
> struct net_device *bond_dev;
> + struct bonding *bond;
> + struct alb_bond_info *bond_info;
Please arrange these longest to shortest line, it's easier to read.
> int res;
>
> rtnl_lock();
> @@ -4523,6 +4525,14 @@ int bond_create(struct net *net, const char *name)
> return -ENOMEM;
> }
>
> + /*
> + * Initialize rx_hashtbl_used_head to RLB_NULL_INDEX.
> + * It is set to 0 by default which is wrong.
> + */
Multiline comment style of networking content is:
/* text
* text
*/
See: Documentation/networking/netdev-FAQ.txt
Alternatively you can create an inline with descriptive name that does the
initialization and wouldn't need the comment. Either way's fine by me.
Cheers,
Nik
> + bond = netdev_priv(bond_dev);
> + bond_info = &(BOND_ALB_INFO(bond));
> + bond_info->rx_hashtbl_used_head = RLB_NULL_INDEX;
> +
> dev_net_set(bond_dev, net);
> bond_dev->rtnl_link_ops = &bond_link_ops;
>
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix Kernel Panic in bonding driver debugfs file: rlb_hash_table
2015-04-29 19:45 ` Nikolay Aleksandrov
@ 2015-04-29 20:30 ` Vishwanath Pai
2015-04-29 20:57 ` David Miller
0 siblings, 1 reply; 6+ messages in thread
From: Vishwanath Pai @ 2015-04-29 20:30 UTC (permalink / raw)
To: Nikolay Aleksandrov, Andy Gospodarek, davem
Cc: Jay Vosburgh, Veaceslav Falico, netdev, linux-kernel
On 04/29/2015 03:45 PM, Nikolay Aleksandrov wrote:
> On 04/29/2015 08:24 PM, Pai wrote:
>> This patch fixes a Kernel Panic in bonding driver debugfs file: rlb_hash_table.
>>
>> $> modprobe bonding mode=6
>> $> cat /sys/kernel/debug/bonding/bond0/rlb_hash_table
>>
>> This will crash the kernel. The struct alb_bond_info is initialized only when
>> the bonding interface is initialized (ip link set bond0 up) and not at the time
>> it is allocated. If we try to read the table before that, it'll result in a
>> kernel panic.
>>
>> The patch applies against both net and net-next
>>
>> Signed-off-by: Vishwanath Pai <vpai@akamai.com>
>>
> Good catch, a few cosmetic nits below.
>
>> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
>> index 089a402..806892a 100644
>> --- a/drivers/net/bonding/bond_main.c
>> +++ b/drivers/net/bonding/bond_main.c
>> @@ -4510,6 +4510,8 @@ unsigned int bond_get_num_tx_queues(void)
>> int bond_create(struct net *net, const char *name)
>> {
>> struct net_device *bond_dev;
>> + struct bonding *bond;
>> + struct alb_bond_info *bond_info;
> Please arrange these longest to shortest line, it's easier to read.
>
>> int res;
>>
>> rtnl_lock();
>> @@ -4523,6 +4525,14 @@ int bond_create(struct net *net, const char *name)
>> return -ENOMEM;
>> }
>>
>> + /*
>> + * Initialize rx_hashtbl_used_head to RLB_NULL_INDEX.
>> + * It is set to 0 by default which is wrong.
>> + */
> Multiline comment style of networking content is:
> /* text
> * text
> */
>
> See: Documentation/networking/netdev-FAQ.txt
>
> Alternatively you can create an inline with descriptive name that does the
> initialization and wouldn't need the comment. Either way's fine by me.
>
> Cheers,
> Nik
>
>> + bond = netdev_priv(bond_dev);
>> + bond_info = &(BOND_ALB_INFO(bond));
>> + bond_info->rx_hashtbl_used_head = RLB_NULL_INDEX;
>> +
>> dev_net_set(bond_dev, net);
>> bond_dev->rtnl_link_ops = &bond_link_ops;
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe netdev" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>
>
David,
Since the patch has been applied already - should I send a V2 with the
suggested changes? Or submit a new patch that applies on top of the
first patch?
Thanks,
Vishwanath
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix Kernel Panic in bonding driver debugfs file: rlb_hash_table
2015-04-29 20:30 ` Vishwanath Pai
@ 2015-04-29 20:57 ` David Miller
0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2015-04-29 20:57 UTC (permalink / raw)
To: vpai; +Cc: razor, andy, j.vosburgh, vfalico, netdev, linux-kernel
From: Vishwanath Pai <vpai@akamai.com>
Date: Wed, 29 Apr 2015 16:30:44 -0400
> Since the patch has been applied already - should I send a V2 with the
> suggested changes? Or submit a new patch that applies on top of the
> first patch?
You should always send me a relative patch in this situation.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-04-29 20:57 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-29 18:24 [PATCH] Fix Kernel Panic in bonding driver debugfs file: rlb_hash_table Pai
2015-04-29 18:51 ` Andy Gospodarek
2015-04-29 19:37 ` David Miller
2015-04-29 19:45 ` Nikolay Aleksandrov
2015-04-29 20:30 ` Vishwanath Pai
2015-04-29 20:57 ` 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).