{"id":2223246,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2223246/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-cifs-client/patch/20260414191533.1467353-4-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":"<20260414191533.1467353-4-michael.bommarito@gmail.com>","list_archive_url":null,"date":"2026-04-14T19:15:33","name":"[3/3] 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/20260414191533.1467353-4-michael.bommarito@gmail.com/mbox/","series":[{"id":499887,"url":"http://patchwork.ozlabs.org/api/1.2/series/499887/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-cifs-client/list/?series=499887","date":"2026-04-14T19:15:31","name":"ksmbd: harden IPC response arithmetic and ACE walk","version":1,"mbox":"http://patchwork.ozlabs.org/series/499887/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2223246/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2223246/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <linux-cifs+bounces-10819-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=AWSEAA78;\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-10819-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=\"AWSEAA78\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=209.85.219.53","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 4fwDbS5N3Sz1y2d\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 15 Apr 2026 05:19:00 +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 027DF30570CC\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 14 Apr 2026 19:15:43 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id A93CA2248BE;\n\tTue, 14 Apr 2026 19:15:42 +0000 (UTC)","from mail-qv1-f53.google.com (mail-qv1-f53.google.com\n [209.85.219.53])\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 36E7328B7DA\n\tfor <linux-cifs@vger.kernel.org>; Tue, 14 Apr 2026 19:15:41 +0000 (UTC)","by mail-qv1-f53.google.com with SMTP id\n 6a1803df08f44-8a4b8c3a30bso68225466d6.3\n        for <linux-cifs@vger.kernel.org>;\n Tue, 14 Apr 2026 12:15:41 -0700 (PDT)","from server0 (c-68-48-65-54.hsd1.mi.comcast.net. [68.48.65.54])\n        by smtp.gmail.com with ESMTPSA id\n 6a1803df08f44-8aca478a70csm77229126d6.27.2026.04.14.12.15.38\n        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n        Tue, 14 Apr 2026 12:15:39 -0700 (PDT)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776194142; cv=none;\n b=jY5DiWGw3SOmZMK+vQbX8zYMwVgQnyHGPg3O7CMqSvHz3SDeh4QA53plamRyqHGWtUjP3AvxvlKqL2l0yy/fEu5KteXV47Bto8rDqQg1dDiiRwx5q4b3A2cLWznTdgpP+gsXQjxVCOABq4dZ3zIguGJs5JPu/D2RlbxDBBs90Ss=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776194142; c=relaxed/simple;\n\tbh=0V678CI/bTL105QQk2LrBJXTTCkcQ43Nj6FSGsr09bE=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=hlY+blTIt/JJGX4jhCl1ra6vrYV8axyDd4fjJfR9Na7M+4g+0aR/uhMQdI4bJI/mKFLVC45zobCIQMDtA3fG2MQJ7nhhYH84JShpUitV9F15rs9uaaqUo0TpV02tclwweWYaZwKzLGWyWvLb0EHWkr7/7gPMrslQ2Y/7nLqcrOc=","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=AWSEAA78; arc=none smtp.client-ip=209.85.219.53","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=gmail.com; s=20251104; t=1776194140; x=1776798940;\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=AgctrOw+fTa9HS4kEjyzcX1BTeKi0lvTfjC5zn/MPTk=;\n        b=AWSEAA78E2dCwd1o8hO9Bo4k1B4oIc8Prs8JJWJb/K/mniBK91sPSoijbdL4n2WQJ+\n         r3K2kRTOF4/CDgJfPNqssh+2D1ESD2jy0ldN2Knp7fD5kBwYLddtYGLd7yT8SUo+aLXr\n         yDjQr8SfvI7m/zHLUr0GkBjtltihdVl4bBLCnHX/Lpm7RYbFh6KRdkHLbWHxLwVJGEFl\n         nGnlJFBF7g8BlUceLvKco1to8Cad1uN9wa4zh1cWdj1WHwGn5321p/BZB5NauMF3Z4Fv\n         dQL48ZiLpMCWAY+Al3iPIWoBssVquHmogFve/0Bk/KbjLoekyY36jkKTeipREqV18Zfc\n         F21A==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20251104; t=1776194140; x=1776798940;\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=AgctrOw+fTa9HS4kEjyzcX1BTeKi0lvTfjC5zn/MPTk=;\n        b=eG/40mlrzwyLFVJ6jX3APvp9DMX3O7uYoMkrliFMZsrhO93InDIqV9qGT6WdugiPiz\n         fYtn0oTU/XqAAxvymcdtHiCMTLF2J24/Qy+ljemWdecF3L0XDZDUMbvLs4geAHfTdzSe\n         AkMq+VpG4ZXqGN895GKk3TlYgILziqNwCm2M5b+OnMqNdScz11IfP8J1imPQxtSA6H1/\n         9+LONTKE7eucNZ674qya3YxsbDYN+czULwy8m8LtzA58llBOBfajzCR3hwusmcX8a/ky\n         F+afzAsCHRf9NnTsO4xVa+YTnrC41GVHtNRWHjasLrInKhgKsUef0kYBzXwHIVz2aPsp\n         Cpqg==","X-Gm-Message-State":"AOJu0Yw5RKgjs4YkZc85croDProLBpDO1K+ztpSjjZWH7h5yhy1XE6y9\n\t0VxSEdiLho93+ic3RWZbWUmIigDFeAxQpypkxz0L18KxS3U8ffN2CS+HKY7P04BD","X-Gm-Gg":"AeBDiesV8wFhqHK5L/tcRFExt41rgS/2LxIyJCLKHcQQlAP5od/ytbfINpGQj0i/wXd\n\tiuJEXUIC+wkZ/YKCSZwdzLvW9HqdrfKoTJBZlv3YSQno6cauycGVFqCxNvrGs84Vxlc7XvRggQs\n\t82W0QZJDhLIBGdWw1wwpiUZD7y4/Zvcvn47cbAcDsYTCgm0FHdl6eEs9qyzLviDM5TXKOm/MlWl\n\tZfZZVTT+YdbxXIFFwwesznt7WXCWxtUEvTVcEqsBPd+TOXXrXcFnUvCurPFPBZEHTt8CxlRA5LF\n\tq5GxSO0D8FaAgk9Fz4GEy7/Cti7GOx/ni21ph3ic7o/JSzo0Uz+lf/xHrF452yMIzQn+PWjIX0G\n\ts1qZnGMeCAsjb6M4F8b5ufVWIZdkR5O11FRU2G1I3d8I6rMqsro2sOs5QRDy1Dp8ulIeJOlKzV9\n\tFEMb1/MxoaLiM1UNNLKjGXippN4WkIjpFXyQZ3p9sOi9NH4L9ev1dw+JMluWtbgPkSknldxo2ql\n\tn/zOP/iPB6f7PrIzSeo/vXCJPZkVRY=","X-Received":"by 2002:a05:6214:4c8f:b0:8a6:1545:41ae with SMTP id\n 6a1803df08f44-8ac860ef7b0mr284828526d6.15.1776194139885;\n        Tue, 14 Apr 2026 12:15:39 -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 3/3] ksmbd: require minimum ACE size in smb_check_perm_dacl()","Date":"Tue, 14 Apr 2026 15:15:33 -0400","Message-ID":"<20260414191533.1467353-4-michael.bommarito@gmail.com>","X-Mailer":"git-send-email 2.53.0","In-Reply-To":"<20260414191533.1467353-1-michael.bommarito@gmail.com>","References":"<20260414191533.1467353-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\nfs/smb/server/smbacl.c | 17 +++++++++++++----\n1 file changed, 13 insertions(+), 4 deletions(-)\n\n--\n2.53.0","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":["3/3"]}