skb allocation size question
Subsystems (2)
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
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, yetskb->truesizeis 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.