diff mbox

hfsplus: add missing osx prefix to FinderInfo attribute check

Message ID CABikg9z4F6R1Sse4+Qc3_4Vpj2ghr52A7mXtJrKxcbxiOcYg3A@mail.gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Sergei Antonov April 2, 2015, 11:41 p.m. UTC
On 1 April 2015 at 05:41, Thomas Hebb <tommyhebb@gmail.com> wrote:
> By the time we reach strcmp_xattr_finder_info(), hfsplus_osx_getxattr()
> has already prefixed the user-provided xattr name with "osx.", so the
> existing check for the special FinderInfo attribute will always fail,
> and ENODATA will be returned to userspace.
>
> Since hfsplus_listxattr() reports the FinderInfo attribute, this
> behavior causes certain userspace utilities (e.g. patch) to fail, since
> the kernel lists an attribute that doesn't exist.
>
> Cc: stable@vger.kernel.org
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Hin-Tak Leung <htl10@users.sourceforge.net>
> Cc: Sergei Antonov <saproj@gmail.com>
> Cc: Anton Altaparmakov <anton@tuxera.com>
> Cc: Fabian Frederick <fabf@skynet.be>
> Cc: Christian Kujau <lists@nerdbynature.de>
> Signed-off-by: Thomas Hebb <tommyhebb@gmail.com>
> ---
>  fs/hfsplus/xattr.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/fs/hfsplus/xattr.c b/fs/hfsplus/xattr.c
> index d98094a..da0664e 100644
> --- a/fs/hfsplus/xattr.c
> +++ b/fs/hfsplus/xattr.c
> @@ -28,8 +28,16 @@ const struct xattr_handler *hfsplus_xattr_handlers[] = {
>   static int strcmp_xattr_finder_info(const char *name)
>  {
> +       int err = 0;
> +
>         if (name) {
> -               return strncmp(name, HFSPLUS_XATTR_FINDER_INFO_NAME,
> +               err = strncmp(name, XATTR_MAC_OSX_PREFIX,
> +                               XATTR_MAC_OSX_PREFIX_LEN);
> +               if (err)
> +                       return err;
> +
> +               return strncmp(name + XATTR_MAC_OSX_PREFIX_LEN,
> +                               HFSPLUS_XATTR_FINDER_INFO_NAME,
>                                 sizeof(HFSPLUS_XATTR_FINDER_INFO_NAME));
>         }
>         return -1;
> --
> 2.3.4
>

Your patch does fix a bug (reproduced through
listxattr/getxattr/setxattr apis). But I'd recommend a more elegant
code:



If you resubmit it, make it Reviewed-by: Sergei Antonov <saproj@gmail.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Viacheslav Dubeyko April 3, 2015, 1:33 a.m. UTC | #1
On Fri, 2015-04-03 at 01:41 +0200, Sergei Antonov wrote:

> Your patch does fix a bug (reproduced through
> listxattr/getxattr/setxattr apis). But I'd recommend a more elegant
> code:
> 
> --- a/fs/hfsplus/xattr.c
> +++ b/fs/hfsplus/xattr.c
> @@ -29,7 +29,9 @@ const struct xattr_handler *hfsplus_xattr_handlers[] = {
>  static int strcmp_xattr_finder_info(const char *name)
>  {
>      if (name) {
> -        return strncmp(name, HFSPLUS_XATTR_FINDER_INFO_NAME,
> +        return strncmp(name, XATTR_MAC_OSX_PREFIX
> +                HFSPLUS_XATTR_FINDER_INFO_NAME,
> +                XATTR_MAC_OSX_PREFIX_LEN +
>                  sizeof(HFSPLUS_XATTR_FINDER_INFO_NAME));
>      }
>      return -1;
> 
> 
> If you resubmit it, make it Reviewed-by: Sergei Antonov <saproj@gmail.com>

The issue is located in hfsplus_osx_getxattr() method:

{
        char *xattr_name;
        int res;

        if (!strcmp(name, ""))
                return -EINVAL;

        /*
         * Don't allow retrieving properly prefixed attributes
         * by prepending them with "osx."
         */
        if (is_known_namespace(name))
                return -EOPNOTSUPP;
        xattr_name = kmalloc(NLS_MAX_CHARSET_SIZE *
HFSPLUS_ATTR_MAX_STRLEN
                + XATTR_MAC_OSX_PREFIX_LEN + 1, GFP_KERNEL);
        if (!xattr_name)
                return -ENOMEM;

************************************************************
        strcpy(xattr_name, XATTR_MAC_OSX_PREFIX);
        strcpy(xattr_name + XATTR_MAC_OSX_PREFIX_LEN, name);
*************************************************************

This part adds "osx." prefix second time. So, it needs to fix the issue
here.

Thanks,
Vyacheslav Dubeyko.


--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

--- a/fs/hfsplus/xattr.c
+++ b/fs/hfsplus/xattr.c
@@ -29,7 +29,9 @@  const struct xattr_handler *hfsplus_xattr_handlers[] = {
 static int strcmp_xattr_finder_info(const char *name)
 {
     if (name) {
-        return strncmp(name, HFSPLUS_XATTR_FINDER_INFO_NAME,
+        return strncmp(name, XATTR_MAC_OSX_PREFIX
+                HFSPLUS_XATTR_FINDER_INFO_NAME,
+                XATTR_MAC_OSX_PREFIX_LEN +
                 sizeof(HFSPLUS_XATTR_FINDER_INFO_NAME));
     }
     return -1;