hfsplus: avoid crash on failed block map free
Subsystems (2)
Vyacheslav Dubeyko
maintainerPATCH v2 1/1 hfsplus: avoid crash on failed block map free
Hi Alan,
Do you agree with second version of the patch?
With the best regards,
Vyacheslav Dubeyko.
--
From: Alan Cox <[email protected]>
Subject: [PATCH v2] hfsplus: avoid crash on failed block map free
v1->v2
* Change hardcoded error code on -ENOENT.
* Add return -EIO for the case of kmap error.
* Fix issue with twice mutex unlock.
* Fix issue with printing kmap error message on every call.
If the read fails we kmap an error code. This doesn't end well. Instead print a critical error and pray. This mirrors the rest of the fs behaviour with critical error cases.
--- fs/hfsplus/bitmap.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
fs/hfsplus/bitmap.c +12 -1
@@ -176,12 +176,14 @@ int hfsplus_block_free(struct super_block *sb, u32 offset, u32 count)dprint (DBG_BITMAP ,"block_free: %u,%u\n" , offset, count);/* are all of the bits in range? */ if ((offset + count) > sbi->total_blocks) -return -2 ; +return -ENOENT ;mutex_lock (&sbi->alloc_mutex); mapping = sbi->alloc_file->i_mapping; pnr = offset /PAGE_CACHE_BITS ; page =read_mapping_page (mapping, pnr,NULL ); +if (IS_ERR (page)) + goto kaboom; pptr =kmap (page); curr = pptr + (offset & (PAGE_CACHE_BITS -1 )) /32 ; end = pptr +PAGE_CACHE_BITS /32 ;
@@ -214,6 +216,8 @@ int hfsplus_block_free(struct super_block *sb, u32 offset, u32 count)set_page_dirty (page);kunmap (page); page =read_mapping_page (mapping, ++pnr,NULL ); +if (IS_ERR (page)) + goto kaboom; pptr =kmap (page); curr = pptr; end = pptr +PAGE_CACHE_BITS /32 ;
@@ -232,4 +236,11 @@ out:mutex_unlock (&sbi->alloc_mutex);return 0 ; + +kaboom: +printk (KERN_CRIT "hfsplus: unable to mark blocks free: error %ld\n" , +PTR_ERR (page)); +mutex_unlock (&sbi->alloc_mutex); + +return -EIO ; }
Signature · 1 line
1.7.9.5
Quoted 34 lines · On Tue, 13 Nov 2012 13:31:05 +0400 Vyacheslav Dubeyko <[email protected]> wrote:
If the read fails we kmap an error code. This doesn't end well. Instead print a critical error and pray. This mirrors the rest of the fs behaviour with critical error cases.
...
index 4cfbe2e..6feefc0 100644
fs/hfsplus/bitmap.c +5
-1@@ -176,12 +176,14 @@ int hfsplus_block_free(struct super_block *sb, u32 offset, u32 count)dprint (DBG_BITMAP ,"block_free: %u,%u\n" , offset, count);/* are all of the bits in range? */ if ((offset + count) > sbi->total_blocks) -return -2 ; +return -ENOENT ;mutex_lock (&sbi->alloc_mutex); mapping = sbi->alloc_file->i_mapping; pnr = offset /PAGE_CACHE_BITS ; page =read_mapping_page (mapping, pnr,NULL ); +if (IS_ERR (page)) + goto kaboom; pptr =kmap (page); curr = pptr + (offset & (PAGE_CACHE_BITS -1 )) /32 ; end = pptr +PAGE_CACHE_BITS /32 ;@@ -214,6 +216,8 @@ int hfsplus_block_free(struct super_block *sb, u32 offset, u32 count)set_page_dirty (page);kunmap (page); page =read_mapping_page (mapping, ++pnr,NULL ); +if (IS_ERR (page)) + goto kaboom; pptr =kmap (page); curr = pptr; end = pptr +PAGE_CACHE_BITS /32 ;@@ -232,4 +236,11 @@ out:mutex_unlock (&sbi->alloc_mutex);
fs/hfsplus/bitmap.c out: · line 246
Quoted 10 lines
fs/hfsplus/bitmap.c +7
-0return 0 ; + +kaboom: +printk (KERN_CRIT "hfsplus: unable to mark blocks free: error %ld\n" , +PTR_ERR (page)); +mutex_unlock (&sbi->alloc_mutex); + +return -EIO ; }
It looks better than what we currently have!
The code is missing a flush_dcache_page()? We should have one in there after the CPU has modified userspace-mappable page contents.
btw, I still have question marks over your earlier patches:
hfsplus-add-on-disk-layout-declarations-related-to-attributes-tree.patch hfsplus-add-functionality-of-manipulating-by-records-in-attributes-tree.patch hfsplus-rework-functionality-of-getting-setting-and-deleting-of-extended-attributes.patch hfsplus-add-support-of-manipulation-by-attributes-file.patch hfsplus-add-support-of-manipulation-by-attributes-file-checkpatch-fixes.patch hfsplus-code-style-fixes-reworked-support-of-extended-attributes.patch
Christoph sounded unhappy, but the review discussion petered out?
Quoted 8 lines · Andrew Morton
It looks better than what we currently have!
The code is missing a
flush_dcache_page()? We should have one in there after the CPU has modified userspace-mappable page contents.btw, I still have question marks over your earlier patches:
Quoted 8 lines
hfsplus-add-on-disk-layout-declarations-related-to-attributes-tree.patch hfsplus-add-functionality-of-manipulating-by-records-in-attributes-tree.patch hfsplus-rework-functionality-of-getting-setting-and-deleting-of-extended-attributes.patch hfsplus-add-support-of-manipulation-by-attributes-file.patch hfsplus-add-support-of-manipulation-by-attributes-file-checkpatch-fixes.patch hfsplus-code-style-fixes-reworked-support-of-extended-attributes.patch
Christoph sounded unhappy, but the review discussion petered out?
It really just needs the xattr namespace fixed. JFS is a good model for how to expose the legacy OS/2 attributes that are lacking a namespace prefix.
Vyacheslav Dubeyko
maintainerHi,
Quoted 16 lines · Christoph Hellwig
Quoted 15 lines · Andrew Morton
It looks better than what we currently have!
The code is missing a
flush_dcache_page()? We should have one in there after the CPU has modified userspace-mappable page contents.btw, I still have question marks over your earlier patches:
hfsplus-add-on-disk-layout-declarations-related-to-attributes-tree.patch hfsplus-add-functionality-of-manipulating-by-records-in-attributes-tree.patch hfsplus-rework-functionality-of-getting-setting-and-deleting-of-extended-attributes.patch hfsplus-add-support-of-manipulation-by-attributes-file.patch hfsplus-add-support-of-manipulation-by-attributes-file-checkpatch-fixes.patch hfsplus-code-style-fixes-reworked-support-of-extended-attributes.patch
Quoted 4 lines
Quoted 1 line
Christoph sounded unhappy, but the review discussion petered out?
It really just needs the xattr namespace fixed. JFS is a good model for how to expose the legacy OS/2 attributes that are lacking a namespace prefix.
So, likewise JFS model every pure Mac OS X xattr (for example, com.apple.FinderInfo) will be prefixed with "mac-os-x." during list_xattr stage. Then this prefix will be excluded for search in Catalog b-tree during get_xattr and set_xattr calls. And I try to rework the code for using general dispatching code also.
Do you have any objections? :-)
With the best regards,
Vyacheslav Dubeyko.
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 7 lines · Vyacheslav Dubeyko
So, likewise JFS model every pure Mac OS X xattr (for example, com.apple.FinderInfo) will be prefixed with "mac-os-x." during
list_xattrstage. Then this prefix will be excluded for search in Catalog b-tree duringget_xattrandset_xattrcalls. And I try to rework the code for using general dispatching code also.Do you have any objections? :-)
How about just osx as a short prefix? That'll mirror os2. and looks less awkward. Otherwise the plan looks good.
Vyacheslav Dubeyko
maintainerQuoted 7 lines · Christoph Hellwig
Quoted 6 lines · Vyacheslav Dubeyko
So, likewise JFS model every pure Mac OS X xattr (for example, com.apple.FinderInfo) will be prefixed with "mac-os-x." during
list_xattrstage. Then this prefix will be excluded for search in Catalog b-tree duringget_xattrandset_xattrcalls. And I try to rework the code for using general dispatching code also.
Quoted 5 lines
Quoted 1 line
Do you have any objections? :-)
How about just osx as a short prefix? That'll mirror os2. and looks less awkward. Otherwise the plan looks good.
Ok. I agree with "osx." prefix.
With the best regards,
Vyacheslav Dubeyko.
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Vyacheslav Dubeyko
maintainerOn Tue, 2012-11-13 at 14:34 -0800, Andrew Morton wrote:
[snip]
Quoted 4 lines
The code is missing a
flush_dcache_page()? We should have one in there after the CPU has modified userspace-mappable page contents.
Yes, I think your comment is precious. But I feel a necessity to analyze hfsplus driver code more deeply for proper fix of this issue. An userspace-mappable page content is the main use-case for such fix. But it exists the multi CPUs use-case. So, I need to think about correctness of hfsplus driver for such use-case also, I think.
Quoted 12 lines
btw, I still have question marks over your earlier patches:
hfsplus-add-on-disk-layout-declarations-related-to-attributes-tree.patch hfsplus-add-functionality-of-manipulating-by-records-in-attributes-tree.patch hfsplus-rework-functionality-of-getting-setting-and-deleting-of-extended-attributes.patch hfsplus-add-support-of-manipulation-by-attributes-file.patch hfsplus-add-support-of-manipulation-by-attributes-file-checkpatch-fixes.patch hfsplus-code-style-fixes-reworked-support-of-extended-attributes.patch
Christoph sounded unhappy, but the review discussion petered out?
So, as you can see the discussion revives again. :-) And I need to familiarize with implementation of xattrs in JFS before to answer again. I had objection that we need to remember about using HFS+ volumes as under Linux as under Mac OS X. Maybe, JFS implementation of xattrs to change my vision.
With the best regards,
Vyacheslav Dubeyko.
Quoted 24 lines · On Wed, 14 Nov 2012 16:50:53 +0400 Vyacheslav Dubeyko <[email protected]> wrote:
On Tue, 2012-11-13 at 14:34 -0800, Andrew Morton wrote:
[snip]
Quoted 4 lines
The code is missing a
flush_dcache_page()? We should have one in there after the CPU has modified userspace-mappable page contents.Yes, I think your comment is precious. But I feel a necessity to analyze hfsplus driver code more deeply for proper fix of this issue. An userspace-mappable page content is the main use-case for such fix. But it exists the multi CPUs use-case. So, I need to think about correctness of hfsplus driver for such use-case also, I think.
Quoted 10 lines
btw, I still have question marks over your earlier patches:
hfsplus-add-on-disk-layout-declarations-related-to-attributes-tree.patch hfsplus-add-functionality-of-manipulating-by-records-in-attributes-tree.patch hfsplus-rework-functionality-of-getting-setting-and-deleting-of-extended-attributes.patch hfsplus-add-support-of-manipulation-by-attributes-file.patch hfsplus-add-support-of-manipulation-by-attributes-file-checkpatch-fixes.patch hfsplus-code-style-fixes-reworked-support-of-extended-attributes.patch
Quoted 8 lines
Quoted 2 lines
Christoph sounded unhappy, but the review discussion petered out?
So, as you can see the discussion revives again. :-) And I need to familiarize with implementation of xattrs in JFS before to answer again. I had objection that we need to remember about using HFS+ volumes as under Linux as under Mac OS X. Maybe, JFS implementation of xattrs to change my vision.
I'm still unclear where we stand with these patches. Which if any of these should I merge?
Thanks.
hfsplus-avoid-crash-on-failed-block-map-free.patch
http://ozlabs.org/~akpm/mmots/broken-out/hfsplus-avoid-crash-on-failed-block-map-free.patch
hfsplus-add-osx-prefix-for-handling-namespace-of-mac-os-x-extended-attributes.patch
http://ozlabs.org/~akpm/mmots/broken-out/hfsplus-add-osx-prefix-for-handling-namespace-of-mac-os-x-extended-attributes.patch
hfsplus-add-on-disk-layout-declarations-related-to-attributes-tree.patch
http://ozlabs.org/~akpm/mmots/broken-out/hfsplus-add-on-disk-layout-declarations-related-to-attributes-tree.patch
hfsplus-add-functionality-of-manipulating-by-records-in-attributes-tree.patch
http://ozlabs.org/~akpm/mmots/broken-out/hfsplus-add-functionality-of-manipulating-by-records-in-attributes-tree.patch
hfsplus-rework-functionality-of-getting-setting-and-deleting-of-extended-attributes.patch
http://ozlabs.org/~akpm/mmots/broken-out/hfsplus-rework-functionality-of-getting-setting-and-deleting-of-extended-attributes.patch
hfsplus-add-support-of-manipulation-by-attributes-file.patch
http://ozlabs.org/~akpm/mmots/broken-out/hfsplus-add-support-of-manipulation-by-attributes-file.patch
hfsplus-rework-processing-errors-in-hfsplus_free_extents.patch
http://ozlabs.org/~akpm/mmots/broken-out/hfsplus-rework-processing-errors-in-hfsplus_free_extents.patch
hfsplus-rework-processing-of-hfs_btree_write-returned-error.patch
http://ozlabs.org/~akpm/mmots/broken-out/hfsplus-rework-processing-of-hfs_btree_write-returned-error.patch
hfsplus-add-error-message-for-the-case-of-failure-of-sync-fs-in-delayed_sync_fs-method.patch
http://ozlabs.org/~akpm/mmots/broken-out/hfsplus-add-error-message-for-the-case-of-failure-of-sync-fs-in-delayed_sync_fs-method.patch
Vyacheslav Dubeyko
maintainerQuoted 30 lines · Andrew Morton
Quoted 27 lines · On Wed, 14 Nov 2012 16:50:53 +0400 Vyacheslav Dubeyko <[email protected]> wrote:
On Tue, 2012-11-13 at 14:34 -0800, Andrew Morton wrote:
[snip]
Quoted 4 lines
The code is missing a
flush_dcache_page()? We should have one in there after the CPU has modified userspace-mappable page contents.Yes, I think your comment is precious. But I feel a necessity to analyze hfsplus driver code more deeply for proper fix of this issue. An userspace-mappable page content is the main use-case for such fix. But it exists the multi CPUs use-case. So, I need to think about correctness of hfsplus driver for such use-case also, I think.
Quoted 12 lines
btw, I still have question marks over your earlier patches:
hfsplus-add-on-disk-layout-declarations-related-to-attributes-tree.patch hfsplus-add-functionality-of-manipulating-by-records-in-attributes-tree.patch hfsplus-rework-functionality-of-getting-setting-and-deleting-of-extended-attributes.patch hfsplus-add-support-of-manipulation-by-attributes-file.patch hfsplus-add-support-of-manipulation-by-attributes-file-checkpatch-fixes.patch hfsplus-code-style-fixes-reworked-support-of-extended-attributes.patch
Christoph sounded unhappy, but the review discussion petered out?
Quoted 9 lines
Quoted 5 lines
So, as you can see the discussion revives again. :-) And I need to familiarize with implementation of xattrs in JFS before to answer again. I had objection that we need to remember about using HFS+ volumes as under Linux as under Mac OS X. Maybe, JFS implementation of xattrs to change my vision.
I'm still unclear where we stand with these patches. Which if any of these should I merge?
As I can see these patches contain implementation of xattr support (v3) and reworked error processing in some parts of hfsplus driver. The version 3 of xattr support was implemented after remarks of Christoph Hellwig about necessity to have "osx." prefix. So, after this e-mail we had achieved understanding about proper implementation and it was done.
Maybe I misunderstand something but I thought that these patches were merged in linux-next yet. Or do you talking about merging in mainline?
Currently, I am working on ACLs support in hfsplus driver. But, from my point of view, these patches are important and without ACLs support.
With the best regards,
Vyacheslav Dubeyko.
Quoted 29 lines
Thanks.
hfsplus-avoid-crash-on-failed-block-map-free.patch
http://ozlabs.org/~akpm/mmots/broken-out/hfsplus-avoid-crash-on-failed-block-map-free.patchhfsplus-add-osx-prefix-for-handling-namespace-of-mac-os-x-extended-attributes.patch
http://ozlabs.org/~akpm/mmots/broken-out/hfsplus-add-osx-prefix-for-handling-namespace-of-mac-os-x-extended-attributes.patchhfsplus-add-on-disk-layout-declarations-related-to-attributes-tree.patch
http://ozlabs.org/~akpm/mmots/broken-out/hfsplus-add-on-disk-layout-declarations-related-to-attributes-tree.patchhfsplus-add-functionality-of-manipulating-by-records-in-attributes-tree.patch
http://ozlabs.org/~akpm/mmots/broken-out/hfsplus-add-functionality-of-manipulating-by-records-in-attributes-tree.patchhfsplus-rework-functionality-of-getting-setting-and-deleting-of-extended-attributes.patch
http://ozlabs.org/~akpm/mmots/broken-out/hfsplus-rework-functionality-of-getting-setting-and-deleting-of-extended-attributes.patchhfsplus-add-support-of-manipulation-by-attributes-file.patch
http://ozlabs.org/~akpm/mmots/broken-out/hfsplus-add-support-of-manipulation-by-attributes-file.patchhfsplus-rework-processing-errors-in-hfsplus_free_extents.patch
http://ozlabs.org/~akpm/mmots/broken-out/hfsplus-rework-processing-errors-in-hfsplus_free_extents.patchhfsplus-rework-processing-of-hfs_btree_write-returned-error.patch
http://ozlabs.org/~akpm/mmots/broken-out/hfsplus-rework-processing-of-hfs_btree_write-returned-error.patchhfsplus-add-error-message-for-the-case-of-failure-of-sync-fs-in-delayed_sync_fs-method.patch
http://ozlabs.org/~akpm/mmots/broken-out/hfsplus-add-error-message-for-the-case-of-failure-of-sync-fs-in-delayed_sync_fs-method.patch
Quoted 16 lines · On Wed, 19 Dec 2012 10:26:37 +0400 Vyacheslav Dubeyko <[email protected]> wrote:
Quoted 9 lines
Quoted 5 lines
So, as you can see the discussion revives again. :-) And I need to familiarize with implementation of xattrs in JFS before to answer again. I had objection that we need to remember about using HFS+ volumes as under Linux as under Mac OS X. Maybe, JFS implementation of xattrs to change my vision.
I'm still unclear where we stand with these patches. Which if any of these should I merge?
As I can see these patches contain implementation of xattr support (v3) and reworked error processing in some parts of hfsplus driver. The version 3 of xattr support was implemented after remarks of Christoph Hellwig about necessity to have "osx." prefix. So, after this e-mail we had achieved understanding about proper implementation and it was done.
Quoted 5 lines
Maybe I misunderstand something but I thought that these patches were merged in linux-next yet. Or do you talking about merging in mainline?
Currently, I am working on ACLs support in hfsplus driver. But, from my point of view, these patches are important and without ACLs support.
Yes, they've all been in linux-next for a while.
To be more specific: is Christoph OK with a mainline merge?
Vyacheslav Dubeyko
maintainerQuoted 21 lines · Andrew Morton
Quoted 19 lines · On Wed, 19 Dec 2012 10:26:37 +0400 Vyacheslav Dubeyko <[email protected]> wrote:
Quoted 9 lines
Quoted 5 lines
So, as you can see the discussion revives again. :-) And I need to familiarize with implementation of xattrs in JFS before to answer again. I had objection that we need to remember about using HFS+ volumes as under Linux as under Mac OS X. Maybe, JFS implementation of xattrs to change my vision.
I'm still unclear where we stand with these patches. Which if any of these should I merge?
As I can see these patches contain implementation of xattr support (v3) and reworked error processing in some parts of hfsplus driver. The version 3 of xattr support was implemented after remarks of Christoph Hellwig about necessity to have "osx." prefix. So, after this e-mail we had achieved understanding about proper implementation and it was done.
Maybe I misunderstand something but I thought that these patches were merged in linux-next yet. Or do you talking about merging in mainline?
Quoted 6 lines
Quoted 2 lines
Currently, I am working on ACLs support in hfsplus driver. But, from my point of view, these patches are important and without ACLs support.
Yes, they've all been in linux-next for a while.
To be more specific: is Christoph OK with a mainline merge?
I think that we need to ask his about it. :-) I haven't any private e-mailing with him about it.
Maybe, it makes sense to merge in mainline reworked error processing patches previously and, then, to merge the xattr support after ACLs support implementation.
Christoph, could you share your opinion?
With the best regards,
Vyacheslav Dubeyko.
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 4 lines · Vyacheslav Dubeyko
Quoted 3 lines
Yes, they've all been in linux-next for a while.
To be more specific: is Christoph OK with a mainline merge?
Quoted 8 lines
I think that we need to ask his about it. :-) I haven't any private e-mailing with him about it.
Maybe, it makes sense to merge in mainline reworked error processing patches previously and, then, to merge the xattr support after ACLs support implementation.
Christoph, could you share your opinion?
I haven't actually managed to look at your new xattr patches, but at least conceptually I'm fine with them.
Let's get the error handling and misc hfsplus patches in ASAP, in the meantime I'll get a review for the xattr bits in, and then we can decide to merge them directly or together with the ACL bits.
Vyacheslav Dubeyko
maintainerQuoted 12 lines · Christoph Hellwig
Quoted 11 lines · Vyacheslav Dubeyko
Quoted 3 lines
Yes, they've all been in linux-next for a while.
To be more specific: is Christoph OK with a mainline merge?
I think that we need to ask his about it. :-) I haven't any private e-mailing with him about it.
Maybe, it makes sense to merge in mainline reworked error processing patches previously and, then, to merge the xattr support after ACLs support implementation.
Quoted 9 lines
Quoted 1 line
Christoph, could you share your opinion?
I haven't actually managed to look at your new xattr patches, but at least conceptually I'm fine with them.
Let's get the error handling and misc hfsplus patches in ASAP, in the meantime I'll get a review for the xattr bits in, and then we can decide to merge them directly or together with the ACL bits.
Ok. Thank you.
With the best regards,
Vyacheslav Dubeyko.
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html