~ubuntu-branches/debian/sid/trinity/sid

« back to all changes in this revision

Viewing changes to syscalls/mprotect.c

  • Committer: Package Import Robot
  • Author(s): gustavo panizzo
  • Date: 2014-01-17 21:10:15 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20140117211015-k2qbnpu0osa5mlil
Tags: 1.3-1
* New upstream version 1.3.
* Removed wrong dependency on linux-headers. (Closes: #733771).

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * sys_mprotect(unsigned long start, size_t len, unsigned long prot)
3
3
 */
4
4
#include <asm/mman.h>
5
 
#include "trinity.h"    // page_size
 
5
#include "utils.h"      // page_size
6
6
#include "arch.h"
 
7
#include "maps.h"
7
8
#include "random.h"
8
9
#include "sanitise.h"
9
10
#include "shm.h"
10
11
 
11
12
static void sanitise_mprotect(int childno)
12
13
{
13
 
        unsigned long end;
14
 
 
15
 
        shm->a1[childno] &= PAGE_MASK;
16
 
 
17
 
retry_end:
18
 
        end = shm->a1[childno] + shm->a2[childno];
19
 
        /* Length must not be zero. */
20
 
        if (shm->a2[childno] == 0) {
21
 
                shm->a2[childno] = rand64();
22
 
                goto retry_end;
23
 
        }
24
 
 
25
 
        /* End must be after start */
26
 
        if (end <= shm->a1[childno]) {
27
 
                shm->a2[childno] = rand64();
28
 
                goto retry_end;
29
 
        }
 
14
        (void) common_set_mmap_ptr_len(childno);
 
15
}
 
16
 
 
17
/*
 
18
 * If we successfully did an mprotect, update our record of the mappings prot bits.
 
19
 */
 
20
static void post_mprotect(int childno)
 
21
{
 
22
        struct map *map = (struct map *) shm->scratch[childno];
 
23
 
 
24
        if (shm->retval[childno] != 0)
 
25
                map->prot = shm->a3[childno];
30
26
}
31
27
 
32
28
struct syscall syscall_mprotect = {
33
29
        .name = "mprotect",
34
30
        .num_args = 3,
35
31
        .arg1name = "start",
36
 
        .arg1type = ARG_ADDRESS,
 
32
        .arg1type = ARG_MMAP,
37
33
        .arg2name = "len",
38
 
        .arg2type = ARG_LEN,
39
34
        .arg3name = "prot",
40
35
        .arg3type = ARG_LIST,
41
36
        .arg3list = {
44
39
        },
45
40
        .sanitise = sanitise_mprotect,
46
41
        .group = GROUP_VM,
47
 
 
48
 
        .flags = AVOID_SYSCALL, // hopefully temporary.
 
42
        .post = post_mprotect,
49
43
};