From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B5312BB13 for ; Sat, 29 Nov 2025 14:16:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764425767; cv=none; b=bfIufseJqvjOg8D2C2tahX6qBz/s3Bx5x+eYCCXPugqtcIOU3/YA6GTmTNyu/ekV8Ws4z+ZkATfgGpvLTn+UGgJrVC7yJNMqy2LJBAkxxpn/YLiLLQocQJbqe67kx9a5cdBxMPeTJQOiH1uZxja48EVocT5iI5xvvHouD/Rk5HQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764425767; c=relaxed/simple; bh=joJZdz0tLHOvhLlUda4BLQxUQNhSjL7uUERmcL7GcW4=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=bYjQg8FVELtOTEXNizFo9ayxDTDORHZClDfzyNvfE7Oiu4Pgb5n1rrTWi1h+pyuPCj5EB7vCPjmi4YCzHiRKHRPgLWHK8+raZxROGPb2uuu+oW2uBzkBDB5iU4F3YVyZ5FyrrsNTnWfJlrCWnzLrOs8xMbcPJrQh6MqX0+k81sA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JGX464dU; arc=none smtp.client-ip=209.85.167.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JGX464dU" Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-5957db5bdedso3144178e87.2 for ; Sat, 29 Nov 2025 06:16:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764425763; x=1765030563; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=CCb0Eqo5GqhxN4l/mvqQ6jrTkxIuERyWVn+iJxuMgs0=; b=JGX464dUqaJz1cXJ+lF8C0aIrtzRoL5IE2JjnNTVWMxRKvvarIfgK6m7OOnhAeXzfr igalvivWUsLtq+Irt9utOsBlO3e7VXmcFAfsQfdEOyWoCTOWEBuhSDTzZZeGysbnT0XA P8tQ+tN7sdc76WFwoK2vtRVgKCoaBjHpus7VjNycT4hg7kxtkaA++MqG75zKfwkJ63at rgByYZi0JLJeLWX069SEUL/9yCzRrgchAPIhcwWYqBI8SqjLsc2+7HT/d7sRwsFpZC4I 4x90nkL5ScGXoakOXcgkusYPTb18E/CA0muq77OTMKMECIl7ppj4JPuQqlv9POePu5AB uoDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764425763; x=1765030563; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=CCb0Eqo5GqhxN4l/mvqQ6jrTkxIuERyWVn+iJxuMgs0=; b=gN9hXNK5cg9tgewG8wg4X5DEoSMylcBo47BVMx9NjbAXtdaswVJTk0HZjbR6LH/RbT rQEb7Hy1ImfuNWkTu0TboUwjCKGiiEHV4HNT7PVY1w+ij7ZIXBUqGBmjHHpuwgQ/t/Xn RdvlDqbJfQruMukE8a1ChlktZvBsHN/K9PTx1Mxf/h5owTRVpcBPBsHxPBthUz283vdj qSt4KzZeuiCIxI/mZJSi8SVqhKaGzRv3ZqvLms8Iin17uYsJEV0J9ts/QWC5FPLK0z4y MgQvcYmSRC84pBTZelWFNxr1Cn7bOHceA951ckVql4YQ0hUhUpvRzPFZ8mJ8GfT/N2g0 0gmw== X-Forwarded-Encrypted: i=1; AJvYcCXcd28555UFIQCDRRW74ogkcsRg+gnaaaWa28myDX0CTxkAQe9XFdRHdbfEa3vAgfJTtxJ20QuVae9AAAQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyGrSUK613jh0C+9BFG6S4AiqbZ6OkkO/YmMLb27Rx9QBdpjL0s 9dlp3bV0/c7KKv/INkOBFK1I+Uno8LOB4/jV2/IeyaXwIzyX9s+ZMKb1 X-Gm-Gg: ASbGncvfseCFB86Zui6CaH+cR4ud0Cmn3LED1JvMKEa2rhGx0GvWfBmkhjnUbxKX/7Y br4FXpvHuIIc5j2p6Nsc632P3deuT41kopRyfX0DQpUxQvOcrFSumJiqywNa6mbGPg7H6MRs7Cy xFFfzXgegzb+iC1vY2/zPHwBlpuSfTc7GZL0wVJ0W4hL+dIh/XwuQKwOr5pA4NdkysI2ZbrI6Yz fuo/ptZ9FkxpN1RNPQE/geT9wB4ZG/4kRH9dnYBwD28l/d+sDpiBMSSUb1qh+o4wn68mMZPUEpy z7mnvTPdoqk9I7TOaYEj0pgsM9UGoYtWwNZVLdUdlayb8VlSARvv5xyU+WdyyPHUtkcJonvRAcw f4rwNFbsfPx+1TXxaPuE+sZROLSBOYWSuiUYZ3gcjRFXqau6GJC7X3ABmomZMrMWsav2Chdk/VD pz04ING0Hs+KLI4ozT6YWSwc+A3M9WPimHV4+uJUDeaTibEK5B3WaGnhRHkTY= X-Google-Smtp-Source: AGHT+IEA3WrHgp5ecEMKNm9JiVdtpzxk9v/x2/vTeR8RniWcj0S+d7R5TzjjaIhv5WRyeSx0oFzvMg== X-Received: by 2002:a05:6512:23a1:b0:594:36b3:d1fa with SMTP id 2adb3069b0e04-596a3ed471fmr11203155e87.29.1764425763064; Sat, 29 Nov 2025 06:16:03 -0800 (PST) Received: from home-server.lan (89-109-48-215.dynamic.mts-nn.ru. [89.109.48.215]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-596bfa43f33sm1945600e87.49.2025.11.29.06.16.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Nov 2025 06:16:02 -0800 (PST) From: Alexey Simakov To: bskeggs@redhat.com Cc: Alexey Simakov , David Airlie , Daniel Vetter , Francisco Jerez , dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org, Alexandr Sapozhnikov Subject: Date: Sat, 29 Nov 2025 17:14:40 +0300 Message-Id: <20251129141438.8789-1-bigalex934@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Date: Sat, 29 Nov 2025 17:06:57 +0300 Subject: [PATCH v2] drm/nouveau: fix div-by-zero in nouveau_bo_fixup_align The expression 64 * nvbo->mode can be zero when nvbo->mode equals U32_MAX / 64, causing a division by zero in do_div(). Values greater than U32_MAX / 64 cause a u32 overflow, leading to incorrect results. Since nvbo->mode comes from userspace via ioctl, it must be validated to prevent crashes or undefined behavior. Add a check to ensure nvbo->mode is less than U32_MAX / 64 before use in multiplication. Found by Linux Verification Center (linuxtesting.org) with Svace. Fixes: a0af9add499c ("drm/nouveau: Make the MM aware of pre-G80 tiling.") Co-developed-by: Alexandr Sapozhnikov Signed-off-by: Alexandr Sapozhnikov Signed-off-by: Alexey Simakov --- v2 - move value check at the begining of nouveau_bo_alloc for preventing execution of function for case, when tile_mode is too large link to v1: https://lore.kernel.org/dri-devel/20251022041302.13-1-alsp705@gmail.com/ drivers/gpu/drm/nouveau/nouveau_bo.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c index 96a8b7b1215e..774888ffa4a8 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo.c +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c @@ -207,6 +207,9 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 domain, struct nvif_vmm *vmm = cli->svm.cli ? &cli->svm.vmm : &cli->vmm.vmm; int i, pi = -1; + if (tile_mode > U32_MAX / 64) + return ERR_PTR(-EINVAL); + if (!*size) { NV_WARN(drm, "skipped size %016llx\n", *size); return ERR_PTR(-EINVAL); -- 2.34.1