From: walter harms <wharms@bfs.de>
To: Julia Lawall <julia-dAYI7NvHqcQ@public.gmane.org>
Cc: Roland Dreier <rolandd-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org>,
Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
Hal Rosenstock
<hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 10/27] drivers/infiniband/core: Use memdup_user
Date: Sat, 22 May 2010 09:39:41 +0000 [thread overview]
Message-ID: <4BF7A65D.1070501@bfs.de> (raw)
In-Reply-To: <Pine.LNX.4.64.1005221021030.13021-QfmoRoYWmW9knbxzx/v8hQ@public.gmane.org>
Julia Lawall schrieb:
> From: Julia Lawall <julia@diku.dk>
>
> Use memdup_user when user data is immediately copied into the
> allocated region.
>
> The semantic patch that makes this change is as follows:
> (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @@
> expression from,to,size,flag;
> position p;
> identifier l1,l2;
> @@
>
> - to = \(kmalloc@p\|kzalloc@p\)(size,flag);
> + to = memdup_user(from,size);
> if (
> - to=NULL
> + IS_ERR(to)
> || ...) {
> <+... when != goto l1;
> - -ENOMEM
> + PTR_ERR(to)
> ...+>
> }
> - if (copy_from_user(to, from, size) != 0) {
> - <+... when != goto l2;
> - -EFAULT
> - ...+>
> - }
> // </smpl>
>
> Signed-off-by: Julia Lawall <julia@diku.dk>
>
> ---
> drivers/infiniband/core/ucm.c | 11 +++--------
> 1 file changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c
> index 4647484..08f948d 100644
> --- a/drivers/infiniband/core/ucm.c
> +++ b/drivers/infiniband/core/ucm.c
> @@ -706,14 +706,9 @@ static int ib_ucm_alloc_data(const void **dest, u64 src, u32 len)
> if (!len)
> return 0;
>
> - data = kmalloc(len, GFP_KERNEL);
> - if (!data)
> - return -ENOMEM;
> -
> - if (copy_from_user(data, (void __user *)(unsigned long)src, len)) {
> - kfree(data);
> - return -EFAULT;
> - }
> + data = memdup_user((void __user *)(unsigned long)src, len);
> + if (IS_ERR(data))
> + return PTR_ERR(data);
>
> *dest = data;
> return 0;
> --
This cast look strange, can it happen that (unsigned long)<(u64) ?
(is there a 32bit infiniband) ?
just my 2 cents,
wh
WARNING: multiple messages have this Message-ID (diff)
From: walter harms <wharms-fPG8STNUNVg@public.gmane.org>
To: Julia Lawall <julia-dAYI7NvHqcQ@public.gmane.org>
Cc: Roland Dreier <rolandd-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org>,
Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
Hal Rosenstock
<hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 10/27] drivers/infiniband/core: Use memdup_user
Date: Sat, 22 May 2010 11:39:41 +0200 [thread overview]
Message-ID: <4BF7A65D.1070501@bfs.de> (raw)
In-Reply-To: <Pine.LNX.4.64.1005221021030.13021-QfmoRoYWmW9knbxzx/v8hQ@public.gmane.org>
Julia Lawall schrieb:
> From: Julia Lawall <julia-dAYI7NvHqcQ@public.gmane.org>
>
> Use memdup_user when user data is immediately copied into the
> allocated region.
>
> The semantic patch that makes this change is as follows:
> (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @@
> expression from,to,size,flag;
> position p;
> identifier l1,l2;
> @@
>
> - to = \(kmalloc@p\|kzalloc@p\)(size,flag);
> + to = memdup_user(from,size);
> if (
> - to==NULL
> + IS_ERR(to)
> || ...) {
> <+... when != goto l1;
> - -ENOMEM
> + PTR_ERR(to)
> ...+>
> }
> - if (copy_from_user(to, from, size) != 0) {
> - <+... when != goto l2;
> - -EFAULT
> - ...+>
> - }
> // </smpl>
>
> Signed-off-by: Julia Lawall <julia-dAYI7NvHqcQ@public.gmane.org>
>
> ---
> drivers/infiniband/core/ucm.c | 11 +++--------
> 1 file changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c
> index 4647484..08f948d 100644
> --- a/drivers/infiniband/core/ucm.c
> +++ b/drivers/infiniband/core/ucm.c
> @@ -706,14 +706,9 @@ static int ib_ucm_alloc_data(const void **dest, u64 src, u32 len)
> if (!len)
> return 0;
>
> - data = kmalloc(len, GFP_KERNEL);
> - if (!data)
> - return -ENOMEM;
> -
> - if (copy_from_user(data, (void __user *)(unsigned long)src, len)) {
> - kfree(data);
> - return -EFAULT;
> - }
> + data = memdup_user((void __user *)(unsigned long)src, len);
> + if (IS_ERR(data))
> + return PTR_ERR(data);
>
> *dest = data;
> return 0;
> --
This cast look strange, can it happen that (unsigned long)<(u64) ?
(is there a 32bit infiniband) ?
just my 2 cents,
wh
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
WARNING: multiple messages have this Message-ID (diff)
From: walter harms <wharms@bfs.de>
To: Julia Lawall <julia@diku.dk>
Cc: Roland Dreier <rolandd@cisco.com>,
Sean Hefty <sean.hefty@intel.com>,
Hal Rosenstock <hal.rosenstock@gmail.com>,
linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 10/27] drivers/infiniband/core: Use memdup_user
Date: Sat, 22 May 2010 11:39:41 +0200 [thread overview]
Message-ID: <4BF7A65D.1070501@bfs.de> (raw)
In-Reply-To: <Pine.LNX.4.64.1005221021030.13021@ask.diku.dk>
Julia Lawall schrieb:
> From: Julia Lawall <julia@diku.dk>
>
> Use memdup_user when user data is immediately copied into the
> allocated region.
>
> The semantic patch that makes this change is as follows:
> (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @@
> expression from,to,size,flag;
> position p;
> identifier l1,l2;
> @@
>
> - to = \(kmalloc@p\|kzalloc@p\)(size,flag);
> + to = memdup_user(from,size);
> if (
> - to==NULL
> + IS_ERR(to)
> || ...) {
> <+... when != goto l1;
> - -ENOMEM
> + PTR_ERR(to)
> ...+>
> }
> - if (copy_from_user(to, from, size) != 0) {
> - <+... when != goto l2;
> - -EFAULT
> - ...+>
> - }
> // </smpl>
>
> Signed-off-by: Julia Lawall <julia@diku.dk>
>
> ---
> drivers/infiniband/core/ucm.c | 11 +++--------
> 1 file changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c
> index 4647484..08f948d 100644
> --- a/drivers/infiniband/core/ucm.c
> +++ b/drivers/infiniband/core/ucm.c
> @@ -706,14 +706,9 @@ static int ib_ucm_alloc_data(const void **dest, u64 src, u32 len)
> if (!len)
> return 0;
>
> - data = kmalloc(len, GFP_KERNEL);
> - if (!data)
> - return -ENOMEM;
> -
> - if (copy_from_user(data, (void __user *)(unsigned long)src, len)) {
> - kfree(data);
> - return -EFAULT;
> - }
> + data = memdup_user((void __user *)(unsigned long)src, len);
> + if (IS_ERR(data))
> + return PTR_ERR(data);
>
> *dest = data;
> return 0;
> --
This cast look strange, can it happen that (unsigned long)<(u64) ?
(is there a 32bit infiniband) ?
just my 2 cents,
wh
next prev parent reply other threads:[~2010-05-22 9:39 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-22 8:21 [PATCH 10/27] drivers/infiniband/core: Use memdup_user Julia Lawall
2010-05-22 8:21 ` Julia Lawall
2010-05-22 8:21 ` Julia Lawall
[not found] ` <Pine.LNX.4.64.1005221021030.13021-QfmoRoYWmW9knbxzx/v8hQ@public.gmane.org>
2010-05-22 9:39 ` walter harms [this message]
2010-05-22 9:39 ` walter harms
2010-05-22 9:39 ` walter harms
[not found] ` <4BF7A65D.1070501-fPG8STNUNVg@public.gmane.org>
2010-05-22 15:15 ` Roland Dreier
2010-05-22 15:15 ` Roland Dreier
2010-05-22 15:15 ` Roland Dreier
2010-05-26 4:11 ` Roland Dreier
2010-05-26 4:11 ` Roland Dreier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4BF7A65D.1070501@bfs.de \
--to=wharms@bfs.de \
--cc=hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=julia-dAYI7NvHqcQ@public.gmane.org \
--cc=kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=rolandd-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org \
--cc=sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.