{"id":2224700,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2224700/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-cifs-client/patch/20260417192036.268452-1-tristan@talencesecurity.com/","project":{"id":12,"url":"http://patchwork.ozlabs.org/api/1.1/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":""},"msgid":"<20260417192036.268452-1-tristan@talencesecurity.com>","date":"2026-04-17T19:20:36","name":"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/1.1/people/93179/?format=json","name":"Tristan Madani","email":"tristmd@gmail.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-cifs-client/patch/20260417192036.268452-1-tristan@talencesecurity.com/mbox/","series":[{"id":500392,"url":"http://patchwork.ozlabs.org/api/1.1/series/500392/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-cifs-client/list/?series=500392","date":"2026-04-17T19:20:36","name":"ksmbd: fix out-of-bounds write in smb2_get_ea() EA alignment","version":1,"mbox":"http://patchwork.ozlabs.org/series/500392/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2224700/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2224700/checks/","tags":{},"headers":{"Return-Path":"\n <linux-cifs+bounces-10894-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=NaY4Q3TY;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.234.253.10; helo=sea.lore.kernel.org;\n envelope-from=linux-cifs+bounces-10894-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=\"NaY4Q3TY\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=209.85.128.46","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 [172.234.253.10])\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 4fy4Zp75dJz1yDF\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 18 Apr 2026 05:24:50 +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 327F3309EFC7\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 17 Apr 2026 19:20:41 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 97A2E221FC6;\n\tFri, 17 Apr 2026 19:20:40 +0000 (UTC)","from mail-wm1-f46.google.com (mail-wm1-f46.google.com\n [209.85.128.46])\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 50E2E34E765\n\tfor <linux-cifs@vger.kernel.org>; Fri, 17 Apr 2026 19:20:39 +0000 (UTC)","by mail-wm1-f46.google.com with SMTP id\n 5b1f17b1804b1-483487335c2so9884875e9.2\n        for <linux-cifs@vger.kernel.org>;\n Fri, 17 Apr 2026 12:20:39 -0700 (PDT)","from debian.. ([2001:41d0:303:db6b::])\n        by smtp.gmail.com with ESMTPSA id\n 5b1f17b1804b1-488fc1393f5sm61147675e9.9.2026.04.17.12.20.36\n        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n        Fri, 17 Apr 2026 12:20:37 -0700 (PDT)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776453640; cv=none;\n b=pzFOgS9uQJhpupaMVZmuR6uf8IlH/E8I8C6+xjNu6NDxKiaaukCdkpnSllDfn1B8OwC1/lHzOVtQ8Aiikl4jGOQJsJ5cmY5I+zjiTimWQcKuW/DXt/OXndqKVZAx0IuJe1YNlC2xcZV44i//s9oAgYgu4KBSVNhREnaMgPZrkMk=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776453640; c=relaxed/simple;\n\tbh=D5kZnVaQ/vTrsXOqYWEl96J7QGlRpg6INGoI6xYfsZU=;\n\th=From:To:Cc:Subject:Date:Message-ID:MIME-Version;\n b=dawRzjZh8rgJmOGeVRDusEJtrdZtNuRJkcVgw/9yo7ki3rEaK9WQE8k20uUbjCzAwWHehg8dw9VFUVk2CQHg3L15fIusIKFa86fUdzWNhDZ+GtWl5tpwX1/G44dLE+5HDIsPGXA7w06+SYmNWwNyYnVvmhza5pDBpdT3AO6TCKQ=","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=NaY4Q3TY; arc=none smtp.client-ip=209.85.128.46","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=gmail.com; s=20251104; t=1776453638; x=1777058438;\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=qejIuAQOnYrB0ta1vlKG9Tsn1R8vB7zz59IN9WHpiB4=;\n        b=NaY4Q3TY0Ni6uB6vXusebzSWOBOlo27f34yAICcMhw0szVdYrak1xSJ01IYZQBu7Uv\n         7umFB+tCTz1Re2qQDUzY4rhvgaclwpz8QNHeaGNrxj+Ts5DIQl062JQCDu9Eiy6jnxGb\n         d8lOHUUnZE0EehsQjE9JNcq189zx/z0rV6ijvTlCUYwCyDo8MEfe3XatSUQfJbTmz5T7\n         Uuew08B8W6acFracgTG2afs6cvp9TU0P11nyPMpT0pDwaMhw1ivjY4XUQg7GJaly9Sa3\n         UrFds4oYcyA9wSVanQO4ZRQsWmdNdRMnEVOK5aF2PIEuGsi9YPwv41KwmwzCcSMxpRBO\n         RJhg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20251104; t=1776453638; x=1777058438;\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=qejIuAQOnYrB0ta1vlKG9Tsn1R8vB7zz59IN9WHpiB4=;\n        b=UMXP5rVmtiLHhXAUZd9MNbIPWlPS1bTonNp/IqQcHzQzn9wiPUcTfCUjCDsvTcH4gi\n         YInuhXpneS5a4XY2iIROttULTnMo/lVfQyRGRdlFF7oRAfu1RzmUJiBxq16i1NAjAgdk\n         HywN2LbCJLNjkcXleh+eitzdx6Wb0vELFSPuGgX6IsLernkQZMvFXUNCyZukBKJzAn8W\n         M/rBcLYDS4tXLXdJU+q3kxAkTh+T+eJW2pYHZIzkD5hFxJGqdkoWOsIXp1uK3CsEGWIK\n         EcE5/SPSlnXqae6PgyxjhI34lEk6KxgWC16Uzcp4t26fBhr4KOlwrz5SnCBgSt8YabJT\n         28gw==","X-Forwarded-Encrypted":"i=1;\n AFNElJ+/dYivaKLLTgZjdOIoGBoXg+HbJmyEkWpKrF420ohj0ATM515xeTuTvDmVL32DM+cyEDaQxhwYLJ0j@vger.kernel.org","X-Gm-Message-State":"AOJu0Yzk5mNQJ9tZ1Mqnc4T14mFbtagw5f5GNbHWEDbSqAldejcfc3Q/\n\t5V8MSoUQ2YFE52mybqTJlHjIW8o7gIND5sJXjkTX3uAZXTIp68b6XD5LBcWJRrc=","X-Gm-Gg":"AeBDievEmA360qzVutpIIBFQAxpfn/EPmZLw/Q3c1MhDtgXYOvlHcYAqQf/PZjrCDo8\n\t8i+ilIY+w+cKYDoeujV4LNZbNHzQ3vqTg/J1UCTfjtPxJbIFPAz0+t1BCwTtCbV/5J32NQ6irk6\n\tvuuSdSSDTo9ywjV2dxrE6F+UQsSWnAI8h9K2LEezJ1w6zYuotax4TgJIHTte3AmxzwvTnZO4C+1\n\tl+ocwU8VbZIcwN59TUlR9UOhO4pOgW0ftdgN/aKYoyqgLMenaMGYXuNZhGGW8b0oCow3WkJZss/\n\t+JhSPZFhNILlqr9XbEj4fOv4J7rTnTNnUylrUwhNCW982C5b6r76PnrWCzcKbQYn39xBJt2Gfa2\n\tLejIqVHuyYgmY9ztSKRDZcLmUl+DrzbXTQyUo9ybZe3pcjUctyLylnNzDgXNim9Kwsi9D/A3Omr\n\tsdunhDN3As8QRgHAgwUtry+xx0S0Q=","X-Received":"by 2002:a05:600c:8706:b0:488:d6eb:e635 with SMTP id\n 5b1f17b1804b1-488fb753abdmr66604615e9.12.1776453637660;\n        Fri, 17 Apr 2026 12:20:37 -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] ksmbd: fix out-of-bounds write in smb2_get_ea() EA alignment","Date":"Fri, 17 Apr 2026 19:20:36 +0000","Message-ID":"<20260417192036.268452-1-tristan@talencesecurity.com>","X-Mailer":"git-send-email 2.47.3","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 for buf_free_len is performed\nbefore the value memcpy, but the alignment memset fires unconditionally\nafterward with no check. When the EA value exactly fills the remaining\nbuffer space (buf_free_len == 0 after value subtraction), the alignment\nmemset writes 1-3 NUL bytes past the buf_free_len boundary.\n\nAdd a bounds check before the alignment memset to prevent writing past\nthe authorized buffer space.\n\nThis is the same bug pattern as commit beef2634f81f (\"ksmbd: fix\nout-of-bounds write in get_file_all_info() for compound requests\")\nand commit fda9522ed6af (\"ksmbd: fix out-of-bounds write in\nksmbd_vfs_get_sd_xattr() for compound requests\"), both of which\nadded bounds checks before unconditional writes in QUERY_INFO\nresponse formatting.\n\nCc: stable@vger.kernel.org\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":[]}