From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1494A33F592 for ; Tue, 24 Mar 2026 17:24:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774373078; cv=none; b=bOnLWf6hZP4dseBHBReEqcJTwQ33HSXBUxpmjXt63XB5H4ZvRWIR2ggBt8u7X6K4s7iFR0zfat4RWg8nGBRFnsnW+zQu+hm6tpRnMEnHYezWRaEGG+iKUZ1hql4zk8rKE37TuFOEuUhs+Sl4QV2GveeuAgTS00pOefmRSix3PtI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774373078; c=relaxed/simple; bh=oXs4I6mMqSwBAvchbxnYVrf/YdMm7dAVc9TVQQX8JmQ=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OKbKx9oqJXCjq657/P2RbpwXORFaKQWw9vFvPK86E51KuWxNF95QC06PB3XjJVzM6ke2pl+XQodiNkZ0sb4AttUq1Os5xHppRwKUCAKBjwaezkUttKuWAqD4B9o6LcuW8kp1Ctfl7tMQ+X6WWlbxth6TKO23OBcqBq4QAY8JcWU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=hPzr9inW; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hPzr9inW" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-486b9675d36so46423365e9.0 for ; Tue, 24 Mar 2026 10:24:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774373075; x=1774977875; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=u/buPiUy5oTsDNeh8fxWco5MnGg2B8mSKvsG2zbXN8U=; b=hPzr9inW5b5AOy9pmF/iu8z50L5HZeGYchZvspIWUJFew+lM/tyZb3jMadtrJXtNTV Gzu+tqx/HqkBHT/I62fRuMA0qWF0JfH+NVnPVRJ0F1eFJKhWHFa9AFs95VG2KBRr10Fh 0BnTOqsCkr/Tb7wYJFNF5UN6Rkg7UBkXM7Qt2yPQUARYInmXEuRxXFooXZ3tA8jSfWno vZrXJxYBOUSu/Is9dr0WEOVrhYXEBWTIzMoKFEcsaKA07ZXdZIIX5nogZm01COBIGT2j MIBCB5hcsta/Ohapcm2brceRcTzXE8Ca0yAo5L4CZqlEElY8F2AUmkAxniqgj00cizzd 8xHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774373075; x=1774977875; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=u/buPiUy5oTsDNeh8fxWco5MnGg2B8mSKvsG2zbXN8U=; b=tJccjYERZPletIx+GFLl7rNjtXgxhGjdSC1HDlE+FWiO5kXP8UPEJyiKodMgwbe0C9 XZWLgjGcD8LOkGQDVr3W4e7CVsVaqz2OnIU6uOsJNjMAKRHPzQYXvJw5xTMQHDbD2M4b e1KzeIp8vIHlaWd5tWqqhV4pDNVHPmErmoDAn4x2dfnOXYWPlLVPiaNgzd+aMPeztV0U kydF7eWKPoyBjMdoefg3OG3wS2GJuJvevxSjw2D67yV3+xMnjlxvLQIEpYcjtk4VNgZb p2eMaQ1Nmn7p+zQweSkNjMWICPLPnFNkItT5aJH6wt62QqrCFRedxEDaVowCwxV/6UPu +W/Q== X-Forwarded-Encrypted: i=1; AJvYcCWV5HpKUHchLzkmmnxpeE1RhPHgTmNmtip0UqWuVxahXy0/0nvsed+hqID/TcYSMAdnJzVtWdJz51cXyPo=@vger.kernel.org X-Gm-Message-State: AOJu0Yz0NUQWjKtj+ZvJzZW2Ae6LUQ3RyLZoLBiC6+2nXNC8sWIUuuRl ivVY4N6RjwmY7Y6z04vksXs18TEKjFcS6E4k1cuv7MamDxnTctm0LbtT X-Gm-Gg: ATEYQzxbD1Jfs2o3I6eaz/9tWdGkLx2mrxCePMej9J/xc2NAn+V95IHnNXOknmun7Ta zM0KVMueD1KkVDtAsUlYg9cNtyRMtNyjAMTHH4NIaxniSP2my4x0GdApQkyTkztyok8iIxElPH7 5ZWmcPgYzXJ2svLuDxLB2vXRP07UXO0XcR6vgacuOEv3r3q0GX18zOIydDJo8nzXuR6H7+EaSYn ophZjA5NaXKTGrKpZCDsJrVVmIn11WgUB0y92aba9j7SPBVU//xE3uq644t6OFJavTWCWlb0cgG 1e18Nz1qoMyz0TJFtp2eJ4VLpGpiykC5y1ZTt+JPQG1T+fGCjgSW+JPQRTmV6+GtEICjQsJqrFw cAi29dIEGVzKuhsbkv8e6RArMEOTZEg1WeWNLvwWNBFTO08LSEArv1nZ1AGXWNNQ//nidrhYr3N KfywSokBA1dsvSfiBgqYEJ8mR2BDcfbpR5XyWeRYIg9KsaX5NjjYzOqLDbPeVSUqag X-Received: by 2002:a05:600d:41c9:b0:483:a27e:6706 with SMTP id 5b1f17b1804b1-48715fd4d54mr8538555e9.9.1774373075116; Tue, 24 Mar 2026 10:24:35 -0700 (PDT) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48711702191sm60933025e9.5.2026.03.24.10.24.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Mar 2026 10:24:34 -0700 (PDT) Date: Tue, 24 Mar 2026 17:24:33 +0000 From: David Laight To: Petr Mladek Cc: Rasmus Villemoes , Andy Shevchenko , "Masami Hiramatsu (Google)" , Steven Rostedt , Sergey Senozhatsky , Andrew Morton , linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 1/2] lib/vsprintf: Fix to check field_width and precision Message-ID: <20260324172433.05292942@pumpkin> In-Reply-To: References: <177410406326.38798.16853803119128725972.stgit@devnote2> <177410407207.38798.2345647618225402693.stgit@devnote2> <20260323135905.5272127b@pumpkin> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Tue, 24 Mar 2026 17:45:49 +0100 Petr Mladek wrote: > On Mon 2026-03-23 13:59:05, David Laight wrote: ... > > I've also just fixed nolibc's handling of %*.*s (which is in 'next' since > > I only wrote it recently), the above is actually broken. > > Negative 'precision' (all values) are fine, they just request the default. > > Great catch! We should clamp the precision to (0, PRECISION_MAX). But we > should warn only when it is outside of (-PRECISION_MAX, PRECISION_MAX). No, you are going to clamp it needs to be to (-1, PRECISION_MAX); but max(precision, PRECISION_MAX) if fine now the value is being saved in an int. And there is no need to warn about changing negative values - they all mean exactly the same thing. There isn't actually any need to worry about large precision values for %s - they request truncation, precision only increases the output for numbers. > > > So the patch needs a big fat NACK... > > What is an acceptable solution then, please? You could do: spec->precision = clamp(prec, -1, PRECISION_MAX); if (spec->precision < prec) WARN(...); David > > Frankly, I would like to stay on earth. This started as a simple fix > of a regression added a year ago. For me, any solution which > restores the year old behavior is good enough. > > We might need to find another volunteer to implement a better > solution, e.g. the new non-panicing MSG_AND_BT() macro. > > Alternatively, we could remove the WARN_ONCE() completely. > It looks acceptable for me. But Rasmus would need to agree as well. > > Best Regards, > Petr