How to make a USB barcode scanner unrecognizable in the kernel


#1

My kernel version is 4.18.16-300.fc29_x86.I have a scanning gun with USB interface, which can be identified on my computer.What I need to do now is to prohibit the identification of this scanner at the kernel level.My idea is to identify PID and VID and filter them out. But I don’t know how to change it at the kernel level. What should I do? Do you have any ideas?


#2

You can de-authorize the device via udev.


#3

Udev is user mode, and I want to solve this problem at the kernel level


#4

You could unplug the USB device. This is hardware level, even lower than
kernel level!


#5

No, no, the task requires finding solutions at the kernel level. I want to read the PID and VID of the scanner gun from the kernel and ban them. Is this ok?


#6

OH! So you want to use this device from userspace, and not have the kernel
managing the device? You can do that with udev rules as suggested above, in
fact, you can use the same udev rules to start your software if you like.


#7

No, I’m trying to disable this device at the kernel level and make it unusable on my Fedora system. In other words, it’s a kernel-level modification that makes the computer unrecognizable after inserting a scanning gun.


#8

The udev rule tells the kernel not to trust the device, which completely disables it at the kernel level. That’s pretty much the furthest you’ll be able to easily get.

What’s your use case?


#9

It is used to study Linux kernel and device driver management. This is the task given by the tutor, which requires that the device be unrecognizable at the kernel level.


#10

Is there any other way? Can I filter out the device’s two IDs from the kernel level?


#11

It’s not possible to prevent the kernel from seeing devices on the USB bus.
Even if you were to write a kernel module that takes ownership of the device,
the kernel is still going to see the device. Whether it actually does
something with that device is another story entirely.


#13

Oh, I see.
What should I do? Or can I prevent the kernel from loading a USB driver to make it not work?


#14

Have you tried just asking the instructor? This is definitely a bit odd to answer without knowing some more details… You can block USB storage devices, but that might not work on this because…well, it’s not actually a USB storage device.


#15

Yes, what details do you want to know that I can provide? I can hardly see my teacher. He often travels on business. I couldn’t discuss it with him in time.


#16

Assuming the kernel module used to drive the device isn’t builtin, you could
add it to the blacklist theoretically…


#17

oh,thanks.I’ll study it again.


#18

Ah - my guess is the tutor is looking for blacklisting.


#20

How to modify the kernel and disable it? Do you have any ideas?


#21

You honestly really just have to ask the tutor… Outside of blacklisting a driver (the device will still show up, it just won’t work) or deauthenticating through udev, this isn’t really something that’s easily attainable, and I really think there was just a misunderstanding of the extent that the device needs to be unrecognizable (probably just need to make sure no drivers are picking it up).