Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp3593131rdb; Wed, 27 Dec 2023 12:30:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IHS3CSRsdcfyFO0ReYH6UqEYS+dJTzX5Ks1xjo7kA3GzoTYBDqySPg3q/NNi11svBli5Vvz X-Received: by 2002:a17:903:1ce:b0:1d4:829:fede with SMTP id e14-20020a17090301ce00b001d40829fedemr11053923plh.125.1703709001883; Wed, 27 Dec 2023 12:30:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703709001; cv=none; d=google.com; s=arc-20160816; b=Gf5n1OKeruDSO1ZH51XbgNWyiZlbMQPAjHylJzqM7s6DWQbK8G3W71pxqUtH3805Pm vEqrCjV5npf5dV9AHy9E5ROKbsK7XkI7pJStJRjJ6pxAluZYWuUgIW/wx6p385TJphf/ YDwA8XRggeaFY2Xd5fOU2PaYrMmgtx5q/IWCjZJP2/B7Kd8G7leIlZ39u6Vh5WZ5rT4E IAZPLwiMbmz+rW+E4IRds4dyD1EzGMNk3MW579f+7GkAcpbcKRNJQX6YtB7iVgUTQmxn f4ai2vglHuQ5FaqzZt88JjivBCJjwmZoi+BMKKY+BOcTgCK/WLdDR3TwelDKul2qIcia Xnig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:in-reply-to:autocrypt :from:content-language:references:cc:to:subject:user-agent :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :date:message-id:dkim-signature; bh=zhh7IshWwlE6VZPNSP29ccb7pYQvoUHEgdvf/B3f1aQ=; fh=W/XT51LREhi0kxr8mOb3revp2PIVOcLak1/qAD1ZsjY=; b=neMia48o9KMrzhEJkBkohqsOb0YeQkQW3/QbZR4kC7rQNVfJmurK5gn+8s+7L5BmNC F/J/hoVbtvQ0T0wxmK64fLe27YuJNo9H2caU2uXcFCuav+A0dtdP1ROochraCVayIPUH W0kJSl5gHz5P9TxOeYgYAYX5Tmd/GxhtlvTzWmeizH3IhvLp/Tcn7EZVrquqDG7xyDNZ kTW6nEF1XYrWRb4WPt6QBjiG0bQp5ouwvfcdIXqbcLgZhFULqxsWSCwBLxDtx1rDOHwO PVvVoG2IHZ7MsSmaP3PE2waZ4ubiil70NROsyvFnHh5wjkBnMVfNwJz6Lk+lwDd8mgWh ltQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.com header.s=s31663417 header.b=F1ofzNPV; spf=pass (google.com: domain of linux-kernel+bounces-12240-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12240-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gmx.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id t15-20020a170902b20f00b001cf68d3e90csi1625850plr.98.2023.12.27.12.30.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 12:30:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-12240-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.com header.s=s31663417 header.b=F1ofzNPV; spf=pass (google.com: domain of linux-kernel+bounces-12240-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12240-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gmx.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 3DFC7283924 for ; Wed, 27 Dec 2023 20:30:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1215847F66; Wed, 27 Dec 2023 20:29:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.com header.i=quwenruo.btrfs@gmx.com header.b="F1ofzNPV" X-Original-To: linux-kernel@vger.kernel.org Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2A7AA47F53; Wed, 27 Dec 2023 20:29:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.com; s=s31663417; t=1703708958; x=1704313758; i=quwenruo.btrfs@gmx.com; bh=coGxLO1xjfB+I0nXBEM3KYB+AYsCBtjhmWVIL1BxfDw=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From: In-Reply-To; b=F1ofzNPVVZziFXcc3OHlbk4dlhQy6FWPxnsQ/ScMjD0InyQCy1UQBUGIn102jJK1 e1+Dh8YP4uC3Y4GEjze7I/TKaDtCMrMXIR0slKslXvccQU3+Ydz7nMiMdwbSO5uQm WezSGE/fUWmQCavFhkmOpsJrnljoCSbQApoP28r1XDOy1IffXV3wesV8kw/MW5P8t kf91/T10Y0fx6e9FUxnaEYm//wjUUXkC8LYhEx1XeTycI1qSU1nX5+TZh6/EuYhuD C6OBJgPFdU3j2GmvTLAzsYFN8+zKMqs7AasbJcOFU7RgIj/IjOGT6vQX05Ep8ZioA SFKaWG/WmR4cJun9zg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [172.16.0.153] ([118.211.64.174]) by mail.gmx.net (mrgmx104 [212.227.17.174]) with ESMTPSA (Nemesis) id 1Mg6Zq-1qkuzj39R8-00hbXY; Wed, 27 Dec 2023 21:29:18 +0100 Message-ID: <291b8b6c-7421-4796-b283-46ac46ce3e36@gmx.com> Date: Thu, 28 Dec 2023 06:59:10 +1030 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/3] kstrtox: introduce a safer version of memparse() To: David Disseldorp , Qu Wenruo Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, christophe.jaillet@wanadoo.fr, andriy.shevchenko@linux.intel.com, David.Laight@ACULAB.COM References: <7fd6e5cf2b7258c3c076334f443d5fee7b1086d6.1703324146.git.wqu@suse.com> <20231228002603.059bfb1c@echidna> Content-Language: en-US From: Qu Wenruo Autocrypt: addr=quwenruo.btrfs@gmx.com; keydata= xsBNBFnVga8BCACyhFP3ExcTIuB73jDIBA/vSoYcTyysFQzPvez64TUSCv1SgXEByR7fju3o 8RfaWuHCnkkea5luuTZMqfgTXrun2dqNVYDNOV6RIVrc4YuG20yhC1epnV55fJCThqij0MRL 1NxPKXIlEdHvN0Kov3CtWA+R1iNN0RCeVun7rmOrrjBK573aWC5sgP7YsBOLK79H3tmUtz6b 9Imuj0ZyEsa76Xg9PX9Hn2myKj1hfWGS+5og9Va4hrwQC8ipjXik6NKR5GDV+hOZkktU81G5 gkQtGB9jOAYRs86QG/b7PtIlbd3+pppT0gaS+wvwMs8cuNG+Pu6KO1oC4jgdseFLu7NpABEB AAHNIlF1IFdlbnJ1byA8cXV3ZW5ydW8uYnRyZnNAZ214LmNvbT7CwJQEEwEIAD4CGwMFCwkI BwIGFQgJCgsCBBYCAwECHgECF4AWIQQt33LlpaVbqJ2qQuHCPZHzoSX+qAUCY00iVQ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v/0oUrGU+U5X4IvdnvT+8viPzszL5wXswJZfqfy8tmHM85yjObVdIG6AlnrrD In-Reply-To: <20231228002603.059bfb1c@echidna> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:3Kus+rPDU83mnij4glVIs3LjLXWKXPHFpN2JtBPvgw+o4lpGyYs bPF8KMZB75aI0hrEQAUuun8JLnTzID4XTgQMRwp/RH2gup+Wgx2GMIM1Kh0SO7IowSyOypZ hOicZNV57bFT+yvxW6uz01oo/omgmpbsV+qc0xzWL3mPbxnhrsQAxQXmamboZblfotE/nBb OvBDhPGtIW0UXYHDwDqSQ== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:Sjv25Gal26g=;hPCQtvjrNlb3LivY4L+q79oiyxY SBfxhKBWdfR/GtdLnTq7SywboumbImoZNptYco/okdo+vjV0qJOuKTIKSPBVpe4WwJHbiEREK BMqpZ0KCYHUVoBZj1h6I+B9Zd2SmC/EQHmABJOIzIgU9cLatVRuD1nh07VHWMA3DGei839KCP 9hixctr5DaGHh+rkYNCFrb589oxhCFUwTouLvyR7FDKS3gU0bd9XAfcR2RDmHTNA9dD94Mf8H 96LEIqSP3OYH4975XjWkbl4RC2jbaOCIdzB84vLh9Qcq2L+DSmrYWNgnNkR1PWEet4utfBVVi QCNWPhRQOtQt/Hck/wSKLM7NDtyTKvBs6+j6+vplKRPLgSweRAlQrVcs/O+NSHMBquTK0pN3k V6RfQuewSpiIWSaTYzlVCgT7yY5Yp6Q3pHwyq1eOa3jxMDRlJD+WTKpbdI4pMZr3TWJzl93I9 s6Cq2zPkLl9KGo7xyIhktNhYd5mnjGnlZOcD1pX0tday6NxszHB/TYNap8zNM6NLMsIzmzcW2 s6fDfmg2vRHL5hqyOSkISWRga4FGYOhaalR/7UqqpXmAE2AXzSo+5/y22aM+21QAfmItOZ+u3 uZKcTMDxOYNq042RCnZEXk3hldjSRL2zoXxUIR7sgRJwRmnbsSEaoX+CBE2lMW4LUt7xKmpQs +EpHty/E5sPszRy0tV5l3Syg7ZXP73BuDatwjsEXUUCp8xdDjUT4TEtDnBqUFy1h20u+Pzbnb wc0sl/XcG11z6DYBKA8KRPzQBhRaLWMcWHqAod7zMvDfADUOB4iXoyERkDH+Ddsv/gHmOvple P2ZePxRGJ1f1PGcUr97bEDq1nzq4sUn9/i/PT/qKem13iZft1DN3Zepcg1q3jfkPcxUxUcmq+ h7kL6jP+fyRqb81lOW9IW6OOdEajOjxyVLShEfQyXvVd4BY/PtdnAtisChhxhypJEU8NkSXpP ZAu56g== On 2023/12/27 23:56, David Disseldorp wrote: > On Sat, 23 Dec 2023 20:28:05 +1030, Qu Wenruo wrote: > >> + s =3D _parse_integer_fixup_radix(s, &base); >> + rv =3D _parse_integer(s, base, &value); >> + if (rv & KSTRTOX_OVERFLOW) >> + return -ERANGE; >> + if (rv =3D=3D 0) >> + return -EINVAL; > > I was playing around with your unit tests and noticed that "0xG" didn't > reach the expected rv =3D=3D 0 -> -EINVAL above. It seems that > _parse_integer_fixup_radix() should handle 0x differently, or > at least step past any autodetected '0' octal prefix. Yes, that's also the problem I hit, but I'm not 100% sure if changing _parse_integer_fixup_radix() is safe for other call sites thus I didn't put such test case here. My initial failure cases includes things like "0x" which would still return 0 is already a warning sign. Thanks, Qu > > Cheers, David >