netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Borkmann <dborkman@redhat.com>
To: Atzm Watanabe <atzm@stratosphere.co.jp>
Cc: David Laight <David.Laight@ACULAB.COM>,
	netdev@vger.kernel.org,
	Stephen Hemminger <stephen@networkplumber.org>,
	Ben Hutchings <bhutchings@solarflare.com>,
	David Miller <davem@davemloft.net>
Subject: Re: [PATCH v3 2/3] packet: fill the gap of TPACKET_ALIGNMENT with zeros
Date: Mon, 16 Dec 2013 13:55:43 +0100	[thread overview]
Message-ID: <52AEF84F.1000604@redhat.com> (raw)
In-Reply-To: <87k3f56k8t.wl%atzm@stratosphere.co.jp>

On 12/16/2013 01:41 PM, Atzm Watanabe wrote:
> At Mon, 16 Dec 2013 11:22:35 +0100,
> Daniel Borkmann wrote:
>>
>> On 12/16/2013 11:16 AM, David Laight wrote:
>>>>> +		memset(h.h2->tp_padding, 0,
>>>>> +		       hdrlen - offsetof(struct tpacket2_hdr, tp_padding));
>>>
>>> What is wrong with 'sizeof h.h2->tp_padding' ?
>>> The compiler will probably inline the memset into a couple of word
>>> sized writes of zero - probably not measurable.
>>> Not zeroing them might be leaking kernel memory contents (depends
>>> where the memory came from - might just be stale packet data).
>>
>> The ring buffer memory we're operating on comes from mmap(2) btw.
>
> Thank you for comments.
> In struct tpacket2_hdr, it seems that a padding member was really
> zeroing to fix information leak on commit
> 13fcb7bd322164c67926ffe272846d4860196dc6 ("af_packet: prevent information leak").
> So next time I'll try to zero tp_padding using sizof(h.h2->tp_padding)
> David proposed.  If you have any thoughts on this please share it with me.

Yep, 13fcb7bd was for struct tpacket_auxdata structure in packet_recvmsg()
that sits on the stack and copied uninitialized data to user space. But,
okay, lets go with the memset().

  reply	other threads:[~2013-12-16 12:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-16  8:12 [PATCH v3 2/3] packet: fill the gap of TPACKET_ALIGNMENT with zeros Atzm Watanabe
2013-12-16 10:09 ` Daniel Borkmann
2013-12-16 10:16   ` David Laight
2013-12-16 10:22     ` Daniel Borkmann
2013-12-16 12:41       ` Atzm Watanabe
2013-12-16 12:55         ` Daniel Borkmann [this message]
2013-12-16 16:48           ` Atzm Watanabe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52AEF84F.1000604@redhat.com \
    --to=dborkman@redhat.com \
    --cc=David.Laight@ACULAB.COM \
    --cc=atzm@stratosphere.co.jp \
    --cc=bhutchings@solarflare.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).