Page 1 of 1

An easy way to remove the noexec protection from partitions

Posted: Fri Nov 16, 2012 1:36 pm
by mamaich
To make our life harder, Samsung decided to make all custom mounts as noexec. So you can't run a file from USB. Here is a code from their sources:

Code: Select all

#ifdef CONFIG_MOUNT_SECURITY
/* 
 * Devices in this list will not be applied "noexec" option.
 * All device will be applied "noexec" option to protect system security
 * except some devices for system
 * */
char *allowedDEV[] = {"bml", "stl", "mmcblk", "dev/root",
		"proc", "rootfs", "sysfs", "tmpfs", "none", 
		"END" };
#endif
....
#ifdef CONFIG_MOUNT_SECURITY
	/* Apply MNT_NOEXEC option except some devices for system */
	numOfDev = sizeof(allowedDEV)/sizeof(allowedDEV[0]);
	
	for( i = 0 ; i < numOfDev  ; i++) {
		if(strstr(dev_name, allowedDEV[i]) != NULL)
			break;
	}
	
	if( i == numOfDev ) {
		mnt_flags |= MNT_NOEXEC;
	}
#endif
Looking at this source code - it is easy to overcome this protection. The code does the following: it checks that the device path contains a given string somewhere inside its name. So you can create your own device with mknode that contains, say, "bml" in its name - and this device would be mounted as executable.

Here is a working example, tested on my UE32ES6727:

Code: Select all

mknod /tmp/loopnone b 7 9
losetup /tmp/loopnone /dtv/usb/sda1/t-mst10pdeuc.xfs
mount -o sync,exec /tmp/loopnone /mnt
This example uses the "none" allowed device substring.

Re: An easy way to remove the noexec protection from partiti

Posted: Tue Nov 20, 2012 9:24 am
by arris69
mamaich wrote:To make our life harder, Samsung decided to make all custom mounts as noexec. So you can't run a file from USB. Here is a code from their sources:
....
Here is a working example, tested on my UE32ES6727:

Code: Select all

mknod /tmp/loopnone b 7 9
losetup /tmp/loopnone /dtv/usb/sda1/t-mst10pdeuc.xfs
mount -o sync,exec /tmp/loopnone /mnt
This example uses the "none" allowed device substring.
nice :-)

Re: An easy way to remove the noexec protection from partiti

Posted: Fri Nov 30, 2012 3:14 am
by E3V3A
Is that a permanent fix or does it re-enable noexec, after reboot?

Re: An easy way to remove the noexec protection from partiti

Posted: Fri Nov 30, 2012 8:05 am
by juusso
as you see, the es series hack is not permanent, so all changes you ever make on tmpfs will be valid only until you reboot TV.