Skip to content

Commit 4c1a6e6

Browse files
committed
fixup code blocks in docs
1 parent d9c9218 commit 4c1a6e6

9 files changed

Lines changed: 72 additions & 57 deletions

liburing-rs/docs/io_uring_recvmsg_cmsg_nexthdr.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ NULL.
1414

1515
The structure is defined as follows:
1616

17-
17+
```c
1818
struct io_uring_recvmsg_out {
1919
__u32 namelen; /* Name byte count as would have been populated
2020
* by recvmsg(2) */
@@ -24,17 +24,13 @@ The structure is defined as follows:
2424
__u32 flags; /* Flags result as would have been populated
2525
* by recvmsg(2) */
2626
};
27+
```
2728
28-
io_uring_recvmsg_name(3)
29-
returns a pointer to the name in the buffer.
30-
io_uring_recvmsg_cmsg_firsthdr(3)
31-
returns a pointer to the first cmsg in the buffer, or NULL.
32-
io_uring_recvmsg_cmsg_nexthdr(3)
33-
returns a pointer to the next cmsg in the buffer, or NULL.
34-
io_uring_recvmsg_payload(3)
35-
returns a pointer to the payload in the buffer.
36-
io_uring_recvmsg_payload_length(3)
37-
Calculates the usable payload length in bytes.
29+
* [io_uring_recvmsg_name] - returns a pointer to the name in the buffer.
30+
* [io_uring_recvmsg_cmsg_firsthdr] - returns a pointer to the first cmsg in the buffer, or NULL.
31+
* [io_uring_recvmsg_cmsg_nexthdr] - returns a pointer to the next cmsg in the buffer, or NULL.
32+
* [io_uring_recvmsg_payload] - returns a pointer to the payload in the buffer.
33+
* [io_uring_recvmsg_payload_length] - Calculates the usable payload length in bytes.
3834
3935
# SEE ALSO
4036

liburing-rs/docs/io_uring_recvmsg_name.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ NULL.
1414

1515
The structure is defined as follows:
1616

17-
17+
```c
1818
struct io_uring_recvmsg_out {
1919
__u32 namelen; /* Name byte count as would have been populated
2020
* by recvmsg(2) */
@@ -24,17 +24,13 @@ The structure is defined as follows:
2424
__u32 flags; /* Flags result as would have been populated
2525
* by recvmsg(2) */
2626
};
27+
```
2728
28-
io_uring_recvmsg_name(3)
29-
returns a pointer to the name in the buffer.
30-
io_uring_recvmsg_cmsg_firsthdr(3)
31-
returns a pointer to the first cmsg in the buffer, or NULL.
32-
io_uring_recvmsg_cmsg_nexthdr(3)
33-
returns a pointer to the next cmsg in the buffer, or NULL.
34-
io_uring_recvmsg_payload(3)
35-
returns a pointer to the payload in the buffer.
36-
io_uring_recvmsg_payload_length(3)
37-
Calculates the usable payload length in bytes.
29+
* [io_uring_recvmsg_name] - returns a pointer to the name in the buffer.
30+
* [io_uring_recvmsg_cmsg_firsthdr] - returns a pointer to the first cmsg in the buffer, or NULL.
31+
* [io_uring_recvmsg_cmsg_nexthdr] - returns a pointer to the next cmsg in the buffer, or NULL.
32+
* [io_uring_recvmsg_payload] - returns a pointer to the payload in the buffer.
33+
* [io_uring_recvmsg_payload_length] - Calculates the usable payload length in bytes.
3834
3935
# SEE ALSO
4036

liburing-rs/docs/io_uring_recvmsg_payload.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ NULL.
1414

1515
The structure is defined as follows:
1616

17-
17+
```c
1818
struct io_uring_recvmsg_out {
1919
__u32 namelen; /* Name byte count as would have been populated
2020
* by recvmsg(2) */
@@ -24,17 +24,13 @@ The structure is defined as follows:
2424
__u32 flags; /* Flags result as would have been populated
2525
* by recvmsg(2) */
2626
};
27+
```
2728
28-
io_uring_recvmsg_name(3)
29-
returns a pointer to the name in the buffer.
30-
io_uring_recvmsg_cmsg_firsthdr(3)
31-
returns a pointer to the first cmsg in the buffer, or NULL.
32-
io_uring_recvmsg_cmsg_nexthdr(3)
33-
returns a pointer to the next cmsg in the buffer, or NULL.
34-
io_uring_recvmsg_payload(3)
35-
returns a pointer to the payload in the buffer.
36-
io_uring_recvmsg_payload_length(3)
37-
Calculates the usable payload length in bytes.
29+
* [io_uring_recvmsg_name] - returns a pointer to the name in the buffer.
30+
* [io_uring_recvmsg_cmsg_firsthdr] - returns a pointer to the first cmsg in the buffer, or NULL.
31+
* [io_uring_recvmsg_cmsg_nexthdr] - returns a pointer to the next cmsg in the buffer, or NULL.
32+
* [io_uring_recvmsg_payload] - returns a pointer to the payload in the buffer.
33+
* [io_uring_recvmsg_payload_length] - Calculates the usable payload length in bytes.
3834
3935
# SEE ALSO
4036

liburing-rs/docs/io_uring_recvmsg_payload_length.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ NULL.
1414

1515
The structure is defined as follows:
1616

17-
17+
```c
1818
struct io_uring_recvmsg_out {
1919
__u32 namelen; /* Name byte count as would have been populated
2020
* by recvmsg(2) */
@@ -24,17 +24,13 @@ The structure is defined as follows:
2424
__u32 flags; /* Flags result as would have been populated
2525
* by recvmsg(2) */
2626
};
27+
```
2728
28-
io_uring_recvmsg_name(3)
29-
returns a pointer to the name in the buffer.
30-
io_uring_recvmsg_cmsg_firsthdr(3)
31-
returns a pointer to the first cmsg in the buffer, or NULL.
32-
io_uring_recvmsg_cmsg_nexthdr(3)
33-
returns a pointer to the next cmsg in the buffer, or NULL.
34-
io_uring_recvmsg_payload(3)
35-
returns a pointer to the payload in the buffer.
36-
io_uring_recvmsg_payload_length(3)
37-
Calculates the usable payload length in bytes.
29+
* [io_uring_recvmsg_name] - returns a pointer to the name in the buffer.
30+
* [io_uring_recvmsg_cmsg_firsthdr] - returns a pointer to the first cmsg in the buffer, or NULL.
31+
* [io_uring_recvmsg_cmsg_nexthdr] - returns a pointer to the next cmsg in the buffer, or NULL.
32+
* [io_uring_recvmsg_payload] - returns a pointer to the payload in the buffer.
33+
* [io_uring_recvmsg_payload_length] - Calculates the usable payload length in bytes.
3834
3935
# SEE ALSO
4036

liburing-rs/docs/io_uring_recvmsg_validate.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ NULL.
1414

1515
The structure is defined as follows:
1616

17-
17+
```c
1818
struct io_uring_recvmsg_out {
1919
__u32 namelen; /* Name byte count as would have been populated
2020
* by recvmsg(2) */
@@ -24,17 +24,13 @@ The structure is defined as follows:
2424
__u32 flags; /* Flags result as would have been populated
2525
* by recvmsg(2) */
2626
};
27+
```
2728
28-
io_uring_recvmsg_name(3)
29-
returns a pointer to the name in the buffer.
30-
io_uring_recvmsg_cmsg_firsthdr(3)
31-
returns a pointer to the first cmsg in the buffer, or NULL.
32-
io_uring_recvmsg_cmsg_nexthdr(3)
33-
returns a pointer to the next cmsg in the buffer, or NULL.
34-
io_uring_recvmsg_payload(3)
35-
returns a pointer to the payload in the buffer.
36-
io_uring_recvmsg_payload_length(3)
37-
Calculates the usable payload length in bytes.
29+
* [io_uring_recvmsg_name] - returns a pointer to the name in the buffer.
30+
* [io_uring_recvmsg_cmsg_firsthdr] - returns a pointer to the first cmsg in the buffer, or NULL.
31+
* [io_uring_recvmsg_cmsg_nexthdr] - returns a pointer to the next cmsg in the buffer, or NULL.
32+
* [io_uring_recvmsg_payload] - returns a pointer to the payload in the buffer.
33+
* [io_uring_recvmsg_payload_length] - Calculates the usable payload length in bytes.
3834
3935
# SEE ALSO
4036

liburing-rs/docs/io_uring_register_bpf_filter.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
io_uring_register_bpf_filter, io_uring_register_bpf_filter_task -
2-
register classic BPF filters for io_uring operations
1+
Register classic BPF filters for io_uring operations.
32

43
# DESCRIPTION
54

@@ -22,6 +21,7 @@ The *bpf* argument is a pointer to a **struct io_uring_bpf** with
2221
*cmd_type* set to **IO_URING_BPF_CMD_FILTER**. The embedded **struct
2322
io_uring_bpf_filter** describes the filter to register:
2423

24+
```c
2525
struct io_uring_bpf_filter {
2626
__u32 opcode; /* io_uring opcode to filter */
2727
__u32 flags; /* IO_URING_BPF_FILTER_* */
@@ -31,6 +31,7 @@ io_uring_bpf_filter** describes the filter to register:
3131
__u64 filter_ptr; /* pointer to BPF filter */
3232
__u64 resv2[5];
3333
};
34+
```
3435
3536
*opcode* specifies which io_uring operation the filter applies to (e.g.,
3637
**IORING_OP_SOCKET**, **IORING_OP_NOP**, **IORING_OP_READ**).
@@ -88,6 +89,7 @@ the kernel's.
8889
The BPF filter receives a context structure that can be inspected using
8990
**BPF_LD** instructions with absolute addressing. The context layout is:
9091
92+
```c
9193
struct io_uring_bpf_ctx {
9294
__u64 user_data; /* offset 0: user_data from SQE */
9395
__u8 opcode; /* offset 8: io_uring opcode */
@@ -107,6 +109,7 @@ The BPF filter receives a context structure that can be inspected using
107109
} open;
108110
};
109111
};
112+
```
110113

111114
The *pdu_size* field indicates the size in bytes of the
112115
operation-specific data passed in the union. A filter can check this
@@ -165,6 +168,7 @@ The caller does not have the **CAP_SYS_ADMIN** capability and the
165168

166169
**Deny**\ all NOP operations
167170

171+
```c
168172
#include <sys/prctl.h>
169173
#include <linux/filter.h>
170174
#include <liburing.h>
@@ -191,9 +195,11 @@ The caller does not have the **CAP_SYS_ADMIN** capability and the
191195

192196
/* Or register on the task */
193197
io_uring_register_bpf_filter_task(&bpf);
198+
```
194199
195200
**Allow**\ only AF_INET sockets
196201
202+
```c
197203
#include <sys/prctl.h>
198204
#include <linux/filter.h>
199205
#include <sys/socket.h>
@@ -225,9 +231,11 @@ The caller does not have the **CAP_SYS_ADMIN** capability and the
225231
226232
prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
227233
io_uring_register_bpf_filter_task(&bpf);
234+
```
228235

229236
**Allow**\ only NOP, deny everything else
230237

238+
```c
231239
struct sock_filter allow_filter[] = {
232240
BPF_STMT(BPF_RET | BPF_K, 1), /* return 1 (allow) */
233241
};
@@ -244,12 +252,14 @@ The caller does not have the **CAP_SYS_ADMIN** capability and the
244252

245253
prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
246254
io_uring_register_bpf_filter_task(&bpf);
255+
```
247256
248257
**Discover**\ kernel pdu_size for an opcode
249258
250259
This example demonstrates how to use the **-EMSGSIZE** write-back to
251260
discover the kernel's expected payload size.
252261
262+
```c
253263
struct sock_filter allow[] = {
254264
BPF_STMT(BPF_RET | BPF_K, 1),
255265
};
@@ -274,6 +284,7 @@ discover the kernel's expected payload size.
274284
/* retry with correct size */
275285
ret = io_uring_register_bpf_filter(&ring, &bpf);
276286
}
287+
```
277288

278289
# NOTES
279290

@@ -287,7 +298,9 @@ with elevated privileges but under the attacker-controlled filter.
287298

288299
To set the **no_new_privs** attribute, call:
289300

301+
```c
290302
prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
303+
```
291304
292305
Once set, **no_new_privs** cannot be unset and is inherited by child
293306
processes across [fork](https://man7.org/linux/man-pages/man2/fork.2.html) and preserved across [execve](https://man7.org/linux/man-pages/man2/execve.2.html).

liburing-rs/docs/io_uring_register_bpf_filter_task.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ The *bpf* argument is a pointer to a **struct io_uring_bpf** with
2222
*cmd_type* set to **IO_URING_BPF_CMD_FILTER**. The embedded **struct
2323
io_uring_bpf_filter** describes the filter to register:
2424

25+
```c
2526
struct io_uring_bpf_filter {
2627
__u32 opcode; /* io_uring opcode to filter */
2728
__u32 flags; /* IO_URING_BPF_FILTER_* */
@@ -31,6 +32,7 @@ io_uring_bpf_filter** describes the filter to register:
3132
__u64 filter_ptr; /* pointer to BPF filter */
3233
__u64 resv2[5];
3334
};
35+
```
3436
3537
*opcode* specifies which io_uring operation the filter applies to (e.g.,
3638
**IORING_OP_SOCKET**, **IORING_OP_NOP**, **IORING_OP_READ**).
@@ -88,6 +90,7 @@ the kernel's.
8890
The BPF filter receives a context structure that can be inspected using
8991
**BPF_LD** instructions with absolute addressing. The context layout is:
9092
93+
```c
9194
struct io_uring_bpf_ctx {
9295
__u64 user_data; /* offset 0: user_data from SQE */
9396
__u8 opcode; /* offset 8: io_uring opcode */
@@ -107,6 +110,7 @@ The BPF filter receives a context structure that can be inspected using
107110
} open;
108111
};
109112
};
113+
```
110114

111115
The *pdu_size* field indicates the size in bytes of the
112116
operation-specific data passed in the union. A filter can check this
@@ -165,6 +169,7 @@ The caller does not have the **CAP_SYS_ADMIN** capability and the
165169

166170
**Deny**\ all NOP operations
167171

172+
```c
168173
#include <sys/prctl.h>
169174
#include <linux/filter.h>
170175
#include <liburing.h>
@@ -191,9 +196,11 @@ The caller does not have the **CAP_SYS_ADMIN** capability and the
191196

192197
/* Or register on the task */
193198
io_uring_register_bpf_filter_task(&bpf);
199+
```
194200
195201
**Allow**\ only AF_INET sockets
196202
203+
```c
197204
#include <sys/prctl.h>
198205
#include <linux/filter.h>
199206
#include <sys/socket.h>
@@ -225,9 +232,11 @@ The caller does not have the **CAP_SYS_ADMIN** capability and the
225232
226233
prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
227234
io_uring_register_bpf_filter_task(&bpf);
235+
```
228236

229237
**Allow**\ only NOP, deny everything else
230238

239+
```c
231240
struct sock_filter allow_filter[] = {
232241
BPF_STMT(BPF_RET | BPF_K, 1), /* return 1 (allow) */
233242
};
@@ -244,12 +253,14 @@ The caller does not have the **CAP_SYS_ADMIN** capability and the
244253

245254
prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
246255
io_uring_register_bpf_filter_task(&bpf);
256+
```
247257
248258
**Discover**\ kernel pdu_size for an opcode
249259
250260
This example demonstrates how to use the **-EMSGSIZE** write-back to
251261
discover the kernel's expected payload size.
252262
263+
```c
253264
struct sock_filter allow[] = {
254265
BPF_STMT(BPF_RET | BPF_K, 1),
255266
};
@@ -274,6 +285,7 @@ discover the kernel's expected payload size.
274285
/* retry with correct size */
275286
ret = io_uring_register_bpf_filter(&ring, &bpf);
276287
}
288+
```
277289

278290
# NOTES
279291

@@ -287,7 +299,9 @@ with elevated privileges but under the attacker-controlled filter.
287299

288300
To set the **no_new_privs** attribute, call:
289301

302+
```c
290303
prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
304+
```
291305
292306
Once set, **no_new_privs** cannot be unset and is inherited by child
293307
processes across [fork](https://man7.org/linux/man-pages/man2/fork.2.html) and preserved across [execve](https://man7.org/linux/man-pages/man2/execve.2.html).

0 commit comments

Comments
 (0)