{"id":2224703,"url":"http://patchwork.ozlabs.org/api/patches/2224703/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-cifs-client/patch/20260417193317.315698-1-tristan@talencesecurity.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":"<20260417193317.315698-1-tristan@talencesecurity.com>","list_archive_url":null,"date":"2026-04-17T19:33:17","name":"[v2] ksmbd: fix out-of-bounds write in smb2_get_ea() EA alignment","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"62bcdf4a5c9a4e287de0100d527313a75170b11b","submitter":{"id":93179,"url":"http://patchwork.ozlabs.org/api/people/93179/?format=json","name":"Tristan Madani","email":"tristmd@gmail.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-cifs-client/patch/20260417193317.315698-1-tristan@talencesecurity.com/mbox/","series":[{"id":500395,"url":"http://patchwork.ozlabs.org/api/series/500395/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-cifs-client/list/?series=500395","date":"2026-04-17T19:33:17","name":"[v2] ksmbd: fix out-of-bounds write in smb2_get_ea() EA alignment","version":2,"mbox":"http://patchwork.ozlabs.org/series/500395/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2224703/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2224703/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <linux-cifs+bounces-10895-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=Zfwpzdvd;\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-10895-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=\"Zfwpzdvd\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=209.85.221.47","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 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fy4mx5Lb0z1yCv\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 18 Apr 2026 05:33:37 +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 B145A3011C65\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 17 Apr 2026 19:33:26 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 0E40832E126;\n\tFri, 17 Apr 2026 19:33:25 +0000 (UTC)","from mail-wr1-f47.google.com (mail-wr1-f47.google.com\n [209.85.221.47])\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 B1DFF389470\n\tfor <linux-cifs@vger.kernel.org>; Fri, 17 Apr 2026 19:33:21 +0000 (UTC)","by mail-wr1-f47.google.com with SMTP id\n ffacd0b85a97d-43cfd1f9fd1so660512f8f.3\n        for <linux-cifs@vger.kernel.org>;\n Fri, 17 Apr 2026 12:33:20 -0700 (PDT)","from debian.. ([2001:41d0:303:db6b::])\n        by smtp.gmail.com with ESMTPSA id\n ffacd0b85a97d-43fe4e4daf2sm6341754f8f.33.2026.04.17.12.33.18\n        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n        Fri, 17 Apr 2026 12:33:18 -0700 (PDT)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776454404; cv=none;\n b=EoJcN7I5q71ISy5hFg1vPkLH0WGKLKi4r8exNWk9TcQQg3jERg7TE43HQFagovTIyHNkHKsxI90rZKON0zyShS/WLBXt2Hk2BotsCM2PofqgmBwG4og+ChhT2Ri1Shqr5LULtrlaA6vbadB8R5VhKdNvrCcGNI2vC5MFL+iURcI=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776454404; c=relaxed/simple;\n\tbh=wSouMAxbC4qBTG56Li1QJbGu7+b7Rn1l0WqH5ApVDw4=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=sOd/90WQ5iB06ftpB6KE0KDD0dF81h+/w7cxNcJCJl55WqdwQ2FtRK7rmwwFZc/JLgXhC9q9wWIdP/BXCEX9scnlYIqh39fsj871QADgmD15Mmpog3w6m07ZoK1ARyxJ96inrXYiZyyi9maumfwsdpRJUFufaUEjQguI922spxg=","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=Zfwpzdvd; arc=none smtp.client-ip=209.85.221.47","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=gmail.com; s=20251104; t=1776454399; x=1777059199;\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=kQ0cthg0w4P6S7KugYGvtLaxhgxAoG60Ed2oJXFQlJE=;\n        b=Zfwpzdvdgew6YVKkzjQU10DXoYj8onpvnXmHUf9zsPbNCD59dL0gSkbUO1EZA6PnKo\n         WiZe864Tz9ApWMdKvIIXx1UniqinnJPZWN/rNWm9jm4CpQB7Tpx+KQvfTNoykE2Bm00H\n         1icNTvekACYfOrozraQSvZ6RcBRjQHNFqcbpN1GoklQr05pfG2WE0nmjpRjOJwr/4JJz\n         v9Jgr1JK/BlH6jeBxPcpCgy2VOWGlJ31e9vxKxnQbXzG32i8GwJdojA/LOEfQGQZwgTh\n         uh8BvvFU4IpFvfP6Dl8f2skhZMF8bess0QIfAu4CVF5PJfoth/zZ9WTBqZ0F8nPS6mkl\n         NLfQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20251104; t=1776454399; x=1777059199;\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=kQ0cthg0w4P6S7KugYGvtLaxhgxAoG60Ed2oJXFQlJE=;\n        b=Faw5cZCOpoLlK6ajmIEIZl+ZSQ8QO4wbmqnH203xn2DM0HhMVy6lD8QAM9PpbOjaav\n         d150prMH1EBINJ9k1r5W6mPyLcRCgAqG7zVjTtU1Z5Zd9cWmZVJCABf0fM5gckFfq/RP\n         xsVQUhWSIU4TzdLb2yUhG0Hq06SXgrXC6eL1zEs89gQP5RvySkJJuAWb9M/PMTSkhikZ\n         IFhrSxLB9kOmEmMU/lp3Isxr14uNpcWsTY1aVmOSQGCvxUGdZu0JInoKVwH1gnfbb9f/\n         RbQSeQUGIZMME4FRYN2IszKupFUCi14MixKbzwDRuPQR4QYNWcqpZ0giqalzLohPcayG\n         1ssw==","X-Forwarded-Encrypted":"i=1;\n AFNElJ+Jtapv+1M7zR3kegZxpeM2hok9jfzcudTxOkScmoQdZOyiOm0FRjH2jmWMdT1lcchb0CYicrQkUwvF@vger.kernel.org","X-Gm-Message-State":"AOJu0Yyk93e4mQH4O6rMnax7qHn9JM0JVPTqzay1mIGBiFFhzTfSI+3n\n\tsBBN5pe8HJmTxJ1xUUM4rMnKL2SYXmMTtvpA+JXrI2ZqG2nIqyKEY5oJm4Xbc+Y=","X-Gm-Gg":"AeBDiesiEAOeDNaguDYn+1Pls0Y/Jzsqg5r0hISpsRMCfncSidTATm5ekxSlhbDMKJX\n\thF2tFY1JaotxCgiSlVQtMo7edN9EHudREBnhb1RI8cFLG+WRbpZ10n3zLiall05OwCIxkdcBr54\n\tsGJit/Wcibpyx84nvKO2MxFxiVfos0GdIWzebXyXCcQ7G6HvGYwoEVgSp/LK+EK8FETrqOPtrRP\n\t4ExZcVmVoiODT1RaagzVh4ybMOsmCcPow03FFVWQnKZhXqT8aQm5sKXDREZWVwTnL25MunZqRiR\n\tyQ2ux4IyvaktxGbFDp3VpSl9ezh7mMZU7VJTH+z87NeSBjK19B8UejWl/9ZDjkulLDeA22hRQci\n\tlTezhzQTwpjVC3ymBeCLmmTPH6xWEWkTM3BMZMionCb1YZQqghBTJcP4nFJaW3fiBvcUm3GibYy\n\tTxcElwLbfaJgpIggc9","X-Received":"by 2002:a05:6000:1446:b0:43d:73d4:b2f with SMTP id\n ffacd0b85a97d-43fe3e11634mr6425771f8f.39.1776454399246;\n        Fri, 17 Apr 2026 12:33:19 -0700 (PDT)","From":"Tristan Madani <tristmd@gmail.com>","X-Google-Original-From":"Tristan Madani <tristan@talencesecurity.com>","To":"Namjae Jeon <linkinjeon@kernel.org>,\n\tSteve French <smfrench@gmail.com>","Cc":"Sergey Senozhatsky <senozhatsky@chromium.org>,\n\tTom Talpey <tom@talpey.com>,\n\tlinux-cifs@vger.kernel.org,\n\tstable@vger.kernel.org,\n\tTristan Madani <tristan@talencesecurity.com>","Subject":"[PATCH v2] ksmbd: fix out-of-bounds write in smb2_get_ea() EA\n alignment","Date":"Fri, 17 Apr 2026 19:33:17 +0000","Message-ID":"<20260417193317.315698-1-tristan@talencesecurity.com>","X-Mailer":"git-send-email 2.47.3","In-Reply-To":"<20260417192036.268452-1-tristan@talencesecurity.com>","References":"<20260417192036.268452-1-tristan@talencesecurity.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":"smb2_get_ea() applies 4-byte alignment padding via memset() after\nwriting each EA entry. The bounds check on buf_free_len is performed\nbefore the value memcpy, but the alignment memset fires unconditionally\nafterward with no check on remaining space.\n\nWhen the EA value exactly fills the remaining buffer (buf_free_len == 0\nafter value subtraction), the alignment memset writes 1-3 NUL bytes\npast the buf_free_len boundary. In compound requests where the response\nbuffer is shared across commands, the first command (e.g., READ) can\nconsume most of the buffer, leaving a tight remainder for the QUERY_INFO\nEA response. The alignment memset then overwrites past the physical\nkvmalloc allocation into adjacent kernel heap memory.\n\nAdd a bounds check before the alignment memset to ensure buf_free_len\ncan accommodate the padding bytes.\n\nThis is the same bug pattern fixed by commit beef2634f81f (\"ksmbd: fix\npotencial OOB in get_file_all_info() for compound requests\") and\ncommit fda9522ed6af (\"ksmbd: fix OOB write in QUERY_INFO for compound\nrequests\"), both of which added bounds checks before unconditional\nwrites in QUERY_INFO response handlers.\n\nCc: stable@vger.kernel.org\nFixes: e2b76ab8b5c9 (\"ksmbd: add support for read compound\")\nSigned-off-by: Tristan Madani <tristan@talencesecurity.com>\n---\n fs/smb/server/smb2pdu.c | 2 ++\n 1 file changed, 2 insertions(+)","diff":"diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c\nindex ee32e61b6d3c7..407173d2175af 100644\n--- a/fs/smb/server/smb2pdu.c\n+++ b/fs/smb/server/smb2pdu.c\n@@ -4821,6 +4821,8 @@ static int smb2_get_ea(struct ksmbd_work *work, struct ksmbd_file *fp,\n \t\t/* align next xattr entry at 4 byte bundary */\n \t\talignment_bytes = ((next_offset + 3) & ~3) - next_offset;\n \t\tif (alignment_bytes) {\n+\t\t\tif (buf_free_len < alignment_bytes)\n+\t\t\t\tbreak;\n \t\t\tmemset(ptr, '\\0', alignment_bytes);\n \t\t\tptr += alignment_bytes;\n \t\t\tnext_offset += alignment_bytes;\n","prefixes":["v2"]}