All of lore.kernel.org
 help / color / mirror / Atom feed
* [Ocfs2-devel] ocfs2: some xattr fixes
@ 2008-10-23  8:26 Tiger Yang
  2008-10-23  8:33 ` [Ocfs2-devel] [PATCH 1/4] ocfs2: fix license in xattr Tiger Yang
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Tiger Yang @ 2008-10-23  8:26 UTC (permalink / raw)
  To: ocfs2-devel

Makr, Joel,

There are 4 fixes for xattr. The top 3 patches in the first patch of acl 
v3 patches before. The fourth patch is a new fix due to I met a bug 
about this.

1. fix licence in xattr
2. fix function declaration in xattr
3. remove duplicate definition in xattr
4. add array bounds checking

Best regards,
tiger

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

* [Ocfs2-devel] [PATCH 1/4] ocfs2: fix license in xattr
  2008-10-23  8:26 [Ocfs2-devel] ocfs2: some xattr fixes Tiger Yang
@ 2008-10-23  8:33 ` Tiger Yang
  2008-10-23  9:22   ` Joel Becker
  2008-10-23  8:33 ` [Ocfs2-devel] [PATCH 2/4] ocfs2: fix function declaration and definition " Tiger Yang
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: Tiger Yang @ 2008-10-23  8:33 UTC (permalink / raw)
  To: ocfs2-devel

This patch fix license in xattr.c and xattr.h.

Signed-off-by: Tiger Yang <tiger.yang@oracle.com>
---
 fs/ocfs2/xattr.c |   13 ++++---------
 fs/ocfs2/xattr.h |   12 ++----------
 2 files changed, 6 insertions(+), 19 deletions(-)

diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index 0239078..baa4825 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -3,25 +3,20 @@
  *
  * xattr.c
  *
- * Copyright (C) 2008 Oracle.  All rights reserved.
+ * Copyright (C) 2004, 2008 Oracle.  All rights reserved.
  *
  * CREDITS:
- * Lots of code in this file is taken from ext3.
+ * Lots of code in this file is copy from linux/fs/ext3/xattr.c.
+ * Copyright (C) 2001-2003 Andreas Gruenbacher, <agruen@suse.de>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * License version 2 as published by the Free Software Foundation.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 021110-1307, USA.
  */
 
 #include <linux/capability.h>
diff --git a/fs/ocfs2/xattr.h b/fs/ocfs2/xattr.h
index c25c7c6..e4e45c8 100644
--- a/fs/ocfs2/xattr.h
+++ b/fs/ocfs2/xattr.h
@@ -3,24 +3,16 @@
  *
  * xattr.h
  *
- * Function prototypes
- *
- * Copyright (C) 2008 Oracle.  All rights reserved.
+ * Copyright (C) 2004, 2008 Oracle.  All rights reserved.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * License version 2 as published by the Free Software Foundation.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 021110-1307, USA.
  */
 
 #ifndef OCFS2_XATTR_H
-- 
1.5.4.1

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

* [Ocfs2-devel] [PATCH 2/4] ocfs2: fix function declaration and definition in xattr
  2008-10-23  8:26 [Ocfs2-devel] ocfs2: some xattr fixes Tiger Yang
  2008-10-23  8:33 ` [Ocfs2-devel] [PATCH 1/4] ocfs2: fix license in xattr Tiger Yang
@ 2008-10-23  8:33 ` Tiger Yang
  2008-10-23  9:23   ` Joel Becker
  2008-10-23  8:34 ` [Ocfs2-devel] [PATCH 3/4] ocfs2: remove duplicate " Tiger Yang
  2008-10-23  8:34 ` [Ocfs2-devel] [PATCH 4/4] ocfs2: add array bounds checking Tiger Yang
  3 siblings, 1 reply; 11+ messages in thread
From: Tiger Yang @ 2008-10-23  8:33 UTC (permalink / raw)
  To: ocfs2-devel

Because we merge split xattr files into one file, some functions
no need declare or define in the head file.

Signed-off-by: Tiger Yang <tiger.yang@oracle.com>
---
 fs/ocfs2/xattr.c |   28 +++++++++++++++++++++++-----
 fs/ocfs2/xattr.h |   26 ++++----------------------
 2 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index baa4825..667525b 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -142,6 +142,24 @@ static int ocfs2_xattr_set_entry_index_block(struct inode *inode,
 static int ocfs2_delete_xattr_index_block(struct inode *inode,
 					  struct buffer_head *xb_bh);
 
+static inline u16 ocfs2_xattr_buckets_per_cluster(struct ocfs2_super *osb)
+{
+	return (1 << osb->s_clustersize_bits) / OCFS2_XATTR_BUCKET_SIZE;
+}
+
+static inline u16 ocfs2_blocks_per_xattr_bucket(struct super_block *sb)
+{
+	return OCFS2_XATTR_BUCKET_SIZE / (1 << sb->s_blocksize_bits);
+}
+
+static inline u16 ocfs2_xattr_max_xe_in_bucket(struct super_block *sb)
+{
+	u16 len = sb->s_blocksize -
+		 offsetof(struct ocfs2_xattr_header, xh_entries);
+
+	return len / sizeof(struct ocfs2_xattr_entry);
+}
+
 static inline const char *ocfs2_xattr_prefix(int name_index)
 {
 	struct xattr_handler *handler = NULL;
@@ -793,11 +811,11 @@ cleanup:
  * Copy an extended attribute into the buffer provided.
  * Buffer is NULL to compute the size of buffer required.
  */
-int ocfs2_xattr_get(struct inode *inode,
-		    int name_index,
-		    const char *name,
-		    void *buffer,
-		    size_t buffer_size)
+static int ocfs2_xattr_get(struct inode *inode,
+			   int name_index,
+			   const char *name,
+			   void *buffer,
+			   size_t buffer_size)
 {
 	int ret;
 	struct ocfs2_dinode *di = NULL;
diff --git a/fs/ocfs2/xattr.h b/fs/ocfs2/xattr.h
index e4e45c8..1d8314c 100644
--- a/fs/ocfs2/xattr.h
+++ b/fs/ocfs2/xattr.h
@@ -32,29 +32,11 @@ enum ocfs2_xattr_type {
 
 extern struct xattr_handler ocfs2_xattr_user_handler;
 extern struct xattr_handler ocfs2_xattr_trusted_handler;
-
-extern ssize_t ocfs2_listxattr(struct dentry *, char *, size_t);
-extern int ocfs2_xattr_get(struct inode *, int, const char *, void *, size_t);
-extern int ocfs2_xattr_set(struct inode *, int, const char *, const void *,
-			   size_t, int);
-extern int ocfs2_xattr_remove(struct inode *inode, struct buffer_head *di_bh);
 extern struct xattr_handler *ocfs2_xattr_handlers[];
 
-static inline u16 ocfs2_xattr_buckets_per_cluster(struct ocfs2_super *osb)
-{
-	return (1 << osb->s_clustersize_bits) / OCFS2_XATTR_BUCKET_SIZE;
-}
-
-static inline u16 ocfs2_blocks_per_xattr_bucket(struct super_block *sb)
-{
-	return OCFS2_XATTR_BUCKET_SIZE / (1 << sb->s_blocksize_bits);
-}
-
-static inline u16 ocfs2_xattr_max_xe_in_bucket(struct super_block *sb)
-{
-	u16 len = sb->s_blocksize -
-		 offsetof(struct ocfs2_xattr_header, xh_entries);
+ssize_t ocfs2_listxattr(struct dentry *, char *, size_t);
+int ocfs2_xattr_set(struct inode *, int, const char *, const void *,
+		    size_t, int);
+int ocfs2_xattr_remove(struct inode *, struct buffer_head *);
 
-	return len / sizeof(struct ocfs2_xattr_entry);
-}
 #endif /* OCFS2_XATTR_H */
-- 
1.5.4.1

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

* [Ocfs2-devel] [PATCH 3/4] ocfs2: remove duplicate definition in xattr
  2008-10-23  8:26 [Ocfs2-devel] ocfs2: some xattr fixes Tiger Yang
  2008-10-23  8:33 ` [Ocfs2-devel] [PATCH 1/4] ocfs2: fix license in xattr Tiger Yang
  2008-10-23  8:33 ` [Ocfs2-devel] [PATCH 2/4] ocfs2: fix function declaration and definition " Tiger Yang
@ 2008-10-23  8:34 ` Tiger Yang
  2008-10-23  9:25   ` Joel Becker
  2008-10-23  8:34 ` [Ocfs2-devel] [PATCH 4/4] ocfs2: add array bounds checking Tiger Yang
  3 siblings, 1 reply; 11+ messages in thread
From: Tiger Yang @ 2008-10-23  8:34 UTC (permalink / raw)
  To: ocfs2-devel

Include/linux/xattr.h already has the definition about xattr prefix,
so remove the duplicate definitions in xattr.c.

Signed-off-by: Tiger Yang <tiger.yang@oracle.com>
---
 fs/ocfs2/xattr.c |   11 ++---------
 1 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index 667525b..754e5fa 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -4830,14 +4830,11 @@ out:
 /*
  * 'trusted' attributes support
  */
-
-#define XATTR_TRUSTED_PREFIX "trusted."
-
 static size_t ocfs2_xattr_trusted_list(struct inode *inode, char *list,
 				       size_t list_size, const char *name,
 				       size_t name_len)
 {
-	const size_t prefix_len = sizeof(XATTR_TRUSTED_PREFIX) - 1;
+	const size_t prefix_len = XATTR_TRUSTED_PREFIX_LEN;
 	const size_t total_len = prefix_len + name_len + 1;
 
 	if (list && total_len <= list_size) {
@@ -4874,18 +4871,14 @@ struct xattr_handler ocfs2_xattr_trusted_handler = {
 	.set	= ocfs2_xattr_trusted_set,
 };
 
-
 /*
  * 'user' attributes support
  */
-
-#define XATTR_USER_PREFIX "user."
-
 static size_t ocfs2_xattr_user_list(struct inode *inode, char *list,
 				    size_t list_size, const char *name,
 				    size_t name_len)
 {
-	const size_t prefix_len = sizeof(XATTR_USER_PREFIX) - 1;
+	const size_t prefix_len = XATTR_USER_PREFIX_LEN;
 	const size_t total_len = prefix_len + name_len + 1;
 	struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
 
-- 
1.5.4.1

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

* [Ocfs2-devel] [PATCH 4/4] ocfs2: add array bounds checking
  2008-10-23  8:26 [Ocfs2-devel] ocfs2: some xattr fixes Tiger Yang
                   ` (2 preceding siblings ...)
  2008-10-23  8:34 ` [Ocfs2-devel] [PATCH 3/4] ocfs2: remove duplicate " Tiger Yang
@ 2008-10-23  8:34 ` Tiger Yang
  2008-10-23  9:30   ` Joel Becker
  3 siblings, 1 reply; 11+ messages in thread
From: Tiger Yang @ 2008-10-23  8:34 UTC (permalink / raw)
  To: ocfs2-devel

This could avoid arry bounds exceeded issue.

Signed-off-by: Tiger Yang <tiger.yang@oracle.com>
---
 fs/ocfs2/xattr.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index 754e5fa..888641d 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -164,7 +164,7 @@ static inline const char *ocfs2_xattr_prefix(int name_index)
 {
 	struct xattr_handler *handler = NULL;
 
-	if (name_index > 0 && name_index < OCFS2_XATTR_MAX)
+	if (name_index > 0 && name_index < ARRAY_SIZE(ocfs2_xattr_handler_map))
 		handler = ocfs2_xattr_handler_map[name_index];
 
 	return handler ? handler->prefix : NULL;
-- 
1.5.4.1

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

* [Ocfs2-devel] [PATCH 1/4] ocfs2: fix license in xattr
  2008-10-23  8:33 ` [Ocfs2-devel] [PATCH 1/4] ocfs2: fix license in xattr Tiger Yang
@ 2008-10-23  9:22   ` Joel Becker
  0 siblings, 0 replies; 11+ messages in thread
From: Joel Becker @ 2008-10-23  9:22 UTC (permalink / raw)
  To: ocfs2-devel

On Thu, Oct 23, 2008 at 04:33:03PM +0800, Tiger Yang wrote:
> This patch fix license in xattr.c and xattr.h.
> 
> Signed-off-by: Tiger Yang <tiger.yang@oracle.com>
Signed-off-by: Joel Becker <joel.becker@oracle.com>

> ---
>  fs/ocfs2/xattr.c |   13 ++++---------
>  fs/ocfs2/xattr.h |   12 ++----------
>  2 files changed, 6 insertions(+), 19 deletions(-)
> 
> diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
> index 0239078..baa4825 100644
> --- a/fs/ocfs2/xattr.c
> +++ b/fs/ocfs2/xattr.c
> @@ -3,25 +3,20 @@
>   *
>   * xattr.c
>   *
> - * Copyright (C) 2008 Oracle.  All rights reserved.
> + * Copyright (C) 2004, 2008 Oracle.  All rights reserved.
>   *
>   * CREDITS:
> - * Lots of code in this file is taken from ext3.
> + * Lots of code in this file is copy from linux/fs/ext3/xattr.c.
> + * Copyright (C) 2001-2003 Andreas Gruenbacher, <agruen@suse.de>
>   *
>   * This program is free software; you can redistribute it and/or
>   * modify it under the terms of the GNU General Public
> - * License as published by the Free Software Foundation; either
> - * version 2 of the License, or (at your option) any later version.
> + * License version 2 as published by the Free Software Foundation.
>   *
>   * This program is distributed in the hope that it will be useful,
>   * but WITHOUT ANY WARRANTY; without even the implied warranty of
>   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>   * General Public License for more details.
> - *
> - * You should have received a copy of the GNU General Public
> - * License along with this program; if not, write to the
> - * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
> - * Boston, MA 021110-1307, USA.
>   */
>  
>  #include <linux/capability.h>
> diff --git a/fs/ocfs2/xattr.h b/fs/ocfs2/xattr.h
> index c25c7c6..e4e45c8 100644
> --- a/fs/ocfs2/xattr.h
> +++ b/fs/ocfs2/xattr.h
> @@ -3,24 +3,16 @@
>   *
>   * xattr.h
>   *
> - * Function prototypes
> - *
> - * Copyright (C) 2008 Oracle.  All rights reserved.
> + * Copyright (C) 2004, 2008 Oracle.  All rights reserved.
>   *
>   * This program is free software; you can redistribute it and/or
>   * modify it under the terms of the GNU General Public
> - * License as published by the Free Software Foundation; either
> - * version 2 of the License, or (at your option) any later version.
> + * License version 2 as published by the Free Software Foundation.
>   *
>   * This program is distributed in the hope that it will be useful,
>   * but WITHOUT ANY WARRANTY; without even the implied warranty of
>   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>   * General Public License for more details.
> - *
> - * You should have received a copy of the GNU General Public
> - * License along with this program; if not, write to the
> - * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
> - * Boston, MA 021110-1307, USA.
>   */
>  
>  #ifndef OCFS2_XATTR_H
> -- 
> 1.5.4.1
> 

-- 

"Depend on the rabbit's foot if you will, but remember, it didn't
 help the rabbit."
	- R. E. Shay

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127

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

* [Ocfs2-devel] [PATCH 2/4] ocfs2: fix function declaration and definition in xattr
  2008-10-23  8:33 ` [Ocfs2-devel] [PATCH 2/4] ocfs2: fix function declaration and definition " Tiger Yang
@ 2008-10-23  9:23   ` Joel Becker
  0 siblings, 0 replies; 11+ messages in thread
From: Joel Becker @ 2008-10-23  9:23 UTC (permalink / raw)
  To: ocfs2-devel

On Thu, Oct 23, 2008 at 04:33:33PM +0800, Tiger Yang wrote:
> Because we merge split xattr files into one file, some functions
> no need declare or define in the head file.
> 
> Signed-off-by: Tiger Yang <tiger.yang@oracle.com>
Signed-off-by: Joel Becker <joel.becker@oracle.com>

> ---
>  fs/ocfs2/xattr.c |   28 +++++++++++++++++++++++-----
>  fs/ocfs2/xattr.h |   26 ++++----------------------
>  2 files changed, 27 insertions(+), 27 deletions(-)
> 
> diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
> index baa4825..667525b 100644
> --- a/fs/ocfs2/xattr.c
> +++ b/fs/ocfs2/xattr.c
> @@ -142,6 +142,24 @@ static int ocfs2_xattr_set_entry_index_block(struct inode *inode,
>  static int ocfs2_delete_xattr_index_block(struct inode *inode,
>  					  struct buffer_head *xb_bh);
>  
> +static inline u16 ocfs2_xattr_buckets_per_cluster(struct ocfs2_super *osb)
> +{
> +	return (1 << osb->s_clustersize_bits) / OCFS2_XATTR_BUCKET_SIZE;
> +}
> +
> +static inline u16 ocfs2_blocks_per_xattr_bucket(struct super_block *sb)
> +{
> +	return OCFS2_XATTR_BUCKET_SIZE / (1 << sb->s_blocksize_bits);
> +}
> +
> +static inline u16 ocfs2_xattr_max_xe_in_bucket(struct super_block *sb)
> +{
> +	u16 len = sb->s_blocksize -
> +		 offsetof(struct ocfs2_xattr_header, xh_entries);
> +
> +	return len / sizeof(struct ocfs2_xattr_entry);
> +}
> +
>  static inline const char *ocfs2_xattr_prefix(int name_index)
>  {
>  	struct xattr_handler *handler = NULL;
> @@ -793,11 +811,11 @@ cleanup:
>   * Copy an extended attribute into the buffer provided.
>   * Buffer is NULL to compute the size of buffer required.
>   */
> -int ocfs2_xattr_get(struct inode *inode,
> -		    int name_index,
> -		    const char *name,
> -		    void *buffer,
> -		    size_t buffer_size)
> +static int ocfs2_xattr_get(struct inode *inode,
> +			   int name_index,
> +			   const char *name,
> +			   void *buffer,
> +			   size_t buffer_size)
>  {
>  	int ret;
>  	struct ocfs2_dinode *di = NULL;
> diff --git a/fs/ocfs2/xattr.h b/fs/ocfs2/xattr.h
> index e4e45c8..1d8314c 100644
> --- a/fs/ocfs2/xattr.h
> +++ b/fs/ocfs2/xattr.h
> @@ -32,29 +32,11 @@ enum ocfs2_xattr_type {
>  
>  extern struct xattr_handler ocfs2_xattr_user_handler;
>  extern struct xattr_handler ocfs2_xattr_trusted_handler;
> -
> -extern ssize_t ocfs2_listxattr(struct dentry *, char *, size_t);
> -extern int ocfs2_xattr_get(struct inode *, int, const char *, void *, size_t);
> -extern int ocfs2_xattr_set(struct inode *, int, const char *, const void *,
> -			   size_t, int);
> -extern int ocfs2_xattr_remove(struct inode *inode, struct buffer_head *di_bh);
>  extern struct xattr_handler *ocfs2_xattr_handlers[];
>  
> -static inline u16 ocfs2_xattr_buckets_per_cluster(struct ocfs2_super *osb)
> -{
> -	return (1 << osb->s_clustersize_bits) / OCFS2_XATTR_BUCKET_SIZE;
> -}
> -
> -static inline u16 ocfs2_blocks_per_xattr_bucket(struct super_block *sb)
> -{
> -	return OCFS2_XATTR_BUCKET_SIZE / (1 << sb->s_blocksize_bits);
> -}
> -
> -static inline u16 ocfs2_xattr_max_xe_in_bucket(struct super_block *sb)
> -{
> -	u16 len = sb->s_blocksize -
> -		 offsetof(struct ocfs2_xattr_header, xh_entries);
> +ssize_t ocfs2_listxattr(struct dentry *, char *, size_t);
> +int ocfs2_xattr_set(struct inode *, int, const char *, const void *,
> +		    size_t, int);
> +int ocfs2_xattr_remove(struct inode *, struct buffer_head *);
>  
> -	return len / sizeof(struct ocfs2_xattr_entry);
> -}
>  #endif /* OCFS2_XATTR_H */
> -- 
> 1.5.4.1
> 

-- 

"The real reason GNU ls is 8-bit-clean is so that they can
 start using ISO-8859-1 option characters."
	- Christopher Davis (ckd at loiosh.kei.com)

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127

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

* [Ocfs2-devel] [PATCH 3/4] ocfs2: remove duplicate definition in xattr
  2008-10-23  8:34 ` [Ocfs2-devel] [PATCH 3/4] ocfs2: remove duplicate " Tiger Yang
@ 2008-10-23  9:25   ` Joel Becker
  0 siblings, 0 replies; 11+ messages in thread
From: Joel Becker @ 2008-10-23  9:25 UTC (permalink / raw)
  To: ocfs2-devel

On Thu, Oct 23, 2008 at 04:34:13PM +0800, Tiger Yang wrote:
> Include/linux/xattr.h already has the definition about xattr prefix,
> so remove the duplicate definitions in xattr.c.
> 
> Signed-off-by: Tiger Yang <tiger.yang@oracle.com>
Signed-off-by: Joel Becker <joel.becker@oracle.com>

> ---
>  fs/ocfs2/xattr.c |   11 ++---------
>  1 files changed, 2 insertions(+), 9 deletions(-)
> 
> diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
> index 667525b..754e5fa 100644
> --- a/fs/ocfs2/xattr.c
> +++ b/fs/ocfs2/xattr.c
> @@ -4830,14 +4830,11 @@ out:
>  /*
>   * 'trusted' attributes support
>   */
> -
> -#define XATTR_TRUSTED_PREFIX "trusted."
> -
>  static size_t ocfs2_xattr_trusted_list(struct inode *inode, char *list,
>  				       size_t list_size, const char *name,
>  				       size_t name_len)
>  {
> -	const size_t prefix_len = sizeof(XATTR_TRUSTED_PREFIX) - 1;
> +	const size_t prefix_len = XATTR_TRUSTED_PREFIX_LEN;
>  	const size_t total_len = prefix_len + name_len + 1;
>  
>  	if (list && total_len <= list_size) {
> @@ -4874,18 +4871,14 @@ struct xattr_handler ocfs2_xattr_trusted_handler = {
>  	.set	= ocfs2_xattr_trusted_set,
>  };
>  
> -
>  /*
>   * 'user' attributes support
>   */
> -
> -#define XATTR_USER_PREFIX "user."
> -
>  static size_t ocfs2_xattr_user_list(struct inode *inode, char *list,
>  				    size_t list_size, const char *name,
>  				    size_t name_len)
>  {
> -	const size_t prefix_len = sizeof(XATTR_USER_PREFIX) - 1;
> +	const size_t prefix_len = XATTR_USER_PREFIX_LEN;
>  	const size_t total_len = prefix_len + name_len + 1;
>  	struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
>  
> -- 
> 1.5.4.1
> 

-- 

"If at first you don't succeed, cover all traces that you tried."
                                                        -Unknown

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127

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

* [Ocfs2-devel] [PATCH 4/4] ocfs2: add array bounds checking
  2008-10-23  8:34 ` [Ocfs2-devel] [PATCH 4/4] ocfs2: add array bounds checking Tiger Yang
@ 2008-10-23  9:30   ` Joel Becker
  2008-10-23 10:06     ` Tiger Yang
  0 siblings, 1 reply; 11+ messages in thread
From: Joel Becker @ 2008-10-23  9:30 UTC (permalink / raw)
  To: ocfs2-devel

On Thu, Oct 23, 2008 at 04:34:44PM +0800, Tiger Yang wrote:
> This could avoid arry bounds exceeded issue.
> 
> Signed-off-by: Tiger Yang <tiger.yang@oracle.com>
> ---
>  fs/ocfs2/xattr.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
> index 754e5fa..888641d 100644
> --- a/fs/ocfs2/xattr.c
> +++ b/fs/ocfs2/xattr.c
> @@ -164,7 +164,7 @@ static inline const char *ocfs2_xattr_prefix(int name_index)
>  {
>  	struct xattr_handler *handler = NULL;
>  
> -	if (name_index > 0 && name_index < OCFS2_XATTR_MAX)
> +	if (name_index > 0 && name_index < ARRAY_SIZE(ocfs2_xattr_handler_map))
>  		handler = ocfs2_xattr_handler_map[name_index];

	Another option is to define the map as:

static struct xattr_handler *ocfs2_xattr_handler_map[OCFS2_ATTR_MAX] = {

This reuses our nice OCFS2_XATTR_MAX value.  But both methods work.

Joel

-- 

"You cannot bring about prosperity by discouraging thrift. You cannot
 strengthen the weak by weakening the strong. You cannot help the wage
 earner by pulling down the wage payer. You cannot further the
 brotherhood of man by encouraging class hatred. You cannot help the
 poor by destroying the rich. You cannot build character and courage by
 taking away a man's initiative and independence. You cannot help men
 permanently by doing for them what they could and should do for
 themselves."
	- Abraham Lincoln 

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127

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

* [Ocfs2-devel] [PATCH 4/4] ocfs2: add array bounds checking
  2008-10-23  9:30   ` Joel Becker
@ 2008-10-23 10:06     ` Tiger Yang
  2008-10-23 22:09       ` Joel Becker
  0 siblings, 1 reply; 11+ messages in thread
From: Tiger Yang @ 2008-10-23 10:06 UTC (permalink / raw)
  To: ocfs2-devel

Thanks for your quick review and suggestion.
I think your solutions is better than mine. It's more simple.

thanks,
tiger

Joel Becker wrote:
> On Thu, Oct 23, 2008 at 04:34:44PM +0800, Tiger Yang wrote:
>> This could avoid arry bounds exceeded issue.
>>
>> Signed-off-by: Tiger Yang <tiger.yang@oracle.com>
>> ---
>>  fs/ocfs2/xattr.c |    2 +-
>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
>> index 754e5fa..888641d 100644
>> --- a/fs/ocfs2/xattr.c
>> +++ b/fs/ocfs2/xattr.c
>> @@ -164,7 +164,7 @@ static inline const char *ocfs2_xattr_prefix(int name_index)
>>  {
>>  	struct xattr_handler *handler = NULL;
>>  
>> -	if (name_index > 0 && name_index < OCFS2_XATTR_MAX)
>> +	if (name_index > 0 && name_index < ARRAY_SIZE(ocfs2_xattr_handler_map))
>>  		handler = ocfs2_xattr_handler_map[name_index];
> 
> 	Another option is to define the map as:
> 
> static struct xattr_handler *ocfs2_xattr_handler_map[OCFS2_ATTR_MAX] = {
> 
> This reuses our nice OCFS2_XATTR_MAX value.  But both methods work.
> 
> Joel
> 

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

* [Ocfs2-devel] [PATCH 4/4] ocfs2: add array bounds checking
  2008-10-23 10:06     ` Tiger Yang
@ 2008-10-23 22:09       ` Joel Becker
  0 siblings, 0 replies; 11+ messages in thread
From: Joel Becker @ 2008-10-23 22:09 UTC (permalink / raw)
  To: ocfs2-devel

On Thu, Oct 23, 2008 at 06:06:37PM +0800, Tiger Yang wrote:
> Thanks for your quick review and suggestion.
> I think your solutions is better than mine. It's more simple.

	I pulled your change but fixed it up this way.

Joel
> 
> thanks,
> tiger
> 
> Joel Becker wrote:
> > On Thu, Oct 23, 2008 at 04:34:44PM +0800, Tiger Yang wrote:
> >> This could avoid arry bounds exceeded issue.
> >>
> >> Signed-off-by: Tiger Yang <tiger.yang@oracle.com>
> >> ---
> >>  fs/ocfs2/xattr.c |    2 +-
> >>  1 files changed, 1 insertions(+), 1 deletions(-)
> >>
> >> diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
> >> index 754e5fa..888641d 100644
> >> --- a/fs/ocfs2/xattr.c
> >> +++ b/fs/ocfs2/xattr.c
> >> @@ -164,7 +164,7 @@ static inline const char *ocfs2_xattr_prefix(int name_index)
> >>  {
> >>  	struct xattr_handler *handler = NULL;
> >>  
> >> -	if (name_index > 0 && name_index < OCFS2_XATTR_MAX)
> >> +	if (name_index > 0 && name_index < ARRAY_SIZE(ocfs2_xattr_handler_map))
> >>  		handler = ocfs2_xattr_handler_map[name_index];
> > 
> > 	Another option is to define the map as:
> > 
> > static struct xattr_handler *ocfs2_xattr_handler_map[OCFS2_ATTR_MAX] = {
> > 
> > This reuses our nice OCFS2_XATTR_MAX value.  But both methods work.
> > 
> > Joel
> > 
> 
> 
> _______________________________________________
> Ocfs2-devel mailing list
> Ocfs2-devel at oss.oracle.com
> http://oss.oracle.com/mailman/listinfo/ocfs2-devel

-- 

"What do you take me for, an idiot?"  
        - General Charles de Gaulle, when a journalist asked him
          if he was happy.

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127

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

end of thread, other threads:[~2008-10-23 22:09 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-23  8:26 [Ocfs2-devel] ocfs2: some xattr fixes Tiger Yang
2008-10-23  8:33 ` [Ocfs2-devel] [PATCH 1/4] ocfs2: fix license in xattr Tiger Yang
2008-10-23  9:22   ` Joel Becker
2008-10-23  8:33 ` [Ocfs2-devel] [PATCH 2/4] ocfs2: fix function declaration and definition " Tiger Yang
2008-10-23  9:23   ` Joel Becker
2008-10-23  8:34 ` [Ocfs2-devel] [PATCH 3/4] ocfs2: remove duplicate " Tiger Yang
2008-10-23  9:25   ` Joel Becker
2008-10-23  8:34 ` [Ocfs2-devel] [PATCH 4/4] ocfs2: add array bounds checking Tiger Yang
2008-10-23  9:30   ` Joel Becker
2008-10-23 10:06     ` Tiger Yang
2008-10-23 22:09       ` Joel Becker

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.