configs for jailed procs to dump code coverage data

list system calls used for dumping code coverage information; empty on
non code coverage builds. Mini-jail configurations can include this file
instead of trying to manage the list themselves.

Bug: 139313557
Test: arm32/arm64/x86 media svcs w/native coverage on, kill -37 to dump stats.
Change-Id: I7323a9739803756a76f54e4a98e995522cab71ef
This commit is contained in:
Ray Essick 2019-10-31 13:53:05 -07:00 committed by Elliott Hughes
parent 57292aa684
commit 36e6f6d128
11 changed files with 160 additions and 0 deletions

37
code_coverage/Android.mk Normal file
View file

@ -0,0 +1,37 @@
# policies to allow processes inside minijail to dump code coverage information
#
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := code_coverage.policy
LOCAL_MODULE_CLASS := ETC
LOCAL_MULTILIB := both
ifeq ($(TARGET_ARCH), $(filter $(TARGET_ARCH), arm arm64))
LOCAL_MODULE_STEM_32 := code_coverage.arm.policy
LOCAL_MODULE_STEM_64 := code_coverage.arm64.policy
endif
ifeq ($(TARGET_ARCH), $(filter $(TARGET_ARCH), x86 x86_64))
LOCAL_MODULE_STEM_32 := code_coverage.x86.policy
LOCAL_MODULE_STEM_64 := code_coverage.x86_64.policy
endif
# different files for different configurations
ifeq ($(NATIVE_COVERAGE),true)
LOCAL_SRC_FILES_arm := seccomp_policy/code_coverage.arm.policy
LOCAL_SRC_FILES_arm64 := seccomp_policy/code_coverage.arm64.policy
LOCAL_SRC_FILES_x86 := seccomp_policy/code_coverage.x86.policy
LOCAL_SRC_FILES_x86_64 := seccomp_policy/code_coverage.x86_64.policy
else
LOCAL_SRC_FILES_arm := empty_policy/code_coverage.arm.policy
LOCAL_SRC_FILES_arm64 := empty_policy/code_coverage.arm64.policy
LOCAL_SRC_FILES_x86 := empty_policy/code_coverage.x86.policy
LOCAL_SRC_FILES_x86_64 := empty_policy/code_coverage.x86_64.policy
endif
LOCAL_MODULE_TARGET_ARCH := arm arm64 x86 x86_64
LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/seccomp_policy
include $(BUILD_PREBUILT)

View file

@ -0,0 +1,2 @@
# empty unless code_coverage is enabled.
# code_coverage.arm.policy

View file

@ -0,0 +1,2 @@
# empty unless code_coverage is enabled.
# code_coverage.arm64.policy

View file

@ -0,0 +1,2 @@
# empty unless code_coverage is enabled.
# code_coverage.x86.policy

View file

@ -0,0 +1,2 @@
# empty unless code_coverage is enabled.
# code_coverage.x86_64.policy

View file

@ -0,0 +1,14 @@
close: 1
mkdirat: 1
msync: 1
munmap: 1
openat: 1
write: 1
fcntl64: 1
fstat64: 1
geteuid32: 1
_llseek: 1
mmap2: 1
sigreturn: 1
gettimeofday: 1
prctl: 1

View file

@ -0,0 +1,13 @@
close: 1
mkdirat: 1
msync: 1
munmap: 1
openat: 1
write: 1
fcntl: 1
fstat: 1
geteuid: 1
lseek: 1
mmap: 1
rt_sigreturn: 1
prctl: 1

View file

@ -0,0 +1,51 @@
// SECCOMP_MODE_STRICT
//
// minijail allowances for code coverage
// this is processed with generate.sh, so we can use appropriate directives
// size specific: __LP64__ for 64 bit, else 32 bit
// arch specific: __arm__, __aarch64__, __i386__, __x86_64__
// includes *all* syscalls used during the coverage dumping
// no skipping just because they might have been in another policy file.
// coverage tool uses different operations on different passes
// 1st: uses write() to fill the file
// 2nd-Nth: uses mmap() to update in place
close: 1
mkdirat: 1
msync: 1
munmap: 1
openat: 1
write: 1
#if defined(__LP64__)
fcntl: 1
fstat: 1
geteuid: 1
lseek: 1
mmap: 1
rt_sigreturn: 1
#else
fcntl64: 1
fstat64: 1
geteuid32: 1
_llseek: 1
mmap2: 1
sigreturn: 1
#endif
#if defined(__arm__)
gettimeofday: 1
#endif
#if defined(__i386__)
madvise: 1
#endif
#if defined(__arm__)
prctl: 1
#elif defined(__aarch64__)
prctl: 1
#endif

View file

@ -0,0 +1,13 @@
close: 1
mkdirat: 1
msync: 1
munmap: 1
openat: 1
write: 1
fcntl64: 1
fstat64: 1
geteuid32: 1
_llseek: 1
mmap2: 1
sigreturn: 1
madvise: 1

View file

@ -0,0 +1,12 @@
close: 1
mkdirat: 1
msync: 1
munmap: 1
openat: 1
write: 1
fcntl: 1
fstat: 1
geteuid: 1
lseek: 1
mmap: 1
rt_sigreturn: 1

View file

@ -0,0 +1,12 @@
#!/bin/bash
# generate the arch-specific files from the generic one
set -ex
cd "$(dirname "$0")"
CPP='cpp -undef -E -P code_coverage.policy.def'
$CPP -D__arm__ -o code_coverage.arm.policy
$CPP -D__aarch64__ -D__LP64__ -o code_coverage.arm64.policy
$CPP -D__i386__ -o code_coverage.x86.policy
$CPP -D__x86_64__ -D__LP64__ -o code_coverage.x86_64.policy