Mercurial > hg > nginx
annotate src/core/ngx_bpf.h @ 9322:d6f75dd66761 default tip
Mp4: added and updated sanity checks for "end" handling.
When handling incorrect data in ngx_http_mp4_crop_stsc_data(),
trak->end_chunk_samples might end up being arbitrary large, leading
to reading before the buffer in ngx_http_mp4_update_stsz_atom(). Fix
is to check that trak->end_chunk_samples corresponds to a memory within
the stsz atom data. For consistency, trak->start_chunk_samples
is checked similarly.
Similarly, trak->end_chunk might end up being smaller than trak->start_chunk,
leading to reading memory after the buffer in ngx_http_mp4_update_stco_atom()
and ngx_http_mp4_update_co64_atom(). Corresponding checks are updated
to explicitly test (trak->end_chunk - trak->start_chunk) instead of just
checking trak->end_chunk and assuming it is larger than trak->start_chunk.
This is generally in line with existing checks of
(trak->end_sample - trak->start_sample) in ngx_http_mp4_update_stsz_atom(),
where trak->end_sample might also become smaller than trak->start_sample
when handling incorrect data in ngx_http_mp4_crop_stts_data().
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Sun, 25 Aug 2024 06:35:40 +0300 |
parents | d3747ba486e7 |
children |
rev | line source |
---|---|
8675
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1 |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
2 /* |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
3 * Copyright (C) Nginx, Inc. |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
4 */ |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
5 |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
6 |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
7 #ifndef _NGX_BPF_H_INCLUDED_ |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
8 #define _NGX_BPF_H_INCLUDED_ |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
9 |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
10 |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
11 #include <ngx_config.h> |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
12 #include <ngx_core.h> |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
13 |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
14 #include <linux/bpf.h> |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
15 |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
16 |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
17 typedef struct { |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
18 char *name; |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
19 int offset; |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
20 } ngx_bpf_reloc_t; |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
21 |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
22 typedef struct { |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
23 char *license; |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
24 enum bpf_prog_type type; |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
25 struct bpf_insn *ins; |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
26 size_t nins; |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
27 ngx_bpf_reloc_t *relocs; |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
28 size_t nrelocs; |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
29 } ngx_bpf_program_t; |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
30 |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
31 |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
32 void ngx_bpf_program_link(ngx_bpf_program_t *program, const char *symbol, |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
33 int fd); |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
34 int ngx_bpf_load_program(ngx_log_t *log, ngx_bpf_program_t *program); |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
35 |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
36 int ngx_bpf_map_create(ngx_log_t *log, enum bpf_map_type type, int key_size, |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
37 int value_size, int max_entries, uint32_t map_flags); |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
38 int ngx_bpf_map_update(int fd, const void *key, const void *value, |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
39 uint64_t flags); |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
40 int ngx_bpf_map_delete(int fd, const void *key); |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
41 int ngx_bpf_map_lookup(int fd, const void *key, void *value); |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
42 |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
43 #endif /* _NGX_BPF_H_INCLUDED_ */ |