lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 24 Dec 2007 03:16:41 +0100
From:	Roman Zippel <zippel@...ux-m68k.org>
To:	Eric Sandeen <sandeen@...hat.com>
Cc:	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH] UPDATED: hfs: handle more on-disk corruptions without oopsing

Hi,

On Thursday 20 December 2007, Eric Sandeen wrote:

> Index: linux-2.6.24-rc3/fs/hfs/brec.c
> ===================================================================
> --- linux-2.6.24-rc3.orig/fs/hfs/brec.c
> +++ linux-2.6.24-rc3/fs/hfs/brec.c
> @@ -44,10 +44,21 @@ u16 hfs_brec_keylen(struct hfs_bnode *no
>  		recoff = hfs_bnode_read_u16(node, node->tree->node_size - (rec + 1) *
> 2); if (!recoff)
>  			return 0;
> -		if (node->tree->attributes & HFS_TREE_BIGKEYS)
> +		if (node->tree->attributes & HFS_TREE_BIGKEYS) {
>  			retval = hfs_bnode_read_u16(node, recoff) + 2;
> -		else
> +			if (retval > node->tree->max_key_len + 2) {
> +				printk(KERN_ERR "hfs: keylen %d too large\n",
> +					retval);
> +				retval = HFS_BAD_KEYLEN;
> +			}
> +		} else {
>  			retval = (hfs_bnode_read_u8(node, recoff) | 1) + 1;
> +			if (retval > node->tree->max_key_len + 1) {
> +				printk(KERN_ERR "hfs: keylen %d too large\n",
> +					retval);
> +				retval = HFS_BAD_KEYLEN;
> +			}
> +		}
>  	}
>  	return retval;
>  }

You can reuse 0 as failure value, a key has to be of nonzero size.

> Index: linux-2.6.24-rc3/fs/hfs/btree.c
> ===================================================================
> --- linux-2.6.24-rc3.orig/fs/hfs/btree.c
> +++ linux-2.6.24-rc3/fs/hfs/btree.c
> @@ -81,6 +81,17 @@ struct hfs_btree *hfs_btree_open(struct
>  		goto fail_page;
>  	if (!tree->node_count)
>  		goto fail_page;
> +	if ((id == HFS_EXT_CNID) && (tree->max_key_len != HFS_MAX_EXT_KEYLEN)) {
> +		printk(KERN_ERR "hfs: invalid extent max_key_len %d\n",
> +			tree->max_key_len);
> +		goto fail_page;
> +	}
> +	if ((id == HFS_CAT_CNID) && (tree->max_key_len != HFS_MAX_CAT_KEYLEN)) {
> +		printk(KERN_ERR "hfs: invalid catalog max_key_len %d\n",
> +			tree->max_key_len);
> +		goto fail_page;
> +	}
> +
>  	tree->node_size_shift = ffs(size) - 1;
>  	tree->pages_per_bnode = (tree->node_size + PAGE_CACHE_SIZE - 1) >>
> PAGE_CACHE_SHIFT;
>

I'd prefer a switch statement here.

It would be nice if you could do the same changes for hfsplus, so both stay in 
sync.
Thanks.

bye, Roman
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists