From: He Zhe <zhe.he@windriver.com>
To: Petr Mladek <pmladek@suse.com>, Steven Rostedt <rostedt@goodmis.org>
Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
<sergey.senozhatsky@gmail.com>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 1/2] printk: Fix panic caused by passing log_buf_len to command line
Date: Sat, 22 Sep 2018 23:36:05 +0800 [thread overview]
Message-ID: <02b53bc1-3803-50b1-d07e-a7962f9e5688@windriver.com> (raw)
In-Reply-To: <20180921073753.mqayzofcofpmhiyu@pathway.suse.cz>
On 2018年09月21日 15:37, Petr Mladek wrote:
> On Thu 2018-09-20 12:30:56, Steven Rostedt wrote:
>> On Fri, 21 Sep 2018 00:16:50 +0800
>> He Zhe <zhe.he@windriver.com> wrote:
>>
>>> On 2018年09月19日 10:43, Steven Rostedt wrote:
>>>> On Wed, 19 Sep 2018 11:39:32 +0900
>>>> Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> wrote:
>>>>
>>>>> On (09/19/18 10:27), He Zhe wrote:
>>>>>> On 2018年09月19日 09:50, Sergey Senozhatsky wrote:
>>>>>>> On (09/19/18 01:17), zhe.he@windriver.com wrote:
>>>>>>>> @@ -1048,7 +1048,14 @@ static void __init log_buf_len_update(unsigned size)
>>>>>>>> /* save requested log_buf_len since it's too early to process it */
>>>>>>>> static int __init log_buf_len_setup(char *str)
>>>>>>>> {
>>>>>>>> - unsigned size = memparse(str, &str);
>>>>>>>> + unsigned size;
>>>>>>> unsigned int size;
>>>>>> This is in v1 but then Steven suggested that it should be split out
>>>>>> and only keep the pure fix part here.
>>>>> Ah, I see.
>>>>>
>>>>> Hmm... memparse() returns u64 value. A user *probably* can ask the kernel
>>>>> to allocate log_buf larger than 'unsigned int'.
>>>>>
>>>>> So may be I'd do two fixes here:
>>>>>
>>>>> First - switch to u64 size.
>>>>> Second - check for NULL str.
>>>>>
>>>>>
>>>>> Steven, Petr, what do you think?
>>>>>
>>>> I think I would switch it around. Check for NULL first, and then switch
>>>> to u64. It was always an int, do we need to backport converting it to
>>>> u64 to stable? The NULL check is a definite, the overflow of int
>>>> shouldn't crash anything.
>> Hi Zhe,
>>
>>> To switch to u64, several variables need to be adjusted to new type to aligned
>>> with new_log_buf_len. And currently new_log_buf_len is passed to
>>> memblock_virt_alloc(phys_addr_t, phys_addr_t). So we can't simply define
>>> new_log_buf_len as u64. We need to define it as phys_addr_t tomake it work
>>> well for both 32bit and 64bit arches, since a 32-bit architecture can set
>>> ARCH_PHYS_ADDR_T_64BIT if it needs a 64-bit phys_addr_t.
>> The above explanation verifies more that the NULL pointer check needs
>> to be first, and that the change in size should not be backported to
>> stable because it has a high risk to doing the change as compared to it
>> being a problem for older kernels.
> I agree that the NULL check should go first.
>
> I would personally keep the size as unsigned int. IMHO, a support
> for a log buffer bigger than 4GB is not worth the complexity.
Thank you, Petr, Steven and Sergey. I'll send v3 soon for the NULL check
and cast correction.
For 64 bit log buffer length, the variable changes should be OK. The main
obstacle might be that we need to modify the syscall below to make the
64 bit length returned back to user space. "error" is not long enough.
int do_syslog(int type, char __user *buf, int len, int source)
...
case SYSLOG_ACTION_SIZE_BUFFER:
error = log_buf_len;
break;
...
return error;
...
SYSCALL_DEFINE3(syslog, int, type, char __user *, buf, int, len)
{
return do_syslog(type, buf, len, SYSLOG_FROM_READER);
}
Besides, in terms of variable type alignment, there has already been a
similar problematic case in do_syslog as below. i.e. int = u64 - u64. It seems
this needs to be fixed.
int do_syslog(int type, char __user *buf, int len, int source)
...
case SYSLOG_ACTION_SIZE_UNREAD:
if (source == SYSLOG_FROM_PROC) {
error = log_next_seq - syslog_seq;
...
I'd like to fix the above issues. But can I have your opinions about how to
handle the syscall?
Thanks,
Zhe
>
> Best Regards,
> Petr
>
next prev parent reply other threads:[~2018-09-22 15:36 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-18 17:17 zhe.he
2018-09-18 17:17 ` [PATCH v2 2/2] printk: Add KBUILD_MODNAME and correct bare use of unsigned zhe.he
2018-09-19 2:06 ` Sergey Senozhatsky
2018-09-19 11:20 ` Petr Mladek
2018-09-19 1:50 ` [PATCH v2 1/2] printk: Fix panic caused by passing log_buf_len to command line Sergey Senozhatsky
2018-09-19 2:27 ` He Zhe
2018-09-19 2:39 ` Sergey Senozhatsky
2018-09-19 2:43 ` Steven Rostedt
2018-09-19 2:47 ` Sergey Senozhatsky
2018-09-19 3:05 ` Steven Rostedt
2018-09-20 16:16 ` He Zhe
2018-09-20 16:30 ` Steven Rostedt
2018-09-21 7:37 ` Petr Mladek
2018-09-22 15:36 ` He Zhe [this message]
2018-09-25 12:16 ` Sergey Senozhatsky
2018-09-25 12:01 ` Sergey Senozhatsky
2018-09-25 12:23 ` Petr Mladek
2018-09-25 12:37 ` Sergey Senozhatsky
2018-09-25 13:31 ` Sergey Senozhatsky
2018-09-25 15:31 ` He Zhe
2018-09-26 11:05 ` Petr Mladek
2018-09-28 7:35 ` Sergey Senozhatsky
2018-09-28 8:22 ` He Zhe
2018-09-19 6:44 ` Sergey Senozhatsky
2018-09-19 10:09 ` He Zhe
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=02b53bc1-3803-50b1-d07e-a7962f9e5688@windriver.com \
--to=zhe.he@windriver.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=sergey.senozhatsky.work@gmail.com \
--cc=sergey.senozhatsky@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®