Bug 10791 - run-init changes to libbb/capability.c breaks compile with Android NDK API <21
Summary: run-init changes to libbb/capability.c breaks compile with Android NDK API <21
Status: RESOLVED FIXED
Alias: None
Product: Busybox
Classification: Unclassified
Component: Other (show other bugs)
Version: 1.28.x
Hardware: Other Other
: P5 critical
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-02-21 02:46 UTC by Chris Renshaw
Modified: 2018-07-24 13:12 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments
proposed patch (1.29 KB, patch)
2018-02-21 14:07 UTC, Denys Vlasenko
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Renshaw 2018-02-21 02:46:05 UTC
CC      libbb/capability.o
libbb/capability.c: In function 'getcaps':
libbb/capability.c:94:3: error: '_LINUX_CAPABILITY_U32S_3' undeclared (first use in this function)
   _LINUX_CAPABILITY_U32S_3, /* = 2 (fits into byte) */
   ^
libbb/capability.c:94:3: note: each undeclared identifier is reported only once for each function it appears in
libbb/capability.c:95:3: error: '_LINUX_CAPABILITY_U32S_2' undeclared (first use in this function)
   _LINUX_CAPABILITY_U32S_2, /* = 2 */
   ^
libbb/capability.c:96:3: error: '_LINUX_CAPABILITY_U32S_1' undeclared (first use in this function)
   _LINUX_CAPABILITY_U32S_1, /* = 1 */
   ^
libbb/capability.c:111:8: error: '_LINUX_CAPABILITY_VERSION_1' undeclared (first use in this function)
   case _LINUX_CAPABILITY_VERSION_1:
        ^
libbb/capability.c:112:15: warning: assignment makes integer from pointer without a cast
    caps->u32s = _LINUX_CAPABILITY_U32S_1;
               ^
libbb/capability.c:114:8: error: '_LINUX_CAPABILITY_VERSION_2' undeclared (first use in this function)
   case _LINUX_CAPABILITY_VERSION_2:
        ^
libbb/capability.c:115:15: warning: assignment makes integer from pointer without a cast
    caps->u32s = _LINUX_CAPABILITY_U32S_2;
               ^
libbb/capability.c:117:8: error: '_LINUX_CAPABILITY_VERSION_3' undeclared (first use in this function)
   case _LINUX_CAPABILITY_VERSION_3:
        ^
libbb/capability.c:118:15: warning: assignment makes integer from pointer without a cast
    caps->u32s = _LINUX_CAPABILITY_U32S_3;
               ^
make[1]: *** [scripts/Makefile.build:198: libbb/capability.o] Error 1

Prior to https://git.busybox.net/busybox/commit/?id=200bcc851acbe1ba30fe90b5cf918f88370a5d15 this could be avoided by disabling CONFIG_FEATURE_SETPRIV_CAPABILITIES + CONFIG_FEATURE_SETPRIV_CAPABILITY_NAMES, but now is unavoidable without disabling CONFIG_PLATFORM_LINUX (so, unavoidable). I have verified this by reverting the 3 run-init commits in 1.28.1 to date and a basic build is able to complete without issue after those config changes to avoid the include.

For reference, the only _LINUX_CAPABILITY define in linux/capability.h prior to Android NDK API 21 is "#define _LINUX_CAPABILITY_VERSION 0x19980330"

Thanks!
Comment 1 Chris Renshaw 2018-02-21 04:06:48 UTC
Also just noticed that run-init includes sys/prctl.h without the precautions taken in setpriv.c, so perhaps those could be added as well:

#ifndef PR_CAPBSET_READ
#define PR_CAPBSET_READ 23
#endif

#ifndef PR_CAPBSET_DROP
#define PR_CAPBSET_DROP 24
#endif
Comment 2 Denys Vlasenko 2018-02-21 14:07:11 UTC
Created attachment 7486 [details]
proposed patch

Please try attached patch
Comment 3 Chris Renshaw 2018-02-23 09:14:07 UTC
I cherry-picked your patch from master branch (https://git.busybox.net/busybox/commit/?id=2af5e3fac394a922bcf7752be25128879405a21a) and it worked as advertised! Thanks Denys. :)