[2.6.6-bk] NTFS 2.1.9 release - Fix two bugs in the decompressionengine.

From: Anton Altaparmakov
Date: Mon May 10 2004 - 04:18:14 EST


Hi Andrew, Hi Linus, please do a

bk pull http://linux-ntfs.bkbits.net/ntfs-2.6

Thanks! This fixes two bugs in the NTFS decompression engine, one of which
was reported by Marcin GibuÅ?a a few days ago on lkml. Many thanks go to him
for the bug report, the help in tracking down the bug and testing the fix.

Best regards,

Anton
--
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK
Linux NTFS maintainer / IRC: #ntfs on irc.freenode.net
WWW: http://linux-ntfs.sf.net/, http://www-stu.christs.cam.ac.uk/~aia21/

===================================================================

This will update the following files:

Documentation/filesystems/ntfs.txt | 2 ++
fs/ntfs/ChangeLog | 14 +++++++++++++-
fs/ntfs/Makefile | 2 +-
fs/ntfs/compress.c | 29 ++++++++++++++++++++++-------
4 files changed, 38 insertions(+), 9 deletions(-)

through these ChangeSets:

<aia21@xxxxxxxxxx> (04/05/10 1.1611)
NTFS: 2.1.9 release - Fix two bugs in the decompression engine
in handling of corner cases.


diff -Nru a/Documentation/filesystems/ntfs.txt b/Documentation/filesystems/ntfs.txt
--- a/Documentation/filesystems/ntfs.txt Mon May 10 10:09:16 2004
+++ b/Documentation/filesystems/ntfs.txt Mon May 10 10:09:16 2004
@@ -273,6 +273,8 @@

Note, a technical ChangeLog aimed at kernel hackers is in fs/ntfs/ChangeLog.

+2.1.9:
+ - Fix two bugs in handling of corner cases in the decompression engine.
2.1.8:
- Read the $MFT mirror and compare it to the $MFT and if the two do not
match, force a read-only mount and do not allow read-write remounts.
diff -Nru a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog
--- a/fs/ntfs/ChangeLog Mon May 10 10:09:16 2004
+++ b/fs/ntfs/ChangeLog Mon May 10 10:09:16 2004
@@ -19,7 +19,19 @@
sufficient for synchronisation here. We then just need to make sure
ntfs_readpage/writepage/truncate interoperate properly with us.

-2.1.8 - Handle $MFT mirror and $LogFile, improve time ihandling, and cleanups.
+2.1.9 - Fix two bugs in decompression engine.
+
+ - Fix a bug where we would not always detect that we have reached the
+ end of a compression block because we were ending at minus one byte
+ which is effectively the same as being at the end. The fix is to
+ check whether the uncompressed buffer has been fully filled and if so
+ we assume we have reached the end of the compression block. A big
+ thank you to Marcin GibuÅ?a for the bug report, the assistance in
+ tracking down the bug and testing the fix.
+ - Fix a possible bug where when a compressed read is truncated to the
+ end of the file, the offset inside the last page was not truncated.
+
+2.1.8 - Handle $MFT mirror and $LogFile, improve time handling, and cleanups.

- Use get_bh() instead of manual atomic_inc() in fs/ntfs/compress.c.
- Modify fs/ntfs/time.c::ntfs2utc(), get_current_ntfs_time(), and
diff -Nru a/fs/ntfs/Makefile b/fs/ntfs/Makefile
--- a/fs/ntfs/Makefile Mon May 10 10:09:16 2004
+++ b/fs/ntfs/Makefile Mon May 10 10:09:16 2004
@@ -5,7 +5,7 @@
ntfs-objs := aops.o attrib.o compress.o debug.o dir.o file.o inode.o logfile.o \
mft.o mst.o namei.o super.o sysctl.o unistr.o upcase.o

-EXTRA_CFLAGS = -DNTFS_VERSION=\"2.1.8\"
+EXTRA_CFLAGS = -DNTFS_VERSION=\"2.1.9\"

ifeq ($(CONFIG_NTFS_DEBUG),y)
EXTRA_CFLAGS += -DDEBUG
diff -Nru a/fs/ntfs/compress.c b/fs/ntfs/compress.c
--- a/fs/ntfs/compress.c Mon May 10 10:09:16 2004
+++ b/fs/ntfs/compress.c Mon May 10 10:09:16 2004
@@ -197,9 +197,15 @@
do_next_sb:
ntfs_debug("Beginning sub-block at offset = 0x%x in the cb.",
cb - cb_start);
-
- /* Have we reached the end of the compression block? */
- if (cb == cb_end || !le16_to_cpup((u16*)cb)) {
+ /*
+ * Have we reached the end of the compression block or the end of the
+ * decompressed data? The latter can happen for example if the current
+ * position in the compression block is one byte before its end so the
+ * first two checks do not detect it.
+ */
+ if (cb == cb_end || !le16_to_cpup((u16*)cb) ||
+ (*dest_index == dest_max_index &&
+ *dest_ofs == dest_max_ofs)) {
int i;

ntfs_debug("Completed. Returning success (0).");
@@ -501,7 +507,7 @@
*/
unsigned int nr_pages = (end_vcn - start_vcn) <<
vol->cluster_size_bits >> PAGE_CACHE_SHIFT;
- unsigned int xpage, max_page, cur_page, cur_ofs, i;
+ unsigned int xpage, max_page, max_ofs, cur_page, cur_ofs, i;
unsigned int cb_clusters, cb_max_ofs;
int block, max_block, cb_max_page, bhs_size, nr_bhs, err = 0;
struct page **pages;
@@ -544,8 +550,11 @@
*/
max_page = ((VFS_I(ni)->i_size + PAGE_CACHE_SIZE - 1) >>
PAGE_CACHE_SHIFT) - offset;
- if (nr_pages < max_page)
+ max_ofs = (VFS_I(ni)->i_size + PAGE_CACHE_SIZE - 1) & ~PAGE_CACHE_MASK;
+ if (nr_pages < max_page) {
max_page = nr_pages;
+ max_ofs = 0;
+ }
for (i = 0; i < max_page; i++, offset++) {
if (i != xpage)
pages[i] = grab_cache_page_nowait(mapping, offset);
@@ -713,8 +722,14 @@
cb_max_page >>= PAGE_CACHE_SHIFT;

/* Catch end of file inside a compression block. */
- if (cb_max_page > max_page)
- cb_max_page = max_page;
+ if (cb_max_page >= max_page) {
+ if (cb_max_page > max_page) {
+ cb_max_page = max_page;
+ cb_max_ofs = max_ofs;
+ } else if (cb_max_ofs > max_ofs) {
+ cb_max_ofs = max_ofs;
+ }
+ }

if (vcn == start_vcn - cb_clusters) {
/* Sparse cb, zero out page range overlapping the cb. */

===================================================================

This BitKeeper patch contains the following changesets:
1.1611
## Wrapped with gzip_uu ##


M'XL( +Y&GT [U8Z6[;1A#^+3[%-"D"V[&D7=Y4*C>.KQB)$\-V@J(P("S)
MI468(@7NRD>C]$??K>_5V:5N6:VO5!(D<G?VF_OCV"_AB^!EJ\929E+C);PO
MA&S5(I9+%C9R+G'II"APJ=DM>KPIRJB9RT34S89KX-XQDU$7KG@I6C7:L"8K
M\K;/6[63O8,O'[=/#*/=AITNRR_X*9?0;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H.$Y1LK*^>36B%G
MO#*M2!*!?93F(HVY7LF8D-!G%PB/,55U,P%31::*TL>B?*_(AL//1_MGF/FR
M1->5_3]CW>]K]!2-*C#(,NWQ"35M:J$(&RD?],4\^8SGB07N>="TLIIY%J:5
M"?'@M$("33R^]1#>^<&THP9S57^8/DT#BG6JP6H%ZXS]>PSI^(ISU-?>;V<G
MVYV=_8_;!Z?0AOJN&G([7_=.3@\_?VJ?O]"FG+^82]MT"EE(W$,'G=6Y6QQT
M;-,G ;4<?&P$EEL]-IS@(9,"C@K>#TG?\U"P^N/@.3A8X3R=A!7*\["PMN?I
M-*Q@5O'P^<TW0FWS^WW96&/=GXZG&7X:'\]D^$F$C*R@9_T5K##MG$<-(]@\
M%DXCQ(3 J#4W\"FR@<1_I5-WWZS!* U3&0TS'6(0 RF/_5J57<:DU(.KFF?[
M?55+",!O6*^/L4Y'2@9EB>.U!L(\I&K,'D^YRP:DTX[ ZD0XQ)%"&R2*B4%)
M6F*<U9RE:QV;M-#!'O5J*AM*K&G4T(:U*$2R@RCL*)#A$'[*.'4[LNA$_4%_
M;6U W8WU*%S'+:-6JZUMQ%A'G32/^8TZI^]Z[&:T\NJ5$JIDBD3,2>#]^CI\
M,W8=8BN6KGYJ RR/BQPCE^82;E1Q;((2GU[AP4T5I]&2NM)+Z1O$PA%;8>&/
M:=1&TLCW:U^1[0_7\G2]OI5V1/H'A]=PO'VPU]G9WGF_USD]_'T/ZY^NPROX
M<V;]:/OTPYLJ,'FE4, O$WN4^:C+5[IFE!$\\=W8Q><P;AQZU -_'-O.^"AL
MM>=@:LL""_NUV<WIX3<S6Y7ZT97:^ X\$[JVUF9$ML8B\\#+IY4;DW^?5;4S
2Z+6#P'=YY/K&/T+)/F"H$P
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/