Skip to content
This repository has been archived by the owner on Sep 20, 2022. It is now read-only.

sniffer: Check for missing netif header in dump_pkt #54

Merged
merged 1 commit into from
Oct 27, 2018

Conversation

jnohlgard
Copy link
Member

@jnohlgard jnohlgard commented Oct 26, 2018

Avoids a hard fault when using the latest RIOT master where raw mode does not provide a netif header.

The sniffer application works without this PR on samr21-xpro, but only because of luck.

pkt = gnrc_pktbuf_remove_snip(pkt, pkt->next);
pkt->next is NULL and the pktbuf_remove call causes an indirect write: pkt->next->next = NULL;

On frdm-kw41z (with RIOT-OS/RIOT#7107) the null pointer write causes a hard fault

for reference, here is the called function where the write happens: https://github.com/RIOT-OS/RIOT/blob/f139dfdad2c81f239e27e2be86a7857e740dc201/sys/net/gnrc/pktbuf/gnrc_pktbuf.c#L54-L62

Avoids a hard fault when using the latest RIOT master where raw mode
does not provide a netif header.
@jnohlgard jnohlgard added the bug label Oct 26, 2018
@jnohlgard jnohlgard requested a review from miri64 October 26, 2018 22:09
jnohlgard pushed a commit to jnohlgard/RIOT that referenced this pull request Oct 26, 2018
Useful in sniffer situations to see the signal strength of a received
packet. Also avoids the crash described in
RIOT-OS/applications#54
Copy link
Member

@miri64 miri64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK. I don't need to test this change to see, that the current state could cause a crash while the new version would not. Compiling works without problems.

I don't know how the impact would be performance-wise, but it might make sense to use gnrc_pktsnip_search_type() instead of just assuming that pkg->next might be GNRC_NETTYPE_NETIF.

@miri64 miri64 merged commit 1945cce into RIOT-OS:master Oct 27, 2018
jnohlgard pushed a commit to jnohlgard/RIOT that referenced this pull request Oct 27, 2018
Useful in sniffer situations to see the signal strength of a received
packet. Also avoids the crash described in
RIOT-OS/applications#54
jnohlgard pushed a commit to jnohlgard/RIOT that referenced this pull request Oct 29, 2018
Useful in sniffer situations to see the signal strength of a received
packet. Also avoids the crash described in
RIOT-OS/applications#54
@jnohlgard jnohlgard deleted the sniffer/pkt-next-nullptr branch November 5, 2018 13:01
pekkanikander pushed a commit to AaltoNEPPI/RIOT that referenced this pull request Nov 13, 2018
Useful in sniffer situations to see the signal strength of a received
packet. Also avoids the crash described in
RIOT-OS/applications#54
chrysn pushed a commit to chrysn-pull-requests/RIOT that referenced this pull request Sep 20, 2022
…xt-nullptr

sniffer: Check for missing netif header in dump_pkt
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants