From nobody Sun Feb 8 09:08:52 2026 Received: from mx.swemel.ru (mx.swemel.ru [95.143.211.150]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CBB611FF1A6; Fri, 18 Apr 2025 08:31:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.143.211.150 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744965105; cv=none; b=uFhLHWi4Z3YU+AyPNNwvI0BbEVks4Loe9zY1sTeB6ltvauko8kFS4ykr9ptbogPPTtTrCZQtqN3FbuydzhpKrLvI9YHYYD0Kdl/ZL7G9IRNWRXWu0SJxijb+IKcUMYSrnU9DGVKBvE8K5bpjUfgyIqKPGYkx8CXeqwK+wrzWmZ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744965105; c=relaxed/simple; bh=qgRPG664md7WzPIJokBTw0TpvU/BTuBy3s7oOPxiohk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=kAe5bQFj98Z4gqojTBOTernA5M70nVvB2mjrmxS4driEEnu4bIl5lXGwddeZQ8dICh2dxHmySUI1hMBskD18jdxNcZFKoRrYpeEsiA+eLEBXiBWUeMsFAW9OWMLnNxF+PpMZMn9eXxphgU0sc7Kke/k1ZzcnfghNl7TYBW5HVtA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=swemel.ru; spf=pass smtp.mailfrom=swemel.ru; dkim=pass (1024-bit key) header.d=swemel.ru header.i=@swemel.ru header.b=Zlm/WRwQ; arc=none smtp.client-ip=95.143.211.150 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=swemel.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=swemel.ru Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=swemel.ru header.i=@swemel.ru header.b="Zlm/WRwQ" From: Denis Arefev DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=swemel.ru; s=mail; t=1744965090; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9Fkkq5isjGMmYO0XquNBWOmOM8h/DO8YafFqbHxC1G8=; b=Zlm/WRwQZgiQoeAvLcqEuRclvt0sHh5uh1ff0FcCW1gt3wshdcWkDH373Y/SOJM65upjvy aUho3Bb8UsT3uPJjALO/f5wHORbP48iGKaYd+p13s+jA4BX4iYGXAn69S7cakwkC5qohHy xok9Lp/LgYjLM/Q53dce59tKgagRVzs= To: Alex Deucher Cc: =?UTF-8?q?Christian=20K=C3=B6nig?= , David Airlie , Simona Vetter , Andrey Grodzovsky , Chunming Zhou , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org, stable@vger.kernel.org Subject: [PATCH v2] drm/amdgpu: check a user-provided number of BOs in list Date: Fri, 18 Apr 2025 11:31:27 +0300 Message-ID: <20250418083129.9739-1-arefev@swemel.ru> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The user can set any value to the variable =E2=80=98bo_number=E2=80=99, via= the ioctl command DRM_IOCTL_AMDGPU_BO_LIST. This will affect the arithmetic expression =E2=80=98in->bo_number * in->bo_info_size=E2=80=99, which is pro= ne to overflow. Add a valid value check. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 964d0fbf6301 ("drm/amdgpu: Allow to create BO lists in CS ioctl v3") Cc: stable@vger.kernel.org Signed-off-by: Denis Arefev --- V1 -> V2: Set a reasonable limit 'USHRT_MAX' for 'bo_number' it as Christian K=C3=B6n= ig suggested drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c b/drivers/gpu/drm/= amd/amdgpu/amdgpu_bo_list.c index 702f6610d024..85f7ee1e085d 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c @@ -189,6 +189,9 @@ int amdgpu_bo_create_list_entry_array(struct drm_amdgpu= _bo_list_in *in, struct drm_amdgpu_bo_list_entry *info; int r; =20 + if (!in->bo_number || in->bo_number > USHRT_MAX) + return -EINVAL; + info =3D kvmalloc_array(in->bo_number, info_size, GFP_KERNEL); if (!info) return -ENOMEM; --=20 2.43.0