On Sat, 11 May 2013 13:29:23 +0200
richard -rw- weinberger <richard.weinber...@gmail.com> wrote:

> On Sat, May 11, 2013 at 1:01 PM, Sergei Trofimovich <sly...@gmail.com> wrote:
> >> With this change:
> >>
> >> diff --git a/fs/namespace.c b/fs/namespace.c
> >> index 7b1ca9b..289211d 100644
> >> --- a/fs/namespace.c
> >> +++ b/fs/namespace.c
> >> @@ -2236,6 +2236,8 @@ int copy_mount_string(const void __user *data, char 
> >> **where)
> >>                 return 0;
> >>         }
> >>
> >> +       printk(" here: size is %ul\n", (unsigned long)data);
> >
> > Be careful, it's long->int truncation. I guess you want '%lu' instead of 
> > '%ul'.
> 
> Erm, data is a character array...

Gah, sorry!

Toralf, it's better to use strnlen_user for it:

--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -2230,12 +2230,16 @@ int copy_mount_options(const void __user * data, 
unsigned long *where)
 int copy_mount_string(const void __user *data, char **where)
 {
        char *tmp;
+       long data_len;

        if (!data) {
                *where = NULL;
                return 0;
        }

+       data_len = strnlen_user (data, (long)(~0ul >> 1) /* LONG_MAX */);
+       printk("%s: __user * data size is %lu\n", __func__, data_len);
+
        tmp = strndup_user(data, PAGE_SIZE);
        if (IS_ERR(tmp))
                return PTR_ERR(tmp);

-- 

  Sergei

Attachment: signature.asc
Description: PGP signature

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and 
their applications. This 200-page book is written by three acclaimed 
leaders in the field. The early access version is available now. 
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

Reply via email to