From owner-freebsd-hackers@freebsd.org Wed Apr 28 14:41:53 2021 Return-Path: Delivered-To: freebsd-hackers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 57FCF5F60D8 for ; Wed, 28 Apr 2021 14:41:53 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FVhD0173rz4kvT for ; Wed, 28 Apr 2021 14:41:51 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by mail-qt1-x833.google.com with SMTP id o21so18705119qtp.7 for ; Wed, 28 Apr 2021 07:41:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=xhK03eKEAL1why/29TFbbjELulA2X5xnKbBS4Ij7GFM=; b=laGaXSPev+uikH6dAVVUYEZeXg1W6QGDGryCWGAupAjsJVXb2QBFVHHPDI5mZk8q5b A29rK/m1opY+9ywCPrsekTUAIR2kno/GVw1BK0ZrgsbfxnLvnEVPVRaBITjExacc1V2m N6PsYjFoFtN11PX4fMOX0e/8NTajg990RUiOKrugSrluz2P1CN0O7ZJ1G9srhVh3YMvl I5tsCpzXz5VvB8U51BQfhzQts/ETqWbTUkz5+adF+uLpU+U1HF/G3uIMC/jNUicCrxRp 66z6V1lRpw/9sujA1umpH5MpqIGImkLJKF9EunswurqyDKxE2+3t4XKLHNLGABqb6MD4 R/SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to; bh=xhK03eKEAL1why/29TFbbjELulA2X5xnKbBS4Ij7GFM=; b=HB9Tj6+lflvQAmirqBwWuPAvGHa85/uosfNc+/7pZAAbbRqau4B9Ax+gFd7W78V5qn 0sHXyMg6zEVyRVy6Twxu9P5PjCzZa3ATAEiI0OaZvgIcc+OjlDuFoQTMewM8zMWaRqqL jYaXBTVAf2ub7DBP/YzHveV+J1DQw3JT31PQmQrv9RH2x6Q/5gU2DC1i8rRPlTmTyJPE AXpoZuwCxU45PfgmLGMyOwvVursMl/VX0Qmap7bx9W7bJnJRNpIbUf6LKKn8WM0iQUD3 Hla4xezkaqn6HABuWyExJH9iPrD4pRvmmr8bJzhtu3E7JdLRCTXMcX5TCZFjvXFEAZz+ OF+A== X-Gm-Message-State: AOAM5332G2wQeoHQZlACKH+vuM1mF6myDKDUDVSdEsmhu0HAXI0cyip+ pwxR+x2l6pkHUoU4KFeDeUXYXUkO+OPFXw== X-Google-Smtp-Source: ABdhPJxnKSkUM6yFtVxG/YB5P/X2990fi2dFM+Ot7Ihs0YQrY9kvRd2eS5wy0dJLjQPzuZrZD9p8Sw== X-Received: by 2002:a05:622a:589:: with SMTP id c9mr26994312qtb.363.1619620911230; Wed, 28 Apr 2021 07:41:51 -0700 (PDT) Received: from nuc ([142.126.164.150]) by smtp.gmail.com with ESMTPSA id g16sm144346qtv.64.2021.04.28.07.41.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Apr 2021 07:41:50 -0700 (PDT) Sender: Mark Johnston Date: Wed, 28 Apr 2021 10:41:51 -0400 From: Mark Johnston To: =?utf-8?B?SW9udcib?= Mihalache Cc: freebsd-hackers@freebsd.org Subject: Re: cap_sysctlbyname for hw.vmm.destroy Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspamd-Queue-Id: 4FVhD0173rz4kvT X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=laGaXSPe; dmarc=none; spf=pass (mx1.freebsd.org: domain of markjdb@gmail.com designates 2607:f8b0:4864:20::833 as permitted sender) smtp.mailfrom=markjdb@gmail.com X-Spamd-Result: default: False [-2.70 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36:c]; RCVD_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[gmail.com:+]; RCPT_COUNT_TWO(0.00)[2]; NEURAL_HAM_SHORT(-1.00)[-1.000]; FREEMAIL_TO(0.00)[gmail.com]; FORGED_SENDER(0.30)[markj@freebsd.org,markjdb@gmail.com]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; FROM_NEQ_ENVFROM(0.00)[markj@freebsd.org,markjdb@gmail.com]; RBL_DBL_DONT_QUERY_IPS(0.00)[2607:f8b0:4864:20::833:from]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; FROM_HAS_DN(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; TAGGED_RCPT(0.00)[]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; DMARC_NA(0.00)[freebsd.org]; SPAMHAUS_ZRD(0.00)[2607:f8b0:4864:20::833:from:127.0.2.255]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::833:from]; MID_RHS_NOT_FQDN(0.50)[]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[freebsd-hackers] X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Technical discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Apr 2021 14:41:53 -0000 There are two bugs in the example, also present in your WIP. I fixed them here: https://cgit.freebsd.org/src/commit/?id=44bbda649dc6c1cdc5a99641e14c77157967e140 On Wed, Apr 28, 2021 at 05:22:22PM +0300, Ionuț Mihalache wrote: > I update the code now [1] but still the same error. Even without any limits > the cap_sysctlbyname fails after using cap_enter. > > [1] - > https://github.com/FreeBSD-UPB/freebsd-src/blob/c54dce7590b065a757dff0f68fd921aca380670f/usr.sbin/bhyve/bhyverun.c#L1567 > > În mie., 28 apr. 2021 la 16:52, Mark Johnston a scris: > > > On Wed, Apr 28, 2021 at 02:30:26PM +0300, Ionuț Mihalache wrote: > > > I tried to test the example from the documentation between here [1] and > > > here [2]. The code stops here [3]. > > > > I think you're referencing an old version of the cap_sysctl man page? > > See the example from the copy in your repo: > > > > https://github.com/FreeBSD-UPB/freebsd-src/blob/3a08ffe4839de9b8396b1760f1dc42b066428807/lib/libcasper/services/cap_sysctl/cap_sysctl.3#L122 > > In particular, when setting limits consumers should not be building > > nvlists directly. > > > > > [1] - > > > > > https://github.com/FreeBSD-UPB/freebsd-src/blob/3a08ffe4839de9b8396b1760f1dc42b066428807/usr.sbin/bhyve/bhyverun.c#L1538 > > > [2] - > > > > > https://github.com/FreeBSD-UPB/freebsd-src/blob/3a08ffe4839de9b8396b1760f1dc42b066428807/usr.sbin/bhyve/bhyverun.c#L1585 > > > [3] - > > > > > https://github.com/FreeBSD-UPB/freebsd-src/blob/3a08ffe4839de9b8396b1760f1dc42b066428807/usr.sbin/bhyve/bhyverun.c#L1581 > > > > > > În lun., 26 apr. 2021 la 20:40, Mark Johnston a > > scris: > > > > > > > On Mon, Apr 26, 2021 at 05:16:14PM +0300, Ionuț Mihalache wrote: > > > > > Hello, > > > > > > > > > > I am working on adding capsicum support for the bhyve snapshot > > feature. > > > > At > > > > > the end of the suspend process, the guest should be destroyed and the > > > > code > > > > > handles this part with a sysctlbyname call which is not working in > > > > > capability mode. I don't know what is the problem but even when using > > > > > cap_sysctlbyname I still get the same error code (EPERM). I tried the > > > > > example from the documentation aswell [1] and still the same error > > code. > > > > > What could be the problem? I have a FreeBSD13 host and a FreeBSD13 > > guest. > > > > > > > > I'm not sure why it would happen unless the casper process is somehow > > > > running as a non-root user. Can you share the code you're testing > > > > somewhere? > > > > > >