Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2249035rdb; Wed, 21 Feb 2024 01:28:20 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWaV8tPk/8OJoNsa20A2z3KQd/tERw85YNulgBTszJTUBDKdpMm9n2tu/ZFPkCti/K2S4+UToqedO3eYUoqh3cP5ShNRr5Di4HhxyeNXQ== X-Google-Smtp-Source: AGHT+IHJdLquxoQvrdfIjXjKhzd/1EWL9N4Ewx96Ly+fQNuka8OTbJ18s2ISEkDhJwNY+6jlvDT0 X-Received: by 2002:a05:620a:29d2:b0:787:3f0e:ee22 with SMTP id s18-20020a05620a29d200b007873f0eee22mr19958882qkp.55.1708507700167; Wed, 21 Feb 2024 01:28:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708507700; cv=pass; d=google.com; s=arc-20160816; b=FElyDfAv3eIKzIjT3BAKpLmVY4VOOlkRUqcfDBb/DnQAcSF6nNElLMQIQoi1HX4CGx l1BsMR49IDGajj1zQZgYU5K/qdoHGgD0ts0mugNXU2oJ1zllPSID4bLC3gqzB4yN2tNz g/Cq0UvAZ5MYe+b80vo4TKJAf0RbeoQQsduoCLTuRgM8SXAIno6jTFL3z5udwAxbL1uE veUi3aG+9u56ToA75BMiQoQjIJJSBcgy09i+rbNCF3Ia7YyJ6i3XZqIK9aeVbSdcYYvX 62QAw/dIfAtVbkN6DMdSwmmwCk3X8JbOilI2yiPudzzGPPMoYrbgkEfappwwE7W1joMq wOow== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature; bh=eT/uH0qZq3eqCfd94wgAJ0+lZ7IXzMci6RxxltQCKcU=; fh=jIk4OCkX0GtJrKi542hJ2O4xoP9JsLYvdkXIiwqoswU=; b=dcyT8R8LvQlqAUgbuH7+6yas8abHdLSAPEywWjD75BjE/IysbB4q/cxNBrB12q48za agWdk9qkjG/st6damZxKuEvg1fIHPN4g6p3/s9L/N/hYV3Cm4lwu7KDDzutdrlsxCKGX 9AvPm2Y/LOvlP3+VIvERBgv31U+hhbvVtgQ2ZN7DPOJHI0nOmkH02usrhiijaNvguhVG MwY+KWpFMnw3Ebx4HFFcf+OePlrJSm0avzJGdf3Xt7BieuqfqAyZ2jvCfC1/LWff53of lM0nKslZVffXwZUIqqNkpYTKUT+tZ1iXBpCILib3Tzqz5KEyIZnxTLRjYSOtF79IlewS bj+Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=KGrfOqHQ; arc=pass (i=1 spf=pass spfdomain=flex--davidgow.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-74398-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74398-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id bk2-20020a05620a1a0200b00787268097dbsi11243755qkb.637.2024.02.21.01.28.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 01:28:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-74398-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=KGrfOqHQ; arc=pass (i=1 spf=pass spfdomain=flex--davidgow.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-74398-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74398-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id C61A11C21869 for ; Wed, 21 Feb 2024 09:28:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0CF203D0CA; Wed, 21 Feb 2024 09:28:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="KGrfOqHQ" Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (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 825443C494 for ; Wed, 21 Feb 2024 09:28:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708507684; cv=none; b=iXpXzRpJSgtg4t4SiUpzsnVd3POl9SzSk4FxZkVk0gsSJ4qEkQRK1OLOT9wv3RUgZ+vMPbuaY5okA3HAdkslCga13zkN4DxgO1s67YiUt5Ehs9xLl8lMvT+zO39x2pJJ4LaTQns4SGAA4faEtJLG2b8Dcp5Ml5u7UZPLORiHOgg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708507684; c=relaxed/simple; bh=rqOJUF9M6mrQc8dXD7M61zFQtSxp3b+ZbBeG2t6aQ78=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=a0VxXfYL2kiuyB00Oh6epBrj5SIK43GTSxti2B73G50K/YM1M5qvvYAiGEN+Gv548/DkQhqjrCZZSMh9oSQp+WaqS/t7SnXpwf4RSuS1t9xk3vKjqGlV5JYq4X62j4d/UTifmruHFXADjByCfWvpip2t1zWNouv56dMIPnhsmu4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--davidgow.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=KGrfOqHQ; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--davidgow.bounces.google.com Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dc6b26845cdso663246276.3 for ; Wed, 21 Feb 2024 01:28:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708507680; x=1709112480; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=eT/uH0qZq3eqCfd94wgAJ0+lZ7IXzMci6RxxltQCKcU=; b=KGrfOqHQz28RK8t77rt5ggx03KxOwAFzkpedVpi5057cKMpApzJygU4Zjxbktz584G pzqxZcplfxBJKKStCROql6+LlpHjEulo+NwsaS66AWIcNfNiFyMXg72DJHI9kAxkAwpD pjgwbVfBhM7xVRkBB1bdlqUIWkkb3TJ/O88666LvBVWwzVGcOB6BXvfjx/RZxCNLi7jJ 84ETuusGPKXg2Zwn0kK6WPg1CW5dpLKKbr9Hcs66so2YNmPhh2EjamJsxJ/rTIP2q8qX IoDqNKMITG2fR3csA4vkehNX+mQssYD3GEGKCsIWfnTZsCL4qeqqTBJZZ9P3ix5CPaJO tScg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708507680; x=1709112480; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=eT/uH0qZq3eqCfd94wgAJ0+lZ7IXzMci6RxxltQCKcU=; b=eByQe9v/a0RD/dSQSsGhlU+naatnAeOcoKgrES0vpju+UjnS3FHnYTCdhwjAPWZiza wEWZQl+T7ATpVbeckgE4JRkqFnmpk05BH+T3dY7uZ3ew3fxFoMrY60vBpShQXwXOFAIW AszbzJzdWIjWBAaDsqDTCTVzsh7E/+GafrIBgWng8Q6St0wNsibcgwpuiNouokzQBJqw YjmPF6LOwJXi8ZXgCIJJyS4qzwMwOeo47y7moDpTVqbrAaW55XmvKyW4SsCn0QhKsnfS c3NOU/m3VwkXPgjrF3kiGDG6R30hnh3+/wVkG5bKt7+OCIdWv1uffZembY+z/6S+Vc00 P49Q== X-Forwarded-Encrypted: i=1; AJvYcCXgyPLl6Llu9cJPukdVG98O1d2d05ItdwrOQPpIOw/GUYEcoLswDdl3e50tPFQ0gn4Uvw4a9ypTOu6+era8zvjbICJ6ayR4WwEVxYZT X-Gm-Message-State: AOJu0YzGiK4K/X6jhTdk4SxiJ/yDokuWDHcGn+eLs7gc+qZGf91ft8bX 48t4YpbUxh6OvW62o9i24RTEmtJpndl0PFT3c8tFL/Oo3SOY6RwGjx68yrT2zLMPX1qKCz40j+Y lpWIxwPqseg== X-Received: from slicestar.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:20a1]) (user=davidgow job=sendgmr) by 2002:a05:6902:188f:b0:dc6:dfc6:4207 with SMTP id cj15-20020a056902188f00b00dc6dfc64207mr4738387ybb.10.1708507680618; Wed, 21 Feb 2024 01:28:00 -0800 (PST) Date: Wed, 21 Feb 2024 17:27:13 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog Message-ID: <20240221092728.1281499-1-davidgow@google.com> Subject: [PATCH 0/9] kunit: Fix printf format specifier issues in KUnit assertions From: David Gow To: Linus Torvalds , Shuah Khan , Guenter Roeck , Rae Moar , Matthew Auld , Arunpravin Paneer Selvam , "=?UTF-8?q?Christian=20K=C3=B6nig?=" , Kees Cook , "=?UTF-8?q?Ma=C3=ADra=20Canal?=" , Rodrigo Vivi , Matthew Brost , Willem de Bruijn , Florian Westphal , Cassio Neri , Javier Martinez Canillas , Arthur Grillo Cc: David Gow , Brendan Higgins , Daniel Latypov , Stephen Boyd , David Airlie , Maxime Ripard , "David S . Miller" , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-xe@lists.freedesktop.org, linux-rtc@vger.kernel.org, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-hardening@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" KUnit has several macros which accept a log message, which can contain printf format specifiers. Some of these (the explicit log macros) already use the __printf() gcc attribute to ensure the format specifiers are valid, but those which could fail the test, and hence used __kunit_do_failed_assertion() behind the scenes, did not. These include: - KUNIT_EXPECT_*_MSG() - KUNIT_ASSERT_*_MSG() - KUNIT_FAIL() This series adds the __printf() attribute, and fixes all of the issues uncovered. (Or, at least, all of those I could find with an x86_64 allyesconfig, and the default KUnit config on a number of other architectures. Please test!) The issues in question basically take the following forms: - int / long / long long confusion: typically a type being updated, but the format string not. - Use of integer format specifiers (%d/%u/%li/etc) for types like size_t or pointer differences (technically ptrdiff_t), which would only work on some architectures. - Use of integer format specifiers in combination with PTR_ERR(), where %pe would make more sense. - Use of empty messages which, whilst technically not incorrect, are not useful and trigger a gcc warning. We'd like to get these (or equivalent) in for 6.9 if possible, so please do take a look if possible. Thanks, -- David Reported-by: Linus Torvalds Closes: https://lore.kernel.org/linux-kselftest/CAHk-=wgJMOquDO5f8ShH1f4rzZwzApNVCw643m5-Yj+BfsFstA@mail.gmail.com/ David Gow (9): kunit: test: Log the correct filter string in executor_test lib/cmdline: Fix an invalid format specifier in an assertion msg lib: memcpy_kunit: Fix an invalid format specifier in an assertion msg time: test: Fix incorrect format specifier rtc: test: Fix invalid format specifier. net: test: Fix printf format specifier in skb_segment kunit test drm: tests: Fix invalid printf format specifiers in KUnit tests drm/xe/tests: Fix printf format specifiers in xe_migrate test kunit: Annotate _MSG assertion variants with gnu printf specifiers drivers/gpu/drm/tests/drm_buddy_test.c | 14 +++++++------- drivers/gpu/drm/tests/drm_mm_test.c | 6 +++--- drivers/gpu/drm/xe/tests/xe_migrate.c | 8 ++++---- drivers/rtc/lib_test.c | 2 +- include/kunit/test.h | 12 ++++++------ kernel/time/time_test.c | 2 +- lib/cmdline_kunit.c | 2 +- lib/kunit/executor_test.c | 2 +- lib/memcpy_kunit.c | 4 ++-- net/core/gso_test.c | 2 +- 10 files changed, 27 insertions(+), 27 deletions(-) -- 2.44.0.rc0.258.g7320e95886-goog