date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,493,001,709,000 |
I faced a strange effect as ... when my notebook wakes up from suspend I can start and close my web cam with guvcview 1-3 times; But after while on 3dr or 4th starting attempt (I didn't count for sure) my OS totally hangs so I have to reboot my notebook to make it work :P
As an attempt to find out some more details I tried to switch to non-GUI mode with alt_ctrl+F1 and input : $guvcview
That's what I could find on output :
...
libv4l2 error setting pixformat : device or resource busy
...
The thing is I have just one web cam on my notebook (the native one) which is build-in ; So I don't get it what else it can be busy with? So I think somehow
the native cam is running though guvcview is closed (correct me if I am wrong...) :(
EDIT :
I tried input as $ps axl | grep 3106
the output is :
0 1000 3106 1208 20 0 544772 68572 poll_s Sl ? 5:59 guvcview
0 1000 3412 3404 20 0 11916 2288 pipe_w S+ pts/4 0:00 grep --color=tty -d skip 3106
after I close the guvcview I can see this output :
ps axl | grep 3106
0 1000 3797 3404 20 0 11916 2392 pipe_w S+ pts/4 0:00 grep --color=tty -d skip 3106
...so is that means I have two threads using the device? I have usb cam; Not really sure how the ps axl output can help in my case; So please give me a tip pls...
lsusb outputs
...ID 04f2:b404 Chicony Electronics Co., Ltd
so it is hard to say what model number the cam really has to use the web cam setup instructions for sure...
So my question is how to fix that cause rebooting on each unlucky web cam start is awkward %)
p.s.
web cam vendor: Chicony Electronics (?not sure how to get model info)
Kernel : 3.16.7.3-1
OS : Linux Arch x64
Thanks
|
This may be a duplicate of this just asked differently.
Anyways, have you tried to find out if another process is using the camera(such as one of your previous attempts to use the camera not exiting properly...)
Try this - (notice you have to take the output of the first line and edit the third line to match your output...
sudo fuser /dev/video0
/dev/video0: 1871m
sudo kill -9 1871
| web cam starting hangs os |
1,493,001,709,000 |
I have put in a Hitachi 2.5 inch hdd inside a Inateck hdd enclosure. I have connected the enclosure to a Toshiba R630-156 using a usb2 cable on a usb3 enclosure port. I can hear and feel the hard drive is powered but I cannot see any messages in dmesg. i cannot see any related output in lsusb. I have enabled usb_storage kernel module but it does not seem to make any difference. I am not experienced with trouble shooting hardware issues so please refer to some documentation if you are using very specific terms in your explanation. please ask if you need anymore debug information. thanks.
$ cat /etc/lsb-release
DISTRIB_ID=LinuxMint
DISTRIB_RELEASE=17
DISTRIB_CODENAME=qiana
DISTRIB_DESCRIPTION="Linux Mint 17 Qiana"
$ uname -a
Linux rag-tos-laptop 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
$ lsmod | grep usb
usb_storage 62209 0
btusb 32412 0
bluetooth 395423 12 bnep,btusb,rfcomm
usbhid 52616 0
hid 106148 2 hid_generic,usbhid
$ lsusb
Bus 002 Device 004: ID 0930:0214 Toshiba Corp.
Bus 002 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0bda:58f5 Realtek Semiconductor Corp.
Bus 001 Device 004: ID 046d:c52e Logitech, Inc.
Bus 001 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
BIOS Information
Vendor: TOSHIBA
Version: Version 1.90
Release Date: 02/24/2011
ROM Size: 2048 kB
Characteristics:
ISA is supported
PCI is supported
PNP is supported
BIOS is upgradeable
BIOS shadowing is allowed
VLB is supported
Boot from CD is supported
Selectable boot is supported
EDD is supported
Japanese floppy for Toshiba 1.2 MB is supported (int 13h)
3.5"/720 kB floppy services are supported (int 13h)
Print screen service is supported (int 5h)
8042 keyboard services are supported (int 9h)
Serial services are supported (int 14h)
Printer services are supported (int 17h)
ACPI is supported
USB legacy is supported
BIOS boot specification is supported
Function key-initiated network boot is supported
Targeted content distribution is supported
BIOS Revision: 1.90
Firmware Revision: 1.40
|
actually, I just realized that when using a usb3 cable and connecting to a usb2 port on the laptop, the device is found and all the partitions are automatically mounted.
The problem I had earlier could be from the usb2 cable which could carry only less power than a usb3 device required.
/dev/sdb5 on /media/r/3c45f792-1630-4866-8a33-1534c115f285 type ext4 (rw,nosuid,nodev,uhelper=udisks2)
/dev/sdb6 on /media/r/ce13cd6c-57bd-4beb-b489-10e2aa2a7876 type ext4 (rw,nosuid,nodev,uhelper=udisks2)
/dev/sdb1 on /media/r/SYSTEM type fuseblk (rw,nosuid,nodev,allow_other,default_permissions,blksize=4096)
/dev/mapper/vgroup1-mymedia on /media/r/dc1afac9-27cc-4f76-95a6-91f0ac0060ef type ext4 (rw,nosuid,nodev,uhelper=udisks2)
/dev/mapper/vgroup1-virtualization on /media/r/c71ff7a8-bfee-48e1-9ab1-25e6a8ecd829 type ext4 (rw,nosuid,nodev,uhelper=udisks2)
kernel: [13587.330014] sdb: sdb1 sdb2 sdb3 sdb4 < sdb5 sdb6 sdb7 sdb8 >
kernel: [13587.333642] sd 8:0:0:0: [sdb] Attached SCSI disk
kernel: [13589.035776] EXT4-fs (sdb5): mounted filesystem with ordered data mode. Opts: (null)
kernel: [13589.038729] EXT4-fs (sdb6): mounted filesystem with ordered data mode. Opts: (null)
kernel: [13592.827240] bio: create slab <bio-1> at 1
kernel: [13595.524660] EXT4-fs (dm-0): mounted filesystem with ordered data mode. Opts: (null)
kernel: [13598.882851] EXT4-fs (dm-1): mounted filesystem with ordered data mode. Opts: (null)
| unrecognized inateck hdd enclosure with linux Mint |
1,401,330,446,000 |
I 'm running Angstrom Linux (3.0.7) on embedded device BeagleBoard-xM. I want to load a module (downloaded from here) and copied into: /lib/modules/3.0.7/kernel/drivers/net/wireless/rtlwifi/8192cu.ko on the BeagleBoard-xM SD card file system.
However, loading the module fails:
root@beagleboard:/# modprobe 8192cu
FATAL: Module 8192cu not found.
Any ideas?
|
Did you run depmod? This is something make modules_install does automatically for you, but if you copy a module into /lib/modules this way, you will need to do that manually. See man depmod for more information.
I am not sure if depmod will report the presence of incompatible modules.
You can also use an explicit path with insmod, which will at least test if the module can be loaded.
> insmod /lib/modules/3.0.7/kernel/drivers/net/wireless/rtlwifi/8192cu.ko
> lsmod | grep 8192cu
If the module has dependencies, they won't be loaded, which is why depmod and modprobe make things more convenient. Note the kernel will reject modules that do not match its version. There is, however, a configuration option to disable this safety feature.
| Loading module 8192cu fails |
1,401,330,446,000 |
I'm currently learning about device developement for linux, I have glaced at some books such as LLD3, .. but I still can't understand what happen when we plug a device into computer, That's my imagination: When we plugs a device into a port, in a magic way, Linux kernel will know what device type and call to appropriate module's probe function to determine if it is exactly device which module need, and the next is magic .... Can anyone correction this?
|
It's not really magic, it's hardware. Information about peripheral events comes to the CPU thru the front side bus, which is the gateway to other hardware; programmatically (in kernel code) these are dealt with via the concept of the interrupt request (IRQ).
Have a look at these in order:
http://en.wikipedia.org/wiki/Northbridge_%28computing%29
http://en.wikipedia.org/wiki/Front_side_bus.
Now consider that the kernel is what determines what goes on in the CPU. Next:
http://en.wikipedia.org/wiki/Interrupts
http://en.wikipedia.org/wiki/IRQ
To get more specific WRT the linux kernel code, it uses handlers which fire on receipt of an interrupt request. The basic parts of this are done with architecture specific asm code, a lot of which you will find in (eg) src/arch/x86/kernel. I don't code in asm (the .S files), so it's greek to me, unfortunately, but the idea here (should be in that wikipedia stuff) is that on receipt of an IRQ, the kernel pre-empts whatever user space code is running in order to process the IRQ (possibly passing something on to whatever user space process).
| What happen when we plug a device in to computer |
1,401,330,446,000 |
I have an Acer netbook, with built-in camera, running just fine under Ubuntu/x86. I also have a stack of broken netbooks of the same model that suffered various accidents over the years of intense use, and serve as source of spare parts. And I got an Orange Pi, to which I wanted to attach a small, lean webcam - the thingy fitting in the narrow bar above the screen was the perfect size, and I knew for a fact it's USB (albeit a special snowfake running on 3.3V instead of USB's standard 5) so I extracted one, found the pinout, hooked it to USB data, 3.3V and GND on my Orange Pi, and it showed up in lsusb just fine, same as on the netbook:
Bus 001 Device 002: ID 04f2:b367 Chicony Electronics Co., Ltd
And that's where my adventure hit a roadblock: there appears to be no kernel module in my Pi's distro to support this camera. No surprise there, I might be the first person in the world who wants to hook up the camera manufactured exclusively to be built into Acer x86 netbooks, to an ARM SBC. Why clutter an ARM build with drivers for hardware never seen before outside an Intel machine? lsmod doesn't show anything related to video. I bet I could compile and add the relevant module if I knew which one is it.
Meanwhile, my (working) netbook's lsusb displays over 80 modules, names of most telling me nothing about what they do.
Module Size Used by
option 57344 0
huawei_cdc_ncm 16384 0
cdc_wdm 20480 1 huawei_cdc_ncm
cdc_ncm 40960 1 huawei_cdc_ncm
usb_wwan 20480 1 option
usbnet 45056 2 cdc_ncm,huawei_cdc_ncm
usbserial 45056 2 usb_wwan,option
uas 24576 0
usb_storage 69632 1 uas
binfmt_misc 20480 1
ccm 20480 6
snd_hrtimer 16384 1
wl 6447104 0
snd_hda_codec_realtek 110592 1
snd_hda_codec_generic 73728 1 snd_hda_codec_realtek
snd_hda_codec_hdmi 49152 1
uvcvideo 90112 0
videobuf2_vmalloc 16384 1 uvcvideo
snd_hda_intel 45056 3
videobuf2_memops 16384 1 videobuf2_vmalloc
videobuf2_v4l2 24576 1 uvcvideo
videobuf2_core 40960 2 videobuf2_v4l2,uvcvideo
videodev 188416 3 videobuf2_core,videobuf2_v4l2,uvcvideo
snd_hda_codec 126976 4 snd_hda_codec_generic,snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec_realtek
media 40960 2 videodev,uvcvideo
snd_hda_core 81920 5 snd_hda_codec_generic,snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec,snd_hda_codec_realtek
snd_hwdep 20480 1 snd_hda_codec
intel_powerclamp 16384 0
snd_pcm 98304 4 snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec,snd_hda_core
arc4 16384 2
coretemp 16384 0
ath9k 155648 0
ath9k_common 36864 1 ath9k
snd_seq_midi 16384 0
ath9k_hw 471040 2 ath9k_common,ath9k
snd_seq_midi_event 16384 1 snd_seq_midi
input_leds 16384 0
acer_wmi 20480 0
joydev 24576 0
sparse_keymap 16384 1 acer_wmi
ath 32768 3 ath9k_common,ath9k,ath9k_hw
serio_raw 16384 0
wmi_bmof 16384 0
mac80211 786432 1 ath9k
rtsx_pci_ms 20480 0
memstick 16384 1 rtsx_pci_ms
snd_rawmidi 32768 1 snd_seq_midi
snd_seq 65536 3 snd_seq_midi,snd_seq_midi_event
lpc_ich 24576 0
cfg80211 634880 5 wl,ath9k_common,ath9k,ath,mac80211
snd_seq_device 16384 3 snd_seq,snd_seq_midi,snd_rawmidi
snd_timer 32768 3 snd_seq,snd_hrtimer,snd_pcm
mac_hid 16384 0
snd 81920 18 snd_hda_codec_generic,snd_seq,snd_seq_device,snd_hda_codec_hdmi,snd_hwdep,snd_hda_intel,snd_hda_codec,snd_hda_codec_realtek,snd_timer,snd_pcm,snd_rawmidi
soundcore 16384 1 snd
shpchp 36864 0
sch_fq_codel 20480 2
cuse 16384 3
parport_pc 32768 0
ppdev 20480 0
lp 20480 0
parport 49152 3 parport_pc,lp,ppdev
ip_tables 28672 0
x_tables 40960 1 ip_tables
autofs4 40960 2
rtsx_pci_sdmmc 24576 0
gma500_gfx 184320 2
i2c_algo_bit 16384 1 gma500_gfx
drm_kms_helper 172032 1 gma500_gfx
syscopyarea 16384 1 drm_kms_helper
sysfillrect 16384 1 drm_kms_helper
psmouse 151552 0
sysimgblt 16384 1 drm_kms_helper
ahci 40960 2
fb_sys_fops 16384 1 drm_kms_helper
libahci 32768 1 ahci
drm 401408 4 drm_kms_helper,gma500_gfx
r8169 86016 0
rtsx_pci 69632 2 rtsx_pci_sdmmc,rtsx_pci_ms
mii 16384 2 r8169,usbnet
wmi 24576 2 acer_wmi,wmi_bmof
video 45056 2 acer_wmi,gma500_gfx
How do I go about finding the right one?
|
You can search through the kernel sources for the vendor id "04f2", then filter for the product id "b367". I found 2 video files with the vendor id,though one zr364xx.c is no longer in the version 6 kernel. No files have the specific product id. You could try editing the other uvc_driver.c file by duplicating the struct entry for /* Chicony CNF7129 (Asus EEE 100HE) */ and changing the product id, then recompiling the module.
| How to tell which kernel module acts as a driver for a USB device? |
1,401,330,446,000 |
I would like to setup correct kernel module loading. For this reason I am interested in the output of uname -r of the custom kernel I compiled and am about to setup.
Since this kernel is of course not already running I have no clue to how I can get the info of uname -r for this kernel, as it is yet to be booted and uname only outputs the current kernel id.
Is there a way to determine the output of uname -r of the kernel I have just compiled?
|
The file command may be able to extract information out of a vmlinuz file:
Linux/x86 Kernel, Setup Version 0x20d, bzImage, Version 4.15.7-1-default ...
| How to do a "uname -r" for a different kernel? |
1,401,330,446,000 |
I want to start using npf on my NetBSD server, rather than relying solely on the external firewall for protection. However, I get:
$ npfctl show
npfctl: /dev/npf: No such file or directory
Alright, maybe I deleted a device node. No matter:
$ grep npf /dev/MAKEDEV
makedev bpf npf
npf)
mkdev npf c 198 0
# mknod /dev/npf c 198 0
$ npfctl show
npfctl: /dev/npf: Device not configured
Oh, right, have to load the driver first:
$ modstat | grep npf; echo $?
1
$ find /stand -name 'npf.kmod'
/stand/sparc64/7.0/modules/npf/npf.kmod
$ uname -sr
NetBSD 7.0.2
# modload npf
modload: Operation not permitted
Why am I (even as root) not permitted to load modules?
|
NetBSD uses kernel secure levels to determine what operations can be performed on a running system. From the link:
-1 Permanently insecure mode
Don't raise the securelevel on boot
0 Insecure mode
The init process (PID 1) may not be traced or accessed by ptrace(2), systrace(4), or procfs.
Immutable and append-only file flags may be changed
All devices may be read or written subject to their permissions
Note: You can't run X11 above this securelevel
Try sysutils/aperture if you really need it.
1 Secure mode
All effects of securelevel 0
/dev/mem and /dev/kmem may not be written to
Raw disk devices of mounted file systems are read-only
Immutable and append-only file flags may not be removed
Kernel modules may not be loaded or unloaded
The net.inet.ip.sourceroute sysctl(8) variable may not be changed
Adding or removing sysctl(9) nodes is denied
The RTC offset may not be changed
Set-id coredump settings may not be altered
Attaching the IP-based kernel debugger, ipkdb(4), is not allowed
Device pass-thru requests that may be used to perform raw disk and/or memory access are denied
iopl and ioperm calls are denied
Access to unmanaged memory is denied
2 Highly secure mode
All effects of securelevel 1
Raw disk devices are always read-only whether mounted or not
New disks may not be mounted, and existing mounts may only be downgraded from read-write to read-only
The system clock may not be set backwards or close to overflow
Per-process coredump name may not be changed
Packet filtering and NAT rules may not be altered
My system was running at securelevel 1, so "Kernel modules may not be loaded or unloaded". Further, setting npf=YES in rc.conf does not automatically load the associated kernel module. One cannot lower the kernel secure level at runtime, so the options are:
Boot to a lower securelevel, then load the module and raise the securelevel, or
Load the module during boot
Clearly the latter is the better option. To load a kernel module at boot, one must ensure that rc.conf contains:
modules=YES
Then, edit (or create) /etc/modules.conf to contain a list of modules to load, one per line. In this case:
# echo npf >> /etc/modules.conf
| Loading NetBSD kernel modules |
1,401,330,446,000 |
I am confused by how built-in kernel modules work. As per my understanding, one can embed a kernel module when compiling the Linux kernel by setting kconfig option to MODULE_NAME=y. Then, it doesn't have to be loaded with e.g. modprobe. Built-in kernel modules can be shown with cat /lib/modules/$(uname -r)/modules.builtin.
When I execute this command, the list shows .ko files. But if they are embedded inside the kernel, why is it showing this? For example:
~$ cat /lib/modules/$(uname -r)/modules.builtin | grep -i bsg #just picking something random
kernel/block/bsg.ko
~$ cat /boot/config-6.5.0-14-generic | grep -i bsg
CONFIG_BLK_DEV_BSG_COMMON=y #implying this is a builtin module
CONFIG_BLK_DEV_BSGLIB=y
CONFIG_BLK_DEV_BSG=y
CONFIG_SCSI_UFS_BSG=y
~$ modinfo bsg
name: bsg
filename: (builtin)
license: GPL
file: block/bsg #why "file"? Isn't it compiled inside the kernel?
...
~$ cat /lib/modules/6.5.0-14-generic/kernel/block/bsg.ko
cat: /lib/modules/6.5.0-14-generic/kernel/block/bsg.ko: No such file or directory
So my questions are:
What really happens to builtin kernel modules and where do they reside inside the system?
Are they inside vmlinuz and extracted somehow?
Why do they appear as .ko file but are not present in the directory where I would expect them?
Considering they are indeed embedded in vmlinu(x/z), how do they end up being "registered" such that we can find them using modinfo? And why does it still have a file (block/bsg) as shown by modinfo if it's in the kernel binary?
|
Builtin kernel “modules” (they aren’t really modules) are part of the main kernel binary, vmlinux before it’s compressed. They are never extracted as separate entities, they are loaded along with the rest of the kernel.
They appear as .ko files in modules.builtin to make things easier for other tools, e.g. for module dependency analysis. By listing them as .ko files, they can be handled in the same way as modules.
When components of the kernel are built-in, but their source files contain module declarations, the information provided there is stored in modules.builtin and modules.builtin.modinfo (see the Kbuild documentation). modules.builtin allows modprobe to handle load requests for built-in modules, and modules.builtin.modinfo allows modinfo to provide information about them. Built-in components don’t have a filename (which points to the real .ko on disk, for loadable modules), but they do have a file — this is an entry specific to builtin modules, storing the name of the source file containing the module declarations (block/bsg.c in your example).
| Where do built-in kernel modules reside? |
1,401,330,446,000 |
I'm still new to understanding the Linux kernel so please forgive the basic question. If you could point me to resources that I could read/watch that would be greatly appreciated.
Coming from Windows, the hardware driver workflow appears to be that you install the core operating system first, then install drivers separately.
With Linux it appears that all the drivers are compiled into the kernel directly - does that mean an installed Linux distro comes with support for all supported hardware, even if you only use a subset of that?
Does that mean installing something like the proprietary NVIDIA driver (which is not included in the kernel) will actually require recompiling the kernel with the NVIDIA driver - where distros like Ubuntu and Fedora provide pre-compiled kernels with the driver built in?
I recently installed a driver on my Linux install that added support for the Xbox wireless dongle. It used "DKMS" to add the driver to my system without compiling it into the kernel.
Is DKMS a method to add micro-kernel features to Linux? Why aren't all drivers distributed as dynamic modules? Aren't kernel modules already dynamic as they are installed under /ib/modules?
How do dynamic kernel modules affect secure boot in the context of a self-signed Linux install?
|
I think you're conflating two related but different concepts: how drivers used by the kernel (statically compiled in, dynamically loaded), and how they're developed (in-tree, out-of-tree).
Drivers that are developed in-tree can be compiled into the kernel or loaded dynamically. Most are dynamically loaded. Drivers developed out of tree are almost always going to be dynamically loaded, simply because they're not going to be in the kernel source code of most distributions, so they can't be compiled in at all. If you have to install a driver separately, then it's developed out-of-kernel.
Drivers depend on a lot of internal APIs of the kernel, and as I understand it, Linux doesn't care about backwards compatibility of these APIs. The preference is for clean code, not maintaining a kludgy mess of ancient cruft and modern code for the sake of backwards compatibility (in a sense). So they prefer having drivers in-tree - if someone does some refactoring of an API, they are also expected to fix up any users of that API, and which they can do, since all users are in the same source code.
Of course, this can't be done for out-of-tree drivers. So they have to be compiled for a specific kernel version, as other versions may break the APIs they're depending on. For NVIDIA, and possibly others, the driver is basically a shim that wraps around a proprietary binary. (The shim supports multiple kernel versions.) This means that for distributions, you have to have a package of the driver for each packaged kernel version.
DKMS is a mechanism to help such out-of-tree kernels - instead of having a version of the driver packaged for each version of the kernel, DKMS will compile the driver for each installed kernel version.
| Why are drivers compiled into the kernel? Why aren't more drivers distributed as dynamic kernel modules? |
1,401,330,446,000 |
So, I was trying to make the driver for my tplink, but when I entered "make", I got this:
make ARCH=x86_64 CROSS_COMPILE= -C /lib/modules/5.18.10-200.fc36.x86_64/build M=/home/dfmaaa1/rtl8821au modules
make[1]: *** /lib/modules/5.18.10-200.fc36.x86_64/build: No such file or directory. Stop.
make: *** [Makefile:116: modules] Error 2
What does this mean? Why can't it find build?
The github repo is https://github.com/ulli-kroll/rtl8821au.
I am using Fedora 36 Workstation. Kernel version: 5.18.10-200.fc36.x86_64
|
sudo dnf install kernel-devel is what you're looking for. If it installs a new kernel part of the process, you'll have to reboot.
| What is the build executable that make wants to use but can't find? |
1,401,330,446,000 |
As pointed out in this question, the prototype for the ioctl function inside a Linux kernel module is:
(version 1)
int ioctl(struct inode *i, struct file *f, unsigned int cmd, unsigned long arg);
or
(version 2)
long ioctl(struct file *f, unsigned int cmd, unsigned long arg);
I would like to use them in a kernel module which implements a character device driver.
Are both the above prototypes suitable in this case? If yes, why? If no, how to choose the right one?
What header/source file(s) contain these prototypes? In other words: what is the official reference file for these prototypes?
I'm running Ubuntu 20.04 on x86_64 and these are my available header files:
/usr/include/asm-generic/ioctl.h
/usr/include/linux/ioctl.h
/usr/include/linux/mmc/ioctl.h
/usr/include/linux/hdlc/ioctl.h
/usr/include/x86_64-linux-gnu/sys/ioctl.h
/usr/include/x86_64-linux-gnu/asm/ioctl.h
The only significant line is in /usr/include/x86_64-linux-gnu/sys/ioctl.h:
extern int ioctl (int __fd, unsigned long int __request, ...) __THROW;
but I can't find here any clue about the above two alternative prototypes.
|
Are both the above prototypes suitable in this case? If yes, why? If no, how to choose the right one?
They are not both suitable. Only version 2 is currently available in the kernel, so this is the version that should be used.
What header/source file(s) contain these prototypes? In other words: what is the official reference file for these prototypes?
They are in include/linux/fs.h (this is a path relative to the kernel sourcecode root directory), inside the struct file_operations definition:
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
That is: the member unlocked_ioctl must be a pointer to a function
long ioctl(struct file *f, unsigned int cmd, unsigned long arg);
which is exactly version 2. If a function my_ioctl() is defined inside a kernel module using version 1 instead, a compiler error will be generated:
error: initialization of ‘long int (*)(struct file *, unsigned int, long unsigned int)’ from incompatible pointer type ‘long int (*)(struct inode *, struct file *, unsigned int, long unsigned int)’ [-Werror=incompatible-pointer-types]
.unlocked_ioctl = my_ioctl
^~~~~~~~
Some additional comments
Version 1 has been the only one, till kernel 2.6.10, where struct file_operations only had
int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
This ioctl function, however, created a Big Kernel Lock (BKL): it locked the whole kernel during its operation. This is undesirable. So, from 2.6.11,
int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
A new way to use ioctls has been introduced, which did not lock the kernel. Here the old ioctl with kernel lock and the new unlocked_ioctl coexist. From 2.6.36, the old ioctl has been removed. All the drivers should be updated accordingly, to only use unlocked_ioctl. Refer to this answer for more information.
In a recent kernel release (5.15.2), it seems that there are still few files using the old ioctl:
linux-5.15.2$ grep -r "ioctl(struct inode" *
Documentation/cdrom/cdrom-standard.rst: int cdrom_ioctl(struct inode *ip, struct file *fp,
drivers/staging/vme/devices/vme_user.c:static int vme_user_ioctl(struct inode *inode, struct file *file,
drivers/scsi/dpti.h:static int adpt_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg);
drivers/scsi/dpt_i2o.c:static int adpt_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
fs/fuse/ioctl.c:static int fuse_priv_ioctl(struct inode *inode, struct fuse_file *ff,
fs/btrfs/ioctl.c:static noinline int search_ioctl(struct inode *inode,
fs/ocfs2/refcounttree.h:int ocfs2_reflink_ioctl(struct inode *inode,
fs/ocfs2/refcounttree.c:int ocfs2_reflink_ioctl(struct inode *inode,
net/sunrpc/cache.c:static int cache_ioctl(struct inode *ino, struct file *filp,
vme_user.c, dpt_i2o.c and cache.c, however, have:
static const struct file_operations adpt_fops = {
.unlocked_ioctl = adpt_unlocked_ioctl,
and then
static long adpt_unlocked_ioctl(struct file *file, uint cmd, ulong arg)
{
struct inode *inode;
long ret;
inode = file_inode(file);
mutex_lock(&adpt_mutex);
ret = adpt_ioctl(inode, file, cmd, arg);
So they use the old version, inside the new (getting the inode from the available data, as suggested by Andy Dalton in the comments). As regards the files inside fs: they seem not to use a struct file_operations; also, their functions are not the ioctl defined in
int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
because they take different parameters (fuse_priv_ioctl in fs/fuse/ioctl.c, search_ioctl in fs/btrfs/ioctl.c, ocfs2_reflink_ioctl in fs/ocfs2/refcounttree.c), so they maybe are only used internally in the driver.
So, the assumption in the linked question that two versions are available for the ioctl function inside a Linux kernel module is wrong. Only unlocked_ioctl (version 2) must be used.
| Two different function prototypes for Linux kernel module ioctl |
1,401,330,446,000 |
I configured a debian kernel 5.10.57 to add the HSR/PRP module. I enabled it as built-in <*>. Then i compiled and installed the kernel using make deb-pkg and dpkg -i *.deb respectively.
The new kernel is running.
debian@debian:~$ uname -r
5.10.57
The HSR/PRP module path is in the builtin.modules file :
debian@debian:~$ cat /lib/modules/5.10.57/modules.builtin |grep hsr
kernel/net/hsr/hsr.ko
But the hsr directory (and the .ko file) does not exist.
debian@debian:~$ ls /lib/modules/5.10.57/kernel/net/ |grep hsr
debian@debian:~$
So the module is not loaded.
debian@debian:~$ lsmod |grep hsr
debian@debian:~$
In the /usr/src/linux-5.10.57/ folder, containing the kernel I compiled, the hsr configuration files are all here.
debian@debian:~$ ls /usr/src/linux-5.10.57/net/hsr/
hsr_debugfs.c hsr_forward.c hsr_framereg.h hsr_netlink.c hsr_slave.h
hsr_device.c hsr_forward.h hsr_main.c hsr_netlink.h Kconfig
hsr_device.h hsr_framereg.c hsr_main.h hsr_slave.c Makefile
debian@debian:~$
I tried a few commands to build the .ko file but nothing worked.
debian@debian:/usr/src/linux-5.10.57/net/hsr$ make
make: *** No targets. Stop.
debian@debian:/usr/src/linux-5.10.57/net/hsr$
debian@debian:/usr/src/linux-5.10.57/net/hsr$ make install
make: *** No rule to make target 'install'. Stop.
debian@debian:/usr/src/linux-5.10.57/net/hsr$
debian@debian:/usr/src/linux-5.10.57/net/hsr$ make modules
make: *** No rule to make target 'modules'. Stop.
debian@debian:/usr/src/linux-5.10.57/net/hsr$
debian@debian:/usr/src/linux-5.10.57/net/hsr$ make modules_install
make: *** No rule to make target 'modules_install'. Stop.
If you want to know what is in the Makefile :
debian@debian:/usr/src/linux-5.10.57/net/hsr$ cat Makefile
# SPDX-License-Identifier: GPL-2.0-only
#
# Makefile for HSR
#
obj-$(CONFIG_HSR) += hsr.o
hsr-y := hsr_main.o hsr_framereg.o hsr_device.o \
hsr_netlink.o hsr_slave.o hsr_forward.o
hsr-$(CONFIG_DEBUG_FS) += hsr_debugfs.o
debian@debian:/usr/src/linux-5.10.57/net/hsr$
Here are my questions :
Does a builtin module need a .ko file to be in the path required by the /lib/modules/5.10.57/modules.builtin file to be loaded ?
If yes, how can I generate or find the hsr.ko file I need ?
|
Since you configured the driver as built-in, rather than a module (<M> in the kernel configuration), it is part of the kernel binary (bzImage etc.). It will always be “loaded” whenever that particular kernel binary is booted.
You won’t see it as a separate .ko file, nor will you be able to force the .ko file to be built.
| Built-in module enabled at kernel configuration is missing |
1,401,330,446,000 |
I am attempting to install a new version of a kernel module. To this end, I attempted to remove the old module with rmmod mod. This gave no output. When I tried modinfo mod, however, I received the same result I did before calling rmmod. What am I missing?
|
modinfo does not care whether the module is loaded or not - if you give it a module name (instead of a full pathname to a .ko file), it finds the module file on disk based on the current /etc/modprobe.d configuration and reports information on it.
So if you already replaced the old module in /lib/modules/... with a new version before running your first modinfo, it has probably been reporting information on the new version all along! That's why running rmmod did not change anything in the modinfo output.
If you want to know the version of a kernel module that is currently loaded (as opposed to what's on disk), use cat /sys/module/<module_name>/version.
| modinfo doesn't change after rmmod |
1,401,330,446,000 |
Would like to know if there is a specific list or location for the name of the kernel modules that are loaded when the system is booted.
Commands like lsmod or cat /proc/kallsyms only show those that have been loaded.
Want to determine which are the modules that have been loaded manually.
Thanks in advance!
|
There might be multiple lists: one for kernel modules loaded within initramfs (i.e. modules necessary for basic I/O and accessing the root filesystem) and another list loaded once the root filesystem has been mounted.
For Debian and related Linux distributions like Ubuntu, there's /etc/initramfs-tools/modules for modules to be loaded in initramfs (in the specific order listed), and /etc/modules-load.d/ drop-in directory for specifying modules to be loaded after the root filesystem is accessible.
For any distribution using the dracut initramfs creator, you might want to look into /etc/dracut.conf and/or /etc/dracut.conf.d/*.conf files for add_drivers, force_drivers and/or filesystems lines: these will cause the specified modules to be added into initramfs, and in case of force_drivers, explicitly loaded regardless of hardware detection.
Besides those, on modern systems, many modules are usually loaded by hardware auto-detection: the kernel will format the hardware IDs detected on any autodetection-capable bus into specific module alias names, and the modules themselves will contain wildcard strings matching the hardware they support. If a match is found, the matching module is loaded. Each driver module will usually have a more detailed hardware detection routine that can further verify the compatibility between the module and the hardware.
On architectures with no auto-detection-capable system buses (e.g. RasPi and various embedded devices), a "device tree", a .dtb file either appended to the kernel image or loaded separately by the bootloader, will describe the system hardware: it includes identifiers for compatible "programming models", which will be used by the kernel to form module alias strings for automatic loading of appropriate modules.
The aim of kernel developers is to make the loading of kernel modules as automatic as reasonably possible.
| Kernel Modules loaded when boot |
1,401,330,446,000 |
Does anyone know I can detect which CPU instructions are being executed?
I am especially interested in detecting AES instructions implemented by recent Intel and AMD CPUs. Would it f.e. be possible to write a kernel module that detects these instructions? Or are the specific CPU instructions that are sent to the CPU not even known by the kernel?
|
Most of the time, CPUs execute processes’ instructions without involving the kernel; the kernel only has to step in if a user-level process causes a trap, either by attemptung to execute an invalid instruction (invalid here covering a variety of reasons) or by invoking a software interrupt. AES instructions are executed directly and the kernel doesn’t know that they’re being executed.
I don’t think there are any related performance counters you could use either. The AES instructions have an unusual execution pattern which may be identifiable statistically, but I’ve never tried that... And that’s not applicable generally anyway.
You could try using an appropriately-instrumented emulator such as Bochs, or analyse binaries to determine the instructions they use — Debian: what instructions do x86-64 binaries use? has more information on the latter.
| How can I detect which instructions are executed on a CPU? |
1,401,330,446,000 |
The problem concerns a driver support regression for the RTL8192CUS WLAN chip under antiX 13.1, a Debian Wheezy (stable) based distribution.
The chip actually resides in a Edimax EW-7811Un 802.11n wireless adapter.
First, here is some general system information.
$ inxi -F
System: Host: 4000cdt Kernel: 3.7.10-antix.3-486-smp i686 (32 bit)
Desktop: IceWM 1.3.7 Distro: antiX-13.1_386-full Luddite 19 June 2013
Machine: No /sys/class/dmi, using dmidecode: you must be root to run dmidecode
CPU: Single core Pentium II (Deschutes) (-UP-) cache: 512 KB flags: (pae) clocked at 233.275 MHz
Graphics: Card: Chips and F65555 HiQVPro X.Org: 1.12.4 drivers: chips (unloaded: fbdev,vesa) Resolution: [email protected]
GLX Renderer: Gallium 0.4 on softpipe GLX Version: 2.1 Mesa 8.0.5
Network: Card: Edimax EW-7811Un 802.11n Wireless Adapter [Realtek RTL8188CUS]
IF: N/A state: N/A mac: N/A
Drives: HDD Total Size: 40.0GB (8.7% used) 1: id: /dev/sda model: TOSHIBA_MK4032GA size: 40.0GB
Partition: ID: / size: 9.9G used: 3.0G (32%) fs: ext4 ID: /home size: 25G used: 284M (2%) fs: ext4
ID: swap-1 size: 2.15GB used: 0.00GB (0%) fs: swap
Sensors: System Temperatures: cpu: 71.0C mobo: N/A
Fan Speeds (in rpm): cpu: N/A
Info: Processes: 88 Uptime: 2:57 Memory: 72.4/151.4MB Client: Shell (bash) inxi: 1.9.9
During booting, the following errors appear on the screen, caused while executing the /etc/network/if-pre-up.d/linux-wlan-ng-pre-up script:
FATAL: Module p80211 not found.
/etc/network/if-pre-up.d/linux-wlan-ng-pre-up
Failed to load p80211.ko.
Listening on LPF/wlan0/00:1f:1f:bf:45:7a
Sending on LPF/wlan0/00:1f:1f:bf:45:7a
Sending on Socket/fallback
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 7
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 10
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 14
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 17
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 13
No DHCPOFFERS received.
No working leases in persistent database - sleeping.
The error messages can be reproduced by issuing respectively the sudo modprobe p80211 and sudo dhclient -v wlan0 commands.
The following modules are loaded:
$ lsmod
Module Size Used by
mperf 870 0
cpufreq_stats 2600 0
cpufreq_powersave 575 0
cpufreq_conservative 3562 0
ppdev 4124 0
lp 6127 0
uinput 5093 1
nfsd 156046 2
auth_rpcgss 19755 1 nfsd
nfs_acl 1576 1 nfsd
nfs 88586 0
lockd 42731 2 nfs,nfsd
fscache 21695 1 nfs
sunrpc 122417 6 nfs,nfsd,auth_rpcgss,lockd,nfs_acl
af_packet 19031 6
dm_crypt 10846 0
arc4 1400 2
rtl8192cu 45534 0
rtlwifi 43564 1 rtl8192cu
rtl8192c_common 23999 1 rtl8192cu
mac80211 192647 3 rtlwifi,rtl8192c_common,rtl8192cu
cfg80211 123731 2 mac80211,rtlwifi
microcode 8484 0
evdev 6815 10
mac_hid 2214 0
psmouse 52159 0
pcspkr 1273 0
serio_raw 3177 0
i2c_piix4 6769 0
toshiba_acpi 10065 0
sparse_keymap 1937 1 toshiba_acpi
parport_pc 23969 1
rfkill 10599 3 cfg80211,toshiba_acpi
parport 21942 3 lp,ppdev,parport_pc
wmi 6240 1 toshiba_acpi
pcmcia 24870 0
battery 5391 0
yenta_socket 15802 0
ac 1753 0
pcmcia_rsrc 5995 1 yenta_socket
pcmcia_core 8446 3 pcmcia,pcmcia_rsrc,yenta_socket
processor 23837 1
button 3513 0
btrfs 555574 0
zlib_deflate 15207 1 btrfs
dm_mod 51354 1 dm_crypt
floppy 41663 0
fan 1818 0
thermal 6606 0
thermal_sys 10423 3 fan,thermal,processor
Proof that this is not an authentication issue:
$ sudo cat /var/log/dmesg |grep wlan0
[ 36.321107] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 38.921480] wlan0: authenticate with 00:xx:xx:xx:xx:xx
[ 38.971473] wlan0: send auth to 00:xx:xx:xx:xx:xx (try 1/3)
[ 38.996892] wlan0: authenticated
[ 39.000218] wlan0: associate with 00:xx:xx:xx:xx:xx (try 1/3)
[ 39.055578] wlan0: RX AssocResp from 00:xx:xx:xx:xx:xx (capab=0x411 status=0 aid=2)
[ 39.056549] wlan0: associated
[ 39.056781] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
[ 49.062856] wlan0: disassociating from 00:xx:xx:xx:xx:xx by local choice (reason=3)
[ 49.086100] wlan0: deauthenticating from 00:xx:xx:xx:xx:xx by local choice (reason=3)
[ 50.431396] wlan0: authenticate with 00:xx:xx:xx:xx:xx
[ 50.481575] wlan0: send auth to 00:xx:xx:xx:xx:xx (try 1/3)
[ 50.684150] wlan0: send auth to 00:xx:xx:xx:xx:xx (try 2/3)
[ 50.888146] wlan0: send auth to 00:xx:xx:xx:xx:xx (try 3/3)
[ 51.092212] wlan0: authentication with 00:xx:xx:xx:xx:xx timed out
$ sudo iwconfig
wlan0 IEEE 802.11bgn ESSID:off/any
Mode:Managed Access Point: Not-Associated Tx-Power=20 dBm
Retry long limit:7 RTS thr=2347 B Fragment thr:off
Encryption key:off
Power Management:off
lo no wireless extensions.
I already tried:
Installing the Linux driver from the Realtek site whilst uninstalling the linux-wlan-ng package and blacklisting the kernel's rtl8192cu module (what worked before with antiX 12M), and
Giving ipv6.disable=1 as a grub boot parameter to the kernel.
Questions
Why can the p80211 module not be found in a distribution that is supposed to be based on Debian Wheezy stable?
How do I get DHCP working for this wireless adapter?
|
FATAL: Module p80211 not found. is usually an indication that the provided driver is outdated for the used kernel.
Moreover, current version 3.4.4_4749.20121105 of Realtek's driver will not compile with the latest Linux kernels. The solution consist in installing a downgraded kernel, compiling Realtek's driver on it and blacklisting the driver provided by the downgraded kernel.
Press Ctrl+Alt+F1 to obtain a command line outside the display manager.
Execute the smxi.sh script that comes packed with Antix.
sudo smxi
For other GNU/Linux distributions, download the script from smxi.org. Follow the instructions. A dist-upgrade is not always necessary.
Choose: 6) kernel-options > 1) alternate-kernel-install
Kernel 3.6.0-11.dmz.1-liquorix-686 or lower work, kernel 3.7.0-10.dmz.1-liquorix-686 and higher do not. The latest stable kernel with long-term support that does work is 3.4.0-35.dmz.1-liquorix-686.
Be sure to reboot into the new kernel before proceeding.
This kernel can be made to boot by default; simply edit...
sudo nano /boot/grub/menu.lst
Download the RTL8192CUS Linux driver from Realtek's web site.
Extract the driver. Then, save below bash script as setup.sh in the same directory as install.sh. (I got this script from Schoelje of SolydXK-distro fame.)
#!/bin/bash
if [ $UID -ne 0 ]; then
echo "Please, type the root password..."
su -c "$0 $@"
exit
fi
apt-get install linux-headers-`uname -r`
apt-get install build-essential
rmmod rtl8192cu
chmod +x install.sh
./install.sh
echo "blacklist rtl8192cu" > /etc/modprobe.d/blacklist-rtl8192cu.conf
echo 8192cu >> /etc/modules
Make the script executable and execute it.
chmod +x setup.sh
./setup.sh
After succesfull completion of the script, issue
sudo service network restart
Your RTL8192CUS wireless adapter should now function properly.
Use the Wicd application to connect to a wireless network.
If always the same WLAN is used, one can also hardcode the security credentials in as follows:
sudo chmod 600 /etc/network/interfaces
sudo nano /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
allow-hotplug eth0
iface eth0 inet dhcp
auto wlan0
iface wlan0 inet dhcp
wpa-ssid xxxxxxxxxxx
wpa-psk xxxxxxxxxxxx
| FATAL: Module p80211 not found. RTL8192CUS WLAN regression under antiX 13.1 (Debian Wheezy) |
1,401,330,446,000 |
.config from /usr/src/linux-2.6.38.8 contains:
CONFIG_R8169=m
CONFIG_R8169_VLAN=y
What's the difference between CONFIG_R8169 and CONFIG_R8169_VLAN?
|
CONFIG_R8169_VLAN enables support for the VLAN/802.1Q code in the r8169 driver. For an introduction in VLANs see http://en.wikipedia.org/wiki/IEEE_802.1Q
A small tip for the future, if you need to determine what a specific config option in the kernel does you should have a look at the integrated help text, e.g: help text for R8169_VLAN. Sometimes it also helps to look at the driver itself and check what the config option does.
| What's the difference between CONFIG_R8169 and CONFIG_R8169_VLAN? |
1,401,330,446,000 |
Kernel module files are located in directories such as
/lib/modules/drivers/
/lib/modules/storage/
/lib/modules/fs/
they all have the extension .ko
but how does the kernel understand that a specific module file belongs to a certain type and should be in a certain directory?
|
The top-level directory for kernel modules is determined by the kernel’s reported version (as shown by uname -r): modules go in /lib/modules/$(uname -r). Modules built alongside the kernel go in a subdirectory of the kernel directory in the top-level directory; modules built later go in a subdirectory of the updates directory.
Inside those directories, kernel modules are installed according to where their source code lives in the tree. Thus all block modules are in the block directory, all fs modules are in the fs directory, etc.
To pick a specific example, /lib/modules/$(uname -r)/kernel/drivers/crypto/padlock-aes.ko is built from drivers/crypto/padlock-aes.c; it’s declared in the relevant Makefile.
Modules are found at installation time by looking for modules.order files which are generated during the build. The implementation lives in scripts/Makefile.modinst.
| How does the kernel understand that a specific module file belongs to a certain type and should be in a certain directory? |
1,401,330,446,000 |
I searched all over the internet but couldn't find proper steps to debug linux module remotely using gdb. I am tring qemu but facing many issues there. Is there any other tool that I can use or if not then can you provide me proper steps to debug linux module remotely?
|
Shouldn't be that hard. From the official kernel documentation (don't search "all over the internet". Search the official documentation and you'll find less bad information):
Have a kernel that has KGBD enabled, and also make sure that during building the config option CONFIG_GDB_SCRIPTS is on. (Refer to documentation for CentOS on how to build a kernel package; that's the easiest way)
run make scripts_gdb
Copy that kernel (vmlinux) into your host system, so that it's easy to know the kernel symbols locally
Run the Linux distro of your choice in QEMU
with QEMU's GDB stub enabled, and listening on some port, i.e., run qemu with -gdb tcp::$SOMEPORT, where $SOMEPORT is the port number you want to use (should be > 1024, < 2¹⁶). Alternatively, run with -s, which is identical to -gdb tcp::1234.
Make sure that QEMU doesn't boot the machine instantly by supplying the -S option
on the host, run gdb /path/to/the/kernel/vmlinux
in gdb, attach to your QEMU stub: target remote :$SOMEPORT.
you can now run continue to boot the VM
| How can I remotely debug linux module using GDB? |
1,401,330,446,000 |
Mostly a general linux question, but where it needs to be specific I am referencing Debian 12 Bookworm amd64 UEFI booting through grub(not direct kernel stub).
I have secure boot disabled in firmware for some multiboot reasons and I have options for signed or unsigned kernels.
Are there any negative impacts of a signed kernel, possible incompatibilities or failures to load modules?
The signed kernel is about 2% larger which is insignificant for my system.
Do use the same modules or require separate special builds?
Can I have a signed and and an unsigned one the system at the same time, similar to having an older stable and very new kernel of the same series, or regular and real-time kernels?
|
If Secure Boot is disabled, the signature on a signed kernel isn’t used, and it behaves like an unsigned kernel.
There are no incompatibilities, and you can load modules without signing them.
See above, no special build is required.
Yes, you can have unsigned kernels alongside signed kernels.
| Is there a downside to a signed kernel? |
1,401,330,446,000 |
I'm trying to get an out-of-tree kernel module working. The module is the usbtm module from Epson for their TM-70/TM-70II slip printers and the TM-S1000 cheque reader.
(The code is GPL licensed, so if you want to copy of the source, let me know, and I will share it.)
I have successfully built the module, and installed it, but it won't load:
root@GAU288888LD06 ~ # uname -rm
5.11.0-27-generic x86_64
root@GAU288888LD06 ~ # modinfo /lib/modules/5.11.0-27-generic/extra/usbtm.ko
filename: /lib/modules/5.11.0-27-generic/extra/usbtm.ko
description: EPSON USB POS Printer Driver Version 3.4 for Linux Kernel 2.6
author: EPSON Edge, Toronto
license: GPL
srcversion: CAC308CD474255ABD4753E1
alias: usb:v04B8p0202d*dc*dsc*dp*ic*isc*ip*in*
depends:
retpoline: Y
name: usbtm
vermagic: 5.11.0-27-generic SMP mod_unload modversions
root@GAU288888LD06 ~ # modprobe usbtm
modprobe: FATAL: Module usbtm not found in directory /lib/modules/5.11.0-27-generic
I don't see any error in dmesg.
Any ideas how to debug this and get it working?
(Incase you are wondering why I don't use the in-tree usblp module, this doesn't work for the cheque reader, only for the slip printers.)
|
modprobe doesn’t know about your module, which suggests that you need to run
depmod
to re-generate modules.dep.bin.
See man depmod
| Out-of-tree kernel module won't load |
1,401,330,446,000 |
I have a computer on which I've installed a custom linux system (created using Yocto). On a previous computer using this build, the network interface worked fine, but on this new computer, eth0 doesn't show at all. I know how to bring a network interface online and configure it if it's been recognized by the OS and has a name (eth0), but I don't know how to create that eth0 in the first place if it's not there.
First, I'll note that if I boot Ubuntu, it recognizes it and it works fine, so there's no hardware issue, and linux is definitely capable of working with this hardware.
Second, I can see the NIC with lspci:
root@intel-corei7-64:/etc# lspci -v -s 01:00.0
01:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 15)
Subsystem: Mitac Device 0787
Flags: fast devsel, IRQ 23
I/O ports at e000 [size=256]
Memory at 91104000 (64-bit, non-prefetchable) [size=4K]
Memory at 91100000 (64-bit, non-prefetchable) [size=16K]
Capabilities: [40] Power Management version 3
Capabilities: [50] MSI: Enable- Count=1/1 Maskable- 64bit+
Capabilities: [70] Express Endpoint, MSI 01
Capabilities: [b0] MSI-X: Enable- Count=4 Masked-
Capabilities: [100] Advanced Error Reporting
Capabilities: [140] Virtual Channel
Capabilities: [160] Device Serial Number 44-01-00-00-68-4c-e0-00
Capabilities: [170] Latency Tolerance Reporting
Capabilities: [178] L1 PM Substates
Kernel modules: r8169
Third, I believe I have the driver installed:
root@intel-corei7-64:/etc# lsmod | grep r8169
r8169 77824 0
libphy 61440 2 r8169,realtek
I'm not sure where to go from here. ip link show doesn't display the interface as an option. I'm not sure why the interface isn't being created automatically, or how to manually create it.
I'll also note that when I plug in my USB -> ethernet connector, eth0 comes online and configures correctly. But the built in NIC isn't working.
Lastly, dmesg shows a line that might be relevant, but I don't really know what it means:
igb: Intel(R) Gigabit Ethernet Network Driver - version 5.6.0-k
Also I have these messages in dmesg:
r8169 0000:01:00.0: enabling device (0000 -> 0003)
r8169: probe of 0000:01:00.0 failed with error -5
r8169: probe of 0000:01:00.0 failed with error -5
Any ideas of how I get this NIC online?
|
I upgraded to the latest version of yocto, which includes the 5.10 linux kernel. I don't know exactly what fixed it, but it's working now. Not a satisfying fix, but it works.
| How do I make Linux aware of a network interface? |
1,401,330,446,000 |
I am tring to install nvidia driver by the following command.
sudo ./NVIDIA-Linux-x86_64-418.43.run --dkms -s
Here I got an error as follows.
ERROR: Failed to run `/sbin/dkms build -m nvidia -v 418.43 -k 3.10.0-1062.el7.x86_64`: Error! echo
Your kernel headers for kernel 3.10.0-1062.el7.x86_64 cannot be found at
/lib/modules/3.10.0-1062.el7.x86_64/build or /lib/modules/3.10.0-1062.el7.x86_64/source.
You can use the --kernelsourcedir option to tell DKMS where it's located.
ERROR: Failed to install the kernel module through DKMS. No kernel module was installed; please try installing again without DKMS, or check the DKMS logs for more
information.
However, /lib/modules/3.10.0-1062.el7.x86_64/build and /lib/modules/3.10.0-1062.el7.x86_64/source are both in my /lib/modules path.
# cd /lib/modules/3.10.0-1062.el7.x86_64
# ls -la
lrwxrwxrwx. 1 root root 39 7月 2 11:11 build -> /usr/src/kernels/3.10.0-1062.el7.x86_64
lrwxrwxrwx. 1 root root 5 7月 2 11:11 source -> build
I have tried sudo yum install "kernel-devel-uname-r == $(uname -r)" in a similar question which doesn't work, it said
No package kernel-devel-uname-r == 3.10.0-1062.el7.x86_64 available
This is my output of uname -r
3.10.0-1062.el7.x86_64
And this is the kernel related packages
kernel.x86_64 3.10.0-1062.el7
kernel.x86_64 3.10.0-1160.31.1.el7
kernel-devel.x86_64 3.10.0-1160.31.1.el7
kernel-headers.x86_64 3.10.0-1160.31.1.el7
How can I solve this?
|
The simplest option would appear to be a reboot, so that the running kernel matches the installed headers (1160.31.1).
Otherwise you’d have to find the header package for your older kernel (1062).
| Your kernel headers for kernel 3.10.0-1062.el7.x86_64 cannot be found |
1,401,330,446,000 |
I've this script which checks for a veth-pair and setup an ifb device on it, but everytime it says cannot find free ifb device for that particular veth pair.
What could be the problem? Even I tried running modprobe command which by default creates two ifb, then also it throws the same error.
#return 0 if the ifb is free
check_ifb()
{
local installed=`nl-qdisc-list -d $1`
[ -n "$installed" ] && return 1
return 0
}
setup_ifb()
{
for ifb in `ifconfig -a -s|egrep ^ifb|cut -d ' ' -f1`
do
check_ifb "$ifb" || continue
IFB="$ifb"
break
done
if [ -z "IFB" ]
then
echo "Unable to find a free ifb device for $vifname"
exit -1
fi
ip link set dev "IFB" up
if [ $? -ne 0 ]
then
echo ip link set dev "IFB" up failed
exit -1
fi
}
|
By default, two ifb interfaces are created when loading the ifb kernel module. This is for obsolete reasons, the same way two dummy interfaces are created when loading the dummy kernel module. Those interfaces are created in the initial network namespace. For example if the system is inside a container or simply a (non initial) network namespace, no ifb interface will exist here.
Don't load the module and hope to get ifb interfaces. Do it the other way around: create an ifb interface, and if needed the kernel module will get loaded anyway. Don't rely anymore on ifconfig which on Linux is now an obsolete tool.
Example:
ip link add name newifbdev type ifb
ip link set dev newifbdev up
You now have an ifb interface called newifbdev up and available for tc-mirred packets.
This would even work inside a user namespace started for example with unshare -U -r -n, despite the inability to manually load the ifb kernel module from such user namespace. If not already loaded, the module will still be indirectly loaded by the creation of the interface (and with default settings, two additional ifb interfaces will also appear in the initial namespace as a side effect).
| modprobe cannot load ifb devices |
1,401,330,446,000 |
I am writing a LKM to create a character device driver.
Linux Kernel: 4.4.0-93-generic in VirtualBox, 2GB ram and SWAP is 300Kb
Problem 1
If I write a C program that handles the fd in dev_write, it's all good, it reads as it should, but if I try to use head -n 1 < /dev/opsysmem it does not output anything.
Code for reading from device:
int main()
{
int ret, fd;
char stringToSend[BUFFER_LENGTH];
printf("Starting device test code example...\n");
fd = open("/dev/opsysmem", O_RDWR); // Open the device with read/write access
if (fd < 0)
{
perror("Failed to open the device...");
return errno;
}
printf("Press ENTER to read back from the device...\n");
getchar();
printf("Reading from the device...\n");
ret = read(fd, receive, BUFFER_LENGTH); // Read the response from the LKM
if (ret < 0)
{
perror("Failed to read the message from the device.");
return errno;
}
printf("The received message is: [%s]\n", receive);
return 0;
}
Problem 2
If I repeatedly send a message big enough, everything is fine, my 2MiB buffer fills up and then the following messages are discarded. However, if the message is smaller (i.e 1 char each), it stops after about 10000 nodes. Is this a problem with my implementation of the linked list, a known linux problem or it's just me not observing something in my code?
When I encounter Problem 2, the vCPU throttles in sinusoidal manner
Here are my functions for read, write:
static ssize_t dev_read(struct file *filep, char *buffer, size_t len, loff_t *offset) {
Node *msg;
int ret_val;
char* message;
unsigned int message_length;
// Entering critical section
down(&sem); //wait state
msg = pop(&l, 0);
// No message? No wait!
if(!msg) {
up(&sem);
return -EAGAIN;
}
if(len < msg->length) {
up(&sem);
return -EINVAL;
}
// Since we have a message, let's send it!
current_size -= message_length;
// copy_to_user has the format ( * to, *from, size) and returns 0 on success
ret_val = copy_to_user(buffer, msg->string, message_length);
if (!ret_val) {
remove_element(&l, 0);
up(&sem);
return ret_val;
} else {
up(&sem);
return -EFAULT; // Failed
}
}
static ssize_t dev_write(struct file *filep, const char *buffer, size_t len, loff_t *offset) {
Node *n;
// buffer larger than 2 * 1024 bytes
if(len > MAX_MESSAGE_SIZE || len == 0) {
return -EINVAL;
}
n = kmalloc(sizeof(Node), GFP_KERNEL);
if(!n) {
return -EAGAIN;
}
n->string = (char*) kmalloc(len, GFP_KERNEL);
n->length = len;
copy_from_user(n->string, buffer, len);
// Enter critical section
down(&sem); //wait state
if(SLEEP) msleep(100);
// buffer is larger than the total list memory (2MiB)
if(current_size + len > MAX_LIST_SIZE) {
up(&sem);
return -EAGAIN;
}
current_size += len;
push(&l, n);
up(&sem);
// Exit critical section
return len;
}
And here is my linked list and its functions
typedef struct Node {
unsigned int length;
char* string;
struct Node *next;
} Node;
typedef struct list{
struct Node *node;
} list;
static void init(list * l){
l->node = NULL;
}
static void destroyNode(Node *n) {
if(n) {
destroyNode(n->next);
kfree(n->string);
n->string = NULL;
kfree(n);
n = NULL;
}
}
static void destroy(list *l){
if(l) {
destroyNode(l->node);
}
}
static Node* pop(list *l, unsigned int index) {
struct Node *_current = l->node;
// Cut down index until reaching the desired position
while(_current) {
if(index) {
_current = _current->next;
index--;
} else { return _current; }
}
// If you are here, the node does not exist
return NULL;
}
static int push(list * l, Node *n) {
if(!n) { return -1; }
// Initialize the string
// Do we have a node in the list?
if (l->node) {
// Virtually add it as a head
n->next = l->node;
} else {
n->next = NULL;
} // Otherwise prepare the list to have no tail
// Now make the list point to the head
l->node = n;
return 0;
}
static int remove_element(list * l, unsigned int index){
// Get the reference for head
struct Node *previous;
struct Node *_current;
previous = NULL;
_current = (Node*) l->node;
// Swap _current until index
while(_current) {
// Is the index !0 and we have more nodes?
if(index) {
previous = _current;
_current = _current->next;
index--;
} else {
if(previous) {
previous->next = _current->next;
} else {
l->node = _current->next;
}
// Free memory, assign NULL pointer
kfree(_current->string);
_current-> string = NULL;
kfree(_current);
_current = NULL;
// Return success
return 0;
}
}
// No _current? No problem!
return -1;
}
Update on __ Problem 2 __
I tried different sizes for the input string and I found this:
After about 650 calls to the device driver, with a size of 3.3k, the message list size becomes 4MiB (which is the maximum). A few more calls are made to the device and then the kernel freezes.
EDIT 1: I updated te dev_write as per comment and deleted debug code
EDIT 2: Added some more functions: push/pop/destroy
EDIT 3: I put in the check for buffer length vs message length
|
I think Problem 1 may be either because head is not seeing an end-of-line character (e.g. newline,'\n'), or it uses seek system calls and you ignore the offset argument in your dev_read() and dev_write() functions (which means seeks won't work, if I understand it correctly) ... check this out - head does try to optimise things using seeks, but not sure if it applies in your case.
Also not sure your answer about Problem 2 being caused by time being out of sync is correct (unless it has something to do with msleep()) ... my guess would be memory allocation problems or a race condition but you don't show us the source code for push() and pop() so we can't tell.
It looks like you just store the buffer and len arguments from dev_write() and then use them in dev_read() to pass to copy_to_user() ... the data in that buffer will still be in user space, so you could be attempting to copy from user space to user space. Reading this might help.
You should update your question with the code of push() and pop() ... but at a minimum push() will need to allocate memory for both a linked list element to be inserted in the list and for a buffer to hold the write data, then use copy_from_user() to get the data out of user space and into the kernel buffer ... and then, after you have finished with msg in dev_read(), you will need to free the kernel buffer contained in msg and then free msg itself.
A lot of copying going on here I know, but to avoid this you have to work very hard with the virtual memory system and the design of your code (i.e. a Zero Copy implementation).
One more small but very important thing, in dev_read() you don't check that message_length is <= len i.e. that there is enough space for the message in the buffer. For example, as your code stands, your driver potentially could try to copy a message bigger than the space available. copy_to_user() should catch this, but then again maybe this is the source of your Problem 2.
| Linux character device driver issues |
1,401,330,446,000 |
Understanding the Linux Kernel says
The kernel has two key tasks to perform in managing modules. The first task is mak-
ing sure the rest of the kernel can reach the module’s global symbols, such as the
entry point to its main function. A module must also know the addresses of symbols
in the kernel and in other modules. Thus, references are resolved once and for all
when a module is linked. The second task consists of keeping track of the use of
modules, so that no module is unloaded while another module or another part of the
kernel is using it. A simple reference count keeps track of each module’s usage.
Is it correct that any shared library can be both dynamically linked (using LD_LIBRARY_PATH), and dynamically loaded (by dlopen(), dlsym() and dlclose())?
Is a module a shared library to the Linux kernel?
How does Linux kernel dynamically use a module? Is it by dynamic linking (using LD_LIBRARY_PATH), or dynamic loading (by dlopen(), dlsym() and dlclose())?
|
Is it correct that any shared library can be both dynamically linked (using LD_LIBRARY_PATH), and dynamically loaded (by dlopen(), dlsym() and dlclose())?
Yes. The difference is that dynamic linking is driven by the dynamic linker, and by the time the program starts (from the program author’s perspective), the libraries have been linked and all the symbols have been resolved; dynamic loading involves doing all that manually.
Is a module a shared library to the Linux kernel?
More or less, but the loading mechanisms are different. The dynamic linker, and libdl, are user-space only, they can’t be used in the kernel.
How does Linux kernel dynamically use a module? Is it by dynamically linking (using LD_LIBRARY_PATH), or dynamical loading (by dlopen(), dlsym() and dlclose())?
The kernel loads modules using load_module, which does all the work itself: loading the ELF object, mapping the required segments, performing all the relocations, etc. It also performs a few module-specific tasks: checking their license, hooking them into sysfs, calling their initialisation function...
load_module is accessed from user space using the init_module or finit_module system calls.
| How does Linux kernel dynamically use a module? |
1,401,330,446,000 |
So I'm trying to get Vuurmuur installed on a headless linux box that I've been using as a home router. So far, I've been using iptables but wanted to switch to using something more convenient/easier to use.
SERVER SETUP
I'm running:
Ubuntu 16.04.3 LTS Xenial
4.4.0-97-generic #120-Ubuntu SMP Tue Sep 19 17:28:18 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
VUURMUUR SETUP
Vuurmuur doesn't have a debian package maintainer so I added this entry to my apt sources:
deb ftp://ftp.vuurmuur.org/ubuntu/ raring main
Do an apt-get update, install vuurmuur and things look ok BUT when I try to run vuurmuur this happens:
# vuurmuur
Error: checking for iptables-capabilities failed. Please see error.log.
I checked the documentation here: https://www.vuurmuur.org/trac/wiki/Faq
and that suggests that iptables or conntrack is not setup correctly
For completeness, this is the error in the error log:
01/04/2018 13:57:18 : PID 1866 : vuurmuur : Error (-1): no connection tracking support in the kernel (in: check_iptcaps:402).
I did a lsmod for iptables and conntrack and they both seem to be there:
# lsmod | egrep "iptable|conntr"
nf_conntrack_netlink 40960 0
nfnetlink 16384 2 nf_conntrack_netlink,nfnetlink_queue
iptable_mangle 16384 0
xt_conntrack 16384 2
iptable_filter 16384 1
iptable_nat 16384 1
nf_conntrack_ipv4 16384 3
nf_defrag_ipv4 16384 1 nf_conntrack_ipv4
nf_nat_ipv4 16384 1 iptable_nat
nf_conntrack 106496 9 xt_helper,nf_nat,xt_state,nf_nat_ipv4,xt_conntrack,nf_nat_masquerade_ipv4,nf_conntrack_netlink,xt_connmark,nf_conntrack_ipv4
ip_tables 24576 3 iptable_filter,iptable_mangle,iptable_nat
x_tables 36864 20 xt_mark,xt_helper,xt_length,ip_tables,xt_tcpudp,ipt_MASQUERADE,xt_NFQUEUE,xt_limit,xt_state,xt_conntrack,xt_LOG,xt_mac,xt_nat,iptable_filter,xt_CLASSIFY,xt_TCPMSS,xt_connmark,ipt_REJECT,xt_REDIRECT,iptable_mangle
WHAT AM I MISSING?
I've seen some other posts that the way conntrack is enabled has changed in the past so I'm wondering if between Raring and Xenial, the method to check for iptables/conntrack changed but vuurmuur hasn't been updated yet.
Thanks,
Alex
|
So turns out their are two options:
Option 1
Run the vuurmuur command with the below option:
-t
Option 2 (what I did)
Use the 0.8rc5 version from the Vuurmuur website and I was able to start Vuurmuur.
| How to resolve "no connection tracking support in the kernel" in Vuurmuur? |
1,513,088,334,000 |
I have installed the Debian Jessie (8) using the Parallels desktop in the MacBook Pro host. It goes fine for some time and now I keep getting message,
some of the required kernel modules are missing. To solve this problem, please try to reinstall Parallels Tools using the virtual machine menu
How do I install the required kernel modules?
|
Have you tried reinstalling Parallels Tools like the message says? That would seem to fix the problem you're having.
| Debian Jessie (8) using the Parallels desktop |
1,513,088,334,000 |
Is it technically possible to write a kernel module to physically connect a PS/2 keyboard to a USB port using a passive converter? If not, why?
(If I simply wanted my keyboard to work I would buy an active adapter, but the purpose of this question is to learn something)
|
No.
No USB standard implements backwards compatibility with PS/2. PS/2 mice which predate USB do not contain time-travelled USB descriptors. Nor can an arbitrary USB port be accessed as a GPIO.
USB descriptors: https://blog.digital-scurf.org/posts/stm32-and-rtfm/
https://en.wikipedia.org/wiki/Gpio & https://en.wikipedia.org/wiki/Bit_banging
(Wiki links aren't going to be great, but the introductions here should give the idea).
Converting the opposite way round, passive USB to PS/2 converters require USB support in the USB input device, and recent USB devices don't bother with it: https://en.wikipedia.org/wiki/PS/2_port#Conversion_between_PS.2F2_and_USB
| Kernel module to connect ps/2 keyboard to usb? |
1,513,088,334,000 |
I have an issue trying to build kernel and modules for an embedded system. The resulting Module.symvers has some (a few dozen) entries with invalid (0x00000000) CRC entries.
I'm trying to figure out the process by which Module.symvers is generated so that I can start debugging the problematic entries. However, after looking at the build process for a few hours, I still can't figure out what generates Module.symvers.
N.B. - I am looking for the code that actually creates the contents of Module.symvers, not for instructions to "make modules" ;-)
I suspect that the breakage is due to building Linux 3.4.12 with GCC 6.3, but I need to get it working with that config. Disabling modvers is not an option, because I need to load 3rd party binary blob modules.
|
The creation of Module.symvers has a number of steps. These steps make use of MODVERDIR (typically .tmp_versions in the build directory) which contains .mod files,
After the modules are compiled and corresponding .o files are generated, the source is pushed through the C pre-processor with -D__GENKSYMS__ and the resulting output is piped into scripts/genksyms. genksyms implements it's own (relatively simple) code parser to generate symbol signatures and their corresponding CRCs. It was the limitations in this parser that prevented genksyms from correctly parsing source when using gcc 6.3 on kernel 3.4. (I solved my issue by backporting kernel 4.12 genksyms). genksyms will produce a .mod.c file for each module that contains all the symbol CRCs. This is then compiled to produce .mod.o files.
The final step involves parsing all the *.mod files in MODVERDIR, examining these for all the .ko files that make up the modules and passing the corresponding list of .mod.o files, together with vmlinux to scripts/modpost. scripts/modposts parses the object files and generates Module.symvers.
| How is Module.symvers generated? |
1,513,088,334,000 |
I updated the database pacman -Syy and update all packages pacman -Su. Then I checked the upgraded packages
cat /var/log/pacman.log | grep -i upgraded
[2017-07-14 14:21] [ALPM] upgraded linux (4.11.7-1 -> 4.11.9-1)
Somewhere during installation I read that probably I have to re-run mkinitcpio -p linux if the package was upgraded. Is it still relevant?
|
Assuming you are using the upstream kernel packages, and you haven't manually reconfigured pacman, then you shouldn't need to.
You can easily check though by seeing what the timestamp on /boot/initramfs-linux.img is, if it's newer than /boot/vmlinuz-linux.img, then the initramfs was updated, and you don't have to manually update it.
| mkinitcpio generation after update |
1,513,088,334,000 |
I want to build latest (4.7.4) kernel with make-kpkg. Also I want to make it as modular as possible. Will it compile modules too or should I run 'make modules' before?
Thanks.
|
Yes it will compile modules. Please refer to http://man.he.net/man1/make-kpkg .
| Will make-kpkg compile modules too? |
1,513,088,334,000 |
I need to use this drivers in a Linux based system that is highly customized and so I'd like to know if there is a way of having this pieces just ready to be manually installed and/or used.
In other terms I need the *.so libraries and the kernel module.
|
First download the ATI binary driver for linux,
If you do ./ati-XX.run --help you could see a lot of options, IIRC, there's an --extract option that will extract everything inside to a folder, which contains:
Kernel module (fglrx) source code
fglrx opengl library (binary)
| Extracting only the module and the libraries from the AMD ATI proprietary drivers |
1,513,088,334,000 |
I'm in the process of installing iptables onto an embedded Debian 8.7 armhf machine that does not have access to the internet. My method has been to manually find the .deb package files from the Debian archives, and then FTP those over to the Debian 8.7 machine and run dpkg.
After a bit of struggling, I was seemingly able to install the iptables .deb package and all of its dependencies. However, when I start trying to use iptables I get the following error:
modprobe: FATAL: Module ip_tables not found.
iptables v1.6.0: can't initialize iptables table `filter': Table does not exist (do you need insmod?)
When running lsmod I can in fact see that the module ip_tables is not loaded or even installed on my machine (I can't find the .ko's anywhere on my machine).
So I'm curious - should the dpkg of iptables have installed the iptables kernel modules? Or does dpkg only handle the user space configuration? Note - I don't believe my kernel version would have iptables already compiled into it.
|
dpkg installs whatever is provided in the packages it’s given, and runs the maintainer scripts included in the packages.
In iptables’ case, the iptables command itself takes care of loading the relevant kernel modules. However the kernel modules need to be available — that’s usually taken care of by the kernel package, but on embedded systems it’s also fairly common to find custom kernels which might not have all the required modules, or where the modules need to be installed in some platform-specific way.
Depending on your exact system, you might be able to install the Debian kernel (linux-image-3.16.0-6-armhf); if you can boot with that, it will provide the iptables modules.
| Should 'dpkg -i iptables' be installing the required kernel modules? |
1,513,088,334,000 |
I build and test a linux kernel source (rolling-stable) for fun, these days, I would like to sign a kernel module with self-created key, then I got the engine PKCS#11 on OpenSSL is used to sign it.
However there is a problem that OpenSSL fails to request a key/certification. So I confirm with pkcs11-tool, but it results "No slots."
Does this mean I should have slot involved in Smart card? Else, how do I sign kernel modules?
Following is openssl.cnf digested
# referenced from the [provider_sect] below.
# Refer to the OpenSSL security policy for more information.
# .include fipsmodule.cnf
[openssl_init]
providers = provider_sect
ssl_conf = ssl_sect
engines = engine_section
[engine_section]
pkcs11 = pkcs11_section
[pkcs11_section]
engine_id = pkcs11
dynamic_path = /usr/lib/x86_64-linux-gnu/engines-3/pkcs11.so
MODULE_PATH = /usr/lib/x86_64-linux-gnu/opensc-pkcs11.so
init = 0
# List of providers to load
[provider_sect]
And I tried googling for a day, but I found only about enterprise, cloud....; not useful.
|
In the scripts sub-directory of the Linux kernel source package, there is a sign-file tool (used to be a script, now a binary tool, built along with the kernel).
Example: linux-6.6.13/scripts/sign-file
You can use it to sign kernel modules:
/path/to/linux-6.6.13/scripts/sign-file sha256 private-key.pem certificate.der kernelmodule.ko
Or if you have both the private key and the certificate in a single file in PEM format, you can set the kernel configuration option CONFIG_MODULE_SIG_KEY (in config menu Cryptographic API -> Certificates for signature checking -> File name or PKCS#11 URI of module signing key) to point to the file, and set CONFIG_MODULE_SIG_ALL=y (in config menu Enable loadable module support -> Automatically sign all modules), then the kernel build process will automatically sign all modules within that kernel build with the key of your choice.
You can create a suitable key-and-certificate file with e.g.:
openssl req -new -nodes -utf8 -sha256 -days 36500 -batch -x509 \
-config x509.genkey -outform PEM -out kernel_key.pem \
-keyout kernel_key.pem
If you want to use the sign-file tool too, you can convert the certificate part to the DER format with:
openssl x509 -in kernel_key.pem -out certificate.der -outform DER
See Documentation/admin-guide/module-signing.rst in the kernel source package for more details.
Using PKCS#11 (and by extension, smart cards or other hardware security modules) is not necessary for kernel module signing.
However, if you create your own Linux distribution and start publishing it world-wide in any significant numbers, using a PKCS#11 security module to hold your release signing keys for added security would be a very good idea.
| Should am I need a pysical Smart Card and its reader device to sign linux kernel module? |
1,513,088,334,000 |
I have an Open SUSE micro OS host with kernel 6.5.9-1-default and an Ubuntu 22.04 distrobox container.
I need to install the linux-headers-$(uname -r) and linux-modules-extra-$(uname -r) packages and the problem is that Ubuntu 22.04 at the time I'm writing doesn't have these packages, their most recent kernel is 6.2.
So, how can I install these Linux headers and modules extra on my Ubuntu 22.04 container?
|
Ultimately, you’ll need to load your modules into the host kernel, so you need to build them with the host’s configuration exactly. Even finding a matching kernel in your Ubuntu container wouldn’t help, you need the headers matching the host’s kernel and configuration.
I don’t know whether micro OS even supports this, its web site is currently down for maintenance.
| Linux header and extra modules on ubuntu container from an open suse micro os host with mismatch kernel versions |
1,513,088,334,000 |
I bought a modern laptop which seems to lack a hardware speaker. Is there some kernel module to simulate it over ALSA instead or so? I could find only some very old patched modules from late 90s which barely work on modern kernel versions already.
|
I had the same sort of problem with a cheap amd mini pc. I am getting old and my eyesight is poor so I like the beep when editing or using a terminal. When I snooze onto the keyboard the beeping can wake me :)
After discussion with bodqhrohro he suggested I should answer his question here. I found two solutions, but neither is perfect.
I searched for a way to get beeping back. Lennart Poettering wrote softbeep in 2002 using an LD_PRELOAD approach. I tried and it didn't work well for me.
I then found https://github.com/mozzwald/Fancy-Beeper-Daemon and after patching and testing wrote an arch linux AUR to build it as a dkms module.
https://aur.archlinux.org/packages/fancybeep-dkms
I added a simple alsa beep program to create a reasonable beep. This approach works, but because the daemon hangs on one of the module created devices (/dev/beep) modprobe -r fancybeep fails because the module is busy. So you have to kill the userspace beep daemon first.
I changed the daemon to beep when signalled with SIGUSR1 and eliminated the extra device /dev/beep. The module has a parameter that the daemon can post its PID to. The module can then just signal the daemon when it wants a beep to be sounded. This approach https://aur.archlinux.org/packages/alsabeep-dkms also works, but obvously is a bit unsafe as if the daemon is killed without clearing the module's PID parameter the module is left signalling a PID that is out of date and could be a future problem.
I imagine the correct approach would be a module that starts off the daemon directly it could either obtain the PID and use a signal or use netlink to request a beep. I'm not enough of a kernel person to figure out exactly how to do that.
| How to simulate a PC speaker? |
1,513,088,334,000 |
I am running Devuan 3.1.1 32-bit (Debian based) with kernel 4.19 on an old PC and trying to install proprietary Nvidia drivers. The latest version of the driver for the FX 5200 is version 173.14.39.
I have tried two methods for installing Nvidia drivers on my machine. The first is using the .run installer file directly from Nvidia's website. The second is using a nvidia-173_*.deb package file from Ubuntu package archives and installing it with dpkg.
I made sure to blacklist the nouveau driver in /etc/modprobe.d/ by creating a file named blacklist-nouveau.conf and putting blacklist nouveau and options nouveau modeset=0 in that file.
.run file method
I installed these packages as a prerequisite for running the installer: linux-headers-4.19.0-21-686 make automake gcc g++. I also installed some extra packages because in some installation instructions for Nvidia drivers I came across while searching for a solution said to install them and I figured it can't hurt to have them: pciutils elfutils libglvnd-dev build-essential.
I downloaded the .run file from here and ran it with sudo sh NVIDIA-Linux-x86-173.14.39-pkg1.run.
The installer runs for about 2 minutes before giving this error in /var/log/nvidia-installer.log.
The error log file says I should run make oldconfig && make prepare on the kernel source to fix the issue, so I tried running make oldconfig && make prepare in every subdirectory in /usr/src, the directory which contains linux-headers-4.19.0-21-686 and linux-headers-4.19.0-21-common. Running in any of these directories gives me this error;
scripts/Makefile.build:45: scripts/basic/Makefile: No such file or directory
make[1]: *** No rule to make target 'scripts/basic/Makefile'. Stop.
make: *** [Makefile:484: scripts_basic] Error 2
and the Nvidia installer still fails.
dpkg method
I added deb [allow-insecure=yes] http://us.archive.ubuntu.com/ubuntu/ trusty main to /etc/apt/sources.list to access Ubuntu 14.04 Trusty Tahr software repositories because the nvidia-173 driver is in those repositories. (yes I am aware that this is very dumb but I am trying everything)
I ran sudo apt install nvidia-173 and received this error:
Package nvidia-173 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or is only available from another source
E: Package 'nvidia-173' has no installation candidate
I found an archive of a nvidia-173_*.deb installer file and downloaded it.
I ran dpkg -i nvidia-173_173.14.39-0ubuntu4_i386.deb and it gave an error saying it had these dependencies that needed to be installed; dkms acpid xorg-video-abi-15 and "broke" apt, so I "fixed" it by running apt --fix-broken install.
dkms and acpid installed, but when I tried to run sudo apt install xorg-video-abi-15 it gave me this error:
Package xorg-video-abi-15 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or is only available from another source
E: Package 'xorg-video-abi-15' has no installation candidate
I was unable to find an archive of xorg-video-abi-15.
When I tried to run dpkg -i nvidia-173_173.14.39-0ubuntu4_i386.deb it gives me this error:
dpkg: dependency problems prevent configuration of nvidia-173:
nvidia-173 depends on xorg-video-abi-11 | xorg-video-abi-12 | xorg-video-abi-13 | xorg-video-abi-14 | xorg-video-abi-15; however;
Package xorg-video-abi-11 is not installed.
Package xorg-video-abi-12 is not installed.
Package xorg-video-abi-13 is not installed.
Package xorg-video-abi-14 is not installed.
Package xorg-video-abi-15 is not installed.
dpkg: error processing package nvidia-173 (--install):
dependency problems - leaving unconfigured
Errors were encountered while processing:
nvidia-173
So, any ideas?
|
I have the misfortune to be very well versed in this issue.
The first, and correct, solution, is to use nouveau free driver.
Legacy means legacy, and EOL means EOL
While you didn't list your system specs or Xorg version, here's the basic cutoff points of 173.14.39 (the last of the 173.xx.xx series):
Last X.org version supported: 1.15
Last kernel supported: 3.12
These are not negotiable items, if you run newer than X.org 1.15 or kernel 3.12, you cannot use the 173.xx driver, period.
So there's no need to waste your time trying to get something that can't run in the modern era running.
the FX 5xxx cards were EOL around 2005. While nvidia does a quite decent job supporting their legacy cards, support tends to run out somewhere between 5 and 10 years, depends.
304.xx series card non free drivers maxed at 4.13 kernel and xorg 1.19. Those are also EOL.
340.xx maxed at 5.4, and are also EOL. Those were made up to 2013, and I think had about 7 or 8 years? of support.
Short story is simple:
If you buy a reasonably modern radeon (1+ GiB ram) or amdgpu supporting AMD card, used, you will be happy, but if you try to run nouveau, you may not be as a happy because it's buggy and inconsistent. I tried it for a while but too much stuff was glitchy, crashed, failures to wake from suspend, etc.
I ran nvidia until 340.xx went EOL with current kernels, then bought some used AMD cards and haven't had any graphics issues since then. Those were well spent $20 per card in my opinion.
Using Nouveau
Your old hardware is more likely to have ok nouveau support than newer cutting edge stuff, but it really varies, nouveau is entirely reverse engineered by non nvidia people, who have done good work, but they don't have specs so it's very difficult for them.
The real question is why a Devuan user even thought trying to use EOL legacy non free nvidia drivers was even an idea worth trying in the first place.
Non free means something, it means nobody has access to the source code of legacy eol drivers, so they can't be updated or fixed or patched, they are binary blobs, period. Sometimes you can do light patching if you know how to do it, but you can't make a kernel or xorg that isn't supported at all work.
| Installing Legacy Nvidia Drivers for FX 5200 |
1,513,088,334,000 |
I have fedora.
I installed incompatible drivers: "sudo dnf install broadcom-wl" and restarted linux. Now i am stuck in emergency mode with shell
I tried removing driver module, but for some reason, lsmod | grep wl does not sees this module, so i can not remove it, hence i am stuck in emergency mode. Please help
EDIT:
Here are systemctl logs
I tried grepping other names related to broadcom:
"bcm43xx, ssb, b43, ndiswrapper, bcma, broadcom, wl", did not find anything
|
Removing driver by "dnf remove broadcom-wl" and then doing "dracut --regenerate-all" did not seem to do anything.
Fixed it by simply chrooting into os from live cd and restoring my timeshift snapshot, sorry.
| Uninstalling broadcom-wl driver: Now stuck in emergency mode |
1,513,088,334,000 |
I had to move from Jessie to Stretch as kernel 5.15.49 requires gcc 5.x version (Jessie had 4.9 version Stretch 6.x). I decided to try the ZSTD module compression option in 5.15.x. I ensured to apt-get install zstd beforehand.
Using make bindeb-pkg it gets all the way past compiling and signing the modules but then errors out and you can see on the screen the zstd output saying incorrect parameters then giving a sample of what the parameters should be. So clearly it's executing the compressor but it doesn't like whatever parameters kbuild is sending it?
Is this a known issue? Is there an easy fix for this?
TIA!!
|
Debian Stretch has zstd version 1.1.2, which lacks support for the -T0 option which the kernel uses (it instructs zstd to use all available cores).
-T0 can be dropped without adversely affecting the build (other than the time taken to compress the modules); edit scripts/Makefile.modinst and remove -T0 from cmd_zstd.
Note that Debian Stretch is about to drop out of long-term support (on June 30); if you want to continue using it, you should consider Extended LTS.
| Using Debian Stretch to build 5.15.x kernel with zstd compression fails with incorrect parameters |
1,513,088,334,000 |
This video shows an example Raspberry Pi Linux kernel module which creates a new character device. It uses the kernel API register_chdev. In a comment to the video (I can not generate a direct link to it), as regards the return value of register_chdev, the author states:
If the return value is not equal to 0, the device number is already in use. The upper 12 bits of the return value are your major device number, the lower 20 bits are the minor device number.
I guess that by "the device number is already in use" he means "the non-zero major device number arbitrarily chosen in the kernel module is already in use".
Despite several webpages deal with this (the official one, then this one and this one), I did not find any information about this internal subdivision of the return value.
If I choose to create (with my kernel module) a device with a major number already in use, the kernel does never accept it and refuses to register the device. This occurs both when the major number I chose is the same as the one of a block device, and when the major number I choose is the same as the one of a character device. register_chdev always return a negative value. In the latter case, instead, I was expecting a positive non-zero return value, with the upper 12 bits representing the major device number, and the lower 20 bits representing the minor device number (maybe greater than 0: if the major number was already used, maybe the system already had at least a device related to it, with the minor number 0).
Is it true what is stated in the Youtube comment? Where can I find some documentation about it?
I'm running Raspbian 10, uname -a shows:
Linux raspberrypi 5.10.63-v7+ #1459 SMP Wed Oct 6 16:41:10 BST 2021 armv7l GNU/Linux
|
register_chrdev itself isn’t documented in the kernel, but its definition is short:
static inline int register_chrdev(unsigned int major, const char *name,
const struct file_operations *fops)
{
return __register_chrdev(major, 0, 256, name, fops);
}
which basically means it calls __register_chrdev to register a major with a full range of minors (256 minors starting at 0), and return that function’s result. The latter is documented as
If major == 0 this functions will dynamically allocate a major and return its number.
If major > 0 this function will attempt to reserve a device with the given major number and will return zero on success.
Returns a -ve errno on failure.
There’s no provision for returning minors, encoded or otherwise. The purpose of these functions is to register a major in any case, potentially with a subset of minors; not a single minor.
The encoding comes into play when the device driver handles an open call, or any other time it needs to determine what minor (and perhaps major, if it handles multiple majors) a given device corresponds to. A driver is given the inode it’s asked to handle; for a device node, that includes the device number, which encodes the major and minor. The MAJOR and MINOR macros, or starting from an inode, the imajor and iminor functions, should be used to extract the values.
Some character devices offer multiplexing on top of the major registration mechanisms described above; see How does one misc driver control all this different hardware? for an example of this.
| Linux kernel register_chdev returned value |
1,513,088,334,000 |
Im having trouble with my Debian 11 install reverting back to 3.5mm analog audio output, though HDMI is plugged in and where I want the audio to come out of. Debian GUI has no stock way to disable a output device. Normally the setting in sound area sticks, but recently not always.
Its even tricky to do it with CLI via alsa or pulse tools, as we are not dealing with different audio cards, as most examples online deal with, but both HDMI output and Analog output are different devices of the one HDA Intel PCH device.
This is the results of aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC662 rev3 Analog [ALC662 rev3 Analog]
Subdevices: 0/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0]
Subdevices: 1/1
Subdevice #0: subdevice #0
|
My approach to solving this was to disable the module/drivers related to the ALC662 device, and luckly this worked while leaving the HDMI sound working still.
First I tried what you will find many examples of, which is adding "blacklist [module_name]" into a .conf file in /etc/modprobe.d/
I found this worked on some one level of the sound modules but not all. It worked on snd_hda_codec_realtek, but this was not enough, as then ALC662 reverted back to Generic, and putting blacklist snd_hda_codec_generic did not work.
The trick was to also block loading snd_hda_codec_generic with this line in the .conf as well.
blacklist snd_hda_codec_generic
install snd_hda_codec_generic /bin/false
alternatively just renaming /lib/modules/5.10.0-8-amd64/kernel/sound/pci/hda/snd-hda-codec-generic.ko (found by /usr/sbin/modinfo snd_hda_codec_generic) worked, but the above seemed a little less savage and easier to find in the future should someone wonder why analog sound isnt working if they need it.
| Disable Analog Audio, Force Default HDMI Audio - Disable / Blacklist snd_hda_intel Module |
1,513,088,334,000 |
I'm learning driver development and according to the book I read, all Linux devices of same type have same major number are controlled by same driver so for example if we have a computer with multiple UART physical ports all of them will have same major number but different minor number which the driver will interpret as different physical ports. My question is that according to this link misc devices (major number 10) are many and my PC confirms this, so my question is that how can one driver control all these different devices(there are many of them virtual). Is there one level of redirection in which when i open a device the Kernel have registered this major number already and according to minor number the kernel registered driver calls the driver responsible to this minor number(the one I wrote), or when I open the device file my registered driver will be the one called directly.
|
Yes, there is a level of indirection. The misc driver is registered as the driver for all device nodes with the corresponding major; it maintains a list of registered drivers. When a device is opened, the first handler is misc_open, which looks for a matching driver in the list and passes control to it.
| How does one misc driver control all this different hardware? |
1,513,088,334,000 |
I have installed ubuntu 20.04 on a qemu arm64 virtual machine. This is based on qemu's arm64 'virt' machine and I added a peripheral in the virtual machine. Now to test device driver, I need to build kernel module and I have to do it on my x86_64 ubuntu 20.04 machine.
Inside the VM, the uname -r command gives me 5.4.0-77-generic. I learned that I need the kernel source for this version(or is only the kernel header enough? this says I need kernel source.) . I have had trouble downloading a specific kernel version in the past and now I'm not sure how I should get this version.
From https://launchpad.net/ubuntu/focal/+source/linux-signed I can see some 5.4.0-77.86 versions under security and main but I'm not sure how these versions are different from 5.4.0-77-generic. Please anyone tell me how I can get this 5.4.0-77-generic kernel version source. Step by step instruction will be appreciated but any comment is welcome. Thanks! (The kernel.org site shows only some selected or recent versions.)
ADD :
After apt-cache search 5.4.0 I tried sudo apt install linux-cloud-tools-5.4.0-77-generic and it installs
/.
/usr
/usr/lib
/usr/lib/linux-tools
/usr/lib/linux-tools/5.4.0-77-generic
/usr/share
/usr/share/doc
/usr/share/doc/linux-cloud-tools-5.4.0-77-generic
/usr/share/doc/linux-cloud-tools-5.4.0-77-generic/copyright
/usr/lib/linux-tools/5.4.0-77-generic/hv_fcopy_daemon
/usr/lib/linux-tools/5.4.0-77-generic/hv_kvp_daemon
/usr/lib/linux-tools/5.4.0-77-generic/hv_vss_daemon
/usr/lib/linux-tools/5.4.0-77-generic/lsvmbus
/usr/share/doc/linux-cloud-tools-5.4.0-77-generic/changelog.Debian.gz
I don't think this contains the kernel source.
|
To build a standalone kernel driver, you only need your kernel's header.
It can be installed throught the linux-headers-5.4.0-77-generic package.
Don't mind about what is on repository, just:
Make sure your package database is up-to-date by running as root apt update
Install the required package with, still as root, apt install linux-headers-5.4.0-77-generic.
Usually, on ubuntu based distros, you'll have:
linux-image-<version> : The kernel by itself.
linux-headers-<version> : Kernel's header.
linux-source-<version> : Kernel's whole sources.
| Where to get linux "5.4.0-77-generic" kernel source? |
1,513,088,334,000 |
I'm trying to register a kprobe to retrieve the address of a syscall. But all my attempts seem to return -22 as the error code. The sample code below (incomplete but contains the related functions) tries to register a kernel probe for the sys_mkdir call.
It doesn't seem to matter if I specify pre or post handlers, simply registering the probe doesn't work.
Note: I'm trying to use kprobes as a replacement for the unexported kallsyms_lookup_name that is no longer exported in kernel 5.7 and above.
unsigned long lookup_name(const char *name)
{
int ret;
struct kprobe kp;
unsigned long retval;
kp.symbol_name = name;
ret = register_kprobe(&kp);
if (ret < 0) {
printk(KERN_DEBUG "register_kprobe failed for symbol %s, returned %d\n", name,
ret);
return 0;
}
retval = (unsigned long)kp.addr;
unregister_kprobe(&kp);
return retval;
}
static int __init mod_init(void)
{
int (*fn)(unsigned long param);
fn = (void*)lookup_name("__x64_sys_mkdir");
}
|
You’re not initialising the kprobe structure in full, so you’re failing the exclusive or requirement between symbol_name and addr (point 3 in the table in the register_kprobe documentation): addr contains whatever is on the stack on function entry, which is likely to be non-zero, so both symbol_name and addr are non-zero and register_kprobe fails with EINVAL (22).
You can fix this as follows:
int ret;
struct kprobe kp = {
.symbol_name = name
};
unsigned long retval;
which will ensure that the other members of the structure are initialised to their default values.
| Unable to register kprobe |
1,513,088,334,000 |
recently I'm wondering why program installed on linux systems are just archives extracted inside system paths and not just archives mounted as read-only entry-points.
As far as I understood, Android apk files are archives that are live-mounted when the app is opened, so why there's nothing similar under other linux-based systems like desktop or server OSs?
Recently I've attended a Linux Kernel Programming course and I thought that to implement a module that automatically creates mount points with given archives could be a cool idea, but I'm guessing if anyone thought it before and why this idea could have been discarded. Personally, I did not find anything useful.
Has anyone have some information or hint on this topic?
|
fuse-zip already implements this, as a FUSE module, for ZIP files, and archivemount exists for tarballs (or perhaps even anything supported by libarchive). Both of these even implement writes.
There’s nothing similar in the kernel itself, as far as I’m aware; there are related pieces of code in the kernel, e.g. for decompression, so implementing these in the kernel might not be all that complicated — but there would be some gotchas to take care of around keeping access to the archive file itself, and avoiding races. FUSE takes care of that for you.
| does a kernel module that mounts archives as read-only directories could be good idea? |
1,513,088,334,000 |
I'm a beginner in LKM programming.
I was writing a simple argument passable module which gains command line arguments and then logs them in alert level.
The problem is that I don't know why it doesn't call the second printk in hello_start function, maybe an error had occurred there but the amazing thing is that it works in unloading(rmmod) process.
Here is logs and codes:
// insmod thetestmodule.ko yes_no=1
Dec 26 20:25:31 duckduck kernel: [ 995.877225] Hi darcy. I'm now alive!
// Expect the argument here.
// rmmod thetestmodule
Dec 26 20:26:11 duckduck kernel: [ 995.877230] This is the passed argument: 1
Dec 26 20:26:11 duckduck kernel: [ 1035.956640] Understood. Bye.
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/moduleparam.h>
#define AUTHOR "Darcy"
MODULE_LICENSE("GPL");
MODULE_AUTHOR(AUTHOR);
MODULE_DESCRIPTION("OH. Kernel log, ALERT LEVEL O_o");
MODULE_VERSION("0.1");
static int short yes_no;
module_param(yes_no , short ,0);
MODULE_PARM_DESC(yes_no, "Enter 0 or 1 to say if you want the module be loaded in rescue mode.");
static int __init hello_start(void)
{
printk(KERN_ALERT "Hi darcy. I\'m now alive!\n");
printk(KERN_ALERT "This is the passed argument: %d" , yes_no);
return 0;
}
static void __exit hello_end(void)
{
printk(KERN_INFO "Understood. Bye.\n");
return NULL;
}
module_init(hello_start);
module_exit(hello_end);
Thanks for your cooperation!
|
Your second printk() does not have a \n at the end, while the first one has.
Also, the bracketed number after the word kernel: is the system uptime in seconds, so it looks like the second message was in fact generated well within the same second of time as the first one.
My first assumption is that the missing \n line terminator caused the process that was reading the kernel message buffer to wait in case more text was about to arrive, and the rest of the message was only processed by user-space logging daemon after the \n of the third message signaled that a complete line was received.
In the kernel message buffer (see the dmesg command) the bracketed uptime is typically the first element of the message: the human-readable timestamp, hostname and the word kernel: are added by whatever logging system was used to read the kernel message buffer and inject the kernel messages into the user-space logging stream(s).
So, try adding \n to the end of your second message, like this:
printk(KERN_ALERT "This is the passed argument: %d\n" , yes_no);
| Loadable Kernel Module logging problem in insmoding process |
1,513,088,334,000 |
I'm creating a program that interacts withkernel headers. The user can provide a path to the location of the headers, but first I would like to be able discover existing kernel headers on the users's machine based on convention. This apparently varies between distributions and tools. I know technically linux is fully customizable but I'm trying to understand what conventions apply to the mainstream distros:
who creates /lib/modules/$version and when?
are there guidelines for the structure of /lib/modules besides the /kernel and /extra subdirectories?
are /build and /source expected to always exist under /lib/modules? (both of them?)
is it acceptable that /build and /source are sometimes symlinks and sometimes not?
does the headers and source come together? I've noticed that most distros offer a kernel headers or kernel development package. how is this related?
|
Normally make modules_install but of course distros just package all these modules.
This looks like a Debian/Ubuntu thing. depmod just traverses all the subdirectories under /lib/modules/$version
For Fedora/RHEL/CentOS or the Linux kernel installed from source - the answer is yes.
Normally they are always symlinks
Almost never. There are kernel development headers which are required to build modules, and most distros don't even offer the option of installing the kernel source - it doesn't make a lot of sense for the end user.
Instead of reinventing the wheel, I'd recommend that you take a look at kernel modules build systems offered by VirtualBox, NVIDIA or VMWare. They are well tested and support dozens of distros.
| what are the conventions around /lib/modules? |
1,513,088,334,000 |
I've been looking and looking and everybody explains the /proc/diskstats file, but nobody seems to explain where that data comes from.
I found this comment:
Just remember that /proc/diskstats is tracking the kernel’s read requests–not yours.
on this page:
https://kevinclosson.net/2018/10/09/no-proc-diskstats-does-not-track-your-physical-i-o-requests/
But basically my problem is that I've got a kernel module that creates a block device, and handles requests via a request handler set via blk_queue_make_request not blk_init_queue, just like dm, I don't want the kernel to queue requests for me.
Everything works fine, but nothing shows up in /proc/diskstats What bit of magic am I missing to get my stats in there so it will show up in iostat? I assumed the kernel would be tallying this information since it's handling the requests to the kernel module, but apparently not. or I'm missing a flag somewhere or something.
Any ideas?
|
So I found it...
it seems the kernel supplies helper functions for you....
you need the request_queue, the bio and the gendisk, call these before and after you process the io...
unsigned long start_time;
start_time = jiffies;
generic_start_io_acct(q, bio_op(bio), bio_sectors(bio), &gd->part0);
generic_end_io_acct(q, bio_op(bio), &gd->part0, start_time);
and voila, the stats and your block device start showing up in iostat.
| How do I get the linux kernel to track io stats to a block device I create in a loadable module? |
1,513,088,334,000 |
I would like to know how a userspace program like modprobe can inject an executable file from userspace to kernel memory?
What kind of syscalls does it issue and what interfaces are provided by the kernel to make that possible? (detailed explanation please).
Thanks.
|
Loading a module is done using either one of init_module or finit_module. The first copies a module from a pointer, the second reads it from a file descriptor. Both support passing additional parameters to the module, and a couple of flags for the kernel.
Unloading a module is done using delete_module, which takes the name of the module to unload.
If you want to write code which does this, you might want to look into using libkmod instead; it’s part of kmod and available in all distributions.
| Module (un)loading procedure in the linux kernel |
1,513,088,334,000 |
I have enabled a number of config options on a machine in order to take advantage of the newly-included wireguard module in Linux 5.6.0-rc1.
This was somewhat laborious: I had a minimal working config and guided by the errors I received while trying to put up the wireguard network interface I had to enable, one by one, kernel config options I was not familiar with, until wireguard worked (options like, say, CONFIG_IP_NF_MANGLE).
I now want to automate the replication of this process on another machine as much as possible. That other laptop, in turn, has a relatively small custom-configured kernel; it is an entirely different machine, so make localmodconfig on the current machine is not really an option, because I would then somehow have to merge the two configs anyway.
What I would like to achieve
I would like to have a process that takes a module name as input, as listed by lsmod (e.g. iptable_mangle) and gives me back the kernel option(s) relevant to enabling it (presumably CONFIG_IP_NF_MANGLE=m in this case?).
I have tried
grepping for the kernel module iptable_mangle in the Linux source (github clone) in the hope of maybe finding something that links it to the corresponding kernel option;
running modinfo <target module name> on the current machine, hoping that the displayed info would mention the kernel config option.
Neither of these works: the output doesn't mention CONFIG_IP_NF_MANGLE in either case.
|
Aha! I believe I have found something reasonably reliable.
Poking around through the Linux tree after configuring and grepping recursively for my module name (e.g. iptable_raw or xt_addrtype or what have you) always produces, among the many matching lines, exactly one of the form
<whatever>/Makefile:obj-$(<RELEVANT KERNEL CONFIG OPTION>) += <module name>.o`
Concretely, running
grep -rE '\+\=\s*nf_defrag_ipv6'
in the root of the source tree produces
net/ipv6/netfilter/Makefile:obj-$(CONFIG_NF_DEFRAG_IPV6) += nf_defrag_ipv6.o
This tells me thatCONFIG_NF_DEFRAG_IPV6 is the kernel option that enables nf_defrag_ipv6.
I have tried this on multiple modules, and there's always a unique line of this form returned by grep. This seems eminently scriptable now, to produce, roughly speaking, a hash with
module names returned by lsmod as keys
matching kernel config options as values
Edit:
A word on documentation: the above pattern was, in principle, discoverable through grepping as described, but what actually tipped me off was the += <object file name> syntax mentioned in the Kconfig documentation, which I was perusing for inspiration.
| match Linux kernel config option to specific module |
1,513,088,334,000 |
I wrote a simple device driver that makes device file using class_create() and device_create() function. But then in the exit function of my driver, I destroyed the class first and then the driver, i.e. I called class_destroy() first and then device_destroy(). Due to this in kernel logs I saw some error messages and didn't see the output message that I had put in my exit function.
The driver was also not removed stating that it is still in use.
I want to know:
I think I made a mistake by freeing the class first and then removing the device, so error messages were appropriate. But now I cannot remove my driver using rmmod. Is there any way to remove the driver without rebooting the system?
I used lsmod to check which service is using my driver. But instead of showing "used by" count as 1, it is showing -1. What can be the reason for this behaviour?
|
man rmmod:
NAME
rmmod - Simple program to remove a module from the
Linux Kernel
SYNOPSIS
rmmod [-f] [-s] [-v] [modulename]
DESCRIPTION
rmmod is a trivial program to remove a module (when
module unloading support is provided) from the kernel.
Most users will want to use modprobe(8) with the -r
option instead.
OPTIONS
-v, --verbose
Print messages about what the program is doing.
Usually rmmod prints messages only if something
goes wrong.
-f, --force
This option can be extremely dangerous: it has no
effect unless CONFIG_MODULE_FORCE_UNLOAD was set
when the kernel was compiled. With this option,
you can remove modules which are being used, or
which are not designed to be removed, or have been
marked as unsafe (see lsmod(8)).
To be able to use -f, note that your kernel need the CONFIG_MODULE_FORCE_UNLOAD option to be set.
To ensure it is set, you may use:
/boot$ grep CONFIG_MODULE_FORCE_UNLOAD config-`uname -r`
CONFIG_MODULE_FORCE_UNLOAD=y
(If your distro installed the config under /boot...)
Regarding the usage count at -1, see this answer
| How to forcefully remove a loadable module from kernel |
1,513,088,334,000 |
I have a One Netbook 1s running Xubuntu. Everything works find except the touch screen does not work after suspend. I have seen several people with similar problems and it seems like there is a potential solution in this link:
https://github.com/jwrdegoede/linux-sunxi/commit/master
However, I do not understand the discussion there or what I am supposed to do with the material on github. I have tried a few solutions posted by people using Manjaro but they didn't work, perhaps because of the difference between Manjaro and Ubuntu...
This is a "Goodix" touchscreen. I am at the latest version of Ubuntu.
|
Update: You could try to do this. It worked for me. Note that you need to disable secure boot in bios to be able to run the script.
Install acpi_call package (sudo apt install acpi-call-dkms for Debian/Ubuntu, sudo pacman -S acpi_call-dkms for Arch). For Fedora you can install this module from tlp repo.
https://linrunner.de/en/tlp/docs/tlp-linux-advanced-power-management.html
The kernel module provided by this package is mandatory to get the touch screen working after suspend (the folks at Onemix did not define any GPIO in their DSDT related to the goodix reset lines, but rather directly implemented a reset method in the DSDT, that we can call using the acpi_call kernel module). Remember to load the module via: "sudo modprobe acpi_call"
Create a new file /lib/systemd/system-sleep/goodixtouchscreen and put these contents :
#!/bin/sh
case $1 in
pre)
modprobe -r goodix
exit 0
;;
post)
modprobe -r goodix || true
sleep 1s
echo '\_SB.PCI0.I2C2.TCSE.INTO 0' > /proc/acpi/call
sleep 1s
modprobe goodix
exit 0
;;
esac
| Goodix Touchscreen not working after suspend |
1,513,088,334,000 |
Fabian Lee : Software Architect's steps to installing VitualBox:
Make sure the kernel modules (vboxnetadp,vboxnetflt,vboxpic) were loaded properly:
$ lsmod | grep vboxdrv
vboxdrv 446464 3 vboxnetadp,vboxnetflt,vboxpci
My kernel modules seem okay however the numbers don't match Fabian's:
$ lsmod | grep vboxdrv
vboxdrv 471040 3 vboxnetadp,vboxnetflt,vboxpci
|
The first number represents the size of the module in memory, and it’s normal for it to vary from one system to another — it depends on the kernel version it was built for, the version of the module being built, and the compiler and compiler settings used.
| My Kernel modules don't match those of the VirtualBox installation guide. Should I be concerned? |
1,535,821,149,000 |
After doing sudo rmmod usbhid the usbhid driver only reopens when I connect a device, which I don't want because I want to write a custom driver for it and I need it disabled until I say otherwise. The driver itself is not dependant of any other, and it does not give me any errors when removing the module.
So, my question is, how can I disable a driver(in this case usbhid) until reboot or manual enable, not permanently, without the kernel reopening it?
|
You could leverage the blacklist functions of modprobe.d. Add the module to /etc/modprobe.d/blacklist.conf, or add your custom load command, and then comment it out when you're ready to reboot.
https://wiki.archlinux.org/index.php/Kernel_module#Blacklisting
| How to disable a driver from reopening when connecting a device it recognizes? |
1,535,821,149,000 |
I have written a network hook using netfilter. This modules compiles successfully on my ubuntu 16.04.
Now I want to compile it in my embedded board which uses a customized Linux using same version of kernel in my laptop. The only problem is that all the modules in my embedded board are in .ko.xz format and my makefile fails and I don't know how to solve the problem.
My original makefile is:
obj-m += sysfirewall.o
all:
make -C /lib/modules/$(shell uname -r)/build -I/usr/Include/ M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build -I/usr/Include/ M=$(PWD) clean
But this failed because I couldn't find any build folder in my embedded Linux. Instead of build folder there was a kernel folder which I replace it with kernel.
Now my makefile is:
obj-m += sysfirewall.o
all:
make -C /lib/modules/$(shell uname -r)/kernel -I/usr/Include/ M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/kernel -I/usr/Include/ M=$(PWD) clean
But when I run make in the current directory it gives the following error:
$ make -C /lib/modules/4.14.49-ti-r54/kernel -I/usr/Include/ M=/home/parsa/firewall/ modules
make[1]: Entering directory '/lib/modules/4.14.49-ti-r54/kernel'
make[1]: *** No rule to make target 'modules'. Stop.
make[1]: Leaving directory '/lib/modules/4.14.49-ti-r54/kernel'9-ti-r54/uname -i
Makefile:3: recipe for target 'all' failed
make: *** [all] Error 2
How can I solve this problem? Should I uncompress all the modules in my kernel?
Does it really a matter of compressed Linux kernel modules or the error shows something else?
P.S: I don't want to cross-compile the module in my laptop.
Edited:
I noticed there should be a Makefile in the "/lib/modules/$(shell uname -r)/kernel" folder which is not in my embedded board.
I traced the Make file in "/lib/modules/$(shell uname -r)/build" folder in my laptop and realized it is a soft link to /usr/src/linux-headers-4.4.0-128/Makefile. but I don't have anything in my /usr/src in my embedded board. so I think I have to find a make file in order to compile this module and I don't know how !
|
The problem is not with the compression, but with the make not finding the correct files. Note that the make command is entering the /lib/modules/<kernel version>/kernel directory, and only then reporting an error. So it's not finding whatever it needs in there.
You cannot substitute /lib/modules/<kernel version>/kernel to /lib/modules/<kernel version>/build: their contents are different. The kernel directory contains the already-compiled modules that came with that particular kernel version. That does not help the make command at all: it needs the makefiles and .h files that come with the kernel source code. Some of those are dynamically generated as part of the main kernel compilation.
Normally, the /lib/modules/<kernel version>/build is a symbolic link pointing to wherever the kernel headers associated with that particular kernel version are located. If your embedded board uses a kernel that has been compiled in "the Debian way" (i.e. with make bindeb-pkg or similar in the kernel source directory), the kernel compilation process should have produced a number of .deb packages:
linux-image-<version>_<patchversion>_<architecture>.deb = the actual compiled kernel and its modules
linux-headers-<version>_<patchversion>_<architecture>.deb = the headers you'll need to compile further kernel modules for this specific kernel
In that case, you'll only need to find and install the linux-headers package corresponding to the exact kernel version you're using in your ARM board. It will automatically provide the /lib/modules/<kernel version>/build link for you.
If you have compiled your own custom kernel with traditional make bzimage or similar, then you'll have to provide the /lib/modules/<kernel version>/build link yourself. If you have the actual kernel build directory still available, just link it to /lib/modules/<kernel version>/build.
| module makefile fails for armv7l when modules are compressed |
1,535,821,149,000 |
I try to do something like this - link.
All examples in the web are not working at all.
modprobe ubi mtd=0
modprobe: module ubi not found in modules.dep
modprobe ubi
modprobe: module ubi not found in modules.dep
modprobe ubi mtd=/dev/mtd0
modprobe: module ubi not found in modules.dep
|
Firstly, you should ensure that your module is exists in module directories. For example:
find /lib/modules/$(uname -r) -name 'ubi.ko'
If your module doesn't exist you need to build it.
Secondly, your output module ubi not found in modules.dep tells to you that there is no info about module in modules.dep (man 5 modules.dep).
You need to call depmod (man 8 depmod) to complete info about module dependencies.
| How to use ubifs image with modprobe? To extract ubifs image |
1,535,821,149,000 |
I have some experience with C/C++.
I have link+ IDE and Start with document this document(http://www.tldp.org/LDP/lkmpg/2.6/lkmpg.pdf)
Now it is based on 2.6 version and some headers have no functions as suggested by book. So, It is creating problem in testing the concepts.
Is there a way to get around with this problem?
Or any site that can provide kernel programming with all material ready(like OS to experiment and tutorial for Kernel programming with respect to that OS)
My end Goal is to learn about systems interfaces and network interface programming for my project.
|
If you are looking for network related kernel development guide then go for Understanding Linux Network Internals - O'Reilly Media. Its a really nice book.
Another interesting way to learn Kernel programming is taking Eudyptulla Challenge.. This will help you to contribute to open source also.
The best way to understand how any kernel subsystem works is by exploring the code itself which you can get here : http://elixir.free-electrons.com/linux/v3.7/source/kernel across all versions.
Some other books :
Linux kernel in a nutshell
Understanding the Linux Kernel
| Best source to learn Kernel development programming? [closed] |
1,535,821,149,000 |
I'm writing a bash script to install a certain development environment on a computer. In order to do this I need to enable the CONFIG_USB_ACM module in the kernel. I am doing this through:
cd ~/l4t-kernel-surgery-kernel/kernel-4.4
zcat /proc/config.gz > .config
# PART I NEED IDEAS
vim .config # change the line that says CONFIG_USB_ACM=n to CONFIG_USB_ACM=m
make clean
make prepare
make modules_prepare
make M=drivers/usb/class
...
Would it work for me to append the =m line to the end of the config file? Will that overwrite the previous setting of =n? Is there a better way to edit the file in this way from bash?
|
zcat /proc/config.gz | sed 's/CONFIG_USB_ACM=n/CONFIG_USB_ACM=m/' > .config
| Kernel Surgery in a Script |
1,535,821,149,000 |
I am writing some firmware for a microcontroller that communicates over USB. I am getting this error from dmesg:
[3034764.122150] hid-generic 0003:16C0:27DB.0015: item fetching failed at offset -1080905469
[3034764.122158] hid-generic: probe of 0003:16C0:27DB.0015 failed with error -22
Does this error come from the kernel or userspace? Where can I find out what this error means?
|
It is from the kernel driver. If you go to the kernel sources web site freetext search lxr, and enter the search string you will find it leads you to the file hid/hid-core.c
1033 hid_err(device, "item fetching failed at offset %d\n", (int)(end - start));
| Where can I find information on hid-generic error codes? |
1,535,821,149,000 |
I wrote a simple module for the Linux Kernel and it has a stack buffer overflow vulnerability. I want to exploit the module, but I have to turn off the stack protector in the kernel first. How could I do this quickly and simply?
Is it required to compile the kernel every time?
Is there any other way to turn off stack protection in a module of the Linux Kernel (without compiling the kernel)?
|
Those options work by passing options to the compiler, so the most straightforward way is to recompile the kernel.
However for a reproducible and module-specific way kbuild allows you to set custom CFLAGs on a per-module basis.
https://www.kernel.org/doc/Documentation/kbuild/makefiles.txt
You particularly want to set -fno-stack-protector for the modules you want to exploit.
DKMS additionally allows you to set up automatic rebuild for out of tree drivers against arbitrary kernel versions.
| How to turn off stack protector in linux kernel easily? [duplicate] |
1,535,821,149,000 |
I have exactly the same problem as described here. I can find the same "Oops" messages in /var/log/kern.log. I also have an older Radeon HD (so I have to use the free driver). I downloaded the current Debian DVD image, installed it, and my PC is completely unusable, always freezing after a couple of minutes.
So from what I understand, this is a problem with a patch, which is working in newer kernels, and was also applied to older kernels (like 3.16.0-4 — which is used in the Debian 8.3 now) where it causes this horrible bug.
So if I install Ubuntu 16.04 LTS with Linux kernel kernel 4.4, I will not get this bug? Yes or no?
Thanks in advance!
|
Short answer: Linux kernel 4.4 does not have this bug. You should not run into it on Ubuntu 16.04 LTS.
Detailed answer
If you follow the email chain that you linked, you'll get to this message by Nicolai Hähnle:
Kernels that contain commit 954605ca "drm/radeon: use common fence
implementation for fences, v4" are safe, older kernels require a
NULL-pointer check around the call to radeon_fence_ref.
Here is the commit he's talking about on kernel.org. For a more useful visual, here is the same commit on GitHub. On the GitHub page, if you expand the list of commit branch and tag labels, you can see that the commit is included in the tag for the 4.4 kernel (see image below), so you should be fine.
If you really want to be sure, you can probably boot a LiveCD or USB key running Ubuntu 16.04 LTS (currently still in the beta stage of its release cycle) to test it on your computer.
Edit: It may also be worth noting that Debian 8.3 is no longer the latest version, as Debian 8.4 was released on April 2, 2016. However, Debian 8.4 ships with a kernel where this is still not fixed (3.16.7-ckt25-1). It's important to note that the real thing to look for is not what Linux release you're using, but what kernel you're running. In your case (Debian), kernel 3.16.7-ckt25-1 has this problem while 3.16.7-ckt20-1+deb8u4 and 3.16.7-ckt26 do not (relevant bug report).
Edit 2: You can also, as fduff points out in this comment, install a different kernel version on your existing system. Though, I think that's a bit outside the scope of the question you posed, which was simply, "So if I install Ubuntu 16.04 LTS with Linux kernel kernel 4.4, I will not get this bug? Yes or no?"
| Avoiding a buggy kernel version with "Oops" in radeon module |
1,535,821,149,000 |
I'm on an archlinux 4.4.1-2 and I'm trying to set up a netctl service.
Problem is that for netctl to work I need to have bcma and b43 loaded.
Since these two are not out-of-tree modules I thought I didn't had to load them myself.
Neverthless I also tried to load described in this article here.
Unfortunalty this doesn't seem to work either.
Has anyone an Idea what the problem could be?
thanks:D
modinfo of bcma
filename: /lib/modules/4.4.1-2-ARCH/kernel/drivers/bcma/bcma.ko.gz
license: GPL
description: Broadcom's specific AMBA driver
alias: pci:v000014E4d0000A8DCsv*sd*bc*sc*i*
alias: pci:v000014E4d0000A8DBsv*sd*bc*sc*i*
alias: pci:v000014E4d00004727sv*sd*bc*sc*i*
alias: pci:v000014E4d000043B1sv*sd*bc*sc*i*
alias: pci:v000014E4d000043AAsv*sd*bc*sc*i*
alias: pci:v000014E4d000043A9sv*sd*bc*sc*i*
alias: pci:v000014E4d000043A0sv*sd*bc*sc*i*
alias: pci:v000014E4d00004365sv*sd*bc*sc*i*
alias: pci:v000014E4d00004360sv*sd*bc*sc*i*
alias: pci:v000014E4d00004359sv*sd*bc*sc*i*
alias: pci:v000014E4d00004358sv*sd*bc*sc*i*
alias: pci:v000014E4d00004357sv*sd*bc*sc*i*
alias: pci:v000014E4d00004353sv*sd*bc*sc*i*
alias: pci:v000014E4d00004331sv*sd*bc*sc*i*
alias: pci:v000014E4d0000A8D8sv*sd*bc*sc*i*
alias: pci:v000014E4d00004313sv*sd*bc*sc*i*
alias: pci:v000014E4d00000576sv*sd*bc*sc*i*
and modinfo of b43
filename: /lib/modules/4.4.1-2-ARCH/kernel/drivers/net/wireless/b43/b43.ko.gz
firmware: b43/ucode9.fw
firmware: b43/ucode5.fw
firmware: b43/ucode16_mimo.fw
firmware: b43/ucode15.fw
firmware: b43/ucode14.fw
firmware: b43/ucode13.fw
firmware: b43/ucode11.fw
license: GPL
author: Rafał Miłecki
author: Gábor Stefanik
author: Michael Buesch
author: Stefano Brivio
author: Martin Langer
description: Broadcom B43 wireless driver
alias: ssb:v4243id0812rev10*
alias: ssb:v4243id0812rev0F*
alias: ssb:v4243id0812rev0D*
alias: ssb:v4243id0812rev0C*
alias: ssb:v4243id0812rev0B*
alias: ssb:v4243id0812rev0A*
alias: ssb:v4243id0812rev09*
alias: ssb:v4243id0812rev07*
alias: ssb:v4243id0812rev06*
alias: ssb:v4243id0812rev05*
alias: bcma:m04BFid0812rev2Acl*
alias: bcma:m04BFid0812rev28cl*
alias: bcma:m04BFid0812rev1Ecl*
alias: bcma:m04BFid0812rev1Dcl*
alias: bcma:m04BFid0812rev1Ccl*
alias: bcma:m04BFid0812rev18cl*
alias: bcma:m04BFid0812rev17cl*
alias: bcma:m04BFid0812rev15cl*
alias: bcma:m04BFid0812rev11cl*
depends: mac80211,ssb,bcma,led-class,mmc_core,cfg80211,rng-core
intree: Y
vermagic: 4.4.1-2-ARCH SMP preempt mod_unload modversions
parm: bad_frames_preempt:enable(1) / disable(0) Bad Frames Preemption (int)
parm: fwpostfix:Postfix for the .fw files to load. (string)
parm: hwpctl:Enable hardware-side power control (default off) (int)
parm: nohwcrypt:Disable hardware encryption. (int)
parm: hwtkip:Enable hardware tkip. (int)
parm: qos:Enable QOS support (default on) (int)
parm: btcoex:Enable Bluetooth coexistence (default on) (int)
parm: verbose:Log message verbosity: 0=error, 1=warn, 2=info(default), 3=debug (int)
parm: pio:Use PIO accesses by default: 0=DMA, 1=PIO (int)
parm: allhwsupport:Enable support for all hardware (even it if overlaps with the brcmsmac driver) (int)
|
There is a file /etc/modules which lists modules to be loaded at boot. Just add those modules to that file
| module not loaded at boot |
1,535,821,149,000 |
I've been experimenting with the g_mass_storage kernel module.
I first tried loading it by putting it in /etc/modules and the options in /etc/modprobe.d/file.conf
This worked, but when I connected the device to a computer the mass file storage was read only - not what I was looking for.
I reasoned that this was because when the module loads, the root filesystem is mounted as read-only - not read-write.
This is an issue, because the kernel driver tries to get a read-write file handle for its backing storage, and if it can't negotiate this rw handle, it falls back to read-only.
The only solution I can think of is moving the loading of the kernel module later in the boot sequence.
I moved the module initialisation to /etc/rc.local using modprobe, and this worked with both reading & writing - but it feels like a bit of a hack to load the module in there.
Is there a recommended place to load kernel modules that need rw access to a file?
|
A [probably not perfect] solution to this has been to hook onto the "systemd-remount-fs.service" systemd service, which is the remounting of the filesystem to read-write.
This means the module will be loaded as early as possible, whilst still being loaded after the filesystem becomes readwrite.
My sample systemd config file is as follows:
[Unit]
Description=Starts kernel modules for USB OTG
After=systemd-remount-fs.service
DefaultDependencies=false
[Service]
Type=simple
ExecStart=/home/pi/programs/startmod.sh
WorkingDirectory=/home/pi/programs/
[Install]
WantedBy=local-fs.target
This works, if a little hackily.
| How do I load a kernel module later in the boot sequence? |
1,535,821,149,000 |
I'm developing my first sound card driver in Ubuntu with ALSA.
Implementing a volume control for the sound card I stumbled upon a few questions.
1) For the function that is assigned to snd_kcontrol_new.info, I'm trying to understand the logic behind choosing the values of snd_ctl_elem_info.value.integer.min and max. my sound card can go between -100db and 0db, how do I decide if I map it to 0-100 in the snd_ctl_elem_info.value.integer.min/max or 0-15, or any other range?
2) I'm struggling to understand the difference between the control names PCM Playback Volume, Master Playback Volume, and Playback Volume.
Thanks for the answers, and apologies if the questions are very trivial, but I couldn't find a good explanation to them.
|
The control values typically are just the hardware's register values.
The mapping between control values and dB values is done with TLV metadata.
"PCM" applies to the sound played through the PCM device, while "Master" applies to all sounds played.
| ALSA sounds card volume range numbers, and Difference between Control Names |
1,535,821,149,000 |
I have Ubuntu 15.04 with a default full disk encryption installed on my chromebook Pixel with linux-samus kernel patch and everything is working fine. I've just tried compiling a newer version of the kernel (4.1), but when I'm trying to boot it I'm getting an error where I would normally enter the disk encryption password:
Cannot initialize device-mapper. Is dm_mod kernel module loaded?
I'm guessing something is missing in kernel config, any idea what that is? This is the kernel config file.
|
The Device Mapper driver is missing. Run make nconfig or make menuconfig:
Device Drivers --->
[*] Multiple devices driver support (RAID and LVM) --->
<*> Device mapper support
and recompile your kernel.
| Booting encrypted disk kernel error: Cannot initialize device-mapper |
1,535,821,149,000 |
I am using the find command in my Android image; a image which I developed myself and put in an example of a dynamically loadable module. I put the code in the /example directory of my source code, compiled the code, and flashed the phone with it.
I am not sure if it is relevant to my question, but I put the .ko file in the /proc directory of my ramdisk. I created a /drivers directory and put the ko in there. Now I am trying to find the path to the file so I can activate it, but I do not know if I am using the right command.
I am using find, which I got by installing busybox on my platform. All I want to do is a recursive search from root for the word example. I can not follow why I am getting different results when I issue find. I am posting here since this is essentially a Linux question. My question is how can I find the file(s) / directories I am after please? Here is the command I issued and the output I got.
Update after the first comments. Thanks for the help. I have updated the link above with the output. For some reason the ko files don't show up. I do not think they would on the sdcard. I am not sure why I get a permission error, but I don't think that is relevant to my goal any how.
I do know that something is different in this image since I was getting an security error message, which after online research seems to imply that Samsung knox was not happy. It was perhaps the added files. Since I ran this image before successfully for days; actually a version of it without the two files I mentioned. I know that the files are in the image somewhere. As to why I don't see them, it may be a minor Android adjustment. I'll discuss it in xda and see what I get.
|
If you'd like to avoid "permission denied" errors and search recursively the whole Android filesystem, you'll need to have a "rooted" device.
Afterwards, having a rooted device, you may install any Terminal emulator application, run su and run find command.
E.g., you'd like to find all files with .ko extension, so please run:
find / -name "*.ko" in Terminal emulator after running su command.
| How do I find a directory or a file in Linux file system [closed] |
1,535,821,149,000 |
I have been a arch linux user for the past 2 years and now moving on to freeBSD for kernel development.
I have install freeBSD and want to compile a dynamically loadable kernel module for freeBSD. As far as I know, On linux I just need to install linux-headers for the kernel version I am compiling against.
Is there any equivalent package on freeBSD for the same or I have to install full freeBSD source code ?
|
You can find it in /usr/src or you can download from here (src.txz).
In FreeBSD the base system is outside of package manager. You can't install kernel package, system utils (cp, ls, etc.) package, etc.. They are part of base system - you can update with freebsd-update (it's part of base system, of course). Check documentation too!
| How do I install freeBSD headers ? |
1,535,821,149,000 |
I am writing a common code in a driver to get the distros name and host name. host name i am taking from struct utsname{nodename[]}, but how do I get the distro name?
|
The Scope for getting distro name is not in kernel development scope. So no specific method is present currently. I am asking for module param in my driver for this. you can also ask for a ENV variable while compiling.
Thanks, for your help...
| Linux Distro name API to get name of linux distro in a driver code? |
1,535,821,149,000 |
I am using a Dell Vostro 1500 (looking to buy a new computer) and I have installed the wifi drivers with b43-fwcutter or whatever the actual name of it is, but you probably know what I'm talking about.
I am having a problem where I need to enable the wifi kernel module every time I boot my computer, using sudo modprobe b43.
How can I make this automatic?
To make it clear I have tried a couple of things beforehand without success:
http://www.cyberciti.biz/faq/linux-how-to-load-a-kernel-module-automatically-at-boot-time/
https://stackoverflow.com/questions/10730096/how-to-autoload-a-kernel-module-in-gentoo-linux
I may not have tried all of these methods or may have done them incorrectly. So go ahead and advice any of these and I will try them again just to make sure. I'm pretty sure I have tried them correctly and they didn't work however. Again, not all of them.
|
So I tried all of the methods on those links and also the one @jasonwryan put in his comment, which is direct to the Arch wiki. None of them worked.
I found this fishy and just started exploring. Found /etc/modprobe.d/broadcom-wl.conf which contained the following line (among others):
blacklist b43
So it was getting removed from the list of things to load no matter what I tried. Removed it and it worked (FINALLY).
Thanks everyone for your help. :)
P.S.: Arch Wiki on black listing: https://wiki.archlinux.org/index.php/Kernel_modules#Blacklisting
| Auto-load B43 wifi card module in Arch Linux |
1,535,821,149,000 |
From here: http://www.xenomai.org/index.php/RTnet:Installation_%26_Testing#Testing_with_a_single_node_.28local_loopback.29
TODO: simplify the following steps.
- Then you need to edit the file rtnet.conf under the /usr/local/rtnet/etc folder for the correct setup to run RTnet. Edit the following parameters:
- Set the host up as master or slave depending on how you are going to use it.
- The RT_DRIVER should be the realtime equivalent of the module you removed nl. rt_8139too.
Kernel: 2.6.38.8
linux-y3pi:~ # ethtool -i eth0
driver: r8169
version: 2.3LK-NAPI
firmware-version:
bus-info: 0000:01:00.0
After RTnet installation I get:
linux-y3pi:/usr/local/rtnet/modules # ls
rt_8139too.ko rtcfg.ko rt_eepro100.ko rt_loopback.ko rtnet.ko rtudp.ko
rtcap.ko rt_e1000.ko rtipv4.ko rtmac.ko rtpacket.ko tdma.ko
How to find what corresponds to r8169?
|
In the last source distribution, (rtnet-0.9.12.tar.bz2), I can see rtnet-0.9.12/drivers/experimental/rt_r8169.c, so the rt_ nomenclature remains. The module filename should be rt_r8169.ko. It's not there either because it wasn't compiled, or because it failed to compile (it is under the ‘experimental’ subdirectory, after all). I see there's an --enable-r8169 option in the configure script. Did you supply it?
| What is the realtime equivalent of the module r8169? |
1,699,409,805,000 |
I'm trying to build a driver for a USB to HDMI adapter...
Bus 001 Device 010: ID 534d:6021 MacroSilicon VGA Display Adapter
NOTE: "lsusb" output.
... but this error is occurring...
Fatal error: Invalid --compress-debug-sections option: `zstd'
...as can be seen in the full output below...
[eduardolac@eduardolac-pc ms912x]$ make all -j
make CHECK="/usr/bin/sparse" -C /lib/modules/6.5.5-1-MANJARO/build M=/home/eduardolac/Data1/Temp/20231016.1224.0/ms912x modules
make[1]: Entering directory '/usr/lib/modules/6.5.5-1-MANJARO/build'
CC [M] /home/eduardolac/Data1/Temp/20231016.1224.0/ms912x/ms912x_registers.o
CC [M] /home/eduardolac/Data1/Temp/20231016.1224.0/ms912x/ms912x_connector.o
CC [M] /home/eduardolac/Data1/Temp/20231016.1224.0/ms912x/ms912x_transfer.o
CC [M] /home/eduardolac/Data1/Temp/20231016.1224.0/ms912x/ms912x_drv.o
Assembler messages:
Fatal error: Invalid --compress-debug-sections option: `zstd'
make[3]: *** [scripts/Makefile.build:243: /home/eduardolac/Data1/Temp/20231016.1224.0/ms912x/ms912x_connector.o] Error 1
make[3]: *** Waiting for unfinished jobs....
Assembler messages:
Fatal error: Invalid --compress-debug-sections option: `zstd'
make[3]: *** [scripts/Makefile.build:243: /home/eduardolac/Data1/Temp/20231016.1224.0/ms912x/ms912x_registers.o] Error 1
Assembler messages:
Fatal error: Invalid --compress-debug-sections option: `zstd'
make[3]: *** [scripts/Makefile.build:243: /home/eduardolac/Data1/Temp/20231016.1224.0/ms912x/ms912x_transfer.o] Error 1
Assembler messages:
Fatal error: Invalid --compress-debug-sections option: `zstd'
make[3]: *** [scripts/Makefile.build:243: /home/eduardolac/Data1/Temp/20231016.1224.0/ms912x/ms912x_drv.o] Error 1
make[2]: *** [/usr/lib/modules/6.5.5-1-MANJARO/build/Makefile:2034: /home/eduardolac/Data1/Temp/20231016.1224.0/ms912x] Error 2
make[1]: *** [Makefile:234: __sub-make] Error 2
make[1]: Leaving directory '/usr/lib/modules/6.5.5-1-MANJARO/build'
make: *** [Makefile:15: modules] Error 2
The "ld" available on my system does not support the "zstd" option for the "compress-debug-sections" parameter...
[eduardolac@eduardolac-pc ms912x]$ ld --help | grep "compress-debug-sections"
--compress-debug-sections=[none|zlib|zlib-gnu|zlib-gabi]
... but the "binutils" package (which contains "ld") that I have installed on my OS is version 2.41-3, which according to this documentation
( https://sourceware.org/binutils/docs/binutils.html ) already supports the "zstd" option for the "compress-debug-sections" parameter.
The Kernel I have installed is 6.5.X .
Please help me with this. üëÄ
Thanks! ü§ó
Further...
https://askubuntu.com/a/1488791/134723
https://github.com/rhgndf/ms912x/issues/5
https://github.com/rhgndf/ms912x
|
The problem occurs because the "ld" binary used in my case, for some reason, was provided by "Homebrew"...
[eduardolac@eduardolac-pc ms912x]$ pacman -Qo ld
error: No package owns /home/linuxbrew/.linuxbrew/bin/ld
So the solution, for me, was to remove "Homebrew", as I wasn't using it for anything...
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)"
And as a precaution I reinstalled binutils...
yay -Rdd binutils
yay -S binutils
So finally, just open and close the terminal and voilà...
[eduardolac@eduardolac-pc ~]$ ld --version
GNU ld (GNU Binutils) 2.41.0
Copyright (C) 2023 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
Thanks! üòò
[Ref(s).: https://stackoverflow.com/a/64722984/3223785 ]
| “binutils”/Kernel 6.5.X - “Invalid –compress-debug-sections option: `zstd’” |
1,699,409,805,000 |
I have a kernel module (ko) file that is designed for the aarch64 architecture. I'm currently attempting to use qemu on a non-aarch64 system to utilize this aarch64 kernel module for mounting a specific file system within the non-aarch64 system.
I'm curious if it's possible to load and use this module using qemu?
|
No, you can’t use QEMU to load a foreign-architecture kernel module. Modules have to match the architecture of the kernel they’re loaded into (and its ABI, so you can’t load an arbitrary binary module anyway).
The only way you can load your module is to run a VM using QEMU, with the matching foreign-architecture kernel. That would allow you at least to copy the contents of your specific file system to another volume.
| Load kernel modulebusing qemu |
1,699,409,805,000 |
How do I fix that following errors
root@DESKTOP-OK32G:/mnt/c/Windows/system32# service openvswitch-switch start
modprobe: FATAL: Module openvswitch not found in directory /lib/modules/5.10.102.1-microsoft-standard-WSL2
* Inserting openvswitch module
rmmod: ERROR: ../libkmod/libkmod-module.c:1941 kmod_module_get_holders() could not open '/sys/module/bridge/holders': No such file or directory
rmmod: ERROR: Module unloading is not supported
* removing bridge module
* ovsdb-server is already running
modprobe: FATAL: Module openvswitch not found in directory /lib/modules/5.10.102.1-microsoft-standard-WSL2
* Inserting openvswitch module
rmmod: ERROR: ../libkmod/libkmod-module.c:1941 kmod_module_get_holders() could not open '/sys/module/bridge/holders': No such file or directory
rmmod: ERROR: Module unloading is not supported
* removing bridge module
|
The Mininet documentation states: "VM installation is the easiest and most foolproof way of installing Mininet, so it’s what we recommend to start with".
Therefore, I suggest you setup the VM as suggested by the docs: http://mininet.org/download/
Secondly: if you really want to use openvswitch inside WSL, you will probably have to recompile the kernel with the required modules. This process is not beginner friendly, and would take a lot of time and research.
TLDR: if you want to quickly have mininet up and running, please use the VM. Otherwise, you will have lots of trouble.
| Error with starting Openvswitch on wsl2 |
1,647,733,147,000 |
I checked:
https://cateee.net/lkddb/web-lkddb/CRYPTO_RSA.html
The help text is:
Generic implementation of the RSA public key algorithm.
Is this driver for an encryption HW device, ex: from Intel/AMD CPU?
|
No, CRYPTO_RSA provides a generic implementation of RSA, i.e. one which isn’t hardware-specific. It works on any system the kernel works on.
| kernel config, CONFIG_CRYPTO_RSA, what is this config for? |
1,647,733,147,000 |
I am seeing this log:
request_module: kmod_concurrent_max (0) close to 0 (max_modprobes: 50), for module foo, throttling...
I don't understand what does it mean?
auto load too many modules?
|
It means that there are too many modules being loaded in parallel, and that the kernel is waiting for some to complete loading before proceeding with the requested module.
If you don’t see a subsequent error message, either
request_module: modprobe foo cannot be processed, kmod busy with … threads for more than … seconds now
or
request_module: sigkill sent for modprobe foo, giving up
then the problem was resolved.
| request_module: kmod_concurrent_max (0) close to 0 (max_modprobes: 50), for module xxxxxx, throttling |
1,647,733,147,000 |
I'm trying to build and install a linux kernel driver for the mcp251xfd. The build appears to be successful (I get the .ko file), but when I call insmod to install it, I get:
insmod: ERROR: could not insert module mcp251xfd.ko: Invalid module format
In googling around, it appears the most common suggestion is to use the exact same source code for the exact kernel version you are trying to build towards. So a uname -a returns:
Linux fedora 5.11.3-300.fc34.x86_64 #1 SMP Thu Mar 4 19:03:18 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux.
So I then downloaded the kernel source for version 5.11.3, ran make oldconfig, edited the .config file to include the driver, ran make prepare, then went into the driver source code directory and called:
make -C ~/linux-5.11.3 -M=`pwd` modules
and this was successful in that it generates the file mcp251xfd.ko. insmod right after this, and I get the error. I call dmesg, and it returns:
mcp251xfd: version magic '5.11.3 SMP mod_unload ' should be '5.11.3-300.fc34.x86_64 SMP mod_unload '
So I'm not sure what to do next. Was 5.11.3 not the correct version after all?
I notice in my .config file, I see "CONFIG_BUILD_SALT="5.11.3-300.fc34.x86_64". so it looks like that matches my system version number. Is there an extra command line option during "make modules" that instructs to utilize the "salt" version number?
|
The solution was to open the Makefile (the one at the linux source tree) and modify the line:
EXTRAVERSION = -300.fc34.x86_64
Which matches the installed OS's uname -r text.
| insmod coult not insert module invalid module format |
1,647,733,147,000 |
I am trying to implement a PCI device driver for a virtual PCI device on QEMU. The device defines a BAR region as RAM, and the driver can do ioremap() this region and access it without any issues. The next step is to assign this region (or a fraction of it) to a user application. To do this, I have also implemented an .mmap function as part of my driver file operations. This mmap is simply using remap_pfn_range, but it also passes the pfn of the memory pointer returned by the ioremap() earlier.
However, upon running the user space application, the mmap is successful, but when the app tries to access the memory, it is killed and I get the following dmesg errors.
[ 1502.402970] a.out: Corrupted page table at address 7f911b79f000
[ 1502.404085] PGD 13926d067 P4D 13926d067 PUD 1317aa067 PMD 1326d9067 PTE 800026d901000227
[ 1502.404085] Bad pagetable: 000f [#1] SMP NOPTI
[ 1502.404085] Modules linked in: edu_driver(OE) ppdev kvm_amd kvm irqbypass input_leds parport_pc serio_raw parport mac_hid qemu_fw_cfg sch_fq_codel ib_iser rdma_cm iw_cm ib_cm ib_core iscsi_tcp libiscsi_tcp libiscsi scsi_transport_iscsi ip_tables x_tables autofs4 btrfs zstd_compress raid10 raid456 async_raid6_recov async_memcpy async_pq async_xor async_tx xor raid6_pq libcrc32c raid1 raid0 multipath linear psmouse pata_acpi floppy e1000 i2c_piix4
[ 1502.404085] CPU: 0 PID: 1988 Comm: a.out Tainted: G OE 4.15.0-55-generic #60-Ubuntu
[ 1502.404085] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014
[ 1502.404085] RIP: 0033:0x55d687642811
[ 1502.404085] RSP: 002b:00007ffe16c38da0 EFLAGS: 00000213
[ 1502.404085] RAX: 00007f911b79f000 RBX: 0000000000000000 RCX: 00007f911b2a1813
[ 1502.404085] RDX: 0000000000000003 RSI: 0000000000001000 RDI: 0000000000000000
[ 1502.404085] RBP: 00007ffe16c38dc0 R08: 0000000000000003 R09: 0000000000000000
[ 1502.404085] R10: 0000000000008001 R11: 0000000000000246 R12: 000055d687642660
[ 1502.404085] R13: 00007ffe16c38ea0 R14: 0000000000000000 R15: 0000000000000000
[ 1502.404085] FS: 00007f911b7984c0(0000) GS:ffff97237fc00000(0000) knlGS:0000000000000000
[ 1502.404085] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 1502.404085] CR2: 00007f911b79f000 CR3: 0000000132cd8000 CR4: 00000000000006f0
[ 1502.404085] RIP: 0x55d687642811 RSP: 00007ffe16c38da0
[ 1502.404085] ---[ end trace 6b088b58eb816baf ]---
Does anyone know what have I done wrong? Did I missed a step? Or it could be an error specific to QEMU? I am running x86_softmmu as my QEMU configuration and my kernel is the 4.14
|
I've solved this issue and managed to map PCI memory to userspace via the driver.
I've changed the pfn input of the remap_pfn_range function I was using in my custom .mmap
The original was:
io_remap_pfn_range(vma, vma->vm_start, pfn, vma->vm_end - vma->vm_start, vma->vm_page_prot ))
where the pfn was the result of the buffer pointer return from the ioremap().
I changed the pfn to:
pfn = pci_resource_start(pdev, BAR) >> PAGE_SHIFT .
That basically points to the actual starting address pointed by the BAR.
My working remap_pfn_range function is now:
io_remap_pfn_range(vma, vma->vm_start, pci_resource_start(pdev, BAR) >> PAGE_SHIFT, vma->vm_end - vma->vm_start,vma->vm_page_prot )
I confirmed that it works by doing some dummy writes to the buffer pointer in my driver, then picking up the reads and doing some wirtes in my userspace app.
| How can my PCI device driver remap PCI memory to userspace? |
1,647,733,147,000 |
I was trying to get the uid of the process runner which is calling my syscall. I use linux/cred.h and its macro called current_uid() .
The problem is that it returns a type which is unknown for me, kuid_t. So I can't save the return value to an int type static variable. Here are parts of the code and error:
static int getuid(void){
return current_uid();
}
static int caller_uid = getuid();
error:
error: incompatible types when returning type ‘kuid_t’ {aka ‘const struct <anonymous>’} but ‘int’ was expected
current_cred()->xxx; \
|
kuid_t is defined in linux/uidgid.h it's just a simple struct with one uid_t member.
typedef struct {
uid_t val;
} kuid_t;
You should be able to get the uid_t value using current_uid().val and uid_t is just an usigned int.
| Problem in gaining uid of the system caller in a system call LKM using cred.h |
1,647,733,147,000 |
I added my custom driver to be inserted automatically at boot using:
cp ./driver/mydrv.ko /lib/modules/$(uname -r)/extra/
depmod -a
Now I'd like to update with a new version of the driver, I launched the same command but the previous version is inserted...
find /lib/modules -type f -name *mydrv* I removed all the existing files.
How can I debug that?
How can I check from which file the driver is loaded at boot?
How can I check the driver file used? (lsmod doesn't give anything useful but the size and if used)
It seems I can't stop the load of that old third-party driver.
FYI: Running rmmod/insmod the new driver is successfully loaded.
CentOS Linux release 7.8.2003
|
As @stoney said, initramfs has to be regenerated. The reason of the corruption is unknown.
Remove all the *.ko to remove in weak-updates folder.
Generate initramfs: dracut -f --regenerate-all for Centos/RHEL/Fedora
| How to remove/disable the insertion of a driver added with depmod -a? |
1,647,733,147,000 |
UPDATE
Whenever I try to upgrade or install any package no I get the following error
libc6-dbg : Depends: libc6 (= 2.31-0ubuntu9.1) but 2.31-0ubuntu9 is to be installed
libc6-dev : Depends: libc6 (= 2.31-0ubuntu9.1) but 2.31-0ubuntu9 is to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
If I try an upfrade with -f I get the following errors
Errors were encountered while processing:
/var/cache/apt/archives/libc6_2.31-0ubuntu9.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
Without the -f I get another error
$ sudo apt upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
libc6-dbg : Depends: libc6 (= 2.31-0ubuntu9.1) but 2.31-0ubuntu9 is installed
libc6-dev : Depends: libc6 (= 2.31-0ubuntu9.1) but 2.31-0ubuntu9 is installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
**END UPDATE**
I
'm running Ubuntu 20.04.1 LTS and installed Virtualbox Version 6.1.14 r140239 (Qt5.12.8)
I've tried to create a VM and got the following error:
Kernel driver not installed (rc=-1908)
The VirtualBox Linux kernel driver is either not loaded or not set up correctly. Please try setting it up again by executing
'/sbin/vboxconfig'
as root.
If your system has EFI Secure Boot enabled you may also need to sign the kernel modules (vboxdrv, vboxnetflt, vboxnetadp, vboxpci) before you can load them. Please see your Linux system's documentation for more information.
where: suplibOsInit what: 3 VERR_VM_DRIVER_NOT_INSTALLED (-1908) - The support driver is not installed. On linux, open returned ENOENT.
I then followed this thread trying to sign the kernel modules.
The key was created but wasn't able to sign the modules. (don't remember the exact errors)
But now I got some errors in my packages and I can't solve them.
~$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
libc6-dbg : Depends: libc6 (= 2.31-0ubuntu9.1) but 2.31-0ubuntu9 is installed
libc6-dev : Depends: libc6 (= 2.31-0ubuntu9.1) but 2.31-0ubuntu9 is installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
~$ sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
libfprint-2-tod1 libllvm9 linux-headers-5.4.0-26
linux-headers-5.4.0-26-generic linux-image-5.4.0-26-generic
linux-modules-5.4.0-26-generic linux-modules-extra-5.4.0-26-generic
python3-click python3-colorama
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
libc6
Suggested packages:
glibc-doc
The following packages will be upgraded:
libc6
1 upgraded, 0 newly installed, 0 to remove and 133 not upgraded.
3 not fully installed or removed.
Need to get 2.712 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://be.archive.ubuntu.com/ubuntu focal-updates/main amd64 libc6 amd64 2.31-0ubuntu9.1 [2.712 kB]
Fetched 2.712 kB in 6s (460 kB/s)
debconf: DbDriver "config": /var/cache/debconf/config.dat is locked by another process: Resource temporarily unavailable
(Reading database ... 238445 files and directories currently installed.)
Preparing to unpack .../libc6_2.31-0ubuntu9.1_amd64.deb ...
debconf: DbDriver "config": /var/cache/debconf/config.dat is locked by another p
rocess: Resource temporarily unavailable
dpkg: error processing archive /var/cache/apt/archives/libc6_2.31-0ubuntu9.1_amd
64.deb (--unpack):
new libc6:amd64 package pre-installation script subprocess returned error exit
status 1
Errors were encountered while processing:
/var/cache/apt/archives/libc6_2.31-0ubuntu9.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
I've tried to purge lib6 but this didn't work either.
What can I do to solve this?
~$ sudo apt-get remove --purge libc6
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
accountsservice : Depends: libc6 (>= 2.4) but it is not going to be installed
acl : Depends: libc6 (>= 2.14) but it is not going to be installed
...
xserver-xorg-video-vmware : Depends: libc6 (>= 2.14) but it is not going to be installed
xwayland : Depends: libc6 (>= 2.29) but it is not going to be installed
xxd : Depends: libc6 (>= 2.3.4) but it is not going to be installed
xz-utils : Depends: libc6 (>= 2.17) but it is not going to be installed
yelp : Depends: libc6 (>= 2.4) but it is not going to be installed
zeitgeist-core : Depends: libc6 (>= 2.14) but it is not going to be installed
zeitgeist-datahub : Depends: libc6 (>= 2.4) but it is not going to be installed
zenity : Depends: libc6 (>= 2.4) but it is not going to be installed
zip : Depends: libc6 (>= 2.14) but it is not going to be installed
zlib1g : Depends: libc6 (>= 2.14) but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
|
While trying to install or upgrade I saw this weird error
debconf: DbDriver "config": /var/cache/debconf/config.dat is locked by another p
rocess: Resource temporarily unavailable
I looked up what process blocked it with
sudo fuser -v /var/cache/debconf/config.dat
I've got a lot of permission denies but at the bottom of the list was one identifiable process which I was able to kill. Immediately the MOK configuration screen opened and after rebooting all problems were solved including Virtualbox.
Just to make sure, I've turned off secure boot as it turned out to be a major buzzkill.
| Errors in packages after signing kernel modules |
1,647,733,147,000 |
I tried to compile an Android 8 kernel to contain a driver for TP-Link TL-WN722N USB Wi-Fi card for a smartphone, the kernel is flashed successfully, but when I plug the Wi-Fi card via OTG to the phone, it's not recognised by software.
Here are some debugging I have done:
The Wi-Fi card is showing in lsusb -t output, but no driver binding to it.
I can see the module is loaded in /proc/modules and lsmod:
wlan 5801121 0 - Live 0x00000000000000 (O)
The driver I have picked using make menuconfig before compile was called ATH9K and ATH9K_HTC, so I am not sure why it's wlan here, and the offset being all zeros is a bit weird. Also, this is the only item in the output, I guess all other native modules are compiled directly into the kernel, not externally.
There are many things look not very right, but I'm not sure where actually is the problem, any suggestions will be appreciated.
|
I finally got it working, it turns out the Atheros device requires a .fw firmware file to be placed in right directory to work, I noticed this because an error of loading firmware failed message shows in dmesg every time I plug in the wifi card.
I also tried to bind driver to device like @nobody suggested, but I'm not sure if that's working, the driver is not showed in the device folder after binding.
| Why is a loaded module not being driver of the device? |
1,647,733,147,000 |
I want to make some changes in ath9k drivers for learning purposes.
My problem is that when I try to compile the driver, the make command is giving many implicit declaration errors, setup_timer, ACCESS_ONCE, DECLARE_EWMA are the most frequent ones that show up in the errors.
My kernel version is Ubuntu 4.15.0-20-generic and I am using the driver source code from backports-4.14-rc2-1.
These are the commands I run:
cd backports-4.14-rc2-1
make defconfig-ath9k
make
I have already installed necessary header files using build-essential.
What should I do, so that I can compile my edited source code of drivers?
|
I was compiling the driver module from the torvalds linux kernel, that was the problem, now I am compiling it from the Ubuntu source code, and it is working...
| How to compile ath9k drivers from source? |
1,582,710,236,000 |
When I run the command:
cat /lib/modules/4.15.0-20-generic/modules.alias | grep 'ath9k_htc'
I get the following list:
alias usb:v0CF3p20FFd*dc*dsc*dp*ic*isc*ip*in* ath9k_htc
alias usb:v0930p0A08d*dc*dsc*dp*ic*isc*ip*in* ath9k_htc
alias usb:v04DAp3904d*dc*dsc*dp*ic*isc*ip*in* ath9k_htc
alias usb:v0411p0197d*dc*dsc*dp*ic*isc*ip*in* ath9k_htc
alias usb:v0411p017Fd*dc*dsc*dp*ic*isc*ip*in* ath9k_htc
alias usb:v083ApA704d*dc*dsc*dp*ic*isc*ip*in* ath9k_htc
alias usb:v0846p9018d*dc*dsc*dp*ic*isc*ip*in* ath9k_htc
alias usb:v0CF3p7010d*dc*dsc*dp*ic*isc*ip*in* ath9k_htc
alias usb:v1668p1200d*dc*dsc*dp*ic*isc*ip*in* ath9k_htc
alias usb:v0CF3p7015d*dc*dsc*dp*ic*isc*ip*in* ath9k_htc
alias usb:v1EDAp2315d*dc*dsc*dp*ic*isc*ip*in* ath9k_htc
alias usb:v0471p209Ed*dc*dsc*dp*ic*isc*ip*in* ath9k_htc
alias usb:v057Cp8403d*dc*dsc*dp*ic*isc*ip*in* ath9k_htc
alias usb:v0CF3pB002d*dc*dsc*dp*ic*isc*ip*in* ath9k_htc
alias usb:v0CF3pB003d*dc*dsc*dp*ic*isc*ip*in* ath9k_htc
alias usb:v040Dp3801d*dc*dsc*dp*ic*isc*ip*in* ath9k_htc
alias usb:v04CAp4605d*dc*dsc*dp*ic*isc*ip*in* ath9k_htc
alias usb:v13D3p3350d*dc*dsc*dp*ic*isc*ip*in* ath9k_htc
alias usb:v13D3p3349d*dc*dsc*dp*ic*isc*ip*in* ath9k_htc
alias usb:v13D3p3348d*dc*dsc*dp*ic*isc*ip*in* ath9k_htc
alias usb:v13D3p3346d*dc*dsc*dp*ic*isc*ip*in* ath9k_htc
alias usb:v13D3p3328d*dc*dsc*dp*ic*isc*ip*in* ath9k_htc
alias usb:v13D3p3327d*dc*dsc*dp*ic*isc*ip*in* ath9k_htc
alias usb:v07D1p3A10d*dc*dsc*dp*ic*isc*ip*in* ath9k_htc
alias usb:v0846p9030d*dc*dsc*dp*ic*isc*ip*in* ath9k_htc
alias usb:v0CF3p1006d*dc*dsc*dp*ic*isc*ip*in* ath9k_htc
alias usb:v0CF3p9271d*dc*dsc*dp*ic*isc*ip*in* ath9k_htc
I want to know for which alias name - usb:***, the module gets loaded when i plugin my usb device?
|
The line is formatted with the vendor and product id
e.g.
alias usb:v0CF3p9271d*dc*dsc*dp*ic*isc*ip*in* ath9k_htc
Has Vendor ID of 0CF3 and a Product ID of 9271
You can use lsusb to see which device you have plugged into your machine has matching vendor/product ids.
| How to know for which alias name, the module is loaded, when there are multiple aliases? |
1,582,710,236,000 |
When doing lspci, usually we can see a driver in use:
ex:
Kernel driver in use: xhci_hcd
If there is no 'driver in use', does it mean really no driver or it may a driver in use but not external module ( kernel built-in module )
|
Kernel built-in modules will also be reported by "kernel driver in use". For example, my system reports a skl_uncore driver in lspci, and there is no corresponding module in lsmod, so it is a driver that is built into the kernel.
On PCI bridge devices, some of them might not need a driver as they are covered by the generic PCI(e) bridge device support in the kernel.
| lspci can't see driver name in use |
1,582,710,236,000 |
I am following an online tutorial on how to enable VMX operations on x86 architecture. The tutorial has broken the procedure into steps and has posted the code assembled from all the parts into a kernel module. It has also provided a Makefile to compile it. Both of them can be viewed here. While compiling it I am getting the following error:
make -C /lib/modules/4.4.0-81-generic/build M=/home/sbhtwr/Desktop/hypervisor modules EXTRA_CFLAGS="-g -DDEBUG"
make[1]: Entering directory '/usr/src/linux-headers-4.4.0-81-generic'
CC [M] /home/sbhtwr/Desktop/hypervisor/vmx.o
/home/sbhtwr/Desktop/hypervisor/vmx.c: In function ‘__rdmsr1’:
/home/sbhtwr/Desktop/hypervisor/vmx.c:82:8: error: expected ‘:’ or ‘)’ before ‘_ASM_EXTABLE_HANDLE’
_ASM_EXTABLE_HANDLE(1b, 2b, ex_handler_rdmsr_unsafe)
^
/home/sbhtwr/Desktop/hypervisor/vmx.c:82:28: error: invalid suffix "b" on integer constant
_ASM_EXTABLE_HANDLE(1b, 2b, ex_handler_rdmsr_unsafe)
^
/home/sbhtwr/Desktop/hypervisor/vmx.c:82:32: error: invalid suffix "b" on integer constant
_ASM_EXTABLE_HANDLE(1b, 2b, ex_handler_rdmsr_unsafe)
^
scripts/Makefile.build:264: recipe for target '/home/sbhtwr/Desktop/hypervisor/vmx.o' failed
make[2]: *** [/home/sbhtwr/Desktop/hypervisor/vmx.o] Error 1
Makefile:1420: recipe for target '_module_/home/sbhtwr/Desktop/hypervisor' failed
make[1]: *** [_module_/home/sbhtwr/Desktop/hypervisor] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.4.0-81-generic'
Makefile:6: recipe for target 'modules' failed
make: *** [modules] Error 2
I am unable to resolve the error. I feel that some definitions are missing from my copy of linux headers (Although compiler does not explicitly state that as the reason!). I maybe wrong though. Please see NOTE below.
NOTE:
I tried to search the header files on linux repository online for the definition of _ASM_EXTABLE_HANDLE and found it here. I then tried to find asm.h in my local copy of linux headers and found that the definition was missing. So I copy pasted the definition into the module and re-compiled it. There were no errors this time, but a warning:
WARNING: "ex_handler_rdmsr_unsafe" [/home/sbhtwr/Desktop/hypervisor/vmx.ko] undefined!
I found the definition of ex_handler_rdmsr_unsafe here. So I copy pasted the definition of the function into the module, which lead to some more errors indicating missing definitions of functions (which are used in ex_handler_rdmsr_unsafe).
The tutorial page can be found here.
|
It seems that the definitions for _ASM_EXTABLE_HANDLE and ex_handler_rdmsr_unsafe are included in the linux headers 4.15.0-72-generic. Previously I was running Ubuntu 16.04 LTS with linux headers 4.4.0-81-generic. Upgrading to Ubuntu 18.04 LTS (which also upgraded the linux headers to 4.15.0-72-generic) fixed the issue.
| Error while trying to compile kernel module |
1,582,710,236,000 |
I am writing a kernel module. Reads bytes from user space and writes back.
static ssize_t dev_read(struct file *filep, char *buffer, size_t len, loff_t *offset) {
Node *msg;
int error_count = 0;
// Entering critical section
down(&sem); //wait state
msg = pop(&l, 0);
// No message? No wait!
if(!msg) {
up(&sem);
return -EAGAIN;
}
len = msg->length;
error_count = copy_to_user(buffer, msg->string, msg->length);
if (error_count == 0) {
current_size -= msg->length;
remove_element(&l, 0);
up(&sem);
return 0;
} else {
up(&sem);
printk(KERN_INFO "opsysmem: Failed to send %d characters to the user\n", error_count);
return -EFAULT; // Failed -- return a bad address message (i.e. -14)
}
}
static ssize_t dev_write(struct file *filep, const char *buffer, size_t len, loff_t *offset) {
Node *n;
// buffer larger than 2 * 1024 bytes
if(len > MAX_MESSAGE_SIZE || len == 0) {
return -EINVAL;
}
n = kmalloc(sizeof(Node), GFP_KERNEL);
if(!n) {
return -EAGAIN;
}
n->string = (char*) kmalloc(len, GFP_KERNEL);
n->length = len;
copy_from_user(n->string, buffer, len);
// Enter critical section
down(&sem); //wait state
// buffer is larger than the total list memory (2MiB)
if(current_size + len > MAX_LIST_SIZE) {
up(&sem);
return -EAGAIN;
}
current_size += len;
push(&l, n);
up(&sem);
// Exit critical section
return len;
}
Destroy function which should deallocate the linked list
static void __exit opsysmem_exit(void) {
// Deallocate the list of messages
down(&sem);
destroy(&l);
up(&sem);
device_destroy(opsysmemClass, MKDEV(majorNumber, 0)); // remove the device
class_unregister(opsysmemClass); // unregister the device class
class_destroy(opsysmemClass); // remove the device class
unregister_chrdev(majorNumber, DEVICE_NAME); // unregister the major number
printk(KERN_INFO "charDeviceDriver: Goodbye from the LKM!\n");
}
My linked list and destroy function look like this:
static void destroyNode(Node *n) {
if(n) {
destroyNode(n->next);
kfree(n->string);
n->string = NULL;
kfree(n);
n = NULL;
}
}
static void destroy(list *l){
if(l) {
destroyNode(l->node);
}
}
typedef struct Node {
unsigned int length;
char* string;
struct Node *next;
} Node;
typedef struct list{
struct Node *node;
} list;
The problem is the following:
I write to the device driver and I want to rmmod the driver and the opsysmem_exit should be called to kfree() all the memory.
This works when I have a small number of nodes.
If I run a very large amount of nodes (1000+) and I try to rmmode, the vm just freezes.
Do you have any idea why and what else I should do to diagnose this?
Is my function creating too many levels of recursion?
There does not seem to be a problem if I write 2000000 nodes and then I read them back. As far as the list is empty when I rmmod, everything works.
EDIT 1:
I noticed that if I do rmmod without deallocating the memory, the kernel does not crash. However, all the memory allocated is leaked as shown by kedr
|
I have just solved it. Murray Jensen was right. It was the recursion that was killing my kernel.
Could somebody explain why I spent 7 hours to learn this? What is the maximum recursion depth C is capable of in reality? I read an article this morning ad it was saying 523756 I read it here, scroll down to C.
Here's my deallocator. Zero leaks as you may have noticed.
static void destroy2(list *l) {
Node *_current = l->node;
Node *_next;
while(_current) {
_next = _current->next;
kfree(_current->string);
kfree(_current);
_current = _next;
}
}
Another bad thing about the recursive approach I have in the main post is that randomly it would skip kfree-ing 2 to 4 nodes.
For anyone interested in my leak check report: I am using an open-source tool I discovered on github at https://github.com/euspecter/kedr. Comes with no guarantee, but it is very helpful. You don't need to recompile your kernel.
| Kernel space memory deallocation freezes kernel |
1,582,710,236,000 |
If I have 3 pthreads: A, B, C, all originating from the same process, running in user space and one thread, thread B does a blocking read from a kernel module and is put to sleep, will threads A and C also be put to sleep as a result?
According to the documentation, wait_event_interruptible puts the calling process to sleep, not thread.
|
After testing personally, it appears only the calling thread is put to sleep, not any other threads. While one thread was waiting during a blocked read, the other threads were still active.
| Do all threads originating from the same process sleep on wait_event_interruptible()? |
1,582,710,236,000 |
I am trying to write an ansible playbook to check to see if a particular module is loaded for the current kernel running.
if I do an lsmod | grep my_module_$kernelVer
I would see something like
my_module_2_6_32_754_3_5_el6_x86_64
if I am on the 2.6.32-754.3.5.el6.x86_64 kernel
if I am still on that kernel and said module is
my_module_2_6_32_431_el6_x86_64
I need to rebuild the module for the current kernel that is on the server. I know how to do it in bash but I am not sure how to store a specific value with ansible and the register command and I am just learning ansible.
Thanks for any help provided.
|
if I do an lsmod | grep my_module_$kernelVer
Ok, that's the invocation of a shell module. It needs to be a shell because you're using |, and that's a shell construct.
I know how to do it in bash but I am not sure how to store a specific value with ansible and the register command and I am just learning ansible.
You can use the register to capture the results of the command and refer to it later. http://www.mydailytutorials.com/ansible-register-variables/ looks worth reading.
All that having been said, are you really sure you care so much about it matching? Okay, granted, the module not loading may be a big problem for you. But you're testing your kernel upgrades anyway, right? After all, the methodology you define here removes the loaded module to build a new one. I've loaded 3rd party modules in the past that don't even have a kernel version in the name, and frankly I prefer it. I'm not an expert on kernel modules, but keeping kernel versioning and module versions disassociated is worth considering.
| Ansible Search for kernel module loaded |
1,582,710,236,000 |
I'm trying to follow this guide to setup NAT on my Synology NAS. It worked great for me! I had everything working perfectly. But when I came back the next morning, the NAS had done a system update [DSM 6.2.2-24922]... The scripts were gone and after recreating them I get errors that the NAT kernel modules cannot be loaded.
Trying to isolate the issue with the insmod, I was able to determine which modules are failing, and see that it is because of "unknown symbols." Here's what I see (note that the variables here are defined in the script at the above link):
# for MODULE in ${KERNEL_MODULES_NAT}; do "${BIN_SYNOMODULETOOL}" --insmod "${SERVICE}" ${MODULE} || echo ${MODULE} = $?; done
nf_conntrack.ko = 1
nf_defrag_ipv4.ko = 1
nf_conntrack_ipv4.ko = 1
nf_nat.ko = 1
nf_nat_redirect.ko = 1
nf_nat_ipv4.ko = 1
iptable_nat.ko = 255
xt_nat.ko = 255
nf_nat_masquerade_ipv4.ko = 1
xt_REDIRECT.ko = 255
ipt_MASQUERADE.ko = 255
# dmesg | tail -10
[ 2448.777252] iptable_nat: Unknown symbol ipt_alloc_initial_table (err 0)
[ 2448.784021] iptable_nat: Unknown symbol ipt_do_table (err 0)
[ 2448.789913] iptable_nat: Unknown symbol ipt_unregister_table (err 0)
[ 2448.796544] iptable_nat: Unknown symbol ipt_register_table (err 0)
[ 2448.818608] xt_nat: Unknown symbol xt_unregister_targets (err 0)
[ 2448.824851] xt_nat: Unknown symbol xt_register_targets (err 0)
[ 2448.862765] xt_REDIRECT: Unknown symbol xt_unregister_targets (err 0)
[ 2448.869368] xt_REDIRECT: Unknown symbol xt_register_targets (err 0)
[ 2448.891826] ipt_MASQUERADE: Unknown symbol xt_register_target (err 0)
[ 2448.898429] ipt_MASQUERADE: Unknown symbol xt_unregister_target (err 0)
I'm really not sure how to fix it. Maybe try to downgrade DSM? Maybe update the objects which are failing to load? Any ideas?
|
In the end I just installed a TinyCore Virtual Machine on the NAS which can handle the NAT. It seems a bit unnecessary, but I guess it's a little more controllable... so it works.
| Synology NAS insmod unknown symbol |
1,582,710,236,000 |
I'm compiling a kernel just for learning purpose, and I almost get all things working, bluetooth, hdmi, usb, card reader, webcam, wifi... etc. But I can't make touchpad works, all that I know about it is...
xinput:
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ USB OPTICAL MOUSE id=10 [slave pointer (2)]
⎜ ↳ SYN1B81:01 06CB:2970 Touchpad id=12 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Power Button id=8 [slave keyboard (3)]
↳ Sleep Button id=9 [slave keyboard (3)]
↳ HD WebCam: HD WebCam id=11 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=13 [slave keyboard (3)]
cat /proc/bus/input/devices:
I: Bus=0018 Vendor=06cb Product=2970 Version=0100
N: Name="SYN1B81:01 06CB:2970 Touchpad"
P: Phys=i2c-SYN1B81:01
S: Sysfs=/devices/pci0000:00/INT3432:00/i2c-0/i2c-SYN1B81:01/0018:06CB:2970.0002/input/input11
U: Uniq=
H: Handlers=event7
B: PROP=5
B: EV=1b
B: KEY=6420 10000 0 0 0 0
B: ABS=2e0800000000003
B: MSC=20
dmesg | grep SYN1B81:01:
[ 11.112159] i2c_hid i2c-SYN1B81:01: i2c-SYN1B81:01 supply vdd not found, using dummy regulator
[ 11.112178] i2c_hid i2c-SYN1B81:01: Linked as a consumer to regulator.0
[ 11.112181] i2c_hid i2c-SYN1B81:01: i2c-SYN1B81:01 supply vddl not found, using dummy regulator
[ 11.133437] input: SYN1B81:01 06CB:2970 Mouse as /devices/pci0000:00/INT3432:00/i2c-0/i2c-SYN1B81:01/0018:06CB:2970.0002/input/input7
[ 11.133526] input: SYN1B81:01 06CB:2970 Touchpad as /devices/pci0000:00/INT3432:00/i2c-0/i2c-SYN1B81:01/0018:06CB:2970.0002/input/input8
[ 11.133598] hid-generic 0018:06CB:2970.0002: input,hidraw1: I2C HID v1.00 Mouse [SYN1B81:01 06CB:2970] on i2c-SYN1B81:01
[ 11.133664] probe of i2c-SYN1B81:01 returned 1 after 21592 usecs
[ 11.224691] input: SYN1B81:01 06CB:2970 Touchpad as /devices/pci0000:00/INT3432:00/i2c-0/i2c-SYN1B81:01/0018:06CB:2970.0002/input/input11
[ 11.224837] hid-multitouch 0018:06CB:2970.0002: input,hidraw1: I2C HID v1.00 Mouse [SYN1B81:01 06CB:2970] on i2c-SYN1B81:01
So this is basically all that I know about it, lspci -k doesn't show the touchpad, and lsmod just list two modules related i2c_hid and hid_multitouch I've tested the others disabling them and seeing if it was related if touch. And this is the latest config file that I compiled and I don't know how to get support for this touch, I already enabled everything related with i2c, usb, hid that have elan, elantech, synaptics, designware and nothing worked.
|
After reading about i2c I find out what I was missing, basically:
CONFIG_X86_INTEL_LPSS
PINCTRL
CONFIG_MFD_TPS68470
CONFIG_I2C_DESIGNWARE_CORE
CONFIG_I2C_DESIGNWARE_PLATFORM
CONFIG_I2C_DESIGNWARE_SLAVE
| How do I Get Support for Acer E5-573-54zv Touchpad on a Custom Kernel |
1,582,710,236,000 |
I am trying to get virtualbox working on my machine with the pci-passthrough extension. When trying to run a VM, I got this error message:
Kernel driver not installed (rc=-1908)
[message asking me to install the vboxdrv kernel driver
by executing /sbin/vboxconfig as root]
So I did so and got this:
vboxdrv.sh: Stopping VirtualBox services.
vboxdrv.sh: Starting VirtualBox services.
vboxdrv.sh: Building VirtualBox kernel modules.
vboxdrv.sh: failed: modprobe vboxdrv failed. Please use 'dmesg' to find out why.
There were problems setting up VirtualBox. To re-start the set-up process, run
/sbin/vboxconfig
as root.
Looking at dmesg, the installation added no new entries.
Looking at the log file, it failed at the last module:
Building the main VirtualBox module.
Building the net filter module.
Building the net adaptor module.
Building the PCI pass-through module.
meaning that this is the code that fails in /usr/lib/virtualbox/vboxdrv.sh, called from /sbin/vboxconfig:
log "Building the PCI pass-through module."
if ! myerr=`$BUILDINTMP \
--use-module-symvers /tmp/vboxdrv-Module.symvers \
--module-source "$MODULE_SRC/vboxpci" \
--no-print-directory install 2>&1`; then
log "Error building the module:"
module_build_log "$myerr"
failure "Look at $LOG to find out what went wrong"
fi
where $BUILDINTMP points to the runnable file /usr/share/virtualbox/src/vboxhost/build_in_tmp
This is how far I got in troubleshooting, I don't know what to do next.
Some info:
IOMMU / VT-D is enabled
kernel version is 4.10.0-38-generic
OS is Linux Mint 18.3
as far as I can tell, the kernel headers are installed, "as far as I can tell" meaning that the path /lib/modules/4.10.0-38-generic/build/include/linux exists and is full of .h files and other subdirectories
Virtualbox is version 5.2.20
when I installed the PCI passthrough extension to VBox, it indicated a successful installation
|
From the question comments:
modprobe: ERROR: could not insert 'vboxdrv': Required key not available
This indicates the module is already built, but it has not been signed to satisfy Secure Boot requirements.
The simplest workaround would be to just disable Secure Boot. This is especially true with VirtualBox 5.2, because:
it uses its own module build system instead of DKMS, and
as far as I know, it has no facilities to add module signing commands to its module build procedure
(I would really hope that future releases of VirtualBox would move to using DKMS or at least would provide hooks to allow tying custom scripts into the VirtualBox module installation procedure.)
The "proper" fix to this problem would be to create your own Secure Boot key, and use it to either take full control of the Secure Boot in your system firmware, or enroll it as a Machine Owner Key (a bootloader-level extension to Secure Boot) if that is not possible or is too difficult.
This can never be fully automated as such automation would be considered a Secure Boot circumvention device and would be included in UEFI revocation list by the UEFI Forum. This list gets embedded to new UEFI firmware versions. Fortunately, the enrollment is an one-time process.
Once the key has been enrolled to Secure Boot, you could use that key to sign the modules to make them acceptable to the system. You would have to repeat the module signing each time either the kernel or VirtualBox is updated.
According to Ubuntu documentation, you should be able to create a suitable key with sudo update-secureboot-policy --new-key and then enroll it as a Machine Owner Key (MOK) with sudo update-secureboot-policy --enroll-key and rebooting. At reboot, the shim.efi should automatically start the MokManager program, which will require you to confirm the enrollment of the Machine Owner Key, as only at boot time it can verify for sure that the input comes from the user and nowhere else. This is done to ensure that any customization of Secure Boot keys happens with the explicit control of the system owner/administrator.
Reinstallation of the operating system will not remove the MOK from the UEFI firmware variables, but a UEFI firmware upgrade or resetting of all the UEFI firmware settings to defaults might do that. In that case, you would need to redo the enrollment procedure.
Once the MOK has been successfully enrolled, the key should be automatically passed on to the kernel by the firmware, and can be used to sign the modules. VirtualBox 5.2 installs its modules to /lib/modules/<kernel version number>/misc/ directory. To sign the modules in there, you would use the kmodsign command. For example, to sign the vboxdrv.ko module:
cd /lib/modules/$(uname -r)/misc
kmodsign sha512 /var/lib/shim-signed/mok/MOK.priv /var/lib/shim-signed/mok/MOK.der vboxdrv.ko
Repeat this for each module you'll find in this directory. There should be at least four of them: vboxdrv.ko, vboxnetadp.ko, vboxnetflt.ko and vboxpci.ko.
| Error building virtualbox pci-passthrough kernel module - what went wrong? |
1,582,710,236,000 |
I've a kernel-panic problem (I think) trying to use the liveCD of gNewSense 4.0 for i386.
The error is the following:
[8.598401] xhci_queue_intr_tx: 78 callbacks suppressed.
.
.
.
It's showing the same error with different codes (70 for example) as long as my laptop is turned on.
I'll give you some information about my hardware:
uname -m
x86_64
sudo lshw -short
[sudo] password for lucasdavid:
H/W path Device Class Description
=====================================================
system Inspiron 14-3467 (078A)
/0 bus 0PW5P4
/0/0 memory 64KiB BIOS
/0/3d memory 6GiB System Memory
/0/3d/0 memory 4GiB SODIMM Synchronous 2400 MHz (0,4 ns)
/0/3d/1 memory 2GiB SODIMM Synchronous 2400 MHz (0,4 ns)
/0/41 memory 128KiB L1 cache
/0/42 memory 512KiB L2 cache
/0/43 memory 3MiB L3 cache
/0/44 processor Intel(R) Core(TM) i3-6006U CPU @ 2.00GHz
/0/100 bridge Sky Lake Host Bridge/DRAM Registers
/0/100/2 display Sky Lake Integrated Graphics
/0/100/4 generic Intel Corporation
/0/100/14 bus Intel Corporation
/0/100/14/0 usb2 bus xHCI Host Controller
/0/100/14/1 usb1 bus xHCI Host Controller
/0/100/14/1/1 input USB Optical Mouse
/0/100/14/1/2 multimedia USB PnP Sound Device
/0/100/14/1/5 multimedia Integrated_Webcam_HD
/0/100/14/1/6 generic USB2.0-CRW
/0/100/14/1/8 communication Bluetooth wireless interface
/0/100/14.2 generic Intel Corporation
/0/100/15 generic Intel Corporation
/0/100/15.1 generic Intel Corporation
/0/100/16 communication Intel Corporation
/0/100/17 storage Intel Corporation
/0/100/1c bridge Intel Corporation
/0/100/1c/0 wlp1s0 network QCA9565 / AR9565 Wireless Network Adapter
/0/100/1c.5 bridge Intel Corporation
/0/100/1c.5/0 enp2s0 network RTL8101/2/6E PCI Express Fast/Gigabit Ethernet controller
/0/100/1f bridge Intel Corporation
/0/100/1f.2 memory Memory controller
/0/100/1f.3 multimedia Intel Corporation
/0/100/1f.4 bus Intel Corporation
/0/1 scsi0 storage
/0/1/0.0.0 /dev/sda disk 1TB ST1000LM035-1RK1
/0/1/0.0.0/1 volume 599MiB Windows FAT volume
/0/1/0.0.0/2 /dev/sda2 volume 3071MiB Windows FAT volume
/0/1/0.0.0/3 /dev/sda3 volume 516GiB EXT4 volume
/0/1/0.0.0/4 /dev/sda4 volume 11GiB Linux swap volume
/0/1/0.0.0/5 /dev/sda5 volume 399GiB EXT4 volume
/0/2 scsi1 storage
/0/2/0.0.0 /dev/cdrom disk DVD+-RW DU-8A5LH
/1 power DELL 78V9D72
I think the problem is with some usb, so more information:
lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 009: ID 0cf3:e005 Atheros Communications, Inc.
Bus 001 Device 005: ID 0bda:0129 Realtek Semiconductor Corp. RTS5129 Card Reader Controller
Bus 001 Device 004: ID 0bda:5769 Realtek Semiconductor Corp.
Bus 001 Device 003: ID 0d8c:013c C-Media Electronics, Inc. CM108 Audio Controller
Bus 001 Device 002: ID 1bcf:0823 Sunplus Innovation Technology Inc.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
That's all!
|
This distribution doesn't have proper drivers for 2 USB and network card that comes with my laptop. I've just installed Trisquel and it works perfectly now!
| gNewSense livecd gives me an Error (callbacks suppressed) |
1,582,710,236,000 |
I have built an Linux From Scratch system on my laptop, but am struggling to get my Elan Touchpad working. I have narrowed down the search to an issue with the module i2c_designware_core not being loaded.
I am trying to load the module i2c_designware_core, but get an error:
$ modprobe i2c_designware_core
[ 197.551934] i2c_designware_core: exports duplicate symbol i2c_dw_probe (owned by kernel)
modprobe: ERROR: could not insert 'i2c_designware_core': Exec format error
Searching in the Linux kernel source code yields that the symbol i2c_dw_probe is only found in the i2c_designware-related directories. Running rmmod i2c_designware_core tells me that the module is not loaded.
The kernel compilation configuration is set to compile i2c_designware-software as modules, and I have recompiled and reinstalled several times already.
How can the symbol be exported by the kernel if it only exists in a module I have made sure not to build into it?
|
Turns out I had made a terrible mistake when installing the kernel, causing GRUB to load an older one. I guess it makes sense that the duplication happened when trying to load the external module at the same time as the module was built-in.
Sorry for the trouble.
| Modprobe could not insert module; exports duplicate symbol [closed] |
1,582,710,236,000 |
I'm currently doing some project of secure the kernel with syscall hooking and logs...
Now I've done hooking read, and socket system calls, and when I tried to do the same thing with execve (to follow which file have just executed) I get a kernel ops or just I did something wrong because I can't even open the dmesg to see what error I have (dmesg is also executable, and I just overrided that function of running executable files).
I also found out that there is something called stub_execve, and you can't just change the systam call from the systam calls table, because there are system calls that wrapped with another binary or something like that (please fix me if I'm wrong).
So at the end, all I need to do is to see what files have just runned and I need to do it through a kernel module, does anybody think of how to do it, or how to jump over the stub_execve or something like this..? Please help me, I'll be very thankful.
|
Have you looked into kprobes? Or specifically jprobes.
Using jprobe you can hook into execve (or any other kernel function), check its arguments etc just before that function gets executed. The way it works is, caller provides a function with same signature as the one which it wants to trace, and registers it with a call to jprobe_register. Let's call that function my_execve. Then just before executing the actual function, kernel would first save all its context (parameters, register values etc) on stack and pass control to my_execve, passing in a copy of that context. When my_execve returns (using jprobe_return instead of return), kernel restores saved context for original function execve and resumes execution. This means any changes you make to the context won't affect execution of original function. You can see an example here: https://github.com/bytefire/esct/blob/master/esct.c.
If instead you want to manipulate the context, e.g. change values in registers, then use kprobes, which follow similar pattern but have slightly more involved semantics.
| Follow files execution by a kernel module [closed] |
1,582,710,236,000 |
I have RedHat Enterprise Linux Server 7, with kernel: 3.10.0-514 and I downloaded the linux kernel version 4.12.10 and I compile it and configure it without having any error here are the commands I executed:
make mrproper
make dep
make clean
make bzImage
make modules
make modules_install
the execution was done without errors.
then I copied the file System.map to /boot folder, executing:
cp System.map /boot/System.map-4.12.10
and then
cp arch/x86_64/boot/bzImage /boot/bzImage-4.12.10
But when I retstart the OS, I do not have the option to load the new kernel.
Any help please ?
|
Update your initramfs first :
sudo update-initramfs -c -k <kernel name>
For Rhel :
dracut -f -v /boot/<kernel name>
And then update your grub :
sudo update-grub
For Rhel:
grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg ##For BIOS based machines.
grub2-mkconfig -o /boot/grub2/grub.cfg #For UEFI based machines.
| Unable to load new kernel version in RedHat 7.3 |
1,582,710,236,000 |
OS Debian Jessie uname -a
Linux Taomon 3.16.0-4-amd64 #1 SMP Debian 3.16.43-2+deb8u2 (2017-06-26) x86_64 GNU/Linux
Notebook
dmidecode -t 1
# dmidecode 2.12
SMBIOS 2.5 present.
Handle 0x0001, DMI type 1, 27 bytes
System Information
Manufacturer: Acer
Product Name: Aspire 7736
Version: 0100
Serial Number: LXPJA0231102209DE42000
UUID: 34399FC0-6F14-11DF-BF16-AE2F22C409A5
Wake-up Type: Power Switch
SKU Number: Not Specified
Family: Not Specified
When module acer-wmi is loaded my gamepad is unusable. In Xorg.0.log I found
[ 32.403] (II) config/udev: Adding input device Acer BMA150 accelerometer (/dev/input/js0)
[ 32.403] (II) No input driver specified, ignoring this device.
[ 32.403] (II) This device may have been added with another device file.
even as root I can't access the device-node /dev/input/js0
Error opening joystick device "/dev/input/js0": Operation is not permitted
Is there a way to avoid this, without blacklist modul acer-wmi?
modinfo acer-wmi | grep -F parm
parm: mailled:Set initial state of Mail LED (int)
parm: brightness:Set initial LCD backlight brightness (int)
parm: threeg:Set initial state of 3G hardware (int)
parm: force_series:Force a different laptop series (int)
parm: ec_raw_mode:Enable EC raw mode (bool)
Installing kernel from Stretch is not possible, it will install a bunch of packages from stable. Sooner or later it will break apt
|
Now it works as I will. I created 2 udev-rules. The 1. erase the device /dev/input/js0.
cat /etc/udev/rules.d/98-accelerometer.rules
# joystick-fix
SUBSYSTEM=="input", ACTION=="remove", ATTRS{name}=="Acer BMA150 accelerometer", ATTRS{phys}=="wmi/input1", RUN+="/bin/rm %E{DEVNAME}"
SUBSYSTEM=="input", ACTION=="add", ATTRS{name}=="Acer BMA150 accelerometer", ATTRS{phys}=="wmi/input1", RUN+="/bin/rm %E{DEVNAME}"
Sadly, linux remember this device and my gamepad was /dev/input/js1 again.
The 2. creates a Symlink /dev/input/js0, so my emulator is no longer yammering.
cat /etc/udev/rules.d/99-joystick.rules
#joystick-fix 2. part
ACTION=="add", KERNEL=="js[1-9]", SUBSYSTEM=="input", ATTRS{product}=="USB Joystick ", SYMLINK+="input/js0"
| Module acer-wmi blocks gamepad |
1,483,543,885,000 |
My sound subsystem dies irregularly. It can be fixed by rebooting, but I am wondering if I can fix it simply by restarting it - thus avoiding the reboot.
I have tried:
pulseaudio --kill
That does not fix the problem.
Then I tried unloading the modules (to reload them later):
sudo modprobe -r snd_hda_codec_hdmi
sudo modprobe -r snd_hda_codec_analog
sudo modprobe -r snd_hda_codec_generic
sudo modprobe -r snd_hda_intel
sudo modprobe -r snd_hda_controller
sudo modprobe -r snd_hda_codec
sudo modprobe -r snd_hwdep
sudo modprobe -r snd_pcm
sudo modprobe -r snd_seq_midi
sudo modprobe -r snd_seq_midi_event
sudo modprobe -r snd_rawmidi
sudo modprobe -r snd_seq
sudo modprobe -r snd_seq_device
sudo modprobe -r snd_timer
sudo modprobe -r snd
sudo modprobe -r soundcore
All of these give:
modprobe: FATAL: Module XX is in use.
As some of them depend on eachother it makes sense for some of them, but not for this one:
$ lsmod |grep hdmi
snd_hda_codec_hdmi 53248 1
Then I tried forcing the removal:
$ sudo rmmod --force snd_hda_codec_hdmi
rmmod: ERROR: ../libkmod/libkmod-module.c:769 kmod_module_remove_module() could not remove 'snd_hda_codec_hdmi': Resource temporarily unavailable
rmmod: ERROR: could not remove module snd_hda_codec_hdmi: Resource temporarily unavailable
fuser -v /dev/snd/* returns nothing, so it does not seem there is a process accessing the sound subsystem.
Versions:
$ uname -a
Linux hp 3.19.0-32-generic #37~14.04.1-Ubuntu SMP Thu Oct 22 09:41:40 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/issue
Linux Mint 17.3 Rosa \n \l
|
This script https://gitlab.com/ole.tange/tangetools/tree/master/sound-reload fixes it for me every time.
| Sound dies. How to get it working again without rebooting? |
1,483,543,885,000 |
I am trying to get my android kernel working but I have a kernel module that is needed in order to get access to the file system of the device. Unfortunately there is no source code available so there are only the pre-compiled module and the kernel source. The kernel now tries to load the module without success. In the Module.symvers file in the kernel root directory the symbol that is needed is missing but the manufacturer of the device delivered a Module.symvers file from the root of the kernel source tree which includes all symbols that are needed.
How can I include those symbols in my kernel to get the module working?
|
The problem was the config file of the kernel. It disabled some features so the module would not load.
| Add symbols of LKM to kernel |
1,483,543,885,000 |
I developed a module which works as an emulator for a block device. When I write into the block device, I get this in dmesg and the module crashes. I cannot get any hint about what is going on?
[82013.054224] CPU: 9 PID: 15452 Comm: my_blk/0 Tainted: G B I E 3.19.0+ #1
[82013.054226] Hardware name: Dell Inc. PowerEdge R730xd/0599V5, BIOS 1.0.4 08/28/2014
[82013.054229] ffffffff81aa8fb8 ffff881fe1613778 ffffffff817a7f98 0000000000000000
[82013.054234] 0000000000000009 ffff881fe16137a8 ffffffff813c45b5 ffff880030243600
[82013.054239] ffff881fe0a4c798 ffff883feb3ced00 ffff881fe00c3900 ffff881fe16137b8
[82013.054244] Call Trace:
[82013.054251] [<ffffffff817a7f98>] dump_stack+0x4f/0x7b
[82013.054257] [<ffffffff813c45b5>] check_preemption_disabled+0xf5/0x110
[82013.054262] [<ffffffff813c4607>] debug_smp_processor_id+0x17/0x20
[82013.054276] [<ffffffffc03599dd>] megasas_build_io_fusion+0x54d/0x5a0 [megaraid_sas]
[82013.054287] [<ffffffffc0359af1>] megasas_build_and_issue_cmd_fusion+0x71/0x110 [megaraid_sas]
[82013.054296] [<ffffffffc034cf35>] megasas_queue_command+0x145/0x1b0 [megaraid_sas]
[82013.054301] [<ffffffff8154ae03>] scsi_dispatch_cmd+0x103/0x370
[82013.054306] [<ffffffff8154dcbf>] scsi_request_fn+0x4af/0x6c0
[82013.054311] [<ffffffff81374177>] __blk_run_queue+0x37/0x50
[82013.054315] [<ffffffff81374dd1>] queue_unplugged+0x41/0xf0
[82013.054320] [<ffffffff8137a042>] blk_flush_plug_list+0x1d2/0x210
[82013.054325] [<ffffffff8137a098>] blk_finish_plug+0x18/0x50
[82013.054331] [<ffffffff8127e54b>] ext4_writepages+0x55b/0xd10
[82013.054336] [<ffffffff812144ad>] ? __mnt_drop_write+0x2d/0x50
[82013.054342] [<ffffffff8109d624>] ? finish_task_switch+0x64/0x110
[82013.054348] [<ffffffff81187ea0>] do_writepages+0x20/0x40
[82013.054352] [<ffffffff8117c1a9>] __filemap_fdatawrite_range+0x59/0x60
[82013.054356] [<ffffffff8117c1e7>] filemap_write_and_wait_range+0x37/0x80
[82013.054360] [<ffffffff8127376a>] ext4_sync_file+0x12a/0x390
///// calling some functions in my_blk
[82013.054397] [<ffffffff81097b19>] kthread+0xc9/0xe0
[82013.054402] [<ffffffff81097a50>] ? flush_kthread_worker+0x90/0x90
[82013.054407] [<ffffffff817af7bc>] ret_from_fork+0x7c/0xb0
[82013.054412] [<ffffffff81097a50>] ? flush_kthread_worker+0x90/0x90
|
This problem happens when I set CONFIG_PREEMPT=y in my kernel configurations. To solve the problem on linux 3.19.0, I had to apply following patch, which change smp_processor_id() to raw_smp_processor_id() in drivers/scsi/megaraid/megaraid_sas_io_fusion.c. The patch is in the following link:
http://permalink.gmane.org/gmane.linux.scsi/100408
| CPU: 13 PID: 15452 Comm: ssd_blk/0 Tainted: G B I E 3.19.0+ #1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.