[MOD] Disable system write protection on stock kernel

Search This thread

flar2

Recognized Developer
Jun 11, 2012
18,780
87,749
Southwestern Ontario
elementalx.org
This module will disable system write protection on the stock HTC One kernel.


To make /system writeable, you must install the module and then remount /system as rw.

For example:

insmod /system/lib/modules/wp_mod.ko
mount -o remount,rw /system


You can make an init.d script to load it, or add it to the boot.img. Either way will work, but it's important that this is loaded at boot, as attempting to make changes to /system and then installing this module could corrupt the partition.


This is mainly for devs, who are free to incorporate it into their ROMs.
Unless you are an advanced user, I would wait for it to be included in your favourite ROM.


A credit and a link here so people can thank me in the OP would be much appreciated ;)


Download:
wp_mod.ko


Source code: wp_mod.c
 
Last edited:

Isotopes

Senior Member
Aug 3, 2007
523
230
wp_mod.ko for 3.4.10-gddcfb8c kernel version

wow ... new version from this mod ... thx :highfive:

ok ... installed wp_mod.ko to system/lib/modules ... make a new boot.img ... restart ... modified a file in system ... restart ... but changed file back original

ok ... next try ... i found the mod is kernel depends ... hexedit the mod to my kernel version ... installed ... modified a file ... restart ... and it works now, the file is well modified

thx @flar2

attached my modified wp_mod.ko only for 3.4.10-gddcfb8c kernel-version

use the attached with cwm-recovery, its only the modified wp_mod.ko file
 
Last edited:

flar2

Recognized Developer
Jun 11, 2012
18,780
87,749
Southwestern Ontario
elementalx.org
The module should be placed somewhere on your /system partition, because that is what is mounted early in the boot process.

Kernel modules are usually located in /system/lib/modules/ but you can put it anywhere on /system

Then you can load it with an init script using the commands I posted above. Or you can put those commands in init.rc in the boot.img. Obviously the command has to be modified to reflect the location where you copied wp_mod.ko

You have to make sure that the boot.img is set to run init.d scripts, this is also done in init.rc.
 
  • Like
Reactions: kevin mitnick

flar2

Recognized Developer
Jun 11, 2012
18,780
87,749
Southwestern Ontario
elementalx.org
wow ... new version from this mod ... thx :highfive:

ok ... installed wp_mod.ko to system/lib/modules ... make a new boot.img ... restart ... modified a file in system ... restart ... but changed file back original

ok ... next try ... i found the mod is kernel depends ... hexedit the mod to my kernel version ... installed ... modified a file ... restart ... and it works now, the file is well modified

Yes, it will only load if the version info matches.


If people don't know what that means, check your kernel:

uname -a

And make sure the module has the same string:

modinfo wp_mod.ko

You can change it with a hex editor as above, make sure you only change the characters of the version string and nothing else.
 
Last edited:
  • Like
Reactions: kevin mitnick

nikotine81

Senior Member
Sep 14, 2012
74
18

Attachments

  • Screenshot_2013-04-11-20-37-03.jpg
    Screenshot_2013-04-11-20-37-03.jpg
    19.1 KB · Views: 3,742

Riyal

Senior Member
Dec 16, 2011
3,038
1,769
Iloilo City
Hi! Just wanted to add additional info. Since the kernel source is out now you could also disable write protection by changing the line in

arch/arm/configs/m7_defconfig

from
CONFIG_MMC_MUST_PREVENT_WP_VIOLATION=y
to
# CONFIG_MMC_MUST_PREVENT_WP_VIOLATION is not set


referencing file

arch/arm/mach-msm/emmc_partitions.c

code
Code:
#ifdef CONFIG_MMC_MUST_PREVENT_WP_VIOLATION
		if (!strncmp(ptn->name, "system", 6))
			mmc_blk_set_wp_prevention_partno((int) ptn->offset);
#endif

on

Code:
void mmc_blk_set_wp_prevention_partno(int partno)
{
	sprintf(wp_prevention_partno, "mmcblk0p%d", partno);
	pr_info("%s: set wp_prevention_partno to %s\n", __func__, wp_prevention_partno);
}
EXPORT_SYMBOL(mmc_blk_set_wp_prevention_partno);

from

drivers/mmc/card/block.c
 
  • Like
Reactions: joeykrim and flar2

flar2

Recognized Developer
Jun 11, 2012
18,780
87,749
Southwestern Ontario
elementalx.org
Hi! Just wanted to add additional info. Since the kernel source is out now you could also disable write protection by changing the line in



from

to



referencing file



code
Code:
#ifdef CONFIG_MMC_MUST_PREVENT_WP_VIOLATION
		if (!strncmp(ptn->name, "system", 6))
			mmc_blk_set_wp_prevention_partno((int) ptn->offset);
#endif

on

Code:
void mmc_blk_set_wp_prevention_partno(int partno)
{
	sprintf(wp_prevention_partno, "mmcblk0p%d", partno);
	pr_info("%s: set wp_prevention_partno to %s\n", __func__, wp_prevention_partno);
}
EXPORT_SYMBOL(mmc_blk_set_wp_prevention_partno);

from

Thank you, I discovered this months ago: http://forum.xda-developers.com/showthread.php?t=2059411. The reason for disabling it via a module is so people can continue to use the stock kernel. There are already custom kernels for this phone, but not everyone wants a custom kernel.
 
  • Like
Reactions: Isotopes and Riyal

Nekromantik

Senior Member
Apr 1, 2010
6,723
931
London
Google Pixel 6 Pro
Thank you, I discovered this months ago: http://forum.xda-developers.com/showthread.php?t=2059411. The reason for disabling it via a module is so people can continue to use the stock kernel. There are already custom kernels for this phone, but not everyone wants a custom kernel.

Only custom kernel is one from you at the moment.
Have to wait for more devs now.

The base version for the source code seems to be a older base, does that make a difference?
 

flar2

Recognized Developer
Jun 11, 2012
18,780
87,749
Southwestern Ontario
elementalx.org
If you're feeling adventurous here's a kernel to try:

http://goo.im/devs/flar2/One/Bulletproof-m7-0.1.zip


I don't have this device, so I couldn't test it. It might not work.

If the installer doesn't work, take the boot.img out of the zip and flash it in fastboot.

If the kernel won't boot, please send me /proc/last_kmsg. I might have to make some adjustments to the boot.img.

Don't install this unless you want to help me out with log files, etc.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 70
    This module will disable system write protection on the stock HTC One kernel.


    To make /system writeable, you must install the module and then remount /system as rw.

    For example:

    insmod /system/lib/modules/wp_mod.ko
    mount -o remount,rw /system


    You can make an init.d script to load it, or add it to the boot.img. Either way will work, but it's important that this is loaded at boot, as attempting to make changes to /system and then installing this module could corrupt the partition.


    This is mainly for devs, who are free to incorporate it into their ROMs.
    Unless you are an advanced user, I would wait for it to be included in your favourite ROM.


    A credit and a link here so people can thank me in the OP would be much appreciated ;)


    Download:
    wp_mod.ko


    Source code: wp_mod.c
    13
    Here is the defeat system write protection module for Sense 5 Android 4.3:


    wp_mod.ko







    .
    6
    wp_mod.ko for 3.4.10-gddcfb8c kernel version

    wow ... new version from this mod ... thx :highfive:

    ok ... installed wp_mod.ko to system/lib/modules ... make a new boot.img ... restart ... modified a file in system ... restart ... but changed file back original

    ok ... next try ... i found the mod is kernel depends ... hexedit the mod to my kernel version ... installed ... modified a file ... restart ... and it works now, the file is well modified

    thx @flar2

    attached my modified wp_mod.ko only for 3.4.10-gddcfb8c kernel-version

    use the attached with cwm-recovery, its only the modified wp_mod.ko file
    5
    wp_3.4.10-gfa33c1e 3.62.401.1 base ---------> https://www.dropbox.com/s/2h54p2qh36my8jp/wp_3.4.10_gfa33c1e.zip

    Verified working. This is my everything use zip ignore the kernel install error. It means nothing,l.
    5
    wp_mod.ko for 3.4.10-g87f8d97 kernel version

    Really good job can you do the same file for the kernel? Thanks in advance

    and now, here the wp_mod.ko for 3.4.10-g87f8d97 kernel version

    use the attached with cwm-recovery, its only the modified wp_mod.ko file