Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2206381imm; Thu, 20 Sep 2018 09:19:05 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbUnkWKs3OO3gygutatY8s9JIcA6PQVqFSafij1zDmCfsc7jLV/2Z4GkuYVZB3C7FGqnPBj X-Received: by 2002:a62:642:: with SMTP id 63-v6mr42387313pfg.42.1537460345049; Thu, 20 Sep 2018 09:19:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537460345; cv=none; d=google.com; s=arc-20160816; b=clr/s+jP2UzHMQn7oDjHS8wF5POc4NcRWCRjqDF+9naw5Nn9ptcNJloB5rDEPNzgPF ZskHTWMRUCjgP75aKdJRSR/SZIN1oonjoyYjrN0nFjP+BKUciLKbY+c0+FRktnUAt4jK A1Re3Nuow3CDP9gvYRZkISsZ1DLOwjHgbFqMse7INO1tazTF37KWWlr9GQtrX6Es4M1I +q/Z1mJaqhVcHYaaotietYl7nUbDS6tAYLmEkPI1AId5N/KHZyxR2CF9rZ/9IDNtCqBK Brc/eCVRQeRdQjBhnG6l8xHcDuoW8Iy3DfIY6TWfRz6qwovkUCRXOZ3ArM8OJXJqTCIa OdRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=qyvWSZBcripNoCp4UUREndvc0BvHWICrG6ntuThFchg=; b=F65ENKOIqj7P4IUPiIx8IzQz9LS0rBW8mfrqP0IrDwROy9DNj0ZABmQ55n0Ata8ZWE c3sP21Nnfik0PZwxaJmvh/WgDiBIDe4Jd9Q7u+gyX/Z66S4WRl7japaAhvMiijxS1VIR 7KjY30n5dhOu49tdWwzH7TFsAP1HqH90wMbT3BPP4b5r4w8ZRPMxCDXki8LZp/tsihZv +OeJpugSnyNfMQwU10pv4XKdRA8fpSqm1oYTughqPShwJxL8IS40dCYsGMjldt48UZ6L i1Rcqx9jdJGTM2Gy/coKRUGw3tPlWlulLqcD0cMiENZnUgGedMW5+r25zcwumlGeulqZ aA/A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q23-v6si2206317pll.72.2018.09.20.09.18.44; Thu, 20 Sep 2018 09:19:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730950AbeITWCb (ORCPT + 99 others); Thu, 20 Sep 2018 18:02:31 -0400 Received: from mail5.windriver.com ([192.103.53.11]:47742 "EHLO mail5.wrs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726193AbeITWCb (ORCPT ); Thu, 20 Sep 2018 18:02:31 -0400 Received: from ALA-HCA.corp.ad.wrs.com (ala-hca.corp.ad.wrs.com [147.11.189.40]) by mail5.wrs.com (8.15.2/8.15.2) with ESMTPS id w8KGH4g4017154 (version=TLSv1 cipher=AES128-SHA bits=128 verify=FAIL); Thu, 20 Sep 2018 09:17:14 -0700 Received: from [128.224.162.216] (128.224.162.216) by ALA-HCA.corp.ad.wrs.com (147.11.189.50) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 20 Sep 2018 09:16:53 -0700 Subject: Re: [PATCH v2 1/2] printk: Fix panic caused by passing log_buf_len to command line To: Steven Rostedt , Sergey Senozhatsky CC: , , References: <1537291068-443145-1-git-send-email-zhe.he@windriver.com> <20180919015030.GA423@jagdpanzerIV> <6c354803-5341-7237-9ee3-7882252c7483@windriver.com> <20180919023932.GA14090@jagdpanzerIV> <20180918224312.6e9aef50@vmware.local.home> From: He Zhe Message-ID: <1545bc85-b64a-4b45-d40f-79567ac621dc@windriver.com> Date: Fri, 21 Sep 2018 00:16:50 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180918224312.6e9aef50@vmware.local.home> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Content-Language: en-US X-Originating-IP: [128.224.162.216] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018年09月19日 10:43, Steven Rostedt wrote: > On Wed, 19 Sep 2018 11:39:32 +0900 > Sergey Senozhatsky 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. 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. What do you think? #ifdef CONFIG_PHYS_ADDR_T_64BIT typedef u64 phys_addr_t; #else typedef u32 phys_addr_t; #endif Thanks, Zhe > -- Steve >