Summary: | dbus-daemon segfault on 'service dhcdbd restart' | ||
---|---|---|---|
Product: | dbus | Reporter: | Dan Williams <dcbw> |
Component: | core | Assignee: | Havoc Pennington <hp> |
Status: | RESOLVED FIXED | QA Contact: | John (J5) Palmieri <johnp> |
Severity: | critical | ||
Priority: | high | CC: | bressers, johnp |
Version: | unspecified | ||
Hardware: | x86 (IA32) | ||
OS: | Linux (All) | ||
Whiteboard: | |||
i915 platform: | i915 features: | ||
Bug Depends on: | |||
Bug Blocks: | 7813 | ||
Attachments: | Make sure servicedir list is unique |
Description
Dan Williams
2006-10-24 20:05:49 UTC
This is seriously weird crack ... first, why the heck would the system bus load any service files, no <servicedir> are in the config file. Dan can you double check you have no <servicedir>? Maybe strace the bus daemon and see which directories it could be loading? Are you sure you haven't attached gdb to a session bus? Or is this maybe a dbus-daemon with davidz's system activation patch already added? I don't see how anything could get in the activation hash without a <servicedir>, because there's no default in the code. The dir to scan would have to magically appear from thin air or something. Second, the hash table printed by gdb here is not the one involved in any of the functions in the backtrace, but it's not memory garbage, it's just a totally unrelated hash table from another file. (dbus-userdb.c) Maybe gdb just gets confused about what "table" refers to? However, the assertion failure seems to indicate that at runtime maybe the wrong hash table _is_ swapped in. How, I have NO idea. I thought maybe mempools, but it looks like DBusHashTable is allocated with dbus_new0, not with a mem pool. The hash entries are in a mem pool, but don't see how that could matter. If I overlook the total implausibility of everything that's going on, then one theory is that maybe there's some refcounting problem with one of those hash entries so when doing the table_remove_string there the first one frees the entry before the second one runs. Dan, maybe valgrinding this or "p *activation" would be in some way enlightening, I don't know. First I'd just try to solve the mystery of how the system bus located any .service files in the first place. A couple problems I noticed in activation.c while looking at this: - things should short-circuit faster if there are no service dirs - it looks like all dirs are rescanned every time we get an activation request on a service we don't know about - yuck So a couple items there for TODO or bugzilla. Because servicedir is picked up from dhcdbd security profile since we don't distinguish between the system.conf and files in /etc/dbus-1/system.d. Adding to blocker. Havoc, what is the best way to deal with this? Why does dhcdbd specify a servicedir? That can't be the right thing for it to do. Need to file a bug against it, but I'm curious what the thinking was. Anyway, good to have that tracked down, so the next thing is just to debug the crash... presumably not that hard to do? Maybe start by getting "make check" to fail in this spot? In 1.0 we might want to add a config option <noactivate/> to go in system.conf which would cause us to throw an error on any <servicedir/>. We'll have to fix this crash anyway, but since activation makes no sense in 1.0, it'd be nice to just be sure it never happens. I'm marking this as a security bug though it is very low one in my opinion. Basicly what happens is we pass two directories of the same name (named and dhcdbd both install with servicedir set) two directory objects are created. The second object enters the hash with the same key which causes the hash to call the clean up funtion for the first directory object. Since entry objects have a pointer to the directory object (without getting a ref I might add) we eventually read from freed memory. The fix was to make sure list is unique when we parse config files. Patch to follow. Created attachment 7516 [details] [review] Make sure servicedir list is unique Havoc, have you looked at the patch yet? This check: if (link_dir && !strcmp (dir, link_dir)) should be: if (strcmp(dir, link_dir) == 0) (link_dir has no reason to be null and !strcmp isn't an idiom dbus uses) Looks fine otherwise, thanks. You might want to check that the right thing happens if we reload the config - do we dump all servicedir and start over, or do we try to merge somehow and get a similar bug An assertion in activation.c when adding each servicedir that it doesn't already exist would not hurt btw, I don't think this is a security bug. I can't think of an exploit anyway. It amounts to: if you are root, you can write out a file that makes an assertion fail in dbus-daemon. If you are root you can also just "killall dbus-daemon" It is not an assertion. It accesses freed memory. Good point, the assertion is a side-effect of the uninitialized read, but it doesn't change the basic situation that only root could ever trigger this - i.e. it requires creating a broken config file in a system directory. Which is why I think it is low risk but I would like bressers to look over it so we handle it right with all the distibutions. If only root can trigger this flaw, it shouldn't be considered a security issue. Even if someone does trigger this flaw, 'use after free' bugs are typically very difficult to anything other than cause a crash. If you have a rogue person logged in as root, you have far bigger problems than this. One more thing I just realized - the RPM is (and should be) built with -- disable-asserts. There's an assertion failure in here. What the heck? I compile with asserts on in Fedora so we can flush out bugs like these before 1.0. What am I missing, is http://cvs.fedora.redhat.com/viewcvs/rpms/dbus/devel/dbus.spec? rev=1.100&view=auto the wrong thing to look at? make_fast #keep debug mode for now. exit 0 Ah, did not see that. There's a problem here though - shipping with asserts makes things slow but it's OK until 1.0. However, shipping with tests and verbose definitely increases the footprint for security vulnerabilities, and may even introduce some (e.g. searching weird paths that aren't normally searched, format string bugs on any of the verbose spew, possible security- sensitive stuff in the verbose spew). Anyway, the warnings at the end of configure are afaik accurate... I would do an FC5 and FC6 update with this stuff off if possible. in cvs |
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.