Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix use after free issue in mbuf free #565

Merged
merged 1 commit into from
Jan 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/ff_dpdk_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,7 @@ ff_veth_input(const struct ff_dpdk_if_context *ctx, struct rte_mbuf *pkt)
data = rte_pktmbuf_mtod(pn, void*);
len = rte_pktmbuf_data_len(pn);

void *mb = ff_mbuf_get(prev, data, len);
void *mb = ff_mbuf_get(prev, pn, data, len);
if (mb == NULL) {
ff_mbuf_free(hdr);
rte_pktmbuf_free(pkt);
Expand Down Expand Up @@ -1967,7 +1967,7 @@ ff_dpdk_run(loop_func_t loop, void *arg) {
void
ff_dpdk_pktmbuf_free(void *m)
{
rte_pktmbuf_free((struct rte_mbuf *)m);
rte_pktmbuf_free_seg((struct rte_mbuf *)m);
}

static uint32_t
Expand Down
6 changes: 3 additions & 3 deletions lib/ff_veth.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,16 +209,16 @@ ff_mbuf_gethdr(void *pkt, uint16_t total, void *data,
}

void *
ff_mbuf_get(void *m, void *data, uint16_t len)
ff_mbuf_get(void *p, void *m, void *data, uint16_t len)
{
struct mbuf *prev = (struct mbuf *)m;
struct mbuf *prev = (struct mbuf *)p;
struct mbuf *mb = m_get(M_NOWAIT, MT_DATA);

if (mb == NULL) {
return NULL;
}

m_extadd(mb, data, len, NULL, NULL, NULL, 0, 0);
m_extadd(mb, data, len, ff_mbuf_ext_free, m, NULL, 0, EXT_DISPOSABLE);

mb->m_next = NULL;
mb->m_nextpkt = NULL;
Expand Down
2 changes: 1 addition & 1 deletion lib/ff_veth.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ int ff_veth_detach(void *arg);

void *ff_mbuf_gethdr(void *pkt, uint16_t total, void *data,
uint16_t len, uint8_t rx_csum);
void *ff_mbuf_get(void *m, void *data, uint16_t len);
void *ff_mbuf_get(void *p, void *m, void *data, uint16_t len);
void ff_mbuf_free(void *m);

int ff_mbuf_copydata(void *m, void *data, int off, int len);
Expand Down