From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0D82119AD9B; Thu, 25 Jul 2024 14:54:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721919287; cv=none; b=ItsH+9J6yDHSot49li3YvXvW00/wmjwwB+zoE3oRXkHZP7HNm7p8h0s1ljZ//XluUIoaBiA6hxw2IUswWSxoPetdwOaJxxrMNlY82o6wBpveQkPrKVWl9NM9nt5LZCkd4GO/Jvl0OMTmbcR0yJRvJLZhDLaR8Iwc5FuIEr04Yf0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721919287; c=relaxed/simple; bh=fSZ93AvCaPs4rfHBFHb+cfMjDtqADjnMICjU+PfeY+U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o/b5H8xMmd70p6Bmasg2IwYuxHNYyYNfhS7oXlNhxAFbOej9y9e1OcOkLx71ZHXiH22EBro9pM3fMMMrDGDQM5J1TNfmj2UYCZDGBY4XiWG2nHVR65WD7h3BCeWI2zXRl0RuLE5MEc5Gy8UFkNRWxNU3DNlBmWQ46SA6wJNpd5E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=u4VFqPYI; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="u4VFqPYI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46B32C116B1; Thu, 25 Jul 2024 14:54:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1721919286; bh=fSZ93AvCaPs4rfHBFHb+cfMjDtqADjnMICjU+PfeY+U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u4VFqPYImeomljHCSV6GnDT6kzf022t6gNUNpCefuNuIClpOOCYhR1gOgBUKTnSE3 9P4Ilz3ChLhAM6SN/uvwrBArkCMbXQSNAW3gJJw5HP4Qi0jYAbopnYDNDIII7yHQAa mqPwFIqsktHyyZ9tcj2rDiRBTK2ZP9igGFx9zXDA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, lei lu , Konstantin Komarov Subject: [PATCH 5.15 81/87] fs/ntfs3: Validate ff offset Date: Thu, 25 Jul 2024 16:37:54 +0200 Message-ID: <20240725142741.495931258@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240725142738.422724252@linuxfoundation.org> References: <20240725142738.422724252@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: lei lu commit 50c47879650b4c97836a0086632b3a2e300b0f06 upstream. This adds sanity checks for ff offset. There is a check on rt->first_free at first, but walking through by ff without any check. If the second ff is a large offset. We may encounter an out-of-bound read. Signed-off-by: lei lu Signed-off-by: Konstantin Komarov Signed-off-by: Greg Kroah-Hartman --- fs/ntfs3/fslog.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/fs/ntfs3/fslog.c +++ b/fs/ntfs3/fslog.c @@ -724,7 +724,8 @@ static bool check_rstbl(const struct RES if (!rsize || rsize > bytes || rsize + sizeof(struct RESTART_TABLE) > bytes || bytes < ts || - le16_to_cpu(rt->total) > ne || ff > ts || lf > ts || + le16_to_cpu(rt->total) > ne || + ff > ts - sizeof(__le32) || lf > ts - sizeof(__le32) || (ff && ff < sizeof(struct RESTART_TABLE)) || (lf && lf < sizeof(struct RESTART_TABLE))) { return false; @@ -754,6 +755,9 @@ static bool check_rstbl(const struct RES return false; off = le32_to_cpu(*(__le32 *)Add2Ptr(rt, off)); + + if (off > ts - sizeof(__le32)) + return false; } return true;