* Re: [PATCH v2] openvswitch: supply a dummy err_handler of gre_cisco_protocol to prevent kernel crash [not found] <1396398194-4163-1-git-send-email-asuka.com@163.com> @ 2014-04-04 23:05 ` Jesse Gross 2014-04-05 4:20 ` wei zhang 0 siblings, 1 reply; 3+ messages in thread From: Jesse Gross @ 2014-04-04 23:05 UTC (permalink / raw) To: Wei Zhang; +Cc: David Miller, dev, netdev, Linux Kernel Mailing List On Tue, Apr 1, 2014 at 5:23 PM, Wei Zhang <asuka.com@163.com> wrote: > When use gre vport, openvswitch register a gre_cisco_protocol but does not > supply a err_handler with it. The gre_cisco_err() in net/ipv4/gre_demux.c expect > err_handler be provided with the gre_cisco_protocol implementation, and call > ->err_handler() without existence check, cause the kernel crash. > > This patch provide a err_handler to fix this bug. > > v2 -> v1: use the same logic of the gre_rcv() to distinguish which packet is > intended to us! As a tip on kernel process: if you put the version information after three dashes below the signed-off-by line then git will automatically remove it when the final patch is applied. > diff --git a/net/openvswitch/vport-gre.c b/net/openvswitch/vport-gre.c > index a3d6951..f391df1 100644 > --- a/net/openvswitch/vport-gre.c > +++ b/net/openvswitch/vport-gre.c > @@ -110,6 +110,21 @@ static int gre_rcv(struct sk_buff *skb, > return PACKET_RCVD; > } > > +/* Called with rcu_read_lock and BH disabled. */ > +static int gre_err(struct sk_buff *skb, u32 info, > + const struct tnl_ptk_info *tpi) > +{ > + struct ovs_net *ovs_net; > + struct vport *vport; > + > + ovs_net = net_generic(dev_net(skb->dev), ovs_net_id); > + vport = rcu_dereference(ovs_net->vport_net.gre_vport); > + if (unlikely(!vport)) > + return PACKET_REJECT; > + else > + return PACKET_RCVD; Sorry, I forgot to say this before - if we receive the packet then we should also call consume_skb() on it. ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] openvswitch: supply a dummy err_handler of gre_cisco_protocol to prevent kernel crash 2014-04-04 23:05 ` [PATCH v2] openvswitch: supply a dummy err_handler of gre_cisco_protocol to prevent kernel crash Jesse Gross @ 2014-04-05 4:20 ` wei zhang 2014-04-09 0:46 ` Jesse Gross 0 siblings, 1 reply; 3+ messages in thread From: wei zhang @ 2014-04-05 4:20 UTC (permalink / raw) To: Jesse Gross; +Cc: David Miller, dev, netdev, Linux Kernel Mailing List [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 1976 bytes --] At 2014-04-05 07:05:59,"Jesse Gross" <jesse@nicira.com> wrote: >On Tue, Apr 1, 2014 at 5:23 PM, Wei Zhang <asuka.com@163.com> wrote: >> >> v2 -> v1: use the same logic of the gre_rcv() to distinguish which packet is >> intended to us! > >As a tip on kernel process: if you put the version information after >three dashes below the signed-off-by line then git will automatically >remove it when the final patch is applied. Thanks, should I modify it and send a v3 patch? > >> diff --git a/net/openvswitch/vport-gre.c b/net/openvswitch/vport-gre.c >> index a3d6951..f391df1 100644 >> --- a/net/openvswitch/vport-gre.c >> +++ b/net/openvswitch/vport-gre.c >> @@ -110,6 +110,21 @@ static int gre_rcv(struct sk_buff *skb, >>         return PACKET_RCVD; >>  } >> >> +/* Called with rcu_read_lock and BH disabled. */ >> +static int gre_err(struct sk_buff *skb, u32 info, >> +                  const struct tnl_ptk_info *tpi) >> +{ >> +       struct ovs_net *ovs_net; >> +       struct vport *vport; >> + >> +       ovs_net = net_generic(dev_net(skb->dev), ovs_net_id); >> +       vport = rcu_dereference(ovs_net->vport_net.gre_vport); >> +       if (unlikely(!vport)) >> +               return PACKET_REJECT; >> +       else >> +               return PACKET_RCVD; > >Sorry, I forgot to say this before - if we receive the packet then we >should also call consume_skb() on it. Maybe there is no need to call consume_skb()? The icmp_rcv() would call kfree_skb() for us. I also checked the ipgre_err(), it return PACKET_RCVD without call consume_skb() too. Regards, Wei Zhangÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥ ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] openvswitch: supply a dummy err_handler of gre_cisco_protocol to prevent kernel crash 2014-04-05 4:20 ` wei zhang @ 2014-04-09 0:46 ` Jesse Gross 0 siblings, 0 replies; 3+ messages in thread From: Jesse Gross @ 2014-04-09 0:46 UTC (permalink / raw) To: wei zhang; +Cc: David Miller, dev, netdev, Linux Kernel Mailing List On Fri, Apr 4, 2014 at 9:20 PM, wei zhang <asuka.com@163.com> wrote: > At 2014-04-05 07:05:59,"Jesse Gross" <jesse@nicira.com> wrote: >>On Tue, Apr 1, 2014 at 5:23 PM, Wei Zhang <asuka.com@163.com> wrote: >>> >>> v2 -> v1: use the same logic of the gre_rcv() to distinguish which packet is >>> intended to us! >> >>As a tip on kernel process: if you put the version information after >>three dashes below the signed-off-by line then git will automatically >>remove it when the final patch is applied. > > Thanks, should I modify it and send a v3 patch? > >> >>> diff --git a/net/openvswitch/vport-gre.c b/net/openvswitch/vport-gre.c >>> index a3d6951..f391df1 100644 >>> --- a/net/openvswitch/vport-gre.c >>> +++ b/net/openvswitch/vport-gre.c >>> @@ -110,6 +110,21 @@ static int gre_rcv(struct sk_buff *skb, >>> return PACKET_RCVD; >>> } >>> >>> +/* Called with rcu_read_lock and BH disabled. */ >>> +static int gre_err(struct sk_buff *skb, u32 info, >>> + const struct tnl_ptk_info *tpi) >>> +{ >>> + struct ovs_net *ovs_net; >>> + struct vport *vport; >>> + >>> + ovs_net = net_generic(dev_net(skb->dev), ovs_net_id); >>> + vport = rcu_dereference(ovs_net->vport_net.gre_vport); >>> + if (unlikely(!vport)) >>> + return PACKET_REJECT; >>> + else >>> + return PACKET_RCVD; >> >>Sorry, I forgot to say this before - if we receive the packet then we >>should also call consume_skb() on it. > > Maybe there is no need to call consume_skb()? The icmp_rcv() would > call kfree_skb() for us. I also checked the ipgre_err(), it return > PACKET_RCVD without call consume_skb() too. Thanks, you are right. I applied your patch as is. ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-04-09 0:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <1396398194-4163-1-git-send-email-asuka.com@163.com>
2014-04-04 23:05 ` [PATCH v2] openvswitch: supply a dummy err_handler of gre_cisco_protocol to prevent kernel crash Jesse Gross
2014-04-05 4:20 ` wei zhang
2014-04-09 0:46 ` Jesse Gross
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®