[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 1/2] libxc: drop size parameter from xc_flask_context_to_sid()


  • To: Jan Beulich <jbeulich@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: "Daniel P. Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>
  • Date: Thu, 2 Jul 2026 06:21:46 -0400
  • Arc-authentication-results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@xxxxxxxxxxxxxxxxxxxx; dmarc=pass header.from=<dpsmith@xxxxxxxxxxxxxxxxxxxx>
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782987711; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=vIAPMhBu82ubtuLXA6Cfj915g3ip0b/QqrhVvOeWe6s=; b=g5rt67UgzxSmQqYeFgECM7EHEEfq9iA+mWjzItyXmxH/+rLNh/cgkSLyIicAfqjAXr4AAc5gKN/52NML2kiJX9IBZhxeWnhgoemKf5T1GHsH5HXRNtrkNs5pcrGBiH1bx7zYZ4W2aCkbf0BtiLgppb3aEHDIKtthrdZaOm6ToeA=
  • Arc-seal: i=1; a=rsa-sha256; t=1782987711; cv=none; d=zohomail.com; s=zohoarc; b=Erf+OR88YGH7B33E9ch2qAhCtGGsfCsPMoEIbVC+vurj185iySuOiI3psNr3kGL5iMITufCSMpZP2klH1tAvb/hGIMHnimCp2vNOtnrEBHHENMoBqbB8g4vzIZW0ydzvOapoIZIi7MkIcooGUPTd7ppN7+1wRdCMn9v3a0UoRnY=
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=zoho header.d=apertussolutions.com header.i="dpsmith@xxxxxxxxxxxxxxxxxxxx" header.h="Message-ID:Date:MIME-Version:Subject:To:Cc:References:From:In-Reply-To:Content-Type:Content-Transfer-Encoding"
  • Cc: Anthony PERARD <anthony.perard@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Marek Marczykowski <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 02 Jul 2026 10:22:02 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>


On 7/1/26 10:47 AM, Jan Beulich wrote:
Nul-terminated strings are passed in all cases, so the strlen() can very
well be invoked by the function itself. In preparation for a hypervisor
change also include the nul terminator in the size calculation.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Acked-by: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
---
Ideally libxl_flask_context_to_sid() would follow suit, but aiui doing so
would break its (stable) API.

Of course the casts in xc_flask_access() are suspicious.
---
v2: Avoid assert() use in libxl.

--- a/tools/helpers/init-xenstore-domain.c
+++ b/tools/helpers/init-xenstore-domain.c
@@ -108,7 +108,7 @@ static int build(xc_interface *xch)
if ( flask )
      {
-        rv = xc_flask_context_to_sid(xch, flask, strlen(flask), 
&config.ssidref);
+        rv = xc_flask_context_to_sid(xch, flask, &config.ssidref);
          if ( rv )
          {
              fprintf(stderr, "xc_flask_context_to_sid failed\n");
--- a/tools/include/xenctrl.h
+++ b/tools/include/xenctrl.h
@@ -2372,7 +2372,7 @@ long xc_sharing_used_frames(xc_interface
  /*** End sharing interface ***/
int xc_flask_load(xc_interface *xc_handle, char *buf, uint32_t size);
-int xc_flask_context_to_sid(xc_interface *xc_handle, char *buf, uint32_t size, 
uint32_t *sid);
+int xc_flask_context_to_sid(xc_interface *xc_handle, char *buf, uint32_t *sid);
  int xc_flask_sid_to_context(xc_interface *xc_handle, int sid, char *buf, 
uint32_t size);
  int xc_flask_getenforce(xc_interface *xc_handle);
  int xc_flask_setenforce(xc_interface *xc_handle, int mode);
--- a/tools/libs/ctrl/xc_flask.c
+++ b/tools/libs/ctrl/xc_flask.c
@@ -83,10 +83,11 @@ int xc_flask_load(xc_interface *xch, cha
      return err;
  }
-int xc_flask_context_to_sid(xc_interface *xch, char *buf, uint32_t size, uint32_t *sid)
+int xc_flask_context_to_sid(xc_interface *xch, char *buf, uint32_t *sid)
  {
      int err;
      struct xen_flask_op op = {};
+    size_t size = strlen(buf) + 1;
      DECLARE_HYPERCALL_BOUNCE(buf, size, XC_HYPERCALL_BUFFER_BOUNCE_IN);
if ( xc_hypercall_bounce_pre(xch, buf) )
@@ -249,7 +250,7 @@ static int xc_flask_add(xc_interface *xc
      int err;
      struct xen_flask_op op = {};
- err = xc_flask_context_to_sid(xch, scontext, strlen(scontext), &sid);
+    err = xc_flask_context_to_sid(xch, scontext, &sid);
      if ( err )
          return err;
@@ -325,10 +326,10 @@ int xc_flask_access(xc_interface *xch, c
      struct xen_flask_op op = {};
      int err;
- err = xc_flask_context_to_sid(xch, (char*)scon, strlen(scon), &op.u.access.ssid);
+    err = xc_flask_context_to_sid(xch, (char*)scon, &op.u.access.ssid);
      if ( err )
          return err;
-    err = xc_flask_context_to_sid(xch, (char*)tcon, strlen(tcon), 
&op.u.access.tsid);
+    err = xc_flask_context_to_sid(xch, (char*)tcon, &op.u.access.tsid);
      if ( err )
          return err;
--- a/tools/libs/light/libxl_flask.c
+++ b/tools/libs/light/libxl_flask.c
@@ -21,7 +21,10 @@ int libxl_flask_context_to_sid(libxl_ctx
  {
      int rc;
- rc = xc_flask_context_to_sid(ctx->xch, buf, len, ssidref);
+    if (len != strlen(buf))
+        return ERROR_INVAL;
+
+    rc = xc_flask_context_to_sid(ctx->xch, buf, ssidref);
return rc;
  }
--- a/tools/python/xen/lowlevel/xc/xc.c
+++ b/tools/python/xen/lowlevel/xc/xc.c
@@ -1754,7 +1754,7 @@ static PyObject *pyflask_context_to_sid(
          return PyErr_SetFromErrno(xc_error_obj);
      }
- ret = xc_flask_context_to_sid(xc_handle, ctx, strlen(ctx), &sid);
+    ret = xc_flask_context_to_sid(xc_handle, ctx, &sid);
xc_interface_close(xc_handle);

Reviewed-by: Daniel P. Smith <dpsmith@xxxxxxxxxxxxxxxxxxxx>



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.