Irdroid / Irtoy_Irdroid_Patch

A patch for the Irtoy/Irdroid driver built in LIRC
0 stars 0 forks source link

Add buffer overflow protection #1

Open matejdro opened 2 years ago

matejdro commented 2 years ago

Hello,

a while ago I submitted this patch to LIRC, but it went nowhere: https://sourceforge.net/p/lirc/git/merge-requests/41/

Essentially, on my Pi 3, IR Droid USB will report buffer overflow and lock up after holding UP button on RC6 remote for couple of seconds. This resets the driver, allowing for subsequent commands.

Any chance you could include this into your patch, so there is one-patch-to-rule-them-all?

Irdroid commented 2 years ago

Can you post a lircd.conf file with codes for that remote?

Thanks

matejdro commented 2 years ago

Here you go:

mceusb.lircd.conf.txt

Irdroid commented 2 years ago

Hello,

a while ago I submitted this patch to LIRC, but it went nowhere: https://sourceforge.net/p/lirc/git/merge-requests/41/

Essentially, on my Pi 3, IR Droid USB will report buffer overflow and lock up after holding UP button on RC6 remote for couple of seconds. This resets the driver, allowing for subsequent commands.

Any chance you could include this into your patch, so there is one-patch-to-rule-them-all?

Why they didnt merged?, actually I see that your patch is now used in the new linux kernel driver, which addresses or rather works around the buffer overflow issue. https://github.com/torvalds/linux/blob/master/drivers/media/rc/ir_toy.c line #328

Irdroid commented 2 years ago

Hello, a while ago I submitted this patch to LIRC, but it went nowhere: https://sourceforge.net/p/lirc/git/merge-requests/41/ Essentially, on my Pi 3, IR Droid USB will report buffer overflow and lock up after holding UP button on RC6 remote for couple of seconds. This resets the driver, allowing for subsequent commands. Any chance you could include this into your patch, so there is one-patch-to-rule-them-all?

Why they didnt merged?, actually I see that your patch is now used in the new linux kernel driver, which addresses or rather works around the buffer overflow issue https://github.com/torvalds/linux/blob/master/drivers/media/rc/ir_toy.c line #328

matejdro commented 2 years ago

I have no idea why they didn't merge. Probably because project is dead already? There was no feedback from them.

I've tested the linux kernel driver and my patch is not included or at least does not work. After holding up button for several seconds, it will lock up and I have to replug the IrDroid to get it running again. I had to revert to older kernel and use patched LIRC to get it running again.

Irdroid commented 2 years ago

Can you post a lircd.conf file with codes for that remote?

Thanks

I cant seem to replicate that issue, here is a video

RC6 transmit using Irdroid USB Infrared Transceiver

my setup is as follows:

1 . I am using the mce lircd file and a windows machine to transmit the codes using winlirc

  1. Another module is connected to a linux machine running lircd 0.10.1 and irw to listen for the mce commands
Irdroid commented 2 years ago

I tried the above on a PC , but I guess something else may be happening on the raspberry Pi

matejdro commented 2 years ago

Yes, I also can't replicate it on the PC.

My theory is that different architecture and/or weaker processor on the Pi reduces buffer clearing rate and causes buffer overflow.

Irdroid commented 2 years ago

Yes, I also can't replicate it on the PC.

My theory is that different architecture and/or weaker processor on the Pi reduces buffer clearing rate and causes buffer overflow.

Have you tried the new kernel driver interface? The irtoy driver running in userspace should be much slower in comparison with the driver running in the kernel.

matejdro commented 2 years ago

Yes, it appears to have the same issues.

seanyoung commented 2 years ago

I have no idea why they didn't merge. Probably because project is dead already? There was no feedback from them.

The lirc maintainers have more or less given up on the project. However, I've been added as maintainer now and I've merged your patch.

I've tested the linux kernel driver and my patch is not included or at least does not work. After holding up button for several seconds, it will lock up and I have to replug the IrDroid to get it running again. I had to revert to older kernel and use patched LIRC to get it running again.

I have a hard time reproducing this issue. I have written a patch though. Would you be able to test it for me? Thanks

Also what model raspberry pi are you using and what os and os version?

0001-media-irtoy-report-receiver-overflow-and-restore-dev.patch.txt

matejdro commented 2 years ago

I have Raspberry Pi 3 B, running Arch Linux 4.19.88-1-ARCH #1 SMP PREEMPT Wed Dec 11 20:19:40 UTC 2019 armv7l GNU/Linux.

I assume this is kernel patch? I've never compiled kernel before, so testing this will take a while (need to figure out how to even do it).

seanyoung commented 2 years ago

I have Raspberry Pi 3 B, running Arch Linux 4.19.88-1-ARCH #1 SMP PREEMPT Wed Dec 11 20:19:40 UTC 2019 armv7l GNU/Linux.

I assume this is kernel patch? I've never compiled kernel before, so testing this will take a while (need to figure out how to even do it).

How did you test the new kernel driver?

This kernel is too old.

matejdro commented 2 years ago

I updated to the new kernel (sorry can't remember which version) and then I had downgraded due to above issue.

matejdro commented 2 years ago

I've tried building newer kernel for several days now and I've been unsuccessful (https://github.com/raspberrypi/linux/issues/5100).

Kernel 5.15 is the latest that seems to work on Pi 3B+ and that one has older ir_toy driver, so I cannot patch it.

I will see if I can get any help on this issue, in the meantime I will be using 5.15 with IR_TOY=n flag to get the old behavior back.