{"id":2224944,"url":"http://patchwork.ozlabs.org/api/patches/2224944/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-cifs-client/patch/20260419233519.2777046-1-michael.bommarito@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":"<20260419233519.2777046-1-michael.bommarito@gmail.com>","list_archive_url":null,"date":"2026-04-19T23:35:19","name":"[v2] smb: client: fix OOB read in smb2_ioctl_query_info QUERY_INFO path","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"77a2e381fbdb7473e71ef0c505204379a447e257","submitter":{"id":93078,"url":"http://patchwork.ozlabs.org/api/people/93078/?format=json","name":"Michael Bommarito","email":"michael.bommarito@gmail.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-cifs-client/patch/20260419233519.2777046-1-michael.bommarito@gmail.com/mbox/","series":[{"id":500532,"url":"http://patchwork.ozlabs.org/api/series/500532/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-cifs-client/list/?series=500532","date":"2026-04-19T23:35:19","name":"[v2] smb: client: fix OOB read in smb2_ioctl_query_info QUERY_INFO path","version":2,"mbox":"http://patchwork.ozlabs.org/series/500532/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2224944/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2224944/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <linux-cifs+bounces-10918-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=ak8EB9YW;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c09:e001:a7::12fc:5321; helo=sto.lore.kernel.org;\n envelope-from=linux-cifs+bounces-10918-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=\"ak8EB9YW\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=209.85.160.172","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 sto.lore.kernel.org (sto.lore.kernel.org\n [IPv6:2600:3c09:e001:a7::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 4fzQ3n26Bqz1yHB\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 20 Apr 2026 09:36:05 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sto.lore.kernel.org (Postfix) with ESMTP id 26BA5300360A\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 19 Apr 2026 23:36:01 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id A98612C0303;\n\tSun, 19 Apr 2026 23:35:57 +0000 (UTC)","from mail-qt1-f172.google.com (mail-qt1-f172.google.com\n [209.85.160.172])\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 4D99C199D8\n\tfor <linux-cifs@vger.kernel.org>; Sun, 19 Apr 2026 23:35:56 +0000 (UTC)","by mail-qt1-f172.google.com with SMTP id\n d75a77b69052e-506a7bbe9d0so21337811cf.0\n        for <linux-cifs@vger.kernel.org>;\n Sun, 19 Apr 2026 16:35:56 -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 d75a77b69052e-50e3945ae5bsm70011581cf.23.2026.04.19.16.35.54\n        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n        Sun, 19 Apr 2026 16:35:54 -0700 (PDT)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776641757; cv=none;\n b=BrkBuo2tfyQVkeEIXndh4XcJcdiWCXJMqX/nSLBCcY/dDCBbmzu+bruMLcTuDi5OuVhMYpWT5MH5fyKJkzFzwJbnw1u/MNwYycAf2ScmYqfAej6rYnhW55VI45/ablRDop30VS1l3I1FR4NtP5dSzDNXcuGkyBd1ssEGKZW1+l0=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776641757; c=relaxed/simple;\n\tbh=n+/9oE8TaB93W1IqyEWeYZPZfGQ+zJkX0tDzr2hV0CE=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=BwB4kdMyBnff6rYKC5mIuZRbK9kR5OM4RdDzUE/Or42UXzwhhy7xJHHAUHdqlXEwFWqZQBND9xumU00d8hUqZ4o9dAkZb1gZAuj76CQraATHdjs+4Q0umKpLAcxcJHKVVg/rxEYgM5lwaLvsN9quXGGC3zRw1sT659rGewpHoUs=","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=ak8EB9YW; arc=none smtp.client-ip=209.85.160.172","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=gmail.com; s=20251104; t=1776641755; x=1777246555;\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=0vOx1KMOCIDqbwM807GVLF8N7abkefceoi6Jbuerw0w=;\n        b=ak8EB9YW6n10p8HH/GaaQWjn91f6vcyynGVLv1mESkHC7ar93gHnbtOGDlf6Dmp6Yj\n         b0jDDKCZy1s4QGQg9l590jRCMuRUJ3o1w9VemWH1gCb64JK/qAsAw4QBHRjArjrOO5tG\n         1KgX69s8iTYYm8iz/0GjKEEcU/P5747eMi9mQzL3Ms8v3EkrO2SRdAGChCP4TEhilm5x\n         2uJEKJbDuevErxfnvFk/TSDbvTA2BM0jvmwRFTGL1ioXgKsqVfGWqZsdTPQvZI0fpOOC\n         t0NJtMm8ssOB2XZZambyy8YsucY04Ldc5Mrz6z+VEAJWKVMpeu21K1Mm5oICxa+3+k2s\n         CepA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20251104; t=1776641755; x=1777246555;\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=0vOx1KMOCIDqbwM807GVLF8N7abkefceoi6Jbuerw0w=;\n        b=qDXbQ7Eb+w7YHmDjiRM2VtwMV/y9NYXH+BpHDm+LVi4JEMmEJ5XBQP/lL/Mtht609r\n         9qVymJZKztE5r/CNm6N1M6/kyWcEfRYj6XChDjtl5no4UpZZHr8cpRI7kZ6ltCi1TofU\n         McH5GjIoCyadn7fRIhASaWLs7HudAF2BAeK61871etnvF7fiQ380d74RftRuCLBof9xn\n         8F6AltdImrsl+MmFMU6XsNm4434SmEbm0VmxW0Bm1odBv3//dLdVoWdZAABj4hhqJH7N\n         7taXN+fNaGmE8sIoB41vRqfb/o3hSgaKAIxzpX/fFPiD4fnUtBE2F1Eo6iMLF+U+tJnf\n         h2gw==","X-Forwarded-Encrypted":"i=1;\n AFNElJ+Dfz5wyPmfLdH9xKuXkJCyDO29d/hJJ/gwkC7t/cGk7+Vk2lOxikGfp+OqTii+qgZWnipH82VIu+1I@vger.kernel.org","X-Gm-Message-State":"AOJu0YwQHxGBeQ1Hhrp/UZ6DTKRUX8RLGmQhnNGe1MsbotN0ZTMmav96\n\tKWLebWXdspP+zbp3K2TBVU48rrTcCCMEBOfYKgvgOcfLUv3/RA+XYRDP","X-Gm-Gg":"AeBDieso4hTZjzdPTKI+Jp6uAs0ZRJhrQFgZPILtmnnQWGByfwumDCUwMuDRI3H3O3j\n\taGF5VVPPICzBDCX0YnbL4BvFsNXkMz95gfT3TqCwDkqDHXqBbQDf8p7mvdk0W2f8DtAjs0TZBBr\n\tVA1dH9OG+qrmb+Vq45P/ERJNEImLclHy8tjmaXXWxM8kfeSVjYzyy9nM+TcWdn0cDU9FoI6cJba\n\thfH7Q3oYibwA8EforX4414k+ZO2DA2pi0zLsP3gyxOmkhF1DrU0qPctanothm5IhL0J27yntgrK\n\t9fJ9CUhN0RgRuazkmAL3tmISx6skB9m0u6LHIn7UToXNgk3t/zkVxZayzMvY+OUrSzOJwZDbzah\n\tCbkUVbGmfg0rQvITDLHLVi2xImNChxP5mNsOu9NNh3d/xNkRqunKlJZmAKCXm1KNlj022p2UWqg\n\twov2Fmy3hMdfzxwlGYUyPxxHi+WwTECtqwLdkg0d+sLDsR/kRHTd8+zhlqyPdJJDGi8vEt9HgRs\n\tqusZMRISHhIVjT9L3PrydSxa9NIBp8=","X-Received":"by 2002:a05:622a:120d:b0:50d:8b40:d97b with SMTP id\n d75a77b69052e-50e36bd318cmr180439941cf.17.1776641755202;\n        Sun, 19 Apr 2026 16:35:55 -0700 (PDT)","From":"Michael Bommarito <michael.bommarito@gmail.com>","To":"Steve French <sfrench@samba.org>,\n\tNamjae Jeon <linkinjeon@kernel.org>,\n\tlinux-cifs@vger.kernel.org","Cc":"Paulo Alcantara <pc@manguebit.org>,\n\tRonnie Sahlberg <ronniesahlberg@gmail.com>,\n\tShyam Prasad N <sprasad@microsoft.com>,\n\tTom Talpey <tom@talpey.com>,\n\tBharath SM <bharathsm@microsoft.com>,\n\tstable@vger.kernel.org","Subject":"[PATCH v2] smb: client: fix OOB read in smb2_ioctl_query_info\n QUERY_INFO path","Date":"Sun, 19 Apr 2026 19:35:19 -0400","Message-ID":"<20260419233519.2777046-1-michael.bommarito@gmail.com>","X-Mailer":"git-send-email 2.53.0","In-Reply-To":"<20260416213716.3118443-1-michael.bommarito@gmail.com>","References":"<20260416213716.3118443-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":"smb2_ioctl_query_info() has two response-copy branches: PASSTHRU_FSCTL\nand the default QUERY_INFO path.  The QUERY_INFO branch clamps\nqi.input_buffer_length to the server-reported OutputBufferLength and then\ncopies qi.input_buffer_length bytes from qi_rsp->Buffer to userspace, but\nit never verifies that the flexible-array payload actually fits within\nrsp_iov[1].iov_len.\n\nA malicious server can return OutputBufferLength larger than the actual\nQUERY_INFO response, causing copy_to_user() to walk past the response\nbuffer and expose adjacent kernel heap to userspace.\n\nGuard the QUERY_INFO copy with a bounds check on the actual Buffer\npayload.  Use struct_size(qi_rsp, Buffer, qi.input_buffer_length)\nrather than an open-coded addition so the guard cannot overflow on\n32-bit builds.\n\nFixes: f5778c398713 (\"SMB3: Allow SMB3 FSCTL queries to be sent to server from tools\")\nCc: stable@vger.kernel.org\nSigned-off-by: Michael Bommarito <michael.bommarito@gmail.com>\nAssisted-by: Claude:claude-opus-4-6\nAssisted-by: Codex:gpt-5-4\n---\nChanges in v2:\nUse struct_size() for the new QUERY_INFO bound so the guard cannot wrap\non 32-bit builds.\nKeep the check anchored to qi_rsp->Buffer, since that is what the\ncurrent copy_to_user() actually reads; OutputBufferOffset would only\nmatter if the copy site changed too.\nAlso reran the synthetic 73-byte post-fix case under UML and confirmed\nthe new guard still rejects it cleanly.\n\n fs/smb/client/smb2ops.c | 6 ++++++\n 1 file changed, 6 insertions(+)","diff":"diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c\nindex 509fcea28a42..3600705255f8 100644\n--- a/fs/smb/client/smb2ops.c\n+++ b/fs/smb/client/smb2ops.c\n@@ -1783,6 +1783,12 @@ smb2_ioctl_query_info(const unsigned int xid,\n \t\tqi_rsp = (struct smb2_query_info_rsp *)rsp_iov[1].iov_base;\n \t\tif (le32_to_cpu(qi_rsp->OutputBufferLength) < qi.input_buffer_length)\n \t\t\tqi.input_buffer_length = le32_to_cpu(qi_rsp->OutputBufferLength);\n+\t\tif (qi.input_buffer_length > 0 &&\n+\t\t    struct_size(qi_rsp, Buffer, qi.input_buffer_length) >\n+\t\t    rsp_iov[1].iov_len) {\n+\t\t\trc = -EFAULT;\n+\t\t\tgoto out;\n+\t\t}\n \t\tif (copy_to_user(&pqi->input_buffer_length,\n \t\t\t\t &qi.input_buffer_length,\n \t\t\t\t sizeof(qi.input_buffer_length))) {\n","prefixes":["v2"]}