Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
zipr_callbacks
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Open Source Software
zipr_callbacks
Commits
3ade181f
Commit
3ade181f
authored
9 years ago
by
whh8b
Browse files
Options
Downloads
Patches
Plain Diff
Initial checkin of dynamic hook callbacks.
parent
fe2be2f0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitattributes
+2
-0
2 additions, 0 deletions
.gitattributes
hookdynamic/Makefile.in
+28
-0
28 additions, 0 deletions
hookdynamic/Makefile.in
hookdynamic/hook_dynamic_callbacks.c
+113
-0
113 additions, 0 deletions
hookdynamic/hook_dynamic_callbacks.c
with
143 additions
and
0 deletions
.gitattributes
+
2
−
0
View file @
3ade181f
...
...
@@ -10,6 +10,8 @@ canaries/debug_canary_callbacks.c -text
/configure_for_rss -text
example/Makefile.in -text
example/callback.c -text
hookdynamic/Makefile.in -text
hookdynamic/hook_dynamic_callbacks.c -text
inferfn/Makefile.in -text
inferfn/infer.c -text
inferfn/infer.h -text
...
...
This diff is collapsed.
Click to expand it.
hookdynamic/Makefile.in
0 → 100644
+
28
−
0
View file @
3ade181f
CC
=
@CC@
CFLAGS
=
@CFLAGS@
LIB
=
@LIB@
AR
=
@AR@
AS
=
@AS@
ASFLAGS
=
@ASFLAGS@
OBJS
=
hook_dynamic_callbacks.o
.SUFFIXES
:
.o .s .c
.c.o
:
$(
CC
)
$(
CFLAGS
)
$(
INCLUDE
)
-D__
$(
ARCH
)
-c
$<
.s.o
:
$(
AS
)
$(
ASFLAGS
)
$<
all
:
$(OBJS)
$(
AR
)
-r
$(
LIB
)
$(
OBJS
)
clean
:
rm
*
.o
This diff is collapsed.
Click to expand it.
hookdynamic/hook_dynamic_callbacks.c
0 → 100644
+
113
−
0
View file @
3ade181f
/*
* Copyright (c) 2014 - Zephyr Software LLC
*
* This file may be used and modified for non-commercial purposes as long as
* all copyright, permission, and nonwarranty notices are preserved.
* Redistribution is prohibited without prior written consent from Zephyr
* Software.
*
* Please contact the authors for restrictions applying to commercial use.
*
* THIS SOURCE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* Author: Zephyr Software
* e-mail: jwd@zephyr-software.com
* URL : http://www.zephyr-software.com/
*
*/
#ifdef DEBUG
#include
"malloc.h"
#include
"itox.h"
#include
"strlen.h"
#include
"null.h"
#define DEBUG_ADD
#else
typedef
unsigned
uintptr_t
;
#define NULL 0L
#endif
#ifdef DEBUG
#define print_str_debug print_str
#define print_int_debug print_int
#else
#define print_str_debug(a)
#define print_int_debug(a)
#define assert(a)
#endif
#ifdef DEBUG
#define write_fd 2
void
print_str
(
char
*
s
)
{
write
(
write_fd
,
s
,
strlen
(
s
));
}
void
print_int
(
int
x
)
{
char
buf
[
100
];
itox
(
x
,
buf
);
write
(
write_fd
,
buf
,
strlen
(
buf
));
}
#endif
unsigned
long
long
read_random64
(
void
)
{
unsigned
long
long
random_value
=
-
1
;
int
fd
=
-
1
;
fd
=
open
(
"/dev/urandom"
,
0x00
);
if
(
fd
!=
-
1
)
{
read
(
fd
,
(
void
*
)
&
random_value
,
sizeof
(
unsigned
long
long
));
close
(
fd
);
}
return
random_value
;
}
unsigned
long
read_random32
(
void
)
{
unsigned
long
random_value
=
-
1
;
int
fd
=
-
1
;
fd
=
open
(
"/dev/urandom"
,
0x00
);
if
(
fd
!=
-
1
)
{
read
(
fd
,
(
void
*
)
&
random_value
,
sizeof
(
unsigned
long
));
close
(
fd
);
}
return
random_value
;
}
void
set_canary64
(
unsigned
long
long
new_canary
)
{
asm
volatile
(
"mov %0, %%fs:0x28
\n
"
:
:
"r"
(
new_canary
)
:
);
}
void
set_canary32
(
unsigned
long
new_canary
)
{
asm
volatile
(
"mov %0, %%fs:0x28
\n
"
:
:
"r"
(
new_canary
)
:
);
}
/*
*/
#define FORK 57
void
zipr_hook_dynamic_callback
(
unsigned
int
id
,
unsigned
int
rax
)
{
#ifdef DEBUG
print_str_debug
(
"In zipr_hook_dynamic_callback, id="
);
print_int_debug
(
id
);
print_str_debug
(
", rax="
);
print_int_debug
(
rax
);
print_str_debug
(
"
\n
"
);
#endif
if
(
id
==
FORK
&&
rax
!=
0
)
{
/*
* Child!
*/
set_canary32
(
read_random32
());
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment