Monday, December 17, 2012

Hex-editing Linux kernel modules to support new hardware

This is an old trick but a fun one. The ThinkPad X1 Carbon has no built-in Ethernet port. Instead it comes with a USB to Ethernet adapter. The adapter uses the ASIX AX88772 chip, which Linux has supported since time immemorial. But support for the particular adapter shipped by Lenovo was only added in Linux 3.7.

This was a problem for me, since I wanted to use a Debian installer with a 3.2 kernel. I could set up a build environment for that particular kernel and recompile the module. But this seemed like an annoying yak to shave when I just wanted to get the machine working.

The patch to support the Lenovo adapter just adds a new USB device ID to an existing driver:

 }, {
+       // Lenovo U2L100P 10/100
+       USB_DEVICE (0x17ef, 0x7203),
+       .driver_info = (unsigned long) &ax88772_info,
+}, {
        // ASIX AX88772B 10/100
        USB_DEVICE (0x0b95, 0x772b),
        .driver_info = (unsigned long) &ax88772_info,

As a quick-and-dirty solution, we can edit the compiled kernel module asix.ko, changing that existing device ID (0x0b95, 0x772b) to the Lenovo one (0x17ef, 0x7203). Since x86 CPUs are little-endian, this involves changing the bytes

95 0b 2b 77

to

ef 17 03 72

I wanted to do this within the Debian installer without rebooting. Busybox sed does not support hex escapes, but printf does:

sed $(printf 's/\x95\x0b\x2b\x77/\xef\x17\x03\x72/') \
    /lib/modules/$(uname -r)/kernel/drivers/net/usb/asix.ko \
    > /tmp/asix.ko

(It's worth checking that none of those bytes have untoward meanings as ASCII characters in a regular expression. As it happens, sed does not recognize + (aka \x2b) as repetition unless preceded by a backslash.)

Then I loaded the patched module along with its dependencies. A simple way is

modprobe asix
rmmod asix
insmod /tmp/asix.ko

And that was enough for me to complete the install over Ethernet. Of course, once everything is set up, it would be better to compile a properly-patched kernel using make-kpkg. I haven't got around to it yet because wireless is working great. :)

72 comments:

  1. I followed the instructions but running into some problems. I did verify I have the proper vendor and product id as the article suggests.

    Get the following

    insmod: error inserting './asix.ko': -1 Unknown symbol in module.

    Any ideas?

    ReplyDelete
  2. This is so great. It's so old school that nobody would think about it anymore. I just tried it and it's great, thanks.

    ReplyDelete
  3. Funny. Did this not too long ago with a NetBSD kernel image. I knew it supported the hardware for a network card I had, it just wasn't compiled with the correct vendor+product ID. So I wrote some simple C code to scan the NetBSD kernel image and find a set of bytes where a similar (but not exact) network vendor+product ID was hard coded and then overwrite them. It worked of course and was very amusing!

    ReplyDelete
  4. Nice article, thanks for the information. It's very complete information. I will bookmark for next reference
    jaring futsal | jaring golf | jaring pengaman proyek |
    jaring pengaman bangunan | jaring pengaman gedung
    http://www.jual-jaring.blogspot.com/
    http://www.agen-jaring.blogspot.com/
    http://www.pancasamudera-safetynet.blogspot.com/
    http://www.toko-jaring.blogspot.com/
    http://www.pusat-jaring.blogspot.com/
    http://jualjaringpengaman.blogspot.com/
    https://pancasamudera.wordpress.com/
    https://pasangjaringfutsal.wordpress.com/
    https://jualtambangmurah.wordpress.com/
    https://tokojaring.wordpress.com/
    https://jualjaringfutsal.wordpress.com/
    https://jaringfutsal.wordpress.com/


    ReplyDelete
  5. Nice Post, Thanks for your very useful information...

    ReplyDelete
  6. Your blog has given me that thing which I never expect to get from all over the websites. Nice post guys!

    Melbourne Web Developer

    ReplyDelete

  7. Thank you for sharing in this article
    I can learn a lot and could also be a reference
    I am happy to find your website and can join to comment

    Share and Klick Info Blokwalking. Hammer Of Thor
    => Jual Hammer Of Thor Di Bogor
    => Jual Hammer Of Thor Di Medan
    => Jual Hammer Of Thor Di Semarang
    => Jual Hammer Of Thor Di Bandung
    => Jual Hammer Of Thor Di Bandar Lampung
    Obat Good Man | Obat pembesar penis | Vimax Asli | Vimax Extender


    ReplyDelete
  8. Thedigiexperts is Delhi's leading digital marketing institute with over 10 branches all over Delhi, Covers all the main topics such as how to run instagram ads and facebook ads, with Affordable prices.

    ReplyDelete
  9. Thanks for posting this info., putlocker its is very helpful for all of us.keep update with your blogs.

    ReplyDelete
  10. https://crackedversion.com/
    A person who feels appreciated will always do more than what is expected.

    ReplyDelete
  11. usecracked.com
    If Oscars were given for a job well done, I’d nominate you! Congratulations for your fantastic achievement!

    ReplyDelete
  12. starpluskey.com
    The highest reward for man’s toil is not what he gets for it, but what he becomes by it.

    ReplyDelete
  13. Not a single effort of yours will go in vain. You will be rewarded for your pain. Your hard work will bring you a lot of gain.
    mlicensekey.com

    ReplyDelete
  14. Talent means nothing, while experience, acquired in humility and with hard work, means everything.
    iamactivationcode.com

    ReplyDelete

  15. Doing a good job is not always about impressive innovation. Sometimes it is only about doing something with plain dedication. Well done.
    hmzapc.com

    ReplyDelete
  16. Your hard work and effort have paid off!
    faisalpc.comA success well deserved, an occasion worth celebrating! Congratulations!

    ReplyDelete
  17. Even the smallest of jobs well done will take you one step closer towards crackpluskey.comthe success that you have always dreamed about. Keep it up.

    ReplyDelete
  18. Your work speaks volumes of the kind of man you are crackchkey.com– efficient, organized and result-oriented.

    ReplyDelete
  19. Opportunity comes to those who quit Waiting and start Looking. Success comes to those who quit Thinking and start Doing. chserialnumber.com
    Congratulations for Looking and Doing.

    ReplyDelete
  20. https://chactivekey.com/
    A lot of people failed at what you accomplished, simply because they were busy finding problems while you were busy finding solutions. Well done.

    ReplyDelete
  21. https://cracksray.com/acronis-true-image-crack/

    Acronis True Image engines got the user cover from every aspect of data storage and data protection.

    ReplyDelete
  22. https://lpcrack.com/flixgrab-crack/

    FlixGrab permits downloading the things specifically or in clustered form without making any trouble.

    ReplyDelete
  23. https://zsactivatorskey.com/apowersoft-video-editor-crack/

    Apowersoft Video Editor is the best to edit the videos online. Users can launch this in the system or can download it.

    ReplyDelete
  24. https://cskeygen.com/aomei-partition-assistant-crack/

    AOMEI Partition Assistant is such a good and efficient software for managing disk-related issues like storage, partitioning, and much more.

    ReplyDelete
  25. https://cracksad.com/advanced-systemcare-pro-crack/

    Advanced SystemCare Pro can easily access the systematic progress of your device and even make changes to the different operations on your own.

    ReplyDelete
  26. https://icrackedpc.com/avast-secureline-vpn-crack/

    Avast Secureline VPN provides real privacy and provides unlimited online content access. The connection is secure at a super-fast rate.

    ReplyDelete
  27. https://crackdad.com/express-vpn-crack/

    Express VPN is the best software that provides protection and security to any social media, audio, and video belonging to any location of the world.

    ReplyDelete
  28. https://zayanpc.com/proxifier-crack/

    Proxifier in the chain can be enabled or disabled. This basically helps you to operate any network application which does not support working via proxy servers.

    ReplyDelete
  29. This post is really amazing thanks for sharing
    Online Loan

    ReplyDelete
  30. This post is amazing you can also look to Short term loan for the financial need

    ReplyDelete
  31. Nice work is done by admin here. I lvoe the way are you working here.
    crackprovst
    crackmacvst
    crackprime

    ReplyDelete
  32. Thanks for information and keep updating us with valuable content and if possible provide us with

    jibjab alternative|similar to hautelook|lola Iolani Momoa|Sydney Brooke Simpson|


    ReplyDelete
  33. AP 1st, 2nd, 3rd, 4th, 5th Syllabus 2021 Candidates who are Searching for AP 1st, 2nd, 3rd, 4th, 5th Syllabussyllabus, sample questions, exam pattern, and Co-Curricular Subject textbooks can refer to this entire article. APSCERT 1st Class Revised Syllabus Here, we have gathered all subjects Andhra Pradesh Board textbooks for Class 5 students along with the direct download links

    ReplyDelete
  34. This is very educational content and written well for a change. It's nice to see that some people still understand how to write a quality post!
    nordvpn crack

    ReplyDelete
  35. Great Article it its really informative and innovative keep us posted with new updates. its was really valuable. thanks a lot.
    reg organizer crack

    ReplyDelete
  36. naturalreader Crack
    I really enjoy reading and also appreciate your work.

    ReplyDelete
  37. Hi buddies, it is great written piece entirely defined, continue the good work constantly.manga reviews

    ReplyDelete
  38. this is really nice to read..informative post is very good to read..thanks a lot!
    Hey, great blog, but I don’t understand how to add your site in my rss reader. Can you Help me please?
    Best tablet for typing

    ReplyDelete
  39. صباغ الكويت افضل خدمة يحتاجها اهل الكويت فى الوقت الحالي حيث انه من النادر ان تجد صباغ بالكويت محترف ولكن اليوم فى موقع صباغ الكويت سوف تجد افضل صباغين وافضل ديكورات الكويت على احدث صيحه لعام 2021 مثل ورق جدران مودرن بالكويت  ويوجد لدينا تركيب باركية خشب بالكويت ومع ارتفاع الاسعار يمكنك ايضا تركيب بديل الرخام بالكويت وهناك موديلات جديده مثلا استيل الكويت  ناتي الى افضل صباغين بالكويت هنالك جنسيات مختلفة مثل صباغ مصري و صباغ باكستاني وايضا هنالك صباغ هندي جميع الصباغين على اعلى مستوى وبالاخص صباغ عراقي  ونقوم بتقديم الخدمات فى جميع مناطق الكويت مثل صباغ الجهراء  و صباغ مبارك الكبير  و صباغ حولي  و صباغ الفروانية بالاضافة الى صباغ العاصمة  و صباغ الاحمدي  جميع تلك الخدمات نقدمها بالاضافة الى صباغ وايضا صباغ بالكويت بالاضافة الى ارخص صباغ و اشطر صباغ و افضل صباغ ولدينا معلم صباغ يوجد لدينا افضل صباغ بالكويت

    ReplyDelete
  40. Hi, I log on to your new stuff like every week. Your humoristic style is witty, keep it up
    dvdfab crack

    ReplyDelete
  41. its been long since i saw a post that's so educative and informational. i will make sure to share this my facebook group. you can also view contents on our websites below.

    French Bulldog Puppies For Sale

    French Bulldog Breeders

    French Bulldog Puppies For Sale Near Me

    French Bulldog Puppies For adoption

    French Bulldog Puppies


    Blue French Bulldog Puppies

    ReplyDelete
  42. it's so refreshing to see a post that talks straight to the point. thanks so much for writing about this it has really helped me with building my experience. thanks a lot



    siberian husky puppies for sale near me
    Siberian Husky puppies
    Siberian Husky puppies for adoption
      Siberian Husky puppies breeders near me  

      white Siberian Husky puppies  

    ReplyDelete
  43. صباغ الكويت .. هل تبي صباغ شاطر ورخيص بالكويت ؟ هل تريد فني تركيب ورق جدران أو معلم جبس بورد أو تركيب باركيه؟ لا داعي للبحث كثيرا، نحن نوفر لك أفضل الفنيين في الكويت، خدمات صباغة و تركيب ورق جدران وباركيه وجبس بورد علي أعلي مستوي من الحرفية والمهارة، من خلال فنيين متميزين ومدربين، قادرين على تنفيذ أي تصميم يخطر ببالك، لدينا تصميمات بأفكار لا تنتهي، ديكورات مودرن عالمية.

    لدينا أفضل صباغين بالكويت، جنسيات مختلفة، صباغ شاطر ورخيص، نوفر خدمة مميزة جدا بأقل الأسعار, يتميز الفنييون لدينا بالمهارة العالية والسرعة فى التنفيذ، لأننا نحرص على وقتك ونعرف قيمته، وأيضا نهتم جدا بأدق التفاصيل ولا نترك اي ثغرة فى عملنا، كل عمل نقوم به هو لوحة فنية نفتخر بضمها الي سجل أعمالنا.

    ReplyDelete
  44. This does not work since Linux checks the ELF file integrity:
    root@m1:~# modprobe sky2
    modprobe: ERROR: could not insert 'sky2': Key was rejected by service
    root@m1:~# modprobe --force-vermagic sky2
    modprobe: ERROR: could not insert 'sky2': Exec format error

    ReplyDelete
  45. I like viewing web sites which comprehend the price of delivering the excellent useful resource free of charge. I truly adored reading your posting. Thank you!
    best tablet for skype

    ReplyDelete
  46. Always so interesting to visit your site.What a great info, thank you for sharing. this will help me so much in my learning
    Kareena kapoor bra size

    ReplyDelete
  47. This post is very helpful and thanks to share with us.
    To Install AOL Desktop Gold, you can follow the steps provided on the web page or blogs of AOL Email Supports. If you still can’t Download AOL Desktop Gold, you can contact AOL customer service at any time. After you complete the download process, you can restart your computer and check AOL Desktop Gold is working or not. In case you encounter an installation error or software glitch, you can call the AOL Email Supports Toll-Free Number and ask for additional assistance.

    ReplyDelete
  48. I read your post. I appreciate your efforts. Thanks for sharing with us. Keep sharing again.
    Are you looking for Aurora Senior Living with stylish bedrooms and flexible or comfortable furniture? The Gardens Care Homes provides an assisted living standard and essentials things such as cooked meals, transportation, laundry, and medical care. Our staff is always ready to help in any way possible.

    ReplyDelete

  49. this is the one i am searching in google to read, if you wish to oud perfumes online check our website. we are the best perfumes seller and manufacturer in UAE.

    ReplyDelete