From: Andrew Morton <akpm@osdl.org>
To: tglx@linutronix.de
Cc: linux-kernel@vger.kernel.org, mingo@elte.hu, trini@kernel.crashing.org
Subject: Re: [patch 1/2] Validate itimer timeval from userspace
Date: Sat, 18 Mar 2006 14:25:20 -0800 [thread overview]
Message-ID: <20060318142520.2dcbb46c.akpm@osdl.org> (raw)
In-Reply-To: <1142719518.10017.17.camel@localhost.localdomain>
Thomas Gleixner <tglx@linutronix.de> wrote:
>
> On Sat, 2006-03-18 at 13:09 -0800, Andrew Morton wrote:
> > > Of course I can convert it that way, if we want to keep this "help
> > > sloppy programmers aid" alive.
> > >
> >
> > It would be strange to set an alarm for 0xffffffff seconds in the future
> > but yeah, unless we can point at a reason why nobody could have ever been
> > doing that, we should turn this into permanent, documented behaviour of
> > Linux 2.6 and earlier, I'm afraid.
>
> We have to take two things into account:
>
> 1. sys_alarm()
>
> The alarm value 0xFFFFFFFF is valid as the argument to alarm() is an
> unsigned int. So we have to convert this to 0x7FFFFFFF (for 32bit
> machines) because timeval.tv_sec is a signed long. This is done by the
> alarm patch, which is necessary whether we check the sanity of the
> timeval in do_setitimer or not. The current -rc6 kernel sends the alarm
> with the next timer tick, which will break an application which set it
> to something > INT_MAX.
>
> Of course we could do this by the silent conversion of negative values
> in setitimer too. But thats insane as we rely on some broken feature.
So you're saying that sys_alarm(0xffffffff) needs to behave as
sys_alarm(0x7ffffffff)?
I guess if we have to do it that way, the risk of breaking anything is very
small.
What's the 2.4/2.6.13 behaviour of sys_alarm(0xffffffff)?
> 2. setitimer()
>
> An application would have to set value.it_value.tv_sec to a negative
> value to trigger this. Also uninitialized usage of struct timevals can
> cause such behaviour.
>
> I'm not sure, if it is sane to ingore this.
What does 2.4/2.6.13 do? Let's do that.
If you're proposing that we depart from previous behaviour by converting
setitimer(0xffffffff) into setitimer(0x7fffffff) then I guess we could live
with that.
> I can change the itimer
> validate patch for now to do
>
> if (unlikely(!timeval_valid(v))
> fixup_timeval(v);
>
> and print an appropriate warning in fixup_timeval() for the time being.
>
No, we cannot warn - it'll enable unprivileged users to spam the logs.
One could generate a once-per-reboot warning, I guess. The message should
include the PID and current->comm.
next prev parent reply other threads:[~2006-03-18 22:28 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-18 15:18 [patch 0/2] sys_setitimer and sys_alarm hotfixes Thomas Gleixner
2006-03-18 15:18 ` [patch 1/2] Validate itimer timeval from userspace Thomas Gleixner
2006-03-18 19:10 ` Ingo Molnar
2006-03-18 19:57 ` Thomas Gleixner
2006-03-18 20:07 ` Andrew Morton
2006-03-18 20:16 ` Thomas Gleixner
2006-03-18 20:31 ` Andrew Morton
2006-03-18 20:38 ` Thomas Gleixner
2006-03-18 21:09 ` Andrew Morton
2006-03-18 21:26 ` Jesper Juhl
2006-03-18 21:33 ` Andrew Morton
2006-03-18 21:50 ` Jesper Juhl
2006-03-18 22:05 ` Thomas Gleixner
2006-03-18 22:25 ` Andrew Morton [this message]
2006-03-18 23:12 ` tglx
2006-03-18 20:45 ` Jesper Juhl
2006-03-18 22:02 ` Ray Lee
2006-03-18 23:14 ` Eric Piel
2006-03-19 8:55 ` Kyle Moffett
2006-03-18 20:23 ` Jesper Juhl
2006-03-18 20:30 ` Thomas Gleixner
2006-03-18 21:04 ` Andrew Morton
2006-03-21 15:31 ` Pavel Machek
2006-03-18 15:18 ` [patch 2/2] alarm unsigned signed conversion fixup Thomas Gleixner
2006-03-18 20:02 ` Thomas Gleixner
2006-03-18 20:12 ` Andrew Morton
2006-03-18 20:27 ` Thomas Gleixner
2006-03-18 21:06 ` Andrew Morton
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=20060318142520.2dcbb46c.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
--cc=trini@kernel.crashing.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
Powered by JetHome