* [PATCH 2/2] turn BUG_ON for out of bound in mb_cache_entry_find_first/mb_cache_entry_find_next
@ 2010-07-18 13:57 Wang Sheng-Hui
2010-07-18 13:59 ` shenghui
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Wang Sheng-Hui @ 2010-07-18 13:57 UTC (permalink / raw)
To: linux-fsdevel, viro, linux-mm, linux-ext4, kernel-janitors
In mb_cache_entry_find_first/mb_cache_entry_find_next, macro
mb_assert is used to do assertion on index, but it just prints
KERN_ERR info if defined.
Currently, only ext2/ext3/ext4 use the function with index set 0.
But for potential usage by other subsystems, I think we shoud report BUG
if we got some index out of bound here.
Following patch is against 2.6.35-rc3, and should be
applied after the first patch.Please check it.
Signed-off-by: Wang Sheng-Hui <crosslonelyover@gmail.com>
---
fs/mbcache.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/mbcache.c b/fs/mbcache.c
index 5697d9e..ed25979 100644
--- a/fs/mbcache.c
+++ b/fs/mbcache.c
@@ -614,7 +614,7 @@ mb_cache_entry_find_first(struct mb_cache *cache,
int index,
struct list_head *l;
struct mb_cache_entry *ce;
- mb_assert(index < mb_cache_indexes(cache));
+ BUG_ON((index < 0) || (index >= mb_cache_indexes(cache)));
spin_lock(&mb_cache_spinlock);
l = cache->c_indexes_hash[index][bucket].next;
ce = __mb_cache_entry_find(l, &cache->c_indexes_hash[index][bucket],
@@ -652,7 +652,7 @@ mb_cache_entry_find_next(struct mb_cache_entry
*prev, int index,
struct list_head *l;
struct mb_cache_entry *ce;
- mb_assert(index < mb_cache_indexes(cache));
+ BUG_ON((index < 0) || (index >= mb_cache_indexes(cache)));
spin_lock(&mb_cache_spinlock);
l = prev->e_indexes[index].o_list.next;
ce = __mb_cache_entry_find(l, &cache->c_indexes_hash[index][bucket],
--
1.7.1.1
--
Thanks and Regards,
shenghui
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] turn BUG_ON for out of bound in mb_cache_entry_find_first/mb_cache_entry_find_next
2010-07-18 13:57 [PATCH 2/2] turn BUG_ON for out of bound in mb_cache_entry_find_first/mb_cache_entry_find_next Wang Sheng-Hui
@ 2010-07-18 13:59 ` shenghui
2010-07-18 23:35 ` shenghui
2010-07-19 11:09 ` [PATCH 2/2] turn BUG_ON for out of bound in Lukas Czerner
2 siblings, 0 replies; 4+ messages in thread
From: shenghui @ 2010-07-18 13:59 UTC (permalink / raw)
To: linux-fsdevel, viro, linux-mm, linux-ext4, kernel-janitors
在 2010年7月18日 下午9:57,Wang Sheng-Hui <crosslonelyover@gmail.com> 写道:
> In mb_cache_entry_find_first/mb_cache_entry_find_next, macro
> mb_assert is used to do assertion on index, but it just prints
> KERN_ERR info if defined.
> Currently, only ext2/ext3/ext4 use the function with index set 0.
> But for potential usage by other subsystems, I think we shoud report BUG
> if we got some index out of bound here.
>
>
> Following patch is against 2.6.35-rc3, and should be
> applied after the first patch.Please check it.
>
Sorry, made a typo. It's against 2.6.35-rc5.
--
Thanks and Best Regards,
shenghui
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] turn BUG_ON for out of bound in mb_cache_entry_find_first/mb_cache_entry_find_next
2010-07-18 13:57 [PATCH 2/2] turn BUG_ON for out of bound in mb_cache_entry_find_first/mb_cache_entry_find_next Wang Sheng-Hui
2010-07-18 13:59 ` shenghui
@ 2010-07-18 23:35 ` shenghui
2010-07-19 11:09 ` [PATCH 2/2] turn BUG_ON for out of bound in Lukas Czerner
2 siblings, 0 replies; 4+ messages in thread
From: shenghui @ 2010-07-18 23:35 UTC (permalink / raw)
To: linux-fsdevel, viro, linux-mm, linux-ext4, kernel-janitors,
error27
Sorry. Will you recommend to me one mail client?
I have been suffering reformat by client these days.
Thanks,
Signed-off-by: Wang Sheng-Hui <crosslonelyover@gmail.com>
---
fs/mbcache.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/mbcache.c b/fs/mbcache.c
index 5697d9e..5f96b82 100644
--- a/fs/mbcache.c
+++ b/fs/mbcache.c
@@ -614,7 +614,7 @@ mb_cache_entry_find_first(struct mb_cache *cache, int index,
struct list_head *l;
struct mb_cache_entry *ce;
- mb_assert(index < mb_cache_indexes(cache));
+ BUG_ON(!(index < mb_cache_indexes(cache)));
spin_lock(&mb_cache_spinlock);
l = cache->c_indexes_hash[index][bucket].next;
ce = __mb_cache_entry_find(l, &cache->c_indexes_hash[index][bucket],
@@ -652,7 +652,7 @@ mb_cache_entry_find_next(struct mb_cache_entry *prev, int index,
struct list_head *l;
struct mb_cache_entry *ce;
- mb_assert(index < mb_cache_indexes(cache));
+ BUG_ON(!(index < mb_cache_indexes(cache)));
spin_lock(&mb_cache_spinlock);
l = prev->e_indexes[index].o_list.next;
ce = __mb_cache_entry_find(l, &cache->c_indexes_hash[index][bucket],
--
1.7.1.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] turn BUG_ON for out of bound in
2010-07-18 13:57 [PATCH 2/2] turn BUG_ON for out of bound in mb_cache_entry_find_first/mb_cache_entry_find_next Wang Sheng-Hui
2010-07-18 13:59 ` shenghui
2010-07-18 23:35 ` shenghui
@ 2010-07-19 11:09 ` Lukas Czerner
2 siblings, 0 replies; 4+ messages in thread
From: Lukas Czerner @ 2010-07-19 11:09 UTC (permalink / raw)
To: kernel-janitors
On Mon, 19 Jul 2010, shenghui wrote:
> Sorry. Will you recommend to me one mail client?
> I have been suffering reformat by client these days.
> Thanks,
Mutt, or Alpine will be a very good choice.
This can be also useful:
Documentation/SubmittingPatches
Documentation/email-clients.txt
Cheers
-Lukas
>
>
> Signed-off-by: Wang Sheng-Hui <crosslonelyover@gmail.com>
> ---
> fs/mbcache.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/mbcache.c b/fs/mbcache.c
> index 5697d9e..5f96b82 100644
> --- a/fs/mbcache.c
> +++ b/fs/mbcache.c
> @@ -614,7 +614,7 @@ mb_cache_entry_find_first(struct mb_cache *cache, int
> index,
> struct list_head *l;
> struct mb_cache_entry *ce;
>
> - mb_assert(index < mb_cache_indexes(cache));
> + BUG_ON(!(index < mb_cache_indexes(cache)));
> spin_lock(&mb_cache_spinlock);
> l = cache->c_indexes_hash[index][bucket].next;
> ce = __mb_cache_entry_find(l, &cache->c_indexes_hash[index][bucket],
> @@ -652,7 +652,7 @@ mb_cache_entry_find_next(struct mb_cache_entry *prev, int
> index,
> struct list_head *l;
> struct mb_cache_entry *ce;
>
> - mb_assert(index < mb_cache_indexes(cache));
> + BUG_ON(!(index < mb_cache_indexes(cache)));
> spin_lock(&mb_cache_spinlock);
> l = prev->e_indexes[index].o_list.next;
> ce = __mb_cache_entry_find(l, &cache->c_indexes_hash[index][bucket],
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-07-19 11:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-18 13:57 [PATCH 2/2] turn BUG_ON for out of bound in mb_cache_entry_find_first/mb_cache_entry_find_next Wang Sheng-Hui
2010-07-18 13:59 ` shenghui
2010-07-18 23:35 ` shenghui
2010-07-19 11:09 ` [PATCH 2/2] turn BUG_ON for out of bound in Lukas Czerner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).