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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANn89iLP_7YTPMXb99zpNV0M27DUkK2-bY30_-gm2woU7jKPqQ@mail.gmail.com>
Date:   Wed, 1 Dec 2021 19:31:04 -0800
From:   Eric Dumazet <edumazet@...gle.com>
To:     Eric Dumazet <eric.dumazet@...il.com>
Cc:     "David S . Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        netdev <netdev@...r.kernel.org>,
        Dmitry Vyukov <dvyukov@...gle.com>
Subject: Re: [PATCH net-next 02/19] lib: add tests for reference tracker

On Wed, Dec 1, 2021 at 7:21 PM Eric Dumazet <eric.dumazet@...il.com> wrote:
>
> From: Eric Dumazet <edumazet@...gle.com>
>
> This module uses reference tracker, forcing two issues.
>
> 1) Double free of a tracker
>
> 2) leak of two trackers, one being allocated from softirq context.
>
> "modprobe test_ref_tracker" would emit the following traces.
> (Use scripts/decode_stacktrace.sh if necessary)
>
> [

> Signed-off-by: Eric Dumazet <edumazet@...gle.com>
> ---
>  lib/Kconfig.debug      |  10 ++++
>  lib/Makefile           |   2 +-
>  lib/test_ref_tracker.c | 116 +++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 127 insertions(+), 1 deletion(-)
>  create mode 100644 lib/test_ref_tracker.c
>
> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> index 5c12bde10996cf97b5f075d318089b1be73f71d7..d005f555872147e15d3e0a65d2a03e1a5c44f5f0 100644
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -2106,6 +2106,16 @@ config BACKTRACE_SELF_TEST
>
>           Say N if you are unsure.
>
> +config TEST_REF_TRACKER
> +       tristate "Self test for reference tracker"
> +       depends on DEBUG_KERNEL
> +       select REF_TRACKER
> +       help
> +         This option provides a kernel module performing tests
> +         using reference tracker infrastructure.
> +
> +         Say N if you are unsure.
> +
>  config RBTREE_TEST
>         tristate "Red-Black tree test"
>         depends on DEBUG_KERNEL
> diff --git a/lib/Makefile b/lib/Makefile
> index c1fd9243ddb9cc1ac5252d7eb8009f9290782c4a..b213a7bbf3fda2eb9f234fb7473b8f1b617bed6b 100644
> --- a/lib/Makefile
> +++ b/lib/Makefile
> @@ -101,7 +101,7 @@ obj-$(CONFIG_TEST_LOCKUP) += test_lockup.o
>  obj-$(CONFIG_TEST_HMM) += test_hmm.o
>  obj-$(CONFIG_TEST_FREE_PAGES) += test_free_pages.o
>  obj-$(CONFIG_KPROBES_SANITY_TEST) += test_kprobes.o
> -
> +obj-$(CONFIG_TEST_REF_TRACKER) += test_ref_tracker.o
>  #
>  # CFLAGS for compiling floating point code inside the kernel. x86/Makefile turns
>  # off the generation of FPU/SSE* instructions for kernel proper but FPU_FLAGS
> diff --git a/lib/test_ref_tracker.c b/lib/test_ref_tracker.c
> new file mode 100644
> index 0000000000000000000000000000000000000000..73bf9255e03790fa50491fe8e5cd411d54827c45
> --- /dev/null
> +++ b/lib/test_ref_tracker.c
> @@ -0,0 +1,116 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Referrence tracker self test.
> + *
> + * Copyright (c) 2021 Eric Dumazet <edumazet@...gle.com>
> + */
> +#include <linux/init.h>
> +#include <linux/module.h>
> +#include <linux/delay.h>
> +#include <linux/ref_tracker.h>
> +#include <linux/slab.h>
> +#include <linux/timer.h>
> +
> +static struct ref_tracker_dir ref_dir;
> +static struct ref_tracker *tracker[20];
> +
> +#define TRT_ALLOC(X) static noinline void                                      \
> +       alloctest_ref_tracker_alloc##X(struct ref_tracker_dir *dir,     \
> +                                   struct ref_tracker **trackerp)      \
> +       {                                                               \
> +               ref_tracker_alloc(dir, trackerp, GFP_KERNEL);           \
> +       }
> +
> +TRT_ALLOC(0)
> +TRT_ALLOC(1)
> +TRT_ALLOC(2)
> +TRT_ALLOC(3)
> +TRT_ALLOC(4)
> +TRT_ALLOC(5)
> +TRT_ALLOC(6)
> +TRT_ALLOC(7)
> +TRT_ALLOC(8)
> +TRT_ALLOC(9)
> +TRT_ALLOC(10)
> +TRT_ALLOC(11)
> +TRT_ALLOC(12)
> +TRT_ALLOC(13)
> +TRT_ALLOC(14)
> +TRT_ALLOC(15)
> +TRT_ALLOC(16)
> +TRT_ALLOC(17)
> +TRT_ALLOC(18)
> +TRT_ALLOC(19)
> +
> +#undef TRT_ALLOC
> +
> +static noinline void
> +alloctest_ref_tracker_free(struct ref_tracker_dir *dir,
> +                          struct ref_tracker **trackerp)
> +{
> +       ref_tracker_free(dir, trackerp);
> +}
> +
> +
> +static struct timer_list test_ref_tracker_timer;
> +static atomic_t test_ref_timer_done = ATOMIC_INIT(0);
> +
> +static void test_ref_tracker_timer_func(struct timer_list *t)
> +{
> +       alloctest_ref_tracker_alloc0(&ref_dir, &tracker[0]);

This will be changed to use GFP_ATOMIC instead of GFP_KERNEL

          ref_tracker_alloc(&ref_dir, ..., GFP_ATOMIC);

> +       atomic_set(&test_ref_timer_done, 1);
> +}
> +
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ