0

I am sporadically getting a weird effect with my kernel module that I cannot quite place (this is on a Raspberry Pi4 using Raspberry OS, I am using an SSD - no SD card; 3A power supply).

I have built a kernel module that still seems to have some kind of bug that may randomly crash the device (sometimes after 4 secs.. next time after 15 minutes, etc).

What puzzles me is this: I have a successfully built module that can load and run. At some point the device freezes (probably due to my module). I restart the device but when I try to again insert the same kernel module - the one that had been loaded successfully just before the reboot - I am now getting:

insmod: ERROR: could not insert module abc.ko: Invalid parameters

.. and I have to recompile the module (to which I have made absolutely no SW changes) before I am again able to insert it. Interestingly this effect does not occur every time the device freezes but only sometimes.. what is going on? Is there some mechanism in Linux that might "invalidate" some kernel module binary such that it can no longer be used?

PS: The only additional things connected to the Raspberry's 5V power supply are: the SSD (which draws between 80-100mA via USB3), a CPU fan (which supposedly is 200mA), and the PCB that hosts an audio chip used for my project (which draws 80mA).. i.e. I would think that the total 380mA should be well within the range of what my 3A power supply should be able to handle.

9
  • Have you verified there is no faulty hardware? It sounds like the SSD may have a fault that is causing data corruption--which may corrupt the filesystem further when it crashes without the kernel able to save any cached changes back to the SSD.
    – C. M.
    Apr 23, 2021 at 13:54
  • @C.M.why would the kernel make "cached changes" to my "kernel module" binary? should it not be a read only file conceptually? I just want to confirm that there is no scenario in which the kernel might deliberately make changes to the binary. if no such scenario exists then it probably is some kind of HW issue (probably not the SSD since it is already the 2nd SSD that I've observed this effect with..).
    – wothke
    Apr 23, 2021 at 14:37
  • Without further detail, we cannot know if that is the case with any certainty, we can only make guesses. It does not need to change the binary itself, but any file system data structure that corrupts it, such as the inode pointers, might cause it to point to some random sector of the disk which it treats as invalid data. We also do not know what "abc.ko" is doing. It might be trying to modify itself, for example, and in the process it locks up, corrupting itself.
    – C. M.
    Apr 23, 2021 at 16:31
  • As far as the "read only" in general, not just with the module.. Again, it depends. Conceptually, yes, it should not need to modify anything during boot. But some modules may need to do just that to update state information. They might also do that after boot, during runtime. And when it locks up and crashes, corruption can occur.
    – C. M.
    Apr 23, 2021 at 16:37
  • @C.M. I created a separate question that provides more info regarding the impl of my module (see unix.stackexchange.com/questions/646549/… ),, I don't know if/how the two issues might be related
    – wothke
    Apr 24, 2021 at 15:19

0

You must log in to answer this question.

Browse other questions tagged .