mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-08-06 13:38:28 -04:00
core: fix security and concurrency issues found in a backend audit (#2805)
* core: fix security and concurrency issues found in backend audit Security: - privesc: pipe the sudo password via stdin (sudo -S) instead of embedding it in the command string, so it no longer appears in argv (readable by any local user via /proc/<pid>/cmdline or ps) - greeter: tokenize a session .desktop Exec= line into argv and execve directly instead of running it through /bin/sh -c, closing a command- injection path via user-writable ~/.local/share/wayland-sessions - plugins: reject path-separator/.. in plugin id/name before joining into a filesystem path, closing an arbitrary-directory-delete in the uninstall/update fallback - keybinds/hyprland: always quote unrecognized bind actions/keys when writing generated Lua; only re-emit genuine round-tripped custom Lua verbatim (tracked via an explicit flag), closing a Lua-injection path - desktop/mimeapps: reject newline/bracket in mime/desktop-id fields so they can't inject fake sections into the shared mimeapps.list Robustness / concurrency: - server: recover panics in the request-dispatch path so one bad handler can't crash the daemon and drop every client - go-wayland: recover panics in the shared dispatch choke point so a malformed compositor event can't crash CLI tools / the daemon - server: per-connection D-Bus client ID instead of a shared constant, fixing cross-client signal delivery and subscription teardown - network: guard the NetworkManager device maps with a mutex (a concurrent map read/write here is an unrecoverable fatal error) - cups: close the event channel on Stop() so Unsubscribe() of the last subscriber no longer deadlocks; allocate the fresh channel in Start() - freedesktop: reuse the shared session conn for the settings watcher and tear it down in Close(), fixing a per-Manager conn+goroutine leak - clipboard: mutex-guard lazy dbusConn creation - geolocation: use WithMatchMember for the GeoClue2 LocationUpdated signal (was WithMatchSender with an interface.member string, so the match never fired and live location updates never arrived) - screenshot: set failed=true on buffer/pool creation errors so the dispatch loop doesn't wait forever for a ready/failed that never comes * apply code review comments --------- Co-authored-by: bbedward <bbedward@gmail.com>
This commit is contained in:
@@ -37,6 +37,9 @@ func (sm *SubscriptionManager) Start() error {
|
||||
return fmt.Errorf("subscription manager already running")
|
||||
}
|
||||
sm.running = true
|
||||
// replace the channel closed by the previous Stop(); doing it here rather
|
||||
// than in Stop() guarantees a lagging eventHandler still observes the close
|
||||
sm.eventChan = make(chan SubscriptionEvent, 100)
|
||||
sm.mu.Unlock()
|
||||
|
||||
subID, err := sm.createSubscription()
|
||||
@@ -206,6 +209,8 @@ func (sm *SubscriptionManager) parseEvent(attrs ipp.Attributes) SubscriptionEven
|
||||
}
|
||||
|
||||
func (sm *SubscriptionManager) Events() <-chan SubscriptionEvent {
|
||||
sm.mu.Lock()
|
||||
defer sm.mu.Unlock()
|
||||
return sm.eventChan
|
||||
}
|
||||
|
||||
@@ -228,6 +233,13 @@ func (sm *SubscriptionManager) Stop() {
|
||||
}
|
||||
|
||||
sm.stopChan = make(chan struct{})
|
||||
|
||||
// the writer (notificationLoop) joined above, so closing is safe; without
|
||||
// this close Manager.eventHandler never returns and Unsubscribe deadlocks
|
||||
// on eventWG.Wait(). Start() allocates the replacement.
|
||||
sm.mu.Lock()
|
||||
close(sm.eventChan)
|
||||
sm.mu.Unlock()
|
||||
}
|
||||
|
||||
func (sm *SubscriptionManager) cancelSubscription() {
|
||||
|
||||
@@ -38,6 +38,8 @@ func (sm *DBusSubscriptionManager) Start() error {
|
||||
return fmt.Errorf("subscription manager already running")
|
||||
}
|
||||
sm.running = true
|
||||
// replaced here rather than in Stop(); see SubscriptionManager.Start()
|
||||
sm.eventChan = make(chan SubscriptionEvent, 100)
|
||||
sm.mu.Unlock()
|
||||
|
||||
conn, err := dbus.ConnectSystemBus()
|
||||
@@ -252,6 +254,8 @@ func (sm *DBusSubscriptionManager) parseDBusSignal(sig *dbus.Signal) Subscriptio
|
||||
}
|
||||
|
||||
func (sm *DBusSubscriptionManager) Events() <-chan SubscriptionEvent {
|
||||
sm.mu.Lock()
|
||||
defer sm.mu.Unlock()
|
||||
return sm.eventChan
|
||||
}
|
||||
|
||||
@@ -278,6 +282,12 @@ func (sm *DBusSubscriptionManager) Stop() {
|
||||
}
|
||||
|
||||
sm.stopChan = make(chan struct{})
|
||||
|
||||
// the writer (dbusListenerLoop) joined above, so closing is safe; see
|
||||
// SubscriptionManager.Stop()
|
||||
sm.mu.Lock()
|
||||
close(sm.eventChan)
|
||||
sm.mu.Unlock()
|
||||
}
|
||||
|
||||
func (sm *DBusSubscriptionManager) cancelSubscription() {
|
||||
|
||||
Reference in New Issue
Block a user