public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Bad ext3/nfs DoS bug
@ 2006-07-17 13:01 James
  2006-07-17 13:06 ` Marcel Holtmann
                   ` (2 more replies)
  0 siblings, 3 replies; 32+ messages in thread
From: James @ 2006-07-17 13:01 UTC (permalink / raw)
  To: linux-kernel

I've tried contacting the relevant maintainers directly,
and it's even in the kernel bugzilla, but nothing's happened
and it's been over a month now. No-one seems to be doing anyting 
about this. Is one meant to post this to bugtraq or what?

Here's the bug: http://bugzilla.kernel.org/show_bug.cgi?id=6828
(exploit code follows)

> We found this rather surprising behaviour when debugging a
> network card for one of our embedded systems. There was a
> bus problem that occasionally caused the network card to
> place random data in the outgoing packets. We were using
> NFS root, as we hadn't written drivers for the block
> devices yet, and discovered our Linux NFS servers getting
> ext3 errors. It turned out that the 3com cards we have in
> the servers lie about checking UDP checksums, and passed
> the rubbish to knfsd where it was causing the problem. 
> 
> Here's an example one of our widgets (dcm503) is talking
> to an NFS server (dufftown)
> 
> 17:28:38.535011 dcm503.guralp.local.984095109 > dufftown.guralp.local.nfs: 116 
> lookup fh Unknown/1 "" (DF) (ttl 64, id 0, len 144)
>                          4500 0090 0000 4000 4011 3d45 0a52 01fa
>                          c0a8 3024 03ff 0801 007c 8e9c 3aa8 1985
>                          0000 0000 0000 0002 0001 86a3 0000 0002
>                          0000 0004 0000 0001 0000 001c 028f 5b0c
>                          0000 0006 6463 6d35 3033 0000 0000 0000
>                          0000 0000 0000 0000 0000 0000 0000 0000
>                          0100 0001 0021 0003 3d26 3d00 4a2f ffff
>                          3d00 2c08 c923 0000 0000 0000 0000 0000
>                          0000 0000 000a 6d6f 756e 7470 6f69 6e74
> 
> so what's happened here is 4a2f ffff should have been 4a2f
> xxxx but the network card has missed the clock on the bus
> and gotten ffff instead
> 
> nfsd_dispatch: vers 2 proc 4
> nfsd: LOOKUP   32: 01000001 03002100 003d263d ffff2f4a 082c003d 000023c9
> nfsd: nfsd_lookup(fh 32: 01000001 03002100 003d263d ffff2f4a 082c003d 
> 000023c9, )
> nfsd: fh_verify(32: 01000001 03002100 003d263d ffff2f4a 082c003d 000023c9)
> 
> so here the client does a V2 lookup with a DH which has
> gotten screwed up by my clients network card, this is
> received by my server, gets past the UDP checksum code
> (thank you 3com) and ends up at knfsd.
> 
> knfsd passes this to fh_verify which decodes it to be hde3
> and inode 4294913866 (0xffff2f4a)
> 
> that then gets passed to ext3 which then panics.
> 
> EXT3-fs error (device hde3): ext3_get_inode_block: bad inode number: 
> 4294913866
> 
> marks the file system as containing an error, and remounts
> the system read only.
> 
> Obviously this is sub optimal, and a fairly horrid DoS
> since anyone can craft a UDP packet, with a bogus FH in
> it. Whilst this is for V2_LOOKUP it works for all of the
> V2 procedures we tried.
> 

exploit code is available at

http://www.madingley.org/uploaded/crash-nfs.tar.gz

James.





^ permalink raw reply	[flat|nested] 32+ messages in thread
* Re: Bad ext3/nfs DoS bug
@ 2006-07-22  3:38 linux
  0 siblings, 0 replies; 32+ messages in thread
From: linux @ 2006-07-22  3:38 UTC (permalink / raw)
  To: akpm, linux-kernel

>> +static inline int ext3_valid_inum(struct super_block *sb, unsigned long ino)
>> +{
>> +	return ino == EXT3_ROOT_INO ||
>> +		ino == EXT3_JOURNAL_INO ||
>> +		ino == EXT3_RESIZE_INO ||
>> +		(ino > EXT3_FIRST_INO(sb) &&
>> +		 ino <= le32_to_cpu(EXT3_SB(sb)->s_es->s_inodes_count));
>> +}
> 
> One would expect the inode validity test to be
> 
> 	(ino >= EXT3_FIRST_INO(sb)) && (ino < ...->s_inodes_count))
> 
> but even this assumes that s_inodes_count is misnamed and really should be
> called s_last_inode_plus_one.  If it is not misnamed then the validity test
> should be
> 
> 	(ino >= EXT3_FIRST_INO(sb)) &&
> 		(ino < EXT3_FIRST_INO(sb) + ...->s_inodes_count))
> 
> Look through the filesystem for other uses of EXT3_FIRST_INO().  It's all
> rather fishily inconsistent.

Er... I'm not an authoritative speaker, but it seems very simple to me.

Inodes are indexed starting from 1; the index 0 is reserved, and the first
inode on disk is number 1.

Thus, potentially valid inode numbers are 1 through s_inodes_count,
inclusive. Thus the <=.  If this were a standard 0-based index, it would
be <, but it's not.

Further, a range of low inode numbers are reserved for special purposes.
Only a few inode numbers in this range are valid.  However, these
numbers are still assigned space in the inode tables.

The only confusing term is EXT3_FIRST_INO, which is actually
more like EXT3_RESERVED_INODES.  The same 1-based indexing explains
the use of > rather than >= there.

^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2006-07-28 13:30 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-17 13:01 Bad ext3/nfs DoS bug James
2006-07-17 13:06 ` Marcel Holtmann
2006-07-17 18:43 ` Marcel Holtmann
2006-07-18  7:55 ` Marcel Holtmann
2006-07-18 14:56   ` James
2006-07-18 15:22     ` Marcel Holtmann
2006-07-18 15:23       ` James
2006-07-18 20:18         ` Marcel Holtmann
2006-07-19  9:28           ` James
2006-07-19 15:55             ` Jan Kara
2006-07-20  4:46               ` Neil Brown
2006-07-20 16:06                 ` Jan Kara
2006-07-20 20:11                   ` James
2006-07-21  6:44                     ` Neil Brown
2006-07-21  6:39                   ` Neil Brown
2006-07-21 14:24                     ` Jan Kara
2006-07-22  0:06                     ` Andrew Morton
2006-07-22 13:17                       ` Theodore Tso
2006-07-25  1:56                         ` Andrew Morton
2006-07-25  2:21                           ` Neil Brown
2006-07-26 17:12                             ` Eric Sandeen
2006-07-26 23:53                               ` Neil Brown
2006-07-27 18:32                                 ` Eric Sandeen
2006-07-27 19:12                                   ` Christoph Hellwig
2006-07-28  0:34                                     ` Neil Brown
2006-07-28 13:27                                     ` Peter Staubach
2006-07-28 13:30                                       ` Christoph Hellwig
2006-07-25  2:36                           ` Neil Brown
2006-07-25 18:27                             ` Eric Sandeen
2006-07-21  0:42                 ` Marcel Holtmann
2006-07-21 12:29                   ` Andrew Morton
  -- strict thread matches above, loose matches on Subject: below --
2006-07-22  3:38 linux

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox