From patchwork Sat Dec 16 04:10:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Alcantara X-Patchwork-Id: 13495450 Received: from mx.manguebit.com (mx.manguebit.com [167.235.159.17]) (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 664698498 for ; Sat, 16 Dec 2023 04:10:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manguebit.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=manguebit.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=manguebit.com header.i=@manguebit.com header.b="q7JaF2Xj" From: Paulo Alcantara DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manguebit.com; s=dkim; t=1702699813; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=1MWkrAALI2O2O/9VtX/7hA45pQY69vm6tgh+X3v3yN8=; b=q7JaF2XjCqICkrLEQR9ESP+LS8dONwuKE/6aDnPptQa9tGCQaIGaQC8YAqiTzuBFNkpWhl o1gG+R3OoOwQEok7RHGDwERpal59WfFlH8ueu2W7Jm2PCvXL/uldPdrxH2tCPuvs6eG2VH p9cj4iUCDHjnuhfIWDWLbtSEP20N3DxRWDDI8XLBXnJ0eNzdgrwnFRYCh3y5ounlIqMRnW sIk/ss6uxgjgiY2ztQrz/kNS/QMJICVtxngu8Ca/BO6bLIjbSi9Ed8zp5Di3pv05/pUjtY OwA7PIoxQajzl5wN9xCLYMhJjbK8YcaZ9WvJeoBs5EFzWlU1NMv+vXH2emv8yA== ARC-Seal: i=1; s=dkim; d=manguebit.com; t=1702699813; a=rsa-sha256; cv=none; b=cqOIYyg1hoC9pu0GKbSMSfQwdj1EMHWxP+gRiHYKC7UxA/JOiGMb8+bqLPk/oZBxOOsV4u 1ww1PvAKgMYdNfrjUMjDY0ntTM2OhQZ9aQ492X2choryX7yMeLh7IGG2EuxD7tXfg/TiTl QU4pXJCAM9aBJ3PGR+ikuz8JQV+nZ8CScIlPFxU1f2QIrh5Sd5zxv0CpvaPZkON5texW26 tPWP9mMyrPUgiobCMpupccB4wZZG1XO1nBfR5UAG3sG1niecO5SjqplqNSp4NaDN1u9ZWE DQslQEHFDsI2i+WVsSgmLJwpRB4e4WGj/4Q98CzcdHlzkSxNGj8LmNiT28gXHA== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=pc@manguebit.com smtp.mailfrom=pc@manguebit.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=manguebit.com; s=dkim; t=1702699813; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references; bh=1MWkrAALI2O2O/9VtX/7hA45pQY69vm6tgh+X3v3yN8=; b=I5ulei8nKOGXCkIeOHA8kyRvyGfLb0BTFEPtRGLxGYwmAO3VAoJzwTZvjyM4ZjSf4BY8WT +80IwJsPiak7rOHJmR/bOj8eWxFGyZhkCYR3abJXU0eQGQF3aKrK5kmAPUCMrkfzqCiEHr ofSbrEng1TFfYMFYI1VjdLQP9ChKTdHWfNElWAkGa20daFc+ezdaj2tJCWy4esZYoOc9K6 ZwX97rk2Mm3LMyb5pIxOSQQpDGrSrdeZ4eFkQu/BM1zlVCJ7n4+GjtqdI/s7A8PSsSCXPm l7eseVoJOm916X28sYvMybNmyYfqUMQXFBlWe089aoWw3YwGpZWzzLxZ8hiBrg== To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org, Paulo Alcantara Subject: [PATCH 1/2] smb: client: fix potential OOB in cifs_dump_detail() Date: Sat, 16 Dec 2023 01:10:04 -0300 Message-ID: <20231216041005.7948-1-pc@manguebit.com> Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Validate SMB message with ->check_message() before calling ->calc_smb_size(). Signed-off-by: Paulo Alcantara (SUSE) --- fs/smb/client/cifs_debug.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/fs/smb/client/cifs_debug.c b/fs/smb/client/cifs_debug.c index 5596c9f30ccb..60027f5aebe8 100644 --- a/fs/smb/client/cifs_debug.c +++ b/fs/smb/client/cifs_debug.c @@ -40,11 +40,13 @@ void cifs_dump_detail(void *buf, struct TCP_Server_Info *server) #ifdef CONFIG_CIFS_DEBUG2 struct smb_hdr *smb = buf; - cifs_dbg(VFS, "Cmd: %d Err: 0x%x Flags: 0x%x Flgs2: 0x%x Mid: %d Pid: %d\n", - smb->Command, smb->Status.CifsError, - smb->Flags, smb->Flags2, smb->Mid, smb->Pid); - cifs_dbg(VFS, "smb buf %p len %u\n", smb, - server->ops->calc_smb_size(smb)); + cifs_dbg(VFS, "Cmd: %d Err: 0x%x Flags: 0x%x Flgs2: 0x%x Mid: %d Pid: %d Wct: %d\n", + smb->Command, smb->Status.CifsError, smb->Flags, + smb->Flags2, smb->Mid, smb->Pid, smb->WordCount); + if (!server->ops->check_message(buf, server->total_read, server)) { + cifs_dbg(VFS, "smb buf %p len %u\n", smb, + server->ops->calc_smb_size(smb)); + } #endif /* CONFIG_CIFS_DEBUG2 */ } From patchwork Sat Dec 16 04:10:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Alcantara X-Patchwork-Id: 13495451 Received: from mx.manguebit.com (mx.manguebit.com [167.235.159.17]) (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 46D82DDAF for ; Sat, 16 Dec 2023 04:10:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manguebit.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=manguebit.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=manguebit.com header.i=@manguebit.com header.b="hqleqbUM" From: Paulo Alcantara DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manguebit.com; s=dkim; t=1702699815; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=592PpszBy+wK5ur9oBozp/DCIholZwuFhMl1xRTDUzQ=; b=hqleqbUMZ0yG7QUTwwMODsAab4fNUGahn1OQaOgNGBvehojFrTVIo1s3vffcITKk/a0F+y MK26n1f+upJ3UYlK4ADHlda++Zj/7CY6u/YIhaMS9uqlkeHp4lUI3slMIEGveMGthuJXUF 3t+axKQ4FaGhEvC3/p0yfCQ3y3Qlh+jltKnI4v7n6mZWgs8VnxHbEaRPcnAVTU97Gs85xS mYk1gY02A1IcJBUix/2QXV0vdYk25LY5YYbhTjNyyyb4jxxVV5ULURDi7oZb1fG5UfWwTk 6IW25LzXoDR8VwT0IgRg+ITnjJcONTGVYHYOs3zEZdr+CeKjJeM+0MuagURunQ== ARC-Seal: i=1; s=dkim; d=manguebit.com; t=1702699815; a=rsa-sha256; cv=none; b=a8iAT3D5jEUpV6qcjcxJckHyCtdTuiSKgO04JlBBQfZqAEAKf/Nts7Z4R5nNJ+aqdgTFRs DPg0h6Ejgr6IxwVi8zXCI8lnbEBg1OxHGKTVQHHLWVezFa/QUsoBc90JtT5LgMdKMKfDWE z4niupG+mUwTfIbTvJquzuQnpWRfSssxrRRQOehBOAsMKqaiDPrvcZrx6g0WMAww85GmiB YMkeXwzb46mXMZLlawhZ0D949yBtHVPjVurzKZsT8HmSgxQdc9ix92c341A1J9gDBoE8Le 4/HGXbNWks0jSJG8X8ZPImHmXurYpvofWmRjPA4WK06KO5L8W3PTBeYUFHtQ+A== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=pc@manguebit.com smtp.mailfrom=pc@manguebit.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=manguebit.com; s=dkim; t=1702699815; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=592PpszBy+wK5ur9oBozp/DCIholZwuFhMl1xRTDUzQ=; b=QcY0DuOKuJ6XGSkZ9+WP1zr3LhjcIlXY4wnw6V8y6EoYNR/AZ24RFMf/hFy0UbhBqNPhfi 62fJIJ/2o+1uQw3iCMDQ4lYiCcU3xLVc3So/E3tpl4Lny8l+Bf8olQRhIC5iFbX2sOMxfK oL351BQ0Na39smvJaW1c4EVgl4YXebocPLDZSK2aNieUXh14jLrHBXG42i8gOg6u6m7QCl 3A2o017tdva89McML0AaTrqbCOXP/ewo/EQbTfuo4b6whXkd4ujk2uSV2xRwkXSVSHaqfN xCLnULKLZwmR8MMm2BEjAekX78HcXWfEvIeMIbubDYGMXe6jxf3ANAe9jdJTYg== To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org, Paulo Alcantara , j51569436@gmail.com Subject: [PATCH 2/2] smb: client: fix potential OOB in smb2_dump_detail() Date: Sat, 16 Dec 2023 01:10:05 -0300 Message-ID: <20231216041005.7948-2-pc@manguebit.com> In-Reply-To: <20231216041005.7948-1-pc@manguebit.com> References: <20231216041005.7948-1-pc@manguebit.com> Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Validate SMB message with ->check_message() before calling ->calc_smb_size(). This fixes CVE-2023-6610. Reported-by: j51569436@gmail.com Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218219 Signed-off-by: Paulo Alcantara --- fs/smb/client/smb2ops.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c index 62b0a8df867b..66b310208545 100644 --- a/fs/smb/client/smb2ops.c +++ b/fs/smb/client/smb2ops.c @@ -403,8 +403,10 @@ smb2_dump_detail(void *buf, struct TCP_Server_Info *server) cifs_server_dbg(VFS, "Cmd: %d Err: 0x%x Flags: 0x%x Mid: %llu Pid: %d\n", shdr->Command, shdr->Status, shdr->Flags, shdr->MessageId, shdr->Id.SyncId.ProcessId); - cifs_server_dbg(VFS, "smb buf %p len %u\n", buf, - server->ops->calc_smb_size(buf)); + if (!server->ops->check_message(buf, server->total_read, server)) { + cifs_server_dbg(VFS, "smb buf %p len %u\n", buf, + server->ops->calc_smb_size(buf)); + } #endif }