From: frank.blaschka@de.ibm.com
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, linux-s390@vger.kernel.org,
Julia Lawall <julia@diku.dk>,
Andrew Morton <akpm@linux-foundation.org>
Subject: [patch 7/8] [PATCH] qeth: Use memdup_user when user data is immediately copied into the allocated region.
Date: Fri, 23 Jul 2010 11:15:09 +0200 [thread overview]
Message-ID: <20100723091550.566471000@de.ibm.com> (raw)
In-Reply-To: 20100723091502.678949000@de.ibm.com
[-- Attachment #1: 618-qeth-memdup-user.diff --]
[-- Type: text/plain, Size: 1781 bytes --]
From: Julia Lawall <julia@diku.dk>
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>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Frank Blaschka <frank.blaschka@de.ibm.com>
---
drivers/s390/net/qeth_core_main.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff -urpN linux-2.6/drivers/s390/net/qeth_core_main.c linux-2.6-patched/drivers/s390/net/qeth_core_main.c
--- linux-2.6/drivers/s390/net/qeth_core_main.c 2010-07-22 10:22:37.000000000 +0200
+++ linux-2.6-patched/drivers/s390/net/qeth_core_main.c 2010-07-22 10:22:37.000000000 +0200
@@ -3748,15 +3748,10 @@ int qeth_snmp_command(struct qeth_card *
/* skip 4 bytes (data_len struct member) to get req_len */
if (copy_from_user(&req_len, udata + sizeof(int), sizeof(int)))
return -EFAULT;
- ureq = kmalloc(req_len+sizeof(struct qeth_snmp_ureq_hdr), GFP_KERNEL);
- if (!ureq) {
+ ureq = memdup_user(udata, req_len + sizeof(struct qeth_snmp_ureq_hdr));
+ if (IS_ERR(ureq)) {
QETH_CARD_TEXT(card, 2, "snmpnome");
- return -ENOMEM;
- }
- if (copy_from_user(ureq, udata,
- req_len + sizeof(struct qeth_snmp_ureq_hdr))) {
- kfree(ureq);
- return -EFAULT;
+ return PTR_ERR(ureq);
}
qinfo.udata_len = ureq->hdr.data_len;
qinfo.udata = kzalloc(qinfo.udata_len, GFP_KERNEL);
next prev parent reply other threads:[~2010-07-23 9:15 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-23 9:15 [patch 0/8] s390: qeth some more patches for 2.6.36 frank.blaschka
2010-07-23 9:15 ` [patch 1/8] [PATCH] qeth: IP address takeover flag setting frank.blaschka
2010-07-23 9:15 ` [patch 2/8] qeth: Clear mac_bits field when switching between Layer 2 and Layer 3 frank.blaschka
2010-07-23 9:15 ` [patch 3/8] [PATCH] qeth: serialize sysfs-triggered device configurations frank.blaschka
2010-07-23 9:15 ` [patch 4/8] [PATCH] qeth: avoid loop if ipa command response is missing frank.blaschka
2010-07-23 9:15 ` [patch 5/8] [PATCH] claw: A claw device is a group of just 2 ccw devices frank.blaschka
2010-07-23 9:15 ` [patch 6/8] [PATCH] qeth: return zero from reply callback functions frank.blaschka
2010-07-23 9:15 ` frank.blaschka [this message]
2010-07-23 9:15 ` [patch 8/8] [PATCH] qeth: avoid useless removal of multicast addresses frank.blaschka
2010-07-23 19:36 ` [patch 0/8] s390: qeth some more patches for 2.6.36 David Miller
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=20100723091550.566471000@de.ibm.com \
--to=frank.blaschka@de.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=davem@davemloft.net \
--cc=julia@diku.dk \
--cc=linux-s390@vger.kernel.org \
--cc=netdev@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).