Posts
4778
Following
319
Followers
489
Linux kernel hacker and maintainer etc.

OpenPGP: 3AB05486C7752FE1

Jarkko Sakkinen

IMHO the thing in Rust and drivers is not memory safe per se or like "overflow check type of stuff".

It's the structural integrity check that levels up over C really. E.g. in C world I check that a TPM command holding buffer is not too large.

In Rust world I'll check in byte granularity that the data coming from user space and the chip is correct.
1
0
0

Jarkko Sakkinen

Edited 25 days ago
Do rustc eBPF branches unroll loops if they have const limit known by compiler?

I'm just thinking of theory of running tpm2_protocol inside eBPF filter i.e., is it possible and how much effort it would take it realize.

would be just a cool demo

it has lot of characteristics i.e. no-alloc (fully in-stack) and test program compiles without cargo with just rustc.

#linux #kernel #ebpf #rust #tpm
0
0
1

Jarkko Sakkinen

Edited 25 days ago
Conventions I'm converged on tpm2_protocol (for lib.rs):

//! * `alloc` is disallowed.
//! * Dependencies are disallowed.
//! * Developer dependencies are disallowed.
//! * Panics are disallowed.
0
0
0

Jarkko Sakkinen

Edited 25 days ago
the future of zmodem is async as I refined zmodem2 API as follows:

1. ZmodemSession holds the protocol state.
2. ZmodemEvent provides the interface for consuming next events.

I.e. it is to bind to the future (while being still decoupled from them). Also next version of protocol will be zero deps and can compile with rustc only.

#zmodem #rust
0
0
0

Jarkko Sakkinen

tpm2_protocol 0.6.1

0.6.0 and 0.6.1 are really the same, i just fucked up tpm2sh 0.6.0 so...

https://lore.kernel.org/tpm2/aKI-xQsBNNvjeBSk@kernel.org/T/#u
0
0
0

Jarkko Sakkinen

Edited 26 days ago
OK, learning Rust as I got but I was still missing Any implementation so here it is:

https://github.com/puavo-org/tpm2_library/commit/5066da1e529c2c6fc3667ae1e4f2be397836684b

This is a milestone commit given that the implementation is capable of empowering driver, which is a consequence of being able to dynamically interpret the protocol byte stream. I.e. starting from this commit ID it would it driver implementation ready.

It is proven by the test that builds a 100 element list of random objects, streams the list and parses from stream another list, and finally compares that the lists have equal amount of element and each element matches each other.

The test is here:

https://github.com/puavo-org/tpm2_library/blob/main/tpm2sh/tests/dynamic.rs
1
0
1

Jarkko Sakkinen

My favorite command-line parser for Rust:

https://github.com/blyxxyz/lexopt

I.e. it does not create command-line for you and you can fully control of the user experience.
1
0
0

Jarkko Sakkinen

still in progress but this will be a nice debugging feature:
1
0
0

Jarkko Sakkinen

Edited 28 days ago
I mean cli is a gui of one form and usuall guis are not sprayed to the source code

https://github.com/puavo-org/tpm2_library/commit/ddbce9387119c77b618988cd875dcbec812d7b96
1
0
0

Jarkko Sakkinen

I wonder if it either is or could be allowed kselftest to be written in Rust assuming that it requires only rustc and has at most std dependencies? Not talking a cargo build here.
1
0
0

Jarkko Sakkinen

Procedural macros in Rust:

- How to use them with plain rustc?
- Why they need to be in a lib crate?
0
0
0

Jarkko Sakkinen

Edited 28 days ago
The most important setting in fish shell:

set -g fish_autosuggestion_enabled 0

Fucking worst default in a shell that anyone has ever put to any shell (unless you are going epileptic seizure)
0
0
0

Jarkko Sakkinen

My tpm2_protocol crate could be useful also for e.g. some scenarios where you to format your crypto proofs in TPM2 structures wi/o having TPM.
0
0
0

Jarkko Sakkinen

Great, I've used before external crate for this:
https://doc.rust-lang.org/beta/std/io/trait.IsTerminal.html

Apparently std has had this for over two years already.
0
0
0

Jarkko Sakkinen

the next thing i do for tpm2_protocol is render out "rstest" and "hex" from cargo test and make my macro auto-generate roundtrip tests.

i'll also add a Makefile to the root with "make test" target. It will build the test binary with rustc and run the tests. Finally this will be added to the CI.
1
0
0

Jarkko Sakkinen

typoed rust-for-linux to my annoucement by accident as ust-for-linux ****
1
0
0

Jarkko Sakkinen

This was nasty one to fix and took many days (and nights tbh) but now finally command parsing is fixed and all my tests pass:

https://github.com/puavo-org/tpm2_library/commit/7b0fc824bd341fb21c90a06b945f01feb1c20f5e

There's MS TPM 2.0 emulator and swtpm, and that's like all of command parsing and response synthesis I'm aware of. I.e. by practical means there was no useful existing work to take example of :-) I'm pretty happy and a bit proud too that I've reach unipolarity by writing Rust macros reflecting TCG specifications.

I don't have now known bugs in the protocol crate. I'm sure there's a bunch but still feels nice after 1.5 weeks of sleepless nights and 7K SLOC of code (protocol + cli).

#linux #kernel #rust #tpm
1
0
1
Show older