libkmod: Fix open file which some char device#407
libkmod: Fix open file which some char device#407opsiff wants to merge 1 commit intokmod-project:masterfrom
Conversation
|
LGTM. @guludo since this is coming from that commit to allow modprobing from a relative path... are you ok with this too? |
Codecov Report❌ Patch coverage is
🚀 New features to boost your workflow:
|
evelikov
left a comment
There was a problem hiding this comment.
General comment, take it with a pinch of salt.
Having the lseek without any comment, might result in us removing it a few month/years down the line.
Alternative is to use fstat + S_IFREG, which will also catch character/block/directory/symlink... and reduce TOCTOU races. Admittedly I'm not 100% sure:
- which syscall is lighter
- if any existing path intentionally does not resolve when path is a symlink
OK, I will add a comment.
lseek also use file->fd, I use lseek because origin it have a lseek call before the pr here.
I think lseek is lighter little, I have no idea here.
I think symlink resolve in open, I am also not 100% sure. BRs |
|
Here is fstat version patch, it is longer than lseek, @evelikov : |
|
The TOCTOU mentioned refers to the time frame between the file/path checks and the respective
Correct - symlinks are not resolved, only when using |
right, I think we should just add a comment. To me it makes sense to bail out on non-seekable fd since this function depends on lseek to work. |
lucasdemarchi
left a comment
There was a problem hiding this comment.
with the comment added this seems good to me. @evelikov does that handle your concern?
use lseek SEEK_CUR to get whether it is a regular file, lseek return -ESPIPE when fd is associated with a pipe, socket, or FIFO. commit 883d931 upstream ("modprobe: Allow passing path to module") allow to modprobe a file, but not handle opening a FIFO device such as modprobe /dev/tty1. commit 8d03b6c uptream ("libkmod: Use pread where appropriate") fix some cases, such as open /dev/tty1, but not for /dev/vmnet0 or /dev/userio etc. Can be reproduced in run lshw in root and install some vm such ad vmware, more about the case are in the Link. Reference: lyonel/lshw#110 Closes: https://bugs.launchpad.net/ubuntu/+source/lshw/+bug/2069649 Closes: https://bbs.deepin.org.cn/post/291466 Reported-by: Qi Xu <xuqi@uniontech.com> Reported-by: lionheartyu <dongshengyuan@uniontech.com> Fixes: 883d931 ("modprobe: Allow passing path to module") Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
5310034 to
916d414
Compare
use lseek SEEK_CUR to get whether it is a regular file, lseek return -ESPIPE when fd is associated with a pipe, socket, or FIFO. commit 883d931 upstream ("modprobe: Allow passing path to module") allow to modprobe a file, but not handle opening a FIFO device such as modprobe /dev/tty1. commit 8d03b6c uptream ("libkmod: Use pread where appropriate") fix some cases, such as open /dev/tty1, but not for /dev/vmnet0 or /dev/userio etc. Can be reproduced in run lshw in root and install some vm such ad vmware, more about the case are in the Link. Reference: lyonel/lshw#110 Closes: https://bugs.launchpad.net/ubuntu/+source/lshw/+bug/2069649 Closes: https://bbs.deepin.org.cn/post/291466 Reported-by: Qi Xu <xuqi@uniontech.com> Reported-by: lionheartyu <dongshengyuan@uniontech.com> Fixes: 883d931 ("modprobe: Allow passing path to module") Signed-off-by: Wentao Guan <guanwentao@uniontech.com> Reviewed-by: Lucas De Marchi <demarchi@kernel.org> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com> Link: #407 Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
|
Applied, thanks |
use lseek SEEK_CUR to get whether it is a regular file, lseek return -ESPIPE when fd is associated with a pipe, socket, or FIFO.
commit 883d931 upstream ("modprobe: Allow passing path to module") allow to modprobe a file, but not handle opening a FIFO device such as modprobe /dev/tty1.
commit 8d03b6c uptream ("libkmod: Use pread where appropriate") fix some cases, such as open /dev/tty1, but not for /dev/vmnet0 or /dev/userio etc.
Can be reproduced in run lshw in root and install some vm such ad vmware, more about the case are in the Link.
Link: lyonel/lshw#110
Link: https://bugs.launchpad.net/ubuntu/+source/lshw/+bug/2069649
Link: https://bbs.deepin.org.cn/post/291466
Reported-by: Qi Xu xuqi@uniontech.com
Reported-by: lionheartyu dongshengyuan@uniontech.com
Fixes: 883d931 ("modprobe: Allow passing path to module")