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: <87fr9uy6oq.fsf@nvidia.com>
Date: Mon, 1 Dec 2025 08:57:24 +0100
From: Petr Machata <petrm@...dia.com>
To: Jakub Kicinski <kuba@...nel.org>
CC: <davem@...emloft.net>, <netdev@...r.kernel.org>, <edumazet@...gle.com>,
	<pabeni@...hat.com>, <andrew+netdev@...n.ch>, <horms@...nel.org>,
	<shuah@...nel.org>, <willemb@...gle.com>, <petrm@...dia.com>,
	<linux-kselftest@...r.kernel.org>
Subject: Re: [PATCH net-next] selftests: net: py: handle interrupt during
 cleanup


Jakub Kicinski <kuba@...nel.org> writes:

> Following up on the old discussion [1]. Let the BaseExceptions out of
> defer()'ed cleanup. And handle it in the main loop. This allows us to
> exit the tests if user hit Ctrl-C during defer().
>
> Link: https://lore.kernel.org/20251119063228.3adfd743@kernel.org # [1]
> Signed-off-by: Jakub Kicinski <kuba@...nel.org>
> ---
> CC: shuah@...nel.org
> CC: willemb@...gle.com
> CC: petrm@...dia.com
> CC: linux-kselftest@...r.kernel.org
> ---
>  tools/testing/selftests/net/lib/py/ksft.py | 18 ++++++++++++++++--
>  1 file changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/net/lib/py/ksft.py b/tools/testing/selftests/net/lib/py/ksft.py
> index ebd82940ee50..531e7fa1b3ea 100644
> --- a/tools/testing/selftests/net/lib/py/ksft.py
> +++ b/tools/testing/selftests/net/lib/py/ksft.py
> @@ -163,7 +163,7 @@ KSFT_DISRUPTIVE = True
>          entry = global_defer_queue.pop()
>          try:
>              entry.exec_only()
> -        except BaseException:
> +        except Exception:
>              ksft_pr(f"Exception while handling defer / cleanup (callback {i} of {qlen_start})!")
>              tb = traceback.format_exc()
>              for line in tb.strip().split('\n'):
> @@ -333,7 +333,21 @@ KsftCaseFunction = namedtuple("KsftCaseFunction",
>              KSFT_RESULT = False
>              cnt_key = 'fail'
>  
> -        ksft_flush_defer()
> +        try:
> +            ksft_flush_defer()
> +        except BaseException as e:
> +            tb = traceback.format_exc()
> +            for line in tb.strip().split('\n'):
> +                ksft_pr("Exception|", line)
> +            if isinstance(e, KeyboardInterrupt):
> +                ksft_pr()
> +                ksft_pr("WARN: defer() interrupted, cleanup may be incomplete.")
> +                ksft_pr("      Attempting to finish cleanup before exiting.")
> +                ksft_pr("      Interrupt again to exit immediately.")
> +                ksft_pr()
> +                stop = True
> +            # Flush was interrupted, try to finish the job best we can
> +            ksft_flush_defer()
>  
>          if not cnt_key:
>              cnt_key = 'pass' if KSFT_RESULT else 'fail'

Nice.

Reviewed-by: Petr Machata <petrm@...dia.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ