[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#860269: libkf5bluezqt6: kded5 leaks file descriptor to child processes, /dev/rfkill should be opened with CLOEXEC



¡Hola Stefan!

El 2017-04-13 a las 21:28 +0200, Stefan Fritsch escribió:
Package: libkf5bluezqt6 Version: 5.28.0-1 Severity: normal

I have noticed lvm tools complaining about leaked file descriptors when they are started from a shell in a kde konsole. One of the file descriptors is /dev/rfkill , which is likely opened by /usr/lib/x86_64-linux-gnu/libKF5BluezQt.so.5.28.0 (at least that's the only lib in kded5's /proc/../maps file that contains the string rfkill.

libkf5bluezqt6 should open the file with O_CLOEXEC to avoid leaks.

$ LANG=C ls -l /proc/$$/fd total 0 lrwx------ 1 stf stf 64 Apr 13 21:01 0 -> /dev/pts/3 lrwx------ 1 stf stf 64 Apr 13 21:01 1 -> /dev/pts/3 lrwx------ 1 stf stf 64 Apr 13 21:01 2 -> /dev/pts/3 lrwx------ 1 stf stf 64 Apr 13 21:01 255 -> /dev/pts/3 lr-x------ 1 stf stf 64 Apr 13 21:01 31 -> /dev/rfkill lrwx------ 1 stf stf 64 Apr 13 21:01 37 -> socket:[28435]

You description is almost a patch itself, I prepared a patch that adds the O_CLOEXEC flag, but I'm not sure how to reproduce the issue. Can you test the attached patch and tell us if this fixes the issue for you?

This issue seems to be an upstream issue, and since you know how to reproduce it, it would be better if you forward this issue upstream, reporting it via: https://bugs.kde.org

If you do so, please send us the url of the upstream bug.

Happy hacking,
--
"There are only two things wrong with C++: The initial concept and the
implementation."
-- Bertrand Meyer
Saludos /\/\ /\ >< `/
From: Maximiliano Curia <maxy@gnuservers.com.ar>
Date: Tue, 4 Jul 2017 12:07:56 +0200
Subject: Test patch for bugs.debian.org/860269

---
 src/rfkill.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/rfkill.cpp b/src/rfkill.cpp
index 39c8dc6..7bf8e52 100644
--- a/src/rfkill.cpp
+++ b/src/rfkill.cpp
@@ -128,7 +128,7 @@ void Rfkill::devReadyRead()
 void Rfkill::init()
 {
 #ifdef Q_OS_LINUX
-    m_readFd = ::open("/dev/rfkill", O_RDONLY);
+    m_readFd = ::open("/dev/rfkill", O_RDONLY | O_CLOEXEC);
 
     if (m_readFd == -1) {
         qCWarning(BLUEZQT) << "Cannot open /dev/rfkill for reading!";
@@ -157,7 +157,7 @@ bool Rfkill::openForWriting()
         return true;
     }
 
-    m_writeFd = ::open("/dev/rfkill", O_WRONLY);
+    m_writeFd = ::open("/dev/rfkill", O_WRONLY | O_CLOEXEC);
 
     if (m_writeFd == -1) {
         qCWarning(BLUEZQT) << "Cannot open /dev/rfkill for writing!";

Attachment: signature.asc
Description: PGP signature


Reply to: