From nobody Sat Jul 25 20:47:09 2026 Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) (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 0410129BDB1 for ; Mon, 13 Jul 2026 21:55:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783979717; cv=none; b=ecmN8uaFs9muYexiLe/GmArsJdzvkJx4VXfVBFM1UdaQvXQZFTlR5xLSdV/ImJ/Ub2hi85NlAOmur92GVc9MNGFL5vbZF7PnMMtczf/wgr0Rqcu/roLV60HlVRSc8dYgnqM020kDY0yzyE2EWF7xUHopJ5T/2Vx3KKR2LIsk1xw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783979717; c=relaxed/simple; bh=iZfYErounIL9gHykFDebdn//bMBHfpNIHjU5jurLOQg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=tr9Z0im6JiMEUkgOHQnqE5/h7gwjnKT/8gpMMAW4Gwayp7IgyiU+5ahAIich4utQZwhdVkGfp9ISUIed9NvTrf7dRWT6SfnZFaW4vh9oZs+YJeUFSJB0vIL7HvZVQaRsqQnewwcmsTeCqraiU9Hne7DFsIJJ7/UZRiCeOj9ZAxE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=asu.edu; spf=pass smtp.mailfrom=asu.edu; dkim=pass (2048-bit key) header.d=asu.edu header.i=@asu.edu header.b=YKNlqOSa; arc=none smtp.client-ip=209.85.215.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=asu.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=asu.edu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=asu.edu header.i=@asu.edu header.b="YKNlqOSa" Received: by mail-pg1-f174.google.com with SMTP id 41be03b00d2f7-c9e7391839cso275679a12.0 for ; Mon, 13 Jul 2026 14:55:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=asu.edu; s=google; t=1783979715; x=1784584515; 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:content-type; bh=MD7Y6DMFrR7r/Z/j6JTbjRcV0lB38kr6b6Wdu1GS1g8=; b=YKNlqOSapmfq1QdMcoCDyjEAGnHFnMvH7fe9z+LNomCxnBkdtaqmo5zK0T7O10sFy4 BUquJm5IXRQJ5yW0a3uMUCBCyxuDVXyp1/V4cULNgaiCgQpw/DDYpA/ZMwnXvS+fEbAQ LyRtRDGNGyVijY90YNPVJRK8qDpvxyvqZddnQObbrWD6dyuTClfObgl64EH67FzZ1xhE dIwo5cIuzNX6JKodQisFHc9hW8lBssjHC0tlPQQ7dRL89rDxwis+eqD+A+ZIwL3L13Cr EehZDzamWFhc2RjtiHRy+GebPafGeZ2Qrb0mBqGle6F0UPSVXEi2Q15qsvrlkiX72LlK 8xrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783979715; x=1784584515; 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:content-type; bh=MD7Y6DMFrR7r/Z/j6JTbjRcV0lB38kr6b6Wdu1GS1g8=; b=cdKZCSU3zdwmf8etpj637b3bq47EWXKDkDYV9KJZyAodo7JmVAGkYD5zhEOeDQbINL CrtYOhVLKuOu7BLyZk2j1nRWH0HX0Wy1DpwfAYDlfJeGGUy5A38S+Pg+9JL7gpdJzQIt qBtLY5X1NqERw1buA0e6uBTNZXBXf1kApXnPDQ07Z419dISdahOUGVwEkMCzQn8XCGTi jF5nmP2ok0B/t32IIayjhZ9tKMyj/RtO+IMxIoqakTape6clS1Lq2uuzAOq2SnkAPmdR 5N3jg0OVVT8D0ebZP9FtXkDOtBJW+L9t6xaWaVTZV3khAOHct+uqMSUZ8XtnniavT3b8 7wxg== X-Forwarded-Encrypted: i=1; AHgh+RoCwwMc701z+9jCfmSTc8WGXrrxli2AXE4VTKhuhJ88fE9Voe2DpoLrDGLm0fyefJaa0GwAsPAU88kHtcQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyUTLrDtf8R1wv6j99cNS4ZNzafKmDJqWfYS9WOG8HXCeOysOMH iK94JX7pP2W/mRcqxCenBwKk681uE8sN66PNwWVSUfbR6dAc9H2+uvfkV6z+1z58bg== X-Gm-Gg: AfdE7cnrHZM18uYj9J1zceLf/wysugZUr3cfFqj8Dkn23YvBDjV6FrEhFvbnNDHK0dp sb3DE8f/EwmKjytPADan9KPh+PjQnCLuAh5fxISqpknQ1PqQxCpFOTgG5EDen74mpE7/iF4b3Ag rLIcydsarauw6i9FeTK87lbdOFQnicqEvqhMtfqZMc/7kcIGvbEKfbgQpxEw3pLSnnZX5Au2Mmc jntJ+V10YM9Zsve41/ustRqrA64ppl0/tmQ3v2cQ0NNb9l6JLYOcaCSkV4W132bTApxY/1Z3T/1 k7HR1j5hOjCbuhXhm3jGexxHmhW+16mblGMJPmUl6tJ0wGEcPqTgqO59O86XSU0tJxCtIN6h+qL phVKxtfm+2UqWPkpsK9j+ZBa9DIVnHlkS9aXJ3aa4O+H3cZvCPdFZ7PCIvIGygaWGMwgr2uhRmh S34rDQpjjavHdbd2InUA== X-Received: by 2002:a05:6a20:734a:b0:3bf:b9de:8570 with SMTP id adf61e73a8af0-3c110160a19mr10763040637.19.1783979715415; Mon, 13 Jul 2026 14:55:15 -0700 (PDT) Received: from xiang.tailc0aff1.ts.net ([20.171.14.70]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-13b9a67c217sm15480309c88.8.2026.07.13.14.55.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2026 14:55:15 -0700 (PDT) From: "Xiang Mei (Microsoft)" To: Namjae Jeon , Steve French , Sergey Senozhatsky , Tom Talpey Cc: Ronnie Sahlberg , Hyunchul Lee , linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org, AutonomousCodeSecurity@microsoft.com, tgopinath@linux.microsoft.com, kys@microsoft.com, "Xiang Mei (Microsoft)" Subject: [PATCH] ksmbd: validate compound request size before reading StructureSize2 Date: Mon, 13 Jul 2026 21:55:10 +0000 Message-ID: <20260713215510.3288580-1-xmei5@asu.edu> X-Mailer: git-send-email 2.43.0 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" When ksmbd validates a compound (chained) SMB2 request, ksmbd_smb2_check_message() reads pdu->StructureSize2 without first checking that the compound element is large enough to contain it. StructureSize2 is a 2-byte field at offset 64 (__SMB2_HEADER_STRUCTURE_SIZE) from the start of each element. The compound-walking logic only guarantees that a full 64-byte SMB2 header is present for the trailing element: when NextCommand is 0, len is reduced to the number of bytes remaining after next_smb2_rcv_hdr_off. A remote client can craft a compound request whose last element has exactly 64 bytes, so the 2-byte StructureSize2 read at offset 64 extends one byte past the receive buffer, producing a slab-out-of-bounds read. BUG: KASAN: slab-out-of-bounds in ksmbd_smb2_check_message (fs/smb/server= /smb2misc.c:402) Read of size 2 at addr ffff888012ae31ac by task kworker/0:1/14 The buggy address is located 172 bytes inside of allocated 173-byte region Workqueue: ksmbd-io handle_ksmbd_work Call Trace: ... kasan_report (mm/kasan/report.c:595) ksmbd_smb2_check_message (fs/smb/server/smb2misc.c:402) handle_ksmbd_work (fs/smb/server/server.c:119) process_one_work (kernel/workqueue.c:3314) worker_thread (kernel/workqueue.c:3397) kthread (kernel/kthread.c:436) ret_from_fork (arch/x86/kernel/process.c:158) ret_from_fork_asm (arch/x86/entry/entry_64.S:245) Reject any compound element that is too small to hold StructureSize2 before dereferencing it. Fixes: e2f34481b24d ("cifsd: add server-side procedures for SMB3") Reported-by: AutonomousCodeSecurity@microsoft.com Signed-off-by: Xiang Mei (Microsoft) --- fs/smb/server/smb2misc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/smb/server/smb2misc.c b/fs/smb/server/smb2misc.c index c0c4edd092c2..9f3629c86291 100644 --- a/fs/smb/server/smb2misc.c +++ b/fs/smb/server/smb2misc.c @@ -407,6 +407,11 @@ int ksmbd_smb2_check_message(struct ksmbd_work *work) return 1; } =20 + if (len < __SMB2_HEADER_STRUCTURE_SIZE + sizeof(__le16)) { + ksmbd_debug(SMB, "Message is too small for StructureSize2\n"); + return 1; + } + if (smb2_req_struct_sizes[command] !=3D pdu->StructureSize2) { if (!(command =3D=3D SMB2_OPLOCK_BREAK_HE && (le16_to_cpu(pdu->StructureSize2) =3D=3D OP_BREAK_STRUCT_SIZE_20 || --=20 2.43.0