From nobody Sun Dec 14 06:34:41 2025 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (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 6831E1DC9B3 for ; Sat, 13 Dec 2025 01:29:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765589358; cv=none; b=W27qYr4fVpeQqxTDdDUgIN6PkL9SxJflNDOrxQhrek/qjoYxs5CgAZDVIIc3xef3Dd2mlB6NQ+rCFyfdt4Hr+UY0AUvWhlVUd1fdpoB7wPZCQcwVti8XEd6iix5Gs42rvsgn3SG0EsPXOng0AZxMFaVyAhjxfllzssSZyWDHQik= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765589358; c=relaxed/simple; bh=Q/BnWKrddUCa21vqQ0fyH/iLAaKmHYd+0zEE+INzCdw=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=AHe0/OLQyMywPKZ+Z8FmxKYk2ia9wmSg3PxfdY3fBmWPoA22o9YKGtaqfY7cWqDLHm3bUnt1vmOqIutcZUDUSdZr8cf1jLnDLRvSfwbsE2BzGsqpoUYtfYzDy0Arj7ersYjnD+lewOb2j2/6QqSLqM37jq/5pPhCNgeHi5lYqE0= 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=QNpl1/aS; arc=none smtp.client-ip=209.85.214.172 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="QNpl1/aS" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-2a08cb5e30eso808845ad.1 for ; Fri, 12 Dec 2025 17:29:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765589357; x=1766194157; 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=Cln0tpkwGaPX83TGznuKujQwit6sD5kTkWZGVuQGa7E=; b=QNpl1/aSjjIszVUEeeu/E0BXJJDs5CqtTKVNskrDbdaqhFT5h02pZddplzz9uOXGhJ VHPwsJ45twAIaqaCLyoNyuNh/FWxW0azobrWJoz7246c9zv1P1ODIWTuW8tUxwue0Pzz cvTXvgcgbwBBIUBI3zH6coSfnk8WYk7bwURh1G+euFxIBTD+99DjcVUAQot4JRZciJC3 tsIdxPlTJc9ZeSRwfL2sbBKPxMdZmTtNjQ8Y38keciKdu/WPL/TDUgGSOum5XfisY4h+ cPvzyP3ZcG9bUsuXQOrf1X1Iox12+WKzyxzt3jTUiw7czS/eK1hz5gYQ2s3DoQxoKHk0 jsoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765589357; x=1766194157; 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=Cln0tpkwGaPX83TGznuKujQwit6sD5kTkWZGVuQGa7E=; b=jSbEo7lqSCI9RiPVWWxfaOJwcihknnax9OG1juqqsmFf8OE9DkWJiD7XBKTixDeNWn x/2bNC7Iw403OT0mbM21WWYibiuYEr3QjRqtxGcqJDfObx9d6efPFp9MyWyMYhdNy/6n 9A4kaX6Fy/zvs2FJg/Ry3Q7bS7xl77ZoK9Nfu94odVaF+idiUWc8VQO1YkqTGUIMfia8 Q25clurfZ2unR9TJL8sDs2at0ocVGLwJ/yFU5dH+QuLNTB2voBM1/kCy2kHu8j0gluXn dp1uS25bVuUmCUPwLisO2f4Qepm6xbq4gtrrU3LE/AW/qBfTxrs2L8PWZ0iWNnyte75G ZT2w== X-Forwarded-Encrypted: i=1; AJvYcCVCfMcHZGpP1Kpvfbho7W5cq01PRtDtZdD3kwxNkT6zHX6S4/V/LCbsnVDo0IeVbjTtBH1DNlSWIITX1ts=@vger.kernel.org X-Gm-Message-State: AOJu0YycOo24S94a1MmHPxha6RfBVhIGoEIdPq+TZUbeWeWl3GtMfj/l /VeDvvsyQ32RBtYsyngKsWxcpcBXVL0VJTKhvrF+PTH7M1k2UACus5W5 X-Gm-Gg: AY/fxX6jBAlS7NR5gn4m4jfSB18QE6qUNAz/upuG62nbc7eU59N6iisIp7FEv/D0Cn4 eiw4osczOIAm3w8PGDBc5irnnEo5lYozZQtpxXobE+SEPHTXMJkSp2u5XBNwmHas3lq+Crqfpqs 4JBW5ErmWbY8ZnuyA6qooGOlr1NOQeBLToaXHaA5/jbEM5POa/I48EZBRGHkZqK8NqXGC46Y6W+ Cr2KVamL7awzuZ8PK/iru4t7oZeo8vlUkFDA8Xf3azmLu95a9OzBj9FdGWBGuJFqi2ZaqgWyBff TFL6df9H/hs4k+e5DZhBr9VZ8uLoNZKxx74v/FLNt188Gq2CZ+oJOYbeS9QV5hOvfo9nTikx+SK K+va8d2CWL0yYpYHgfDkMVslBTNK7bkDfRcovadhADFXEnN/qdCAzvq6KKkQqACL4tVWHQFQmHx y/2PKVyttKP803YOoqGVRw59Aj0dPxGnnJrIXp7vArRjXOTiaCOW5tsHAMkIQ7KiSsl5GHf3VV X-Google-Smtp-Source: AGHT+IE2FNluVs7vDa7N2km+hccJ4M70DEuxxCelM+kxINda5gMkw26py8jFfb68ATt4fxnqeEdPGQ== X-Received: by 2002:a17:90b:2692:b0:340:b501:3ae2 with SMTP id 98e67ed59e1d1-34abd5c1d75mr2654608a91.0.1765589356670; Fri, 12 Dec 2025 17:29:16 -0800 (PST) Received: from poi.localdomain (KD118158218050.ppp-bb.dion.ne.jp. [118.158.218.50]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c0c2ad5663dsm6370008a12.17.2025.12.12.17.29.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Dec 2025 17:29:16 -0800 (PST) From: Qianchang Zhao To: Vivek Goyal , Stefan Hajnoczi , Miklos Szeredi Cc: =?UTF-8?q?Eugenio=20P=C3=A9rez?= , virtualization@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Zhitong Liu , Qianchang Zhao , stable@vger.kernel.org Subject: [PATCH] virtiofs: fix NULL dereference in virtio_fs_add_queues_sysfs() Date: Sat, 13 Dec 2025 10:28:29 +0900 Message-Id: <20251213012829.685605-1-pioooooooooip@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: quoted-printable Content-Type: text/plain; charset="utf-8" virtio_fs_add_queues_sysfs() creates per-queue sysfs kobjects via kobject_create_and_add(). The current code checks the wrong variable after the allocation: - kobject_create_and_add() may return NULL on failure. - The code incorrectly checks fs->mqs_kobj (the parent kobject), which is expected to be non-NULL at this point. - If kobject_create_and_add() fails, fsvq->kobj is NULL but the code can still call sysfs_create_group(fsvq->kobj, ...), leading to a NULL pointer dereference and kernel panic (DoS). Fix by validating fsvq->kobj immediately after kobject_create_and_add() and aborting on failure, so sysfs_create_group() is never called with a NULL kobject. Reported-by: Qianchang Zhao Reported-by: Zhitong Liu Cc: stable@vger.kernel.org Signed-off-by: Qianchang Zhao --- fs/fuse/virtio_fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c index 6bc7c97b0..b2f6486fe 100644 --- a/fs/fuse/virtio_fs.c +++ b/fs/fuse/virtio_fs.c @@ -373,7 +373,7 @@ static int virtio_fs_add_queues_sysfs(struct virtio_fs = *fs) =20 sprintf(buff, "%d", i); fsvq->kobj =3D kobject_create_and_add(buff, fs->mqs_kobj); - if (!fs->mqs_kobj) { + if (!fsvq->kobj) { ret =3D -ENOMEM; goto out_del; } --=20 2.34.1