From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pingfan Liu Date: Fri, 24 May 2019 03:11:13 +0000 Subject: Re: [PATCHv2] kernel/crash: make parse_crashkernel()'s return value more indicant Message-Id: List-Id: References: <1556087581-14513-1-git-send-email-kernelfans@gmail.com> <10dc5468-6cd9-85c7-ba66-1dfa5aa922b7@suse.com> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Matthias Brugger Cc: Rich Felker , linux-ia64@vger.kernel.org, Julien Thierry , Yangtao Li , Benjamin Herrenschmidt , Palmer Dabbelt , Heiko Carstens , Stefan Agner , linux-mips@vger.kernel.org, Paul Mackerras , "H. Peter Anvin" , Thomas Gleixner , Logan Gunthorpe , linux-s390@vger.kernel.org, Florian Fainelli , Yoshinori Sato , linux-sh@vger.kernel.org, Michael Ellerman , x86@kernel.org, Russell King , Ingo Molnar , Hari Bathini , Catalin Marinas , James Hogan , Dave Young , Fenghua Yu , Will Deacon , Johannes Weiner , Ananth N Mavinakayanahalli , Borislav Petkov , David Hildenbrand , linux-arm-kernel@lists.infradead.org, Jens Axboe , Tony Luck , Baoquan He , Ard Biesheuvel , Robin Murphy , LKML , Ralf Baechle , Thomas Bogendoerfer , Paul Burton , Greg Kroah-Hartman , Martin Schwidefsky , Andrew Morton , linuxppc-dev@lists.ozlabs.org, Greg Hackmann Matthias, ping? Any suggestions? Thanks, Pingfan On Thu, May 2, 2019 at 2:22 PM Pingfan Liu wrote: > > On Thu, Apr 25, 2019 at 4:20 PM Pingfan Liu wrote: > > > > On Wed, Apr 24, 2019 at 4:31 PM Matthias Brugger wrote: > > > > > > > > [...] > > > > @@ -139,6 +141,8 @@ static int __init parse_crashkernel_simple(char *cmdline, > > > > pr_warn("crashkernel: unrecognized char: %c\n", *cur); > > > > return -EINVAL; > > > > } > > > > + if (*crash_size = 0) > > > > + return -EINVAL; > > > > > > This covers the case where I pass an argument like "crashkernel=0M" ? > > > Can't we fix that by using kstrtoull() in memparse and check if the return value > > > is < 0? In that case we could return without updating the retptr and we will be > > > fine. > After a series of work, I suddenly realized that it can not be done > like this way. "0M" causes kstrtoull() to return -EINVAL, but this is > caused by "M", not "0". If passing "0" to kstrtoull(), it will return > 0 on success. > > > > > > It seems that kstrtoull() treats 0M as invalid parameter, while > > simple_strtoull() does not. > > > My careless going through the code. And I tested with a valid value > "256M" using kstrtoull(), it also returned -EINVAL. > > So I think there is no way to distinguish 0 from a positive value > inside this basic math function. > Do I miss anything? > > Thanks and regards, > Pingfan From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3A08C282E1 for ; Fri, 24 May 2019 03:11:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9617721773 for ; Fri, 24 May 2019 03:11:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="a7Sc0Zml" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388744AbfEXDL2 (ORCPT ); Thu, 23 May 2019 23:11:28 -0400 Received: from mail-it1-f194.google.com ([209.85.166.194]:39143 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387559AbfEXDL1 (ORCPT ); Thu, 23 May 2019 23:11:27 -0400 Received: by mail-it1-f194.google.com with SMTP id 9so11694522itf.4; Thu, 23 May 2019 20:11:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=E7hznSwoqjG8X1odMBGc2satoFe87v1Y0P/9fKHS9SY=; b=a7Sc0ZmlEG6jC7OpcrRVUkNXq0SBb3Dc/hNdk5Vi6ayUDLd0Dm8M0wWvJFgwttZZ4M aninTKfSUZDRjfNGqPsMzWLja++EezX/hO4fX5nJBzfyFI6kNO7dvjypaoVQz4ys7+R5 9IVPBxW1C4i6BRZ4f3bqLocvJh1c9QUTPILj4gipCVXMgVTUpT9LBYkMiRDL2TaalXNe rQ6wJugIty6JwVWYs5nF97JpvrTENcxT3PWNqVTqRhEna4JwxQokvn2SUzkeP09LHMDC DgccA6RcG2CmDNt2DoIHjZymnDK30hw9WxWvnBoApiNxfRbL6LLAu65RJr1Ih71O/P5e SodQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=E7hznSwoqjG8X1odMBGc2satoFe87v1Y0P/9fKHS9SY=; b=Ezz2Tgeoxjdv/gvVJ/MA5BphhJp0ROY7eGuEAPB34pjOfZ9Qhjq2ttOZI492SrJqID oYb+trVWohcEsTTnuvrXvqhM9++ob+KDmqye9lu5WGczS9UEq2zlUGooX0bFUTQ7eDNO 73TpY8KHHy+M7pkUnZ7s50p4JClZ/FVH+/BnIUFnJHG2PFE26yzI5AaPHTyZc6iITSaB nqFqf1RuwcGj8pV4vQ7v0OO0m5cntojFaB/EJT2diuKOwc2KO87DKUsVqyDu/xj3efNO jRbywuuPXIY3ktLzuRoSCd49qjhz+CSclAPfHslijAnC/ldpKQ38cq/SakMisXgIe5f4 /CnQ== X-Gm-Message-State: APjAAAU/nXJChSYn3/OkCY5jM66bpCt/c1PazWN/OjkBlJQ/qjpoKeug A1Ap6yIXeByCvDlPB2sRDwiDyk7343xDzT5OICXlSzV8sA== X-Google-Smtp-Source: APXvYqz4ssg3ircx9GKZ/bOQFSdzkDIVdQtquf3WB1GzGhZLWMOO7FDaVjBjQGy32wO2lRBtVYsHwdCKMGdQi1fBKFw= X-Received: by 2002:a24:1dce:: with SMTP id 197mr16766439itj.16.1558667486023; Thu, 23 May 2019 20:11:26 -0700 (PDT) MIME-Version: 1.0 References: <1556087581-14513-1-git-send-email-kernelfans@gmail.com> <10dc5468-6cd9-85c7-ba66-1dfa5aa922b7@suse.com> In-Reply-To: From: Pingfan Liu Date: Fri, 24 May 2019 11:11:13 +0800 Message-ID: Subject: Re: [PATCHv2] kernel/crash: make parse_crashkernel()'s return value more indicant To: Matthias Brugger Cc: LKML , Rich Felker , linux-ia64@vger.kernel.org, Julien Thierry , Yangtao Li , Benjamin Herrenschmidt , Palmer Dabbelt , Heiko Carstens , x86@kernel.org, linux-mips@vger.kernel.org, Paul Mackerras , "H. Peter Anvin" , linux-s390@vger.kernel.org, Florian Fainelli , Yoshinori Sato , linux-sh@vger.kernel.org, Michael Ellerman , David Hildenbrand , Russell King , Ingo Molnar , linux-arm-kernel@lists.infradead.org, Catalin Marinas , James Hogan , Dave Young , Fenghua Yu , Will Deacon , linuxppc-dev@lists.ozlabs.org, Ananth N Mavinakayanahalli , Borislav Petkov , Stefan Agner , Thomas Gleixner , Hari Bathini , Jens Axboe , Tony Luck , Baoquan He , Ard Biesheuvel , Robin Murphy , Greg Kroah-Hartman , Ralf Baechle , Thomas Bogendoerfer , Paul Burton , Johannes Weiner , Martin Schwidefsky , Andrew Morton , Logan Gunthorpe , Greg Hackmann Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Matthias, ping? Any suggestions? Thanks, Pingfan On Thu, May 2, 2019 at 2:22 PM Pingfan Liu wrote: > > On Thu, Apr 25, 2019 at 4:20 PM Pingfan Liu wrote: > > > > On Wed, Apr 24, 2019 at 4:31 PM Matthias Brugger wrote: > > > > > > > > [...] > > > > @@ -139,6 +141,8 @@ static int __init parse_crashkernel_simple(char *cmdline, > > > > pr_warn("crashkernel: unrecognized char: %c\n", *cur); > > > > return -EINVAL; > > > > } > > > > + if (*crash_size == 0) > > > > + return -EINVAL; > > > > > > This covers the case where I pass an argument like "crashkernel=0M" ? > > > Can't we fix that by using kstrtoull() in memparse and check if the return value > > > is < 0? In that case we could return without updating the retptr and we will be > > > fine. > After a series of work, I suddenly realized that it can not be done > like this way. "0M" causes kstrtoull() to return -EINVAL, but this is > caused by "M", not "0". If passing "0" to kstrtoull(), it will return > 0 on success. > > > > > > It seems that kstrtoull() treats 0M as invalid parameter, while > > simple_strtoull() does not. > > > My careless going through the code. And I tested with a valid value > "256M" using kstrtoull(), it also returned -EINVAL. > > So I think there is no way to distinguish 0 from a positive value > inside this basic math function. > Do I miss anything? > > Thanks and regards, > Pingfan From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: MIME-Version: 1.0 References: <1556087581-14513-1-git-send-email-kernelfans@gmail.com> <10dc5468-6cd9-85c7-ba66-1dfa5aa922b7@suse.com> In-Reply-To: From: Pingfan Liu Date: Fri, 24 May 2019 11:11:13 +0800 Message-ID: Subject: Re: [PATCHv2] kernel/crash: make parse_crashkernel()'s return value more indicant List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org List-Archive: To: Matthias Brugger Cc: Rich Felker , linux-ia64@vger.kernel.org, Julien Thierry , Yangtao Li , Benjamin Herrenschmidt , Palmer Dabbelt , Heiko Carstens , Stefan Agner , linux-mips@vger.kernel.org, Paul Mackerras , "H. Peter Anvin" , Thomas Gleixner , Logan Gunthorpe , linux-s390@vger.kernel.org, Florian Fainelli , Yoshinori Sato , linux-sh@vger.kernel.org, Michael Ellerman , x86@kernel.org, Russell King , Ingo Molnar , Hari Bathini , Catalin Marinas , James Hogan , Dave Young , Fenghua Yu , Will Deacon , Johannes Weiner , Ananth N Mavinakayanahalli , Borislav Petkov , David Hildenbrand , linux-arm-kernel@lists.infradead.org, Jens Axboe , Tony Luck , Baoquan He , Ard Biesheuvel , Robin Murphy , LKML , Ralf Baechle , Thomas Bogendoerfer , Paul Burton , Greg Kroah-Hartman , Martin Schwidefsky , Andrew Morton , linuxppc-dev@lists.ozlabs.org, Greg Hackmann List-ID: Matthias, ping? Any suggestions? Thanks, Pingfan On Thu, May 2, 2019 at 2:22 PM Pingfan Liu wrote: > > On Thu, Apr 25, 2019 at 4:20 PM Pingfan Liu wrote: > > > > On Wed, Apr 24, 2019 at 4:31 PM Matthias Brugger wrote: > > > > > > > > [...] > > > > @@ -139,6 +141,8 @@ static int __init parse_crashkernel_simple(char *cmdline, > > > > pr_warn("crashkernel: unrecognized char: %c\n", *cur); > > > > return -EINVAL; > > > > } > > > > + if (*crash_size == 0) > > > > + return -EINVAL; > > > > > > This covers the case where I pass an argument like "crashkernel=0M" ? > > > Can't we fix that by using kstrtoull() in memparse and check if the return value > > > is < 0? In that case we could return without updating the retptr and we will be > > > fine. > After a series of work, I suddenly realized that it can not be done > like this way. "0M" causes kstrtoull() to return -EINVAL, but this is > caused by "M", not "0". If passing "0" to kstrtoull(), it will return > 0 on success. > > > > > > It seems that kstrtoull() treats 0M as invalid parameter, while > > simple_strtoull() does not. > > > My careless going through the code. And I tested with a valid value > "256M" using kstrtoull(), it also returned -EINVAL. > > So I think there is no way to distinguish 0 from a positive value > inside this basic math function. > Do I miss anything? > > Thanks and regards, > Pingfan _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE120C282DD for ; Fri, 24 May 2019 03:12:57 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 129C221773 for ; Fri, 24 May 2019 03:12:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="a7Sc0Zml" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 129C221773 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 459BJR0YBCzDqWM for ; Fri, 24 May 2019 13:12:55 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::142; helo=mail-it1-x142.google.com; envelope-from=kernelfans@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="a7Sc0Zml"; dkim-atps=neutral Received: from mail-it1-x142.google.com (mail-it1-x142.google.com [IPv6:2607:f8b0:4864:20::142]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 459BGn5gTfzDqW7 for ; Fri, 24 May 2019 13:11:29 +1000 (AEST) Received: by mail-it1-x142.google.com with SMTP id m140so11695341itg.2 for ; Thu, 23 May 2019 20:11:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=E7hznSwoqjG8X1odMBGc2satoFe87v1Y0P/9fKHS9SY=; b=a7Sc0ZmlEG6jC7OpcrRVUkNXq0SBb3Dc/hNdk5Vi6ayUDLd0Dm8M0wWvJFgwttZZ4M aninTKfSUZDRjfNGqPsMzWLja++EezX/hO4fX5nJBzfyFI6kNO7dvjypaoVQz4ys7+R5 9IVPBxW1C4i6BRZ4f3bqLocvJh1c9QUTPILj4gipCVXMgVTUpT9LBYkMiRDL2TaalXNe rQ6wJugIty6JwVWYs5nF97JpvrTENcxT3PWNqVTqRhEna4JwxQokvn2SUzkeP09LHMDC DgccA6RcG2CmDNt2DoIHjZymnDK30hw9WxWvnBoApiNxfRbL6LLAu65RJr1Ih71O/P5e SodQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=E7hznSwoqjG8X1odMBGc2satoFe87v1Y0P/9fKHS9SY=; b=KxDAZ83DQhWxwdJ9MWR0Pk0EvfW6gqdoxf6F/U2ihBXParLBAgDyBiXihw59UCEqYs VOCouX/sigypg9nN+NmWvRdjyWS+jx2s2tq4rCGXZKZB50Ej1BzxicgNt9/kQmnChD3K 1gvtSFrbfj+tBPmAJlfUIy1GlXizZ3w8qWGxH1UkOgs9cqcouz6Aln87xiMrGiIxaxsn eHskKB7Xw1NHPLqmFCKv2ipEWGAANvEoCvFfLPenO90XnjOf0RQq0JcvWB0FGndC/Z5U zzLJi6gvn0jbEm7ZRDaGO4xiyW2f6d8rVKn/mZRK/aycA/7zdgW9TKXe8EsYmjHuooWh wCjQ== X-Gm-Message-State: APjAAAW4ITIDdxEjFgtV1/cO5gDz2V3vCasfLyGvJrmlwoWySAmMJVtu HQsE9GkGpmAag9NYjhQJ3bv6ourgJRzkBFBInA== X-Google-Smtp-Source: APXvYqz4ssg3ircx9GKZ/bOQFSdzkDIVdQtquf3WB1GzGhZLWMOO7FDaVjBjQGy32wO2lRBtVYsHwdCKMGdQi1fBKFw= X-Received: by 2002:a24:1dce:: with SMTP id 197mr16766439itj.16.1558667486023; Thu, 23 May 2019 20:11:26 -0700 (PDT) MIME-Version: 1.0 References: <1556087581-14513-1-git-send-email-kernelfans@gmail.com> <10dc5468-6cd9-85c7-ba66-1dfa5aa922b7@suse.com> In-Reply-To: From: Pingfan Liu Date: Fri, 24 May 2019 11:11:13 +0800 Message-ID: Subject: Re: [PATCHv2] kernel/crash: make parse_crashkernel()'s return value more indicant To: Matthias Brugger Content-Type: text/plain; charset="UTF-8" X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Rich Felker , linux-ia64@vger.kernel.org, Julien Thierry , Yangtao Li , Palmer Dabbelt , Heiko Carstens , Stefan Agner , linux-mips@vger.kernel.org, Paul Mackerras , "H. Peter Anvin" , Thomas Gleixner , Logan Gunthorpe , linux-s390@vger.kernel.org, Florian Fainelli , Yoshinori Sato , linux-sh@vger.kernel.org, x86@kernel.org, Russell King , Ingo Molnar , Hari Bathini , Catalin Marinas , James Hogan , Dave Young , Fenghua Yu , Will Deacon , Johannes Weiner , Borislav Petkov , David Hildenbrand , linux-arm-kernel@lists.infradead.org, Jens Axboe , Tony Luck , Baoquan He , Ard Biesheuvel , Robin Murphy , LKML , Ralf Baechle , Thomas Bogendoerfer , Paul Burton , Greg Kroah-Hartman , Martin Schwidefsky , Andrew Morton , linuxppc-dev@lists.ozlabs.org, Greg Hackmann Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" Matthias, ping? Any suggestions? Thanks, Pingfan On Thu, May 2, 2019 at 2:22 PM Pingfan Liu wrote: > > On Thu, Apr 25, 2019 at 4:20 PM Pingfan Liu wrote: > > > > On Wed, Apr 24, 2019 at 4:31 PM Matthias Brugger wrote: > > > > > > > > [...] > > > > @@ -139,6 +141,8 @@ static int __init parse_crashkernel_simple(char *cmdline, > > > > pr_warn("crashkernel: unrecognized char: %c\n", *cur); > > > > return -EINVAL; > > > > } > > > > + if (*crash_size == 0) > > > > + return -EINVAL; > > > > > > This covers the case where I pass an argument like "crashkernel=0M" ? > > > Can't we fix that by using kstrtoull() in memparse and check if the return value > > > is < 0? In that case we could return without updating the retptr and we will be > > > fine. > After a series of work, I suddenly realized that it can not be done > like this way. "0M" causes kstrtoull() to return -EINVAL, but this is > caused by "M", not "0". If passing "0" to kstrtoull(), it will return > 0 on success. > > > > > > It seems that kstrtoull() treats 0M as invalid parameter, while > > simple_strtoull() does not. > > > My careless going through the code. And I tested with a valid value > "256M" using kstrtoull(), it also returned -EINVAL. > > So I think there is no way to distinguish 0 from a positive value > inside this basic math function. > Do I miss anything? > > Thanks and regards, > Pingfan