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] [day] [month] [year] [list]
Message-ID: <20200211130505.2lj2fm6nslbwgmg6@pathway.suse.cz>
Date:   Tue, 11 Feb 2020 14:05:05 +0100
From:   Petr Mladek <pmladek@...e.com>
To:     Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>
Cc:     Nathan Chancellor <natechancellor@...il.com>,
        Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
        Steven Rostedt <rostedt@...dmis.org>,
        linux-kernel@...r.kernel.org, clang-built-linux@...glegroups.com
Subject: Re: [PATCH] printk: Convert a use of sprintf to snprintf in
 console_unlock

On Fri 2020-01-31 16:02:37, Sergey Senozhatsky wrote:
> On (20/01/30 15:16), Nathan Chancellor wrote:
> > When CONFIG_PRINTK is disabled (e.g. when building allnoconfig), clang
> > warns:
> > 
> > ../kernel/printk/printk.c:2416:10: warning: 'sprintf' will always
> > overflow; destination buffer has size 0, but format string expands to at
> > least 33 [-Wfortify-source]
> >                         len = sprintf(text,
> >                               ^
> > 1 warning generated.
> > 
> > It is not wrong; text has a zero size when CONFIG_PRINTK is disabled
> > because LOG_LINE_MAX and PREFIX_MAX are both zero. Change to snprintf so
> > that this case is explicitly handled without any risk of overflow.
> 
> We probably can add a note here that for !CONFIG_PRINTK builds
> logbuf overflow is very unlikely.

Good point. Well, the sprintf() was used for a well defined string:
"** %llu printk messages dropped **\n" ""

It could overflow only when anyone modified LOG_LINE_MAX to
something really small. It was not the case upstream, definitely.

> Otherwise,
> Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@...il.com>

The patch has been committed into printk.git, branch for-5.7.

I did not add any extra comment to keep it simple. I hope
that it is ok.

Best Regards,
Petr

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ