Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp7976822rwd; Tue, 20 Jun 2023 08:35:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ69UC+Ahaq7TuZSTqZXbTB2ihbMo8qjFNluqs5QcMva0ooQd/EV6Sp+xOzqnKaTfXUPTAh8 X-Received: by 2002:a17:902:ecc7:b0:1b1:4801:f516 with SMTP id a7-20020a170902ecc700b001b14801f516mr15657981plh.68.1687275320600; Tue, 20 Jun 2023 08:35:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687275320; cv=none; d=google.com; s=arc-20160816; b=McomC0oz6nLASZW9W+SLTNLvo8ZfeY7WKIp8sBRdffvFO6dkZNrGcR2V17NREIOBMw RQzHZCKfda9NUZe48v0IQgwdRqI/bGYLPMj2GpJkUA3Jn1Op2sjzbnoTkwpyqGKSJCu+ oyXhtoaApr6L9T/X1SBNGPBMzX0HLZ6WnoSYM0mniKuUkG+2FfIKuADd6SyR0gNhD+pW 4OOO1cU+/9lJqLtrjG/DNfMgPa9gJ6AGxcvk3RK2xaoe2FnU4bekSL91Kur3Lv/SPZlT 6ucqTmdI2WqLkZk8ATKgm2W6StZsq1QBHoUYAFVGuoZ/JuUV2g6fb1KBh/modv7KZNqK fi9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=BWgD4WMaPOk1CMzr/XFamAa5SiRcoUj1M09AltTpLxg=; b=JBNrfKFjwbzk8VnKMLinRDD5hZo/ESBN/ZupSdd03A/NqwfpRJaDopFSTYKIQIpW+A QUrBLhXKZ9i0rPryOrL7IWO/GPf24/k4uRkoGzJDl6HGDm5aHMPb5u3X/CKLt1Q+U2w2 FUdzJux7/LaLP02VUYytCcrmhw2fBH9NUCCt6PgaUFKjJXqCGaIJ9YWrUiDAwMakemod St6An2NJhCnjGIkfg7buvC4AJsM1nnzw5hrsyvbQvQOfNlg5YgRmE727MC9fQS+8C79R nIk20nKDh3IIdA0ENBIOjpzgBsSOYDofRvYd3rC+RPi/Id8uxW0NBzuZb2DJyhReRwJ9 ro8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lhqzoryX; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a3-20020a170902ecc300b001b3dacdf717si2278538plh.608.2023.06.20.08.35.07; Tue, 20 Jun 2023 08:35:20 -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=@intel.com header.s=Intel header.b=lhqzoryX; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233563AbjFTPH3 (ORCPT + 99 others); Tue, 20 Jun 2023 11:07:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233523AbjFTPH1 (ORCPT ); Tue, 20 Jun 2023 11:07:27 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB98CDC for ; Tue, 20 Jun 2023 08:07:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687273646; x=1718809646; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=dKDmJjt7XJnSsECb/w05H37T93Rv7V4QnXaN44SoXng=; b=lhqzoryXz0lRnnDb3RoKeX7kc84FNAKV3QWauRN8aFEVsr/Rl23NqkoQ r2zJn2EmYnZ4aKzGHabk3GrKy3EnYbwqhr7e7akAPTHcobIJlYUqbV0ZJ 2+jsYixRmtoNr64eZF34boONiYMgtzlYbXc69ZV+fHJChepT10jv/McOr f8IteT8RZCAIgLqThWVSxP0raa/GttcI1qw1HkRSg5B5dne6SHiWtGqUI tKkSWeCU8aDVLbLvMJnq/x9X7pZxVxXkq2NAVkBoWDQCBu504dsQtnD5f qRh5Ph79KTZxgKSiVMinyZAqVfUd28VPHGyze+V5MgkyfhuNSZV+8KiIn g==; X-IronPort-AV: E=McAfee;i="6600,9927,10747"; a="389158038" X-IronPort-AV: E=Sophos;i="6.00,257,1681196400"; d="scan'208";a="389158038" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jun 2023 08:05:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10747"; a="714071011" X-IronPort-AV: E=Sophos;i="6.00,257,1681196400"; d="scan'208";a="714071011" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga002.jf.intel.com with ESMTP; 20 Jun 2023 08:05:17 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1qBcux-005Hbs-04; Tue, 20 Jun 2023 18:05:15 +0300 Date: Tue, 20 Jun 2023 18:05:14 +0300 From: Andy Shevchenko To: Petr Mladek Cc: David Laight , 'Demi Marie Obenour' , 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 , Steven Rostedt , Sergey Senozhatsky Subject: Re: [PATCH v3 0/4] Make sscanf() stricter Message-ID: References: <23df90dd35874fd89c64906e6a6de164@AcuMS.aculab.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 On Tue, Jun 20, 2023 at 04:57:55PM +0200, Petr Mladek wrote: > On Tue 2023-06-20 16:52:42, Andy Shevchenko wrote: > > On Tue, Jun 20, 2023 at 03:34:09PM +0200, Petr Mladek wrote: > > > On Thu 2023-06-15 14:23:59, Andy Shevchenko wrote: > > > > On Thu, Jun 15, 2023 at 08:06:46AM +0000, David Laight wrote: ... > > > + %pj or another %p modifiers would be hard to understand either. > > > > > > Yes, we have %pe but I think that only few people really use it. > > > And it is kind of self-explanatory because it is typically > > > used together with ERR_PTR() and with variables called > > > "err" or "ret". > > > > j, besides the luck of no (yet) use in the kernel's printf(), is > > described for printf(3) > > > > j A following integer conversion corresponds to an intmax_t or uintmax_t > > argument, or a following n conversion corresponds to a pointer to an > > intmax_t argument. > > I see, I have missed this coincidence. And we would really need to use %pj. > %jd requires intmax_t variable. Otherwise, the compiler produces: > > kernel/lib/test.c:10:17: error: format ‘%jd’ expects argument of type ‘intmax_t *’, but argument 3 has type ‘int *’ [-Werror=format=] > sscanf(str, "%jd hello.", &tmp); > > Hmm, %pj might even make some sense for sscanf() which requires pointers anyway. > But still, we would lose the compiler check of the size of the passed > buffer. > > This is actually my concern with many other %p modifiers. The compiler > is not able to check that we pass the right pointer. I know that this > might happen even with wrong buffer passed to %s or so. But number > types is another category. Yeah, it was a discussion IIRC for the compiler plugin to support %p extensions, but I have no idea where it's now. > > So, I think among all proposals, this one is the best (while all of them may > > sound not good). > > I still prefer the custom handler when it is not too complex. > > Or if there are many users, we could create sscanf_strict() or so. -- With Best Regards, Andy Shevchenko