Python ctypes segmentation fault when rootfs is read-only and /tmp is noexec -


i'm trying use python embedded app on arm processor running linux (cpython 2.7.3 cross-compiled x86/linux). worked until started securing device prevent tampering. first made rootfs read-only, both prevent corruption of rootfs on sudden loss of power , prevent modification our main code unauthorized users. still, python , our ctypes libraries continued working normal. /tmp directory gets mapped tmpfs (ramdrive). step of hardening set noexec flag on tmpfs partition prevent users somehow uploading code lead local root exploit. both of options set, importing ctypes produces immediate segfault:

root@atx4:~# python                                  python 2.7.3 (default, jul 16 2013, 17:15:57)  [gcc 4.3.3] on linux2 type "help", "copyright", "credits" or "license" more information. >>> import ctypes segmentation fault 

interestingly enough, of changes below allows ctypes work correctly:

  1. remounting rootfs read-write
  2. remounting tmpfs without noexec
  3. remounting /dev/shm without noexec

any idea what's causing this? now, i've made /dev/shm mount without noexec, , restrict least possible users.

i cannot reproduce python 2.7.6;

i suspect could've been valid bug.

consider ctypes may need create unique callback (an executable c-level function). mmap anonymous (ok) or shared file (not ok) execute bit set.

memory error handling hard, , have escaped developers.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -