Opened 4 years ago

Closed 13 months ago

#11331 closed project (invalid)

rewrite tor in rust-lang

Reported by: cypherpunks Owned by:
Priority: Medium Milestone: Tor: very long term
Component: Core Tor/Tor Version:
Severity: Normal Keywords: rust
Cc: gk, erinn, jryans@…, Sebastian, Nekit, mgeisler Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

Rust provides many features that would benefit Tor like memory safety, etc. Writing C code that is safe is super hard (even for exeperienced Tor devs).

Child Tickets

Change History (14)

comment:1 Changed 4 years ago by nickm

Milestone: Tor: very long term

Not likely to happen except as an effort to refactor Tor into different modules and rewrite piece-by-piece. OTOH, there's nothing stopping somebody from doing a compatible implementation in whatever language they like. Rust enthusiasts: Prove the superiority of your language by writing a simpler, better, bug-free Tor today! ;)

comment:2 Changed 3 years ago by frewsxcv

I'm really interested in getting the ball moving for this. I'm going to look how the Mozilla devs integrated Rust into Firefox. Also, like nickm said in the previous comment, this should be done module by module. nickm gave me suggestions on IRC:

10:32 AM <nickm> frewsxcv: the workqueue.c code is a bit independent, is inherently threaded, and might be a good test of one's rust skills.
10:32 AM <nickm> frewsxcv: di_ops.c might be an even deeper test of whether-rust-can-even-do-that
10:32 AM <nickm> frewsxcv: rewriting as much as possible of routerparse.c could have concrete benefits
10:33 AM <nickm> frewsxcv: oh, in that case, try tor-resolv.c
10:33 AM <nickm> it depends on nothing
10:33 AM <nickm> Yawning: i think a wholesale rewrite is a bad choice, but that a piecemeal rewrite might be clever.
10:33 AM <nickm> frewsxcv: also, dircollate.c is mostly algorithmic
10:34 AM <nickm> Yawning: yeah but you already rewrote it in go
10:34 AM <nickm> as for things where rust is a good choice, though, our inner loops are most important, and not very isolated :/

Also it looks like dhuseby has already written a config parser https://github.com/dhuseby/torrc-rs

comment:3 Changed 3 years ago by gk

Cc: gk added

comment:4 Changed 3 years ago by nickm

Replacing torrc parsing in rust could be fun but we don't expect hostile input there.

buffers.c would be an interesting candidate, since it's low-level, performance-critical, and security-critical.

Nearly everything in src/tools is interesting but unlikely to be security-critical (in the sense that it doesn't need to handle tricky hostile inputs.)

comment:5 Changed 3 years ago by frewsxcv

Here's a relevant metabug from Mozilla's Bugzilla regarding integrating Rust compilation support into the build system for Gecko:

https://bugzilla.mozilla.org/show_bug.cgi?id=1135640

I took a look at the 'configure.ac' file with the hopes of integrating rustc into the build system. Needless to say the contents of it intimidated me a bit, but I haven't worked with many large C projects before so this sort of config file might be pretty common practice (unfortunately?). If anyone has any suggestions on where to start with respect to incorporating rustc into the build process, let me know.

comment:6 Changed 3 years ago by nickm

So in theory, the part that would need integration would be the various automake files (the various include.am files, plus Makefile.am).

Searching for "rust automake" gets a few hits, but I don't know if any are relevant.

One possibility is to better split Tor up into sublibraries, so that the C parts and the rust parts get built separately, but that would require a bit of rethinking, maybe.

comment:7 Changed 2 years ago by gk

Severity: Normal

#18621 is a duplicate.

comment:8 Changed 2 years ago by erinn

Cc: erinn added

comment:9 Changed 19 months ago by jryans

Cc: jryans@… added

comment:11 Changed 15 months ago by Sebastian

Cc: Sebastian added

comment:12 Changed 15 months ago by Nekit

Cc: Nekit added

comment:13 Changed 15 months ago by mgeisler

Cc: mgeisler added

comment:14 Changed 13 months ago by nickm

Keywords: rust added
Resolution: invalid
Status: newclosed

I'm closing this ticket, since a rewrite in any language is so large as to extend across multiple releases and milestones. The granularity here is just too high for a single ticket.

That doesn't mean no progress has been made, though. Right now, Tor has exploratory support for building with some parts of it in rust. If this works out well, and we manage to get things working nicely on every platform we care about, we can start figuring out which areas are highest-priority for doing in a safe language, and start opening tickets for them.

Note: See TracTickets for help on using tickets.