* [PATCH] char: istallion: fix arbitrary kernel memory reads/writes
@ 2011-04-09 12:41 Vasiliy Kulikov
2011-04-09 13:26 ` Jiri Slaby
0 siblings, 1 reply; 5+ messages in thread
From: Vasiliy Kulikov @ 2011-04-09 12:41 UTC (permalink / raw)
To: linux-kernel; +Cc: Greg Kroah-Hartman, Arnd Bergmann, Alan Cox
stli_brdstats is defined as global variable. After de-BKL-ization in
the patch b4eda9cb48eac1b7 an access to the variable is not serialized
anymore. This leads to the TOCTOU in stli_getbrdstats():
if (copy_from_user(&stli_brdstats, bp, sizeof(combrd_t)))
return -EFAULT;
if (stli_brdstats.brd >= STL_MAXBRDS) <<<<
return -ENODEV;
brdp = stli_brds[stli_brdstats.brd]; <<<<
If one process calls COM_GETBRDSTATS ioctl() with sane .brd, second
process calls COM_GETBRDSTATS ioctl() with invalid .brd, and the
second process' copy_from_user() executes exactly between the check and
stli_brds[] indexation of the first process, then the first process gets
contents of memory at *stli_brds[stli_brdstats.brd] address. Also
the resulting .nrpanels field may be too big, in this case
stli_brdstats.panels array overflows.
Signed-off-by: Vasiliy Kulikov <segoon@openwall.com>
---
drivers/char/istallion.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c
index 7c6de4c..232c5e0 100644
--- a/drivers/char/istallion.c
+++ b/drivers/char/istallion.c
@@ -186,7 +186,6 @@ static struct ktermios stli_deftermios = {
* re-used for each stats call.
*/
static comstats_t stli_comstats;
-static combrd_t stli_brdstats;
static struct asystats stli_cdkstats;
/*****************************************************************************/
@@ -4005,6 +4004,7 @@ static int stli_getbrdstats(combrd_t __user *bp)
{
struct stlibrd *brdp;
unsigned int i;
+ combrd_t stli_brdstats;
if (copy_from_user(&stli_brdstats, bp, sizeof(combrd_t)))
return -EFAULT;
--
1.7.0.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] char: istallion: fix arbitrary kernel memory reads/writes
2011-04-09 12:41 [PATCH] char: istallion: fix arbitrary kernel memory reads/writes Vasiliy Kulikov
@ 2011-04-09 13:26 ` Jiri Slaby
2011-04-09 20:24 ` Valdis.Kletnieks
0 siblings, 1 reply; 5+ messages in thread
From: Jiri Slaby @ 2011-04-09 13:26 UTC (permalink / raw)
To: Vasiliy Kulikov; +Cc: linux-kernel, Greg Kroah-Hartman, Arnd Bergmann, Alan Cox
On 04/09/2011 02:41 PM, Vasiliy Kulikov wrote:
> stli_brdstats is defined as global variable. After de-BKL-ization in
> the patch b4eda9cb48eac1b7 an access to the variable is not serialized
> anymore. This leads to the TOCTOU in stli_getbrdstats():
Don't use such a weird and uncommon abbreviations.
> --- a/drivers/char/istallion.c
> +++ b/drivers/char/istallion.c
Note that the code moved to staging.
regards,
--
js
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] char: istallion: fix arbitrary kernel memory reads/writes
2011-04-09 13:26 ` Jiri Slaby
@ 2011-04-09 20:24 ` Valdis.Kletnieks
2011-04-09 20:36 ` Jiri Slaby
0 siblings, 1 reply; 5+ messages in thread
From: Valdis.Kletnieks @ 2011-04-09 20:24 UTC (permalink / raw)
To: Jiri Slaby
Cc: Vasiliy Kulikov, linux-kernel, Greg Kroah-Hartman, Arnd Bergmann,
Alan Cox
[-- Attachment #1: Type: text/plain, Size: 525 bytes --]
On Sat, 09 Apr 2011 15:26:59 +0200, Jiri Slaby said:
> On 04/09/2011 02:41 PM, Vasiliy Kulikov wrote:
> > stli_brdstats is defined as global variable. After de-BKL-ization in
> > the patch b4eda9cb48eac1b7 an access to the variable is not serialized
> > anymore. This leads to the TOCTOU in stli_getbrdstats():
>
> Don't use such a weird and uncommon abbreviations.
Time Of Check [to] Time Of Use. Hardly uncommon, especially in the security
community. Googling for 'TOCTOU' and 'TOCTTOU' gets about 60K hits combined.
[-- Attachment #2: Type: application/pgp-signature, Size: 227 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] char: istallion: fix arbitrary kernel memory reads/writes
2011-04-09 20:24 ` Valdis.Kletnieks
@ 2011-04-09 20:36 ` Jiri Slaby
0 siblings, 0 replies; 5+ messages in thread
From: Jiri Slaby @ 2011-04-09 20:36 UTC (permalink / raw)
To: Valdis.Kletnieks
Cc: Vasiliy Kulikov, linux-kernel, Greg Kroah-Hartman, Arnd Bergmann,
Alan Cox
On 04/09/2011 10:24 PM, Valdis.Kletnieks@vt.edu wrote:
> On Sat, 09 Apr 2011 15:26:59 +0200, Jiri Slaby said:
>> On 04/09/2011 02:41 PM, Vasiliy Kulikov wrote:
>>> stli_brdstats is defined as global variable. After de-BKL-ization in
>>> the patch b4eda9cb48eac1b7 an access to the variable is not serialized
>>> anymore. This leads to the TOCTOU in stli_getbrdstats():
>>
>> Don't use such a weird and uncommon abbreviations.
>
> Time Of Check [to] Time Of Use. Hardly uncommon, especially in the security
> community.
Well, changelogs are not for security community only. And I think I've
read far than enough papers about code analysis and never seen that before.
> Googling for 'TOCTOU' and 'TOCTTOU' gets about 60K hits combined.
Sure, I googled that a bit. But that didn't persuade me at all. It looks
like it is used by a narrow set of experts.
Whatever, I mainly wanted to point out the code move.
thanks,
--
js
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] char: istallion: fix arbitrary kernel memory reads/writes
@ 2011-04-14 15:56 Vasiliy Kulikov
0 siblings, 0 replies; 5+ messages in thread
From: Vasiliy Kulikov @ 2011-04-14 15:56 UTC (permalink / raw)
To: linux-kernel; +Cc: Greg Kroah-Hartman, devel
stli_brdstats is defined as global variable. After de-BKL-ization in
the patch b4eda9cb48eac1b7 an access to the variable is not serialized
anymore. This leads to the race window between the check and the use
in stli_getbrdstats():
if (copy_from_user(&stli_brdstats, bp, sizeof(combrd_t)))
return -EFAULT;
if (stli_brdstats.brd >= STL_MAXBRDS) <<<
return -ENODEV;
brdp = stli_brds[stli_brdstats.brd]; <<<
If one process calls COM_GETBRDSTATS ioctl() with sane .brd, second
process calls COM_GETBRDSTATS ioctl() with invalid .brd, and the
second process' copy_from_user() executes exactly between the check and
stli_brds[] indexation of the first process, then the first process gets
contents of memory at *stli_brds[stli_brdstats.brd] address. Also
the resulting .nrpanels field may be too big, in this case
stli_brdstats.panels array overflows.
Signed-off-by: Vasiliy Kulikov <segoon@openwall.com>
---
drivers/staging/tty/istallion.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/staging/tty/istallion.c b/drivers/staging/tty/istallion.c
index 0b26627..ca18cbf 100644
--- a/drivers/staging/tty/istallion.c
+++ b/drivers/staging/tty/istallion.c
@@ -186,7 +186,6 @@ static struct ktermios stli_deftermios = {
* re-used for each stats call.
*/
static comstats_t stli_comstats;
-static combrd_t stli_brdstats;
static struct asystats stli_cdkstats;
/*****************************************************************************/
@@ -4005,6 +4004,7 @@ static int stli_getbrdstats(combrd_t __user *bp)
{
struct stlibrd *brdp;
unsigned int i;
+ combrd_t stli_brdstats;
if (copy_from_user(&stli_brdstats, bp, sizeof(combrd_t)))
return -EFAULT;
--
1.7.0.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-04-14 15:56 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-09 12:41 [PATCH] char: istallion: fix arbitrary kernel memory reads/writes Vasiliy Kulikov
2011-04-09 13:26 ` Jiri Slaby
2011-04-09 20:24 ` Valdis.Kletnieks
2011-04-09 20:36 ` Jiri Slaby
-- strict thread matches above, loose matches on Subject: below --
2011-04-14 15:56 Vasiliy Kulikov
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).