From: "George Spelvin" <linux@horizon.com>
To: linux@horizon.com, andi@firstfloor.org
Cc: tj@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC] globmatch() helper function
Date: Wed, 17 Dec 2008 10:37:04 -0500 [thread overview]
Message-ID: <20081217153704.4238.qmail@science.horizon.com> (raw)
In-Reply-To: <87hc530w39.fsf@basil.nowhere.org>
Andi Kleen <andi@firstfloor.org> wrote:
> I'm uneasy with the unbounded recursion. Sure currently all the users
> are controlled in kernel source code and expect to put in sane patterns.
> But if someone ever adds a user controlled glob in some way it will be
> trivial to crash/overwrite memory with the limited kernel stack.
> And with such a generalized function it's likely to be used more
> in the future.
I was just trying to keep the code small and elegant, and adding a
recursion counter or explicit stack would complicate it.
Further, even ignoring the stack space issue, allowing uncontrolled
patterns exposes a second, more insidious bug: due to the naive
backtracking, the run time is (potentially) exponential in the number
of *s present. That could itself crash a non-preemptive kernel with a
watchdog enabled.
The simple fix is a very low limit on non-trailing * patterns (like
maybe 2), but then it's not generalized any more...
I'm willing to be persuaded, but the cost of making it robust against
pathological patterns is significant. Is it really worth it?
And if it's not actually robust, why include a half-assed solution?
Does anyone else have an opinion on the matter?
prev parent reply other threads:[~2008-12-17 15:37 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-17 10:42 George Spelvin
2008-12-17 13:28 ` Andi Kleen
2008-12-17 15:15 ` Peter Zijlstra
2008-12-17 15:47 ` Steven Rostedt
2008-12-17 16:15 ` Andi Kleen
2008-12-18 8:00 ` George Spelvin
2008-12-18 8:55 ` George Spelvin
2008-12-18 19:53 ` Casey Dahlin
2008-12-18 21:53 ` George Spelvin
2008-12-17 16:04 ` George Spelvin
2008-12-17 16:13 ` Steven Rostedt
2008-12-17 16:22 ` Tejun Heo
2008-12-17 16:31 ` Steven Rostedt
2008-12-17 16:33 ` Tejun Heo
2008-12-17 16:36 ` Peter Zijlstra
2008-12-17 16:45 ` Tejun Heo
2008-12-17 16:37 ` Steven Rostedt
2008-12-17 16:51 ` Andi Kleen
2008-12-17 16:54 ` Steven Rostedt
2008-12-17 15:37 ` George Spelvin [this message]
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=20081217153704.4238.qmail@science.horizon.com \
--to=linux@horizon.com \
--cc=andi@firstfloor.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tj@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
all inboxes | Powered by JetHome®