* [PATCH net 1/1] hv_netvsc: Fix a bug in netvsc_start_xmit()
@ 2015-04-28 1:14 K. Y. Srinivasan
2015-04-28 2:57 ` David Miller
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: K. Y. Srinivasan @ 2015-04-28 1:14 UTC (permalink / raw)
To: davem, netdev, linux-kernel, devel, olaf, apw, jasowang; +Cc: K. Y. Srinivasan
Commit commit b08cc79155fc26d0d112b1470d1ece5034651a4b eliminated memory
allocation in the packet send path. This commit introduced a bug since it
did not account for the case if the skb was cloned. Fix this bug by
using the pre-reserved head room only if the skb is not cloned.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
drivers/net/hyperv/netvsc_drv.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index a3a9d38..7eb0251 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -421,7 +421,7 @@ check_size:
pkt_sz = sizeof(struct hv_netvsc_packet) + RNDIS_AND_PPI_SIZE;
- if (head_room < pkt_sz) {
+ if (skb->cloned || head_room < pkt_sz) {
packet = kmalloc(pkt_sz, GFP_ATOMIC);
if (!packet) {
/* out of memory, drop packet */
--
1.7.4.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net 1/1] hv_netvsc: Fix a bug in netvsc_start_xmit()
2015-04-28 1:14 [PATCH net 1/1] hv_netvsc: Fix a bug in netvsc_start_xmit() K. Y. Srinivasan
@ 2015-04-28 2:57 ` David Miller
2015-04-28 3:23 ` KY Srinivasan
2015-04-28 2:57 ` Dexuan Cui
2015-04-28 18:27 ` Sergei Shtylyov
2 siblings, 1 reply; 6+ messages in thread
From: David Miller @ 2015-04-28 2:57 UTC (permalink / raw)
To: kys; +Cc: netdev, linux-kernel, devel, olaf, apw, jasowang
From: "K. Y. Srinivasan" <kys@microsoft.com>
Date: Mon, 27 Apr 2015 18:14:50 -0700
> Commit commit b08cc79155fc26d0d112b1470d1ece5034651a4b eliminated memory
> allocation in the packet send path. This commit introduced a bug since it
> did not account for the case if the skb was cloned. Fix this bug by
> using the pre-reserved head room only if the skb is not cloned.
>
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
We have generic infrastructure to do this, please try instead:
err = skb_cow_head(skb, pkt_sz);
this will take care of everything for you and you can get rid
of all of this dynamic memory allocation etc. in this code
path.
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH net 1/1] hv_netvsc: Fix a bug in netvsc_start_xmit()
2015-04-28 2:57 ` David Miller
@ 2015-04-28 3:23 ` KY Srinivasan
0 siblings, 0 replies; 6+ messages in thread
From: KY Srinivasan @ 2015-04-28 3:23 UTC (permalink / raw)
To: David Miller; +Cc: olaf, netdev, jasowang, linux-kernel, apw, devel
> -----Original Message-----
> From: David Miller [mailto:davem@davemloft.net]
> Sent: Monday, April 27, 2015 7:57 PM
> To: KY Srinivasan
> Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; olaf@aepfle.de; apw@canonical.com;
> jasowang@redhat.com
> Subject: Re: [PATCH net 1/1] hv_netvsc: Fix a bug in netvsc_start_xmit()
>
> From: "K. Y. Srinivasan" <kys@microsoft.com>
> Date: Mon, 27 Apr 2015 18:14:50 -0700
>
> > Commit commit b08cc79155fc26d0d112b1470d1ece5034651a4b eliminated
> memory
> > allocation in the packet send path. This commit introduced a bug since it
> > did not account for the case if the skb was cloned. Fix this bug by
> > using the pre-reserved head room only if the skb is not cloned.
> >
> > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
>
> We have generic infrastructure to do this, please try instead:
>
> err = skb_cow_head(skb, pkt_sz);
>
> this will take care of everything for you and you can get rid
> of all of this dynamic memory allocation etc. in this code
> path.
Thanks David; I will resubmit this patch.
Regards,
K. Y
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH net 1/1] hv_netvsc: Fix a bug in netvsc_start_xmit()
2015-04-28 1:14 [PATCH net 1/1] hv_netvsc: Fix a bug in netvsc_start_xmit() K. Y. Srinivasan
2015-04-28 2:57 ` David Miller
@ 2015-04-28 2:57 ` Dexuan Cui
2015-04-28 18:27 ` Sergei Shtylyov
2 siblings, 0 replies; 6+ messages in thread
From: Dexuan Cui @ 2015-04-28 2:57 UTC (permalink / raw)
To: KY Srinivasan, davem, netdev, linux-kernel, devel, olaf, apw, jasowang
> -----Original Message-----
> From: devel [mailto:driverdev-devel-bounces@linuxdriverproject.org] On
> Behalf Of K. Y. Srinivasan
> Sent: Tuesday, April 28, 2015 9:15
> To: davem@davemloft.net; netdev@vger.kernel.org; linux-
> kernel@vger.kernel.org; devel@linuxdriverproject.org; olaf@aepfle.de;
> apw@canonical.com; jasowang@redhat.com
> Subject: [PATCH net 1/1] hv_netvsc: Fix a bug in netvsc_start_xmit()
>
> Commit commit b08cc79155fc26d0d112b1470d1ece5034651a4b
> eliminated memory
> allocation in the packet send path. This commit introduced a bug since it
> did not account for the case if the skb was cloned. Fix this bug by
> using the pre-reserved head room only if the skb is not cloned.
>
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> ---
> drivers/net/hyperv/netvsc_drv.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/net/hyperv/netvsc_drv.c
> b/drivers/net/hyperv/netvsc_drv.c
> index a3a9d38..7eb0251 100644
> --- a/drivers/net/hyperv/netvsc_drv.c
> +++ b/drivers/net/hyperv/netvsc_drv.c
> @@ -421,7 +421,7 @@ check_size:
>
> pkt_sz = sizeof(struct hv_netvsc_packet) + RNDIS_AND_PPI_SIZE;
>
> - if (head_room < pkt_sz) {
> + if (skb->cloned || head_room < pkt_sz) {
> packet = kmalloc(pkt_sz, GFP_ATOMIC);
> if (!packet) {
> /* out of memory, drop packet */
> --
Without the patch, the guest can panic due to memory corruption.
I confirm the patch can fix the panic I saw.
Tested-by: Dexuan Cui <decui@microsoft.com>
Thanks,
-- Dexuan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net 1/1] hv_netvsc: Fix a bug in netvsc_start_xmit()
2015-04-28 1:14 [PATCH net 1/1] hv_netvsc: Fix a bug in netvsc_start_xmit() K. Y. Srinivasan
2015-04-28 2:57 ` David Miller
2015-04-28 2:57 ` Dexuan Cui
@ 2015-04-28 18:27 ` Sergei Shtylyov
2015-04-28 18:59 ` KY Srinivasan
2 siblings, 1 reply; 6+ messages in thread
From: Sergei Shtylyov @ 2015-04-28 18:27 UTC (permalink / raw)
To: K. Y. Srinivasan, davem, netdev, linux-kernel, devel, olaf, apw,
jasowang
Hello.
On 04/28/2015 04:14 AM, K. Y. Srinivasan wrote:
> Commit commit b08cc79155fc26d0d112b1470d1ece5034651a4b eliminated memory
One "commit" is enough. :-)
And please also specify that commit's summary in parens.
> allocation in the packet send path. This commit introduced a bug since it
> did not account for the case if the skb was cloned. Fix this bug by
> using the pre-reserved head room only if the skb is not cloned.
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
[...]
WBR, Sergei
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH net 1/1] hv_netvsc: Fix a bug in netvsc_start_xmit()
2015-04-28 18:27 ` Sergei Shtylyov
@ 2015-04-28 18:59 ` KY Srinivasan
0 siblings, 0 replies; 6+ messages in thread
From: KY Srinivasan @ 2015-04-28 18:59 UTC (permalink / raw)
To: Sergei Shtylyov, davem, netdev, linux-kernel, devel, olaf, apw, jasowang
> -----Original Message-----
> From: Sergei Shtylyov [mailto:sergei.shtylyov@cogentembedded.com]
> Sent: Tuesday, April 28, 2015 11:27 AM
> To: KY Srinivasan; davem@davemloft.net; netdev@vger.kernel.org; linux-
> kernel@vger.kernel.org; devel@linuxdriverproject.org; olaf@aepfle.de;
> apw@canonical.com; jasowang@redhat.com
> Subject: Re: [PATCH net 1/1] hv_netvsc: Fix a bug in netvsc_start_xmit()
>
> Hello.
>
> On 04/28/2015 04:14 AM, K. Y. Srinivasan wrote:
>
> > Commit commit b08cc79155fc26d0d112b1470d1ece5034651a4b eliminated
> memory
>
> One "commit" is enough. :-)
> And please also specify that commit's summary in parens.
>
> > allocation in the packet send path. This commit introduced a bug since it
> > did not account for the case if the skb was cloned. Fix this bug by
> > using the pre-reserved head room only if the skb is not cloned.
>
> > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
>
> [...]
>
> WBR, Sergei
Will do; thanks.
K. Y
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-04-28 18:59 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-28 1:14 [PATCH net 1/1] hv_netvsc: Fix a bug in netvsc_start_xmit() K. Y. Srinivasan
2015-04-28 2:57 ` David Miller
2015-04-28 3:23 ` KY Srinivasan
2015-04-28 2:57 ` Dexuan Cui
2015-04-28 18:27 ` Sergei Shtylyov
2015-04-28 18:59 ` KY Srinivasan
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).