trace: fix out of bounds write in __rte_trace_mem_get
PATCH 1/1 trace: fix out of bounds write in __rte_trace_mem_get
Offset should be aligned first before checking if there is free space for another write.
Bugzilla ID: 1665
--- lib/eal/include/rte_trace_point.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
lib/eal/include/rte_trace_point.h +1 -3
@@ -328,7 +328,7 @@ __rte_trace_mem_get(uint64_t in)return NULL ; }/* Check the wrap around case */ -uint32_t offset = trace->offset; +uint32_t offset =RTE_ALIGN_CEIL (trace->offset, __RTE_TRACE_EVENT_HEADER_SZ);if (unlikely ((offset + sz) >= trace->len)) {/* Disable the trace event if it in DISCARD mode */ if (unlikely (in & __RTE_TRACE_FIELD_ENABLE_DISCARD))
@@ -336,8 +336,6 @@ __rte_trace_mem_get(uint64_t in) offset =0 ; } -/* Align to event header size */ - offset =RTE_ALIGN_CEIL (offset, __RTE_TRACE_EVENT_HEADER_SZ);void *mem =RTE_PTR_ADD (&trace->mem[0 ], offset); offset += sz; trace->offset = offset;
Signature · 1 line
2.49.0
Quoted 6 lines
Offset should be aligned first before checking if there is free space for another write.
Bugzilla ID: 1665
Fixes ebaee6409702 ("trace: simplify trace point headers")
Quoted 7 lines
Signed-off-by Oleksandr Nahnybida <[email protected]>--- lib/eal/include/rte_trace_point.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)--
2.49.0
Quoted 6 lines · Oleksandr Nahnybida
Offset should be aligned first before checking if there is free space for another write.
Bugzilla ID: 1665
Fixes ebaee6409702 ("trace: simplify trace point headers")
This commit ebaee6409702 ("trace: simplify trace point headers") just moved code around.
I think the bug was present since the first implementation, so:
Signature · 1 line
David Marchand
PATCH v2 1/1 trace: fix out of bounds write in __rte_trace_mem_get
In reply to Oleksandr NahnybidaOffset should be aligned first before checking if there is free space for another write.
Bugzilla ID: 1665
---
Specified correct "Fixes" commit.
lib/eal/include/rte_trace_point.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
lib/eal/include/rte_trace_point.h +1 -3
@@ -328,7 +328,7 @@ __rte_trace_mem_get(uint64_t in)return NULL ; }/* Check the wrap around case */ -uint32_t offset = trace->offset; +uint32_t offset =RTE_ALIGN_CEIL (trace->offset, __RTE_TRACE_EVENT_HEADER_SZ);if (unlikely ((offset + sz) >= trace->len)) {/* Disable the trace event if it in DISCARD mode */ if (unlikely (in & __RTE_TRACE_FIELD_ENABLE_DISCARD))
@@ -336,8 +336,6 @@ __rte_trace_mem_get(uint64_t in) offset =0 ; } -/* Align to event header size */ - offset =RTE_ALIGN_CEIL (offset, __RTE_TRACE_EVENT_HEADER_SZ);void *mem =RTE_PTR_ADD (&trace->mem[0 ], offset); offset += sz; trace->offset = offset;
--
2.49.0
Quoted 38 lines
Offset should be aligned first before checking if there is free space for another write.
Bugzilla ID: 1665
Fixes 032a7e5499a0 ("trace: implement provider payload")Signed-off-by Oleksandr Nahnybida <[email protected]>---
Specified correct "Fixes" commit.lib/eal/include/rte_trace_point.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)lib/eal/include/rte_trace_point.h +2
-4@@ -328,7 +328,7 @@ __rte_trace_mem_get(uint64_t in)return NULL ; }/* Check the wrap around case */ -uint32_t offset = trace->offset; +uint32_t offset =RTE_ALIGN_CEIL (trace->offset, +__RTE_TRACE_EVENT_HEADER_SZ);if (unlikely ((offset + sz) >= trace->len)) {/* Disable the trace event if it in DISCARD mode */ if (unlikely (in & __RTE_TRACE_FIELD_ENABLE_DISCARD))@@ -336,8 +336,6 @@ __rte_trace_mem_get(uint64_t in) offset =0 ; } -/* Align to event header size */ - offset =RTE_ALIGN_CEIL (offset, __RTE_TRACE_EVENT_HEADER_SZ);void *mem =RTE_PTR_ADD (&trace->mem[0 ], offset); offset += sz; trace->offset = offset; --
Quoted 1 line
2.49.0
David Marchand
AppliedQuoted 6 lines · Oleksandr Nahnybida
Offset should be aligned first before checking if there is free space for another write.
Bugzilla ID: 1665
Fixes 032a7e5499a0 ("trace: implement provider payload")
Quoted 3 lines
Signed-off-by Oleksandr Nahnybida <[email protected]>Acked-by Sunil Kumar Kori <[email protected]>
Applied, thanks.
Signature · 1 line
David Marchand