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: <CAO+b5-q0dVQUVLgo3VosAjNWHYNCf=xv8_qcCjBfYuhVh9RT9Q@mail.gmail.com>
Date:	Thu, 25 Aug 2011 19:42:19 +0200
From:	Bart Van Assche <bvanassche@....org>
To:	Jason Baron <jbaron@...hat.com>
Cc:	gregkh@...e.de, joe@...ches.com, jim.cromie@...il.com,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/4] dynamic_debug: use a single printk() to emit msgs

On Thu, Aug 25, 2011 at 7:34 PM, Jason Baron <jbaron@...hat.com> wrote:
> -static int dynamic_emit_prefix(const struct _ddebug *descriptor)
> +#define PREFIX_SIZE 64
> +#define LEFT(wrote) ((PREFIX_SIZE - wrote) > 0) ? (PREFIX_SIZE - wrote) : 0
> +
> +static char *dynamic_emit_prefix(const struct _ddebug *desc, char *buf)
>  {
> -       char tid[sizeof(int) + sizeof(int)/2 + 4];
> -       char lineno[sizeof(int) + sizeof(int)/2];
> +       int pos = 0;
>
> -       if (descriptor->flags & _DPRINTK_FLAGS_INCL_TID) {
> +       pos += snprintf(buf + pos, LEFT(pos), "%s", KERN_DEBUG);
> +       if (desc->flags & _DPRINTK_FLAGS_INCL_TID) {
>                if (in_interrupt())
> -                       snprintf(tid, sizeof(tid), "%s", "<intr> ");
> +                       pos += snprintf(buf + pos, LEFT(pos), "%s ",
> +                                               "<intr>");
>                else
> -                       snprintf(tid, sizeof(tid), "[%d] ",
> -                                task_pid_vnr(current));
> -       } else {
> -               tid[0] = 0;
> +                       pos += snprintf(buf + pos, LEFT(pos), "[%d] ",
> +                                               task_pid_vnr(current));
>        }
> +       if (desc->flags & _DPRINTK_FLAGS_INCL_MODNAME)
> +               pos += snprintf(buf + pos, LEFT(pos), "%s:", desc->modname);
> +       if (desc->flags & _DPRINTK_FLAGS_INCL_FUNCNAME)
> +               pos += snprintf(buf + pos, LEFT(pos), "%s:", desc->function);
> +       if (desc->flags & _DPRINTK_FLAGS_INCL_LINENO)
> +               pos += snprintf(buf + pos, LEFT(pos), "%d ", desc->lineno);
>
> -       if (descriptor->flags & _DPRINTK_FLAGS_INCL_LINENO)
> -               snprintf(lineno, sizeof(lineno), "%d", descriptor->lineno);
> -       else
> -               lineno[0] = 0;
> -
> -       return printk(KERN_DEBUG "%s%s%s%s%s%s",
> -                     tid,
> -                     (descriptor->flags & _DPRINTK_FLAGS_INCL_MODNAME) ?
> -                     descriptor->modname : "",
> -                     (descriptor->flags & _DPRINTK_FLAGS_INCL_MODNAME) ?
> -                     ":" : "",
> -                     (descriptor->flags & _DPRINTK_FLAGS_INCL_FUNCNAME) ?
> -                     descriptor->function : "",
> -                     (descriptor->flags & _DPRINTK_FLAGS_INCL_FUNCNAME) ?
> -                     ":" : "",
> -                     lineno);
> +       return buf;
>  }

Shouldn't the new implementation guarantee that buf[] is
'\0'-terminated if pos >= PREFIX_SIZE ?

Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ