Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3659360iog; Mon, 27 Jun 2022 23:14:03 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tOxZDWReHo+OM5lTl+ygZGWFrEC3AIB6LWhA056G7XSm3au5b/0RW/pDsQo+t7911Yp78v X-Received: by 2002:aa7:8890:0:b0:525:85db:c0d1 with SMTP id z16-20020aa78890000000b0052585dbc0d1mr3039933pfe.69.1656396843323; Mon, 27 Jun 2022 23:14:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656396843; cv=none; d=google.com; s=arc-20160816; b=S9rae6MCZlPCCImlsjXXIBUVkqCoU9zzeCRozVta9tOM+vTsxyOqYcRivRUwoAixuF BInSzEbi3H9PlaushgA7/kCClIbuidZtzXrSzhQzD6/Xi+A3k/XIMwJWZTP8dvmvlF/P juxbY7IxsARzghKMW+n83cNgAczpgnKIyCWpxERoDJ2JCTOSZF6q1UTnuNmPlkF98nxJ EGPBfLDyzKjS5qcMqiRQAs60LjwgSkSRtLRrSaie5hDGelkieARHBsm+g7Tm+fqU1Kqo v6pRkjaM99xQzdANfQfUh2OlkOWqgPf0NP13+Ypjth4OgYag4LSgtw+6GlyV4sR6gJjK 5H4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=Se2qB99u1N/AQEtAu3pZ9dnLrVvY/WSkf+PU2V4gha4=; b=X/14eqkRkIPV9J9s3doiZR68MFxTe57oI/9XlxEiItyTGpKFj1qes/Sh/3oAKqonBm cBfZKyTQ76hj+vhQPi6nivhKCB4eyjqkXASF0ZGnKWt7uAwf/L/Unu/R/nAymJeWkIU9 MPacYa8198X/hoCLf2oqnNAftqgANf/Sxo4qjLB1/WaKzfj6db12N/exBaQLSyX9sgnl CmwB9yPH12hQB84YrAazhNpPYUzAiIv2XPnAnEEZj2KtiCxY2MjniIt+Ers7uMveipdj S6tqbv3m+S6euHurHP6sS2dERhjyS2rBbRG318j47npva/zOEXkpzeDTPGGq58oFFPLK wh7A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s16-20020a056a00195000b0050d80e4935fsi17615536pfk.256.2022.06.27.23.13.49; Mon, 27 Jun 2022 23:14:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245195AbiF1GAm (ORCPT + 99 others); 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: 8bit X-FEAS-AUTH-USER: dzm91@hust.edu.cn X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 = sdp->sd_vfs->s_id; - 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); table = sdp->sd_table_name; while ((table = strchr(table, '/'))) -- 2.35.1