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]
Message-ID: <CAF=yD-Jc1v9hp9cy-0gZxqWg6PDoiPA90pvJPKRrB-Mn9DcJ7Q@mail.gmail.com>
Date:   Tue, 17 Jan 2023 13:04:13 -0500
From:   Willem de Bruijn <willemdebruijn.kernel@...il.com>
To:     Alexander H Duyck <alexander.duyck@...il.com>
Cc:     netdev@...r.kernel.org, davem@...emloft.net, kuba@...nel.org,
        edumazet@...gle.com, pabeni@...hat.com,
        Willem de Bruijn <willemb@...gle.com>
Subject: Re: [PATCH net] selftests/net: toeplitz: fix race on tpacket_v3 block close

On Tue, Jan 17, 2023 at 11:31 AM Alexander H Duyck
<alexander.duyck@...il.com> wrote:
>
> On Mon, 2023-01-16 at 12:40 -0500, Willem de Bruijn wrote:
> > From: Willem de Bruijn <willemb@...gle.com>
> >
> > Avoid race between process wakeup and tpacket_v3 block timeout.
> >
> > The test waits for cfg_timeout_msec for packets to arrive. Packets
> > arrive in tpacket_v3 rings, which pass packets ("frames") to the
> > process in batches ("blocks"). The sk waits for req3.tp_retire_blk_tov
> > msec to release a block.
> >
> > Set the block timeout lower than the process waiting time, else
> > the process may find that no block has been released by the time it
> > scans the socket list. Convert to a ring of more than one, smaller,
> > blocks with shorter timeouts. Blocks must be page aligned, so >= 64KB.
> >
> > Somewhat awkward while () notation dictated by checkpatch: no empty
> > braces allowed, nor statement on the same line as the condition.
>
> You might look at using a do/while approach rather than just a straight
> while. I believe that is the pattern used at various points throughout
> the kernel when you do nothing between the braces. I know we have
> instances of "do {} while (0)" throughout the kernel so that might be a
> way to go.

Thanks. I tried a couple of approaches. None of them seemed
particularly clean. I include do {} while (condition) in that list.

In this case, I think the patchwork error is a false positive and

  while (condition) {}

is idiomatic.

The rule it triggers is to prevent excess braces for single line branches.

Alternative might be

  while (condition);

That triggers a rule that tries to prevent "if (condition) action;" on
the same line.

I found the current solution the least bad of the allowed options. But
can definitely respin using "do {} while" if preferred.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ