diff --git a/0001-unistr.c-Fix-use-after-free-in-ntfs_uppercase_mbs.patch b/0001-unistr.c-Fix-use-after-free-in-ntfs_uppercase_mbs.patch new file mode 100644 index 0000000000000000000000000000000000000000..5cbb9d4cb7318d3e8f326384dfff9129398988a2 --- /dev/null +++ b/0001-unistr.c-Fix-use-after-free-in-ntfs_uppercase_mbs.patch @@ -0,0 +1,37 @@ +From 75dcdc2cf37478fad6c0e3427403d198b554951d Mon Sep 17 00:00:00 2001 +From: Erik Larsson +Date: Tue, 13 Jun 2023 17:47:15 +0300 +Subject: [PATCH] unistr.c: Fix use-after-free in 'ntfs_uppercase_mbs'. + +If 'utf8_to_unicode' throws an error due to an invalid UTF-8 sequence, +then 'n' will be less than 0 and the loop will terminate without storing +anything in '*t'. After the loop the uppercase string's allocation is +freed, however after it is freed it is unconditionally accessed through +'*t', which points into the freed allocation, for the purpose of NULL- +terminating the string. This leads to a use-after-free. +Fixed by only NULL-terminating the string when no error has been thrown. + +Thanks for Jeffrey Bencteux for reporting this issue: +https://github.com/tuxera/ntfs-3g/issues/84 +--- + libntfs-3g/unistr.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/libntfs-3g/unistr.c b/libntfs-3g/unistr.c +index 5854b3b..db8ddf4 100644 +--- a/libntfs-3g/unistr.c ++++ b/libntfs-3g/unistr.c +@@ -1189,8 +1189,9 @@ char *ntfs_uppercase_mbs(const char *low, + free(upp); + upp = (char*)NULL; + errno = EILSEQ; ++ } else { ++ *t = 0; + } +- *t = 0; + } + return (upp); + } +-- +2.43.0 + diff --git a/ntfs-3g.spec b/ntfs-3g.spec index c556a1c754a6a67be652165ff7f9d6b95c4e565a..4f043030a55a4a7dba9ada967fdf3c76320d86c1 100644 --- a/ntfs-3g.spec +++ b/ntfs-3g.spec @@ -1,6 +1,6 @@ Name: ntfs-3g Version: 2022.10.3 -Release: 1 +Release: 2 Epoch: 2 Summary: Linux NTFS userspace driver License: GPLv2+ @@ -8,6 +8,7 @@ URL: http://www.ntfs-3g.org/ Source0: http://tuxera.com/opensource/%{name}_ntfsprogs-%{version}%{?subver}.tgz Patch0: 0000-ntfs-3g_ntfsprogs-2011.10.9-RC-ntfsck-unsupported-return-0.patch Patch1: add-version-and-help-usage.patch +Patch2: 0001-unistr.c-Fix-use-after-free-in-ntfs_uppercase_mbs.patch BuildRequires: libtool, libattr-devel, libconfig-devel, libgcrypt-devel, gnutls-devel, libuuid-devel Provides: ntfsprogs-fuse = %{epoch}:%{version}-%{release} @@ -89,6 +90,12 @@ rm -rf $RPM_BUILD_ROOT%{_defaultdocdir}/%{name}/README %{_mandir}/man*/* %changelog +* Tue Jun 4 2024 liuh - 2:2022.10.3-2 +- Type:bugfix +- Id:NA +- SUG:NA +- DESC:sync patch from community fix UAF in ntfs_uppercase_mbs + * Tue Apr 18 2023 liyanan - 2:2022.10.3-1 - Update to 2022.10.3