Skip to content

Commit 5d90cf6

Browse files
jmberg-intelrichardweinberger
authored andcommitted
um: further clean up user_syms
Make some cleanups, add and fix some comments and document here that we shouldn't export (libc) symbols for "_user.c" code, rather such should work like hostfs does now. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Richard Weinberger <richard@nod.at>
1 parent 6d708d1 commit 5d90cf6

1 file changed

Lines changed: 16 additions & 15 deletions

File tree

arch/um/os-Linux/user_syms.c

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,36 @@
33
#include <linux/types.h>
44
#include <linux/module.h>
55

6-
/* Some of this are builtin function (some are not but could in the future),
7-
* so I *must* declare good prototypes for them and then EXPORT them.
8-
* The kernel code uses the macro defined by include/linux/string.h,
9-
* so I undef macros; the userspace code does not include that and I
10-
* add an EXPORT for the glibc one.
6+
/*
7+
* This file exports some critical string functions and compiler
8+
* built-in functions (where calls are emitted by the compiler
9+
* itself that we cannot avoid even in kernel code) to modules.
10+
*
11+
* "_user.c" code that previously used exports here such as hostfs
12+
* really should be considered part of the 'hypervisor' and define
13+
* its own API boundary like hostfs does now; don't add exports to
14+
* this file for such cases.
1115
*/
1216

13-
#undef strlen
14-
#undef strstr
15-
#undef memcpy
16-
#undef memset
17-
18-
extern size_t strlen(const char *);
19-
extern void *memmove(void *, const void *, size_t);
20-
extern void *memset(void *, int, size_t);
21-
2217
/* If it's not defined, the export is included in lib/string.c.*/
2318
#ifdef __HAVE_ARCH_STRSTR
19+
#undef strstr
2420
EXPORT_SYMBOL(strstr);
2521
#endif
2622

2723
#ifndef __x86_64__
24+
#undef memcpy
2825
extern void *memcpy(void *, const void *, size_t);
2926
EXPORT_SYMBOL(memcpy);
27+
extern void *memmove(void *, const void *, size_t);
3028
EXPORT_SYMBOL(memmove);
29+
#undef memset
30+
extern void *memset(void *, int, size_t);
3131
EXPORT_SYMBOL(memset);
3232
#endif
3333

3434
#ifdef CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA
35+
/* needed for __access_ok() */
3536
EXPORT_SYMBOL(vsyscall_ehdr);
3637
EXPORT_SYMBOL(vsyscall_end);
3738
#endif
@@ -44,6 +45,6 @@ extern long __guard __attribute__((weak));
4445
EXPORT_SYMBOL(__guard);
4546

4647
#ifdef _FORTIFY_SOURCE
47-
extern int __sprintf_chk(char *str, int flag, size_t strlen, const char *format);
48+
extern int __sprintf_chk(char *str, int flag, size_t len, const char *format);
4849
EXPORT_SYMBOL(__sprintf_chk);
4950
#endif

0 commit comments

Comments
 (0)