From nobody Sun Apr 19 18:49:45 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B41AC43334 for ; Tue, 28 Jun 2022 06:00:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245197AbiF1GAm (ORCPT ); Tue, 28 Jun 2022 02:00:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235044AbiF1GAi (ORCPT ); Tue, 28 Jun 2022 02:00:38 -0400 Received: from hust.edu.cn (unknown [202.114.0.240]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51C322C67E for ; Mon, 27 Jun 2022 23:00:36 -0700 (PDT) Received: from localhost.localdomain ([172.16.0.254]) (user=dzm91@hust.edu.cn mech=LOGIN bits=0) by mx1.hust.edu.cn with ESMTP id 25S605dn024527-25S605dq024527 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 28 Jun 2022 14:00:10 +0800 From: Dongliang Mu To: Bob Peterson , Andreas Gruenbacher , Steven Whitehouse , Jean Delvare Cc: Dongliang Mu , syzkaller , cluster-devel@redhat.com, linux-kernel@vger.kernel.org Subject: [PATCH] gfs2: fix overread in the strlcpy of init_names Date: Tue, 28 Jun 2022 13:59:48 +0800 Message-Id: <20220628055949.566089-1-dzm91@hust.edu.cn> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-FEAS-AUTH-USER: dzm91@hust.edu.cn Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Dongliang Mu In init_names, strlcpy will overread the src string as the src string is less than GFS2_FSNAME_LEN(256). Fix this by modifying strlcpy back to snprintf, reverting the commit 00377d8e3842. Fixes: 00377d8e3842 ("[GFS2] Prefer strlcpy() over snprintf()") Reported-by: syzkaller Signed-off-by: Dongliang Mu --- fs/gfs2/ops_fstype.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index c9b423c874a3..ee29b50d39b9 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c @@ -383,8 +383,8 @@ static int init_names(struct gfs2_sbd *sdp, int silent) if (!table[0]) table =3D sdp->sd_vfs->s_id; =20 - strlcpy(sdp->sd_proto_name, proto, GFS2_FSNAME_LEN); - strlcpy(sdp->sd_table_name, table, GFS2_FSNAME_LEN); + snprintf(sdp->sd_proto_name, GFS2_FSNAME_LEN, "%s", proto); + snprintf(sdp->sd_table_name, GFS2_FSNAME_LEN, "%s", table); =20 table =3D sdp->sd_table_name; while ((table =3D strchr(table, '/'))) --=20 2.35.1