sync with OpenBSD -current
This commit is contained in:
parent
1cefe29c7e
commit
fdad81bcfc
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: init.c,v 1.19 2023/10/12 16:37:05 deraadt Exp $ */
|
||||
/* $OpenBSD: init.c,v 1.20 2024/01/18 19:00:11 deraadt Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2014,2015 Philip Guenther <guenther@openbsd.org>
|
||||
*
|
||||
@ -35,11 +35,6 @@
|
||||
|
||||
#include "init.h"
|
||||
|
||||
#if defined(APIWARN)
|
||||
__warn_references(syscall,
|
||||
"syscall() may go away, please rewrite code to use direct calls");
|
||||
#endif
|
||||
|
||||
#define MAX(a,b) (((a)>(b))?(a):(b))
|
||||
|
||||
#ifdef TIB_EXTRA_ALIGN
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: tls12_record_layer.c,v 1.40 2023/07/08 20:38:23 beck Exp $ */
|
||||
/* $OpenBSD: tls12_record_layer.c,v 1.41 2024/01/18 16:30:43 tb Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2020 Joel Sing <jsing@openbsd.org>
|
||||
*
|
||||
@ -525,7 +525,7 @@ tls12_record_layer_ccs_cipher(struct tls12_record_layer *rl,
|
||||
goto err;
|
||||
|
||||
/* More special handling for GOST... */
|
||||
if (EVP_CIPHER_type(rl->cipher) == NID_gost89_cnt) {
|
||||
if (EVP_CIPHER_nid(rl->cipher) == NID_gost89_cnt) {
|
||||
gost_param_nid = NID_id_tc26_gost_28147_param_Z;
|
||||
if (EVP_MD_type(rl->handshake_hash) == NID_id_GostR3411_94)
|
||||
gost_param_nid = NID_id_Gost28147_89_CryptoPro_A_ParamSet;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: ec_point_conversion.c,v 1.14 2023/08/01 17:19:49 tb Exp $ */
|
||||
/* $OpenBSD: ec_point_conversion.c,v 1.15 2024/01/18 16:49:40 tb Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2021 Theo Buehler <tb@openbsd.org>
|
||||
* Copyright (c) 2021 Joel Sing <jsing@openbsd.org>
|
||||
@ -55,7 +55,6 @@ hexdump(const unsigned char *buf, size_t len)
|
||||
|
||||
for (i = 1; i <= len; i++)
|
||||
fprintf(stderr, " 0x%02hhx,%s", buf[i - 1], i % 8 ? "" : "\n");
|
||||
|
||||
if (len % 8)
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
@ -135,24 +135,6 @@ int amdgpu_vcn_sw_init(struct amdgpu_device *adev)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Some Steam Deck's BIOS versions are incompatible with the
|
||||
* indirect SRAM mode, leading to amdgpu being unable to get
|
||||
* properly probed (and even potentially crashing the kernel).
|
||||
* Hence, check for these versions here - notice this is
|
||||
* restricted to Vangogh (Deck's APU).
|
||||
*/
|
||||
if (adev->ip_versions[UVD_HWIP][0] == IP_VERSION(3, 0, 2)) {
|
||||
const char *bios_ver = dmi_get_system_info(DMI_BIOS_VERSION);
|
||||
|
||||
if (bios_ver && (!strncmp("F7A0113", bios_ver, 7) ||
|
||||
!strncmp("F7A0114", bios_ver, 7))) {
|
||||
adev->vcn.indirect_sram = false;
|
||||
dev_info(adev->dev,
|
||||
"Steam Deck quirk: indirect SRAM disabled on BIOS %s\n", bios_ver);
|
||||
}
|
||||
}
|
||||
|
||||
hdr = (const struct common_firmware_header *)adev->vcn.fw->data;
|
||||
adev->vcn.fw_version = le32_to_cpu(hdr->ucode_version);
|
||||
|
||||
|
@ -719,9 +719,7 @@ static const struct i2c_algorithm smu_v11_0_i2c_algo = {
|
||||
};
|
||||
|
||||
static const struct i2c_adapter_quirks smu_v11_0_i2c_control_quirks = {
|
||||
#ifdef notyet
|
||||
.flags = I2C_AQ_NO_ZERO_LEN,
|
||||
#endif
|
||||
};
|
||||
|
||||
int smu_v11_0_i2c_control_init(struct amdgpu_device *adev)
|
||||
|
@ -1907,7 +1907,7 @@ static void amdgpu_dm_fini(struct amdgpu_device *adev)
|
||||
#ifdef notyet
|
||||
hdcp_destroy(&adev->dev->kobj, adev->dm.hdcp_workqueue);
|
||||
#else
|
||||
STUB();
|
||||
hdcp_destroy(NULL, adev->dm.hdcp_workqueue);
|
||||
#endif
|
||||
adev->dm.hdcp_workqueue = NULL;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
* Rob Clark <robdclark@gmail.com>
|
||||
*/
|
||||
|
||||
#include <sys/stdarg.h>
|
||||
#include <linux/stdarg.h>
|
||||
|
||||
#include <linux/io.h>
|
||||
#include <linux/moduleparam.h>
|
||||
|
@ -188,6 +188,7 @@
|
||||
*/
|
||||
|
||||
#include <linux/anon_inodes.h>
|
||||
#include <linux/dma-fence-unwrap.h>
|
||||
#include <linux/eventfd.h>
|
||||
#include <linux/file.h>
|
||||
#include <linux/fs.h>
|
||||
|
@ -539,9 +539,7 @@ static bool rc6_supported(struct intel_rc6 *rc6)
|
||||
static void rpm_get(struct intel_rc6 *rc6)
|
||||
{
|
||||
GEM_BUG_ON(rc6->wakeref);
|
||||
#ifdef notyet
|
||||
pm_runtime_get_sync(rc6_to_i915(rc6)->drm.dev);
|
||||
#endif
|
||||
rc6->wakeref = true;
|
||||
}
|
||||
|
||||
|
@ -133,17 +133,6 @@ enum intel_platform {
|
||||
#define INTEL_SUBPLATFORM_M 0
|
||||
#define INTEL_SUBPLATFORM_P 1
|
||||
|
||||
/* ADL */
|
||||
#define INTEL_SUBPLATFORM_RPL 0
|
||||
|
||||
/* ADL-P */
|
||||
/*
|
||||
* As #define INTEL_SUBPLATFORM_RPL 0 will apply
|
||||
* here too, SUBPLATFORM_N will have different
|
||||
* bit set
|
||||
*/
|
||||
#define INTEL_SUBPLATFORM_N 1
|
||||
|
||||
enum intel_ppgtt_type {
|
||||
INTEL_PPGTT_NONE = I915_GEM_PPGTT_NONE,
|
||||
INTEL_PPGTT_ALIASING = I915_GEM_PPGTT_ALIASING,
|
||||
|
@ -34,7 +34,6 @@
|
||||
#include "radeon.h"
|
||||
#include "radeon_prime.h"
|
||||
|
||||
|
||||
struct sg_table *radeon_gem_prime_get_sg_table(struct drm_gem_object *obj)
|
||||
{
|
||||
struct radeon_bo *bo = gem_to_radeon_bo(obj);
|
||||
@ -104,6 +103,7 @@ void radeon_gem_prime_unpin(struct drm_gem_object *obj)
|
||||
radeon_bo_unreserve(bo);
|
||||
}
|
||||
|
||||
|
||||
struct dma_buf *radeon_gem_prime_export(struct drm_gem_object *gobj,
|
||||
int flags)
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: kern_sysctl.c,v 1.422 2024/01/15 15:47:37 mvs Exp $ */
|
||||
/* $OpenBSD: kern_sysctl.c,v 1.423 2024/01/18 08:48:32 mvs Exp $ */
|
||||
/* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */
|
||||
|
||||
/*-
|
||||
@ -1283,13 +1283,8 @@ fill_file(struct kinfo_file *kf, struct file *fp, struct filedesc *fdp,
|
||||
if (so == NULL) {
|
||||
so = (struct socket *)fp->f_data;
|
||||
/* if so is passed as parameter it is already locked */
|
||||
switch (so->so_proto->pr_domain->dom_family) {
|
||||
case AF_INET:
|
||||
case AF_INET6:
|
||||
NET_LOCK();
|
||||
locked = 1;
|
||||
break;
|
||||
}
|
||||
solock(so);
|
||||
locked = 1;
|
||||
}
|
||||
|
||||
kf->so_type = so->so_type;
|
||||
@ -1312,14 +1307,14 @@ fill_file(struct kinfo_file *kf, struct file *fp, struct filedesc *fdp,
|
||||
kf->so_splicelen = -1;
|
||||
if (so->so_pcb == NULL) {
|
||||
if (locked)
|
||||
NET_UNLOCK();
|
||||
sounlock(so);
|
||||
break;
|
||||
}
|
||||
switch (kf->so_family) {
|
||||
case AF_INET: {
|
||||
struct inpcb *inpcb = so->so_pcb;
|
||||
|
||||
NET_ASSERT_LOCKED();
|
||||
soassertlocked(so);
|
||||
if (show_pointers)
|
||||
kf->inp_ppcb = PTRTOINT64(inpcb->inp_ppcb);
|
||||
kf->inp_lport = inpcb->inp_lport;
|
||||
@ -1341,7 +1336,7 @@ fill_file(struct kinfo_file *kf, struct file *fp, struct filedesc *fdp,
|
||||
case AF_INET6: {
|
||||
struct inpcb *inpcb = so->so_pcb;
|
||||
|
||||
NET_ASSERT_LOCKED();
|
||||
soassertlocked(so);
|
||||
if (show_pointers)
|
||||
kf->inp_ppcb = PTRTOINT64(inpcb->inp_ppcb);
|
||||
kf->inp_lport = inpcb->inp_lport;
|
||||
@ -1388,7 +1383,7 @@ fill_file(struct kinfo_file *kf, struct file *fp, struct filedesc *fdp,
|
||||
}
|
||||
}
|
||||
if (locked)
|
||||
NET_UNLOCK();
|
||||
sounlock(so);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: if_wg.c,v 1.35 2024/01/01 18:47:02 mvs Exp $ */
|
||||
/* $OpenBSD: if_wg.c,v 1.36 2024/01/18 08:46:41 mvs Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 2015-2020 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
|
||||
@ -518,7 +518,7 @@ wg_peer_destroy(struct wg_peer *peer)
|
||||
continue;
|
||||
}
|
||||
NET_UNLOCK();
|
||||
tsleep_nsec(sc, PWAIT, "wg_ifq", 1000);
|
||||
tsleep_nsec(&nowake, PWAIT, "wg_ifq", 1000);
|
||||
NET_LOCK();
|
||||
}
|
||||
NET_UNLOCK();
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: in_pcb.c,v 1.284 2024/01/09 19:57:00 bluhm Exp $ */
|
||||
/* $OpenBSD: in_pcb.c,v 1.285 2024/01/18 11:03:16 claudio Exp $ */
|
||||
/* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */
|
||||
|
||||
/*
|
||||
@ -1306,6 +1306,10 @@ in_pcbset_rtableid(struct inpcb *inp, u_int rtableid)
|
||||
{
|
||||
struct inpcbtable *table = inp->inp_table;
|
||||
|
||||
/* table must exist */
|
||||
if (!rtable_exists(rtableid))
|
||||
return (EINVAL);
|
||||
|
||||
mtx_enter(&table->inpt_mtx);
|
||||
if (inp->inp_lport) {
|
||||
mtx_leave(&table->inpt_mtx);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: ip_output.c,v 1.392 2023/12/01 15:30:47 bluhm Exp $ */
|
||||
/* $OpenBSD: ip_output.c,v 1.393 2024/01/18 11:03:16 claudio Exp $ */
|
||||
/* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */
|
||||
|
||||
/*
|
||||
@ -1077,11 +1077,6 @@ ip_ctloutput(int op, struct socket *so, int level, int optname,
|
||||
if (rtableid != rtid && rtableid != 0 &&
|
||||
(error = suser(p)) != 0)
|
||||
break;
|
||||
/* table must exist */
|
||||
if (!rtable_exists(rtid)) {
|
||||
error = EINVAL;
|
||||
break;
|
||||
}
|
||||
error = in_pcbset_rtableid(inp, rtid);
|
||||
break;
|
||||
case IP_PIPEX:
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: ip6_output.c,v 1.282 2023/12/01 15:30:47 bluhm Exp $ */
|
||||
/* $OpenBSD: ip6_output.c,v 1.283 2024/01/18 11:03:16 claudio Exp $ */
|
||||
/* $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $ */
|
||||
|
||||
/*
|
||||
@ -1376,11 +1376,6 @@ do { \
|
||||
if (rtableid != rtid && rtableid != 0 &&
|
||||
(error = suser(p)) != 0)
|
||||
break;
|
||||
/* table must exist */
|
||||
if (!rtable_exists(rtid)) {
|
||||
error = EINVAL;
|
||||
break;
|
||||
}
|
||||
error = in_pcbset_rtableid(inp, rtid);
|
||||
break;
|
||||
case IPV6_PIPEX:
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: tsort.c,v 1.37 2019/07/11 17:28:32 mestre Exp $ */
|
||||
/* $OpenBSD: tsort.c,v 1.38 2024/01/18 15:34:29 espie Exp $ */
|
||||
/* ex:ts=8 sw=4:
|
||||
*
|
||||
* Copyright (c) 1999-2004 Marc Espie <espie@openbsd.org>
|
||||
@ -448,7 +448,7 @@ dequeue(struct array *h)
|
||||
enqueue((h), (n)); \
|
||||
else \
|
||||
(h)->t[(h)->entries++] = (n); \
|
||||
} while(0);
|
||||
} while(0)
|
||||
|
||||
static void
|
||||
enqueue(struct array *h, struct node *n)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: bgpctl.c,v 1.299 2024/01/08 15:09:14 claudio Exp $ */
|
||||
/* $OpenBSD: bgpctl.c,v 1.300 2024/01/18 14:46:21 claudio Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003 Henning Brauer <henning@openbsd.org>
|
||||
@ -459,15 +459,15 @@ main(int argc, char *argv[])
|
||||
int
|
||||
show(struct imsg *imsg, struct parse_result *res)
|
||||
{
|
||||
struct peer *p;
|
||||
struct peer p;
|
||||
struct ctl_timer t;
|
||||
struct ctl_show_interface *iface;
|
||||
struct ctl_show_nexthop *nh;
|
||||
struct ctl_show_interface iface;
|
||||
struct ctl_show_nexthop nh;
|
||||
struct ctl_show_set set;
|
||||
struct ctl_show_rtr rtr;
|
||||
struct kroute_full *kf;
|
||||
struct ktable *kt;
|
||||
struct flowspec *f;
|
||||
struct kroute_full kf;
|
||||
struct ktable kt;
|
||||
struct flowspec f;
|
||||
struct ctl_show_rib rib;
|
||||
struct rde_memstats stats;
|
||||
u_char *asdata;
|
||||
@ -478,60 +478,60 @@ show(struct imsg *imsg, struct parse_result *res)
|
||||
case IMSG_CTL_SHOW_NEIGHBOR:
|
||||
if (output->neighbor == NULL)
|
||||
break;
|
||||
p = imsg->data;
|
||||
output->neighbor(p, res);
|
||||
if (imsg_get_data(imsg, &p, sizeof(p)) == -1)
|
||||
err(1, "imsg_get_data");
|
||||
output->neighbor(&p, res);
|
||||
break;
|
||||
case IMSG_CTL_SHOW_TIMER:
|
||||
if (imsg->hdr.len < IMSG_HEADER_SIZE + sizeof(t))
|
||||
errx(1, "wrong imsg len");
|
||||
if (output->timer == NULL)
|
||||
break;
|
||||
memcpy(&t, imsg->data, sizeof(t));
|
||||
if (imsg_get_data(imsg, &t, sizeof(t)) == -1)
|
||||
err(1, "imsg_get_data");
|
||||
if (t.type > 0 && t.type < Timer_Max)
|
||||
output->timer(&t);
|
||||
break;
|
||||
case IMSG_CTL_SHOW_INTERFACE:
|
||||
if (output->interface == NULL)
|
||||
break;
|
||||
iface = imsg->data;
|
||||
output->interface(iface);
|
||||
if (imsg_get_data(imsg, &iface, sizeof(iface)) == -1)
|
||||
err(1, "imsg_get_data");
|
||||
output->interface(&iface);
|
||||
break;
|
||||
case IMSG_CTL_SHOW_NEXTHOP:
|
||||
if (output->nexthop == NULL)
|
||||
break;
|
||||
nh = imsg->data;
|
||||
output->nexthop(nh);
|
||||
if (imsg_get_data(imsg, &nh, sizeof(nh)) == -1)
|
||||
err(1, "imsg_get_data");
|
||||
output->nexthop(&nh);
|
||||
break;
|
||||
case IMSG_CTL_KROUTE:
|
||||
case IMSG_CTL_SHOW_NETWORK:
|
||||
if (imsg->hdr.len < IMSG_HEADER_SIZE + sizeof(*kf))
|
||||
errx(1, "wrong imsg len");
|
||||
if (output->fib == NULL)
|
||||
break;
|
||||
kf = imsg->data;
|
||||
output->fib(kf);
|
||||
if (imsg_get_data(imsg, &kf, sizeof(kf)) == -1)
|
||||
err(1, "imsg_get_data");
|
||||
output->fib(&kf);
|
||||
break;
|
||||
case IMSG_CTL_SHOW_FLOWSPEC:
|
||||
if (imsg->hdr.len < IMSG_HEADER_SIZE + sizeof(*f))
|
||||
errx(1, "wrong imsg len");
|
||||
if (output->flowspec == NULL)
|
||||
break;
|
||||
f = imsg->data;
|
||||
output->flowspec(f);
|
||||
if (imsg_get_data(imsg, &f, sizeof(f)) == -1)
|
||||
err(1, "imsg_get_data");
|
||||
output->flowspec(&f);
|
||||
break;
|
||||
case IMSG_CTL_SHOW_FIB_TABLES:
|
||||
if (imsg->hdr.len < IMSG_HEADER_SIZE + sizeof(*kt))
|
||||
errx(1, "wrong imsg len");
|
||||
if (output->fib_table == NULL)
|
||||
break;
|
||||
kt = imsg->data;
|
||||
output->fib_table(kt);
|
||||
if (imsg_get_data(imsg, &kt, sizeof(kt)) == -1)
|
||||
err(1, "imsg_get_data");
|
||||
output->fib_table(&kt);
|
||||
break;
|
||||
case IMSG_CTL_SHOW_RIB:
|
||||
if (imsg->hdr.len < IMSG_HEADER_SIZE + sizeof(rib))
|
||||
errx(1, "wrong imsg len");
|
||||
if (output->rib == NULL)
|
||||
break;
|
||||
/* XXX */
|
||||
memcpy(&rib, imsg->data, sizeof(rib));
|
||||
aslen = imsg->hdr.len - IMSG_HEADER_SIZE - sizeof(rib);
|
||||
asdata = imsg->data;
|
||||
@ -559,37 +559,31 @@ show(struct imsg *imsg, struct parse_result *res)
|
||||
output->attr(imsg->data, ilen, res->flags, 0);
|
||||
break;
|
||||
case IMSG_CTL_SHOW_RIB_MEM:
|
||||
if (imsg->hdr.len < IMSG_HEADER_SIZE + sizeof(stats))
|
||||
errx(1, "wrong imsg len");
|
||||
if (output->rib_mem == NULL)
|
||||
break;
|
||||
memcpy(&stats, imsg->data, sizeof(stats));
|
||||
if (imsg_get_data(imsg, &stats, sizeof(stats)) == -1)
|
||||
err(1, "imsg_get_data");
|
||||
output->rib_mem(&stats);
|
||||
return (1);
|
||||
case IMSG_CTL_SHOW_SET:
|
||||
if (imsg->hdr.len < IMSG_HEADER_SIZE + sizeof(set))
|
||||
errx(1, "wrong imsg len");
|
||||
if (output->set == NULL)
|
||||
break;
|
||||
memcpy(&set, imsg->data, sizeof(set));
|
||||
if (imsg_get_data(imsg, &set, sizeof(set)) == -1)
|
||||
err(1, "imsg_get_data");
|
||||
output->set(&set);
|
||||
break;
|
||||
case IMSG_CTL_SHOW_RTR:
|
||||
if (imsg->hdr.len < IMSG_HEADER_SIZE + sizeof(rtr))
|
||||
errx(1, "wrong imsg len");
|
||||
if (output->rtr == NULL)
|
||||
break;
|
||||
memcpy(&rtr, imsg->data, sizeof(rtr));
|
||||
if (imsg_get_data(imsg, &rtr, sizeof(rtr)) == -1)
|
||||
err(1, "imsg_get_data");
|
||||
output->rtr(&rtr);
|
||||
break;
|
||||
case IMSG_CTL_RESULT:
|
||||
if (imsg->hdr.len != IMSG_HEADER_SIZE + sizeof(rescode)) {
|
||||
warnx("got IMSG_CTL_RESULT with wrong len");
|
||||
break;
|
||||
}
|
||||
if (output->result == NULL)
|
||||
break;
|
||||
memcpy(&rescode, imsg->data, sizeof(rescode));
|
||||
if (imsg_get_data(imsg, &rescode, sizeof(rescode)) == -1)
|
||||
err(1, "imsg_get_data");
|
||||
output->result(rescode);
|
||||
return (1);
|
||||
case IMSG_CTL_END:
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: rtr.c,v 1.19 2024/01/04 16:38:18 claudio Exp $ */
|
||||
/* $OpenBSD: rtr.c,v 1.20 2024/01/18 09:39:36 claudio Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2020 Claudio Jeker <claudio@openbsd.org>
|
||||
@ -530,12 +530,10 @@ rtr_recalc(void)
|
||||
|
||||
/* walk tree in reverse because aspa_add_set requires that */
|
||||
RB_FOREACH_REVERSE(aspa, aspa_tree, &at) {
|
||||
uint32_t as[2];
|
||||
as[0] = aspa->as;
|
||||
as[1] = aspa->num;
|
||||
struct aspa_set as = { .as = aspa->as, .num = aspa->num };
|
||||
|
||||
imsg_compose(ibuf_rde, IMSG_RECONF_ASPA, 0, 0, -1,
|
||||
&as, sizeof(as));
|
||||
&as, offsetof(struct aspa_set, tas));
|
||||
imsg_compose(ibuf_rde, IMSG_RECONF_ASPA_TAS, 0, 0, -1,
|
||||
aspa->tas, aspa->num * sizeof(*aspa->tas));
|
||||
imsg_compose(ibuf_rde, IMSG_RECONF_ASPA_DONE, 0, 0, -1,
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: session.c,v 1.460 2024/01/16 13:15:31 claudio Exp $ */
|
||||
/* $OpenBSD: session.c,v 1.461 2024/01/18 14:56:44 claudio Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003, 2004, 2005 Henning Brauer <henning@openbsd.org>
|
||||
@ -73,7 +73,7 @@ struct bgp_msg *session_newmsg(enum msg_type, uint16_t);
|
||||
int session_sendmsg(struct bgp_msg *, struct peer *);
|
||||
void session_open(struct peer *);
|
||||
void session_keepalive(struct peer *);
|
||||
void session_update(uint32_t, void *, size_t);
|
||||
void session_update(uint32_t, struct ibuf *);
|
||||
void session_notification(struct peer *, uint8_t, uint8_t, struct ibuf *);
|
||||
void session_notification_data(struct peer *, uint8_t, uint8_t, void *,
|
||||
size_t);
|
||||
@ -1640,7 +1640,7 @@ session_keepalive(struct peer *p)
|
||||
}
|
||||
|
||||
void
|
||||
session_update(uint32_t peerid, void *data, size_t datalen)
|
||||
session_update(uint32_t peerid, struct ibuf *ibuf)
|
||||
{
|
||||
struct peer *p;
|
||||
struct bgp_msg *buf;
|
||||
@ -1653,12 +1653,13 @@ session_update(uint32_t peerid, void *data, size_t datalen)
|
||||
if (p->state != STATE_ESTABLISHED)
|
||||
return;
|
||||
|
||||
if ((buf = session_newmsg(UPDATE, MSGSIZE_HEADER + datalen)) == NULL) {
|
||||
if ((buf = session_newmsg(UPDATE, MSGSIZE_HEADER + ibuf_size(ibuf))) ==
|
||||
NULL) {
|
||||
bgp_fsm(p, EVNT_CON_FATAL);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ibuf_add(buf->buf, data, datalen)) {
|
||||
if (ibuf_add_buf(buf->buf, ibuf)) {
|
||||
ibuf_free(buf->buf);
|
||||
free(buf);
|
||||
bgp_fsm(p, EVNT_CON_FATAL);
|
||||
@ -2973,6 +2974,7 @@ session_dispatch_imsg(struct imsgbuf *imsgbuf, int idx, u_int *listener_cnt)
|
||||
struct listen_addr *la, *next, nla;
|
||||
struct session_dependon sdon;
|
||||
struct bgpd_config tconf;
|
||||
size_t len;
|
||||
uint32_t peerid;
|
||||
int n, fd, depend_ok, restricted;
|
||||
uint16_t t;
|
||||
@ -3251,14 +3253,13 @@ session_dispatch_imsg(struct imsgbuf *imsgbuf, int idx, u_int *listener_cnt)
|
||||
case IMSG_UPDATE:
|
||||
if (idx != PFD_PIPE_ROUTE)
|
||||
fatalx("update request not from RDE");
|
||||
if (imsg.hdr.len > IMSG_HEADER_SIZE +
|
||||
MAX_PKTSIZE - MSGSIZE_HEADER ||
|
||||
imsg.hdr.len < IMSG_HEADER_SIZE +
|
||||
MSGSIZE_UPDATE_MIN - MSGSIZE_HEADER)
|
||||
len = imsg_get_len(&imsg);
|
||||
if (imsg_get_ibuf(&imsg, &ibuf) == -1 ||
|
||||
len > MAX_PKTSIZE - MSGSIZE_HEADER ||
|
||||
len < MSGSIZE_UPDATE_MIN - MSGSIZE_HEADER)
|
||||
log_warnx("RDE sent invalid update");
|
||||
else
|
||||
session_update(imsg.hdr.peerid, imsg.data,
|
||||
imsg.hdr.len - IMSG_HEADER_SIZE);
|
||||
session_update(peerid, &ibuf);
|
||||
break;
|
||||
case IMSG_UPDATE_ERR:
|
||||
if (idx != PFD_PIPE_ROUTE)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: privsep.c,v 1.24 2020/01/23 00:17:27 dlg Exp $ */
|
||||
/* $OpenBSD: privsep.c,v 1.25 2024/01/18 09:58:23 claudio Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010 Yasuoka Masahiko <yasuoka@openbsd.org>
|
||||
@ -526,7 +526,7 @@ privsep_recvfd(void)
|
||||
if (r->retval != 0)
|
||||
errno = r->rerrno;
|
||||
else
|
||||
retval = imsg.fd;
|
||||
retval = imsg_get_fd(&imsg);
|
||||
}
|
||||
imsg_free(&imsg);
|
||||
|
||||
@ -646,18 +646,19 @@ privsep_priv_dispatch_imsg(struct imsgbuf *ibuf)
|
||||
case PRIVSEP_BIND: {
|
||||
struct PRIVSEP_BIND_ARG *a = imsg.data;
|
||||
struct PRIVSEP_COMMON_RESP r = { -1, 0 };
|
||||
int fd;
|
||||
|
||||
if (imsg.hdr.len != IMSG_HEADER_SIZE + sizeof(*a) ||
|
||||
imsg.fd < 0)
|
||||
(fd = imsg_get_fd(&imsg)) < 0)
|
||||
r.rerrno = EINVAL;
|
||||
else if (privsep_npppd_check_bind(a))
|
||||
r.rerrno = EACCES;
|
||||
else {
|
||||
if ((r.retval = bind(imsg.fd,
|
||||
if ((r.retval = bind(fd,
|
||||
(struct sockaddr *)&a->name, a->namelen))
|
||||
!= 0)
|
||||
r.rerrno = errno;
|
||||
close(imsg.fd);
|
||||
close(fd);
|
||||
}
|
||||
(void)imsg_compose(ibuf, PRIVSEP_OK, 0, 0, -1,
|
||||
&r, sizeof(r));
|
||||
@ -744,28 +745,29 @@ on_broken_entry:
|
||||
case PRIVSEP_SENDTO: {
|
||||
struct PRIVSEP_SENDTO_ARG *a = imsg.data;
|
||||
struct PRIVSEP_COMMON_RESP r = { -1, 0 };
|
||||
int fd;
|
||||
|
||||
if (imsg.hdr.len < IMSG_HEADER_SIZE + sizeof(*a) ||
|
||||
imsg.hdr.len < IMSG_HEADER_SIZE +
|
||||
offsetof(struct PRIVSEP_SENDTO_ARG,
|
||||
msg[a->len]))
|
||||
r.rerrno = EMSGSIZE;
|
||||
else if (imsg.fd < 0)
|
||||
else if ((fd = imsg_get_fd(&imsg)) < 0)
|
||||
r.rerrno = EINVAL;
|
||||
else if (privsep_npppd_check_sendto(a))
|
||||
r.rerrno = EACCES;
|
||||
else {
|
||||
if (a->tolen > 0)
|
||||
r.retval = sendto(imsg.fd, a->msg,
|
||||
r.retval = sendto(fd, a->msg,
|
||||
a->len, a->flags,
|
||||
(struct sockaddr *)&a->to,
|
||||
a->tolen);
|
||||
else
|
||||
r.retval = send(imsg.fd, a->msg, a->len,
|
||||
r.retval = send(fd, a->msg, a->len,
|
||||
a->flags);
|
||||
if (r.retval < 0)
|
||||
r.rerrno = errno;
|
||||
close(imsg.fd);
|
||||
close(fd);
|
||||
}
|
||||
(void)imsg_compose(ibuf, PRIVSEP_OK, 0, 0, -1,
|
||||
&r, sizeof(r));
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: crl.c,v 1.30 2023/12/10 14:18:23 job Exp $ */
|
||||
/* $OpenBSD: crl.c,v 1.31 2024/01/18 14:34:26 job Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
*
|
||||
@ -96,7 +96,7 @@ crl_parse(const char *fn, const unsigned char *der, size_t len)
|
||||
warnx("%s: X509_CRL_get0_lastUpdate failed", fn);
|
||||
goto out;
|
||||
}
|
||||
if (!x509_get_time(at, &crl->lastupdate)) {
|
||||
if (!x509_get_time(at, &crl->thisupdate)) {
|
||||
warnx("%s: ASN1_TIME_to_tm failed", fn);
|
||||
goto out;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: extern.h,v 1.198 2024/01/07 09:48:29 tb Exp $ */
|
||||
/* $OpenBSD: extern.h,v 1.199 2024/01/18 14:34:26 job Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
*
|
||||
@ -435,7 +435,7 @@ struct crl {
|
||||
char *aki;
|
||||
char *number;
|
||||
X509_CRL *x509_crl;
|
||||
time_t lastupdate; /* do not use before */
|
||||
time_t thisupdate; /* do not use before */
|
||||
time_t nextupdate; /* do not use after */
|
||||
};
|
||||
/*
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: parser.c,v 1.107 2024/01/08 19:46:19 tb Exp $ */
|
||||
/* $OpenBSD: parser.c,v 1.108 2024/01/18 14:34:26 job Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2019 Claudio Jeker <claudio@openbsd.org>
|
||||
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
@ -429,7 +429,7 @@ proc_parser_mft(struct entity *entp, struct mft **mp, char **crlfile,
|
||||
}
|
||||
|
||||
if (*mp != NULL) {
|
||||
*crlmtime = crl->lastupdate;
|
||||
*crlmtime = crl->thisupdate;
|
||||
if (!crl_insert(&crlt, crl)) {
|
||||
warnx("%s: duplicate AKI %s", file, crl->aki);
|
||||
crl_free(crl);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: print.c,v 1.44 2023/11/16 11:18:47 tb Exp $ */
|
||||
/* $OpenBSD: print.c,v 1.45 2024/01/18 14:34:26 job Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2021 Claudio Jeker <claudio@openbsd.org>
|
||||
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
@ -352,12 +352,12 @@ crl_print(const struct crl *p)
|
||||
free(issuer);
|
||||
|
||||
if (outformats & FORMAT_JSON) {
|
||||
json_do_int("valid_since", p->lastupdate);
|
||||
json_do_int("valid_since", p->thisupdate);
|
||||
json_do_int("valid_until", p->nextupdate);
|
||||
json_do_array("revoked_certs");
|
||||
} else {
|
||||
printf("CRL last update: %s\n",
|
||||
time2str(p->lastupdate));
|
||||
printf("CRL this update: %s\n",
|
||||
time2str(p->thisupdate));
|
||||
printf("CRL next update: %s\n",
|
||||
time2str(p->nextupdate));
|
||||
printf("Revoked Certificates:\n");
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: config.c,v 1.73 2024/01/03 22:34:39 dv Exp $ */
|
||||
/* $OpenBSD: config.c,v 1.74 2024/01/18 14:49:59 claudio Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org>
|
||||
@ -552,10 +552,12 @@ config_getvm(struct privsep *ps, struct imsg *imsg)
|
||||
{
|
||||
struct vmop_create_params vmc;
|
||||
struct vmd_vm *vm = NULL;
|
||||
int fd;
|
||||
|
||||
IMSG_SIZE_CHECK(imsg, &vmc);
|
||||
memcpy(&vmc, imsg->data, sizeof(vmc));
|
||||
vmc.vmc_kernel = imsg->fd;
|
||||
fd = imsg_get_fd(imsg);
|
||||
vmc.vmc_kernel = fd;
|
||||
|
||||
errno = 0;
|
||||
if (vm_register(ps, &vmc, &vm, imsg->hdr.peerid, 0) == -1)
|
||||
@ -563,14 +565,12 @@ config_getvm(struct privsep *ps, struct imsg *imsg)
|
||||
|
||||
vm->vm_state |= VM_STATE_RUNNING;
|
||||
vm->vm_peerid = (uint32_t)-1;
|
||||
vm->vm_kernel = imsg->fd;
|
||||
vm->vm_kernel = fd;
|
||||
return (0);
|
||||
|
||||
fail:
|
||||
if (imsg->fd != -1) {
|
||||
close(imsg->fd);
|
||||
imsg->fd = -1;
|
||||
}
|
||||
if (fd != -1)
|
||||
close(fd);
|
||||
|
||||
vm_remove(vm, __func__);
|
||||
if (errno == 0)
|
||||
@ -584,6 +584,7 @@ config_getdisk(struct privsep *ps, struct imsg *imsg)
|
||||
{
|
||||
struct vmd_vm *vm;
|
||||
unsigned int n, idx;
|
||||
int fd;
|
||||
|
||||
errno = 0;
|
||||
if ((vm = vm_getbyvmid(imsg->hdr.peerid)) == NULL) {
|
||||
@ -593,8 +594,9 @@ config_getdisk(struct privsep *ps, struct imsg *imsg)
|
||||
|
||||
IMSG_SIZE_CHECK(imsg, &n);
|
||||
memcpy(&n, imsg->data, sizeof(n));
|
||||
fd = imsg_get_fd(imsg);
|
||||
|
||||
if (n >= vm->vm_params.vmc_ndisks || imsg->fd == -1) {
|
||||
if (n >= vm->vm_params.vmc_ndisks || fd == -1) {
|
||||
log_warnx("invalid disk id");
|
||||
errno = EINVAL;
|
||||
return (-1);
|
||||
@ -605,7 +607,7 @@ config_getdisk(struct privsep *ps, struct imsg *imsg)
|
||||
errno = EINVAL;
|
||||
return (-1);
|
||||
}
|
||||
vm->vm_disks[n][idx] = imsg->fd;
|
||||
vm->vm_disks[n][idx] = fd;
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -614,6 +616,7 @@ config_getif(struct privsep *ps, struct imsg *imsg)
|
||||
{
|
||||
struct vmd_vm *vm;
|
||||
unsigned int n;
|
||||
int fd;
|
||||
|
||||
errno = 0;
|
||||
if ((vm = vm_getbyvmid(imsg->hdr.peerid)) == NULL) {
|
||||
@ -623,16 +626,18 @@ config_getif(struct privsep *ps, struct imsg *imsg)
|
||||
|
||||
IMSG_SIZE_CHECK(imsg, &n);
|
||||
memcpy(&n, imsg->data, sizeof(n));
|
||||
fd = imsg_get_fd(imsg);
|
||||
|
||||
if (n >= vm->vm_params.vmc_nnics ||
|
||||
vm->vm_ifs[n].vif_fd != -1 || imsg->fd == -1) {
|
||||
vm->vm_ifs[n].vif_fd != -1 || fd == -1) {
|
||||
log_warnx("invalid interface id");
|
||||
goto fail;
|
||||
}
|
||||
vm->vm_ifs[n].vif_fd = imsg->fd;
|
||||
vm->vm_ifs[n].vif_fd = fd;
|
||||
return (0);
|
||||
fail:
|
||||
if (imsg->fd != -1)
|
||||
close(imsg->fd);
|
||||
if (fd != -1)
|
||||
close(fd);
|
||||
errno = EINVAL;
|
||||
return (-1);
|
||||
}
|
||||
@ -641,6 +646,7 @@ int
|
||||
config_getcdrom(struct privsep *ps, struct imsg *imsg)
|
||||
{
|
||||
struct vmd_vm *vm;
|
||||
int fd;
|
||||
|
||||
errno = 0;
|
||||
if ((vm = vm_getbyvmid(imsg->hdr.peerid)) == NULL) {
|
||||
@ -648,16 +654,15 @@ config_getcdrom(struct privsep *ps, struct imsg *imsg)
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (imsg->fd == -1) {
|
||||
fd = imsg_get_fd(imsg);
|
||||
if (fd == -1) {
|
||||
log_warnx("invalid cdrom id");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
vm->vm_cdrom = imsg->fd;
|
||||
vm->vm_cdrom = fd;
|
||||
return (0);
|
||||
fail:
|
||||
if (imsg->fd != -1)
|
||||
close(imsg->fd);
|
||||
errno = EINVAL;
|
||||
return (-1);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: control.c,v 1.41 2023/04/28 19:46:42 dv Exp $ */
|
||||
/* $OpenBSD: control.c,v 1.42 2024/01/18 14:49:59 claudio Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2015 Reyk Floeter <reyk@openbsd.org>
|
||||
@ -440,7 +440,7 @@ control_dispatch_imsg(int fd, short event, void *arg)
|
||||
case IMSG_VMDOP_RELOAD:
|
||||
case IMSG_CTL_RESET:
|
||||
if (proc_compose_imsg(ps, PROC_PARENT, -1,
|
||||
imsg.hdr.type, fd, imsg.fd,
|
||||
imsg.hdr.type, fd, imsg_get_fd(&imsg),
|
||||
imsg.data, IMSG_DATA_SIZE(&imsg)) == -1)
|
||||
goto fail;
|
||||
break;
|
||||
@ -453,7 +453,7 @@ control_dispatch_imsg(int fd, short event, void *arg)
|
||||
|
||||
/* imsg.fd may contain kernel image fd. */
|
||||
if (proc_compose_imsg(ps, PROC_PARENT, -1,
|
||||
imsg.hdr.type, fd, imsg.fd, &vmc,
|
||||
imsg.hdr.type, fd, imsg_get_fd(&imsg), &vmc,
|
||||
sizeof(vmc)) == -1) {
|
||||
control_close(fd, cs);
|
||||
return;
|
||||
@ -508,7 +508,7 @@ control_dispatch_imsg(int fd, short event, void *arg)
|
||||
vid.vid_uid);
|
||||
|
||||
if (proc_compose_imsg(ps, PROC_PARENT, -1,
|
||||
imsg.hdr.type, fd, imsg.fd,
|
||||
imsg.hdr.type, fd, imsg_get_fd(&imsg),
|
||||
&vid, sizeof(vid)) == -1)
|
||||
goto fail;
|
||||
break;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: priv.c,v 1.23 2023/07/13 18:31:59 dv Exp $ */
|
||||
/* $OpenBSD: priv.c,v 1.24 2024/01/18 14:49:59 claudio Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2016 Reyk Floeter <reyk@openbsd.org>
|
||||
@ -94,6 +94,7 @@ priv_dispatch_parent(int fd, struct privsep_proc *p, struct imsg *imsg)
|
||||
struct vmop_addr_req vareq;
|
||||
struct vmop_addr_result varesult;
|
||||
char type[IF_NAMESIZE];
|
||||
int ifd;
|
||||
|
||||
switch (imsg->hdr.type) {
|
||||
case IMSG_VMDOP_PRIV_IFDESCR:
|
||||
@ -254,14 +255,15 @@ priv_dispatch_parent(int fd, struct privsep_proc *p, struct imsg *imsg)
|
||||
varesult.var_vmid = vareq.var_vmid;
|
||||
varesult.var_nic_idx = vareq.var_nic_idx;
|
||||
|
||||
ifd = imsg_get_fd(imsg);
|
||||
/* resolve lladdr for the tap(4) and send back to parent */
|
||||
if (ioctl(imsg->fd, SIOCGIFADDR, &varesult.var_addr) != 0)
|
||||
if (ioctl(ifd, SIOCGIFADDR, &varesult.var_addr) != 0)
|
||||
log_warn("SIOCGIFADDR");
|
||||
else
|
||||
proc_compose_imsg(ps, PROC_PARENT, -1,
|
||||
IMSG_VMDOP_PRIV_GET_ADDR_RESPONSE, imsg->hdr.peerid,
|
||||
-1, &varesult, sizeof(varesult));
|
||||
close(imsg->fd);
|
||||
close(ifd);
|
||||
break;
|
||||
case IMSG_VMDOP_CONFIG:
|
||||
config_getconfig(env, imsg);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: proc.c,v 1.21 2023/09/26 01:53:54 dv Exp $ */
|
||||
/* $OpenBSD: proc.c,v 1.22 2024/01/18 14:49:59 claudio Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010 - 2016 Reyk Floeter <reyk@openbsd.org>
|
||||
@ -661,7 +661,7 @@ proc_dispatch(int fd, short event, void *arg)
|
||||
case IMSG_CTL_PROCFD:
|
||||
IMSG_SIZE_CHECK(&imsg, &pf);
|
||||
memcpy(&pf, imsg.data, sizeof(pf));
|
||||
proc_accept(ps, imsg.fd, pf.pf_procid,
|
||||
proc_accept(ps, imsg_get_fd(&imsg), pf.pf_procid,
|
||||
pf.pf_instance);
|
||||
break;
|
||||
default:
|
||||
@ -792,7 +792,8 @@ proc_forward_imsg(struct privsep *ps, struct imsg *imsg,
|
||||
enum privsep_procid id, int n)
|
||||
{
|
||||
return (proc_compose_imsg(ps, id, n, imsg->hdr.type,
|
||||
imsg->hdr.peerid, imsg->fd, imsg->data, IMSG_DATA_SIZE(imsg)));
|
||||
imsg->hdr.peerid, imsg_get_fd(imsg), imsg->data,
|
||||
IMSG_DATA_SIZE(imsg)));
|
||||
}
|
||||
|
||||
struct imsgbuf *
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: vm.c,v 1.95 2024/01/10 04:13:59 dv Exp $ */
|
||||
/* $OpenBSD: vm.c,v 1.96 2024/01/18 14:49:59 claudio Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org>
|
||||
@ -596,7 +596,7 @@ vm_dispatch_vmm(int fd, short event, void *arg)
|
||||
break;
|
||||
case IMSG_VMDOP_SEND_VM_REQUEST:
|
||||
vmr.vmr_id = vm->vm_vmid;
|
||||
vmr.vmr_result = send_vm(imsg.fd, vm);
|
||||
vmr.vmr_result = send_vm(imsg_get_fd(&imsg), vm);
|
||||
imsg_compose_event(&vm->vm_iev,
|
||||
IMSG_VMDOP_SEND_VM_RESPONSE,
|
||||
imsg.hdr.peerid, imsg.hdr.pid, -1, &vmr,
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: vmd.c,v 1.152 2023/09/26 01:53:54 dv Exp $ */
|
||||
/* $OpenBSD: vmd.c,v 1.153 2024/01/18 14:49:59 claudio Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org>
|
||||
@ -97,6 +97,7 @@ vmd_dispatch_control(int fd, struct privsep_proc *p, struct imsg *imsg)
|
||||
{
|
||||
struct privsep *ps = p->p_ps;
|
||||
int res = 0, ret = 0, cmd = 0, verbose;
|
||||
int ifd;
|
||||
unsigned int v = 0, flags;
|
||||
struct vmop_create_params vmc;
|
||||
struct vmop_id vid;
|
||||
@ -111,7 +112,7 @@ vmd_dispatch_control(int fd, struct privsep_proc *p, struct imsg *imsg)
|
||||
case IMSG_VMDOP_START_VM_REQUEST:
|
||||
IMSG_SIZE_CHECK(imsg, &vmc);
|
||||
memcpy(&vmc, imsg->data, sizeof(vmc));
|
||||
vmc.vmc_kernel = imsg->fd;
|
||||
vmc.vmc_kernel = imsg_get_fd(imsg);
|
||||
|
||||
/* Try registering our VM in our list of known VMs. */
|
||||
if (vm_register(ps, &vmc, &vm, 0, vmc.vmc_owner.uid)) {
|
||||
@ -257,11 +258,12 @@ vmd_dispatch_control(int fd, struct privsep_proc *p, struct imsg *imsg)
|
||||
IMSG_SIZE_CHECK(imsg, &vid);
|
||||
memcpy(&vid, imsg->data, sizeof(vid));
|
||||
id = vid.vid_id;
|
||||
ifd = imsg_get_fd(imsg);
|
||||
if (vid.vid_id == 0) {
|
||||
if ((vm = vm_getbyname(vid.vid_name)) == NULL) {
|
||||
res = ENOENT;
|
||||
cmd = IMSG_VMDOP_SEND_VM_RESPONSE;
|
||||
close(imsg->fd);
|
||||
close(ifd);
|
||||
break;
|
||||
} else {
|
||||
vid.vid_id = vm->vm_vmid;
|
||||
@ -269,43 +271,42 @@ vmd_dispatch_control(int fd, struct privsep_proc *p, struct imsg *imsg)
|
||||
} else if ((vm = vm_getbyvmid(vid.vid_id)) == NULL) {
|
||||
res = ENOENT;
|
||||
cmd = IMSG_VMDOP_SEND_VM_RESPONSE;
|
||||
close(imsg->fd);
|
||||
close(ifd);
|
||||
break;
|
||||
}
|
||||
vmr.vmr_id = vid.vid_id;
|
||||
log_debug("%s: sending fd to vmm", __func__);
|
||||
proc_compose_imsg(ps, PROC_VMM, -1, imsg->hdr.type,
|
||||
imsg->hdr.peerid, imsg->fd, &vid, sizeof(vid));
|
||||
imsg->hdr.peerid, ifd, &vid, sizeof(vid));
|
||||
break;
|
||||
case IMSG_VMDOP_RECEIVE_VM_REQUEST:
|
||||
IMSG_SIZE_CHECK(imsg, &vid);
|
||||
memcpy(&vid, imsg->data, sizeof(vid));
|
||||
if (imsg->fd == -1) {
|
||||
ifd = imsg_get_fd(imsg);
|
||||
if (ifd == -1) {
|
||||
log_warnx("%s: invalid fd", __func__);
|
||||
return (-1);
|
||||
}
|
||||
if (atomicio(read, imsg->fd, &vmh, sizeof(vmh)) !=
|
||||
sizeof(vmh)) {
|
||||
if (atomicio(read, ifd, &vmh, sizeof(vmh)) != sizeof(vmh)) {
|
||||
log_warnx("%s: error reading vmh from received vm",
|
||||
__func__);
|
||||
res = EIO;
|
||||
close(imsg->fd);
|
||||
close(ifd);
|
||||
cmd = IMSG_VMDOP_START_VM_RESPONSE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (vmd_check_vmh(&vmh)) {
|
||||
res = ENOENT;
|
||||
close(imsg->fd);
|
||||
close(ifd);
|
||||
cmd = IMSG_VMDOP_START_VM_RESPONSE;
|
||||
break;
|
||||
}
|
||||
if (atomicio(read, imsg->fd, &vmc, sizeof(vmc)) !=
|
||||
sizeof(vmc)) {
|
||||
if (atomicio(read, ifd, &vmc, sizeof(vmc)) != sizeof(vmc)) {
|
||||
log_warnx("%s: error reading vmc from received vm",
|
||||
__func__);
|
||||
res = EIO;
|
||||
close(imsg->fd);
|
||||
close(ifd);
|
||||
cmd = IMSG_VMDOP_START_VM_RESPONSE;
|
||||
break;
|
||||
}
|
||||
@ -317,14 +318,14 @@ vmd_dispatch_control(int fd, struct privsep_proc *p, struct imsg *imsg)
|
||||
if (ret != 0) {
|
||||
res = errno;
|
||||
cmd = IMSG_VMDOP_START_VM_RESPONSE;
|
||||
close(imsg->fd);
|
||||
close(ifd);
|
||||
} else {
|
||||
vm->vm_state |= VM_STATE_RECEIVED;
|
||||
config_setvm(ps, vm, imsg->hdr.peerid,
|
||||
vmc.vmc_owner.uid);
|
||||
log_debug("%s: sending fd to vmm", __func__);
|
||||
proc_compose_imsg(ps, PROC_VMM, -1,
|
||||
IMSG_VMDOP_RECEIVE_VM_END, vm->vm_vmid, imsg->fd,
|
||||
IMSG_VMDOP_RECEIVE_VM_END, vm->vm_vmid, ifd,
|
||||
NULL, 0);
|
||||
}
|
||||
break;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: vmm.c,v 1.116 2024/01/03 22:34:39 dv Exp $ */
|
||||
/* $OpenBSD: vmm.c,v 1.117 2024/01/18 14:49:59 claudio Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org>
|
||||
@ -252,7 +252,7 @@ vmm_dispatch_parent(int fd, struct privsep_proc *p, struct imsg *imsg)
|
||||
}
|
||||
imsg_compose_event(&vm->vm_iev,
|
||||
imsg->hdr.type, imsg->hdr.peerid, imsg->hdr.pid,
|
||||
imsg->fd, &vid, sizeof(vid));
|
||||
imsg_get_fd(imsg), &vid, sizeof(vid));
|
||||
break;
|
||||
case IMSG_VMDOP_UNPAUSE_VM:
|
||||
IMSG_SIZE_CHECK(imsg, &vid);
|
||||
@ -265,7 +265,7 @@ vmm_dispatch_parent(int fd, struct privsep_proc *p, struct imsg *imsg)
|
||||
}
|
||||
imsg_compose_event(&vm->vm_iev,
|
||||
imsg->hdr.type, imsg->hdr.peerid, imsg->hdr.pid,
|
||||
imsg->fd, &vid, sizeof(vid));
|
||||
imsg_get_fd(imsg), &vid, sizeof(vid));
|
||||
break;
|
||||
case IMSG_VMDOP_SEND_VM_REQUEST:
|
||||
IMSG_SIZE_CHECK(imsg, &vid);
|
||||
@ -273,13 +273,13 @@ vmm_dispatch_parent(int fd, struct privsep_proc *p, struct imsg *imsg)
|
||||
id = vid.vid_id;
|
||||
if ((vm = vm_getbyvmid(id)) == NULL) {
|
||||
res = ENOENT;
|
||||
close(imsg->fd);
|
||||
close(imsg_get_fd(imsg)); /* XXX */
|
||||
cmd = IMSG_VMDOP_START_VM_RESPONSE;
|
||||
break;
|
||||
}
|
||||
imsg_compose_event(&vm->vm_iev,
|
||||
imsg->hdr.type, imsg->hdr.peerid, imsg->hdr.pid,
|
||||
imsg->fd, &vid, sizeof(vid));
|
||||
imsg_get_fd(imsg), &vid, sizeof(vid));
|
||||
break;
|
||||
case IMSG_VMDOP_RECEIVE_VM_REQUEST:
|
||||
IMSG_SIZE_CHECK(imsg, &vmc);
|
||||
@ -290,18 +290,18 @@ vmm_dispatch_parent(int fd, struct privsep_proc *p, struct imsg *imsg)
|
||||
cmd = IMSG_VMDOP_START_VM_RESPONSE;
|
||||
break;
|
||||
}
|
||||
vm->vm_tty = imsg->fd;
|
||||
vm->vm_tty = imsg_get_fd(imsg);
|
||||
vm->vm_state |= VM_STATE_RECEIVED;
|
||||
vm->vm_state |= VM_STATE_PAUSED;
|
||||
break;
|
||||
case IMSG_VMDOP_RECEIVE_VM_END:
|
||||
if ((vm = vm_getbyvmid(imsg->hdr.peerid)) == NULL) {
|
||||
res = ENOENT;
|
||||
close(imsg->fd);
|
||||
close(imsg_get_fd(imsg)); /* XXX */
|
||||
cmd = IMSG_VMDOP_START_VM_RESPONSE;
|
||||
break;
|
||||
}
|
||||
vm->vm_receive_fd = imsg->fd;
|
||||
vm->vm_receive_fd = imsg_get_fd(imsg);
|
||||
res = vmm_start_vm(imsg, &id, &pid);
|
||||
/* Check if the ID can be mapped correctly */
|
||||
if ((id = vm_id2vmid(id, NULL)) == 0)
|
||||
@ -318,12 +318,12 @@ vmm_dispatch_parent(int fd, struct privsep_proc *p, struct imsg *imsg)
|
||||
/* Forward hardware address details to the guest vm */
|
||||
imsg_compose_event(&vm->vm_iev,
|
||||
imsg->hdr.type, imsg->hdr.peerid, imsg->hdr.pid,
|
||||
imsg->fd, &var, sizeof(var));
|
||||
imsg_get_fd(imsg), &var, sizeof(var));
|
||||
break;
|
||||
case IMSG_VMDOP_RECEIVE_VMM_FD:
|
||||
if (env->vmd_fd > -1)
|
||||
fatalx("already received vmm fd");
|
||||
env->vmd_fd = imsg->fd;
|
||||
env->vmd_fd = imsg_get_fd(imsg);
|
||||
|
||||
/* Get and terminate all running VMs */
|
||||
get_info_vm(ps, NULL, 1);
|
||||
@ -656,7 +656,7 @@ vmm_start_vm(struct imsg *imsg, uint32_t *id, pid_t *pid)
|
||||
vcp = &vm->vm_params.vmc_params;
|
||||
|
||||
if (!(vm->vm_state & VM_STATE_RECEIVED)) {
|
||||
if ((vm->vm_tty = imsg->fd) == -1) {
|
||||
if ((vm->vm_tty = imsg_get_fd(imsg)) == -1) {
|
||||
log_warnx("%s: can't get tty", __func__);
|
||||
goto err;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user