{"id":2231598,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2231598/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-cifs-client/patch/20260430220601.76266-1-rosenp@gmail.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":"<20260430220601.76266-1-rosenp@gmail.com>","date":"2026-04-30T22:06:01","name":"cifssmb: use struct_offset in memcpy calculations","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"2ade8404233d7111d6d6d3e5f63b03d3c9d0f0c6","submitter":{"id":70304,"url":"http://patchwork.ozlabs.org/api/1.1/people/70304/?format=json","name":"Rosen Penev","email":"rosenp@gmail.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-cifs-client/patch/20260430220601.76266-1-rosenp@gmail.com/mbox/","series":[{"id":502398,"url":"http://patchwork.ozlabs.org/api/1.1/series/502398/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-cifs-client/list/?series=502398","date":"2026-04-30T22:06:01","name":"cifssmb: use struct_offset in memcpy calculations","version":1,"mbox":"http://patchwork.ozlabs.org/series/502398/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2231598/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2231598/checks/","tags":{},"headers":{"Return-Path":"\n <linux-cifs+bounces-11316-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=VqSD8WzE;\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-11316-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=\"VqSD8WzE\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=209.85.210.171","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)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g67YG3DZtz1yGq\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 01 May 2026 08:06:26 +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 048AE3016C94\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 30 Apr 2026 22:06:23 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 2E1DB39280C;\n\tThu, 30 Apr 2026 22:06:22 +0000 (UTC)","from mail-pf1-f171.google.com (mail-pf1-f171.google.com\n [209.85.210.171])\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 DC7691A08AF\n\tfor <linux-cifs@vger.kernel.org>; Thu, 30 Apr 2026 22:06:20 +0000 (UTC)","by mail-pf1-f171.google.com with SMTP id\n d2e1a72fcca58-834da62e52dso724797b3a.3\n        for <linux-cifs@vger.kernel.org>;\n Thu, 30 Apr 2026 15:06:20 -0700 (PDT)","from ryzen ([2601:644:8000:5b5d:7285:c2ff:fe45:8a32])\n        by smtp.gmail.com with ESMTPSA id\n d2e1a72fcca58-83515b5b921sm697669b3a.54.2026.04.30.15.06.18\n        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n        Thu, 30 Apr 2026 15:06:19 -0700 (PDT)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777586782; cv=none;\n b=R02+63QEToYhwfHFC5e805Pvmvp8Dxc3FTC5CTIvwPIwo3evw1rJU0pSBmArkn+1wuiyVExiUiqzjy6J7SH16exIkMeroi4BhS6Ae/Lw132lPV6PN4ffrrWimPMYqE6hZCV42DtQggRc4MvsjoXjGbJHawcGhkCU2blJK0Y1EmQ=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777586782; c=relaxed/simple;\n\tbh=eT6EIBZi9rcXmuu3voYecfDsErBQjfP+qHIsnasVWgQ=;\n\th=From:To:Cc:Subject:Date:Message-ID:MIME-Version;\n b=CaVHU6hEJQ7gaV+EQdcMgZ1YWmx4NS/Y3/LmscahP1U59Y013VG8rpQ2VRnVnilFnU9uG4pWNvG5wwgzxVmIwgyUiM4GZHFyXPks2KtL5nY0jVoZoeCSPfs7NXdsPh+9UzXKd9OJVYm4CQLf/bQU+OkmX6O2nDS1R56q1Y+yY2w=","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=VqSD8WzE; arc=none smtp.client-ip=209.85.210.171","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=gmail.com; s=20251104; t=1777586780; x=1778191580;\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=/dA6RZLZIEwYVmfS2bByylL2+V02+Ice5FzEDwkLVw8=;\n        b=VqSD8WzEbezPfkcbesmmwRzb+yvLA4sRjt9hC6CIC5YFeCg3dG5+LuQi3a8RD8A+Yl\n         l6EYRnqer/7LQXSzqzTMeOTxuj3ESDFnPtaVRQNNmsgJq1tCIwORdKKZDGSEYHcdvC3l\n         ZsKFxo5E0Lu4yQZIc0fJy2DppikQLSGzfjtQTh+8kR9GmMvJLWFA3B34ZdPLYb+jNgLp\n         T49jfxZ8UCddMdwm5d3zh1J7dqv5DA++Yi1a4+BSR+HM2vvew02uf3lR7GEXQw1CPyEu\n         rJoKOsGoR1bZ1tbChH41jATOb2KzdETurjskorC0OpS6DEH75Qi9WEmT3fVhblfGoQ6a\n         zzWA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20251104; t=1777586780; x=1778191580;\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=/dA6RZLZIEwYVmfS2bByylL2+V02+Ice5FzEDwkLVw8=;\n        b=Ln2HwV7fo69LThX7cigk2DWAbqOPtY6cLPG/vwOwu+ozWJwS4xIKEbST6MMgUgvf4i\n         Zdym2e9aE/TFzF3wVRurPnP9utxeUX7C2tZ2sp/7pf9tA9H+ZoGleDHXhLWRf0EFXB2d\n         D33N35sM/zXxd2hH9l/ngpSRR5za1QKQeMeMLZIeX9sB/nN4TWBHW2EV1X739l8V2pbR\n         5vUPSnE+TESY3+1qmDC1Zlj70CjEylY8l98dowxJyKVO+UpRh0dTuNU86kg7pPoPEjck\n         XJOd29Cg1PK5aRYkNE/MkiqpkNSLcTze2b2+HSSDSip0POOOEb6UKvUOo92NireiFCD/\n         5A7Q==","X-Gm-Message-State":"AOJu0Yz96Xqoq/506Q/iKPu7ZBKoqkLSZ9t4P9l9hjTCuFh6cRh6VXMI\n\t1aqJM0/92X3PiTB0bV6G49JU00VMxEqVtUDWcx29K66kdeAJQMCjFOsN0m9DToSi","X-Gm-Gg":"AeBDietwF6/2lAqtF63tqpZhMBa43QiB1RGfJuiDeXGVyPt0ik9+xyZ+xjP+6Qx24l6\n\tW/39ESMEmIFgGKkwgLEY0T8PG9hzyX6TGLh7pUBIh9LOiwTboJud+aZWxjTeLOTl+hsDrA+xXSn\n\tiR93aQ/GAenJyZTvu2PaarC1DMMIDb8vsjK5oXGSVfCFbB1fb926KGRVdjTpdNqO6qkf+tbfHXt\n\te6AxmPFFysr+LOzTAlAyGSakP2G7zZSQ5DR14FFQ5Sel5YfcBnuz4KKtFK8oyzhCGS4tb0pxGT7\n\t1KDBaewQS0FFGrGjcCJv5GRWW04u2QGUrhka8KrvDkovk6pDqkPocCCT9l7AjUd23VK+BAYgHcG\n\twTt1UYf8IIr7RBiwk23F5kohkumVoS8+yU/lWLg5BuO6+1NkOEfc+rLtjE315v3msWZK5+pqtF6\n\tAlUDAaD3ngslCJwNe5GGAeMtc1kzObqnWrGpEIvdYaxt/ZmWmwAv9GWebKj3mX0OC2reTBm0E96\n\ty982pZ6axiG3Bb5ZStIUJBg7I3c2Ol+Iyc5SZPJi8yxWw==","X-Received":"by 2002:a05:6a00:a586:b0:81f:4a36:1c7c with SMTP id\n d2e1a72fcca58-834fdbd1642mr5647846b3a.23.1777586779877;\n        Thu, 30 Apr 2026 15:06:19 -0700 (PDT)","From":"Rosen Penev <rosenp@gmail.com>","To":"linux-cifs@vger.kernel.org","Cc":"Steve French <sfrench@samba.org>,\n\tPaulo 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\tsamba-technical@lists.samba.org (moderated list:COMMON INTERNET FILE SYSTEM\n CLIENT (CIFS and SMB3)),\n\tlinux-kernel@vger.kernel.org (open list)","Subject":"[PATCH] cifssmb: use struct_offset in memcpy calculations","Date":"Thu, 30 Apr 2026 15:06:01 -0700","Message-ID":"<20260430220601.76266-1-rosenp@gmail.com>","X-Mailer":"git-send-email 2.54.0","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":"It seems W=1/FORTIFY_SOURCE is getting confused about the math here.\n\nUse struct_offset to point FORTIFY_SOURCE to the correct place.\n\nRemove response_data variables and directly apply to memcpy. Simpler\nand avoids excess casting.\n\nSigned-off-by: Rosen Penev <rosenp@gmail.com>\n---\n fs/smb/client/cifssmb.c | 40 +++++++++++++---------------------------\n 1 file changed, 13 insertions(+), 27 deletions(-)","diff":"diff --git a/fs/smb/client/cifssmb.c b/fs/smb/client/cifssmb.c\nindex 3990a9012264..8598cec5ebbd 100644\n--- a/fs/smb/client/cifssmb.c\n+++ b/fs/smb/client/cifssmb.c\n@@ -4090,9 +4090,9 @@ CIFSSMBQFileInfo(const unsigned int xid, struct cifs_tcon *tcon,\n \t\t\t\t      get_bcc(&pSMBr->hdr), 40);\n \t\telse if (pFindData) {\n \t\t\t__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);\n-\t\t\tmemcpy((char *) pFindData,\n-\t\t\t       (char *) &pSMBr->hdr.Protocol +\n-\t\t\t       data_offset, sizeof(FILE_ALL_INFO));\n+\t\t\tmemcpy(pFindData,\n+\t\t\t       (char *)pSMBr + struct_offset(pSMBr, hdr.Protocol) + data_offset,\n+\t\t\t       sizeof(FILE_ALL_INFO));\n \t\t} else\n \t\t    rc = -ENOMEM;\n \t}\n@@ -4264,9 +4264,8 @@ CIFSSMBUnixQFileInfo(const unsigned int xid, struct cifs_tcon *tcon,\n \t\t\t\t      get_bcc(&pSMBr->hdr), sizeof(FILE_UNIX_BASIC_INFO));\n \t\t} else {\n \t\t\t__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);\n-\t\t\tmemcpy((char *) pFindData,\n-\t\t\t       (char *) &pSMBr->hdr.Protocol +\n-\t\t\t       data_offset,\n+\t\t\tmemcpy(pFindData,\n+\t\t\t       (char *)pSMBr + struct_offset(pSMBr, hdr.Protocol) + data_offset,\n \t\t\t       sizeof(FILE_UNIX_BASIC_INFO));\n \t\t}\n \t}\n@@ -4349,9 +4348,8 @@ CIFSSMBUnixQPathInfo(const unsigned int xid, struct cifs_tcon *tcon,\n \t\t\t\t      get_bcc(&pSMBr->hdr), sizeof(FILE_UNIX_BASIC_INFO));\n \t\t} else {\n \t\t\t__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);\n-\t\t\tmemcpy((char *) pFindData,\n-\t\t\t       (char *) &pSMBr->hdr.Protocol +\n-\t\t\t       data_offset,\n+\t\t\tmemcpy(pFindData,\n+\t\t\t       (char *)pSMBr + struct_offset(pSMBr, hdr.Protocol) + data_offset,\n \t\t\t       sizeof(FILE_UNIX_BASIC_INFO));\n \t\t}\n \t}\n@@ -5079,7 +5077,6 @@ CIFSSMBQFSAttributeInfo(const unsigned int xid, struct cifs_tcon *tcon)\n /* level 0x105  SMB_QUERY_FILE_SYSTEM_INFO */\n \tTRANSACTION2_QFSI_REQ *pSMB = NULL;\n \tTRANSACTION2_QFSI_RSP *pSMBr = NULL;\n-\tFILE_SYSTEM_ATTRIBUTE_INFO *response_data;\n \tunsigned int in_len;\n \tint rc = 0;\n \tint bytes_returned = 0;\n@@ -5130,11 +5127,8 @@ CIFSSMBQFSAttributeInfo(const unsigned int xid, struct cifs_tcon *tcon)\n \t\t\t\t      get_bcc(&pSMBr->hdr), 13);\n \t\t} else {\n \t\t\t__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);\n-\t\t\tresponse_data =\n-\t\t\t    (FILE_SYSTEM_ATTRIBUTE_INFO\n-\t\t\t     *) (((char *) &pSMBr->hdr.Protocol) +\n-\t\t\t\t data_offset);\n-\t\t\tmemcpy(&tcon->fsAttrInfo, response_data,\n+\t\t\tmemcpy(&tcon->fsAttrInfo,\n+\t\t\t       (char *)pSMBr + struct_offset(pSMBr, hdr.Protocol) + data_offset,\n \t\t\t       sizeof(FILE_SYSTEM_ATTRIBUTE_INFO));\n \t\t}\n \t}\n@@ -5152,7 +5146,6 @@ CIFSSMBQFSDeviceInfo(const unsigned int xid, struct cifs_tcon *tcon)\n /* level 0x104 SMB_QUERY_FILE_SYSTEM_INFO */\n \tTRANSACTION2_QFSI_REQ *pSMB = NULL;\n \tTRANSACTION2_QFSI_RSP *pSMBr = NULL;\n-\tFILE_SYSTEM_DEVICE_INFO *response_data;\n \tunsigned int in_len;\n \tint rc = 0;\n \tint bytes_returned = 0;\n@@ -5205,11 +5198,8 @@ CIFSSMBQFSDeviceInfo(const unsigned int xid, struct cifs_tcon *tcon)\n \t\t\t\t      sizeof(FILE_SYSTEM_DEVICE_INFO));\n \t\telse {\n \t\t\t__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);\n-\t\t\tresponse_data =\n-\t\t\t    (FILE_SYSTEM_DEVICE_INFO *)\n-\t\t\t\t(((char *) &pSMBr->hdr.Protocol) +\n-\t\t\t\t data_offset);\n-\t\t\tmemcpy(&tcon->fsDevInfo, response_data,\n+\t\t\tmemcpy(&tcon->fsDevInfo,\n+\t\t\t       (char *)pSMBr + struct_offset(pSMBr, hdr.Protocol) + data_offset,\n \t\t\t       sizeof(FILE_SYSTEM_DEVICE_INFO));\n \t\t}\n \t}\n@@ -5227,7 +5217,6 @@ CIFSSMBQFSUnixInfo(const unsigned int xid, struct cifs_tcon *tcon)\n /* level 0x200  SMB_QUERY_CIFS_UNIX_INFO */\n \tTRANSACTION2_QFSI_REQ *pSMB = NULL;\n \tTRANSACTION2_QFSI_RSP *pSMBr = NULL;\n-\tFILE_SYSTEM_UNIX_INFO *response_data;\n \tunsigned int in_len;\n \tint rc = 0;\n \tint bytes_returned = 0;\n@@ -5277,11 +5266,8 @@ CIFSSMBQFSUnixInfo(const unsigned int xid, struct cifs_tcon *tcon)\n \t\t\t\t      get_bcc(&pSMBr->hdr), 13);\n \t\t} else {\n \t\t\t__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);\n-\t\t\tresponse_data =\n-\t\t\t    (FILE_SYSTEM_UNIX_INFO\n-\t\t\t     *) (((char *) &pSMBr->hdr.Protocol) +\n-\t\t\t\t data_offset);\n-\t\t\tmemcpy(&tcon->fsUnixInfo, response_data,\n+\t\t\tmemcpy(&tcon->fsUnixInfo,\n+\t\t\t       (char *)pSMBr + struct_offset(pSMBr, hdr.Protocol) + data_offset,\n \t\t\t       sizeof(FILE_SYSTEM_UNIX_INFO));\n \t\t}\n \t}\n","prefixes":[]}