Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp359217rdb; Thu, 30 Nov 2023 06:48:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IFuLezvI4+HFmVQmPeomkAR4nzKC8JH9cPrynDB93CzyWyaTaP0ChBTbkot9Kgo+b+Ci+0g X-Received: by 2002:a17:902:dac7:b0:1cf:c397:8f09 with SMTP id q7-20020a170902dac700b001cfc3978f09mr19219642plx.55.1701355731952; Thu, 30 Nov 2023 06:48:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701355731; cv=none; d=google.com; s=arc-20160816; b=JzKi59K6P/VZTfFXEnDfZpxXSJjViIn8i6OYzWVWGzqrL+SkMrWbrLczEuiioo2fCv QHwrI0th5y9PZQ2fr5ESBYjzoIoKomLnM2kpLEE64HKZ9JAiy7nPgXPPKde+RY1xnXhm xy0wMoAsJd8Q/jrwYmyn5Urk8x6i8vHBLjDGF66J6WFxINpHJ+0ZOpDZNURLEHX4Bere Md+1l4BUGhqcVlBV7JmOD+zdnHz8D+pq9CZFmRKFUkngctm9eUzOM2aPXLbxJqYXQS6D /GdlOPuYyDaoaIYMj7SyfKGCA3fR/2YJRGTyltWfL/9pKQBbc4QDGA9B0CvVOVPUuoSO brlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=0muDf491lrhXINQT2ZKN2LliQpFV7k/GNMdeGRlPdsU=; fh=7fP0Lf960/0W8Q4xC7fRTbZJsHQDaVtdFN+W/AOVQas=; b=W5X10154scgfSYGrbbASHN50mjvEvwAXd1VE+EhVoNQEEwd6OIXKh6b28dGqwHCd9k 2fZx3KwLDA1obpC/fOjyZdHsSbHuDoR76rZAZIWy7VlAGWCOKq0DAADPd18Kld/3o9fA 4lnM6R0IjPXsoRZAcHPhnQBidOnUTIDRCdj9LRDIl/Fcy3ctoK/7Yq82Ozsk61u96Osf 3I9LqmmsKyFCSDqRRII5gNwli0LgAjwvTUn2sO2Vpb+NeBLbh8MC4DbSOMXKiCzxFkLq lsPcS8jHZ03DNAo4X0Nrbiws6BoR3xEsaH6sHELzWQxlQkgTa1SERsW3G5Ue0beaVH+5 TVPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hQgGi9gq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id u7-20020a17090341c700b001d018b5a0dcsi1430512ple.411.2023.11.30.06.48.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 06:48:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hQgGi9gq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 5D38C8032358; Thu, 30 Nov 2023 06:48:49 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346025AbjK3Osf (ORCPT + 99 others); Thu, 30 Nov 2023 09:48:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232192AbjK3Ose (ORCPT ); Thu, 30 Nov 2023 09:48:34 -0500 Received: from mail-yb1-xb35.google.com (mail-yb1-xb35.google.com [IPv6:2607:f8b0:4864:20::b35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91AC3B5 for ; Thu, 30 Nov 2023 06:48:40 -0800 (PST) Received: by mail-yb1-xb35.google.com with SMTP id 3f1490d57ef6-db53f8cf4afso490249276.3 for ; Thu, 30 Nov 2023 06:48:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701355720; x=1701960520; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=0muDf491lrhXINQT2ZKN2LliQpFV7k/GNMdeGRlPdsU=; b=hQgGi9gqKRUwpt7+fo/Oe52nORnTqj9YwHKoOBhgCpMHdBbzFyb+TFfNxQJxMWbk3q E8hhNZVLIOtjsmMOfD+emJDs/ZcTe5y5oY63h3NnmVfb7ubc6ytnhb+tFGTA4jWtVZSY Wt9E8LMTxRpXI7uAoqdqCWM5d/3TtE0/7BKm+M3tA5xlRK5JMeo2bdBMRH/Qq3Ffoqqr jUlMcj2+6QQvONQwUBZlTHCV7aEQtNw6qELBsBngOZGoP5dSZ95Pm97zuW1E8QB8b5mC KyrlmhI8RBinEuNtzze4NkfQ2wk4Z1JCzmfQsXsEAvOmw//t651UgPvlbkIb0RAUCTu+ EELg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701355720; x=1701960520; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0muDf491lrhXINQT2ZKN2LliQpFV7k/GNMdeGRlPdsU=; b=WJz0Ykrz2C00DdXHnJW19JuhwJ7GHauETMtTQjS8lHDwJ7wPXjXO8jcfQisTt57zzd Z/gpJ2NKW/e33OGu10c4SADwV1/3L4HuM8KlV3KxTJR50A8EuZu8W9RXERA0S0xb8mzX MwWbx1+ZMVbX5IyU9HnGtjKczk3L6WwU/2EFGhkGXcdnyfJNtVsgOolFTsIkAY/YnVMx F4a+Vt46KWfq9XHtxbc2R/KAyn3ID0yfF0S6GB+R255sTLmqbFyZ5pjN8YoP3o2yt4Wq 6OHPAkgF9ka7+x9a2iwO3Vr7iVQ0ITqYdG6q9MQEfFop694bgLvdv52z7MO9IV9/vS7H YXaA== X-Gm-Message-State: AOJu0YxUZQWglBCcS0Ta2nAMRk72PS1JWS3B2b4Ej+pp+Bsws3VrwEwk Hgem2dsJLwAVJL7QtIGO5bDjRhgRXHSqHMPCZRIKyA== X-Received: by 2002:a25:8e0a:0:b0:da0:5ba2:6275 with SMTP id p10-20020a258e0a000000b00da05ba26275mr20783935ybl.34.1701355719730; Thu, 30 Nov 2023 06:48:39 -0800 (PST) MIME-Version: 1.0 References: <20231130105459.3208986-1-lee@kernel.org> <20231130105459.3208986-4-lee@kernel.org> In-Reply-To: <20231130105459.3208986-4-lee@kernel.org> From: Linus Walleij Date: Thu, 30 Nov 2023 15:48:27 +0100 Message-ID: Subject: Re: [PATCH 3/5] usb: fotg210-hcd: Replace snprintf() with the safer scnprintf() variant To: Lee Jones Cc: linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Yuan-Hsin Chen , Feng-Hsin Chiang , Po-Yu Chuang , linux-usb@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 30 Nov 2023 06:48:49 -0800 (PST) On Thu, Nov 30, 2023 at 11:55=E2=80=AFAM Lee Jones wrote: > There is a general misunderstanding amongst engineers that {v}snprintf() > returns the length of the data *actually* encoded into the destination > array. However, as per the C99 standard {v}snprintf() really returns > the length of the data that *would have been* written if there were > enough space for it. This misunderstanding has led to buffer-overruns > in the past. It's generally considered safer to use the {v}scnprintf() > variants in their place (or even sprintf() in simple cases). So let's > do that. > > The uses in this file both seem to assume that data *has been* written! > > Link: https://lwn.net/Articles/69419/ > Link: https://github.com/KSPP/linux/issues/105 > Cc: Linus Walleij > Cc: Greg Kroah-Hartman > Cc: Yuan-Hsin Chen > Cc: Feng-Hsin Chiang > Cc: Po-Yu Chuang > Cc: linux-usb@vger.kernel.org > Signed-off-by: Lee Jones Reviewed-by: Linus Walleij Thanks for doing this Lee! And as David points out it is even a bug fix at the same time. Yours, Linus Walleij