All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
To: Petr Mladek <pmladek@suse.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
	zhe.he@windriver.com, rostedt@goodmis.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 4/4] printk: Give error on attempt to set log buffer length to over 4G
Date: Wed, 10 Oct 2018 17:21:29 +0900	[thread overview]
Message-ID: <20181010082129.GA631@jagdpanzerIV> (raw)
In-Reply-To: <20181010080932.h6nln2qsgg4oef4l@pathway.suse.cz>

On (10/10/18 10:09), Petr Mladek wrote:
> > > +#define LOG_BUF_LEN_MAX (u32)(1 << 31)
> > [..]
> > > +	if (size > (u64)LOG_BUF_LEN_MAX) {
> > > +		size = (u64)LOG_BUF_LEN_MAX;
> > > +		pr_err("log_buf over 2G is not supported.\n");
> > > +	}
> > 
> > Why not INT_MAX?
> 
> INT_MAX is 0x7fffffff but we need 0x80000000. I did not find
> any predefined macro.

Hmm, OK. I need to think about it more.

> > > +	pr_info("log_buf_len: %u bytes\n", log_buf_len);
> > > +	pr_info("early log buf free: %u(%u%%)\n",
> > >  		free, (free * 100) / __LOG_BUF_LEN);
> > 
> > Can 'free * 100' overflow?
> 
> Good question. It uses the size of the static buffer. If I count
> correctly then we are on the safe side because LOG_BUF_SHIFT
> is limited by
> 
> 	range 12 25

I didn't know there was Kconfig "range" :)

$ echo $(((1<<25)*100))
3355443200

	-ss

  reply	other threads:[~2018-10-10  8:21 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-29 16:45 [PATCH v5 1/4] printk: Fix panic caused by passing log_buf_len to command line zhe.he
2018-09-29 16:45 ` [PATCH v5 2/4] printk: Correct wrong casting zhe.he
2018-10-02  5:50   ` Sergey Senozhatsky
2018-10-08 13:03     ` Petr Mladek
2018-09-29 16:45 ` [PATCH v5 3/4] printk: Add KBUILD_MODNAME and remove a redundant print prefix zhe.he
2018-10-02  5:52   ` Sergey Senozhatsky
2018-10-08 13:04   ` Petr Mladek
2018-09-29 16:45 ` [PATCH v5 4/4] printk: Give error on attempt to set log buffer length to over 4G zhe.he
2018-10-02  5:51   ` Sergey Senozhatsky
2018-10-08 13:59   ` Petr Mladek
2018-10-08 14:59     ` Sergey Senozhatsky
2018-10-09 13:05       ` Petr Mladek
2018-10-09 13:57         ` Sergey Senozhatsky
2018-10-10  8:09           ` Petr Mladek
2018-10-10  8:21             ` Sergey Senozhatsky [this message]
2018-10-08 16:30     ` He Zhe
2018-10-02  5:48 ` [PATCH v5 1/4] printk: Fix panic caused by passing log_buf_len to command line Sergey Senozhatsky
2018-10-08 13:01 ` Petr Mladek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181010082129.GA631@jagdpanzerIV \
    --to=sergey.senozhatsky.work@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=sergey.senozhatsky@gmail.com \
    --cc=zhe.he@windriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.