# Cannot make segment writable for relocation error

**URL:** <https://linux-tips.com/t/cannot-make-segment-writable-for-relocation-error/481>\
**Category:** Shell\
**Created:** [February 23, 2017, 3:44pm UTC](https://linux-tips.com/t/cannot-make-segment-writable-for-relocation-error/481 "2017-02-23T15:44:05Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![demirten](https://linux-tips.com/user_avatar/linux-tips.com/demirten/32/64_2.png) [@demirten](https://linux-tips.com/u/demirten)\
**Post date:** [February 23, 2017, 3:57pm UTC](https://linux-tips.com/t/cannot-make-segment-writable-for-relocation-error/481/2 "2017-02-23T15:57:38Z")

</div>

It seems that you’re trying to run a program with grsecurity patched kernel (see [https://grsecurity.net/](https://grsecurity.net/))

In order to solve this problem you must disable MPROTECT PaX flags on the binary (/usr/bin/java here)

> The goal of MPROTECT is to help prevent the introduction of new executable code into the task’s address space. This is accomplished by restricting the mmap() and mprotect() interfaces.

The restrictions prevent

- creating executable anonymous mappings
- creating executable/writable file mappings
- making an executable/read-only file mapping writable except for performing relocations on an ET\_DYN ELF file (non-PIC shared library)
- making a non-executable mapping executable

See more on: [https://pax.grsecurity.net/docs/mprotect.txt](https://pax.grsecurity.net/docs/mprotect.txt)

Run following command to disable mprotect:

```auto
$ sudo paxctl -m /usr/bin/java

```

If you’re getting an error like `file java does not have a PT_PAX_FLAGS program header, try conversion`, you should convert PT\_GNU\_STACK into PT\_PAX\_FLAGS with::

```auto
$ sudo paxctl -c /usr/bin/java

```

After a successfull convert, you can should run previous command again. To check whether flags are added or not you can use **-v** option:

```auto
$ sudo paxctl -v /usr/bin/java
PaX control v0.7
Copyright 2004,2005,2006,2007,2009,2010,2011,2012 PaX Team <pageexec@freemail.hu>

- PaX flags: -----m-x-e-- [java]
	MPROTECT is disabled
	RANDEXEC is disabled
	EMUTRAMP is disabled

```

---

_[View the full topic](https://linux-tips.com/t/cannot-make-segment-writable-for-relocation-error/481)._
