* buffer overflow in srm_env_write?!
@ 2005-03-11 12:23 oliver.heid
2005-03-11 16:35 ` rezso
0 siblings, 1 reply; 5+ messages in thread
From: oliver.heid @ 2005-03-11 12:23 UTC (permalink / raw)
Shouldn't
if (copy_from_user(buf, buffer, count))
goto out;
buf[count] = '\0';
ret1 = callback_setenv(entry->id, buf, count);
read
buf[count-1] = '\0';
^^^^^^^
in srm_env_write() in srm_env.c?! When I change SRM variables via
/proc/srm_environment, a trailing linefeed 0x0a is written into the
variable, which it is not when changing the variable via the SRM graphical
console itself. The above code change overwrites the linefeed with 0x0.
Oliver
^ permalink raw reply [flat|nested] 5+ messages in thread
* buffer overflow in srm_env_write?!
2005-03-11 12:23 oliver.heid
@ 2005-03-11 16:35 ` rezso
0 siblings, 0 replies; 5+ messages in thread
From: rezso @ 2005-03-11 16:35 UTC (permalink / raw)
On Friday 11 March 2005 14:23, Heid Oliver wrote:
> Shouldn't
>
> if (copy_from_user(buf, buffer, count))
> goto out;
> buf[count] = '\0';
>
> ret1 = callback_setenv(entry->id, buf, count);
>
> read
>
> buf[count-1] = '\0';
> ^^^^^^^
>
> in srm_env_write() in srm_env.c?! When I change SRM variables via
> /proc/srm_environment, a trailing linefeed 0x0a is written into the
> variable, which it is not when changing the variable via the SRM graphical
> console itself. The above code change overwrites the linefeed with 0x0.
can post a patch for this ?
It is a bug, srm env through proc is really unusable,
evry time when i do echo "1" > /proc/.../boot_osflags it doesn't work only
if i re-set it in real SRM bios.
>
> Oliver
>
> _______________________________________________
> axp-list mailing list
> axp-list at redhat.com
> https://www.redhat.com/mailman/listinfo/axp-list
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* buffer overflow in srm_env_write?!
@ 2005-03-14 16:19 oliver.heid
2005-03-14 19:15 ` falk
0 siblings, 1 reply; 5+ messages in thread
From: oliver.heid @ 2005-03-14 16:19 UTC (permalink / raw)
here it is.
--- arch/alpha/kernel/srm_env.c~ 2005-03-02 08:37:49.000000000 +0100
+++ arch/alpha/kernel/srm_env.c 2005-03-14 17:00:48.000000000 +0100
@@ -152,7 +152,7 @@
res = -EFAULT;
if (copy_from_user(buf, buffer, count))
goto out;
- buf[count] = '\0';
+ buf[count-1] = '\0';
ret1 = callback_setenv(entry->id, buf, count);
if ((ret1 >> 61) == 0) {
---
-----Original Message-----
From: Balint Cristian [mailto:rezso at rdsor.ro]
Sent: Friday, March 11, 2005 17:36
To: axp-list at redhat.com; rth at redhat.com
Cc: Heid Oliver
Subject: Re: buffer overflow in srm_env_write?!
On Friday 11 March 2005 14:23, Heid Oliver wrote:
> Shouldn't
>
> if (copy_from_user(buf, buffer, count))
> goto out;
> buf[count] = '\0';
>
> ret1 = callback_setenv(entry->id, buf, count);
>
> read
>
> buf[count-1] = '\0';
> ^^^^^^^
>
> in srm_env_write() in srm_env.c?! When I change SRM variables via
> /proc/srm_environment, a trailing linefeed 0x0a is written into the
> variable, which it is not when changing the variable via the SRM graphical
> console itself. The above code change overwrites the linefeed with 0x0.
can post a patch for this ?
It is a bug, srm env through proc is really unusable,
evry time when i do echo "1" > /proc/.../boot_osflags it doesn't work only
if i re-set it in real SRM bios.
>
> Oliver
>
> _______________________________________________
> axp-list mailing list
> axp-list at redhat.com
> https://www.redhat.com/mailman/listinfo/axp-list
>
_______________________________________________
axp-list mailing list
axp-list at redhat.com
https://www.redhat.com/mailman/listinfo/axp-list
^ permalink raw reply [flat|nested] 5+ messages in thread
* buffer overflow in srm_env_write?!
2005-03-14 16:19 buffer overflow in srm_env_write?! oliver.heid
@ 2005-03-14 19:15 ` falk
2005-03-14 20:47 ` michal
0 siblings, 1 reply; 5+ messages in thread
From: falk @ 2005-03-14 19:15 UTC (permalink / raw)
Heid Oliver <oliver.heid at siemens.com> writes:
> here it is.
>
> --- arch/alpha/kernel/srm_env.c~ 2005-03-02 08:37:49.000000000 +0100
> +++ arch/alpha/kernel/srm_env.c 2005-03-14 17:00:48.000000000 +0100
> @@ -152,7 +152,7 @@
> res = -EFAULT;
> if (copy_from_user(buf, buffer, count))
> goto out;
> - buf[count] = '\0';
> + buf[count-1] = '\0';
>
> ret1 = callback_setenv(entry->id, buf, count);
> if ((ret1 >> 61) == 0) {
> ---
That will nuke the kernel if count == 0.
The real solution is not to add a newline if you don't want one to be
added. Use echo -n.
--
Falk
^ permalink raw reply [flat|nested] 5+ messages in thread
* buffer overflow in srm_env_write?!
2005-03-14 19:15 ` falk
@ 2005-03-14 20:47 ` michal
0 siblings, 0 replies; 5+ messages in thread
From: michal @ 2005-03-14 20:47 UTC (permalink / raw)
On Mon, Mar 14, 2005 at 08:15:44PM +0100, Falk Hueffner wrote:
> Heid Oliver <oliver.heid at siemens.com> writes:
>
> > here it is.
> >
> > --- arch/alpha/kernel/srm_env.c~ 2005-03-02 08:37:49.000000000 +0100
> > +++ arch/alpha/kernel/srm_env.c 2005-03-14 17:00:48.000000000 +0100
> > @@ -152,7 +152,7 @@
> > res = -EFAULT;
> > if (copy_from_user(buf, buffer, count))
> > goto out;
> > - buf[count] = '\0';
> > + buf[count-1] = '\0';
> >
> > ret1 = callback_setenv(entry->id, buf, count);
> > if ((ret1 >> 61) == 0) {
> > ---
>
> That will nuke the kernel if count == 0.
Do we ever really want a traling newline here? If not then
such code in srm_env.c may cause the least surprises:
if (copy_from_user(buf, buffer, count))
goto out;
if (count > 0 && buf[count-1] == '\n')
count -= 1;
buf[count] = '\0';
ret1 = callback_setenv(entry->id, buf, count);
.....
Although then if want that newline you have to do something
like
echo "extra newline
"
which will be not obvious.
Michal
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-03-14 20:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-03-14 16:19 buffer overflow in srm_env_write?! oliver.heid
2005-03-14 19:15 ` falk
2005-03-14 20:47 ` michal
-- strict thread matches above, loose matches on Subject: below --
2005-03-11 12:23 oliver.heid
2005-03-11 16:35 ` rezso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox