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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 4 May 2021 13:22:17 +1200
From:   Richard Sanger <rsanger@...d.net.nz>
To:     Willem de Bruijn <willemdebruijn.kernel@...il.com>
Cc:     Network Development <netdev@...r.kernel.org>,
        Daniel Borkmann <daniel@...earbox.net>
Subject: Re: [PATCH] net: packetmmap: fix only tx timestamp on request

Hi Willem,

This is to match up with the documented behaviour; see the timestamping section
at the bottom of
https://www.kernel.org/doc/html/latest/networking/packet_mmap.html

If no call to setsockopt(fd, SOL_PACKET, PACKET_TIMESTAMP, ...) is made then
the tx path ring should not return timestamps, or timestamp flags set in
tp_status.

As noted in b9c32fb27170
("packet: if hw/sw ts enabled in rx/tx ring, report which ts we got")
this is to retain backwards compatibility with old code.

However, currently, a timestamp can be returned without setting
PACKET_TIMESTAMP, in the case that skb->tstamp includes a timestamp.
I only noticed this recently due to:
aa4e689ed1 (veth: add software timestamping)
which means skb->tstamp now includes a timestamp.

The issue this bug causes for old/non-timestamp aware code is that tp_status
may incorrectly have the TP_STATUS_TS_SOFTWARE flag set, so the documented
check (tp_status == TP_STATUS_AVAILABLE) that a frame in the ring is free fails.
Causing such code to hang infinitely.

This patch corrects the behaviour for the tx path. But, doesn't change the
behaviour on the rx path. The rx path still includes a timestamp (hence
the patch always sets the SOF_TIMESTAMPING_SOFTWARE flag on rx).

Thanks,
Richard


On Tue, May 4, 2021 at 12:36 PM Willem de Bruijn
<willemdebruijn.kernel@...il.com> wrote:
>
> On Mon, May 3, 2021 at 8:04 PM Richard Sanger <rsanger@...d.net.nz> wrote:
> >
> > The packetmmap tx ring should only return timestamps if requested,
> > as documented. This allows compatibility with non-timestamp aware
> > user-space code which checks tp_status == TP_STATUS_AVAILABLE;
> > not expecting additional timestamp flags to be set.
>
> This is an established interface.
>
> Passing the status goes back to 2013, since commit b9c32fb27170
> ("packet: if hw/sw ts enabled in rx/tx ring, report which ts we got").
>
> Passing a timestamp itself in tp_sec/tp_usec goes back to before git,
> probably to the introduction of the ring.
>
> I don't think we can change this now. That will likely break
> applications that have come to expect current behavior.
>
> Is it documented somewhere that the ring works differently? Or are you
> referring to the general SO_TIMESTAMPING behavior, which is a separate
> timestamp interface.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ