{"id":2224783,"url":"http://patchwork.ozlabs.org/api/patches/2224783/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-cifs-client/patch/20260418154505.84684-1-akif.sait111@gmail.com/","project":{"id":12,"url":"http://patchwork.ozlabs.org/api/projects/12/?format=json","name":"Linux CIFS Client","link_name":"linux-cifs-client","list_id":"linux-cifs.vger.kernel.org","list_email":"linux-cifs@vger.kernel.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260418154505.84684-1-akif.sait111@gmail.com>","list_archive_url":null,"date":"2026-04-18T15:45:05","name":"ksmbd: fix O(N^2) DoS in smb2_lock via unbounded LockCount","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"5f2f01d61e09ab3d45be6d6618c612654bfd027f","submitter":{"id":93185,"url":"http://patchwork.ozlabs.org/api/people/93185/?format=json","name":"Akif Sait","email":"akif.sait111@gmail.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-cifs-client/patch/20260418154505.84684-1-akif.sait111@gmail.com/mbox/","series":[{"id":500450,"url":"http://patchwork.ozlabs.org/api/series/500450/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-cifs-client/list/?series=500450","date":"2026-04-18T15:45:05","name":"ksmbd: fix O(N^2) DoS in smb2_lock via unbounded LockCount","version":1,"mbox":"http://patchwork.ozlabs.org/series/500450/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2224783/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2224783/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <linux-cifs+bounces-10898-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-cifs@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=f9cbbP1T;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c15:e001:75::12fc:5321; helo=sin.lore.kernel.org;\n envelope-from=linux-cifs+bounces-10898-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com\n header.b=\"f9cbbP1T\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=209.85.214.176","smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=gmail.com"],"Received":["from sin.lore.kernel.org (sin.lore.kernel.org\n [IPv6:2600:3c15:e001:75::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fybgp0gT7z1yDF\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 19 Apr 2026 01:45:58 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sin.lore.kernel.org (Postfix) with ESMTP id A3DE23007A67\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 18 Apr 2026 15:45:53 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id AFADD243376;\n\tSat, 18 Apr 2026 15:45:50 +0000 (UTC)","from mail-pl1-f176.google.com (mail-pl1-f176.google.com\n [209.85.214.176])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 82D0E199385\n\tfor <linux-cifs@vger.kernel.org>; Sat, 18 Apr 2026 15:45:49 +0000 (UTC)","by mail-pl1-f176.google.com with SMTP id\n d9443c01a7336-2ad21f437eeso10769375ad.0\n        for <linux-cifs@vger.kernel.org>;\n Sat, 18 Apr 2026 08:45:49 -0700 (PDT)","from localhost.localdomain ([205.254.163.141])\n        by smtp.gmail.com with ESMTPSA id\n d9443c01a7336-2b5fab4cc47sm54703385ad.82.2026.04.18.08.45.45\n        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n        Sat, 18 Apr 2026 08:45:48 -0700 (PDT)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776527150; cv=none;\n b=QE0DS4DirIm9/hRzpceFR28B718O5TNhTO5ZMyFIw0u1lt6qKo+QwgOIM2456235KqmIpg+P3/XZbxqI7IUFl3LuB8kmKWy8R4rtCB5t8DPPJIz0LMfIQo2ntwt2ICUCpDzumw7fjnSGnDfkBEF55uSCZ0dlp7dTcVdNK+dq88A=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776527150; c=relaxed/simple;\n\tbh=sX27uXV1JVZhbIDBUsq4KYLX5oQryToCfrgcG5bZcQA=;\n\th=From:To:Cc:Subject:Date:Message-ID:MIME-Version;\n b=tm0jXzGXu21mVGCO+OFa38lMdGz06Lfn17Oiauta5vLPeK7qZ33kWmNFbutRWvzahwd9gAJeh+EJlRIf7sGfndgAwIA9qfGazBam2RfFsHXpSYzw0r7CwVKrx1bJH6vmTFOWM7xRuCAKULD7hk3m8RxqV1WjyyandCL0mllJMLI=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com;\n spf=pass smtp.mailfrom=gmail.com;\n dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com\n header.b=f9cbbP1T; arc=none smtp.client-ip=209.85.214.176","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=gmail.com; s=20251104; t=1776527149; x=1777131949;\n darn=vger.kernel.org;\n        h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n         :to:from:from:to:cc:subject:date:message-id:reply-to;\n        bh=Nixch5XpAUlwvDbeIvi1QyFB/G5nvIJ1ufdy7DtrBwY=;\n        b=f9cbbP1T75icNfJrimxW+GIoKVb1jXxem9FGOKm6xkpo4FfzHnZgPtq4zsdeNmPQYT\n         lO1B53OA6zXcrSi8WvKrVxigq29GT5kQsTC7S0g9dqGH72pNBtHVazr8lOhO4Udkcmfh\n         gZMQrK+QMEkAkJRfOyLSyIsJI5BQbcuGjRDJg45M3YJQcdW5Pejz4YcOHMJc4MJ/DXKt\n         Tp/0zyZ8IXr5uNKdx9OofIY5gmqAyAApHp/ymAiM0Moqib70oc9wgsYFQSSMMn9njyUM\n         Kuu4gsWTkAWEk5gcYghtknTFwhvqQYiuocxUClg8bcZbcfHqigUvRPs10VWDucMUDQwC\n         +A1A==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20251104; t=1776527149; x=1777131949;\n        h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n         :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n         :message-id:reply-to;\n        bh=Nixch5XpAUlwvDbeIvi1QyFB/G5nvIJ1ufdy7DtrBwY=;\n        b=dgz1kTHi1kFYVRwGWscFgdohoWzUMIS2DDmzb6w4tDEA9270SSZ9eg9FiLHknl8No5\n         yRTtS+xgUFAMzt6wGsRwL0foWGCim/4oRO+AEwhSriwl0cBH7PkSgK63J84E9JjfLmUB\n         QyjqNtBQuBTeKHqPeFZdeMjSPyijFqxVDiLuVKdSMmOFhycNZEJ4cQ3o/4gyAYxyWSBf\n         lx2gjCBqVTQ6GvuOWnWWiceaPLAPkz/ohQgD8damzfp1vNdMVQnrHAt/DNnGAcXB/Rdo\n         Sc/j/xTA6B/OoAlbOAIOeTHDOrvVpBct6hlMG3ugdANIQhfHiJDuDusIpyW59LwwSuWP\n         vGcw==","X-Forwarded-Encrypted":"i=1;\n AFNElJ++tRGi99Pk3JxhZ3A6oK7wtyNQWRglT45v/vn3Qez6L4rRpuy9Rk6Gw5Bp1SBxp0RfW1iXhDBR/cqY@vger.kernel.org","X-Gm-Message-State":"AOJu0YzGyD2SMFqo6N45xG0U8U1/zhzzFFTqky9qDuvUSCkOEF8Uawr8\n\tAI56me8C+9/c6br3rA7tazvzaLEZ2kwrrhgu7+/q0pMR+akl1J6y2cWG","X-Gm-Gg":"AeBDietXE7pk1IvCMt/KFfxjdatvU7YGFFZio9amgs4DlJqZzlM078rhGtFi8nQuMxf\n\tnSo6rW8NsCd1PS3AgeJFnyfON/TN98Mg+0wUnyHiyrGoFgtPCcWgWe9I/utUSKaZwYcsnZDf0tk\n\thlPLkr5TEos2sS6i1zFVQLKzKMExG9UyJCBuMSY6ZsziL/PyUnSZ1e4glTYjBgahRtfJCN/GDoL\n\tg9uyxHHqKpJc+68ax5dQnQIQr9KjTllQQyZfa76Rq4XFQcbW9JZU0NmXav05AwCLvH2TJ/gClPM\n\tkKKhGbsRjyeb55GRVWmdKI0VwOLrZe/0UMmXMZEIPMTvJMRHj54/iwE5RdHm478kpMaiSMIJzb/\n\tLvABxY1Q55Ep5eqOBO+bRJjQEGJY6rFUiGg1dK5djk34kuAG+JMgkJTjK2/ducDyp/I+T1O7GGa\n\tYNqizlWHUl+KzQVm8VL53wNCH7iLJiWCaK+wtD6UVBV9ipYwHGYbuoXcCOAj02cFk=","X-Received":"by 2002:a17:903:1aac:b0:2b2:54db:3e93 with SMTP id\n d9443c01a7336-2b5f9ecb056mr57628515ad.23.1776527148805;\n        Sat, 18 Apr 2026 08:45:48 -0700 (PDT)","From":"Akif Sait <akif.sait111@gmail.com>","To":"linkinjeon@kernel.org,\n\tsmfrench@gmail.com","Cc":"senozhatsky@chromium.org,\n\ttom@talpey.com,\n\tlinux-cifs@vger.kernel.org,\n\tAkif Sait <akif.sait111@gmail.com>","Subject":"[PATCH] ksmbd: fix O(N^2) DoS in smb2_lock via unbounded LockCount","Date":"Sat, 18 Apr 2026 21:15:05 +0530","Message-ID":"<20260418154505.84684-1-akif.sait111@gmail.com>","X-Mailer":"git-send-email 2.53.0","Precedence":"bulk","X-Mailing-List":"linux-cifs@vger.kernel.org","List-Id":"<linux-cifs.vger.kernel.org>","List-Subscribe":"<mailto:linux-cifs+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-cifs+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit"},"content":"smb2_lock() performs O(N^2) conflict detection with no cap on LockCount.\nCap lock_count at 64 to prevent CPU exhaustion from a single request.\n\nSigned-off-by: Akif Sait <akif.sait111@gmail.com>\n---\nHi Namjae, Steve,\n\nsmb2_lock processes LockCount lock elements using a nested loop where\neach element checks all previous elements for conflicts. With no cap on\nLockCount a single authenticated request with LockCount=65535 results in\nroughly 2.1 billion iterations inside a ksmbd worker thread, pinning the\nCPU completely. A few concurrent requests hang the host entirely.\n\nCap lock_count at 64. The MS-SMB2 spec defines Open.LockSequenceArray\nas exactly 64 entries so 64 is the intended ceiling. No real workload\ncomes close to this in a single request.\n\nLet me know if you need more info or a reproducer.\n\nThanks,\nAkif\n\n\n fs/smb/server/smb2pdu.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)","diff":"diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c\nindex ee32e61b6d3c..012f0c3585a0 100644\n--- a/fs/smb/server/smb2pdu.c\n+++ b/fs/smb/server/smb2pdu.c\n@@ -7492,7 +7492,7 @@ int smb2_lock(struct ksmbd_work *work)\n \tlock_ele = req->locks;\n \n \tksmbd_debug(SMB, \"lock count is %d\\n\", lock_count);\n-\tif (!lock_count) {\n+\tif (!lock_count || lock_count > 64) {\n \t\terr = -EINVAL;\n \t\tgoto out2;\n \t}\n","prefixes":[]}