From nobody Sat May 30 20:11:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1776379103; cv=none; d=zohomail.com; s=zohoarc; b=Y/GgTS7NKPNJj0XO8QQsfiiAVHB8HaTvwTzTyUIweYfRLnvKaUn+G04IXQxd6mnbM/PFb6mg/8MTWCyjzwMol0xht4N1V86CdC2GtBxAyeAq6YKWL9Ltt1rNz86pVErxq5SWYnmiMjYitS2CZP8/lfEAsIDiy+S6v7eJa4+H+PE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776379103; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=KCsFtdTDgbFc/U88ymKe8zR4zhuBtfCqsEs0LceHIRo=; b=bCCtsBP7hRWBbRLjfWYGyd2A6Yq4qaoQoz8kLDxiqWgDEAICg+KP9CIY1Dbyv69L96Ew/10qJKJuk9g2pOOQZuYD8FP296uiiBXqPNUnBAN10ko7OP+CqThgq9vfTG77HoVXx9pJmg7P1oRi67OMC0YC68NtG9keY1/IOFwtO38= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776379103331136.63624044823734; Thu, 16 Apr 2026 15:38:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wDVLZ-0007kk-NY; Thu, 16 Apr 2026 18:38:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wDSzo-00022Z-Cs for qemu-devel@nongnu.org; Thu, 16 Apr 2026 16:07:28 -0400 Received: from mail-oo1-xc30.google.com ([2607:f8b0:4864:20::c30]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wDSzm-0000He-Ri for qemu-devel@nongnu.org; Thu, 16 Apr 2026 16:07:28 -0400 Received: by mail-oo1-xc30.google.com with SMTP id 006d021491bc7-6888f36ceaaso136202eaf.2 for ; Thu, 16 Apr 2026 13:07:26 -0700 (PDT) Received: from localhost ([136.49.184.116]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-6946044199fsm521624eaf.14.2026.04.16.13.07.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Apr 2026 13:07:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776370045; x=1776974845; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KCsFtdTDgbFc/U88ymKe8zR4zhuBtfCqsEs0LceHIRo=; b=SDw1r8WbJ17GV93Eh5EZSg0p2fcCToOw9DV+KM/2xjS9tIPI7UKZmcuhEwWKPdVfNC nN4dyg/vaA1fvD5ZZUYo9+JuONdtGV4Bs3EnFyp1XskJaQWPvtWjnTFmg/8PCETzlxCs 39HzRsSdyiBACYP7eSvjmjJWA/3qOJdHeJxa0+/rzLK/8md4+eq7gwJqGWUOs/hdTo0P SJbPniT74FfClL7YNf4JqUFfwfmfEWGqXkzXYmQGGcx3atIMk5ynEqoJWYAXfkj/NgJb cQw8k/ekanlRZ4tnNMNoZGV3tcmK1KJWkqO/IrtbA3xFj5fpHsv78VzXYeHDgx0NTGi9 myTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776370045; x=1776974845; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=KCsFtdTDgbFc/U88ymKe8zR4zhuBtfCqsEs0LceHIRo=; b=Hgyisxa6hkbVNGxrGn0j3Pnj+yFOG8WvZ2OzP+tRG8MgFehBxIBuJDI7gNSgK851gv vJ37WplWwzNibe6GORziSzFa32nI5Sbgn/T58JbjePaU4N67BviMC15kHxKLIw0rlNNN 0Q853JNsgDf0AFE1n3LX66QHULgyzfNE25ckROMgl7oXpVvj6vFq9peEfjrZtKyj4FaM WbGNYc8191p3KGjCglDQ2Z3hFmR64ck2Z9o8HzugPjmsGboVH8J71OAepR+ITwa82Z+E GYXEiuxGy7FnS6CzuWX4a2qTPlu4SbZ2rZA0O9u3mUe8Gfq2sdBNJsMjd5BFAO6v9V1n tMrw== X-Gm-Message-State: AOJu0Yzm4kqermUJlJQF4bTvU+HxTghhBu33SWreeUOvBb/asIHaHgVk TngQ+wIOdgLBNb/o95/RfeOYHAgcaAMKw2nYlORyF4V/QF5az3TTagj/8AisqWNP X-Gm-Gg: AeBDieuHrB6VJOypjXyb0R2dmhUJgYud8hirQTQkJVgl6GXQajiFcYy6xNiKUn7BU6R hWyFSknszIzvL6IinsGP0ZmtJKjCzj0/+4kyqe4DQ6nCok19JNzNBc2yv76pZbhf/QylHMfRw5F vWaWPqWyiHFw5A1HzRNEpAlWmbF3kllojllRUhv1r1O13SkY9oQ3KU35UIPlw95CgGqWS2wX7Fq CJ2+VGws65YmxuE7ppualpyI8ymNxB/qZUdfsy6LabobPg3YRO/eg+U5Ijjch5tiUZwgQSfx7Ln qUceQfqCt54stV+AlLjT0rOyyY9uTtr9q7E9IRc1mFpg7P0JOFP1GaJCoE9KKR4ruo15DmcelWz 3zHsVG+lTiyrBTSu1RxFEr5v/9dGuhQNUWoBGY0tlboiIEg+H1BTpgu9Vdk8ErB1YAoYNhSfnZ4 SNlnaUVAoluXyPMU83QZM5E/zQJFkaSRzGivRiC2TupGx4/4tAKn6A1Xh2G1ouLiQ94QyWePql/ Da4MqLZ+3ceDHi46dFccTbT/CrBZG6ydPU= X-Received: by 2002:a4a:e1bc:0:b0:67e:1552:16cf with SMTP id 006d021491bc7-69462f04df4mr18380eaf.2.1776370045239; Thu, 16 Apr 2026 13:07:25 -0700 (PDT) From: Aaron Esau X-Google-Original-From: Aaron Esau To: qemu-devel@nongnu.org Cc: Jonathan.Cameron@huawei.com, jic23@kernel.org, berrange@redhat.com, Aaron Esau , qemu-stable@nongnu.org Subject: [PATCH 1/2] hw/cxl: fix OOB read in Get Log command due to incorrect pointer arithmetic Date: Thu, 16 Apr 2026 15:07:01 -0500 Message-ID: <20260416200702.2374709-2-git@aaronesau.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260416200702.2374709-1-git@aaronesau.com> References: <20260416200702.2374709-1-git@aaronesau.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::c30; envelope-from=aaron1esau@gmail.com; helo=mail-oo1-xc30.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FORGED_GMAIL_RCVD=1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 16 Apr 2026 18:38:05 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1776379104582158500 Content-Type: text/plain; charset="utf-8" From: Aaron Esau The memmove in cmd_logs_get_log() uses cci->cel_log + get_log->offset, which performs pointer arithmetic in units of sizeof(struct cel_log) (4 bytes per element). However, per CXL r3.1 Section 8.2.9.5.2, the offset field is a byte offset into the log. The existing bounds check correctly treats offset as a byte value: (uint64_t)get_log->offset + get_log->length >=3D sizeof(cci->cel_log) But the memmove reads from a position that is get_log->offset * sizeof(cel_log[0]) bytes past the start, which can be well beyond the array even when the bounds check passes. For example, offset=3D65536 and length=3D512 passes the check (66048 < sizeof(cel_log)) but the memmove reads from byte 262144 past cel_log, leaking adjacent heap data. Fix by casting to uint8_t * before adding the byte offset, matching the semantics assumed by the bounds check. Cc: qemu-stable@nongnu.org Fixes: 056172691b ("hw/cxl/device: Add log commands (8.2.9.4) + CEL") Reported-by: Aaron Esau Signed-off-by: Aaron Esau Reviewed-by: Jonathan Cameron --- hw/cxl/cxl-mailbox-utils.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index d8ba7e8625..0adf1e72c8 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -1217,7 +1217,8 @@ static CXLRetCode cmd_logs_get_log(const struct cxl_c= md *cmd, /* Store off everything to local variables so we can wipe out the payl= oad */ *len_out =3D get_log->length; =20 - memmove(payload_out, cci->cel_log + get_log->offset, get_log->length); + memmove(payload_out, (uint8_t *)cci->cel_log + get_log->offset, + get_log->length); =20 return CXL_MBOX_SUCCESS; } --=20 2.53.0 From nobody Sat May 30 20:11:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1776379115; cv=none; d=zohomail.com; s=zohoarc; b=c1+j9qlZKsN5iNG3PgE2RRxGLqAnmx4u/i0fNtcB6nU6aGIoQ80I0Ztqsy49xUg3YmCOKFG8dIYDa9W38UiRUbfGnCfUHBIdVGiFgNQmp2gnWorLhaInj4kcOXiEKOaTIVqkYMbFgBse0l9VAZejRMTeHLDoVOMUUaIWuQbt5ME= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776379115; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=p1WMxWJyeutL6cak8qb7wJqgMiroiOZ8xYTt72hdlKY=; b=OLapb7Cvd20G1/QSmF6Rdx/az8Xsga2KbfyVpQtNUqMbkciGepL+O95jngLMWXyOtEANXxHxfrs0fedwgXzAn5EcVLDxrVg5E1NpvEuO4ulwEOu4IYgrIAhlX1/fQEgsGOIROL8XO/np87tJK0P57GfYviF8XiKhHCTlkJMsv5Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776379115495772.0707302157393; Thu, 16 Apr 2026 15:38:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wDVLa-0007nc-W5; Thu, 16 Apr 2026 18:38:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wDSzq-00022x-6T for qemu-devel@nongnu.org; Thu, 16 Apr 2026 16:07:30 -0400 Received: from mail-ot1-x329.google.com ([2607:f8b0:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wDSzo-0000IL-7Q for qemu-devel@nongnu.org; Thu, 16 Apr 2026 16:07:29 -0400 Received: by mail-ot1-x329.google.com with SMTP id 46e09a7af769-7dbcb45153cso1095689a34.3 for ; Thu, 16 Apr 2026 13:07:27 -0700 (PDT) Received: from localhost ([136.49.184.116]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7dc90a5ef51sm633330a34.9.2026.04.16.13.07.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Apr 2026 13:07:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776370047; x=1776974847; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=p1WMxWJyeutL6cak8qb7wJqgMiroiOZ8xYTt72hdlKY=; b=oDpgxx9xZtVGiuxketHDxRymZbivvO37kZ+V08ms2IIhigr8FBTjLEw0B2nIBrb1Tc W9rz67KQ20E0f55Of6eCvkJC9FAn2yUaTtm51FBCJeJaP96ZnNoBvhyX9nqQRx75ptsK 0Q1PbUubHjbCtXBNRyB8lGtvKIuFILlIF0xsGGk2R+CY317Q79IKHPApNwFpujXzxV21 DsH+WR1tzRydQfLnyH+XQhyy/p4Z7vmMsXaWq5MGxwGY4fLTqiAjXsQFZsMuvCxozvvI 4bzlt+of+eqDdPQ7rcRED3fTApVn2tK5+acatY8kSh55B7RP7mhdtUh5Ejn8q49Si9nP 8pDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776370047; x=1776974847; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=p1WMxWJyeutL6cak8qb7wJqgMiroiOZ8xYTt72hdlKY=; b=cBcH2S/YKDEWgtWplVgYKN9ZfKlLcAJEV+Q3dQr3/Fs/1MrORdQZ17ObSVwEG6RCcB 46zpEu5Wg1TYlFtB4M7UZQZJJfKx97go3Rf74zeZfeykXP7omgyhJ2PDKY+7HbaBgrmt nQKXGp1nD7mZrmbb41cAuE6x+Lqho2DENgn0M54xFvOWWZthH2csBco9qZwgjxvzWwZg ESxnWW52pLGlcE0zou7Bh+jc6uCsLqE4Y1LLMnEcZwVVbuVTIMVNqt2w2pJ6rjc1w3YK j89oTCZhBCBkO7NoGE7uSyHJy4zBn+dzc+UAVuj9/GHBH8eHe3cNkqs52aEh9ffDcqck wM4w== X-Gm-Message-State: AOJu0YxudmCcReIm9TuLk98tOvWXTWlNesbxm7UXnGCfRFWpe88Qat2E ktOArds9MlXh3C/LslI1tb9fjmK6yh+Z8NULGotNPnwhr5u9OHFYu15Z+rABOaog X-Gm-Gg: AeBDievAnOWwE4JFR1mVQZ5ctpZIwilSS9kq8cPWHAf92jCnYzrSxsd6inGRZOmY0cj fQgrDYq38OHVV9iaWMLf/1HRkbOlNgoFnQYHdh3nM65Rm/h7j7v91qV2JsaIFj8KrKlJVGRfe5k WUy7chtyobKgBcsTpSIluNCr0TlQ5bpObhNyeEiY742MsfHA1xj5AGrmxhrX+iJ1i+AZD82nWc4 Vsw3NrZ+Zo2ajHwA4n3+fRciwShIuQXzJ53yxAbvoN31RXvoL3d2FnNdoSyIFszIYkBX906boV9 lyIkf+FnUuNaCQlcrawnNm7BR7Q17AcWaIQCjmymEx08iWUxQvB5G03/njpTbTN3jNgeucqAcam 4T9VNAH+l68lOpdrDBeMGCsZGuttbg6SaAtqw/Z5pi/DqXvqqHFirGdo7YXZg3j3QEEzzjJvvb1 WmO7GSZBwt1bJxcQhJuEEyWqSh+DSqv5JdcH1aGW6eFhbvx3KGH+/m7yziDw4UZxEoQo3lk0H7s V6812JpXcmlJRc/w7FUgrZWECqaXNCbfpo= X-Received: by 2002:a05:6830:411d:b0:7d7:e695:93b8 with SMTP id 46e09a7af769-7dc926d2605mr324081a34.5.1776370046849; Thu, 16 Apr 2026 13:07:26 -0700 (PDT) From: Aaron Esau X-Google-Original-From: Aaron Esau To: qemu-devel@nongnu.org Cc: Jonathan.Cameron@huawei.com, jic23@kernel.org, berrange@redhat.com, Aaron Esau , qemu-stable@nongnu.org Subject: [PATCH 2/2] hw/cxl: add missing bounds checks in Set Feature for PPR and sparing Date: Thu, 16 Apr 2026 15:07:02 -0500 Message-ID: <20260416200702.2374709-3-git@aaronesau.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260416200702.2374709-1-git@aaronesau.com> References: <20260416200702.2374709-1-git@aaronesau.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::329; envelope-from=aaron1esau@gmail.com; helo=mail-ot1-x329.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 16 Apr 2026 18:38:06 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1776379116375158500 Content-Type: text/plain; charset="utf-8" From: Aaron Esau cmd_features_set_feature() is missing bounds validation on the offset and data length for several feature UUIDs before their memcpy calls. The patrol_scrub and ecs cases correctly check: if ((uint32_t)hdr->offset + bytes_to_copy > sizeof(ct3d->..._wr_attrs)) return CXL_MBOX_INVALID_PAYLOAD_LENGTH; But the soft_ppr, hard_ppr, cacheline_sparing, row_sparing, bank_sparing, and rank_sparing cases are missing this check. Since bytes_to_copy is derived from the full mailbox payload length (up to 2048 bytes) and the write-attribute structs are only a few bytes each, a guest can overflow into adjacent CXLType3Dev fields. Add the same bounds check pattern to all six affected feature handlers. Cc: qemu-stable@nongnu.org Fixes: 5e5a86bab8 ("hw/cxl: Add support for Maintenance command and Post Pa= ckage Repair (PPR)") Fixes: da5cafdc4d ("hw/cxl: Add emulation for memory sparing control featur= e") Reported-by: Aaron Esau Signed-off-by: Aaron Esau --- hw/cxl/cxl-mailbox-utils.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 0adf1e72c8..5fabfcbbab 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -1814,6 +1814,11 @@ static CXLRetCode cmd_features_set_feature(const str= uct cxl_cmd *cmd, return CXL_MBOX_UNSUPPORTED; } =20 + if ((uint32_t)hdr->offset + bytes_to_copy > + sizeof(ct3d->soft_ppr_wr_attrs)) { + return CXL_MBOX_INVALID_PAYLOAD_LENGTH; + } + memcpy((uint8_t *)&ct3d->soft_ppr_wr_attrs + hdr->offset, sppr_write_attrs, bytes_to_copy); set_feat_info->data_size +=3D bytes_to_copy; @@ -1833,6 +1838,11 @@ static CXLRetCode cmd_features_set_feature(const str= uct cxl_cmd *cmd, return CXL_MBOX_UNSUPPORTED; } =20 + if ((uint32_t)hdr->offset + bytes_to_copy > + sizeof(ct3d->hard_ppr_wr_attrs)) { + return CXL_MBOX_INVALID_PAYLOAD_LENGTH; + } + memcpy((uint8_t *)&ct3d->hard_ppr_wr_attrs + hdr->offset, hppr_write_attrs, bytes_to_copy); set_feat_info->data_size +=3D bytes_to_copy; @@ -1852,6 +1862,11 @@ static CXLRetCode cmd_features_set_feature(const str= uct cxl_cmd *cmd, return CXL_MBOX_UNSUPPORTED; } =20 + if ((uint32_t)hdr->offset + bytes_to_copy > + sizeof(ct3d->cacheline_sparing_wr_attrs)) { + return CXL_MBOX_INVALID_PAYLOAD_LENGTH; + } + memcpy((uint8_t *)&ct3d->cacheline_sparing_wr_attrs + hdr->offset, mem_sparing_write_attrs, bytes_to_copy); set_feat_info->data_size +=3D bytes_to_copy; @@ -1870,6 +1885,11 @@ static CXLRetCode cmd_features_set_feature(const str= uct cxl_cmd *cmd, return CXL_MBOX_UNSUPPORTED; } =20 + if ((uint32_t)hdr->offset + bytes_to_copy > + sizeof(ct3d->row_sparing_wr_attrs)) { + return CXL_MBOX_INVALID_PAYLOAD_LENGTH; + } + memcpy((uint8_t *)&ct3d->row_sparing_wr_attrs + hdr->offset, mem_sparing_write_attrs, bytes_to_copy); set_feat_info->data_size +=3D bytes_to_copy; @@ -1888,6 +1908,11 @@ static CXLRetCode cmd_features_set_feature(const str= uct cxl_cmd *cmd, return CXL_MBOX_UNSUPPORTED; } =20 + if ((uint32_t)hdr->offset + bytes_to_copy > + sizeof(ct3d->bank_sparing_wr_attrs)) { + return CXL_MBOX_INVALID_PAYLOAD_LENGTH; + } + memcpy((uint8_t *)&ct3d->bank_sparing_wr_attrs + hdr->offset, mem_sparing_write_attrs, bytes_to_copy); set_feat_info->data_size +=3D bytes_to_copy; @@ -1906,6 +1931,11 @@ static CXLRetCode cmd_features_set_feature(const str= uct cxl_cmd *cmd, return CXL_MBOX_UNSUPPORTED; } =20 + if ((uint32_t)hdr->offset + bytes_to_copy > + sizeof(ct3d->rank_sparing_wr_attrs)) { + return CXL_MBOX_INVALID_PAYLOAD_LENGTH; + } + memcpy((uint8_t *)&ct3d->rank_sparing_wr_attrs + hdr->offset, mem_sparing_write_attrs, bytes_to_copy); set_feat_info->data_size +=3D bytes_to_copy; --=20 2.53.0