Commit graph

2883 commits

Author SHA1 Message Date
bunnie
0c657cffcd cleanup a hosted mode warning 2024-01-08 02:24:05 +08:00
bunnie
933666a67b add an implementation for new_with_strategy() on sha512trunc256
this is needed to unbreak hosted mode. The strategy in hosted
mode is *always* to use software as there is no hardware hashing
engine.
2024-01-08 02:23:23 +08:00
bunnie
055231cb5a extract loader hash from environment
also fix region alignment bug and version code bug.

tested, now works.
2024-01-08 01:44:17 +08:00
bunnie
b87dde9208 add new signature version code to api 2024-01-08 01:44:01 +08:00
bunnie
385e15084a add susres testing feature to the ticktimer-test-client 2024-01-06 15:45:20 +08:00
bunnie
10154b8372 add some comments and an assert to check consistency 2024-01-05 16:47:31 +08:00
bunnie
61686007c7 modify the signing routine to work with an unmapped kernel region
Now, we finally get to addressing the root cause of #472.

We can't map all of kernel memory anymore, because exclusivity of
ownership of pages is now properly enforced. This means that XIP
images, which run directly out of FLASH, map their code region of
FLASH into their processes. This disallows measurement of their
code spaces by the rootkeys crate; previously we had mapped all
of code space and could measure everyone's code but it also means
we had a double-ownership.

Having resolved that single-ownership is cleaner, we now have
a scheme where the loader, which sees all of the kernel anyways,
computes a hash and signature check of the kernel at boot time,
and pashes the unsigned hash on to the environment variables of Xous
(environment variables pending @xobs commits).

This commit fixes up all the kernel signing routines to work with
a now disjoint kernel memory space. In particular, the key signing
routine needs access to three parts of the FLASH region devoted
to storing `xous.img` (which is loosely and imprecisely referred
to as "kernel memory"; this does lead to confusion thinking that
we're referring to the RAM devoted to the kernel, but for this
discussion we are talking about the window of FLASH where `xous.img`
is written, along with other metadata related to it):

- the first page, where the signature is stored
- the end of the kernel, where the kernel length check is stored
- the end of the entire flash window, where the backup records
are stored

The first page is fairly self-explanatory, this is the signature,
some version information, and an unprotected length hint for the
kernel.

Because the length hint in the signature record is unprotected,
we have to repeat it at the end of the kernel data and include
it in the signed region. Thus, there is a window of memory
that is 2 pages large that captures the dynamically varying
(dynamically varying as in build-to-build this offset changes so
it can't be a `const`) location of the length data. 2 pages
are mapped because the region of interest can fall across a
page boundary, so we map the potential lower page and upper
page that captures the length field (although in most cases
the upper page is not used, it is harmless to map it pre-emptively).
A mask is provided so that we can use the previous compuattions
for offsets and just mask it to compute the offest within this
window.

The end of the flash window, the last page, contains the backup
records. This is a set of metadata that records information
about PDDB backups including the checksums of the regions and
encrypted access keys.

This patch attempts to find all accesses to kernel space and
bin them into their respective regions, while adjust their offsets.

Testing will require us to check signing, updating, and backups --
all aspects of the machine lifecycle are impacted!
2024-01-05 16:31:19 +08:00
bunnie
c73df68e15 add sha512-digest wrapper class
this is a trait wrapper that allows us to take pre-hash as
a `[u8]` and wrap it into a thing that hase a finalize() method
and the requisite traits to satisfy Rust, allowing us to pass
our loader-generated, environment-variable-passed hash into
an otherwise unawares cryptography crate.

mea culpa.
2024-01-05 16:29:41 +08:00
bunnie
c51c3cfe79 add std as a target for engine-sha512
we actually do have a `std` now in Xous, it wasn't there before
because we made this crate before we had `std`.

However, I'm not quite sure what apis we should be adding if we
have `std`...probably something else should be added, we'll probably
trip over it when someone tries to compile against a crate that
actually uses the `std`-specific APIs.
2024-01-05 16:19:05 +08:00
bunnie
4d850bffbc modulate the sha512 target based on the host configuration
xous targets use the Precursor hardware engine for hashing

all others use a software-only implementation. Not the most
performant but the code is vendored in
directly from the rustcrypto crate.
2024-01-05 16:17:59 +08:00
bunnie
2addc83f76 add an implementation for x86, etc. targets to run sha512 hashes
this is necessary because we are doing ed25519-dalek on the local
machine and the original signing crate used to implement signatures
("ring") does not support pre-hash mode.

maybe could do with cleaning up the build to eliminate "ring" and
just go with ed25519-dalek for all signings now, but we already
have "ring" as a dependency for other reasons so let's go
with conservative small changes for now.
2024-01-05 16:16:13 +08:00
bunnie
de9af9cfd1 add std test templates to shellchat
some tests cherry-picked out of the `std` suite to help look
into locking problems in the kernel. Behind a feature gate
of `locktests`
2024-01-04 23:19:51 +08:00
bunnie
8ec08c9c76 fix rust v1.75.0 warnings that are probably benign
a lot of re-import warnings have cropped up. While I appreciate
their studiousness on this, the problem is that removing some
of these exports in the API crate could mean that future users
who want access to some API features that aren't used in this
configuration are now unaccessible.

I think it's not a huge problem at the moment, just spam-cleaning
the warnings because there are too many to deal with carefully
at the moment.
2024-01-04 19:15:28 +08:00
bunnie
0d80912f0a fix warning in 1.75.0; breaking change with earlier rust versions
This is unfortunate, and calling this out in a single commit because
this is a dubious decision to achieve warning-free code for such
a minor thing.
2024-01-04 19:13:20 +08:00
bunnie
f88cca4401 cleanup hosted mode implementation for xous-log 2024-01-04 18:31:16 +08:00
Sean Cross
061abb05db xous-log: stdout: insert \r when printing \n
When printing messages to stdout or stderr, insert `\r` whenever we
encounter `\n`.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-12-29 19:01:19 +08:00
Sean Cross
409b50b85e blitstr2: regenerate files after template changes
Regenerate the font files after adjusting the template to generate files
that will not get changed by rustfmt.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-12-27 14:13:16 +08:00
Sean Cross
22546710df blitstr2: codegen: generate rustfmt-compatible code
Generate code that can be put through rustfmt without being altered.
This removes an issue where the font tables can be rearraged by simply
running `rustfmt` on the repository.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-12-27 14:12:26 +08:00
bunnie
fda782663a bump version pins for xous change 2023-12-26 00:13:10 +08:00
bunnie
b6306ac8f4 add debug statements around i2c locking 2023-12-24 23:51:24 +08:00
bunnie
5a0461cb01 make menu building a bit more efficient by not locking when not necessary 2023-12-24 23:51:04 +08:00
bunnie
7e04357aba modernize codec debug 2023-12-24 23:50:50 +08:00
bunnie
8931f10383 work around boot instability issue with a delay setting up codec in TTS
The `codec` seems to hang sometimes during `Setup8kStereo` at boot.
Did not get to the bottom of it, but suspect that the RTC I2C init
sequence is interfering with the codec init sequence. This might
be resolved while also fixing #467, but for now, a short delay
on boot works around the problem.
2023-12-24 23:35:47 +08:00
bunnie
23a9b0cc34 add more helpful debug output for token claim failure 2023-12-24 22:14:39 +08:00
bunnie
f9cf822efb fix #466
reverts pin to the published version on crates.io for smoltcp
2023-12-24 12:11:18 +08:00
bunnie
aaa52ca02c fix warning in en-tts build 2023-12-23 23:50:57 +08:00
bunnie
9c2523ded4 fix #227 2023-12-22 22:20:55 +08:00
bunnie
46588a418c pin smoltcp to a local fork
we need to tag out a release, so we're temporarily forking
`smoltcp` at its current head, testing it, and holding it
there until a full release is tagged out that captures all
of the good stuff that has been going on in that repo since
June.
2023-12-22 22:04:07 +08:00
bunnie
4917d16a02 add some notes about debugging smoltcp 2023-12-22 09:39:11 +08:00
bunnie
85def0adc5 don't block on connection manager
refactor CM routines so if the CM is hung it won't block the net
main thread.
2023-12-22 09:38:43 +08:00
bunnie
fcd7bc9bb8 allow pump to be falliable
attempt to reduce blocking in net path
2023-12-22 09:36:17 +08:00
nworbnhoj
7a75bf73e3
make net ws more robust to test websocket server connection failure 2023-12-12 16:12:22 +11:00
bunnie
fe2eb732a0 add a test for std seek 2023-12-10 12:54:06 +08:00
bunnie
2a521b5b86 fix stdseek to match std word ordering 2023-12-10 12:53:50 +08:00
bunnie
e0e908dbf4 fix utctimems to match std 2023-12-10 12:53:39 +08:00
bunnie
0a0ac292c3 modernize opcode debug on PDDB 2023-12-07 18:41:51 +08:00
bunnie
d9b8fe686d on second thought, no need to check if tz is 0
any time setting would have a non-zero utc offset since the hw
RTC starts near epoch. it is sufficient to just check for that.
2023-12-07 10:01:58 +08:00
bunnie
a36545073d fix #459
This is an error in the "unset time" validator -- should be an &&
statement instead of an || in checking for an unit'd state.
2023-12-07 02:15:25 +08:00
bunnie
9ab66eea80 change error message that's more of a warning 2023-12-07 02:15:05 +08:00
bunnie
7da070f37c fix #460 - prevent PDDB mount dialog from popping up during updates
check the newly-minted EC ready bit prior to running the PDDB mount
handler.
2023-12-07 01:31:06 +08:00
bunnie
6c39534a7b mark the EC as ready at the conclusion of all update activity
by marking the EC as ready after all the update checks are done
we can ensure that the PDDB mount dialog does not attempt to come
up during an EC update.
2023-12-07 01:30:33 +08:00
bunnie
5bff1f6c46 add routines to set/get EC readiness
The nominal purpose of this is to allow other services to delay
interactions that could interfere with an EC update.

Note that anyone could call this routine and mark the EC as not
ready, since the llio block is not secured and the API is public.

I don't think it's a security problem, but is a DoS vector.
2023-12-07 01:29:05 +08:00
bunnie
5aff0f2413 cleanup doc comment errors 2023-12-01 22:08:34 +08:00
bunnie
fa3f349a0a bump pins as xous-rs has changed 2023-12-01 21:20:01 +08:00
nworbnhoj
e8e875742e replace more TcpStream::connect(&str) with TcpStream::connect((&str, u16))
resolves #453
2023-11-30 20:29:15 +11:00
bunnie
367ede62b1 convert usbd-human-interface-device to xous-usb-hid 2023-11-16 17:27:00 +08:00
bunnie
419e547641 bump usbd-hid-device crate to latest
API changes to see if we want to absorb this prior to forking.
2023-11-12 00:02:07 +08:00
bunnie
4f75cd76a8 Merge branch 'main' of github.com:betrusted-io/xous-core into main 2023-11-11 23:13:19 +08:00
bunnie
5ad6106daf fix missing arg on unsafe-app-loading 2023-11-11 23:12:51 +08:00
bunnie
d4624124c9
Merge pull request #443 from betrusted-io/chat-status
WIP: Chat status
2023-11-03 13:54:34 +08:00