Skip to content

Commit 157b0ae

Browse files
committed
add rustsec notes
1 parent ce76b3e commit 157b0ae

File tree

2 files changed

+346
-0
lines changed

2 files changed

+346
-0
lines changed

content/hacking/rustsec.md

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
+++
2+
title = "RustSec"
3+
author = ["Aimee Z"]
4+
description = "Rust and security related"
5+
date = 2021-10-08
6+
draft = false
7+
[menu.main]
8+
weight = 2001
9+
identifier = "rustsec"
10+
+++
11+
12+
<div class="ox-hugo-toc toc">
13+
<div></div>
14+
15+
<div class="heading">Table of Contents</div>
16+
17+
- [Solana dependencies](#solana-dependencies)
18+
19+
</div>
20+
<!--endtoc-->
21+
22+
23+
## Solana dependencies {#solana-dependencies}
24+
25+
When we worked on Solana project, we met a problem that we couldn't update
26+
crate dependencies with `cargo update`.
27+
28+
```shell
29+
$ cargo update -p nix
30+
Updating crates.io index
31+
```
32+
33+
But nothing changed. We kept trying:
34+
35+
```shell
36+
$ cargo update -p nix --precise 0.20.2
37+
Updating crates.io index
38+
error: failed to select a version for `memoffset`.
39+
... required by package `nix v0.20.2`
40+
... which is depended on by `ctrlc v3.1.9`
41+
... which is depended on by `solana-cli v1.9.0 (/<my_path>/solana/cli)`
42+
versions that meet the requirements `^0.6.3` are: 0.6.4, 0.6.3
43+
44+
all possible versions conflict with previously selected packages.
45+
46+
previously selected package `memoffset v0.6.1`
47+
... which is depended on by `crossbeam-epoch v0.9.5`
48+
... which is depended on by `crossbeam-deque v0.8.1`
49+
... which is depended on by `rayon v1.5.1`
50+
... which is depended on by `dashmap v4.0.2`
51+
... which is depended on by `solana-core v1.9.0 (/<my_path>/solana/core)`
52+
... which is depended on by `solana-accounts-cluster-bench v1.9.0 (/<my_path>/solana/accounts-cluster-bench)`
53+
54+
failed to select a version for `memoffset` which could resolve this conflict
55+
```
56+
57+
```shell
58+
$ cargo update -p ctrlc -p nix
59+
Updating crates.io
60+
61+
$ git status
62+
On branch master
63+
Your branch is up to date with 'origin/master'.
64+
65+
nothing to commit, working tree clean
66+
```
67+
68+
One more:
69+
70+
```shell
71+
$ cargo update -p ctrlc -p nix -p crossbeam-epoch -p crossbeam-deque -p rayon -p dashmap
72+
Updating crates.io index
73+
Updating ctrlc v3.1.9 -> v3.2.1
74+
Updating memoffset v0.6.1 -> v0.6.4
75+
Adding nix v0.23.0
76+
77+
78+
79+
$ git status
80+
On branch master
81+
Your branch is up to date with 'origin/master'.
82+
83+
Changes not staged for commit:
84+
(use "git add <file>..." to update what will be committed)
85+
(use "git restore <file>..." to discard changes in working directory)
86+
modified: Cargo.lock
87+
88+
no changes added to commit (use "git add" and/or "git commit -a")
89+
```
90+
91+
Use `tree`:
92+
93+
```shell
94+
$ cargo tree -p nix
95+
error: There are multiple `nix` packages in your project, and the specification `nix` is ambiguous.
96+
Please re-run this command with `-p <spec>` where `<spec>` is one of the following:
97+
nix:0.20.0
98+
nix:0.23.0
99+
```
100+
101+
```shell
102+
$ cargo tree -p nix:0.20.0
103+
nix v0.20.0
104+
├── bitflags v1.3.2
105+
├── cfg-if v1.0.0
106+
└── libc v0.2.103
107+
108+
109+
$ cargo tree -p nix:0.20.0 -i
110+
nix v0.20.0
111+
├── solana-install v1.9.0 (/<my_path>/solana/install)
112+
├── solana-net-utils v1.9.0 (/<my_path>/solana/net-utils)
113+
│ ├── solana-accounts-cluster-bench v1.9.0 (/<my_path>/solana/accounts-cluster-bench)
114+
│ ├── solana-bench-streamer v1.9.0 (/<my_path>/solana/bench-streamer)
115+
│ ├── solana-bench-tps v1.9.0 (/<my_path>/solana/bench-tps)
116+
│ ├── solana-client v1.9.0 (/<my_path>/solana/client)
117+
│ │ ├── solana-accounts-cluster-bench v1.9.0 (/<my_path>/solana/accounts-cluster-bench)
118+
...
119+
```
120+
121+
```shell
122+
$ rg nix -t toml
123+
net-utils/Cargo.toml
124+
16:nix = "0.20.0"
125+
126+
sys-tuner/Cargo.toml
127+
20:[target."cfg(unix)".dependencies]
128+
21:unix_socket2 = "0.5.4"
129+
23:nix = "0.20.0"
130+
131+
ledger-tool/Cargo.toml
132+
43:[target."cfg(unix)".dependencies]
133+
134+
programs/bpf/Cargo.lock
135+
1559:name = "nix"
136+
3079: "nix",
137+
138+
streamer/Cargo.toml
139+
20:nix = "0.20.0"
140+
141+
Cargo.lock
142+
997: "nix 0.23.0",
143+
2605:name = "nix"
144+
2617:name = "nix"
145+
4915: "nix 0.20.0",
146+
5159: "nix 0.20.0",
147+
5705: "nix 0.20.0",
148+
5720: "nix 0.20.0",
149+
5724: "unix_socket2",
150+
6853:name = "unix_socket2"
151+
152+
validator/Cargo.toml
153+
55:[target."cfg(unix)".dependencies]
154+
155+
install/Cargo.toml
156+
23:nix = "0.20.0"
157+
```
158+
159+
```shell
160+
$ cargo update -p nix:0.20.0 --precise 0.20.2
161+
Updating crates.io index
162+
error: failed to select a version for `bitflags`.
163+
... required by package `nix v0.20.2`
164+
... which is depended on by `solana-install v1.9.0 (/<my_path>/solana/install)`
165+
versions that meet the requirements `>=1.1.0, <1.3.0` are: 1.2.1, 1.2.0, 1.1.0
166+
167+
all possible versions conflict with previously selected packages.
168+
169+
previously selected package `bitflags v1.3.1`
170+
... which is depended on by `nix v0.23.0`
171+
... which is depended on by `ctrlc v3.2.1`
172+
... which is depended on by `solana-cli v1.9.0 (/<my_path>/solana/cli)`
173+
174+
failed to select a version for `bitflags` which could resolve this conflict
175+
```
176+
177+
Haven't solved it yet. To be continued.

notes.org

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,175 @@
77
:EXPORT_HUGO_MENU: :menu main
88
:END:
99

10+
** RustSec
11+
:PROPERTIES:
12+
:EXPORT_FILE_NAME: rustsec
13+
:EXPORT_DATE: 2021-10-08
14+
:EXPORT_HUGO_SECTION: hacking
15+
:EXPORT_DESCRIPTION: Rust and security related
16+
:EXPORT_OPTIONS: toc:2
17+
:END:
18+
19+
20+
*** Solana dependencies
21+
22+
When we worked on Solana project, we met a problem that we couldn't update
23+
crate dependencies with =cargo update=.
24+
25+
#+begin_src shell
26+
$ cargo update -p nix
27+
Updating crates.io index
28+
#+end_src
29+
30+
But nothing changed. We kept trying:
31+
32+
#+begin_src shell
33+
$ cargo update -p nix --precise 0.20.2
34+
Updating crates.io index
35+
error: failed to select a version for `memoffset`.
36+
... required by package `nix v0.20.2`
37+
... which is depended on by `ctrlc v3.1.9`
38+
... which is depended on by `solana-cli v1.9.0 (/<my_path>/solana/cli)`
39+
versions that meet the requirements `^0.6.3` are: 0.6.4, 0.6.3
40+
41+
all possible versions conflict with previously selected packages.
42+
43+
previously selected package `memoffset v0.6.1`
44+
... which is depended on by `crossbeam-epoch v0.9.5`
45+
... which is depended on by `crossbeam-deque v0.8.1`
46+
... which is depended on by `rayon v1.5.1`
47+
... which is depended on by `dashmap v4.0.2`
48+
... which is depended on by `solana-core v1.9.0 (/<my_path>/solana/core)`
49+
... which is depended on by `solana-accounts-cluster-bench v1.9.0 (/<my_path>/solana/accounts-cluster-bench)`
50+
51+
failed to select a version for `memoffset` which could resolve this conflict
52+
#+end_src
53+
54+
#+begin_src shell
55+
$ cargo update -p ctrlc -p nix
56+
Updating crates.io
57+
58+
$ git status
59+
On branch master
60+
Your branch is up to date with 'origin/master'.
61+
62+
nothing to commit, working tree clean
63+
#+end_src
64+
65+
One more:
66+
67+
#+begin_src shell
68+
$ cargo update -p ctrlc -p nix -p crossbeam-epoch -p crossbeam-deque -p rayon -p dashmap
69+
Updating crates.io index
70+
Updating ctrlc v3.1.9 -> v3.2.1
71+
Updating memoffset v0.6.1 -> v0.6.4
72+
Adding nix v0.23.0
73+
74+
75+
76+
$ git status
77+
On branch master
78+
Your branch is up to date with 'origin/master'.
79+
80+
Changes not staged for commit:
81+
(use "git add <file>..." to update what will be committed)
82+
(use "git restore <file>..." to discard changes in working directory)
83+
modified: Cargo.lock
84+
85+
no changes added to commit (use "git add" and/or "git commit -a")
86+
#+end_src
87+
88+
Use =tree=:
89+
90+
#+begin_src shell
91+
$ cargo tree -p nix
92+
error: There are multiple `nix` packages in your project, and the specification `nix` is ambiguous.
93+
Please re-run this command with `-p <spec>` where `<spec>` is one of the following:
94+
nix:0.20.0
95+
nix:0.23.0
96+
97+
#+end_src
98+
99+
#+begin_src shell
100+
$ cargo tree -p nix:0.20.0
101+
nix v0.20.0
102+
├── bitflags v1.3.2
103+
├── cfg-if v1.0.0
104+
└── libc v0.2.103
105+
106+
107+
$ cargo tree -p nix:0.20.0 -i
108+
nix v0.20.0
109+
├── solana-install v1.9.0 (/<my_path>/solana/install)
110+
├── solana-net-utils v1.9.0 (/<my_path>/solana/net-utils)
111+
│ ├── solana-accounts-cluster-bench v1.9.0 (/<my_path>/solana/accounts-cluster-bench)
112+
│ ├── solana-bench-streamer v1.9.0 (/<my_path>/solana/bench-streamer)
113+
│ ├── solana-bench-tps v1.9.0 (/<my_path>/solana/bench-tps)
114+
│ ├── solana-client v1.9.0 (/<my_path>/solana/client)
115+
│ │ ├── solana-accounts-cluster-bench v1.9.0 (/<my_path>/solana/accounts-cluster-bench)
116+
...
117+
#+end_src
118+
119+
#+begin_src shell
120+
$ rg nix -t toml
121+
net-utils/Cargo.toml
122+
16:nix = "0.20.0"
123+
124+
sys-tuner/Cargo.toml
125+
20:[target."cfg(unix)".dependencies]
126+
21:unix_socket2 = "0.5.4"
127+
23:nix = "0.20.0"
128+
129+
ledger-tool/Cargo.toml
130+
43:[target."cfg(unix)".dependencies]
131+
132+
programs/bpf/Cargo.lock
133+
1559:name = "nix"
134+
3079: "nix",
135+
136+
streamer/Cargo.toml
137+
20:nix = "0.20.0"
138+
139+
Cargo.lock
140+
997: "nix 0.23.0",
141+
2605:name = "nix"
142+
2617:name = "nix"
143+
4915: "nix 0.20.0",
144+
5159: "nix 0.20.0",
145+
5705: "nix 0.20.0",
146+
5720: "nix 0.20.0",
147+
5724: "unix_socket2",
148+
6853:name = "unix_socket2"
149+
150+
validator/Cargo.toml
151+
55:[target."cfg(unix)".dependencies]
152+
153+
install/Cargo.toml
154+
23:nix = "0.20.0"
155+
#+end_src
156+
157+
158+
#+begin_src shell
159+
$ cargo update -p nix:0.20.0 --precise 0.20.2
160+
Updating crates.io index
161+
error: failed to select a version for `bitflags`.
162+
... required by package `nix v0.20.2`
163+
... which is depended on by `solana-install v1.9.0 (/<my_path>/solana/install)`
164+
versions that meet the requirements `>=1.1.0, <1.3.0` are: 1.2.1, 1.2.0, 1.1.0
165+
166+
all possible versions conflict with previously selected packages.
167+
168+
previously selected package `bitflags v1.3.1`
169+
... which is depended on by `nix v0.23.0`
170+
... which is depended on by `ctrlc v3.2.1`
171+
... which is depended on by `solana-cli v1.9.0 (/<my_path>/solana/cli)`
172+
173+
failed to select a version for `bitflags` which could resolve this conflict
174+
#+end_src
175+
176+
Haven't solved it yet. To be continued.
177+
178+
10179
** Syntax of method calls :rust:@hacking:
11180
:PROPERTIES:
12181
:EXPORT_FILE_NAME: rust-method-syntax

0 commit comments

Comments
 (0)