From 98fb057487a806303f93db3e0f746525ea487c59 Mon Sep 17 00:00:00 2001 From: Bob Peterson Date: Tue, 13 Aug 2019 09:25:15 -0400 Subject: [PATCH] gfs2: Fix possible fs name overflows This patch fixes three places in which temporary character buffers could overflow due to the addition of the file system id from patch 3792ce973f07. Thanks to Dan Carpenter for pointing it out. Signed-off-by: Bob Peterson Signed-off-by: Andreas Gruenbacher --- fs/gfs2/glock.c | 2 +- fs/gfs2/rgrp.c | 2 +- fs/gfs2/util.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index e23fb8b7b020e..a27dbd3dec011 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -1788,8 +1788,8 @@ void gfs2_dump_glock(struct seq_file *seq, struct gfs2_glock *gl, bool fsid) unsigned long long dtime; const struct gfs2_holder *gh; char gflags_buf[32]; - char fs_id_buf[GFS2_FSNAME_LEN + 3 * sizeof(int) + 2]; struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; + char fs_id_buf[sizeof(sdp->sd_fsname) + 7]; memset(fs_id_buf, 0, sizeof(fs_id_buf)); if (fsid && sdp) /* safety precaution */ diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index 49ac0a5e74ea7..2466bb44a23c5 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c @@ -2285,7 +2285,7 @@ void gfs2_rgrp_dump(struct seq_file *seq, struct gfs2_glock *gl, static void gfs2_rgrp_error(struct gfs2_rgrpd *rgd) { struct gfs2_sbd *sdp = rgd->rd_sbd; - char fs_id_buf[GFS2_FSNAME_LEN + 3 * sizeof(int) + 2]; + char fs_id_buf[sizeof(sdp->sd_fsname) + 7]; fs_warn(sdp, "rgrp %llu has an error, marking it readonly until umount\n", (unsigned long long)rgd->rd_addr); diff --git a/fs/gfs2/util.c b/fs/gfs2/util.c index 83f6c582773a5..c45159133d8ee 100644 --- a/fs/gfs2/util.c +++ b/fs/gfs2/util.c @@ -178,7 +178,7 @@ int gfs2_consist_rgrpd_i(struct gfs2_rgrpd *rgd, int cluster_wide, const char *function, char *file, unsigned int line) { struct gfs2_sbd *sdp = rgd->rd_sbd; - char fs_id_buf[GFS2_FSNAME_LEN + 3 * sizeof(int) + 2]; + char fs_id_buf[sizeof(sdp->sd_fsname) + 7]; int rv; sprintf(fs_id_buf, "fsid=%s: ", sdp->sd_fsname); -- 2.30.2