libxc: drop size parameter from xc_flask_context_to_sid()

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@suse.com>
Acked-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Anthony PERARD <anthony.perard@vates.tech>
Reviewed-by: Daniel P. Smith <dpsmith@apertussolutions.com>
This commit is contained in:
Jan Beulich committed 2026-07-06 09:41:45 +02:00
1 parent e457520245
commit dc21138144
5 files changed
+12 -8

No files matched your search

+1 -1
View File
@@ -108,7 +108,7 @@ static int build(xc_interface *xch)
if ( flask ) 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 ) if ( rv )
{ {
fprintf(stderr, "xc_flask_context_to_sid failed\n"); fprintf(stderr, "xc_flask_context_to_sid failed\n");
+1 -1
View File
@@ -2377,7 +2377,7 @@ long xc_sharing_used_frames(xc_interface *xch);
/*** End sharing interface ***/ /*** End sharing interface ***/
int xc_flask_load(xc_interface *xc_handle, char *buf, uint32_t size); 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_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_getenforce(xc_interface *xc_handle);
int xc_flask_setenforce(xc_interface *xc_handle, int mode); int xc_flask_setenforce(xc_interface *xc_handle, int mode);
+5 -4
View File
@@ -83,10 +83,11 @@ int xc_flask_load(xc_interface *xch, char *buf, uint32_t size)
return err; 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; int err;
struct xen_flask_op op = {}; struct xen_flask_op op = {};
size_t size = strlen(buf) + 1;
DECLARE_HYPERCALL_BOUNCE(buf, size, XC_HYPERCALL_BUFFER_BOUNCE_IN); DECLARE_HYPERCALL_BOUNCE(buf, size, XC_HYPERCALL_BUFFER_BOUNCE_IN);
if ( xc_hypercall_bounce_pre(xch, buf) ) if ( xc_hypercall_bounce_pre(xch, buf) )
@@ -249,7 +250,7 @@ static int xc_flask_add(xc_interface *xch, uint32_t ocon, uint64_t low, uint64_t
int err; int err;
struct xen_flask_op op = {}; 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 ) if ( err )
return err; return err;
@@ -325,10 +326,10 @@ int xc_flask_access(xc_interface *xch, const char *scon, const char *tcon,
struct xen_flask_op op = {}; struct xen_flask_op op = {};
int err; 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 ) if ( err )
return 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 ) if ( err )
return err; return err;
+4 -1
View File
@@ -21,7 +21,10 @@ int libxl_flask_context_to_sid(libxl_ctx *ctx, char *buf, size_t len,
{ {
int rc; 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; return rc;
} }
+1 -1
View File
@@ -1754,7 +1754,7 @@ static PyObject *pyflask_context_to_sid(PyObject *self, PyObject *args,
return PyErr_SetFromErrno(xc_error_obj); 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); xc_interface_close(xc_handle);
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.