diff mbox

linux-generic: pktio: fix crash caused by invalid l2 offset

Message ID 1420646078-25851-1-git-send-email-ciprian.barbu@linaro.org
State New
Headers show

Commit Message

Ciprian Barbu Jan. 7, 2015, 3:54 p.m. UTC
Signed-off-by: Ciprian Barbu <ciprian.barbu@linaro.org>
---
Fix for bug 1034: https://bugs.linaro.org/show_bug.cgi?id=1034
 platform/linux-generic/odp_packet.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Ciprian Barbu Jan. 7, 2015, 5:17 p.m. UTC | #1
On Wed, Jan 7, 2015 at 6:15 PM, Stuart Haslam <stuart.haslam@arm.com> wrote:
> On Wed, Jan 07, 2015 at 03:54:38PM +0000, Ciprian Barbu wrote:
>> Signed-off-by: Ciprian Barbu <ciprian.barbu@linaro.org>
>
> I hit this problem yesterday and Bill sent a patch to resolve it;
>
> http://lists.linaro.org/pipermail/lng-odp/2015-January/007115.html
>
> (Perhaps I should've raised a bug..)
>
>> ---
>> Fix for bug 1034: https://bugs.linaro.org/show_bug.cgi?id=1034
>>  platform/linux-generic/odp_packet.c | 4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c
>> index eb0767a..180c8e0 100644
>> --- a/platform/linux-generic/odp_packet.c
>> +++ b/platform/linux-generic/odp_packet.c
>> @@ -232,6 +232,8 @@ void odp_packet_user_u64_set(odp_packet_t pkt, uint64_t ctx)
>>  void *odp_packet_l2_ptr(odp_packet_t pkt, uint32_t *len)
>>  {
>>       odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
>> +     if (pkt_hdr == NULL)
>> +             return NULL;

Yeah, that was debug code, ignore it.

>
> I don't think this check is needed. If you call this function with a pkt
> that isn't valid then behaviour is undefined.
>
>>       return packet_map(pkt_hdr, pkt_hdr->l2_offset, len);
>>  }
>>
>> @@ -778,7 +780,7 @@ int _odp_packet_parse(odp_packet_t pkt)
>>       pkt_hdr->error_flags.all  = 0;
>>       pkt_hdr->input_flags.all  = 0;
>>       pkt_hdr->output_flags.all = 0;
>> -     pkt_hdr->l2_offset        = ODP_PACKET_OFFSET_INVALID;
>> +     pkt_hdr->l2_offset        = 0;
>>       pkt_hdr->l3_offset        = ODP_PACKET_OFFSET_INVALID;
>>       pkt_hdr->l4_offset        = ODP_PACKET_OFFSET_INVALID;
>>       pkt_hdr->payload_offset   = ODP_PACKET_OFFSET_INVALID;
>
> --
> Stuart.
>
Bill Fischofer Jan. 7, 2015, 5:38 p.m. UTC | #2
My patch resolves this issue.  The change to odp_packet_l2_ptr() in this
patch is not needed.

Bill

On Wed, Jan 7, 2015 at 11:17 AM, Ciprian Barbu <ciprian.barbu@linaro.org>
wrote:

> On Wed, Jan 7, 2015 at 6:15 PM, Stuart Haslam <stuart.haslam@arm.com>
> wrote:
> > On Wed, Jan 07, 2015 at 03:54:38PM +0000, Ciprian Barbu wrote:
> >> Signed-off-by: Ciprian Barbu <ciprian.barbu@linaro.org>
> >
> > I hit this problem yesterday and Bill sent a patch to resolve it;
> >
> > http://lists.linaro.org/pipermail/lng-odp/2015-January/007115.html
> >
> > (Perhaps I should've raised a bug..)
> >
> >> ---
> >> Fix for bug 1034: https://bugs.linaro.org/show_bug.cgi?id=1034
> >>  platform/linux-generic/odp_packet.c | 4 +++-
> >>  1 file changed, 3 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/platform/linux-generic/odp_packet.c
> b/platform/linux-generic/odp_packet.c
> >> index eb0767a..180c8e0 100644
> >> --- a/platform/linux-generic/odp_packet.c
> >> +++ b/platform/linux-generic/odp_packet.c
> >> @@ -232,6 +232,8 @@ void odp_packet_user_u64_set(odp_packet_t pkt,
> uint64_t ctx)
> >>  void *odp_packet_l2_ptr(odp_packet_t pkt, uint32_t *len)
> >>  {
> >>       odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
> >> +     if (pkt_hdr == NULL)
> >> +             return NULL;
>
> Yeah, that was debug code, ignore it.
>
> >
> > I don't think this check is needed. If you call this function with a pkt
> > that isn't valid then behaviour is undefined.
> >
> >>       return packet_map(pkt_hdr, pkt_hdr->l2_offset, len);
> >>  }
> >>
> >> @@ -778,7 +780,7 @@ int _odp_packet_parse(odp_packet_t pkt)
> >>       pkt_hdr->error_flags.all  = 0;
> >>       pkt_hdr->input_flags.all  = 0;
> >>       pkt_hdr->output_flags.all = 0;
> >> -     pkt_hdr->l2_offset        = ODP_PACKET_OFFSET_INVALID;
> >> +     pkt_hdr->l2_offset        = 0;
> >>       pkt_hdr->l3_offset        = ODP_PACKET_OFFSET_INVALID;
> >>       pkt_hdr->l4_offset        = ODP_PACKET_OFFSET_INVALID;
> >>       pkt_hdr->payload_offset   = ODP_PACKET_OFFSET_INVALID;
> >
> > --
> > Stuart.
> >
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
>
diff mbox

Patch

diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c
index eb0767a..180c8e0 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -232,6 +232,8 @@  void odp_packet_user_u64_set(odp_packet_t pkt, uint64_t ctx)
 void *odp_packet_l2_ptr(odp_packet_t pkt, uint32_t *len)
 {
 	odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+	if (pkt_hdr == NULL)
+		return NULL;
 	return packet_map(pkt_hdr, pkt_hdr->l2_offset, len);
 }
 
@@ -778,7 +780,7 @@  int _odp_packet_parse(odp_packet_t pkt)
 	pkt_hdr->error_flags.all  = 0;
 	pkt_hdr->input_flags.all  = 0;
 	pkt_hdr->output_flags.all = 0;
-	pkt_hdr->l2_offset        = ODP_PACKET_OFFSET_INVALID;
+	pkt_hdr->l2_offset        = 0;
 	pkt_hdr->l3_offset        = ODP_PACKET_OFFSET_INVALID;
 	pkt_hdr->l4_offset        = ODP_PACKET_OFFSET_INVALID;
 	pkt_hdr->payload_offset   = ODP_PACKET_OFFSET_INVALID;