From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f170.google.com (mail-qk1-f170.google.com [209.85.222.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD60D280CE5 for ; Sat, 11 Jul 2026 15:08:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783782494; cv=none; b=JEXXQ8PEOPAT7/DsrHfSGKLX2tA/0LK01Mvdm8TEwFmCAthRKqAPo8u9qgTy7/slElxJJzKtSuXqputGGDGu4ImU5+K2DwMHfcer7aQQkg5t7D1NaA8A3WKLbkKZzicYJZN36hp20aOvkdGXsB0RLVD1FrXJS11eXZbS3IrXIBg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783782494; c=relaxed/simple; bh=CdhefricwWhFH7olfPqmXW38H4i9Ji9hk0aWVmUDFfA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=EUUnHdfLDpSLC7ngsN4hsmAYcHgks/F73OIanW91QSoMNu6kweSWNXUiF1cKdFuwhw/hQuuHwQuwkAfuL45Y+JFn9jPzLCjUFqdNDW9husCNoub33/W9oFi+BAJDEUFgbwEgW4KKu93ZizGREwfAhFRT6J2+copwgtkEOo05ftU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dyBBpbOd; arc=none smtp.client-ip=209.85.222.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dyBBpbOd" Received: by mail-qk1-f170.google.com with SMTP id af79cd13be357-920f33347f5so97154985a.3 for ; Sat, 11 Jul 2026 08:08:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783782492; x=1784387292; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=Typ9h20vIh7Ab90myOn31vTAuGHIxFcn9F7x3mbLByY=; b=dyBBpbOdlwY5NsCIFVD/UnyDvcBpE1Ka5KjOrWp5RJMr1Nn8NAeFrFZTGWxHUqWWwo LhlV6Ja9+Y60stjQZYeacn+/lfBfZ/TPHWts5B5n0h9x/CH85ObRXkJ3SYS3zqV7fq2E ZDEFbvmrEig2nzNyinnYl1Dv17EuMo5HrIzuGugjTS/IP0AzYVY+US9Y25vlRXgfMOIj 0E3QvWt4kWdJERNw8kDCRf8npcy+z+zW2QsifH0h6ee2wvclUCfIZOf39DGPpub0higq QO6GwEk/EIN+fL+Wgw54QeuXTGgCBtjihGGoQvr5HyNV7qMB8jSv1AwaABcfiUfEwOov UunQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783782492; x=1784387292; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Typ9h20vIh7Ab90myOn31vTAuGHIxFcn9F7x3mbLByY=; b=inz0MABMghqo35VqQuIg0/SjZVDL9Z6lw2frZHGUpdhV8IoS4piuExdtCGYOyH5GOk hXdCFIPW6QyJV4C7fzzQ9h7XQgZiv/CAxdaSUw3ztP6xoR9f5SApxBgr6IsizjXXlI2K VPwKGaJuDLHVffiSrUjw5RrA/tLxmaU/IqgQVO+UeUbrlXnjnVNHWlSQe/IaMWGBCaSt vNW6wN5Xe0O85NquNCRevi+nXeMi9if86cWNZO038Obx+PTxH1dRbYUwzP5hh0SGDfgU QDuBF1O2s29MxWXsMb1Mp4u9mq6H9g30rW0F4L8EXJdUvz69BcPWvFKFkxcRroFVaew3 TiKQ== X-Forwarded-Encrypted: i=1; AHgh+RrQld3COg0rUq9lS+fPtFHl9rg1sTF1uJc1nnaZd98QwOQhfLYqSwIK7i+2o7dz8KRWrHYzHVAvi6uSc2s=@vger.kernel.org X-Gm-Message-State: AOJu0YzU96FKMsO/6RKXhpy7sPgin7gOBoJy1FQp334nG5EmHKhkqRKP tK++OYtNcIfXNH5XXpjHa81sRQH7L/aSBZrhNx2XO7ueb13T0ADz48Kj X-Gm-Gg: AfdE7cmtkD8klYdmfDeD1gMIJaIGuY5JYTgMbKfCO6cRx69s0W6rp9r/GLYSK3EkI28 RYduS69HRgZ66IR1VQqoNs7iyzdmQ+wn7yFd+jSKsT744ul4U+gzK/nYWhpVwiy7FiwPyLclZV8 GFusHWI/tv+wWwix1MJwa/a0figUhnuaiPBDwoc7/X1R9PruOK2bZoOE233myUAMRWOFBpWuUPt 5G+Weo6MpxX9M1q+mqcsoMeMwnws+A+0e81LFqukf3C+GUJhImCSY+m+u+9cPT0jEXljeaZXstL wP7dLbMs8WNB1kAcFwxUTntrrDC6/5BJFjwwePJU9zLgJ6Q9wG+l5lEQ63RbM2Hk3O3iigxRdim zINru+f4j8fZtiDhf0ypFqYqAMjPazzCaUzrzmEUM4hFHeuDC1evTEE156Ed3q3Ib7mr7hS4DAz HlGAxbTuxU0dbqXlP5efSC67Zn1NgTrflzTafLqQ1ab4sjUgYV8HQEORHeBJr+A+w8EG4bnJ7jp bYxtQyg4A== X-Received: by 2002:a05:620a:608e:b0:92e:93a6:4eaa with SMTP id af79cd13be357-92ef2b567c1mr345018485a.32.1783782491736; Sat, 11 Jul 2026 08:08:11 -0700 (PDT) Received: from server0 (c-68-48-65-54.hsd1.mi.comcast.net. [68.48.65.54]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8ffd57baf98sm69401616d6.17.2026.07.11.08.08.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jul 2026 08:08:11 -0700 (PDT) From: Michael Bommarito To: Andreas Gruenbacher Cc: gfs2@lists.linux.dev, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH] gfs2: reject an over-long name in get_name_filldir Date: Sat, 11 Jul 2026 11:08:08 -0400 Message-ID: <20260711150808.2919076-1-michael.bommarito@gmail.com> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 7bit get_name_filldir() copies a directory entry name into the caller's fixed GFS2_FNAMESIZE-byte buffer with memcpy(gnfd->name, name, length) without checking length against GFS2_FNAMESIZE. A gfs2 directory entry whose name length exceeds GFS2_FNAMESIZE, as produced by a corrupted or crafted on-disk directory, overflows the buffer. Impact: an out-of-bounds write past the GFS2_FNAMESIZE name buffer (KASAN) in the NFS-export get_name path, reachable when a gfs2 filesystem carrying a crafted directory entry is re-exported over NFS. Reject entries whose name length exceeds GFS2_FNAMESIZE before the copy. Fixes: b3b94faa5fe5 ("[GFS2] The core of GFS2") Cc: stable@vger.kernel.org Assisted-by: Claude:claude-opus-4-8 Signed-off-by: Michael Bommarito --- fs/gfs2/export.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/gfs2/export.c b/fs/gfs2/export.c index 3334c394ce9cb..7b28f1eb9ad0d 100644 --- a/fs/gfs2/export.c +++ b/fs/gfs2/export.c @@ -76,6 +76,9 @@ static bool get_name_filldir(struct dir_context *ctx, const char *name, if (inum != gnfd->inum.no_addr) return true; + if (length > GFS2_FNAMESIZE) + return false; + memcpy(gnfd->name, name, length); gnfd->name[length] = 0; -- 2.53.0