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] [day] [month] [year] [list]
Message-ID: <CAK7LNAQ2APK-4T+9wmS=ELT11hqCYgh9w=tcMpaPFxttKMOsBQ@mail.gmail.com>
Date: Wed, 20 Nov 2024 11:37:22 +0900
From: Masahiro Yamada <masahiroy@...nel.org>
To: linux-kbuild@...r.kernel.org
Cc: Nathan Chancellor <nathan@...nel.org>, Nicolas Schier <nicolas@...sle.eu>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 03/15] modpost: introduce module_alias_printf() helper

On Wed, Nov 20, 2024 at 8:57 AM Masahiro Yamada <masahiroy@...nel.org> wrote:
>
> The generic ->do_entry() handler is currently limited to returning
> a single alias string.
>
> However, this is not flexible enough for several subsystems, which
> currently require their own implementations:
>
>  - do_usb_table()
>  - do_of_table()
>  - do_pnp_device_entry()
>  - do_pnp_card_entries()
>
> This commit introduces a helper function so that these special cases can
> add multiple MODULE_ALIAS() and then migrate to the generic framework.
>
> Signed-off-by: Masahiro Yamada <masahiroy@...nel.org>
> ---
>
>  scripts/mod/file2alias.c | 89 +++++++++++++++++++++++++++++-----------
>  scripts/mod/modpost.c    | 11 ++++-
>  scripts/mod/modpost.h    | 19 ++++++++-
>  3 files changed, 91 insertions(+), 28 deletions(-)
>
> diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
> index 34678ed40fdb..e31619cee05e 100644
> --- a/scripts/mod/file2alias.c
> +++ b/scripts/mod/file2alias.c
> @@ -10,6 +10,12 @@
>   * of the GNU General Public License, incorporated herein by reference.
>   */
>
> +#include <stdarg.h>
> +#include <stdio.h>
> +
> +#include "list.h"
> +#include "xalloc.h"
> +
>  #include "modpost.h"
>  #include "devicetable-offsets.h"
>
> @@ -31,6 +37,56 @@ typedef Elf64_Addr   kernel_ulong_t;
>  #include <ctype.h>
>  #include <stdbool.h>
>
> +/**
> + * module_alias_printf - add auto-generated MODULE_ALIAS()
> + *
> + * @mod: module
> + * @append_wildcard: append '*' for future extension if not exist yet
> + * @fmt: printf(3)-like format
> + */
> +static void __attribute__((format (printf, 3, 4)))
> +module_alias_printf(struct module *mod, bool append_wildcard,
> +                   const char *fmt, ...)
> +{
> +       struct module_alias *new;
> +       size_t len, n;
> +       va_list ap;
> +
> +       /* Determine required size. */
> +       va_start(ap, fmt);
> +       n = vsnprintf(NULL, 0, fmt, ap);
> +       va_end(ap);
> +
> +       if (n < 0) {
> +               error("vsnprintf failed\n");
> +               return;
> +       }
> +
> +       len = n + 1;    /* extra byte for '\0' */
> +
> +       if (append_wildcard)
> +               len++;  /* extra byte for '*' */
> +
> +       new = xmalloc(sizeof(*new) + len);
> +
> +       /* Now, really print it to the allocated buffer */
> +       va_start(ap, fmt);
> +       n = vsnprintf(new->str, len, fmt, ap);
> +       va_end(ap);
> +
> +       if (n < 0) {
> +               error("vsnprintf failed\n");
> +               return;


This is a memory leak bug.
I will add free() here.

        if (n < 0) {
                error("vsnprintf failed\n");
+               free(new);
                return;
        }




-- 
Best Regards
Masahiro Yamada

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ