From patchwork Fri Mar 21 14:40:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 14025590 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 849E91D86DC; Fri, 21 Mar 2025 14:48:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742568513; cv=none; b=JzFx/Q0gCFMDDlMuugdTN7wjU+g8TTtHx0WVB+obccH0/tf//RYicbLQbNtiAttBvlu8JysJEZTyymK5+wtqTY8mqZZ/felLgD6BDznIr3qMSTibTMsEE3Mic3cMNZsxtIKweNTknM7QOssmTYNES06G6mbOu0lrOFrcpOMRss8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742568513; c=relaxed/simple; bh=KSdjX0FfUSl7y+GxVDh/faeFQui6+tylS4V+elc6NWs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JX2C2b8CrqsWZtSjoG1QF/2pRyJC+q1IYWEe5wF0O5HqmKq6T+ttQFprmO/B756Kn4cicAxq7GzZkWvxmOQBFA2mPDWlvKP4lbtLOuVdhJKpHx5X4+fGN/OQFnnpi899q7IX/h8oTvwvnJE2vrpc4QgBVANsAENtT7oOMWCRXg8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=AHthgjjU; arc=none smtp.client-ip=198.175.65.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="AHthgjjU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1742568511; x=1774104511; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KSdjX0FfUSl7y+GxVDh/faeFQui6+tylS4V+elc6NWs=; b=AHthgjjU7GkBLYUgufiJshtoSXWq6/kU5mRxIg1XhnSrQDyKj4g9ZaHP EicP8o+2va8yYGAV9I5L/VRnZ5URlUioinQiWyYTVwCvZkJrgnIx6H0rF 6cEE9f7zKn0Ko4M+B7Rnq8DvbF9klOP0KkxL1RGC/WzZcsowB6/c/FV4J U82YdAhLzHZeLiL9VXXdkw9Ocir90CsnVPzaoWdKIRJC5v7gbxqb9mo4B 7c39A0pqun9Wc8BQ6uesI/n317EcjnYTlNQlf5TyrmXSLubWy9NI+dAc/ 1g02G5Q4oGwNFP/gBgsW4TLzVXER5t4koG1Ee0zeXNgwZs+umYba9XV4/ A==; X-CSE-ConnectionGUID: zXElSM94T8OV0F7ytdp+hg== X-CSE-MsgGUID: 6EXUNvlvQxuL79VL3Ezn0g== X-IronPort-AV: E=McAfee;i="6700,10204,11380"; a="54051589" X-IronPort-AV: E=Sophos;i="6.14,264,1736841600"; d="scan'208";a="54051589" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Mar 2025 07:48:29 -0700 X-CSE-ConnectionGUID: ptGMsh16Tv2UG1yupX3UwQ== X-CSE-MsgGUID: qFj2567SQxyr3o/bHGnpWg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,264,1736841600"; d="scan'208";a="123594414" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa008.fm.intel.com with ESMTP; 21 Mar 2025 07:48:25 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 2A54D214; Fri, 21 Mar 2025 16:48:24 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Christophe JAILLET , Kees Cook , Steven Rostedt , "Masami Hiramatsu (Google)" , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: Andy Shevchenko , Mathieu Desnoyers , Andrew Morton , Petr Mladek , Rasmus Villemoes , Sergey Senozhatsky Subject: [PATCH v2 1/6] seq_buf: Mark binary printing functions with __printf() attribute Date: Fri, 21 Mar 2025 16:40:47 +0200 Message-ID: <20250321144822.324050-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250321144822.324050-1-andriy.shevchenko@linux.intel.com> References: <20250321144822.324050-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Binary printing functions are using printf() type of format, and compiler is not happy about them as is: lib/seq_buf.c:162:17: error: function ‘seq_buf_bprintf’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format] Fix the compilation errors by adding __printf() attribute. Signed-off-by: Andy Shevchenko --- include/linux/seq_buf.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/seq_buf.h b/include/linux/seq_buf.h index fe41da005970..52791e070506 100644 --- a/include/linux/seq_buf.h +++ b/include/linux/seq_buf.h @@ -167,8 +167,8 @@ extern int seq_buf_hex_dump(struct seq_buf *s, const char *prefix_str, const void *buf, size_t len, bool ascii); #ifdef CONFIG_BINARY_PRINTF -extern int -seq_buf_bprintf(struct seq_buf *s, const char *fmt, const u32 *binary); +__printf(2, 0) +int seq_buf_bprintf(struct seq_buf *s, const char *fmt, const u32 *binary); #endif void seq_buf_do_printk(struct seq_buf *s, const char *lvl); From patchwork Fri Mar 21 14:40:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 14025589 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4308F1D63F5; Fri, 21 Mar 2025 14:48:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742568512; cv=none; b=gHYwZwzLQanK0QMvlHBmp++Tt4aDyeMfLtc+B6MMKm4ZxKvG4XjraeQfzEbxNYRANEDZiJ52pe6GJ6bCOHMMX5V8avwhTJyu6vFp0EYv0MIPmlAPHPYAS8keUiO8wFmffI0Uxhr+HpBwhVpTIfFy1RN7HEb38huhjYUIR4Ti1aQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742568512; c=relaxed/simple; bh=ZjSo7eVpfj+8bQUd8bOZ5xX/jg5b3oj1RsnbRQGEH9M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=l7hlcUlCqMP+vjQHjZjYvrrnkhfAYR3OU14hQqyYYUgtD6eCfYVa2eCYOjRLhOkJ9Wo4/LIDO71sExYSw5OfpSPQw7DxB29zg+JXreFNDRmSNtpa0L2hN7QfImWtAMxCxg6cqqs5CzpER6fSwT9RiwhmDKslwgzdNzs8I4Puo6Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Wgntf6aK; arc=none smtp.client-ip=198.175.65.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Wgntf6aK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1742568512; x=1774104512; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZjSo7eVpfj+8bQUd8bOZ5xX/jg5b3oj1RsnbRQGEH9M=; b=Wgntf6aKipvN1ivgUb/So8ugFe7bwMPMAZ1g5khdP4DxXFMP8DrByOzf qLzTpFAmj3KJ0y6lZwjZdLNG/e/jjovPWRx9BRKNtvgw9e+qhVhhRdENv +ef/QIKYOof3SnwDHkywIma9qipfQzOw7TW3Vg8hMimmSCG5fYzamFygN 8WWqL53T5uzYZZ8CrE1TFn7sGyTvqObxnQjzveYUxXo3hZCXoQkO3JCQ4 UahMCA0jUH2iMNokwGnWDJfM5IjSo49tiokfRPcpkYcwReQkt11seak6d 6EMIuvfTVO+OD2WjMVCHUaJmjzccCJ1k8u0NrDYEtMpbPvqp92OjSvKU8 Q==; X-CSE-ConnectionGUID: 97+tsq2/TK6Q5malYGPyaw== X-CSE-MsgGUID: Zs6+P1OZQgOZs6jT7HNSHQ== X-IronPort-AV: E=McAfee;i="6700,10204,11380"; a="43955845" X-IronPort-AV: E=Sophos;i="6.14,264,1736841600"; d="scan'208";a="43955845" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Mar 2025 07:48:29 -0700 X-CSE-ConnectionGUID: FFLmS4KmTE+MWxzWg0bcwA== X-CSE-MsgGUID: /oWpPbPXQKqKNQaw9/rT0w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,264,1736841600"; d="scan'208";a="128250098" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa003.jf.intel.com with ESMTP; 21 Mar 2025 07:48:25 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 3BE82663; Fri, 21 Mar 2025 16:48:24 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Christophe JAILLET , Kees Cook , Steven Rostedt , "Masami Hiramatsu (Google)" , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: Andy Shevchenko , Mathieu Desnoyers , Andrew Morton , Petr Mladek , Rasmus Villemoes , Sergey Senozhatsky Subject: [PATCH v2 2/6] seq_file: Mark binary printing functions with __printf() attribute Date: Fri, 21 Mar 2025 16:40:48 +0200 Message-ID: <20250321144822.324050-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250321144822.324050-1-andriy.shevchenko@linux.intel.com> References: <20250321144822.324050-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Binary printing functions are using printf() type of format, and compiler is not happy about them as is: fs/seq_file.c:418:35: error: function ‘seq_bprintf’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format] Fix the compilation errors by adding __printf() attribute. Signed-off-by: Andy Shevchenko --- include/linux/seq_file.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h index 2fb266ea69fa..d6ebf0596510 100644 --- a/include/linux/seq_file.h +++ b/include/linux/seq_file.h @@ -181,6 +181,7 @@ int seq_open_private(struct file *, const struct seq_operations *, int); int seq_release_private(struct inode *, struct file *); #ifdef CONFIG_BINARY_PRINTF +__printf(2, 0) void seq_bprintf(struct seq_file *m, const char *f, const u32 *binary); #endif From patchwork Fri Mar 21 14:40:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 14025588 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9DDCD1D5166; Fri, 21 Mar 2025 14:48:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742568511; cv=none; b=UaROkMEckOLIBtlikf0ZfM2mEubH2SGr23NwkHsI6oaNwrUai650CIXu6HL+IoeE2vFdi7RPFv2LohFNzzHlMonY2r8jUGdU2L+IMcePlQqeEx9i4jfmiP9OerponxcZTFKkqYx3dvZ71RF6gNZ0bvFt0Ftr507Cgr9PnizMa1w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742568511; c=relaxed/simple; bh=eddE4Az45J+CNVC8b/7OXbCIoBXO0ea/5BEW+nVzaw8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=W+89waawzHaWwj6irdS2+sgdmQ5xpqifcE5ra9Q/SIadnCAAd26nk2hBKk14SgfPjjtJ7LkV/4chmJSF6kxGhmDa11ddz9hyUg/Ii7ub9GhIJtkBRUxMiwRdm6VRF08pdvXxYvdpwlgox72ucv82p0ig+HETd9FbrPrAokIp14w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=LfbavYgh; arc=none smtp.client-ip=198.175.65.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="LfbavYgh" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1742568509; x=1774104509; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=eddE4Az45J+CNVC8b/7OXbCIoBXO0ea/5BEW+nVzaw8=; b=LfbavYghnYhdOqyT+pKReOkLC47GNpikW1KeGPX7AZqkDYzLDeKa+OPI s66HRek8N0tLwIiUZcwtJLm9DKfxkCQfDQGJhAf5iscc0e2KAAbB6xgVl g4t4RZkNF0bZF+5OIYPJYp4kP2rSeAYt6Va//cQQn/Ib0Cm9saw3T1btG ICvH8jwnpIF/Yf55np0Wwo0duccRIXu51vL4sCNXykSouIE5wGHH28crU EGs2hG1cuoAtDowqJHET7SLiSEP9sM70SZkHyTSwhlTRdcKHYFzbIHrWS p6WtHEzUFuo6uwffDIgARIi8K+nhrxi3YtYIKGAhUy/TyA4mjRo4vHjPP w==; X-CSE-ConnectionGUID: cXmCzn0CTSa+S7nTOWk6yw== X-CSE-MsgGUID: 2xS/alZrQbOmeaP5FO7ckA== X-IronPort-AV: E=McAfee;i="6700,10204,11380"; a="54051579" X-IronPort-AV: E=Sophos;i="6.14,264,1736841600"; d="scan'208";a="54051579" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Mar 2025 07:48:28 -0700 X-CSE-ConnectionGUID: 6TAWbJK4QXmevbI64IpCQw== X-CSE-MsgGUID: HOIG2mDcQvCaZeT5ljhcTw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,264,1736841600"; d="scan'208";a="123594413" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa008.fm.intel.com with ESMTP; 21 Mar 2025 07:48:25 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 4EE5E6D4; Fri, 21 Mar 2025 16:48:24 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Christophe JAILLET , Kees Cook , Steven Rostedt , "Masami Hiramatsu (Google)" , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: Andy Shevchenko , Mathieu Desnoyers , Andrew Morton , Petr Mladek , Rasmus Villemoes , Sergey Senozhatsky Subject: [PATCH v2 3/6] tracing: Mark binary printing functions with __printf() attribute Date: Fri, 21 Mar 2025 16:40:49 +0200 Message-ID: <20250321144822.324050-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250321144822.324050-1-andriy.shevchenko@linux.intel.com> References: <20250321144822.324050-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Binary printing functions are using printf() type of format, and compiler is not happy about them as is: kernel/trace/trace.c:3292:9: error: function ‘trace_vbprintk’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format] kernel/trace/trace_seq.c:182:9: error: function ‘trace_seq_bprintf’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format] Fix the compilation errors by adding __printf() attribute. While at it, move existing __printf() attributes from the implementations to the declarations. IT also fixes incorrect attribute parameters that are used for trace_array_printk(). Signed-off-by: Andy Shevchenko --- include/linux/trace.h | 4 ++-- include/linux/trace_seq.h | 8 ++++---- kernel/trace/trace.c | 11 +++-------- kernel/trace/trace.h | 16 +++++++++------- 4 files changed, 18 insertions(+), 21 deletions(-) diff --git a/include/linux/trace.h b/include/linux/trace.h index fdcd76b7be83..7eaad857dee0 100644 --- a/include/linux/trace.h +++ b/include/linux/trace.h @@ -72,8 +72,8 @@ static inline int unregister_ftrace_export(struct trace_export *export) static inline void trace_printk_init_buffers(void) { } -static inline int trace_array_printk(struct trace_array *tr, unsigned long ip, - const char *fmt, ...) +static inline __printf(3, 4) +int trace_array_printk(struct trace_array *tr, unsigned long ip, const char *fmt, ...) { return 0; } diff --git a/include/linux/trace_seq.h b/include/linux/trace_seq.h index 1ef95c0287f0..a93ed5ac3226 100644 --- a/include/linux/trace_seq.h +++ b/include/linux/trace_seq.h @@ -88,8 +88,8 @@ extern __printf(2, 3) void trace_seq_printf(struct trace_seq *s, const char *fmt, ...); extern __printf(2, 0) void trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args); -extern void -trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary); +extern __printf(2, 0) +void trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary); extern int trace_print_seq(struct seq_file *m, struct trace_seq *s); extern int trace_seq_to_user(struct trace_seq *s, char __user *ubuf, int cnt); @@ -113,8 +113,8 @@ static inline __printf(2, 3) void trace_seq_printf(struct trace_seq *s, const char *fmt, ...) { } -static inline void -trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary) +static inline __printf(2, 0) +void trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary) { } diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 0e6d517e74e0..989a3f54384a 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -3322,10 +3322,9 @@ int trace_vbprintk(unsigned long ip, const char *fmt, va_list args) } EXPORT_SYMBOL_GPL(trace_vbprintk); -__printf(3, 0) -static int -__trace_array_vprintk(struct trace_buffer *buffer, - unsigned long ip, const char *fmt, va_list args) +static __printf(3, 0) +int __trace_array_vprintk(struct trace_buffer *buffer, + unsigned long ip, const char *fmt, va_list args) { struct ring_buffer_event *event; int len = 0, size; @@ -3375,7 +3374,6 @@ __trace_array_vprintk(struct trace_buffer *buffer, return len; } -__printf(3, 0) int trace_array_vprintk(struct trace_array *tr, unsigned long ip, const char *fmt, va_list args) { @@ -3405,7 +3403,6 @@ int trace_array_vprintk(struct trace_array *tr, * Note, trace_array_init_printk() must be called on @tr before this * can be used. */ -__printf(3, 0) int trace_array_printk(struct trace_array *tr, unsigned long ip, const char *fmt, ...) { @@ -3450,7 +3447,6 @@ int trace_array_init_printk(struct trace_array *tr) } EXPORT_SYMBOL_GPL(trace_array_init_printk); -__printf(3, 4) int trace_array_printk_buf(struct trace_buffer *buffer, unsigned long ip, const char *fmt, ...) { @@ -3466,7 +3462,6 @@ int trace_array_printk_buf(struct trace_buffer *buffer, return ret; } -__printf(2, 0) int trace_vprintk(unsigned long ip, const char *fmt, va_list args) { return trace_array_vprintk(printk_trace, ip, fmt, args); diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 9c21ba45b7af..447d4f2a7fd2 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h @@ -836,13 +836,15 @@ static inline void __init disable_tracing_selftest(const char *reason) extern void *head_page(struct trace_array_cpu *data); extern unsigned long long ns2usecs(u64 nsec); -extern int -trace_vbprintk(unsigned long ip, const char *fmt, va_list args); -extern int -trace_vprintk(unsigned long ip, const char *fmt, va_list args); -extern int -trace_array_vprintk(struct trace_array *tr, - unsigned long ip, const char *fmt, va_list args); + +__printf(2, 0) +int trace_vbprintk(unsigned long ip, const char *fmt, va_list args); +__printf(2, 0) +int trace_vprintk(unsigned long ip, const char *fmt, va_list args); +__printf(3, 0) +int trace_array_vprintk(struct trace_array *tr, + unsigned long ip, const char *fmt, va_list args); +__printf(3, 4) int trace_array_printk_buf(struct trace_buffer *buffer, unsigned long ip, const char *fmt, ...); void trace_printk_seq(struct trace_seq *s); From patchwork Fri Mar 21 14:40:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 14025591 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A7431D88A4; Fri, 21 Mar 2025 14:48:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742568513; cv=none; b=AJ+OKme0hp0235LtRi1HGKTrbVE1Lcwj4m2cZ7j2vhcsSFTVOAvu055283nmv6bqJrGYERUJ70iyLMAP0IHt03uIWzEmxICdcWQm8N3g9dlSLjODMk/aZsQIVlTYEaf4mTJpCIfkSdvZRYBdsU53k3VKHQjJ9m0s3eWgjaTGXPg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742568513; c=relaxed/simple; bh=qPhdBccUurWZ8vX2YNRN+CZDAIh2aFQ2W5yHmydtpBc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bikO88no369Yn2BbWKSJ53/zIGqZDtMfYgDLEYHn84HcpDsDlSBeRrlRIrmgoGmNYTggdhtr0x7i7LFskLGGrIt2HEEa4K+0QgrvDLTHn9dJFuaUZgvALUtJxtXu6rTnSkp6bC9EDQQGxiLfzInLp4KqBWY9Rt2pqmaEXtwP2Qk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=CqeTL/i6; arc=none smtp.client-ip=198.175.65.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="CqeTL/i6" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1742568512; x=1774104512; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qPhdBccUurWZ8vX2YNRN+CZDAIh2aFQ2W5yHmydtpBc=; b=CqeTL/i6WstPnp4hbjC6ijyvkUqNJlQIRlfeTsZ6s/WzvjUZM1vyo2lc +5YtBihTSCGajMdkRNFja8+KUSSg2crQaBSlDYLRJOxjBxpSeRt04RBXz oS6fCv4XMIDaYucDTzdJmCPaBsNP8l1HC/6CW9ihCi63p5kyenAmo4+oX FdJ7REDsO8OU3EkAH+a/O3sG0dkWkM11Pa78cxymaDydAEofYik3dENF4 cu+3orTsyAz6xetAwSmhL+YJtHEzJ5ItXnLEbEQtfIEU6+jztVQvzSiIL GnSst1bMrwk9ZWt432FVfzfSJG3N157km7QQsa5KFUIzw39YDaT7cZovw A==; X-CSE-ConnectionGUID: V47erTjtQ/aDrLSX2ply6w== X-CSE-MsgGUID: PowIal8FSKCZTXe+T0xaog== X-IronPort-AV: E=McAfee;i="6700,10204,11380"; a="43955856" X-IronPort-AV: E=Sophos;i="6.14,264,1736841600"; d="scan'208";a="43955856" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Mar 2025 07:48:29 -0700 X-CSE-ConnectionGUID: tR0FNL3rT5CHMFDHUreADw== X-CSE-MsgGUID: YBgxQtSKRZeBnT9jt7W0rA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,264,1736841600"; d="scan'208";a="128250099" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa003.jf.intel.com with ESMTP; 21 Mar 2025 07:48:25 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 5FA57708; Fri, 21 Mar 2025 16:48:24 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Christophe JAILLET , Kees Cook , Steven Rostedt , "Masami Hiramatsu (Google)" , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: Andy Shevchenko , Mathieu Desnoyers , Andrew Morton , Petr Mladek , Rasmus Villemoes , Sergey Senozhatsky Subject: [PATCH v2 4/6] vsnprintf: Mark binary printing functions with __printf() attribute Date: Fri, 21 Mar 2025 16:40:50 +0200 Message-ID: <20250321144822.324050-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250321144822.324050-1-andriy.shevchenko@linux.intel.com> References: <20250321144822.324050-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Binary printf() functions are using printf() type of format, and compiler is not happy about them as is: lib/vsprintf.c:3130:47: error: function ‘vbin_printf’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format] lib/vsprintf.c:3298:33: error: function ‘bstr_printf’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format] Fix the compilation errors by adding __printf() attribute. Signed-off-by: Andy Shevchenko --- include/linux/string.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/string.h b/include/linux/string.h index f8e21e80942f..f15696e8e4d4 100644 --- a/include/linux/string.h +++ b/include/linux/string.h @@ -336,8 +336,8 @@ int __sysfs_match_string(const char * const *array, size_t n, const char *s); #define sysfs_match_string(_a, _s) __sysfs_match_string(_a, ARRAY_SIZE(_a), _s) #ifdef CONFIG_BINARY_PRINTF -int vbin_printf(u32 *bin_buf, size_t size, const char *fmt, va_list args); -int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf); +__printf(3, 0) int vbin_printf(u32 *bin_buf, size_t size, const char *fmt, va_list args); +__printf(3, 0) int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf); #endif extern ssize_t memory_read_from_buffer(void *to, size_t count, loff_t *ppos, From patchwork Fri Mar 21 14:40:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 14025592 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8CB47225387; Fri, 21 Mar 2025 14:48:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742568515; cv=none; b=giwKghD1yS9MNEF3NqMBz2M7QZ0Gfx0u4/AAtp/T6l2orVaPpf4CL9u9oIfQClLutl9Qr4KWanUZ46GGRdXFn9LLBXP0Ec71bEO3VVSPHc1N72XyNRH0Bhdg47zyE+8QOXMwZdwQuelkuzPNLu4ZJZKeY1iFZqz8cTgf52wVpkI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742568515; c=relaxed/simple; bh=Na8tB43VtqlJupW8wV1IfANzSElg1383772Apvo0nrY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JX3vleWAzEKtU3pyfyzNmXm5yeQJu/Xr2f4nDFpTWiYDCIwzNtCRISnmd1A0DgR9IzYBrFaFKl/QSK2BFqFE8rjnYT/0/RZimeDUgjoE6HYaBX5YuuB5ncczf1Aeb7/ACnpuqsV1loe7kAc7+h9+HP53xsFwsgV73W1G0g3E7NA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=UfsRMnTT; arc=none smtp.client-ip=198.175.65.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="UfsRMnTT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1742568513; x=1774104513; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Na8tB43VtqlJupW8wV1IfANzSElg1383772Apvo0nrY=; b=UfsRMnTTyl+39B47I1FQD0q/ot929A3/CjQsGla6dHmG837d8vlxzxij uDdAGnGLP2PRggOsR7Bdj+PFVMwdCS3C67CMJGleapX9s11bMH+3f9qRT rCLgfprWbfj3gA1N1hAdDbLDSeChNhs5d/iGXnZEDvqGOyWRorkJc7obY riQGSLoMUQBM6F64xjaHtFtgA2rHTgYh+u2noCPoKYFVZQPtMXJcKHNvK UVcc4yMWz9FJb+LYbWX1hVFPovd56YXyWQ1Cs+yLy/YVQhNVrI5GKPy2M m8goa1QMpJ9A9H5iTKHC4bQb+jK0gvW8+pDlzmTBHN6aSBlOGReGpqjkJ g==; X-CSE-ConnectionGUID: K2tCvh/qRsenadyo8Qzcng== X-CSE-MsgGUID: CRg5h7x8RCqtjODLOCayUw== X-IronPort-AV: E=McAfee;i="6700,10204,11380"; a="54051601" X-IronPort-AV: E=Sophos;i="6.14,264,1736841600"; d="scan'208";a="54051601" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Mar 2025 07:48:33 -0700 X-CSE-ConnectionGUID: 6HSOltahRJiClIsozq5QGA== X-CSE-MsgGUID: PDQtDl5dQaCTPovu4pm4pA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,264,1736841600"; d="scan'208";a="123594439" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa008.fm.intel.com with ESMTP; 21 Mar 2025 07:48:29 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 70C16720; Fri, 21 Mar 2025 16:48:24 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Christophe JAILLET , Kees Cook , Steven Rostedt , "Masami Hiramatsu (Google)" , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: Andy Shevchenko , Mathieu Desnoyers , Andrew Morton , Petr Mladek , Rasmus Villemoes , Sergey Senozhatsky , Rasmus Villemoes Subject: [PATCH v2 5/6] vsnprintf: Drop unused const char fmt * in va_format() Date: Fri, 21 Mar 2025 16:40:51 +0200 Message-ID: <20250321144822.324050-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250321144822.324050-1-andriy.shevchenko@linux.intel.com> References: <20250321144822.324050-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 va_format() doesn't use original formatting string, drop that argument as it's done elsewhere in similar cases. Suggested-by: Rasmus Villemoes Signed-off-by: Andy Shevchenko --- lib/vsprintf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 56fe96319292..899e14e4c469 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -1693,7 +1693,7 @@ char *escaped_string(char *buf, char *end, u8 *addr, struct printf_spec spec, } static char *va_format(char *buf, char *end, struct va_format *va_fmt, - struct printf_spec spec, const char *fmt) + struct printf_spec spec) { va_list va; @@ -2462,7 +2462,7 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr, case 'U': return uuid_string(buf, end, ptr, spec, fmt); case 'V': - return va_format(buf, end, ptr, spec, fmt); + return va_format(buf, end, ptr, spec); case 'K': return restricted_pointer(buf, end, ptr, spec); case 'N': From patchwork Fri Mar 21 14:40:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 14025593 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D6B08226CF8; Fri, 21 Mar 2025 14:48:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742568515; cv=none; b=N7A9uZ/2w81SFI5Kz/fFa8rpEtHD1na4cvIwICF11dDSNA6PnYLkS943YSs6Hj4qYye/raAn2qfX5/bYFd5Ayyuoyim8B3j2l6h8aPopsg2BbXkzbTvZb5bMPkB6RfSizPx8LY5NEKqPjaoTsQEmZDlXG456OxNeChfKiG7KZK0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742568515; c=relaxed/simple; bh=ZXYi5+hCwMt9VL0lN6Wi5OSskYXnANBgk5fZgVkMnCU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PlqFFYKUbMuZUZenyrRt+4L41RgHgl+m+CTigquQcm778z+gff3zmD2z61gUILuuXuErgRl3J1gj4P7+O5cRZ8Jsp92BDVIBXlEm9n2Hw2tUoI3ZI8D/iCeMi80DOIVoMjF6x2onp21O3SWZfSvS1C0WCuYNE5c0xduOo+/5vxU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=CLv7PsKg; arc=none smtp.client-ip=192.198.163.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="CLv7PsKg" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1742568514; x=1774104514; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZXYi5+hCwMt9VL0lN6Wi5OSskYXnANBgk5fZgVkMnCU=; b=CLv7PsKgItmLe/tZJOXxnx4C11DnBJ/a6M6UjWYILqXD1tYy4KMo7qdR Rlo2wOWdnHXEVr4adlaFoviPZvXfnFvObSjppLItR2DuWEPqC1x/tPwFl hXVg23qFpXl/wEmnkRtgK/kGkx+90l1X4AsL9ti/XQLjWXwHJTR+eyS1A CncOkYtEpCALPAwTd048/i2K/vMGiOsV375daIZIiXpzsq4M+BWNfkwTs b1OZA3oofnDu912NtSAge0F6mzODI5kc/SPXD3JX9olYEekFyXeKti81A t4ZZsz3T75IJG8vLtIk5DzCUIaa3cdsFwmOvH6WySuE7oV/foIvA5TH4t Q==; X-CSE-ConnectionGUID: 9Y2NKSTpQu+uUeScA9zNmQ== X-CSE-MsgGUID: uo8goeKIQoC6UZZ/MUkKWQ== X-IronPort-AV: E=McAfee;i="6700,10204,11380"; a="43962530" X-IronPort-AV: E=Sophos;i="6.14,264,1736841600"; d="scan'208";a="43962530" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Mar 2025 07:48:33 -0700 X-CSE-ConnectionGUID: CkKTOcn0RAmW5fcNUnj1SA== X-CSE-MsgGUID: nkf0lf1oTwCLgPMuuEmavg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,264,1736841600"; d="scan'208";a="123880127" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa010.fm.intel.com with ESMTP; 21 Mar 2025 07:48:29 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 822BC85F; Fri, 21 Mar 2025 16:48:24 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Christophe JAILLET , Kees Cook , Steven Rostedt , "Masami Hiramatsu (Google)" , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: Andy Shevchenko , Mathieu Desnoyers , Andrew Morton , Petr Mladek , Rasmus Villemoes , Sergey Senozhatsky , Rasmus Villemoes Subject: [PATCH v2 6/6] vsnprintf: Silence false positive GCC warning for va_format() Date: Fri, 21 Mar 2025 16:40:52 +0200 Message-ID: <20250321144822.324050-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250321144822.324050-1-andriy.shevchenko@linux.intel.com> References: <20250321144822.324050-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 va_format() is using vsnprintf(), and GCC compiler (Debian 14.2.0-17) is not happy about this: lib/vsprintf.c:1704:9: error: function ‘va_format’ might be a candidate for ‘gnu_print ’ format attribute [-Werror=suggest-attribute=format] Fix the compilation errors (`make W=1` when CONFIG_WERROR=y, which is default) by silencing the false positive GCC warning. Suggested-by: Rasmus Villemoes Signed-off-by: Andy Shevchenko --- lib/vsprintf.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 899e14e4c469..a55e88895a64 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -1692,6 +1692,10 @@ char *escaped_string(char *buf, char *end, u8 *addr, struct printf_spec spec, return buf; } +#pragma GCC diagnostic push +#ifndef __clang__ +#pragma GCC diagnostic ignored "-Wsuggest-attribute=format" +#endif static char *va_format(char *buf, char *end, struct va_format *va_fmt, struct printf_spec spec) { @@ -1706,6 +1710,7 @@ static char *va_format(char *buf, char *end, struct va_format *va_fmt, return buf; } +#pragma GCC diagnostic pop static noinline_for_stack char *uuid_string(char *buf, char *end, const u8 *addr,