Re: [Cluster-devel] [PATCH RESEND 2/8] fs: dlm: Fix the size of a buffer in dlm_create_debug_file()
Greg KH <[email protected]> Wed, 11 Oct 2023 08:24:29 +0200
| Newsgroups | com.redhat.cluster-devel,dev.linux.lists.gfs2,org.kernel.vger.stable |
|---|---|
| Message-ID | <2023101124-overlying-gating-62c8@gregkh> |
On Tue, Oct 10, 2023 at 06:04:42PM -0400, Alexander Aring wrote: > From: Christophe JAILLET <[email protected]> >=20 > 8 is not the maximum size of the suffix used when creating debugfs files. >=20 > Let the compiler compute the correct size, and only give a hint about the > longest possible string that is used. >=20 > When building with W=3D1, this fixes the following warnings: >=20 > fs/dlm/debug_fs.c: In function =E2=80=98dlm_create_debug_file=E2=80=99: > fs/dlm/debug_fs.c:1020:58: error: =E2=80=98snprintf=E2=80=99 output may= be truncated before the last format character [-Werror=3Dformat-truncation= =3D] > 1020 | snprintf(name, DLM_LOCKSPACE_LEN + 8, "%s_waiters", ls-= >ls_name); > | ^ > fs/dlm/debug_fs.c:1020:9: note: =E2=80=98snprintf=E2=80=99 output betwe= en 9 and 73 bytes into a destination of size 72 > 1020 | snprintf(name, DLM_LOCKSPACE_LEN + 8, "%s_waiters", ls-= >ls_name); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~~~~~~~~~ > fs/dlm/debug_fs.c:1031:50: error: =E2=80=98_queued_asts=E2=80=99 direct= ive output may be truncated writing 12 bytes into a region of size between = 8 and 72 [-Werror=3Dformat-truncation=3D] > 1031 | snprintf(name, DLM_LOCKSPACE_LEN + 8, "%s_queued_asts",= ls->ls_name); > | ^~~~~~~~~~~~ > fs/dlm/debug_fs.c:1031:9: note: =E2=80=98snprintf=E2=80=99 output betwe= en 13 and 77 bytes into a destination of size 72 > 1031 | snprintf(name, DLM_LOCKSPACE_LEN + 8, "%s_queued_asts",= ls->ls_name); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~~~~~~~~~~~~~ >=20 > Fixes: 541adb0d4d10b ("fs: dlm: debugfs for queued callbacks") > Signed-off-by: Christophe JAILLET <[email protected]> > Signed-off-by: Alexander Aring <[email protected]> > --- > fs/dlm/debug_fs.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) >=20 > diff --git a/fs/dlm/debug_fs.c b/fs/dlm/debug_fs.c > index e9726c6cbdf2..c93359ceaae6 100644 > --- a/fs/dlm/debug_fs.c > +++ b/fs/dlm/debug_fs.c > @@ -973,7 +973,8 @@ void dlm_delete_debug_comms_file(void *ctx) > =20 > void dlm_create_debug_file(struct dlm_ls *ls) > { > -=09char name[DLM_LOCKSPACE_LEN + 8]; > +=09/* Reserve enough space for the longest file name */ > +=09char name[DLM_LOCKSPACE_LEN + sizeof("_queued_asts")]; > =20 > =09/* format 1 */ > =20 > --=20 > 2.39.3 >=20 <formletter> This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read: https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html for how to do this properly. </formletter>