Skip to content

Commit 0f5fe54

Browse files
committed
luzer: disable parasite instrumentation
Follows up commit f379505 ("luzer: disable instrumentation of internal functions"). Follows up #11
1 parent 59877a2 commit 0f5fe54

File tree

6 files changed

+38
-29
lines changed

6 files changed

+38
-29
lines changed

luzer/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ set(LUZER_SOURCES luzer.c
1616
add_library(luzer_impl SHARED ${LUZER_SOURCES})
1717
target_include_directories(luzer_impl PRIVATE
1818
${LUA_INCLUDE_DIR}
19+
${CMAKE_CURRENT_SOURCE_DIR}
1920
)
2021

2122
target_link_libraries(luzer_impl PRIVATE

luzer/compat.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "lua.h"
22
#include "lualib.h"
33
#include "lauxlib.h"
4+
#include "macros.h"
45

56
/*
67
* PUC-Rio Lua uses `lconfig_h` as include guard for `luaconf.h`,
@@ -14,7 +15,7 @@
1415

1516
#if !defined(LUA_VERSION_NUM) || (LUA_VERSION_NUM == 501 && !defined(IS_LUAJIT))
1617

17-
static int
18+
NO_SANITIZE static int
1819
countlevels(lua_State *L) {
1920
lua_Debug ar;
2021
int li = 1, le = 1;
@@ -32,7 +33,7 @@ countlevels(lua_State *L) {
3233
return le - 1;
3334
}
3435

35-
static int
36+
NO_SANITIZE static int
3637
findfield(lua_State *L, int objidx, int level) {
3738
if (level == 0 || !lua_istable(L, -1))
3839
/* Not found. */
@@ -68,22 +69,22 @@ findfield(lua_State *L, int objidx, int level) {
6869
return 0;
6970
}
7071

71-
int
72+
NO_SANITIZE int
7273
lua_absindex(lua_State *L, int i) {
7374
if (i < 0 && i > LUA_REGISTRYINDEX)
7475
i += lua_gettop(L) + 1;
7576
return i;
7677
}
7778

78-
void
79+
NO_SANITIZE void
7980
lua_copy(lua_State *L, int from, int to) {
8081
int abs_to = lua_absindex(L, to);
8182
luaL_checkstack(L, 1, "not enough stack slots");
8283
lua_pushvalue(L, from);
8384
lua_replace(L, abs_to);
8485
}
8586

86-
static int
87+
NO_SANITIZE static int
8788
pushglobalfuncname(lua_State *L, lua_Debug *ar) {
8889
int top = lua_gettop(L);
8990
/* Push function. */
@@ -103,7 +104,7 @@ pushglobalfuncname(lua_State *L, lua_Debug *ar) {
103104
}
104105
}
105106

106-
static void
107+
NO_SANITIZE static void
107108
pushfuncname(lua_State *L, lua_Debug *ar) {
108109
/* Is there a name? */
109110
if (*ar->namewhat != '\0')
@@ -128,7 +129,7 @@ pushfuncname(lua_State *L, lua_Debug *ar) {
128129
/* Size of the second part of the stack. */
129130
#define LEVELS2 10
130131

131-
void
132+
NO_SANITIZE void
132133
luaL_traceback(lua_State *L, lua_State *L1,
133134
const char *msg, int level) {
134135
lua_Debug ar;

luzer/fuzzed_data_provider.cc

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ typedef struct {
3535
} lua_userdata_t;
3636

3737
/* Consumes a string from the fuzzer input. */
38-
static int
38+
NO_SANITIZE static int
3939
luaL_consume_string(lua_State *L)
4040
{
4141
lua_userdata_t *lfdp;
@@ -52,7 +52,7 @@ luaL_consume_string(lua_State *L)
5252
}
5353

5454
/* Consumes a table with specified number of strings from the fuzzer input. */
55-
static int
55+
NO_SANITIZE static int
5656
luaL_consume_strings(lua_State *L)
5757
{
5858
lua_userdata_t *lfdp;
@@ -78,7 +78,7 @@ luaL_consume_strings(lua_State *L)
7878
}
7979

8080
/* Consumes a boolean from the fuzzer input. */
81-
static int
81+
NO_SANITIZE static int
8282
luaL_consume_boolean(lua_State *L)
8383
{
8484
lua_userdata_t *lfdp;
@@ -93,7 +93,7 @@ luaL_consume_boolean(lua_State *L)
9393
}
9494

9595
/* Consumes a table with specified number of booleans from the fuzzer input. */
96-
static int
96+
NO_SANITIZE static int
9797
luaL_consume_booleans(lua_State *L)
9898
{
9999
lua_userdata_t *lfdp;
@@ -114,7 +114,7 @@ luaL_consume_booleans(lua_State *L)
114114
}
115115

116116
/* Consumes a float from the fuzzer input. */
117-
static int
117+
NO_SANITIZE static int
118118
luaL_consume_number(lua_State *L)
119119
{
120120
lua_userdata_t *lfdp;
@@ -133,7 +133,7 @@ luaL_consume_number(lua_State *L)
133133
}
134134

135135
/* Consumes a table with specified number of numbers from the fuzzer input. */
136-
static int
136+
NO_SANITIZE static int
137137
luaL_consume_numbers(lua_State *L)
138138
{
139139
lua_userdata_t *lfdp;
@@ -159,7 +159,7 @@ luaL_consume_numbers(lua_State *L)
159159

160160
/* Consumes an arbitrary int or an int between min and max from the fuzzer
161161
input. */
162-
static int
162+
NO_SANITIZE static int
163163
luaL_consume_integer(lua_State *L)
164164
{
165165
lua_userdata_t *lfdp;
@@ -178,7 +178,7 @@ luaL_consume_integer(lua_State *L)
178178
}
179179

180180
/* Consumes an int array from the fuzzer input. */
181-
static int
181+
NO_SANITIZE static int
182182
luaL_consume_integers(lua_State *L)
183183
{
184184
lua_userdata_t *lfdp;
@@ -202,7 +202,7 @@ luaL_consume_integers(lua_State *L)
202202
return 1;
203203
}
204204

205-
static int
205+
NO_SANITIZE static int
206206
luaL_consume_probability(lua_State *L)
207207
{
208208
lua_userdata_t *lfdp;
@@ -217,7 +217,7 @@ luaL_consume_probability(lua_State *L)
217217
}
218218

219219
/* Returns the number of unconsumed bytes in the fuzzer input. */
220-
static int
220+
NO_SANITIZE static int
221221
luaL_remaining_bytes(lua_State *L)
222222
{
223223
lua_userdata_t *lfdp;
@@ -231,15 +231,15 @@ luaL_remaining_bytes(lua_State *L)
231231
return 1;
232232
}
233233

234-
static int close(lua_State *L) {
234+
NO_SANITIZE static int close(lua_State *L) {
235235
lua_userdata_t *lfdp;
236236
lfdp = (lua_userdata_t *)luaL_checkudata(L, 1, FDP_LUA_UDATA_NAME);
237237
delete lfdp->fdp;
238238

239239
return 0;
240240
}
241241

242-
static int tostring(lua_State *L) {
242+
NO_SANITIZE static int tostring(lua_State *L) {
243243
lua_pushstring(L, "FuzzedDataProvider");
244244
return 1;
245245
}
@@ -280,7 +280,7 @@ fdp_metatable_init(lua_State *L)
280280
lua_pop(L, 1); /* Remove the metatable from the stack. */
281281
}
282282

283-
int
283+
NO_SANITIZE int
284284
luaL_fuzzed_data_provider(lua_State *L)
285285
{
286286
int index = lua_gettop(L);

luzer/luzer.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@
3434

3535
static lua_State *LL;
3636

37-
static void
37+
NO_SANITIZE static void
3838
set_global_lua_state(lua_State *L)
3939
{
4040
LL = L;
4141
}
4242

43-
lua_State *
43+
NO_SANITIZE lua_State *
4444
get_global_lua_state(void)
4545
{
4646
if (!LL) {
@@ -125,7 +125,7 @@ get_coverage_symbols_location(void) {
125125
return (dl_info.dli_fname);
126126
}
127127

128-
void
128+
NO_SANITIZE void
129129
init(void)
130130
{
131131
if (!&LLVMFuzzerRunDriver) {
@@ -144,7 +144,7 @@ init(void)
144144
}
145145
}
146146

147-
static void
147+
NO_SANITIZE static void
148148
sig_handler(int sig)
149149
{
150150
switch (sig) {
@@ -441,7 +441,8 @@ static const struct luaL_Reg Module[] = {
441441
{ NULL, NULL }
442442
};
443443

444-
int luaopen_luzer_impl(lua_State *L)
444+
NO_SANITIZE int
445+
luaopen_luzer_impl(lua_State *L)
445446
{
446447
init();
447448

luzer/tracer.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ _trace_branch(uint64_t idx)
4343
increment_counter(idx);
4444
}
4545

46-
static inline unsigned int lhash(const char *key, size_t offset)
46+
NO_SANITIZE static inline unsigned int
47+
lhash(const char *key, size_t offset)
4748
{
4849
const char *const last = &key[strlen(key) - 1];
4950
uint32_t h = LHASH_INIT;
@@ -63,7 +64,8 @@ static inline unsigned int lhash(const char *key, size_t offset)
6364
* https://github.com/lunarmodules/luacov/blob/master/src/luacov/runner.lua#L102-L117
6465
* https://github.com/lunarmodules/luacov/blob/78f3d5058c65f9712e6c50a0072ad8160db4d00e/src/luacov/runner.lua#L439-L450
6566
*/
66-
void debug_hook(lua_State *L, lua_Debug *ar)
67+
NO_SANITIZE void
68+
debug_hook(lua_State *L, lua_Debug *ar)
6769
{
6870
lua_getinfo(L, "Sln", ar);
6971
if (ar && ar->source && ar->currentline) {

luzer/version.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
const char *llvm_version_string(void) {
1+
#include "macros.h"
2+
3+
NO_SANITIZE const char *
4+
llvm_version_string(void) {
25
return "@LLVM_VERSION@";
36
}
47

5-
const char *luzer_version_string(void) {
8+
NO_SANITIZE const char *
9+
luzer_version_string(void) {
610
return "@CMAKE_PROJECT_VERSION@";
711
}

0 commit comments

Comments
 (0)