diff mbox

linux-generic: pktio: fix SEGV after odp_pktio_inq_remdef()

Message ID 1427993360-26324-1-git-send-email-stuart.haslam@linaro.org
State Accepted
Commit f639f626a7cf6c198f0ea4b649d7b86d2026f14b
Headers show

Commit Message

Stuart Haslam April 2, 2015, 4:49 p.m. UTC
Calling odp_pktio_inq_remdef() causes the pktio's inq_default to be set
to ODP_QUEUE_INVALID, but when the scheduler later polls the pktio it
fails to check the validity of inq_default and ends up passing a bogus
pointer to queue_enq_multi().

Signed-off-by: Stuart Haslam <stuart.haslam@linaro.org>
---
 platform/linux-generic/odp_packet_io.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Ciprian Barbu April 3, 2015, 7:49 a.m. UTC | #1
On Thu, Apr 2, 2015 at 7:49 PM, Stuart Haslam <stuart.haslam@linaro.org> wrote:
> Calling odp_pktio_inq_remdef() causes the pktio's inq_default to be set
> to ODP_QUEUE_INVALID, but when the scheduler later polls the pktio it
> fails to check the validity of inq_default and ends up passing a bogus
> pointer to queue_enq_multi().
>
> Signed-off-by: Stuart Haslam <stuart.haslam@linaro.org>

Reviewed-by: Ciprian Barbu <ciprian.barbu@linaro.org>

> ---
>  platform/linux-generic/odp_packet_io.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c
> index 45303f6..73a4be2 100644
> --- a/platform/linux-generic/odp_packet_io.c
> +++ b/platform/linux-generic/odp_packet_io.c
> @@ -685,6 +685,9 @@ int pktin_poll(pktio_entry_t *entry)
>         if (odp_unlikely(is_free(entry)))
>                 return -1;
>
> +       if (odp_unlikely(entry->s.inq_default == ODP_QUEUE_INVALID))
> +               return -1;
> +
>         num = odp_pktio_recv(entry->s.handle, pkt_tbl, QUEUE_MULTI_MAX);
>
>         if (num < 0) {
> --
> 2.1.1
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp
diff mbox

Patch

diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c
index 45303f6..73a4be2 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -685,6 +685,9 @@  int pktin_poll(pktio_entry_t *entry)
 	if (odp_unlikely(is_free(entry)))
 		return -1;
 
+	if (odp_unlikely(entry->s.inq_default == ODP_QUEUE_INVALID))
+		return -1;
+
 	num = odp_pktio_recv(entry->s.handle, pkt_tbl, QUEUE_MULTI_MAX);
 
 	if (num < 0) {