Package: libcap-ng0
Version: 0.6.6-1
Followup-For: Bug #631807
memset usage to reset the structure to 0 and NULL is indeed the
culprit.
Here is a patch that fix the bug.
I made it after reading:
http://ex-parrot.com/~chris/random/initialise.html
as I clued that being pedantic could help and it did.
Sadly I found no pointer telling about the rationale for why only on armel
does it fail.
Thus all I can tell here is the memset hack breaks on an address-of on a no
basic
type field of a __thread structure.
The patch is against src/cap-ng.c from libcap-ng 0.6.6
I tested the libcap-ng-utils on armel and also reinstalled bluez without
issues.
BR,
Alban
-- System Information:
Debian Release: wheezy/sid
APT prefers unstable
APT policy: (500, 'unstable'), (500, 'testing'), (1, 'experimental')
Architecture: amd64 (x86_64)
Kernel: Linux 3.4.0test0-03166-gf6a26ae (SMP w/2 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages libcap-ng0 depends on:
ii libc6 2.13-32
libcap-ng0 recommends no packages.
libcap-ng0 suggests no packages.
-- no debconf information
--- cap-ng.c.nofix 2012-05-29 04:35:34.000000000 +0000
+++ cap-ng.c.fix 2012-05-29 04:35:22.000000000 +0000
@@ -136,6 +136,11 @@
__u32 bounds[2];
};
+
+static struct __user_cap_header_struct hdrzz = {0, 0};
+static cap_data_t datazz = { {0, 0, 0} };
+static __u32 boundzz = {0};
+
// Global variables with per thread uniqueness
static __thread struct cap_ng m = { 1,
{0, 0},
@@ -149,7 +154,7 @@
if (m.state != CAPNG_NEW)
return;
- memset(&m.hdr, 0, sizeof(m.hdr));
+ m.hdr = hdrzz;
(void)capget(&m.hdr, NULL); // Returns -EINVAL
if (m.hdr.version == _LINUX_CAPABILITY_VERSION_3 ||
m.hdr.version == _LINUX_CAPABILITY_VERSION_2) {
@@ -161,7 +166,7 @@
return;
}
- memset(&m.data, 0, sizeof(cap_data_t));
+ m.data = datazz;
#ifdef HAVE_SYSCALL_H
m.hdr.pid = (unsigned)syscall(__NR_gettid);
#else
@@ -178,10 +183,13 @@
return;
if (set & CAPNG_SELECT_CAPS)
- memset(&m.data, 0, sizeof(cap_data_t));
+ m.data = datazz;
#ifdef PR_CAPBSET_DROP
- if (set & CAPNG_SELECT_BOUNDS)
- memset(m.bounds, 0, sizeof(m.bounds));
+ if (set & CAPNG_SELECT_BOUNDS) {
+ unsigned i;
+ for (i=0; i<sizeof(m.bounds)/sizeof(__u32); i++)
+ m.bounds[i] = boundzz;
+ }
#endif
m.state = CAPNG_INIT;
}