[ovs-git] [openvswitch/ovs] 00d3d4: checkpatch: Avoid catastrophic backtracking.

Aaron Conole noreply at github.com
Wed Sep 8 19:52:55 UTC 2021


  Branch: refs/heads/master
  Home:   https://github.com/openvswitch/ovs
  Commit: 00d3d4a7d3750ab1d907d58894ad817febce1cf7
      https://github.com/openvswitch/ovs/commit/00d3d4a7d3750ab1d907d58894ad817febce1cf7
  Author: Aaron Conole <aconole at redhat.com>
  Date:   2021-09-08 (Wed, 08 Sep 2021)

  Changed paths:
    M tests/checkpatch.at
    M utilities/checkpatch.py

  Log Message:
  -----------
  checkpatch: Avoid catastrophic backtracking.

As Frode Nordahl points out in [0], it is possible for the
python regex module to enter a case of catastrophic backtracking
which causes oscillation between states and hangs the checkpatch
script.

One suggested solution to these cases is to use an anchor[1] in
the regex, which should force the backtrack to exit early.
However, when I tested this, it didn't seem to improve anything
(since the start is already anchored, and trying to anchor the
end results in the same hang).

Instead, we explicitly check that the line ends with '\\' before
trying to match on the 'if-inside-a-macro' check.  A new check
is added to catch the case in checkpatch.

0: https://mail.openvswitch.org/pipermail/ovs-dev/2021-August/386881.html
1: https://stackoverflow.com/questions/22072406/preventing-any-backtracking-in-regex-past-a-specific-pattern

Signed-off-by: Aaron Conole <aconole at redhat.com>
Signed-off-by: Ilya Maximets <i.maximets at ovn.org>




More information about the git mailing list