Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp331577imm; Fri, 21 Sep 2018 00:38:27 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYDEPSdh+OPChuchAh9F0jHKSQfbO065Cpi0zedQxfE1unj/Jth/JBqiGpjytN23o3o0ZXl X-Received: by 2002:a63:ca09:: with SMTP id n9-v6mr39997904pgi.287.1537515507867; Fri, 21 Sep 2018 00:38:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537515507; cv=none; d=google.com; s=arc-20160816; b=wRVCKiH5IgxaM9meOS410BVPdC92oiiQuSwYJe+XAKcQdtjOzdoDdjWAq2JFk+J8Re bHl0FS4+13IRieVBTZuFRPw5lFJp7UFk3FkqcMfJiaWEiGD037+/fG9pslgCGNBcbo0x 4VGRbX8SxFYmYHhyU55c/VFngXPiM4f57h1BHk6diCZUKIFrS2HDzid9gyXJxZoiG6Qq vF9H5HBaS5m6/fkigsfCM5Z4q+K9tSS+/QLSj/uwJvncXgdvqmlMjN51RZCFWxaZ9xr3 rg8iGAJ8IrcX44HyT1IZEstKfHZ6v8tgxvfFU8c80bOKKi2M70Glg9sXqSHNbqd8xb1o pd9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=qPvBsENSCvVoJov7jqn3xVWLz0LdYbw5nwnyiaDfkIw=; b=lDmjNc3WsJxHBKNmGI00J+7hCUbjGoQa35ZIKxRsyNlu53eezSXsI9a8lUqjjqb1ss Hhwh9O/fudBmovHLZoSYVrJ3iXCYN8105+hmqABiRGtoVqoffCl7/JU/VMmHzxfynnCY ZxAVIj/4d0qRbmSwsMK9vDEwJ8OCr8/NKbxEB67drpPaL1Kgg+ANCNBRDrx2k0bvPTlJ 1pOScEtZdvEcA/l+dUoL3YhAfffgCj7Attntzwqi+ii/INGPpaQIwxLxMZcUrIoMvVYU wfYkLjbbf8kk4t0O3SRF3+76SrIDI4JH5mAhE1IiSgXRhRoObbbOdnZqNQVDqu0Je7+h Zlgw== 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 p187-v6si28810576pfp.27.2018.09.21.00.38.10; Fri, 21 Sep 2018 00:38:27 -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 S2389404AbeIUNZd (ORCPT + 99 others); Fri, 21 Sep 2018 09:25:33 -0400 Received: from mx2.suse.de ([195.135.220.15]:54226 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726479AbeIUNZd (ORCPT ); Fri, 21 Sep 2018 09:25:33 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 77188AF58; Fri, 21 Sep 2018 07:37:54 +0000 (UTC) Date: Fri, 21 Sep 2018 09:37:53 +0200 From: Petr Mladek To: Steven Rostedt Cc: He Zhe , Sergey Senozhatsky , 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 Message-ID: <20180921073753.mqayzofcofpmhiyu@pathway.suse.cz> 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> <1545bc85-b64a-4b45-d40f-79567ac621dc@windriver.com> <20180920123056.27b2cf18@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180920123056.27b2cf18@gandalf.local.home> User-Agent: NeoMutt/20170421 (1.8.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 2018-09-20 12:30:56, Steven Rostedt wrote: > On Fri, 21 Sep 2018 00:16:50 +0800 > He Zhe wrote: > > > 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. > > > > 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. Best Regards, Petr