From: Kees Cook <keescook@chromium.org>
To: Kalle Valo <kvalo@kernel.org>
Cc: Kees Cook <keescook@chromium.org>,
Johannes Berg <johannes.berg@intel.com>,
Max Chen <mxchen@codeaurora.org>,
Yang Shen <shenyang39@huawei.com>,
Steven Rostedt <rostedt@goodmis.org>,
"Matthew Wilcox (Oracle)" <willy@infradead.org>,
Christoph Hellwig <hch@lst.de>,
Justin Stitt <justinstitt@google.com>,
Kent Overstreet <kent.overstreet@linux.dev>,
Petr Mladek <pmladek@suse.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Arnd Bergmann <arnd@arndb.de>, Jonathan Corbet <corbet@lwn.net>,
Yun Zhou <yun.zhou@windriver.com>,
Jacob Keller <jacob.e.keller@intel.com>,
Zhen Lei <thunder.leizhen@huawei.com>,
linux-trace-kernel@vger.kernel.org,
linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org
Subject: [RFC][PATCH] wifi: wil6210: Replace strlcat() usage with seq_buf
Date: Thu, 26 Oct 2023 10:13:49 -0700 [thread overview]
Message-ID: <20231026171349.work.928-kees@kernel.org> (raw)
The use of strlcat() is fragile at best, and we'd like to remove it from
the available string APIs in the kernel. Instead, use the safer seq_buf
APIs.
Cc: Kalle Valo <kvalo@kernel.org>
Cc: Johannes Berg <johannes.berg@intel.com>
Cc: Max Chen <mxchen@codeaurora.org>
Cc: Yang Shen <shenyang39@huawei.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Justin Stitt <justinstitt@google.com>
Cc: Kent Overstreet <kent.overstreet@linux.dev>
Cc: Petr Mladek <pmladek@suse.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Yun Zhou <yun.zhou@windriver.com>
Cc: Jacob Keller <jacob.e.keller@intel.com>
Cc: Zhen Lei <thunder.leizhen@huawei.com>
Cc: linux-trace-kernel@vger.kernel.org
Cc: linux-wireless@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
This is mainly an example of where/how to use the ongoing seq_buf
refactoring happening in the tracing tree:
https://lore.kernel.org/lkml/20231026170722.work.638-kees@kernel.org/
---
drivers/net/wireless/ath/wil6210/wmi.c | 23 ++++++++++-------------
1 file changed, 10 insertions(+), 13 deletions(-)
diff --git a/drivers/net/wireless/ath/wil6210/wmi.c b/drivers/net/wireless/ath/wil6210/wmi.c
index 6fdb77d4c59e..45b8c651b8e2 100644
--- a/drivers/net/wireless/ath/wil6210/wmi.c
+++ b/drivers/net/wireless/ath/wil6210/wmi.c
@@ -3159,36 +3159,34 @@ int wmi_suspend(struct wil6210_priv *wil)
return rc;
}
-static void resume_triggers2string(u32 triggers, char *string, int str_size)
+static void resume_triggers2string(u32 triggers, struct seq_buf *s)
{
- string[0] = '\0';
-
if (!triggers) {
- strlcat(string, " UNKNOWN", str_size);
+ seq_buf_puts(s, " UNKNOWN");
return;
}
if (triggers & WMI_RESUME_TRIGGER_HOST)
- strlcat(string, " HOST", str_size);
+ seq_buf_puts(s, " HOST")
if (triggers & WMI_RESUME_TRIGGER_UCAST_RX)
- strlcat(string, " UCAST_RX", str_size);
+ seq_buf_puts(s, " UCAST_RX");
if (triggers & WMI_RESUME_TRIGGER_BCAST_RX)
- strlcat(string, " BCAST_RX", str_size);
+ seq_buf_puts(s, " BCAST_RX");
if (triggers & WMI_RESUME_TRIGGER_WMI_EVT)
- strlcat(string, " WMI_EVT", str_size);
+ seq_buf_puts(s, " WMI_EVT");
if (triggers & WMI_RESUME_TRIGGER_DISCONNECT)
- strlcat(string, " DISCONNECT", str_size);
+ seq_buf_puts(s, " DISCONNECT");
}
int wmi_resume(struct wil6210_priv *wil)
{
struct wil6210_vif *vif = ndev_to_vif(wil->main_ndev);
int rc;
- char string[100];
+ DECLARE_SEQ_BUF(s, 100);
struct {
struct wmi_cmd_hdr wmi;
struct wmi_traffic_resume_event evt;
@@ -3203,10 +3201,9 @@ int wmi_resume(struct wil6210_priv *wil)
WIL_WAIT_FOR_SUSPEND_RESUME_COMP);
if (rc)
return rc;
- resume_triggers2string(le32_to_cpu(reply.evt.resume_triggers), string,
- sizeof(string));
+ resume_triggers2string(le32_to_cpu(reply.evt.resume_triggers), s);
wil_dbg_pm(wil, "device resume %s, resume triggers:%s (0x%x)\n",
- reply.evt.status ? "failed" : "passed", string,
+ reply.evt.status ? "failed" : "passed", seq_buf_cstr(s),
le32_to_cpu(reply.evt.resume_triggers));
return reply.evt.status;
--
2.34.1
next reply other threads:[~2023-10-26 17:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-26 17:13 Kees Cook [this message]
2023-10-26 22:03 ` [RFC][PATCH] wifi: wil6210: Replace strlcat() usage with seq_buf Justin Stitt
2023-10-31 3:50 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231026171349.work.928-kees@kernel.org \
--to=keescook@chromium.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=arnd@arndb.de \
--cc=corbet@lwn.net \
--cc=gregkh@linuxfoundation.org \
--cc=hch@lst.de \
--cc=jacob.e.keller@intel.com \
--cc=johannes.berg@intel.com \
--cc=justinstitt@google.com \
--cc=kent.overstreet@linux.dev \
--cc=kvalo@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=mhiramat@kernel.org \
--cc=mxchen@codeaurora.org \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.org \
--cc=shenyang39@huawei.com \
--cc=thunder.leizhen@huawei.com \
--cc=willy@infradead.org \
--cc=yun.zhou@windriver.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.