I have a crashed Linux system, where a special kernel module is loaded that does not respond to its assigned interrupt anymore. Is it possible to access the Internals of that specific module to see what has happened? Can it be done in a running system or do I need to modify the kernel, the module? Any hints are welcome.
Related
I had an issue with trying to get the wpa_supplicant to run on board running a custom Embedded Linux distribution. After some debugging it turned out that it was because the domain type PF_PACKET was not supported by the kernel:
drv->eapol_tx_sock = socket(PF_PACKET, SOCK_DGRAM, 0);
This is supported by the af_packet module and loading it beforehand fixed the problem. I noticed that it also has the alias "pf-net-17" and it appears that the kernel can load this module at runtime if requested from user-space via the alias. I tested this in another Embedded Linux distribution and sure enough this seems to be the case. It was loaded after the supplicant was called.
Does anyone know why this functionality is not working in the first setup? Maybe I missed a kernel setting?
There are basically 2 reasons why this worked on another system and not on your board:
the PF_PACKET was configured to be built in the kernel or not as a module.
The af_packet module was automatically loaded at runtime, either as a dependancy to another module or as a module to be automatically loaded at boot
I suggest that you read this document about module loading which is quite concise, yet complete and precise.
A way to fix your problem would be to make sure that depmod was run for your target system so that the module dependancy for your build is updated of load the af_packet module automatically at boot.
Another place to look at is udev, which is meant to load modules according to the devices detected by the kernel. Maybe this is also missing/misconfigured in your system.
Linux n00b here. How does one switch from User Mode to Kernel Mode? I'm running Linux Ubuntu 12.10. Is there an interrupt that I can call using inline assembly code that will do this? If not, how can it be done?
I'm asking this question because I am wishing to write a SCTP (network)protocol stack which has access to the kernel and runs in the background constantly though the UI cannot directly access the kernel. Never done anything like this before so tips from pros would definitely be appreciated.
All switches to kernel mode are made via system calls. In the case of network protocols these system calls are socket, listen, accept, ioctl, read, write, recvmsg, etc.
You write a Linux kernel module. There is already a SCTP protocol stack for Linux though. You would likely be better off modifying it to do what you want.
Once you have written and compiled your module you can load it into the kernel using insmod and rmmod. In my experience you rarely get a chance to use rmmod because if you made a mistake the system crashes or freezes. So use a virtual machine for your testing. It is faster to reboot, you lose less data, and it is easier to hook up a virtual serial console for debugging.
I am sure this question is a duplicate by the way. You can find a lot of questions on this topic.
For security reasons, the kernel ceased to export characters necessary for writing security modules in the form of loadable kernel modules (Linux Kernel Module, LKM) starting with version 2.6.24.
And you can't export sys_call_table, again for security reasons.
But then, how can I filter filesystem requests?
I'll state it simply: I want to hook the "open" function!
I don't want to have to compile my own version of the kernel, what's the point of drivers? It should work for all kernels.
Please help, thought I would have more freedom than Windows with Linux, but now I see the most precious parts of my life are blocked in Linux.
I've written a kernel module that can do this called tpe-lkm. I've also mentioned it on some other questions similar to this here on StackOverflow:
access to the sys_call_table in kernel 2.6+
Reading kernel memory using a module
intercepting file system system calls
Hope one of these helps you out.
Neaded your help on lirc.
I want to use lirc for decoding of ir signals. I am using a custom board based on Cortex A8 with 2.6.37 kernel and IR is received thru’ serial port. I can see UART interrupts coming properly when I press the button of the IR remote.
But when I try to run the configure script with device=all or device=serial and run make and make install as mentioned in the installation page on lirc.org, It sends me an error that the kernel configuration is invalid.
But still I am able to generate the .ko files(lirc_dev and lirc_serial) needed for loading the kernel modules but not able to insert lirc_serial module as I am using a port having mmio and the port used by lirc is io mapped.
My virtual adddress is 0xfa022000 and physical address is 0x48022000(using ttyO1).
Can I use lirc for this address.
Do I need to make any change in the code?
Also I cannot install directly on the board I am using as I could not build the kernel source code on the board due to minimal things present on the board.So am running the setup on some other machine and cross compiling for arm.
So I could not have the configuration files placed at the right locations also the node(/dev/lirc0) is not made.
Shall I make the node manually or will inserting the modules do the work?
Also do I need to have the configuration files at proper location before inserting the modules?
Also does it have any dependency with the kernel version?
Please suggest me the steps for cross compiling and loading the kernel modules on my own and also let me know which all conf files or other files are required to be present for making the things work.
I would really be very thankful to you for the help.
I have been trying it for the past 2 weeks.
Regards
Harman.
/dev/lirc0 should be created automatically if lirc_serial is loaded successfully. If it's not created, module was not loaded correctly.
lirc_serial does work with mmio - see 'iommap' module's param. You'll need to set it to 1 for mmio to work.
You'll also need to use 'io' and 'irq' params to setup your address and irq.
I'm using UDOO board with Cortex A9 CPU and could get my mmio and irq information from /proc/tty/driver/IMX-uart.
My kernel is newer though - it's 3.0.35 and I'm not sure if all of that will work in your case.
I was eventually able to load lirc_serial, but it still didn't work, so I had to connect my IR receiver directly to GPIO and write my own kernel driver based on lirc_rpi to make it working: http://funny-embeddings.blogspot.com/2013/12/udoo-adding-ir-and-building-lirc-kernel.html
I am interested in profiling a module for the Linux Kernel. I tried it this way:
Built the kernel with CONFIG_PROFILING=y
Booted the kernel with profile=2
Reset the profiler by echo 123 > /proc/profile
The module was successfully loaded by a dedicated daemon
Run a user-space app that is using the module through specific ioctl calls. The test app worked as expected so the module was working OK.
Read the profiling info using readprofile -p /proc/profile -m System.map where System.app was generated along with the kernel.
So far, so good. Almost everything worked as expected. What did not work however, is that I didn't get any info about my module, i.e. there was no mention of any function from the module.
However, on second thoughts, I remebered that I forgot to recompile the module using the CONFIG_PROFILING=y.
So, my question is: Did the module not show up in the profiling log because it had not been compiled with the CONFIG_PROFILING=y or is there some other more obvious reason that I don't know of?
If one wonders, why I am asking rather than trying it straight away, that is because, I can't do it at home and I'd rather like to hear what the knowledgable would say before I get access to the code again.
It doesn't seem possible for modules to be profiled in this way as they are loaded dynamically, which means that they are missing from the System.map file.
A solution would be to build the driver into the kernel. Unfortunately, this does not always work as the system may be designed to run only with the driver built into a module.
I suggest that using oprofile should work.