Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp613087imm; Wed, 10 Oct 2018 01:11:43 -0700 (PDT) X-Google-Smtp-Source: ACcGV60CM/hFjGWeNsJH24NKLz9un2iulBmcWBt2zzurd4QH7RM34NU3Rkztc7Hxy47gZ5OOD1Ek X-Received: by 2002:a63:1e15:: with SMTP id e21-v6mr29045230pge.430.1539159103065; Wed, 10 Oct 2018 01:11:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539159103; cv=none; d=google.com; s=arc-20160816; b=0fsKuBCinZGnr1STTrQRsC9/YAunpMhW+Q4iELiC7JlrloEmZ9HObu5HnN6gvyfbgC pVCdopvbI93gHoYHKVWezOpA8D+0AjGjnIGP7bQO3H/fiWysIIxmxiN8cdXXtx4Wec1Z 3Lt/02exiuH06/tSJjCSJGQz0hZoF30781Z+cAupLBtJSuxPMfA4WmqNBHHFqeSV8MO+ M2qecwGIdki/czZxNLzZBFw+4yM2oOPy9rlHX4WsW1IAiHE+POdZyzM8KLiReAVSAINc I31Q5LqkVnj0wNS/qzRIT7Df4vc51W8I5gRbT+BHqd/tUEqI3s93Nuzrwk0GdVlZQpiF 5h4g== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=PS25k5/w1bD6u4RqGpUXDB5RBNlx7ndpgB2K7BGxors=; b=FWIlvHkJyZ+ZMtdbG2INajNB9ei9ALYkeTf9NuyhNdx9rb98eZppQBtezirzlulHoj HtZX8saXxgr6qC+oj8s0/9L/dEqbiJKn5H+NTg2fzvy96p8UT3dpcHfSLx+5Uf4hVotv ovIsM7OI4UFdRqPD7tk+UL9ejlBihZwBYLwbDequkQkVrs+c/ksFFAgpIDnvwyN1n+jA 1qALErm2qwNEWXs/HTD8saK5TQXuFN3jj3d22YnX0cI8h4bWT4lgD1aMbhSCzAbOylFL RktnE94srdg6+Yz6y3tPoma3SkrH9SwdIKQfwQQNjq95V4EM5uwXI5srNo33YA+6IfZH 8DWw== 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 w11-v6si22348434pgf.587.2018.10.10.01.11.28; Wed, 10 Oct 2018 01:11:43 -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 S1726966AbeJJPaf (ORCPT + 99 others); Wed, 10 Oct 2018 11:30:35 -0400 Received: from mx2.suse.de ([195.135.220.15]:38220 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725837AbeJJPae (ORCPT ); Wed, 10 Oct 2018 11:30:34 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 4BFF9AFDA; Wed, 10 Oct 2018 08:09:33 +0000 (UTC) Date: Wed, 10 Oct 2018 10:09:32 +0200 From: Petr Mladek To: Sergey Senozhatsky Cc: 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 Message-ID: <20181010080932.h6nln2qsgg4oef4l@pathway.suse.cz> References: <1538239553-81805-1-git-send-email-zhe.he@windriver.com> <1538239553-81805-4-git-send-email-zhe.he@windriver.com> <20181008135916.gg4kkmoki5bgtco5@pathway.suse.cz> <20181008145950.GA1473@tigerII.localdomain> <20181009130538.7rtd3du2d7l6m63w@pathway.suse.cz> <20181009135758.GA1419@tigerII.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181009135758.GA1419@tigerII.localdomain> 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 Tue 2018-10-09 22:57:58, Sergey Senozhatsky wrote: > On (10/09/18 15:05), Petr Mladek wrote: > > > > > > Yeah, I think we gonna have problems even with a 4G logbuf and a 32-bit > > > user-space doing syslog(int len). > > > > > > I agree on the "not motivated enough" part ;) > > > > OK, I have pushed an updated patch that has the limit 2GB > > into printk.git, for-4.20 branch. > > > > Note that it is slightly different than the yesterday's proposal. > > I made a mistake in testing and still compared with UNIT_MAX. > > > > The pushed version can be seen at > > https://git.kernel.org/pub/scm/linux/kernel/git/pmladek/printk.git/commit/?h=for-4.20&id=e6fe3e5b7d16e8f146a4ae7fe481bc6e97acde1e > > > --- > > > +#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. > > > + 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 Best Regards, Petr