Last active
March 1, 2023 09:05
-
-
Save BigNerd95/0be0a5b52a16524a78fc768f0d208a74 to your computer and use it in GitHub Desktop.
Atheros Country Code ART bypass passing a custom Country Name when loading the driver (e.g.: insmod ath cn=AU)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
char *user_country_name = ""; // [MOD] | |
module_param_named(cn, user_country_name, charp, S_IRUGO); // [MOD] | |
MODULE_PARM_DESC(cn, "Country Name"); // [MOD] | |
static int __ath_regd_init(struct ath_regulatory *reg) | |
{ | |
struct country_code_to_enum_rd *country = NULL; | |
u16 regdmn; | |
if (!reg) | |
return -EINVAL; | |
ath_regd_sanitize(reg); | |
printk(KERN_DEBUG "ath: EEPROM regdomain: 0x%0x\n", reg->current_rd); | |
if (!ath_regd_is_eeprom_valid(reg)) { | |
pr_err("Invalid EEPROM contents\n"); | |
return -EINVAL; | |
} | |
regdmn = ath_regd_get_eepromRD(reg); | |
reg->country_code = ath_regd_find_country_by_name(user_country_name); // [MOD] | |
if (reg->country_code != (u16) -1) // [MOD] | |
printk(KERN_DEBUG "ath: User Override Country Code\n"); // [MOD] | |
else // [MOD] | |
reg->country_code = ath_regd_get_default_country(regdmn); | |
if (reg->country_code == CTRY_DEFAULT && | |
regdmn == CTRY_DEFAULT) { | |
printk(KERN_DEBUG "ath: EEPROM indicates default " | |
"country code should be used\n"); | |
reg->country_code = CTRY_UNITED_STATES; | |
} | |
// [...] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
LEDE instruction:
Clone LEDE project
git clone https://github.com/lede-project/source.git
cd source
Build for your target
make menuconfig
(select your target)make package/kernel/mac80211/compile
Patch the driver with my diff
You have to edit
__ath_regd_init
function in this file:build_dir/target-[ARCH]/linux-ar71xx_generic/backports-[VER]/drivers/net/wireless/ath/regd.c
(Add lines with // [MOD] comment)
Build and flash the firmware
Build the firmware
make -j9
(Where 9 is your cpu's threads number + 1)
Then flash the router
On PC:
nc -l -p 1234 -q 0 < bin/targets/ar71xx/generic/lede-ar71xx-generic-[MODEL]-squashfs-sysupgrade.bin
On router:
nc 192.168.1.X 1234 > /tmp/fw.bin && sysupgrade /tmp/fw.bin
Add driver parameter
After the router reboot, create the file /etc/modules.d/ath
echo "ath cn=AU" > /etc/modules.d/ath
So when LEDE starts up, the ath module will be loaded with cn (Country Name) parameter.
Check the Mod
reboot
the router and check log messages:dmesg | grep ath
You should see
ath: EEPROM regdomain: 0x0 ath: User Override Country Code ath: doing EEPROM country->regdmn map search ath: country maps to regdmn code: 0x21 ath: Country alpha2 being used: AU ath: Regpair used: 0x21
You can check the reg domain
iw reg get
and you should see