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

Re: [PATCH v3] xen/sched: validate RTDS putinfo period and budget


  • To: Juergen Gross <jgross@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Oleksii Moisieiev <oleksii_moisieiev@xxxxxxxx>
  • Date: Fri, 27 Mar 2026 17:10:40 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xyE7EWmKuzN9aNOOfrcmBtZ9Fgo2lRaTMao1kbNldko=; b=vSK5PSXnjx4PMXpmn8TGL0Oz6W0IX9oPzlmfEjdqh9OOMgulEKZBVwBk9/93oIlzfXhXKwaPuY20WwwESB38u+Z7WJVRvsdAG60bCzZ/hK1xsU35k2qlBtBcU+qcy4ZFXCe0b65WF4PVBNbelPR9sSeEJarXtb8DwGvkjoS3LkNWu/2NqCLsKdiATq6Elq8p9W9GivLFOjDz1MsLelTLwRSyIGi7DyujFw/rwYAHNM9z/HJImHiNKFoDKdAp/9URjXxksTE06IWSfTuOC6xfDIukZs+KokgaUxHJAhIIYSTJ5hcbmJ8bC05Hx5fSxiZ28EAoo2D6bVGuRyX2w/jYAA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kI0n9VT5yqoUt+quJM1BvoPMBRLenfrW7vlEQqNO9jv0HlU+uZw/PfUgumSxJrbdqx0sN+Lz+eJOvoY37XeKwgC+oQHUFdtsAYSLloQbuVeb69BgIAQF9W4HJRvhGPrc8hAn/uPRbd2yL02Xks9ZaQaqH6qHn7f3rFQAiq5hN0jfd7CBH9hdFftACPvt0c58IPa8+tkAgShnufQoTToZv9RwdrEGkrqr0OnCffzoaaHyTZJEQ0C8b8Rk8HjzZXm3o5HW+eT6Kz8xP+9YZxP4WqBptlenlJlVHaCWVSnryZGgIUws5O/VBlspUbCT/OP830XVEqQTLM2s1bz3s03hUQ==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=epam.com header.i="@epam.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Dario Faggioli <dfaggioli@xxxxxxxx>, George Dunlap <gwd@xxxxxxxxxxxxxx>, Meng Xu <mengxu@xxxxxxxxxxxxx>
  • Delivery-date: Fri, 27 Mar 2026 15:11:10 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Juergen

On 27/03/2026 14:51, Juergen Gross wrote:
On 27.03.26 12:31, Oleksii Moisieiev wrote:
The RTDS domain-wide XEN_DOMCTL_SCHEDOP_putinfo path only checks for
zero values before applying period and budget to all vCPUs in the
domain.

This is weaker than the per-vCPU XEN_DOMCTL_SCHEDOP_putvcpuinfo path,
which already rejects values below the minimum, above the maximum, and
cases where budget exceeds period.

Use the same validation rules for putinfo as for putvcpuinfo, so
invalid domain-wide updates are rejected with -EINVAL instead of being
applied inconsistently.

Signed-off-by: Oleksii Moisieiev <oleksii_moisieiev@xxxxxxxx>
---

Changes in v3:
- changed rt_validate_params input to get struct instead of
period and budget
- improved code readability

Changes in v2:
- introduce rt_validate_params helper function to check period and budget

  xen/common/sched/rt.c | 37 ++++++++++++++++++++++++-------------
  1 file changed, 24 insertions(+), 13 deletions(-)

diff --git a/xen/common/sched/rt.c b/xen/common/sched/rt.c
index 7b1f64a779..c161bf7f78 100644
--- a/xen/common/sched/rt.c
+++ b/xen/common/sched/rt.c
@@ -1362,6 +1362,23 @@ out:
      unit_schedule_unlock_irq(lock, unit);
  }
  +static int
+rt_validate_params(struct xen_domctl_sched_rtds *rtds,
+                   s_time_t *period, s_time_t *budget)
+{
+    s_time_t p = MICROSECS(rtds->period);
+    s_time_t b = MICROSECS(rtds->budget);
+
+    if ( p > RTDS_MAX_PERIOD || b < RTDS_MIN_BUDGET ||
+         b > p || p < RTDS_MIN_PERIOD )

This sequence of tests makes it harder to read than necessary.

Could you please rearrange to:

+    if ( p < RTDS_MIN_PERIOD || p > RTDS_MAX_PERIOD ||
+         b < RTDS_MIN_BUDGET || b > p )

This makes it rather obvious what the allowed ranges are.

Sure. Will fix and post v4.
With this and the "const" added mentioned by Jan you can add my:

Reviewed-by: Juergen Gross <jgross@xxxxxxxx>


Juergen



 


Rackspace

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