Files
RedBear-OS/local/patches/base/P18-8-bounded-ipcd-queues.patch
T
vasilito cee25393d8 fix: boot process improvements — dependency cycle, INIT_NOTIFY, probing loop, and log spam fixes
- Fix P15-8-init-cycle-detection.patch: replace visiting+error with seen+silent-skip
  to eliminate 11 false-positive 'dependency cycle detected' errors on shared deps
- Fix P0-daemon-fix-init-notify-unwrap.patch: remove eprintln! for missing
  INIT_NOTIFY (expected for oneshot_async services, ~7 daemons affected)
- Fix driver-manager hotplug loop: add PERMANENTLY_SKIPPED static set shared
  between hotplug handler and DriverConfig::probe() to stop infinite re-probing
  of Fatal/NotSupported/deferred-exhausted device+driver pairs (e.g. ided)
- Fix driver-manager log_timeline: suppress repeated EPIPE/ENOENT errors with
  AtomicI32 dedup and AtomicBool one-shot guards for boot timeline JSON
- Add driver-manager SIGTERM handler, ACPI bus registration, --status mode,
  driver reap loop, graceful shutdown, and reduced deferred retries (30→3)
2026-05-17 12:34:02 +03:00

119 lines
3.7 KiB
Diff

--- a/ipcd/src/chan.rs
+++ b/ipcd/src/chan.rs
@@ -16,6 +16,9 @@
path: Option<String>,
awaiting: VecDeque<usize>,
}
+
+/// Maximum pending connections per listener (like Linux SOMAXCONN).
+const MAX_LISTENER_BACKLOG: usize = 64;
#[derive(Debug)]
pub enum Extra {
Client(Client),
@@ -66,6 +69,9 @@
pub fn connect(&mut self, other: usize) -> Result<()> {
match self.extra {
Extra::Listener(ref mut listener) => {
+ if listener.awaiting.len() >= MAX_LISTENER_BACKLOG {
+ return Err(Error::new(ECONNREFUSED));
+ }
listener.awaiting.push_back(other);
Ok(())
}
--- a/ipcd/src/uds/stream.rs
+++ b/ipcd/src/uds/stream.rs
@@ -32,6 +32,11 @@
}
}
+/// Maximum pending connections per UDS listener.
+const MAX_UDS_LISTENER_BACKLOG: usize = 64;
+/// Maximum queued data packets per connection before dropping/warning.
+const MAX_UDS_PACKET_QUEUE: usize = 256;
+
#[derive(Debug, Default, Clone, PartialEq, Eq)]
struct Connection {
peer: usize,
@@ -305,14 +310,18 @@
}
_ => return Err(Error::new(ECONNREFUSED)),
}
- self.connect_unchecked(other, client_ucred);
+ self.connect_unchecked(other, client_ucred)?;
Ok(())
}
- fn connect_unchecked(&mut self, other: &mut Socket, client_ucred: ucred) {
+ fn connect_unchecked(&mut self, other: &mut Socket, client_ucred: ucred) -> Result<()> {
+ if self.awaiting.len() >= MAX_UDS_LISTENER_BACKLOG {
+ return Err(Error::new(ECONNREFUSED));
+ }
self.awaiting.push_back((other.primary_id, client_ucred));
other.state = State::Connecting;
other.connection = Some(Connection::new(self.primary_id));
+ Ok(())
}
fn is_listening(&self) -> bool {
@@ -753,6 +762,9 @@
return Ok(0);
}
+ if connection.packets.len() >= MAX_UDS_PACKET_QUEUE {
+ return Err(Error::new(EAGAIN));
+ }
connection.packets.push_back(packet);
(payload_len, remote_id)
};
@@ -997,7 +1010,7 @@
return Err(Error::new(EPIPE));
}
let pair_ucred = ucred { pid: ctx.pid as _, uid: ctx.uid as _, gid: ctx.gid as _ };
- socket.connect_unchecked(&mut new, pair_ucred);
+ socket.connect_unchecked(&mut new, pair_ucred)?;
}
// smoltcp sends writeable whenever a listener gets a
@@ -1059,6 +1072,9 @@
name,
);
let packet = DataPacket::new(buf.to_vec(), ancillary_data);
+ if connection.packets.len() >= MAX_UDS_PACKET_QUEUE {
+ return Err(Error::new(EAGAIN));
+ }
connection.packets.push_back(packet);
}
}
--- a/ipcd/src/uds/dgram.rs
+++ b/ipcd/src/uds/dgram.rs
@@ -21,6 +21,9 @@
mem,
rc::Rc,
};
+
+/// Maximum queued datagrams per socket.
+const MAX_DGRAM_QUEUE: usize = 256;
use syscall::{error::*, flag::*, schemev2::NewFdFlags, Error, FobtainFdFlags, Stat};
#[derive(Debug, Default)]
@@ -393,6 +396,9 @@
Credential::new(pid as i32, uid as i32, gid as i32),
)?;
let payload_len = message.len();
+ if socket.messages.len() >= MAX_DGRAM_QUEUE {
+ return Err(Error::new(EAGAIN));
+ }
socket.messages.push_back(message);
Ok(payload_len)
@@ -559,6 +565,9 @@
name,
),
);
+ if remote.messages.len() >= MAX_DGRAM_QUEUE {
+ return Err(Error::new(EAGAIN));
+ }
remote.messages.push_back(message);
self.post_fevent(remote_id, EVENT_READ.bits())?;