Skip to contentSkip to conversation

skb allocation size question

DISCUSSION Aaron Williams 2 participants 2 messages Sep 1, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi,

I have been trying to track down an issue in one of our drivers with SKB allocation and in my research I came across something that seems a bit strange. In __alloc_skb, a block for the data allocates size + sizeof(struct skb_shared_info) bytes, yet skb->truesize is set to size + sizeof(struct sk_buff). Is there a reason for this discrepancy?

-Aaron Williams

#1 lore raw
Quoted 7 lines · Aaron Williams

Hi,

I have been trying to track down an issue in one of our drivers with SKB allocation and in my research I came across something that seems a bit strange. In __alloc_skb, a block for the data allocates size + sizeof(struct skb_shared_info) bytes, yet skb->truesize is set to size + sizeof(struct sk_buff). Is there a reason for this discrepancy?

Hi Aaron

Not really. We also could add in truesize the sizeof(struct skb_shared_info).

Including sizeof(struct sk_buff) is enough to prevent a malicious user filling kernel memory with skb of one byte of payload.

Problem is, adding this extra overhead could slowdown some applications, using too small RCVBUF / SNDBUF settings.