Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp358008rwd; Mon, 12 Jun 2023 14:55:30 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ48ObEfBgdkngT0B1Rl2rqag20pehNNiIJXqst3SH4Hjx0FSp/4zxnENV8PYrFaNGNT0p+0 X-Received: by 2002:a05:6a21:3997:b0:119:6112:534c with SMTP id ad23-20020a056a21399700b001196112534cmr12573325pzc.57.1686606930068; Mon, 12 Jun 2023 14:55:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686606930; cv=none; d=google.com; s=arc-20160816; b=sg6J6Z8kj3sR7HGUR9IvRiZ0kVZsCk46NapL6T2S0NSih9neRMz+HKX2kqAYHmdF+l ERgKV8pAC8h4HNWgms6+ErcO6j4z9BymoIIkUD9xyQd9IO2pP/x8Sk97o8sdCAai5Wv/ MceUxZDRk2tsPsK7TyGuySzXrpgafqLQAgzr35gi8absIMMRgrx6O9M9+gXALFuyzP1A JyPzUR/gBPx/24TyrNZez5SBVkccZtE00JyTqDJpnSAc7MlmCrwktVebtDC4xpUpFP2O 94iHGBmsBD+nyqWw3pSiqCPhizh7anNxtgs3V0VdR7XmF9J3ojpogADuEWRlvAgDM85f QQxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:feedback-id :dkim-signature:dkim-signature; bh=8jihgvEIZdo23thuvLLLAAsXI5uRYfTJPltAxmBuMfQ=; b=opq6E6eNo0/hUc2xOt6O5EhCYZLdS8kgxxkBkR97UZY2nv+WbwLq/WjGSGC3/5TMtp CkDjHrhhAg3nOnqUbg2fF3fQyL54d0KrPE82jmhoViL5PQvrbx9nltRIr2Kx6YoBOUNM 1vOyokOq6UhMBl52bSGw0mbLlOFPkBEw284odVHXpNDOHAzf1XlG0RbrTYyOG2aIIM1n P17jiB0/Y1ws4uJE5A08ybVCSzEGZoBvxjEkWM/hYiHQd82mvrVJ99eOiclT7rEBlQo9 X9X71qDM6bSOOw05AtEvaF+guYt2OcfGP73Puc1GcrPdE+2InghQodG0l4sjCQmeK6/T 6pGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@invisiblethingslab.com header.s=fm1 header.b="H8YwY/GQ"; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=osF9P45F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g13-20020aa79f0d000000b00643970acd01si7230211pfr.319.2023.06.12.14.55.18; Mon, 12 Jun 2023 14:55:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@invisiblethingslab.com header.s=fm1 header.b="H8YwY/GQ"; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=osF9P45F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238434AbjFLVZn (ORCPT + 99 others); Mon, 12 Jun 2023 17:25:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239039AbjFLVZY (ORCPT ); Mon, 12 Jun 2023 17:25:24 -0400 Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EA424204 for ; Mon, 12 Jun 2023 14:23:27 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 036C25C0159; Mon, 12 Jun 2023 17:23:25 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Mon, 12 Jun 2023 17:23:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= invisiblethingslab.com; h=cc:cc:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm1; t= 1686605004; x=1686691404; bh=8jihgvEIZdo23thuvLLLAAsXI5uRYfTJPlt AxmBuMfQ=; b=H8YwY/GQjZWoYO5QIsxoeCCV4Vw+plGGMjhIcy5xyUwQ9S9Hzkg 3w9cAcywPvue9ZyXRF5+7D9fJCk/gsZdLKQI8G7wtkB3u91b2qh8u4FyMA0+qT7x xSsKUOzT6ZSUs74RZUZ2XP3PehFCWIobWfCWrH+EGCqQecnDGSyBjakr0Hu/H/IC TJjqYBMpgz91UO/m4A53XY8WaTtyVKfymGprTVIBqpGnIij7RVFWdpS/+30jYJhI cbrW1DBuxtrscwaqOP7AniIpuCOpTjU+wYMdgxQLl0STtrmDnej0XA4u5+fLgsfw U3UNgsAtmqb+OL6qwH+HKAZVs8mg9LNRNbg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1686605004; x=1686691404; bh=8jihgvEIZdo23 thuvLLLAAsXI5uRYfTJPltAxmBuMfQ=; b=osF9P45Fc5n2xA29iiZOKiFVhv2yC zTLgW8lZNM+9aDDV2ZksDOjxInfd+zcZ4xtdurYW9mEynTAhDiJ/eUfcElMTsx6q vZKo3qbmv4gamirIXllUu30uiYro4Epepi1e4bpGknB7JPZH1NEq/xFrCsluG36w YdDh5dtZd9HqfJxY8CJLWlPk3+YfTw6gUIrFFdEjeaCtJ58UDxj3e7q7mJf+1leZ L6V2+NUTMX5ftiDdZ3JO4fDrtLqdqvi5x/Yjl8F+ch4tGUpVMxI8V+dkYRyrgUA6 6ATxg4Tja6tGj0LRs6n2p6CuBOI0tNjZCTOirb9WJfC2iJih03PlKK+3A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrgeduhedgudehlecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvvefukfhfgggtuggjsehgtderredttdejnecuhfhrohhmpeffvghm ihcuofgrrhhivgcuqfgsvghnohhurhcuoeguvghmihesihhnvhhishhisghlvghthhhinh hgshhlrggsrdgtohhmqeenucggtffrrghtthgvrhhnpedvjeetgeekhfetudfhgfetffeg fffguddvgffhffeifeeikeektdehgeetheffleenucevlhhushhtvghrufhiiigvpedtne curfgrrhgrmhepmhgrihhlfhhrohhmpeguvghmihesihhnvhhishhisghlvghthhhinhhg shhlrggsrdgtohhm X-ME-Proxy: Feedback-ID: iac594737:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 12 Jun 2023 17:23:23 -0400 (EDT) Date: Mon, 12 Jun 2023 17:23:18 -0400 From: Demi Marie Obenour To: Andy Shevchenko Cc: Alexey Dobriyan , linux-kernel@vger.kernel.org, Rasmus Villemoes , Hans de Goede , Mauro Carvalho Chehab , Sakari Ailus , Greg Kroah-Hartman , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Lee Jones , Andy Lutomirski , Thomas Gleixner , Vincenzo Frascino , Petr Mladek , Steven Rostedt , Sergey Senozhatsky Subject: Re: [PATCH v3 0/4] Make sscanf() stricter Message-ID: References: <6ab6adce-2318-4ae6-bde6-4317485639fd@p183> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="1qNhvq2VHyxB7HMQ" Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --1qNhvq2VHyxB7HMQ Content-Type: text/plain; protected-headers=v1; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Date: Mon, 12 Jun 2023 17:23:18 -0400 From: Demi Marie Obenour To: Andy Shevchenko Cc: Alexey Dobriyan , linux-kernel@vger.kernel.org, Rasmus Villemoes , Hans de Goede , Mauro Carvalho Chehab , Sakari Ailus , Greg Kroah-Hartman , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Lee Jones , Andy Lutomirski , Thomas Gleixner , Vincenzo Frascino , Petr Mladek , Steven Rostedt , Sergey Senozhatsky Subject: Re: [PATCH v3 0/4] Make sscanf() stricter On Tue, Jun 13, 2023 at 12:00:44AM +0300, Andy Shevchenko wrote: > On Mon, Jun 12, 2023 at 04:25:01PM -0400, Demi Marie Obenour wrote: > > On Mon, Jun 12, 2023 at 02:59:38PM +0300, Alexey Dobriyan wrote: > > > > + bool _placeholder; > > > > + return simple_strntoull(cp, INT_MAX, endp, base, &_placeholder); > > >=20 > > > This can be done without introducing dummy variables: > > >=20 > > > void f(bool *b) > > > { > > > } > > >=20 > > > f((bool[1]){}); > >=20 > > This is more consise, but (at least to me) significantly less readable. > >=20 > > > > > lib/vsprintf.c:3727:26: error: unknown conversion type character = =E2=80=98!=E2=80=99 in format [-Werror=3Dformat=3D] > > > > So NAK. > > >=20 > > > Yeah, ! should go after format specifier like it does for %p. > >=20 > > I hadn't considered that. Is the typical approach in Linux to use e.g. > > %d%[!] if one wants a literal '!'? >=20 > It might be that the cleanest way we have is to create %p-like extensions= to > sscanf(). %p takes alnum as parameter and that is usually works since it = makes > a little sense to attach alnum suffix to the pointer. >=20 > (I don't like to have %dX, where X is alnum as we expanding our hack to > something which people don't expect to be altered even in the kernelm, y= ou may > refer to the discussion about %de for printing errors) Personally I=E2=80=99m not too worried about compatibility with userspace sscanf(), except to the extent that -Werror=3Dformat can keep working. Userspace sscanf() is almost useless: it has undefined behavior on integer overflow and swallows spaces that should usually be rejected. I typically either use strto*l() or (as I am currently doing for Xen=E2=80= =99s toolstack) just write my own parsing functions from scratch. --=20 Sincerely, Demi Marie Obenour (she/her/hers) Invisible Things Lab --1qNhvq2VHyxB7HMQ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEdodNnxM2uiJZBxxxsoi1X/+cIsEFAmSHjMoACgkQsoi1X/+c IsFFLg/+IexZNCutgAvzB9QpLaKvrRK1RyCLLOexeqRIrLpsZxC5ph43KrBFdEye ORcumc8hllJ6geaozUFYZWZi1bEq2pELnftswyZzwzHq2JXrRoDfJDwidQd9fSui 8OThDF5rcDips9C3kaD1LjTkFkeNDqz68bh4ns78PWIZVt6m4Vct9FV1Qj1cPD1b Er7B7eb9OY+mT9+/k02JNejJ56zw8VxB0+UKeFpdnl5aZHRS75lkEPaQe7y0F+bB WbAjCzlac8sDrMJYi5GwumwarFDQRIPKgLff0VE/qeQl+c9l6jFHzBwH6TnYSd33 evxkYU+PID/GlsXTVSuSBbRdXRZ8TACoN78xjK5dk9PWKfZ56oTNLNVs8gSw47Ci MSIVZoGD5Nm7tEPY+5BSQSwHE4NmWVcK8kfbI0xfc3Kkg8mfiWmO5chg44+EZD9y ui+SaDuras2bVsLiie4y/nvznEmLd8sGW2MmZErtTJUZlMpaZ8zxmWPO041UceQc hCYmOTu5W9GQaRW/mkEAxFXDKWXHuNiRezAKNGQLLP7UZAxpOWiIYsnMQTbdMwjC Xa1k75R1qKbXqmFOULaT2ng5+vI1KUQe1XRjLbr9UDD10x8HnjCSDOBcuqJVX4mK etxenamwRW1++pcZDGPJh26vWrBn3Vkxd0doGvHdUM96A4pz6cQ= =KpGC -----END PGP SIGNATURE----- --1qNhvq2VHyxB7HMQ--