From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (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 7ECA33128B2 for ; Fri, 5 Dec 2025 11:13:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764933201; cv=none; b=G9/F7ktQ2wb8X/zqOPmKEplZh4w5NpwfAJlADgc1Vw02qEqUcOvvDGucXxHhCXQkC3HbQJfVXMXRaFXygrFVDgnlY20wn4AZOa5SIrMVpMrajxAQy+WMDfAVO4dBCYG7mECErDIKxX9+Yd8s8Ia9quf/9jHRxhwYn0PfjdK1YTk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764933201; c=relaxed/simple; bh=L5lAswxvjw1mfCwWrlotvEHbri+CHRLvGyZd/g7JahU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=hI9J6S87DId04apKYjwCXW2ya0I6ECob8KA/xA0ET6mzd9nHr0rshDGdd0jZWbEExWnXG0H66FFOpZcB+4BZgxY6nVXSZVwMJPj8vhr/53vyb/W0o9iTVN9P4jnW5ZcV39VB0uoKKoeQoR01m+K3xqixjKF3fCHKPdNgLnLCHDc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ursulin.net; spf=pass smtp.mailfrom=ursulin.net; dkim=pass (2048-bit key) header.d=ursulin.net header.i=@ursulin.net header.b=urpMDqvT; arc=none smtp.client-ip=209.85.128.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ursulin.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ursulin.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ursulin.net header.i=@ursulin.net header.b="urpMDqvT" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-477b198f4bcso16218905e9.3 for ; Fri, 05 Dec 2025 03:13:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ursulin.net; s=google; t=1764933196; x=1765537996; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=S+WodKuxsAcIaiFl8vrv/vlH2xW1X4fsVn0hYeqa028=; b=urpMDqvTCvs06cnALG/rrJrTB7KEgAyo5200gL8VA62j2UGgKqM9LSFsGGgE1tjcDk XeFP5uxzxacSL10Cwgp7xmiSNC2nLr2jnvpybpa3kO0Xrda0r6PiUSTzfolG5R5ly8hJ MO9IfVmtymScjUqsKq/AkFF20ZngAexSEYIrcyrv1giVfkTYhdmG1jPk4hCZVg133C7S r6HZHwJG0n3flfsCXbOMjwccAX6JeJLiI98S0G+tRCQKc4fsVB6AyVsNDHyHkJObsQUa JMryjuoGwhnp8Y3N6i7gO7wHZFp2woRJrkhb0HF80hMUVh9zdbrj+xkzum6P+jfIjdve /LIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764933196; x=1765537996; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=S+WodKuxsAcIaiFl8vrv/vlH2xW1X4fsVn0hYeqa028=; b=adLv5GNfEqqXW1G9O/sO57tSeMiNCgdXyPq1XYajGFw39Sr8IN4xmpIqthdbRE46DH T42F4TnwIgSGPNTTeIs0WMUdZbIRvW/iZcDNSriPTfKZaxDoZo/VL6czGQ5A+u19QnxU 3sIRRiMtXvPLno/q/D1zrNGT3yASW+NDOcnEcmf/v9jYzVt3gbJ59vmSBosvYb2Gtvsi U38ekiESolRsls5AUVuEsvIYZ+3ncNF7DrQE5jTQQyOeXbQOlJSkPB4nGFPbQwIj5gwa ZD2H7U4QrNm/obGHew6Qg+rsZ8WVDVQU5s1Fj+ou9ACHl4YP8DksnU/msBh9FdAoaUFF arJg== X-Forwarded-Encrypted: i=1; AJvYcCVa/izjrk6jQLdoCriShBq7LtvJNKct+bhuOANkme9ahlu61SvV2j4ypg4VaM7m2ZtC2BqZqt2majfyxJg=@vger.kernel.org X-Gm-Message-State: AOJu0YyqkbSjeZ5AToymDApo6BqYaZ0Xc3nNY0CKzlHMggTpyCnRQbvP JkUttnYpjhdUloEjnCX7C13FjpRs700X0SiV+C3nmagr6W/bqWNnC0bVniP8/lX53Q4= X-Gm-Gg: ASbGnct9MDE68gt5Ba2dRLUB2/TX9t4RfWhEBcIC9jwHz1/M7uheZOHnImtpRKYB9MZ xyrbSH5bKO9mvzAKaJM3sGa404ou8Wzq6Dd5Fj9oNy6m3lXKnTCHYReBBNYKdOtStM0jurwS1vC k658LSxRQFEkXHAZZcwIjBlfWO7fzHet+HjflH80hzxD5g4iI2CbHd3lQ2htVJxE/qjak05FKGg e/jPfGc8+T9if9nGNcKavYi6ny1EL2/qazX4ZhKq/3QHDYa5eoo7+9QOz0eMjQQ62bHo252lM6o g4+L6a1tibnuPkD38zNjmQi/LUsA+MOq33+E4GqkrNWcNk2W4lTom4GvsQpi9KRudR6/fNaNHky KCuo+XItNbtBQbHVOIJoTumdkXTOdOXK5fzO+qm73xD9zrB6Ec1dinCNUy8E+T9U0uncFtrF4Kq vDEzLOeacdA4U2j6WUN4hfZuvpaxh7tPdy X-Google-Smtp-Source: AGHT+IHWFWMng59b4w4U1rlU2HcWmiW9XpOp5yfe1/AglWE2uY9Sbb4A7lkyow1PeMTpYULiYugI0A== X-Received: by 2002:a05:600c:458d:b0:479:2a09:9262 with SMTP id 5b1f17b1804b1-4792aeea47amr82087805e9.9.1764933196049; Fri, 05 Dec 2025 03:13:16 -0800 (PST) Received: from [192.168.0.101] ([90.240.106.137]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-42f7d2226c5sm8398656f8f.23.2025.12.05.03.13.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 05 Dec 2025 03:13:15 -0800 (PST) Message-ID: Date: Fri, 5 Dec 2025 11:13:15 +0000 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] drm/i195: Fix format string truncation warning To: Ard Biesheuvel Cc: Ard Biesheuvel , linux-kernel@vger.kernel.org, Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , David Airlie , Simona Vetter , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org References: <20251107164240.2023366-2-ardb+git@google.com> <14ca1b28-df1d-4065-ad7a-97a3ff81a5a4@ursulin.net> Content-Language: en-GB From: Tvrtko Ursulin In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 05/12/2025 10:48, Ard Biesheuvel wrote: > On Sun, 9 Nov 2025 at 19:00, Ard Biesheuvel wrote: >> >> On Sat, 8 Nov 2025 at 01:27, Tvrtko Ursulin wrote: >>> >>> >>> On 07/11/2025 16:42, Ard Biesheuvel wrote: >>>> From: Ard Biesheuvel >>>> >>>> GCC notices that the 16-byte uabi_name field could theoretically be too >>>> small for the formatted string if the instance number exceeds 100. >>>> >>>> Given that there are apparently ABI concerns here, this is the minimal >>>> fix that shuts up the compiler without changing the output or the >>>> maximum length for existing values < 100. >>> >>> What would be those ABI concerns? I don't immediately see any. >>>> drivers/gpu/drm/i915/intel_memory_region.c: In function ‘intel_memory_region_create’: >>>> drivers/gpu/drm/i915/intel_memory_region.c:273:61: error: ‘%u’ directive output may be truncated writing between 1 and 5 bytes into a region of size between 3 and 11 [-Werror=format-truncation=] >>>> 273 | snprintf(mem->uabi_name, sizeof(mem->uabi_name), "%s%u", >>>> | ^~ >>>> drivers/gpu/drm/i915/intel_memory_region.c:273:58: note: directive argument in the range [0, 65535] >>>> 273 | snprintf(mem->uabi_name, sizeof(mem->uabi_name), "%s%u", >>>> | ^~~~~~ >>>> drivers/gpu/drm/i915/intel_memory_region.c:273:9: note: ‘snprintf’ output between 7 and 19 bytes into a destination of size 16 >>>> 273 | snprintf(mem->uabi_name, sizeof(mem->uabi_name), "%s%u", >>>> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>>> 274 | intel_memory_type_str(type), instance); >>>> | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>>> >>>> Signed-off-by: Ard Biesheuvel >>>> --- >>>> Cc: Jani Nikula >>>> Cc: Joonas Lahtinen >>>> Cc: Rodrigo Vivi >>>> Cc: Tvrtko Ursulin >>>> Cc: David Airlie >>>> Cc: Simona Vetter >>>> Cc: intel-gfx@lists.freedesktop.org >>>> Cc: dri-devel@lists.freedesktop.org >>>> >>>> This is unlikely to be the right fix, but sending a wrong patch is >>>> usually a better way to elicit a response than just sending a bug >>>> report. >>>> >>>> drivers/gpu/drm/i915/intel_memory_region.c | 2 +- >>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>> >>>> diff --git a/drivers/gpu/drm/i915/intel_memory_region.c b/drivers/gpu/drm/i915/intel_memory_region.c >>>> index 59bd603e6deb..ad4afcf0c58a 100644 >>>> --- a/drivers/gpu/drm/i915/intel_memory_region.c >>>> +++ b/drivers/gpu/drm/i915/intel_memory_region.c >>>> @@ -271,7 +271,7 @@ intel_memory_region_create(struct drm_i915_private *i915, >>>> mem->instance = instance; >>>> >>>> snprintf(mem->uabi_name, sizeof(mem->uabi_name), "%s%u", >>>> - intel_memory_type_str(type), instance); >>>> + intel_memory_type_str(type), instance % 100); >>> It's a theoretical issue only since there is no hardware with a double >>> digit number of instances. >>> >>> But I guess much prettier fix would be to simply grow the buffer. >>> >> > > OK, so something like > > --- a/drivers/gpu/drm/i915/intel_memory_region.h > +++ b/drivers/gpu/drm/i915/intel_memory_region.h > @@ -72,7 +72,7 @@ struct intel_memory_region { > u16 instance; > enum intel_region_id id; > char name[16]; > - char uabi_name[16]; > + char uabi_name[20]; > bool private; /* not for userspace */ > > struct { Yes please. There is only two of those objects at majority of systems, and 3-4 on a few discrete cards supported by i915, so no big deal to grow them a tiny bit. >>> Also, hm, how come gcc does not find the mem->name vsnprintf from >>> intel_memory_region_set_name? >>> >> > > AFAICT, intel_memory_region_set_name() is never called with a format > string that could produce more than 15/16 bytes of output. Right, I reminded myself that the non-uabi visible name does not have the instance number in it. Regards, Tvrtko