I have written a "Hello, World!" C file myCFile.c on an x86 embedded board on the Debian OS.
#include <stdio.h>
int main()
{
printf("hello\n")
}
I compile the program: gcc myCFile.c
However,
tester@localhost:~/test$ ./a.out
-bash: ./a.out: Permission denied
tester@localhost:~/pravin$ ls -lrt
total 44
-rwxrwxrwx 1 tester test 54 Sep 7 07:33 myCFile.c
-rwxrwxrwx 1 tester test 16608 Sep 7 07:33 a.out
However, if I copy a.out to /run/user/1000, I can execute it.
tester@localhost:/run/user/1000$ ls
a.out bus gnupg systemd
Also, I can execute it when I compile the C file with root user and execute it. I can execute it.
root@localhost:~# gcc myCFile.c
root@localhost:~# ./a.out
hello
root@localhost:~#
Is it something related to the NOEXEC flag?
My /etc/fstab file:
# Begin /etc/fstab
/dev/root / ext4 defaults 0 0 proc
/proc proc nosuid,noexec,nodev 0 0 sysfs /sys sysfs nosuid,noexec,nodev 0 0 devpts
/dev/pts devpts gid=5,mode=620 0 0 tmpfs
/run tmpfs defaults,size=1500M 0 0 devtmpfs
/dev devtmpfs mode=0755,nosuid 0 0
# End /etc/fstab
LABEL=persistent /persistent ext4 defaults,data=journal,noatime,nosuid,nodev,noexec 0 2
/persistent/home /home none defaults,bind 0 0
/persistent/tmp /tmp none defaults,bind 0 0