From patchwork Thu Mar 20 18:04:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 14024331 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 63F86226CF9; Thu, 20 Mar 2025 18:09:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742494177; cv=none; b=TnmSlqxFufZMfItubCpeLEnY0YEXiZapDwwtFZ5+0E9jHuPeklgP7Atr6AT6xX2IClLysDQUDNhfMY6Crh7kQBfVmFpd5s8Fvx6KBiKQ9DjcLH6dhaRWltIpI4l+MK5TQ0mTpL3XbYCE6iC6pk/g+TMAocez5H6hFs9gHdi6o1w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742494177; 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=oU5jCGcnB4G8hFeBMznLicYMYT3CJTXw9xyzawlsd/EJj0qTu67vvwS/QjGExOs6ENO4wu4v/GnmtK5FF2aAuJiXL4s96fklb5QuKv0pmPB1Zn9KBGWMZjyNi1TrzagC9BHzRu+Xi2A5ooZBr9hcW6CkrnN/TSfnxN9UpnbmU44= 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=SQDbvkg6; arc=none smtp.client-ip=198.175.65.9 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="SQDbvkg6" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1742494175; x=1774030175; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KSdjX0FfUSl7y+GxVDh/faeFQui6+tylS4V+elc6NWs=; b=SQDbvkg6NyGd/2VX/wJZUfhCgXxpRo3VFOb7tkTi9nIFEouugb8GhrxY E/DzhUsnGO6RCmZYMw0h0R7XIvlayQsxRXdA7W8bcxCY4rd+CWmZ0xVBP NBzyVA6dQoU+64ADKOYBfW2yjYv9W/0pm+LEGQX0HJoClF8babJ8qCtT7 4IDea+6cFIVE3KeCaXS60hhASBib1Gj7Zf7kSowQCfS1/TEtYYgR0E+R6 23zAgzoM35iKRF8mM1Ksvv9ZvJFFRs+AHPtT+e/wYF+i3u85R6VQpUZ+s d+ofsTJIEYA7fktci+7AZlgoQxCOSz7oYLashYxtK0Ywsq7Whxv4jJmNv Q==; X-CSE-ConnectionGUID: tSK0cLZVSCuSl9/CQP1e7w== X-CSE-MsgGUID: S/H8pdHmQzi2cDheoWCf5g== X-IronPort-AV: E=McAfee;i="6700,10204,11379"; a="66208809" X-IronPort-AV: E=Sophos;i="6.14,262,1736841600"; d="scan'208";a="66208809" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2025 11:09:32 -0700 X-CSE-ConnectionGUID: Q3uWJba8ShmIoJZ26CMBow== X-CSE-MsgGUID: EXOOtSFjSzWVx27gaNKn7w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,262,1736841600"; d="scan'208";a="146405838" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa002.fm.intel.com with ESMTP; 20 Mar 2025 11:09:29 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 97B3A126; Thu, 20 Mar 2025 20:09:27 +0200 (EET) From: Andy Shevchenko To: Petr Mladek , 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: John Ogness , Sergey Senozhatsky , Andy Shevchenko , Mathieu Desnoyers , Andrew Morton , Rasmus Villemoes Subject: [PATCH v1 1/6] seq_buf: Mark binary printing functions with __printf() attribute Date: Thu, 20 Mar 2025 20:04:22 +0200 Message-ID: <20250320180926.4002817-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250320180926.4002817-1-andriy.shevchenko@linux.intel.com> References: <20250320180926.4002817-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 Thu Mar 20 18:04:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 14024328 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 47F3F226173; Thu, 20 Mar 2025 18:09:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742494175; cv=none; b=oL+Q9tcVC5A/j/O8HXSON3QOne+wo/iD+deuFXWHLq5IadnAJOxixnvVSWRaCynv1GK+Hw1a2G0s9FJElRcRWGVRy3urenphjUhwd6/ac2ZInh49+Wi6CYwmn+uxL3U1DD59cRAs3F8a8u7fUtvtwUeh3DD8lfyB0JOSz3Cov4E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742494175; c=relaxed/simple; bh=ZjSo7eVpfj+8bQUd8bOZ5xX/jg5b3oj1RsnbRQGEH9M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LQcoSwos/X+N+QdtP8iz/bvPc2tHJ1lXIW0Lg9sGgmrWOJHB5gWzIpE7HLHb5QFbsjct7KLJeU6XJcGuRFE57hlGfyw1P83D31oPOTpLPr/80zKcNc70LclHKzOIzJyPei5lH30vQD0MKAnGtDC1tDdkXkJZx+RYM8gmZjH/Oy0= 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=nhI7RhMw; arc=none smtp.client-ip=198.175.65.9 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="nhI7RhMw" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1742494173; x=1774030173; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZjSo7eVpfj+8bQUd8bOZ5xX/jg5b3oj1RsnbRQGEH9M=; b=nhI7RhMw3WoFS59rb221ncNv3qM73xE680L3ljrqwWVGoZBLLOS7k6Tg idSkqQcSXszzmsMSd4Ai+a/fzvnJoDXVcM3GKP1FWTj/bW9PcTIBUHcqZ il+yMKF1WfA3fbijlwOGYb3PGaI1QFOZqmx6FPsRiXUs7wj9dJQpAmuMt Tn/iazAKVJIsQvXN8TnH2ke1xoP5VOQ4PDvnBfFD9OSHN50IINAkIdoBr UH0TkA6n4OzwdOC5RsBFdq07d+NAzN51Xe5z+xEQQzLT0fdPJ2gI3e89e gb7o8xZBKpP9F+SwPpUBysGD7hDdL1yoU5+Zub7Gv4Wt2OXHmPnaTHyWb A==; X-CSE-ConnectionGUID: A5r6vbjpSxKVMpmpYOHrsQ== X-CSE-MsgGUID: jHqWRRWfQpOE+3RMSW6RJQ== X-IronPort-AV: E=McAfee;i="6700,10204,11379"; a="66208788" X-IronPort-AV: E=Sophos;i="6.14,262,1736841600"; d="scan'208";a="66208788" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2025 11:09:32 -0700 X-CSE-ConnectionGUID: qm5chT69RlW864m3IXdCuw== X-CSE-MsgGUID: bix4mCOxR7eM5F5LNBk5FQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,262,1736841600"; d="scan'208";a="146405835" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa002.fm.intel.com with ESMTP; 20 Mar 2025 11:09:29 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id A712C2A7; Thu, 20 Mar 2025 20:09:27 +0200 (EET) From: Andy Shevchenko To: Petr Mladek , 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: John Ogness , Sergey Senozhatsky , Andy Shevchenko , Mathieu Desnoyers , Andrew Morton , Rasmus Villemoes Subject: [PATCH v1 2/6] seq_file: Mark binary printing functions with __printf() attribute Date: Thu, 20 Mar 2025 20:04:23 +0200 Message-ID: <20250320180926.4002817-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250320180926.4002817-1-andriy.shevchenko@linux.intel.com> References: <20250320180926.4002817-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 Thu Mar 20 18:04:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 14024329 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 47EDC225A59; Thu, 20 Mar 2025 18:09:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742494175; cv=none; b=XYAPsM1KQG6D5keRU2PPHtb5KmB3sDPAyX7Adq8Ng+lH8Qyi3+gj77WI61pm8j+znIn0bSaHfimKf5kCFt9+14ZGXmO7PDYVwrMyE2lrBi2mMr1wEcVMNEmSXKu1+q/EJmHSNaPL0cFQhww/TJOOivY4kMx5i5HblUkWbGeUqpM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742494175; c=relaxed/simple; bh=Nro01uE35mEDJNYyleEIH0iraSqA4MVZyZeU5e/+IW0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZQg6igrXhV7LLuUTRljCOipqF4I8UPJJ4C23W3DzpgfcDYkGVakxgX5YqyUqfJtx2clja7QV85i4N/BTwBQt7xAiBR2d5FOPelSfQK4ts4BLaMlai+J2KAE+1ESW6NcDd1XEKTiunBQEqStRwX6KyGxXNFjo+rsoSqGz6iO59Os= 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=LgZMTs7z; arc=none smtp.client-ip=198.175.65.18 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="LgZMTs7z" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1742494173; x=1774030173; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Nro01uE35mEDJNYyleEIH0iraSqA4MVZyZeU5e/+IW0=; b=LgZMTs7ztH2YS4ewUCqnD7Cf3YTJhJNLctdxYxjhj1HdqjV02HY8W4to +VwaHbUwjV+E451TnESTxBBo24PpleihmfjmkfVDVIRYx8qRQJxsDU4be tLumNSUHVTZ2t3b8un9bhihAqv0GnscoGVNfKTe5fuXP7T7McQJwvbdcc UH686xWme+1ZP5ep7YuweIoEHQ6nK35PwcgRT0lK8TqCg3xFvjaw/xhNs 21hmgDtaZwqE+SZJlO1IDUc2Z0MYUO5PTVm/Zdy7defGEmxPxeHXfw1GL CzZVTSy17kvAwrevLxPJJKy5RTflzR3HFc8G7kTmh3AUoQV5m0W0UFeIV A==; X-CSE-ConnectionGUID: 1PPatObcRf+8lNyRo6DWOg== X-CSE-MsgGUID: T7MDYYK7Q16CK0ObbJ1ULA== X-IronPort-AV: E=McAfee;i="6700,10204,11379"; a="43913246" X-IronPort-AV: E=Sophos;i="6.14,262,1736841600"; d="scan'208";a="43913246" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2025 11:09:33 -0700 X-CSE-ConnectionGUID: efyg0u4iQ3eSrO4Ws/1T9g== X-CSE-MsgGUID: 3FFFB2h+StmpcfTXOpUp0w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,262,1736841600"; d="scan'208";a="123140148" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa010.jf.intel.com with ESMTP; 20 Mar 2025 11:09:28 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id B5D84747; Thu, 20 Mar 2025 20:09:27 +0200 (EET) From: Andy Shevchenko To: Petr Mladek , 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: John Ogness , Sergey Senozhatsky , Andy Shevchenko , Mathieu Desnoyers , Andrew Morton , Rasmus Villemoes Subject: [PATCH v1 3/6] tracing: Mark binary printing functions with __printf() attribute Date: Thu, 20 Mar 2025 20:04:24 +0200 Message-ID: <20250320180926.4002817-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250320180926.4002817-1-andriy.shevchenko@linux.intel.com> References: <20250320180926.4002817-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. Signed-off-by: Andy Shevchenko --- include/linux/trace_seq.h | 7 ++++--- kernel/trace/trace.c | 3 --- kernel/trace/trace.h | 16 +++++++++------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/include/linux/trace_seq.h b/include/linux/trace_seq.h index 1ef95c0287f0..7e69628092e4 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,7 +113,8 @@ static inline __printf(2, 3) void trace_seq_printf(struct trace_seq *s, const char *fmt, ...) { } -static inline void +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..6a29218ca210 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -3375,7 +3375,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) { @@ -3450,7 +3449,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 +3464,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 Thu Mar 20 18:04:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 14024332 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 A8515227BB6; Thu, 20 Mar 2025 18:09:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742494178; cv=none; b=JR7TP6Ne1IXfLpp5b/v4peFSVRHD5PgY+NRvkUJgTXhW32IkoSsUcvasWc3CeKtC9bSa9cfcwOrdd8kggwuU/9BfuYeofXTAoj1SCEHNA57NT4m9freVDEkPe2RA/UTGwz2Z48FoE9rx1bEH/o11JP8v38X4jMZj7UX5vr/MlCo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742494178; c=relaxed/simple; bh=qPhdBccUurWZ8vX2YNRN+CZDAIh2aFQ2W5yHmydtpBc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tqZUT3Vzuzz1K/x0GdJu0ioktK0AwsxJAxAjEVkoEzrP7kS+q2E2aYpKq44aXgfnpRRGA+MsDwjsIMULni9GPTmzWFuXPL/z6FZ7vCHTC9j//ydDmicJjPWQsixTXbBrWT4SNI9toZ+eC+LdWiG2Vr8Nd/UWyxlOXHqmrx4GRMc= 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=WhccJz05; arc=none smtp.client-ip=198.175.65.9 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="WhccJz05" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1742494176; x=1774030176; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qPhdBccUurWZ8vX2YNRN+CZDAIh2aFQ2W5yHmydtpBc=; b=WhccJz05WQTWlyqV5gsBtxf4tfP742y69GKljAegu3C25I3ucdcrgrG3 YbzqlBU/UdAkIEXmgeCUL+8i87JFxnpJrZkZCYv5kt4z63BK05ZPitKSO fOT7WEd5DcQtHan52vPxjS+j8oRUediNEDFhaQvh2XVot46C223VTyDyl a1ihZbmREapGniyngOVoOAGXzneTenw9zTpFcMOQlxv7Lbqv37l1Q5n5Y 7GABmSF5ZIf+OafxoQW7zRtQGtmWIXYXKWCSIXKIYws3Iy/rtk88ZSb/H wcPnGcVfPvtv5VM3N+Xp9OaEkJP6T72xaBfs4Joh9I/UkiWOVeMKvGoE+ Q==; X-CSE-ConnectionGUID: T3r/awbmQwuzcOkfdU/m4Q== X-CSE-MsgGUID: ozi8JU7TQzC4GcQ64qtfmA== X-IronPort-AV: E=McAfee;i="6700,10204,11379"; a="66208817" X-IronPort-AV: E=Sophos;i="6.14,262,1736841600"; d="scan'208";a="66208817" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2025 11:09:33 -0700 X-CSE-ConnectionGUID: MF2uH33yRI+KnmO3oYhzHQ== X-CSE-MsgGUID: 2vWPM9FYQt6OjDnL7cjJlA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,262,1736841600"; d="scan'208";a="146405837" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa002.fm.intel.com with ESMTP; 20 Mar 2025 11:09:29 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id C45927D2; Thu, 20 Mar 2025 20:09:27 +0200 (EET) From: Andy Shevchenko To: Petr Mladek , 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: John Ogness , Sergey Senozhatsky , Andy Shevchenko , Mathieu Desnoyers , Andrew Morton , Rasmus Villemoes Subject: [PATCH v1 4/6] vsnprintf: Mark binary printing functions with __printf() attribute Date: Thu, 20 Mar 2025 20:04:25 +0200 Message-ID: <20250320180926.4002817-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250320180926.4002817-1-andriy.shevchenko@linux.intel.com> References: <20250320180926.4002817-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 Thu Mar 20 18:04:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 14024333 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 7F6DD227EB6; Thu, 20 Mar 2025 18:09:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742494179; cv=none; b=ph6Pz9p7lJYd3p6b5BVtcGQQvE3+/oKsfLxHoryqalRunb4/RfDPzIeGy9QF2HMkPkw1+LNfItNrTcCexa58YMVp1MCCz6ZOpr4nrEDeQwX4MU9Mrd139NxWBkyWiftRfcxVOj7j1bhp1QGpnP6o4ikHE9/oudeytL41Swcby34= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742494179; c=relaxed/simple; bh=pQlyCusjB8gPAtS0tOzHj8Kweq7GyzmGdgfWs5InqJI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HlLan+TDe4zHThza7bqHWUm6FbPcC5g7jOpwBXaWuEGvEQJSaduPhFrGDXinKxHcc7gwXXmkAJ3533bQqPDRJbz3Ktq8MYmV/Lk5Pss1WGdZkhIetwvoo7hbul+a9IdnZsykUvD9y8E5UqgoXvrf7i8lPqJfN7nMFaj4CG4kGWc= 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=SSGZvQnu; arc=none smtp.client-ip=198.175.65.9 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="SSGZvQnu" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1742494177; x=1774030177; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pQlyCusjB8gPAtS0tOzHj8Kweq7GyzmGdgfWs5InqJI=; b=SSGZvQnuY8Zp0xd9gg4TkVIUTWi4ASX0us4wRTdcK+Lqqpg3MeHHFJMD D2U73SKvDU7DglUvXX4DFNOlIwq3AyMFwJZsEBDZ0CrqJLnWh3gSStTHM Zgt/Oz8/+phJPcwzbfp5qphT8Thva0WNigGpccN2LH9jGazNstHA97qg7 6ui8eohtkUqzo4KT9GdCgvuyXSbIXGePoP6M+0zQae/kk1zX8Rqklng6F gwYkvgvqIij1p6W7RUrwJjg09FMBTW5D198hn+axpmHcjHqJbwULsIIjB 67nVX9Jj/9ALo+vDLykR37jw4Iz/x3wQsLeUrVrmtFqLayx7HqPZsaQel A==; X-CSE-ConnectionGUID: 1M3Mvc1eQ6yzLHLBdywScA== X-CSE-MsgGUID: WSsKaYn4SpOZmUKFbYXG/g== X-IronPort-AV: E=McAfee;i="6700,10204,11379"; a="66208840" X-IronPort-AV: E=Sophos;i="6.14,262,1736841600"; d="scan'208";a="66208840" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2025 11:09:36 -0700 X-CSE-ConnectionGUID: IgwD9fy+TeCmsAPOY8aUYA== X-CSE-MsgGUID: ndWpyh7sRQSgDWsVOKzcfQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,262,1736841600"; d="scan'208";a="146405851" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa002.fm.intel.com with ESMTP; 20 Mar 2025 11:09:34 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id D21578B5; Thu, 20 Mar 2025 20:09:27 +0200 (EET) From: Andy Shevchenko To: Petr Mladek , 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: John Ogness , Sergey Senozhatsky , Andy Shevchenko , Mathieu Desnoyers , Andrew Morton , Rasmus Villemoes Subject: [PATCH v1 5/6] vsnprintf: Mark pointer() with __printf() attribute Date: Thu, 20 Mar 2025 20:04:26 +0200 Message-ID: <20250320180926.4002817-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250320180926.4002817-1-andriy.shevchenko@linux.intel.com> References: <20250320180926.4002817-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 pointer() is using printf() type of format, and GCC compiler (Debian 14.2.0-17) is not happy about this: lib/vsprintf.c:2466:17: error: function ‘pointer’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format] Fix the compilation errors (`make W=1` when CONFIG_WERROR=y, which is default) by adding __printf() attribute. Signed-off-by: Andy Shevchenko --- lib/vsprintf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 56fe96319292..8ebb5f866b08 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -2419,7 +2419,7 @@ char *rust_fmt_argument(char *buf, char *end, void *ptr); * from Rust code to format core::fmt::Arguments. Do *not* use it from C. * See rust/kernel/print.rs for details. */ -static noinline_for_stack +static noinline_for_stack __printf(1, 0) char *pointer(const char *fmt, char *buf, char *end, void *ptr, struct printf_spec spec) { From patchwork Thu Mar 20 18:04:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 14024334 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 4A289228CA9; Thu, 20 Mar 2025 18:09:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742494179; cv=none; b=K7o1OM0zxXAqACdtXsXkWfYb3heUiqyt70jlwS0OmFAIT0VYh/VnkxmhZqKtCGqQLZDL27JMrd3iGg5c8ohGCTyhFNmIdXTqtN0hidnsI1ZL3Lhm8MGKBbezaS/iI/VYa972QMOhjLPNkq6yW2/Fb3/7fB1/OBnOH8oZAcN1Des= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742494179; c=relaxed/simple; bh=B/IrAUEQScS6ZPsOJQ4R3YhljPCbyRabKcJDMFmRDeQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tvd5emxYTxs+7L4YnsmcA0K2vl+oflrujR4YMKDkC+fTHFjBJt6Sl2myj5s/aTi+InaDOsgAqUYvl9XpTzYsERYs/LTtXTMv4bUlEudSOt0oF53+pc2y6lZPye0Sd5aCPd0gp57Si7EdbIUM5RhDHSp8I7UI+OlfodjqJeL8eFU= 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=YWzHs6kc; arc=none smtp.client-ip=198.175.65.9 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="YWzHs6kc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1742494178; x=1774030178; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=B/IrAUEQScS6ZPsOJQ4R3YhljPCbyRabKcJDMFmRDeQ=; b=YWzHs6kck+k7i1+3vJoIT2SCj2+LsdLEIqPzmpXyKw0D90hySLy4wsrU SoKH2l3nkK8yVaPCStYwkqqqJoB66NA1o2GXbJKzq7C3fULWJOTFGALDR ghAH99xP1FGWP2Bvk13ZJjB5VlioUth/fZTvL21OOU6sVFttBZsTWI+3l XMBQOr/Su2q9VMo+ugKrj18ZliyQOimKfE+qyRYPisoPmHLbiJUG7H7IB mW48X3NNcSeKyA2XaNX5p8XczS9XtVcA0jj4MSX2UiAKUrmsyWACzdP50 7qmMFxrIoWAlZ9mA4ajiDXnNI7p8WI5SYFduJ9Cy7O0ft6bPNmqJ5MJRK w==; X-CSE-ConnectionGUID: 5r3QEwJiQvWgXqKBw0pk2g== X-CSE-MsgGUID: ugQFD39TQ2iKL9Hw2sLZVw== X-IronPort-AV: E=McAfee;i="6700,10204,11379"; a="66208853" X-IronPort-AV: E=Sophos;i="6.14,262,1736841600"; d="scan'208";a="66208853" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2025 11:09:37 -0700 X-CSE-ConnectionGUID: CHnv/ul0T6a72fTp0xFsGw== X-CSE-MsgGUID: WZmDiWoFQ6SBrvIt0IIw8g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,262,1736841600"; d="scan'208";a="146405852" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa002.fm.intel.com with ESMTP; 20 Mar 2025 11:09:34 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id DC0738B7; Thu, 20 Mar 2025 20:09:27 +0200 (EET) From: Andy Shevchenko To: Petr Mladek , 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: John Ogness , Sergey Senozhatsky , Andy Shevchenko , Mathieu Desnoyers , Andrew Morton , Rasmus Villemoes Subject: [PATCH v1 6/6] vsnprintf: Mark va_format() with __printf() attribute Date: Thu, 20 Mar 2025 20:04:27 +0200 Message-ID: <20250320180926.4002817-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250320180926.4002817-1-andriy.shevchenko@linux.intel.com> References: <20250320180926.4002817-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 printf() type of format, 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 adding __printf() attribute. This, unfortunately, requires to reconsider the type of the parameter used for that. That's why I added static_assert() and used explicit casting. Any other solution I tried failed with the similar or other error. Signed-off-by: Andy Shevchenko --- include/linux/printk.h | 5 ++++- lib/vsprintf.c | 7 ++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/include/linux/printk.h b/include/linux/printk.h index 4217a9f412b2..182d48b4930f 100644 --- a/include/linux/printk.h +++ b/include/linux/printk.h @@ -2,12 +2,13 @@ #ifndef __KERNEL_PRINTK__ #define __KERNEL_PRINTK__ -#include #include #include #include #include #include +#include +#include struct console; @@ -87,6 +88,8 @@ struct va_format { va_list *va; }; +static_assert(offsetof(struct va_format, fmt) == 0); + /* * FW_BUG * Add this to a message where you are sure the firmware is buggy or behaves diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 8ebb5f866b08..ebb3c563a7ee 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -1692,9 +1692,10 @@ char *escaped_string(char *buf, char *end, u8 *addr, struct printf_spec spec, return buf; } -static char *va_format(char *buf, char *end, struct va_format *va_fmt, - struct printf_spec spec, const char *fmt) +static __printf(3, 0) +char *va_format(char *buf, char *end, const char *fmt, struct printf_spec spec) { + struct va_format *va_fmt = (struct va_format *)fmt; va_list va; if (check_pointer(&buf, end, va_fmt, spec)) @@ -2462,7 +2463,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':