commit a version that exhausts the kernel allocation

This commit is contained in:
bunnie 2021-01-07 16:58:13 +08:00
parent b884c8ed4f
commit 323c11f554
5 changed files with 39 additions and 26 deletions

View file

@ -243,6 +243,16 @@ fn xmain() -> ! {
let shell_id = xous::SID::from_bytes(b"shell ").unwrap();
let shell_conn = xous::connect(shell_id).unwrap();
/*
info!("Test NS registration");
let registration = Registration::new();
let mut sendable_registration = Sendable::new(registration)
.expect("can't create sendable registration structure");
write!(sendable_registration.name, "A test Name!").unwrap();
info!("namserver registration input: {:?}", sendable_registration.success);
sendable_registration.lend_mut(ns_conn, sendable_registration.mid()).expect("nameserver registration failure!");
info!("nameserver registration result: {:?}, {:?}", sendable_registration.success, sendable_registration.sid);
*/
let agent_conn: usize;
if cfg!(feature = "fccagent") {
let agent_id = xous::SID::from_bytes(b"fcc-agent-server").unwrap();

View file

@ -345,32 +345,25 @@ fn shell_main() -> ! {
)
.expect("unable to draw to screen");
/* test code to exhaust memory allocation */
let mut iter = 0;
info!("Test memory allocation");
loop {
let lookup = Lookup::new();
let mut sendable_lookup = Sendable::new(lookup)
.expect("can't create sendable lookup structure");
write!(sendable_lookup.name, "A test Name!").unwrap();
sendable_lookup.lend_mut(ns_conn, sendable_lookup.mid()).expect("nameserver lookup failure!");
info!("memtest: iter {}", iter);
iter += 1;
}
// Periodic tasks
if let Ok(elapsed_time) = ticktimer_server::elapsed_ms(ticktimer_conn) {
if elapsed_time - last_time > 500 {
last_time = elapsed_time;
info!("Requesting batt stats from COM");
get_batt_stats_nb(com_conn).expect("Can't get battery stats from COM");
info!("Test NS registration");
let registration = Registration::new();
let mut sendable_registration = Sendable::new(registration)
.expect("can't create sendable registration structure");
write!(sendable_registration.name, "A test Name!").unwrap();
info!("namserver registration input: {:?}", sendable_registration.success);
sendable_registration.lend_mut(ns_conn, sendable_registration.mid()).expect("nameserver registration failure!");
info!("nameserver registration result: {:?}, {:?}", sendable_registration.success, sendable_registration.sid);
info!("Test NS lookup");
let lookup = Lookup::new();
info!("making sendable");
let mut sendable_lookup = Sendable::new(lookup)
.expect("can't create sendable lookup structure");
info!("making a test name");
write!(sendable_lookup.name, "A test Name!").unwrap();
info!("nameserver lookup input: {:?}", sendable_lookup.success);
sendable_lookup.lend_mut(ns_conn, sendable_lookup.mid()).expect("nameserver lookup failure!");
info!("nameserver lookup result: {:?}, {:?}", sendable_lookup.success, sendable_lookup.cid);
}
} else {
error!("error requesting ticktimer!")

View file

@ -81,7 +81,7 @@ asking for access to the `ticktimer` or other public services.
B. flat denial: `xous-name-server` simply returns a message saying the
request was denied by setting `success` to `false`. This is also the case
when the request is malformed or incorrect. No information shall be leaked about the
nature of the denial. Denials are also delayed to the nearest 0.5 second interval since boot
nature of the denial. Denials are also delayed to the nearest 0.1 second interval since boot
to eliminate side channels and to rate limit fuzzing requests. Some
services (such as the key server) are restricted to only a set of
trusted process loaded at boot, and therefore it should not be

View file

@ -11,7 +11,7 @@ Calls are made using the xous::ipc::Sendable IPC wrapper, for example:
let mut sendable_registration = Sendable::new(registration)
.expect("can't create sendable registration structure");
write!(sendable_registration.name, "I'm a server, call me Fred!");
write!(sendable_registration.name, "I'm a server, please call me Fred!");
sendable_registration.lend_mut(ns_conn, sendable_registration.mid());

View file

@ -12,6 +12,8 @@ use heapless::consts::*;
use log::{error, info};
const FAIL_TIMEOUT_MS: u64 = 100;
#[xous::xous_main]
fn xmain() -> ! {
log_server::init_wait().unwrap();
@ -43,8 +45,8 @@ fn xmain() -> ! {
registration.success = true;
} else {
registration.success = false;
// compute the next interval that is 0.5s away
let target_time: u64 = ((ticktimer_server::elapsed_ms(ticktimer_conn).unwrap() / 500) + 1) * 500;
// compute the next interval, rounded to a multiple of FAIL_TIMEOUT_MS to reduce timing side channels
let target_time: u64 = ((ticktimer_server::elapsed_ms(ticktimer_conn).unwrap() / FAIL_TIMEOUT_MS) + 1) * FAIL_TIMEOUT_MS;
info!("NS: request failed, waiting for deterministic timeout");
while ticktimer_server::elapsed_ms(ticktimer_conn).unwrap() < target_time {
xous::yield_slice();
@ -56,9 +58,17 @@ fn xmain() -> ! {
let lookup: &mut Lookup = unsafe {
&mut *(m.buf.as_mut_ptr() as *mut Lookup)
};
/*
info!("NS: Lookup request for {}", lookup.name);
// lookup.cid = 1337;
lookup.success = true;
if let Ok(server_sid) = name_table.get(lookup) {
lookup.success = true;
let sender_pid = &envelope.sender.pid()?;
let connection_id = xous::connect_for_process(sender_pid, server_sid).expect("NS: can't broker connection");
lookup.cid = connection_id;
} else {
lookup.success = false;
// no authenticate remedy currently supported, but we'd put that code somewhere around here eventually.
}*/
} else {
error!("NS: unknown message ID received");
}