Subject: sysctl/XSM: pass full struct xen_sysctl to xsm_sysctl()
From: Jan Beulich <[email-masked]>

Subsequently some sub-ops will want to inspect their sub-sub-ops.

This is part of CVE-2026-62426 / XSA-499.

Signed-off-by: Jan Beulich <[email-masked]>
Acked-by: Roger Pau Monné <[email-masked]>
Reviewed-by: Andrew Cooper <[email-masked]>
Acked-by: Daniel P. Smith <[email-masked]>

--- a/xen/common/sysctl.c
+++ b/xen/common/sysctl.c
@@ -42,7 +42,7 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xe
     if ( op->interface_version != XEN_SYSCTL_INTERFACE_VERSION )
         return -EACCES;
 
-    ret = xsm_sysctl(XSM_PRIV, op->cmd);
+    ret = xsm_sysctl(XSM_PRIV, op);
     if ( ret )
         return ret;
 
--- a/xen/include/xsm/dummy.h
+++ b/xen/include/xsm/dummy.h
@@ -180,7 +180,8 @@ static XSM_INLINE int cf_check xsm_domct
     }
 }
 
-static XSM_INLINE int cf_check xsm_sysctl(XSM_DEFAULT_ARG int cmd)
+static XSM_INLINE int cf_check xsm_sysctl(
+    XSM_DEFAULT_ARG const struct xen_sysctl *op)
 {
     XSM_ASSERT_ACTION(XSM_PRIV);
     return xsm_default_action(action, current->domain, NULL);
--- a/xen/include/xsm/xsm.h
+++ b/xen/include/xsm/xsm.h
@@ -62,7 +62,7 @@ struct xsm_ops {
     int (*set_target)(struct domain *d, struct domain *e);
     int (*domctl)(struct domain *d, struct xen_domctl *op);
 #ifdef CONFIG_SYSCTL
-    int (*sysctl)(int cmd);
+    int (*sysctl)(const struct xen_sysctl *op);
     int (*readconsole)(uint32_t clear);
 #endif
 
@@ -251,9 +251,9 @@ static inline int xsm_domctl(xsm_default
 }
 
 #ifdef CONFIG_SYSCTL
-static inline int xsm_sysctl(xsm_default_t def, int cmd)
+static inline int xsm_sysctl(xsm_default_t def, const struct xen_sysctl *op)
 {
-    return alternative_call(xsm_ops.sysctl, cmd);
+    return alternative_call(xsm_ops.sysctl, op);
 }
 
 static inline int xsm_readconsole(xsm_default_t def, uint32_t clear)
--- a/xen/xsm/flask/hooks.c
+++ b/xen/xsm/flask/hooks.c
@@ -872,9 +872,9 @@ static int cf_check flask_domctl(struct
 }
 
 #ifdef CONFIG_SYSCTL
-static int cf_check flask_sysctl(int cmd)
+static int cf_check flask_sysctl(const struct xen_sysctl *op)
 {
-    switch ( cmd )
+    switch ( op->cmd )
     {
     /* These have individual XSM hooks */
     case XEN_SYSCTL_readconsole:
@@ -942,7 +942,7 @@ static int cf_check flask_sysctl(int cmd
                                     XEN2__COVERAGE_OP, NULL);
 
     default:
-        return avc_unknown_permission("sysctl", cmd);
+        return avc_unknown_permission("sysctl", op->cmd);
     }
 }