lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <317951393088907@web3h.yandex.ru>
Date:	Sat, 22 Feb 2014 21:08:27 +0400
From:	Кулешов Алексей <rndfax@...dex.ru>
To:	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: sk_buff: why field 'head' contains skb_shared_info?

Subj.

Look at this core function:
net/core/skbuff.c: __alloc_skb
...
        size = SKB_DATA_ALIGN(size);
        size += SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
        data = kmalloc_reserve(size, gfp_mask, node, &pfmemalloc);
...
        shinfo = skb_shinfo(skb);
        memset(shinfo, 0, offsetof(struct skb_shared_info, dataref));
...

It looks like it was made purposely, but for what?

Why this question has risen.
I found for my needs a very nice (for the first look) function <build_skb> from skbuff.c:
>  * build_skb - build a network buffer
>  * @data: data buffer provided by caller
> ...
>  * Notes :
>  *  Before IO, driver allocates only data buffer where NIC put incoming frame

Everything looks delicious, until this place:
>  *  Driver should add room at head (NET_SKB_PAD) and
>  *  MUST add room at tail (SKB_DATA_ALIGN(skb_shared_info))

And what if NIC is not a regular net_device and it doesn't need sk_buff at all.
But for virtual ethernet device "Ethernet-over-NIC" sk_buff is crucial.
So driver for NIC can't just kmalloc(NICs_RCV_BUF_SIZE, ...) for incoming buffers,
it has to kmalloc(NICs_RCV_BUF_SIZE + <skb_shared_info>, ...) to cover
attached (if any) to NIC virtual ethernet device needs.
Or virtual ethernet device has to do netdev_alloc_skb + memcpy,
which is obviously not so good.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ