Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1467186 > unrolled thread
| Started by | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| First post | 2016-08-21 19:40 +0200 |
| Last post | 2016-08-21 22:00 +0200 |
| Articles | 10 — 4 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.
[PATCH 0/2] IB/core: Fine-tuning for ib_is_udata_cleared() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-21 19:40 +0200
[PATCH 2/2] IB/core: Delete an unnecessary initialisation in ib_is_udata_cleared() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-21 19:50 +0200
[PATCH 1/2] IB/core: Use memdup_user() rather than duplicating its implementation SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-21 19:50 +0200
Re: [PATCH 0/2] IB/core: Fine-tuning for ib_is_udata_cleared() Joe Perches <joe@perches.com> - 2016-08-21 20:10 +0200
Re: IB/core: Fine-tuning for ib_is_udata_cleared() Joe Perches <joe@perches.com> - 2016-08-21 22:00 +0200
Re: IB/core: Fine-tuning for ib_is_udata_cleared() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-21 22:20 +0200
Re: IB/core: Fine-tuning for ib_is_udata_cleared() Yann Droneaud <ydroneaud@opteya.com> - 2016-08-22 11:50 +0200
[PATCH v2] IB/core: Use memdup_user() rather than duplicating its implementation SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-22 18:40 +0200
Re: [PATCH v2] IB/core: Use memdup_user() rather than duplicating its implementation Doug Ledford <dledford@redhat.com> - 2016-08-23 18:50 +0200
Re: IB/core: Fine-tuning for ib_is_udata_cleared() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-21 22:00 +0200
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-08-21 19:40 +0200 |
| Subject | [PATCH 0/2] IB/core: Fine-tuning for ib_is_udata_cleared() |
| Message-ID | <s8ESZ-3jP-5@gated-at.bofh.it> |
From: Markus Elfring <elfring@users.sourceforge.net> Date: Sun, 21 Aug 2016 19:34:12 +0200 A few update suggestions were taken into account from static source code analysis. Markus Elfring (2): Use memdup_user() Delete an unnecessary initialisation include/rdma/ib_verbs.h | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) -- 2.9.3
[toc] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-08-21 19:50 +0200 |
| Subject | [PATCH 2/2] IB/core: Delete an unnecessary initialisation in ib_is_udata_cleared() |
| Message-ID | <s8F2F-3mZ-3@gated-at.bofh.it> |
| In reply to | #1467186 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Aug 2016 19:23:12 +0200
The local variable "ret" will be set to an appropriate value a bit later.
Thus omit the explicit initialisation at the beginning.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
include/rdma/ib_verbs.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 033610b..0d8100f 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -2199,7 +2199,7 @@ static inline bool ib_is_udata_cleared(struct ib_udata *udata,
size_t len)
{
const void __user *p = udata->inbuf + offset;
- bool ret = false;
+ bool ret;
u8 *buf;
if (len > USHRT_MAX)
--
2.9.3
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-08-21 19:50 +0200 |
| Subject | [PATCH 1/2] IB/core: Use memdup_user() rather than duplicating its implementation |
| Message-ID | <s8F2F-3mZ-7@gated-at.bofh.it> |
| In reply to | #1467186 |
From: Markus Elfring <elfring@users.sourceforge.net> Date: Sun, 21 Aug 2016 18:45:22 +0200 Reuse existing functionality from memdup_user() instead of keeping duplicate source code. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> --- include/rdma/ib_verbs.h | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 6f667dd..033610b 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -2205,16 +2205,11 @@ static inline bool ib_is_udata_cleared(struct ib_udata *udata, if (len > USHRT_MAX) return false; - buf = kmalloc(len, GFP_KERNEL); - if (!buf) + buf = memdup_user(p, len); + if (IS_ERR(buf)) return false; - if (copy_from_user(buf, p, len)) - goto free; - ret = !memchr_inv(buf, 0, len); - -free: kfree(buf); return ret; } -- 2.9.3
[toc] | [prev] | [next] | [standalone]
| From | Joe Perches <joe@perches.com> |
|---|---|
| Date | 2016-08-21 20:10 +0200 |
| Message-ID | <s8Fm1-3If-1@gated-at.bofh.it> |
| In reply to | #1467186 |
On Sun, 2016-08-21 at 19:39 +0200, SF Markus Elfring wrote: > From: Markus Elfring <elfring@users.sourceforge.net> > Date: Sun, 21 Aug 2016 19:34:12 +0200 > > A few update suggestions were taken into account > from static source code analysis. Don't introduce a defect in patch 1 and correct that introduced defect in patch 2. This should be a single patch.
[toc] | [prev] | [next] | [standalone]
| From | Joe Perches <joe@perches.com> |
|---|---|
| Date | 2016-08-21 22:00 +0200 |
| Subject | Re: IB/core: Fine-tuning for ib_is_udata_cleared() |
| Message-ID | <s8H4u-4F3-7@gated-at.bofh.it> |
| In reply to | #1467192 |
On Sun, 2016-08-21 at 21:51 +0200, SF Markus Elfring wrote: > > Don't introduce a defect in patch 1 and correct > > that introduced defect in patch 2. > Which detail do you not like here? See above.
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-08-21 22:20 +0200 |
| Subject | Re: IB/core: Fine-tuning for ib_is_udata_cleared() |
| Message-ID | <s8HnQ-510-3@gated-at.bofh.it> |
| In reply to | #1467228 |
>>> Don't introduce a defect in patch 1 and correct >>> that introduced defect in patch 2. >> Which detail do you not like here? > > See above. This feedback is not clearer. I find that the two update steps should work in principle, shouldn't they? I guess that we have got different preferences for the shown patch granularity. Another update variant can follow a bit later with the changes squashed together. Regards, Markus
[toc] | [prev] | [next] | [standalone]
| From | Yann Droneaud <ydroneaud@opteya.com> |
|---|---|
| Date | 2016-08-22 11:50 +0200 |
| Subject | Re: IB/core: Fine-tuning for ib_is_udata_cleared() |
| Message-ID | <s8U1I-4zE-19@gated-at.bofh.it> |
| In reply to | #1467238 |
Hi, Le dimanche 21 août 2016 à 22:15 +0200, SF Markus Elfring a écrit : > > > > > > > > > > > > > Don't introduce a defect in patch 1 and correct > > > > that introduced defect in patch 2. > > > Which detail do you not like here? > > > > See above. > > This feedback is not clearer. > It's clear enough: your second patch fixes an issue you introduced in your first patch by removing the code which made use of the ret initialization value: - if (copy_from_user(buf, p, len)) - goto free; > I find that the two update steps should work in principle, > shouldn't they? > It would be better to squash them here. Regards. -- Yann Droneaud OPTEYA
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-08-22 18:40 +0200 |
| Subject | [PATCH v2] IB/core: Use memdup_user() rather than duplicating its implementation |
| Message-ID | <s90qt-ft-7@gated-at.bofh.it> |
| In reply to | #1467513 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 22 Aug 2016 18:23:24 +0200
* Reuse existing functionality from memdup_user() instead of keeping
duplicate source code.
This issue was detected by using the Coccinelle software.
* The local variable "ret" will be set to an appropriate value a bit later.
Thus omit the explicit initialisation at the beginning.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
v2: The desired changes were put into a single patch instead of
distributing them over two update steps.
include/rdma/ib_verbs.h | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 6f667dd..0d8100f 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -2199,22 +2199,17 @@ static inline bool ib_is_udata_cleared(struct ib_udata *udata,
size_t len)
{
const void __user *p = udata->inbuf + offset;
- bool ret = false;
+ bool ret;
u8 *buf;
if (len > USHRT_MAX)
return false;
- buf = kmalloc(len, GFP_KERNEL);
- if (!buf)
+ buf = memdup_user(p, len);
+ if (IS_ERR(buf))
return false;
- if (copy_from_user(buf, p, len))
- goto free;
-
ret = !memchr_inv(buf, 0, len);
-
-free:
kfree(buf);
return ret;
}
--
2.9.3
[toc] | [prev] | [next] | [standalone]
| From | Doug Ledford <dledford@redhat.com> |
|---|---|
| Date | 2016-08-23 18:50 +0200 |
| Subject | Re: [PATCH v2] IB/core: Use memdup_user() rather than duplicating its implementation |
| Message-ID | <s9n3I-6xg-27@gated-at.bofh.it> |
| In reply to | #1467778 |
[Multipart message — attachments visible in raw view] — view raw
On 8/22/2016 12:30 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 22 Aug 2016 18:23:24 +0200
>
> * Reuse existing functionality from memdup_user() instead of keeping
> duplicate source code.
>
> This issue was detected by using the Coccinelle software.
>
> * The local variable "ret" will be set to an appropriate value a bit later.
> Thus omit the explicit initialisation at the beginning.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Applied, thanks.
--
Doug Ledford <dledford@redhat.com>
GPG Key ID: 0E572FDD
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-08-21 22:00 +0200 |
| Subject | Re: IB/core: Fine-tuning for ib_is_udata_cleared() |
| Message-ID | <s8H4u-4F3-9@gated-at.bofh.it> |
| In reply to | #1467192 |
>> A few update suggestions were taken into account >> from static source code analysis. > > Don't introduce a defect in patch 1 and correct > that introduced defect in patch 2. Which detail do you not like here? > This should be a single patch. Do any more software software developers would like to get the proposed changes in a single update step? Regards, Markus
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web