From: Kulikov Vasiliy <segooon@gmail.com>
To: kernel-janitors@vger.kernel.org
Cc: "Michael H. Warfield" <mhw@wittsend.com>,
Greg Kroah-Hartman <gregkh@suse.de>,
Rakib Mullick <rakib.mullick@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
Ben Hutchings <ben@decadent.org.uk>,
linux-kernel@vger.kernel.org
Subject: [PATCH] char: ip2: check put_user() result
Date: Thu, 29 Jul 2010 15:55:38 +0000 [thread overview]
Message-ID: <1280418938-5833-1-git-send-email-segooon@gmail.com> (raw)
put_user()/copy_to_user() may fail, if so return -EFAULT.
Signed-off-by: Kulikov Vasiliy <segooon@gmail.com>
---
drivers/char/ip2/ip2main.c | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/char/ip2/ip2main.c b/drivers/char/ip2/ip2main.c
index 07f3ea3..3f70a05 100644
--- a/drivers/char/ip2/ip2main.c
+++ b/drivers/char/ip2/ip2main.c
@@ -2813,9 +2813,9 @@ DumpTraceBuffer ( char __user *pData, int count )
return -EIO;
}
rc = put_user(tracewrap, pIndex );
- rc = put_user(TRACEMAX, ++pIndex );
- rc = put_user(tracestrip, ++pIndex );
- rc = put_user(tracestuff, ++pIndex );
+ rc |= put_user(TRACEMAX, ++pIndex);
+ rc |= put_user(tracestrip, ++pIndex);
+ rc |= put_user(tracestuff, ++pIndex);
pData += sizeof(int) * 6;
count -= sizeof(int) * 6;
@@ -2828,7 +2828,7 @@ DumpTraceBuffer ( char __user *pData, int count )
}
chunk = TRACEMAX - tracestrip;
if ( dumpcount > chunk ) {
- rc = copy_to_user(pData, &tracebuf[tracestrip],
+ rc |= copy_to_user(pData, &tracebuf[tracestrip],
chunk * sizeof(tracebuf[0]) );
pData += chunk * sizeof(tracebuf[0]);
tracestrip = 0;
@@ -2836,15 +2836,15 @@ DumpTraceBuffer ( char __user *pData, int count )
} else {
chunk = dumpcount;
}
- rc = copy_to_user(pData, &tracebuf[tracestrip],
+ rc |= copy_to_user(pData, &tracebuf[tracestrip],
chunk * sizeof(tracebuf[0]) );
tracestrip += chunk;
tracewrap = 0;
- rc = put_user(tracestrip, ++pIndex );
- rc = put_user(tracestuff, ++pIndex );
+ rc |= put_user(tracestrip, ++pIndex);
+ rc |= put_user(tracestuff, ++pIndex);
- return dumpcount;
+ return rc ? -EFAULT : dumpcount;
#else
return 0;
#endif
--
1.7.0.4
next reply other threads:[~2010-07-29 15:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-29 15:55 Kulikov Vasiliy [this message]
2010-07-29 16:13 ` [PATCH] char: ip2: check put_user() result Alan Cox
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=1280418938-5833-1-git-send-email-segooon@gmail.com \
--to=segooon@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=ben@decadent.org.uk \
--cc=gregkh@suse.de \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhw@wittsend.com \
--cc=rakib.mullick@gmail.com \
/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