{"id":2223493,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2223493/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-cifs-client/patch/20260415112501.116426-3-michael.bommarito@gmail.com/","project":{"id":12,"url":"http://patchwork.ozlabs.org/api/1.2/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":"<20260415112501.116426-3-michael.bommarito@gmail.com>","list_archive_url":null,"date":"2026-04-15T11:25:01","name":"[v2,2/2] ksmbd: require minimum ACE size in smb_check_perm_dacl()","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"1a812291c2cf14153c9c673437b1a5c83e8f998d","submitter":{"id":93078,"url":"http://patchwork.ozlabs.org/api/1.2/people/93078/?format=json","name":"Michael Bommarito","email":"michael.bommarito@gmail.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-cifs-client/patch/20260415112501.116426-3-michael.bommarito@gmail.com/mbox/","series":[{"id":499975,"url":"http://patchwork.ozlabs.org/api/1.2/series/499975/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-cifs-client/list/?series=499975","date":"2026-04-15T11:24:59","name":"ksmbd: harden ipc_validate_msg() and smb_check_perm_dacl()","version":2,"mbox":"http://patchwork.ozlabs.org/series/499975/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2223493/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2223493/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <linux-cifs+bounces-10835-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=diaIpdD7;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org;\n envelope-from=linux-cifs+bounces-10835-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=\"diaIpdD7\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=209.85.160.169","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 sea.lore.kernel.org (sea.lore.kernel.org\n [IPv6:2600:3c0a:e001:db::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fwf8w11vwz1yDF\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 15 Apr 2026 21:30:56 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 165B630E58C0\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 15 Apr 2026 11:25:24 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id DF0E83793C1;\n\tWed, 15 Apr 2026 11:25:23 +0000 (UTC)","from mail-qt1-f169.google.com (mail-qt1-f169.google.com\n [209.85.160.169])\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 7682F2D1931\n\tfor <linux-cifs@vger.kernel.org>; Wed, 15 Apr 2026 11:25:22 +0000 (UTC)","by mail-qt1-f169.google.com with SMTP id\n d75a77b69052e-50d876329bbso69217051cf.2\n        for <linux-cifs@vger.kernel.org>;\n Wed, 15 Apr 2026 04:25:22 -0700 (PDT)","from server0.tail6e7dd.ts.net (c-68-48-65-54.hsd1.mi.comcast.net.\n [68.48.65.54])\n        by smtp.gmail.com with ESMTPSA id\n d75a77b69052e-50e1af9dc5fsm10621191cf.16.2026.04.15.04.25.20\n        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n        Wed, 15 Apr 2026 04:25:20 -0700 (PDT)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776252323; cv=none;\n b=pamChB/ALMi2G+VqmPBIAN5dXK/PnTJt6EhZuDPfxfxAnv0FpvuL3OpXSsnQKFIy2BHUdag0D/RMjcMZlj50q3qX/pNJAN8tTaQFY5CXkX6NWtj9lO53Ua2tK9uimLhVmuxzC3iiZfDi6IeT/N6in7dhw5ebgeLtU7ggEzUrnKo=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776252323; c=relaxed/simple;\n\tbh=U5CI1dkHZFucrf1FtoI0iIBoTcbsjPIrp1ozHF2ILDs=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=fEHFgm/57rf+QxulE2hO1SvPYI8cwhe3DW+5ujnu8b1uOVFcmpDQCE0k58n3TJs4qrwl0IkevABk0H8+Db0SIL7t1Od2VcbtbPHV+8k69EHzvC2Tq6VQmF1DXUooMtn4Xd6IzpO6dwH3ZkA1+/I9+y4JOJKugcyKA62qXEbdHV4=","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=diaIpdD7; arc=none smtp.client-ip=209.85.160.169","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=gmail.com; s=20251104; t=1776252321; x=1776857121;\n darn=vger.kernel.org;\n        h=content-transfer-encoding:mime-version:references:in-reply-to\n         :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n         :message-id:reply-to;\n        bh=PJ7blFUvJD3xjZodcquJvVuRqv0FWfvmqE9ECTkmuRY=;\n        b=diaIpdD7PJZCVVUdkz47Bvbnl/9i6EqWNx4TEdt1M21S+sElexqNmmpSlHHbGC9212\n         4rsRFEDGrsj8h1XLlighPrI0uG+0MMZ6W1wLpe9+ZBnp/nM2IaQjO4bmJFvXV+QA/BEm\n         K1+mZooyELk7t6nHyUp7jHBB9bw9YrphScFzrdyNU2SaEVAIi5lNWeAEv9iQSAa+jEeQ\n         kAsTxmSstf63eWc9Adf4twsFHUjI2ok+aPlnF2Fq7lz9nBJkfmC6ORd9KVn58iK4BTtf\n         e5PFZ/Ci51IZUorchkyyePUeI4PAqSka7dTLHlA5yFrNfK4+3R+83B4FwW578uih/usU\n         Da4A==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20251104; t=1776252321; x=1776857121;\n        h=content-transfer-encoding:mime-version:references:in-reply-to\n         :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n         :to:cc:subject:date:message-id:reply-to;\n        bh=PJ7blFUvJD3xjZodcquJvVuRqv0FWfvmqE9ECTkmuRY=;\n        b=h9tQQL9DhpLlJ+/vrP0eYhjfwFIVj0/Vqwjjc7RQqR5m09tQzmBHM+bLszIkAzoWCM\n         M9embEx8+j1FRzO4yxrcbR97ug2qPoRnnH6EA76SSNwQuG58NbwUMZYBAr1HnFfRYX4d\n         JsyxX9UmxglHaBVcdNKZGSwi1xIR7V1xeybgVBq9JLUlWomTjFog0JS/JG0jusOxSb17\n         kZkt8Yak07ImHM9zJubJjc/i8FRgrXQPaMDqDTpt1SugDAGXgo4UZ8hZ0HfJjFQanDvG\n         QZ7tDLXvFFPxAefK8JK8mS8yEJ4be0qxYS7A9G467qphGza7ZaR2kpk2ONHw3SPWdWT+\n         RFJw==","X-Gm-Message-State":"AOJu0YwAyHvL0PmUP6r0su8jMzC9DW0HlOo1P9FtFlt18+wbAa3RcaCY\n\twLo7MVAZkelDqkVULsnKGco122dkUa4AQqjEcYhqe1wfoXEguAgSmx2MeoP55Q==","X-Gm-Gg":"AeBDievcKncocaFLw2ZjQCnfPhxQ++B+rEaQAgMUdtZJHE4Zo/YHV0Gy5wJx/5LPq5M\n\tTdrZwPRB242W4EfUsvFj6jlChxBbdRc9D2aUnETFxHD3ca8QULFdli8RKXkJEJCvAfvYTwuNL1B\n\tkr+xqUwwsJwEcPhfdZjQqxJJ/KSuk9sEv31YY/BwLMSxTfn+/TU7HE16jFe7L6i8+xxxlwXrl4K\n\tIL9TGQWWeybDGNmfH2CpR481Kzbu6GhJA4RRP29A/nNrLYObW1KBb8MoJCYW1+UL5qnRcEMkSJ1\n\trwufZWGJF3ZVRmbAqXnTCUyUmKgN/piahQCuUhhjua19x8BRPjKo5Vqr8pR5gdHK1EXOzpDWdLo\n\tLXBRJF/YkroKEFgNonxqEGNe5V/LcJ87r11+efEDhguBxaouTqomncJC0NBPEWYdwA7hai7YVur\n\tOKOBzyLkQa+fYU1NLfDIh+xifoSBkuFhGe4Fv84GX0g/8y87yxKg12E3YYPuiKLEHvWlsy04XRw\n\tZTnt6L2bJ27CktkYIgLbi57HRVrnO7Ap7784NGc00CKI1xpUOhL1Q==","X-Received":"by 2002:a05:622a:a945:10b0:50b:5336:1d20 with SMTP id\n d75a77b69052e-50dd5beac96mr247328681cf.53.1776252321175;\n        Wed, 15 Apr 2026 04:25:21 -0700 (PDT)","From":"Michael Bommarito <michael.bommarito@gmail.com>","To":"linux-cifs@vger.kernel.org,\n\tNamjae Jeon <linkinjeon@kernel.org>,\n\tSteve French <smfrench@gmail.com>","Cc":"Sergey Senozhatsky <senozhatsky@chromium.org>,\n\tTom Talpey <tom@talpey.com>,\n\tstable@vger.kernel.org","Subject":"[PATCH v2 2/2] ksmbd: require minimum ACE size in\n smb_check_perm_dacl()","Date":"Wed, 15 Apr 2026 07:25:01 -0400","Message-ID":"<20260415112501.116426-3-michael.bommarito@gmail.com>","X-Mailer":"git-send-email 2.53.0","In-Reply-To":"<20260415112501.116426-1-michael.bommarito@gmail.com>","References":"<20260414191533.1467353-1-michael.bommarito@gmail.com>\n <CAKYAXd9EBFBcy9bJ3=sJiYVYHAYjKYqOqD53UCJ8zWKXF0sAeg@mail.gmail.com>\n <CAKYAXd8B78Gde_7+Ph0cSL998k4qqs_okB0jky0m5h8i25_AGQ@mail.gmail.com>\n <20260415112501.116426-1-michael.bommarito@gmail.com>","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":"Both ACE-walk loops in smb_check_perm_dacl() only guard against an\nunder-sized remaining buffer, not against an ACE whose declared\n`ace->size` is smaller than the struct it claims to describe:\n\n  if (offsetof(struct smb_ace, access_req) > aces_size)\n      break;\n  ace_size = le16_to_cpu(ace->size);\n  if (ace_size > aces_size)\n      break;\n\nThe first check only requires the 4-byte ACE header to be in bounds;\nit does not require access_req (4 bytes at offset 4) to be readable.\nAn attacker who has set a crafted DACL on a file they own can declare\nace->size == 4 with aces_size == 4, pass both checks, and then\n\n  granted |= le32_to_cpu(ace->access_req);               /* upper loop */\n  compare_sids(&sid, &ace->sid);                         /* lower loop */\n\nreads access_req at offset 4 (OOB by up to 4 bytes) and ace->sid at\noffset 8 (OOB by up to CIFS_SID_BASE_SIZE + SID_MAX_SUB_AUTHORITIES\n* 4 bytes).\n\nTighten both loops to require\n\n  ace_size >= offsetof(struct smb_ace, sid) + CIFS_SID_BASE_SIZE\n\nwhich is the smallest valid on-wire ACE layout (4-byte header +\n4-byte access_req + 8-byte sid base with zero sub-auths).  Also\nreject ACEs whose sid.num_subauth exceeds SID_MAX_SUB_AUTHORITIES\nbefore letting compare_sids() dereference sub_auth[] entries.\n\nparse_sec_desc() already enforces an equivalent check (lines 441-448);\nsmb_check_perm_dacl() simply grew weaker validation over time.\n\nReachability: authenticated SMB client with permission to set an ACL\non a file.  On a subsequent CREATE against that file, the kernel\nwalks the stored DACL via smb_check_perm_dacl() and triggers the\nOOB read.  Not pre-auth, and the OOB read is not reflected to the\nattacker, but KASAN reports and kernel state corruption are\npossible.\n\nFixes: e2f34481b24d (\"cifsd: add server-side procedures for SMB3\")\nCc: stable@vger.kernel.org\nAssisted-by: Claude:claude-opus-4-6\nAssisted-by: Codex:gpt-5-4\nSigned-off-by: Michael Bommarito <michael.bommarito@gmail.com>\n---\n fs/smb/server/smbacl.c | 17 +++++++++++++----\n 1 file changed, 13 insertions(+), 4 deletions(-)","diff":"diff --git a/fs/smb/server/smbacl.c b/fs/smb/server/smbacl.c\nindex c30d01877c41..d5943256c071 100644\n--- a/fs/smb/server/smbacl.c\n+++ b/fs/smb/server/smbacl.c\n@@ -1341,10 +1341,13 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path,\n \t\tace = (struct smb_ace *)((char *)pdacl + sizeof(struct smb_acl));\n \t\taces_size = acl_size - sizeof(struct smb_acl);\n \t\tfor (i = 0; i < le16_to_cpu(pdacl->num_aces); i++) {\n-\t\t\tif (offsetof(struct smb_ace, access_req) > aces_size)\n+\t\t\tif (offsetof(struct smb_ace, sid) +\n+\t\t\t    CIFS_SID_BASE_SIZE > aces_size)\n \t\t\t\tbreak;\n \t\t\tace_size = le16_to_cpu(ace->size);\n-\t\t\tif (ace_size > aces_size)\n+\t\t\tif (ace_size > aces_size ||\n+\t\t\t    ace_size < offsetof(struct smb_ace, sid) +\n+\t\t\t\t       CIFS_SID_BASE_SIZE)\n \t\t\t\tbreak;\n \t\t\taces_size -= ace_size;\n \t\t\tgranted |= le32_to_cpu(ace->access_req);\n@@ -1359,13 +1362,19 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path,\n \tace = (struct smb_ace *)((char *)pdacl + sizeof(struct smb_acl));\n \taces_size = acl_size - sizeof(struct smb_acl);\n \tfor (i = 0; i < le16_to_cpu(pdacl->num_aces); i++) {\n-\t\tif (offsetof(struct smb_ace, access_req) > aces_size)\n+\t\tif (offsetof(struct smb_ace, sid) +\n+\t\t    CIFS_SID_BASE_SIZE > aces_size)\n \t\t\tbreak;\n \t\tace_size = le16_to_cpu(ace->size);\n-\t\tif (ace_size > aces_size)\n+\t\tif (ace_size > aces_size ||\n+\t\t    ace_size < offsetof(struct smb_ace, sid) +\n+\t\t\t       CIFS_SID_BASE_SIZE)\n \t\t\tbreak;\n \t\taces_size -= ace_size;\n \n+\t\tif (ace->sid.num_subauth > SID_MAX_SUB_AUTHORITIES)\n+\t\t\tbreak;\n+\n \t\tif (!compare_sids(&sid, &ace->sid) ||\n \t\t    !compare_sids(&sid_unix_NFS_mode, &ace->sid)) {\n \t\t\tfound = 1;\n","prefixes":["v2","2/2"]}