summaryrefslogtreecommitdiff
path: root/proto
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2023-04-21 15:26:06 +0200
committerMaria Matejka <mq@ucw.cz>2023-04-24 10:33:28 +0200
commit22f54eaee6c6dbe12ad7bb0ee1da09e3e026b970 (patch)
treeeab05c98833ba8b966005aca6c4dd237fb026ec2 /proto
parent6230d87c74e3629e21f1e0fe22a874a58302a01e (diff)
Resource pools are now bound with domains.
Memory allocation is a fragile part of BIRD and we need checking that everybody is using the resource pools in an appropriate way. To assure this, all the resource pools are associated with locking domains and every resource manipulation is thoroughly checked whether the appropriate locking domain is locked. With transitive resource manipulation like resource dumping or mass free operations, domains are locked and unlocked on the go, thus we require pool domains to have higher order than their parent to allow for this transitive operations. Adding pool locking revealed some cases of insecure memory manipulation and this commit fixes that as well.
Diffstat (limited to 'proto')
-rw-r--r--proto/babel/babel.c2
-rw-r--r--proto/bfd/bfd.c2
-rw-r--r--proto/bgp/attrs.c4
-rw-r--r--proto/bgp/bgp.c3
-rw-r--r--proto/ospf/iface.c4
-rw-r--r--proto/ospf/neighbor.c2
-rw-r--r--proto/radv/radv.c2
-rw-r--r--proto/rpki/rpki.c2
8 files changed, 11 insertions, 10 deletions
diff --git a/proto/babel/babel.c b/proto/babel/babel.c
index e95a0ead..decaa407 100644
--- a/proto/babel/babel.c
+++ b/proto/babel/babel.c
@@ -1826,7 +1826,7 @@ babel_add_iface(struct babel_proto *p, struct iface *new, struct babel_iface_con
TRACE(D_EVENTS, "Adding interface %s", new->name);
- pool *pool = rp_new(p->p.pool, new->name);
+ pool *pool = rp_new(p->p.pool, proto_domain(&p->p), new->name);
ifa = mb_allocz(pool, sizeof(struct babel_iface));
ifa->proto = p;
diff --git a/proto/bfd/bfd.c b/proto/bfd/bfd.c
index ddbc4948..f7d8f8d9 100644
--- a/proto/bfd/bfd.c
+++ b/proto/bfd/bfd.c
@@ -1073,7 +1073,7 @@ bfd_start(struct proto *P)
pthread_spin_init(&p->lock, PTHREAD_PROCESS_PRIVATE);
- p->tpool = rp_new(P->pool, "BFD loop pool");
+ p->tpool = birdloop_pool(P->loop);
p->session_slab = sl_new(P->pool, sizeof(struct bfd_session));
HASH_INIT(p->session_hash_id, P->pool, 8);
diff --git a/proto/bgp/attrs.c b/proto/bgp/attrs.c
index 4e6524f4..82971c01 100644
--- a/proto/bgp/attrs.c
+++ b/proto/bgp/attrs.c
@@ -1853,7 +1853,7 @@ bgp_init_pending_tx(struct bgp_channel *c)
{
ASSERT_DIE(!c->ptx);
- pool *p = rp_new(c->pool, "BGP Pending TX");
+ pool *p = rp_new(c->pool, proto_domain(c->c.proto), "BGP Pending TX");
c->ptx = ralloc(p, &bgp_pending_tx_class);
c->ptx->pool = p;
@@ -1981,7 +1981,7 @@ bgp_out_table_feed(void *data)
static void
bgp_out_table_export_start(struct rt_exporter *re, struct rt_export_request *req)
{
- req->hook = rt_alloc_export(re, sizeof(struct bgp_out_export_hook));
+ req->hook = rt_alloc_export(re, req->pool, sizeof(struct bgp_out_export_hook));
req->hook->req = req;
struct bgp_out_export_hook *hook = SKIP_BACK(struct bgp_out_export_hook, h, req->hook);
diff --git a/proto/bgp/bgp.c b/proto/bgp/bgp.c
index 0525d502..e60884ba 100644
--- a/proto/bgp/bgp.c
+++ b/proto/bgp/bgp.c
@@ -922,7 +922,8 @@ bgp_graceful_restart_feed(struct bgp_channel *c)
{
c->stale_feed = (struct rt_export_request) {
.name = "BGP-GR",
- .list = &global_work_list,
+ .list = proto_event_list(c->c.proto),
+ .pool = c->c.proto->pool,
.trace_routes = c->c.debug | c->c.proto->debug,
.dump_req = bgp_graceful_restart_feed_dump_req,
.log_state_change = bgp_graceful_restart_feed_log_state_change,
diff --git a/proto/ospf/iface.c b/proto/ospf/iface.c
index 0eecb432..c3ec4a4c 100644
--- a/proto/ospf/iface.c
+++ b/proto/ospf/iface.c
@@ -567,7 +567,7 @@ ospf_iface_new(struct ospf_area *oa, struct ifa *addr, struct ospf_iface_patt *i
OSPF_TRACE(D_EVENTS, "Adding interface %s (%N) to area %R",
iface->name, &addr->prefix, oa->areaid);
- pool = rp_new(p->p.pool, "OSPF Interface");
+ pool = rp_new(p->p.pool, proto_domain(&p->p), "OSPF Interface");
ifa = mb_allocz(pool, sizeof(struct ospf_iface));
ifa->iface = iface;
ifa->addr = addr;
@@ -690,7 +690,7 @@ ospf_iface_new_vlink(struct ospf_proto *p, struct ospf_iface_patt *ip)
/* Vlink ifname is stored just after the ospf_iface structure */
- pool = rp_new(p->p.pool, "OSPF Vlink");
+ pool = rp_new(p->p.pool, proto_domain(&p->p), "OSPF Vlink");
ifa = mb_allocz(pool, sizeof(struct ospf_iface) + 16);
ifa->oa = p->backbone;
ifa->cf = ip;
diff --git a/proto/ospf/neighbor.c b/proto/ospf/neighbor.c
index 2c73d251..59a60587 100644
--- a/proto/ospf/neighbor.c
+++ b/proto/ospf/neighbor.c
@@ -80,7 +80,7 @@ struct ospf_neighbor *
ospf_neighbor_new(struct ospf_iface *ifa)
{
struct ospf_proto *p = ifa->oa->po;
- struct pool *pool = rp_new(p->p.pool, "OSPF Neighbor");
+ struct pool *pool = rp_new(p->p.pool, proto_domain(&p->p), "OSPF Neighbor");
struct ospf_neighbor *n = mb_allocz(pool, sizeof(struct ospf_neighbor));
n->pool = pool;
diff --git a/proto/radv/radv.c b/proto/radv/radv.c
index eb15f9cb..3d5fe5a3 100644
--- a/proto/radv/radv.c
+++ b/proto/radv/radv.c
@@ -287,7 +287,7 @@ radv_iface_new(struct radv_proto *p, struct iface *iface, struct radv_iface_conf
RADV_TRACE(D_EVENTS, "Adding interface %s", iface->name);
- pool *pool = rp_new(p->p.pool, iface->name);
+ pool *pool = rp_new(p->p.pool, proto_domain(&p->p), iface->name);
ifa = mb_allocz(pool, sizeof(struct radv_iface));
ifa->pool = pool;
ifa->ra = p;
diff --git a/proto/rpki/rpki.c b/proto/rpki/rpki.c
index e5638aff..0fd686b3 100644
--- a/proto/rpki/rpki.c
+++ b/proto/rpki/rpki.c
@@ -599,7 +599,7 @@ rpki_check_expire_interval(uint seconds)
static struct rpki_cache *
rpki_init_cache(struct rpki_proto *p, struct rpki_config *cf)
{
- pool *pool = rp_new(p->p.pool, cf->hostname);
+ pool *pool = rp_new(p->p.pool, proto_domain(&p->p), cf->hostname);
struct rpki_cache *cache = mb_allocz(pool, sizeof(struct rpki_cache));