LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] Terminate hugetlbfs mount argument list
@ 2008-03-11 22:42 Andi Kleen
  2008-03-11 22:48 ` Roland Dreier
  0 siblings, 1 reply; 4+ messages in thread
From: Andi Kleen @ 2008-03-11 22:42 UTC (permalink / raw)
  To: akpm, wli, linux-kernel

Terminate hugetlbfs mount argument list

[2.6.25 candidate I believe]

The match_table_t for the mount arguments in hugetlbfs wasn't 
terminated as match_tokens expect. I didn't see a crash just code
audit, but it's still safer to terminate it in case the variables after
that in .data are not NULL.

Signed-off-by: Andi Kleen <ak@suse.de>

Index: linux/fs/hugetlbfs/inode.c
===================================================================
--- linux.orig/fs/hugetlbfs/inode.c
+++ linux/fs/hugetlbfs/inode.c
@@ -63,6 +63,7 @@ static match_table_t tokens = {
 	{Opt_uid,	"uid=%u"},
 	{Opt_gid,	"gid=%u"},
 	{Opt_err,	NULL},
+	{},
 };
 
 static void huge_pagevec_release(struct pagevec *pvec)

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

* Re: [PATCH] Terminate hugetlbfs mount argument list
  2008-03-11 22:42 [PATCH] Terminate hugetlbfs mount argument list Andi Kleen
@ 2008-03-11 22:48 ` Roland Dreier
  2008-03-11 22:56   ` Andi Kleen
  0 siblings, 1 reply; 4+ messages in thread
From: Roland Dreier @ 2008-03-11 22:48 UTC (permalink / raw)
  To: Andi Kleen; +Cc: akpm, wli, linux-kernel

 > The match_table_t for the mount arguments in hugetlbfs wasn't 
 > terminated as match_tokens expect. I didn't see a crash just code
 > audit, but it's still safer to terminate it in case the variables after
 > that in .data are not NULL.

I think you're misunderstanding the match_token() interface.  The
comment before match_token() says:

 * @table: match_table_t describing the set of allowed option tokens and the
 * arguments that may be associated with them. Must be terminated with a
 * &struct match_token whose pattern is set to the NULL pointer.

and that's exactly what already exists here:

 	{Opt_gid,	"gid=%u"},
 	{Opt_err,	NULL},

So your patch is effectively an obfuscated NOP.

 - R.

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

* Re: [PATCH] Terminate hugetlbfs mount argument list
  2008-03-11 22:48 ` Roland Dreier
@ 2008-03-11 22:56   ` Andi Kleen
  2008-03-11 23:26     ` Roland Dreier
  0 siblings, 1 reply; 4+ messages in thread
From: Andi Kleen @ 2008-03-11 22:56 UTC (permalink / raw)
  To: Roland Dreier; +Cc: Andi Kleen, akpm, wli, linux-kernel

On Tue, Mar 11, 2008 at 03:48:46PM -0700, Roland Dreier wrote:
>  > The match_table_t for the mount arguments in hugetlbfs wasn't 
>  > terminated as match_tokens expect. I didn't see a crash just code
>  > audit, but it's still safer to terminate it in case the variables after
>  > that in .data are not NULL.
> 
> I think you're misunderstanding the match_token() interface.  The
> comment before match_token() says:

Hmm indeed I did. To my defense it's a weird unusual coding pattern
that tricked me.  What good is it to give terminator elements own enum values?

-Andi

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

* Re: [PATCH] Terminate hugetlbfs mount argument list
  2008-03-11 22:56   ` Andi Kleen
@ 2008-03-11 23:26     ` Roland Dreier
  0 siblings, 0 replies; 4+ messages in thread
From: Roland Dreier @ 2008-03-11 23:26 UTC (permalink / raw)
  To: Andi Kleen; +Cc: akpm, wli, linux-kernel

 > Hmm indeed I did. To my defense it's a weird unusual coding pattern
 > that tricked me.  What good is it to give terminator elements own enum values?

It's a little odd.  But I guess it does let you do

	token = match_token(...table...);
	switch (token) {
	case ERR_VALUE:...

and get ERR_VALUE back for anything that doesn't match one of the real
token patterns.

 - R.

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

end of thread, other threads:[~2008-03-11 23:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-11 22:42 [PATCH] Terminate hugetlbfs mount argument list Andi Kleen
2008-03-11 22:48 ` Roland Dreier
2008-03-11 22:56   ` Andi Kleen
2008-03-11 23:26     ` Roland Dreier

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).