Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1230116 > unrolled thread

[PATCH v2 6/7] squashfs: xattr simplifications

Started byAndreas Gruenbacher <agruenba@redhat.com>
First post2015-09-22 14:30 +0200
Last post2015-10-04 15:20 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v2 6/7] squashfs: xattr simplifications Andreas Gruenbacher <agruenba@redhat.com> - 2015-09-22 14:30 +0200
    Re: [PATCH v2 6/7] squashfs: xattr simplifications Christoph Hellwig <hch@infradead.org> - 2015-10-04 08:30 +0200
      Re: [PATCH v2 6/7] squashfs: xattr simplifications Andreas Grünbacher <andreas.gruenbacher@gmail.com> - 2015-10-04 15:20 +0200

#1230116 — [PATCH v2 6/7] squashfs: xattr simplifications

FromAndreas Gruenbacher <agruenba@redhat.com>
Date2015-09-22 14:30 +0200
Subject[PATCH v2 6/7] squashfs: xattr simplifications
Message-ID<qbuRQ-5fA-17@gated-at.bofh.it>
Now that the xattr handler is passed to the xattr handler operations, we
have access to the attribute name prefix, so simplify the squashfs xattr
handlers a bit.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
---
 fs/squashfs/xattr.c | 90 ++++++++++++++++++-----------------------------------
 1 file changed, 31 insertions(+), 59 deletions(-)

diff --git a/fs/squashfs/xattr.c b/fs/squashfs/xattr.c
index 4ae1e4f..6a4cc34 100644
--- a/fs/squashfs/xattr.c
+++ b/fs/squashfs/xattr.c
@@ -212,96 +212,68 @@ failed:
 }
 
 
-/*
- * User namespace support
- */
-static size_t squashfs_user_list(const struct xattr_handler *handler,
-				 struct dentry *d, char *list, size_t list_size,
-				 const char *name, size_t name_len)
+static size_t squashfs_xattr_handler_list(const struct xattr_handler *handler,
+					  struct dentry *d, char *list,
+					  size_t list_size, const char *name,
+					  size_t name_len)
 {
-	if (list && XATTR_USER_PREFIX_LEN <= list_size)
-		memcpy(list, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN);
-	return XATTR_USER_PREFIX_LEN;
+	int len = strlen(handler->prefix);
+
+	if (list && len <= list_size)
+		memcpy(list, handler->prefix, len);
+	return len;
 }
 
-static int squashfs_user_get(const struct xattr_handler *handler,
-			     struct dentry *d, const char *name, void *buffer,
-			     size_t size)
+static int squashfs_xattr_handler_get(const struct xattr_handler *handler,
+				      struct dentry *d, const char *name,
+				      void *buffer, size_t size)
 {
 	if (name[0] == '\0')
 		return  -EINVAL;
 
-	return squashfs_xattr_get(d_inode(d), SQUASHFS_XATTR_USER, name,
+	return squashfs_xattr_get(d_inode(d), handler->flags, name,
 		buffer, size);
 }
 
+/*
+ * User namespace support
+ */
 static const struct xattr_handler squashfs_xattr_user_handler = {
 	.prefix	= XATTR_USER_PREFIX,
-	.list	= squashfs_user_list,
-	.get	= squashfs_user_get
+	.flags	= SQUASHFS_XATTR_USER,
+	.list	= squashfs_xattr_handler_list,
+	.get	= squashfs_xattr_handler_get
 };
 
 /*
  * Trusted namespace support
  */
-static size_t squashfs_trusted_list(const struct xattr_handler *handler,
-				    struct dentry *d, char *list,
-				    size_t list_size, const char *name,
-				    size_t name_len)
+static size_t squashfs_trusted_xattr_handler_list(const struct xattr_handler *handler,
+						  struct dentry *d, char *list,
+						  size_t list_size, const char *name,
+						  size_t name_len)
 {
 	if (!capable(CAP_SYS_ADMIN))
 		return 0;
-
-	if (list && XATTR_TRUSTED_PREFIX_LEN <= list_size)
-		memcpy(list, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN);
-	return XATTR_TRUSTED_PREFIX_LEN;
-}
-
-static int squashfs_trusted_get(const struct xattr_handler *handler,
-				struct dentry *d, const char *name,
-				void *buffer, size_t size)
-{
-	if (name[0] == '\0')
-		return  -EINVAL;
-
-	return squashfs_xattr_get(d_inode(d), SQUASHFS_XATTR_TRUSTED, name,
-		buffer, size);
+	return squashfs_xattr_handler_list(handler, d, list, list_size, name,
+					   name_len);
 }
 
 static const struct xattr_handler squashfs_xattr_trusted_handler = {
 	.prefix	= XATTR_TRUSTED_PREFIX,
-	.list	= squashfs_trusted_list,
-	.get	= squashfs_trusted_get
+	.flags	= SQUASHFS_XATTR_TRUSTED,
+	.list	= squashfs_trusted_xattr_handler_list,
+	.get	= squashfs_xattr_handler_get
 };
 
 /*
  * Security namespace support
  */
-static size_t squashfs_security_list(const struct xattr_handler *handler,
-				     struct dentry *d, char *list,
-				     size_t list_size, const char *name,
-				     size_t name_len)
-{
-	if (list && XATTR_SECURITY_PREFIX_LEN <= list_size)
-		memcpy(list, XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN);
-	return XATTR_SECURITY_PREFIX_LEN;
-}
-
-static int squashfs_security_get(const struct xattr_handler *handler,
-				 struct dentry *d, const char *name,
-				 void *buffer, size_t size)
-{
-	if (name[0] == '\0')
-		return  -EINVAL;
-
-	return squashfs_xattr_get(d_inode(d), SQUASHFS_XATTR_SECURITY, name,
-		buffer, size);
-}
-
 static const struct xattr_handler squashfs_xattr_security_handler = {
 	.prefix	= XATTR_SECURITY_PREFIX,
-	.list	= squashfs_security_list,
-	.get	= squashfs_security_get
+	.flags	= SQUASHFS_XATTR_SECURITY,
+	.list	= squashfs_xattr_handler_list,
+	.get	= squashfs_xattr_handler_get
 };
 
 static const struct xattr_handler *squashfs_xattr_handler(int type)
-- 
2.4.3

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

[toc] | [next] | [standalone]


#1239045

FromChristoph Hellwig <hch@infradead.org>
Date2015-10-04 08:30 +0200
Message-ID<qfKY1-FS-9@gated-at.bofh.it>
In reply to#1230116
On Tue, Sep 22, 2015 at 02:26:51PM +0200, Andreas Gruenbacher wrote:
> Now that the xattr handler is passed to the xattr handler operations, we
> have access to the attribute name prefix, so simplify the squashfs xattr
> handlers a bit.
> 
> Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
> ---
>  fs/squashfs/xattr.c | 90 ++++++++++++++++++-----------------------------------
>  1 file changed, 31 insertions(+), 59 deletions(-)
> 
> diff --git a/fs/squashfs/xattr.c b/fs/squashfs/xattr.c
> index 4ae1e4f..6a4cc34 100644
> --- a/fs/squashfs/xattr.c
> +++ b/fs/squashfs/xattr.c
> @@ -212,96 +212,68 @@ failed:
>  }
>  
>  
> -/*
> - * User namespace support
> - */
> -static size_t squashfs_user_list(const struct xattr_handler *handler,
> -				 struct dentry *d, char *list, size_t list_size,
> -				 const char *name, size_t name_len)
> +static size_t squashfs_xattr_handler_list(const struct xattr_handler *handler,
> +					  struct dentry *d, char *list,
> +					  size_t list_size, const char *name,
> +					  size_t name_len)
>  {
> -	if (list && XATTR_USER_PREFIX_LEN <= list_size)
> -		memcpy(list, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN);
> -	return XATTR_USER_PREFIX_LEN;
> +	int len = strlen(handler->prefix);
> +
> +	if (list && len <= list_size)
> +		memcpy(list, handler->prefix, len);
> +	return len;

IS it just me or is this handler broke before and after this patch? It
only copies out the prefix, but not the actual xattr name.

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

[toc] | [prev] | [next] | [standalone]


#1239115

FromAndreas Grünbacher <andreas.gruenbacher@gmail.com>
Date2015-10-04 15:20 +0200
Message-ID<qfRmO-1oB-11@gated-at.bofh.it>
In reply to#1239045
2015-10-04 8:29 GMT+02:00 Christoph Hellwig <hch@infradead.org>:
> IS it just me or is this handler broke before and after this patch? It
> only copies out the prefix, but not the actual xattr name.

Well, squashfs appends the rest of the name in squashfs_listxattr, so
it's not broken, just different. I have tried cleaning that up by
converting the list operation into something like this instead:

  bool (*may_list)(struct dentry *dentry);

The xattr name would always be copied into the buffer in
iop->listxattr. But security_inode_listsecurity which is called from
vfs_getxattr as well as nfs4_xattr_list_nfs4_label was getting in the
way, and it's unclear to me how to best clean that up first.

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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web