From: Alexander Aring <aahringo@redhat.com>
To: teigland@redhat.com
Cc: cluster-devel@redhat.com, gfs2@lists.linux.dev, stable@vger.kernel.org
Subject: [Cluster-devel] [PATCH dlm/next 5/6] dlm: fix string may be truncated
Date: Wed, 6 Sep 2023 10:31:52 -0400 [thread overview]
Message-ID: <20230906143153.1353077-5-aahringo@redhat.com> (raw)
In-Reply-To: <20230906143153.1353077-1-aahringo@redhat.com>
This patch is fixing the following compiler warning when compiling with
-Wformat-truncation:
fs/dlm/debug_fs.c:1031:50: warning: '_queued_asts' directive output may
be truncated writing 12 bytes into a region of size between 8 and 72
We simple increase the additional amount of bytes to 13 because
_queued_asts does not fit into 8 bytes when the whole lockspace name
length is being used.
Fixes: 541adb0d4d10 ("fs: dlm: debugfs for queued callbacks")
Signed-off-by: Alexander Aring <aahringo@redhat.com>
---
fs/dlm/debug_fs.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/fs/dlm/debug_fs.c b/fs/dlm/debug_fs.c
index 5aabcb6f0f15..698d6b7a20f8 100644
--- a/fs/dlm/debug_fs.c
+++ b/fs/dlm/debug_fs.c
@@ -20,6 +20,7 @@
#include "lock.h"
#include "ast.h"
+#define DLM_DEBUG_NAME_LEN (DLM_LOCKSPACE_LEN + 13)
#define DLM_DEBUG_BUF_LEN 4096
static char debug_buf[DLM_DEBUG_BUF_LEN];
static struct mutex debug_buf_lock;
@@ -973,7 +974,7 @@ void dlm_delete_debug_comms_file(void *ctx)
void dlm_create_debug_file(struct dlm_ls *ls)
{
- char name[DLM_LOCKSPACE_LEN + 8];
+ char name[DLM_DEBUG_NAME_LEN];
/* format 1 */
@@ -986,7 +987,7 @@ void dlm_create_debug_file(struct dlm_ls *ls)
/* format 2 */
memset(name, 0, sizeof(name));
- snprintf(name, DLM_LOCKSPACE_LEN + 8, "%s_locks", ls->ls_name);
+ snprintf(name, DLM_DEBUG_NAME_LEN, "%s_locks", ls->ls_name);
ls->ls_debug_locks_dentry = debugfs_create_file(name,
0644,
@@ -997,7 +998,7 @@ void dlm_create_debug_file(struct dlm_ls *ls)
/* format 3 */
memset(name, 0, sizeof(name));
- snprintf(name, DLM_LOCKSPACE_LEN + 8, "%s_all", ls->ls_name);
+ snprintf(name, DLM_DEBUG_NAME_LEN, "%s_all", ls->ls_name);
ls->ls_debug_all_dentry = debugfs_create_file(name,
S_IFREG | S_IRUGO,
@@ -1008,7 +1009,7 @@ void dlm_create_debug_file(struct dlm_ls *ls)
/* format 4 */
memset(name, 0, sizeof(name));
- snprintf(name, DLM_LOCKSPACE_LEN + 8, "%s_toss", ls->ls_name);
+ snprintf(name, DLM_DEBUG_NAME_LEN, "%s_toss", ls->ls_name);
ls->ls_debug_toss_dentry = debugfs_create_file(name,
S_IFREG | S_IRUGO,
@@ -1017,7 +1018,7 @@ void dlm_create_debug_file(struct dlm_ls *ls)
&format4_fops);
memset(name, 0, sizeof(name));
- snprintf(name, DLM_LOCKSPACE_LEN + 8, "%s_waiters", ls->ls_name);
+ snprintf(name, DLM_DEBUG_NAME_LEN, "%s_waiters", ls->ls_name);
ls->ls_debug_waiters_dentry = debugfs_create_file(name,
0644,
@@ -1028,7 +1029,7 @@ void dlm_create_debug_file(struct dlm_ls *ls)
/* format 5 */
memset(name, 0, sizeof(name));
- snprintf(name, DLM_LOCKSPACE_LEN + 8, "%s_queued_asts", ls->ls_name);
+ snprintf(name, DLM_DEBUG_NAME_LEN, "%s_queued_asts", ls->ls_name);
ls->ls_debug_queued_asts_dentry = debugfs_create_file(name,
0644,
--
2.31.1
next prev parent reply other threads:[~2023-09-06 14:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-06 14:31 [Cluster-devel] [PATCH dlm/next 1/6] dlm: fix creating multiple node structures Alexander Aring
2023-09-06 14:31 ` [Cluster-devel] [PATCH dlm/next 2/6] dlm: fix remove member after close call Alexander Aring
2023-09-06 14:31 ` [Cluster-devel] [PATCH dlm/next 3/6] dlm: be sure we reset all nodes at forced shutdown Alexander Aring
2023-09-06 14:31 ` [Cluster-devel] [PATCH dlm/next 4/6] dlm: fix no ack after final message Alexander Aring
2023-09-06 14:31 ` Alexander Aring [this message]
2023-09-06 14:31 ` [Cluster-devel] [PATCH dlm/next 6/6] dlm: slow down filling up processing queue Alexander Aring
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=20230906143153.1353077-5-aahringo@redhat.com \
--to=aahringo@redhat.com \
--cc=cluster-devel@redhat.com \
--cc=gfs2@lists.linux.dev \
--cc=stable@vger.kernel.org \
--cc=teigland@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).