mirror of
https://github.com/lkl/linux.git
synced 2025-12-19 08:03:01 +09:00
lkl: remove CONFIG_ leaks in uapi headers
Upstream has introduce checks against leaking CONFIG_ leaks in uapi headers. We currently have the following sources for such leaks: 1. The kernel config.h we pull in syscalls.h 2. CONFIG_UID16 we use in syscalls.h 3. CONFIG_64BIT we use in syscalls.h and bitsperlong.h 4. CONFIG_BIG_ENDIAN we use in byteorder.h We can remove the config.h as we only use the above mentioned other 3 above CONFIG_. We can also remove CONFIG_UID16 and stick to providing uid32 APIs only (which it was the default anyways). The last two configs are not easy to deal with since we have targets where these are different so they need to be configurable. The approach taken for these are to create to let the host create a kernel config.h based on the current host target. We can then use that config.h to set the endianness and bits per long values, without relying on CONFIG_ symbols. Signed-off-by: Octavian Purdila <tavip@google.com>
This commit is contained in:
committed by
Octavian Purdila
parent
c2818c9a08
commit
0d680a3d58
@@ -5,5 +5,7 @@ generic-y += kvm_para.h
|
||||
generic-y += shmparam.h
|
||||
generic-y += timex.h
|
||||
|
||||
generated-y += config.h
|
||||
|
||||
# no header-y since we need special user headers handling
|
||||
# see arch/lkl/script/headers.py
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#ifndef _ASM_UAPI_LKL_BITSPERLONG_H
|
||||
#define _ASM_UAPI_LKL_BITSPERLONG_H
|
||||
|
||||
#ifdef CONFIG_64BIT
|
||||
#include <asm/config.h>
|
||||
|
||||
#if defined(LKL_CONFIG_64BIT)
|
||||
#define __BITS_PER_LONG 64
|
||||
#else
|
||||
#define __BITS_PER_LONG 32
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#ifndef _ASM_UAPI_LKL_BYTEORDER_H
|
||||
#define _ASM_UAPI_LKL_BYTEORDER_H
|
||||
|
||||
#if defined(CONFIG_BIG_ENDIAN)
|
||||
#include <asm/config.h>
|
||||
|
||||
#if defined(LKL_CONFIG_BIG_ENDIAN)
|
||||
#include <linux/byteorder/big_endian.h>
|
||||
#else
|
||||
#include <linux/byteorder/little_endian.h>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef _ASM_UAPI_LKL_SYSCALLS_H
|
||||
#define _ASM_UAPI_LKL_SYSCALLS_H
|
||||
|
||||
#include <autoconf.h>
|
||||
#include <asm/config.h>
|
||||
#include <linux/types.h>
|
||||
|
||||
typedef __kernel_uid32_t qid_t;
|
||||
@@ -21,10 +21,6 @@ typedef __kernel_gid32_t gid_t;
|
||||
typedef __kernel_uid16_t uid16_t;
|
||||
typedef __kernel_gid16_t gid16_t;
|
||||
typedef unsigned long uintptr_t;
|
||||
#ifdef CONFIG_UID16
|
||||
typedef __kernel_old_uid_t old_uid_t;
|
||||
typedef __kernel_old_gid_t old_gid_t;
|
||||
#endif
|
||||
typedef __kernel_loff_t loff_t;
|
||||
typedef __kernel_size_t size_t;
|
||||
typedef __kernel_ssize_t ssize_t;
|
||||
@@ -83,7 +79,7 @@ typedef __s64 s64;
|
||||
#undef __NR_umount
|
||||
#define __NR_umount __NR_umount2
|
||||
|
||||
#ifdef CONFIG_64BIT
|
||||
#if LKL_CONFIG_64BIT
|
||||
#define __NR_newfstat __NR3264_fstat
|
||||
#define __NR_newfstatat __NR3264_fstatat
|
||||
#endif
|
||||
|
||||
1
tools/lkl/.gitignore
vendored
1
tools/lkl/.gitignore
vendored
@@ -11,5 +11,6 @@ tests/disk
|
||||
tests/vfio-pci
|
||||
Makefile.conf
|
||||
include/lkl_autoconf.h
|
||||
include/kernel_config.h
|
||||
tests/autoconf.sh
|
||||
*.pyc
|
||||
|
||||
@@ -36,7 +36,7 @@ all:
|
||||
|
||||
conf: $(OUTPUT)Makefile.conf
|
||||
|
||||
$(OUTPUT)Makefile.conf: Makefile.autoconf
|
||||
$(OUTPUT)Makefile.conf $(OUTPUT)include/kernel_config.h: Makefile.autoconf
|
||||
$(call QUIET_AUTOCONF, headers)$(MAKE) -f Makefile.autoconf -s
|
||||
|
||||
-include $(OUTPUT)Makefile.conf
|
||||
@@ -60,9 +60,19 @@ else
|
||||
$(Q)touch bin/stat
|
||||
endif
|
||||
|
||||
# rule to build lkl.o
|
||||
$(OUTPUT)lib/lkl.o: bin/stat
|
||||
ASM_UAPI_GENERATED:=$(OUTPUT)../../arch/lkl/include/generated/uapi/asm
|
||||
ASM_CONFIG:=$(ASM_UAPI_GENERATED)/config.h
|
||||
DOT_CONFIG:=$(OUTPUT)../../.config
|
||||
|
||||
$(DOT_CONFIG):
|
||||
$(Q)$(MAKE) -C ../.. ARCH=lkl $(KOPT) $(KCONFIG)
|
||||
|
||||
$(ASM_CONFIG): $(OUTPUT)include/kernel_config.h
|
||||
$(Q)mkdir -p $$(dirname $@)
|
||||
$(call QUIET_INSTALL, kernel_config.h)cp $< $@
|
||||
|
||||
# rule to build lkl.o
|
||||
$(OUTPUT)lib/lkl.o: bin/stat $(ASM_CONFIG) $(DOT_CONFIG)
|
||||
# this workaround is for arm32 linker (ld.gold)
|
||||
$(Q)export PATH=$(srctree)/tools/lkl/bin/:${PATH} ;\
|
||||
$(MAKE) -C ../.. ARCH=lkl $(KOPT) install INSTALL_PATH=$(OUTPUT)
|
||||
|
||||
@@ -8,6 +8,11 @@ define set_autoconf_var
|
||||
export LKL_HOST_CONFIG_$(1)=$(2)
|
||||
endef
|
||||
|
||||
define set_kernel_config
|
||||
$(shell echo "#define $(1) $(2)" \
|
||||
>> $(OUTPUT)/include/kernel_config.h)
|
||||
endef
|
||||
|
||||
define find_include
|
||||
$(eval include_paths=$(shell $(CC) -E -Wp,-v -xc /dev/null 2>&1 | grep '^ '))
|
||||
$(foreach f, $(include_paths), $(wildcard $(f)/$(1)))
|
||||
@@ -101,6 +106,8 @@ define do_autoconf
|
||||
$(eval CC := $(CROSS_COMPILE)gcc)
|
||||
$(eval LD_FMT := $(shell $(LD) -r -print-output-format))
|
||||
$(eval EXEC_FMT := $(shell echo $(LD_FMT) | cut -d "-" -f1))
|
||||
$(if $(or $(filter $(EXEC_FMT),elf64),$(filter $(LD_FMT),pe-x86-64)),$(call set_kernel_config,LKL_CONFIG_64BIT,1))
|
||||
$(if $(filter $(EXEC_FMT),elf64-s390),$(call set_kernel_config,LKL_CONFIG_ENDIAN,1))
|
||||
$(if $(filter $(EXEC_FMT),$(POSIX_HOSTS)),$(call posix_host,$(LD_FMT)))
|
||||
$(if $(filter $(EXEC_FMT),$(NT_HOSTS)),$(call nt_host,$(LD_FMT)))
|
||||
endef
|
||||
@@ -112,5 +119,6 @@ $(OUTPUT)Makefile.conf: Makefile.autoconf
|
||||
$(shell mkdir -p $(OUTPUT)/include)
|
||||
$(shell mkdir -p $(OUTPUT)/tests)
|
||||
$(shell echo -n "" > $(OUTPUT)/include/lkl_autoconf.h)
|
||||
$(shell echo -n "" > $(OUTPUT)/include/kernel_config.h)
|
||||
$(shell echo -n "" > $(OUTPUT)/tests/autoconf.sh)
|
||||
@echo "$$do_autoconf" > $(OUTPUT)/Makefile.conf
|
||||
|
||||
Reference in New Issue
Block a user