Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.1/patches/2229680/?format=api
{ "id": 2229680, "url": "http://patchwork.ozlabs.org/api/1.1/patches/2229680/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-cifs-client/patch/20260428154604.222551-5-henrique.carvalho@suse.com/", "project": { "id": 12, "url": "http://patchwork.ozlabs.org/api/1.1/projects/12/?format=api", "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": "<20260428154604.222551-5-henrique.carvalho@suse.com>", "date": "2026-04-28T15:46:00", "name": "[02/11] smb: client: refactor negotiate context assembly", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "ae326e05389f737f5f7d1c5ff624121357bca9ba", "submitter": { "id": 89563, "url": "http://patchwork.ozlabs.org/api/1.1/people/89563/?format=api", "name": "Henrique Carvalho", "email": "henrique.carvalho@suse.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linux-cifs-client/patch/20260428154604.222551-5-henrique.carvalho@suse.com/mbox/", "series": [ { "id": 501884, "url": "http://patchwork.ozlabs.org/api/1.1/series/501884/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-cifs-client/list/?series=501884", "date": "2026-04-28T15:46:00", "name": null, "version": 1, "mbox": "http://patchwork.ozlabs.org/series/501884/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2229680/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2229680/checks/", "tags": {}, "headers": { "Return-Path": "\n <linux-cifs+bounces-11224-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=suse.com header.i=@suse.com header.a=rsa-sha256\n header.s=google header.b=Y3XDAm+V;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c04:e001:36c::12fc:5321; helo=tor.lore.kernel.org;\n envelope-from=linux-cifs+bounces-11224-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)", "smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com\n header.b=\"Y3XDAm+V\"", "smtp.subspace.kernel.org;\n arc=none smtp.client-ip=209.85.221.47", "smtp.subspace.kernel.org;\n dmarc=pass (p=quarantine dis=none) header.from=suse.com", "smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=suse.com" ], "Received": [ "from tor.lore.kernel.org (tor.lore.kernel.org\n [IPv6:2600:3c04:e001:36c::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 4g4lDz50Kpz1xvV\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 29 Apr 2026 01:47:31 +1000 (AEST)", "from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby tor.lore.kernel.org (Postfix) with ESMTP id 8B664302E7E8\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 28 Apr 2026 15:46:48 +0000 (UTC)", "from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 7C28B3C1973;\n\tTue, 28 Apr 2026 15:46:47 +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 9F8E13C3448\n\tfor <linux-cifs@vger.kernel.org>; Tue, 28 Apr 2026 15:46:45 +0000 (UTC)", "by mail-wr1-f47.google.com with SMTP id\n ffacd0b85a97d-43cfd1f9fd1so7257769f8f.3\n for <linux-cifs@vger.kernel.org>;\n Tue, 28 Apr 2026 08:46:45 -0700 (PDT)", "from precision ([2a01:4b00:c007:bb00:be9d:a3c4:18b1:4a25])\n by smtp.gmail.com with ESMTPSA id\n ffacd0b85a97d-4463d4fa52bsm7725384f8f.15.2026.04.28.08.46.43\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Tue, 28 Apr 2026 08:46:43 -0700 (PDT)" ], "ARC-Seal": "i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777391207; cv=none;\n b=PD/Fq3KrXGkHak9GpItmT9+fS6f+4O5VDR7/SQXjW2pcsNSeamN8H0tzC4BC1nmMOqO4OovQizSbKbTAqLnch/sF/93l1jrOmXIl3uStAtEXHP6Ijx7goiUcBFVQNUaPdJR+ywIQ4lX1L/4SzF2Zs3pbQhwPXplWNmXaAb2Of50=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777391207; c=relaxed/simple;\n\tbh=lQ5DpuALbgTsXOKgwn74AyoacGYenQNBVH9tON40P7o=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=WRH5iSHVZy15htkHO62XgeSXNpjuxc6MBY47kb4ukviZXIs1/3LYQgkmkb0fHMMJrOwlP4KiRFMiq+4nbqRkkT7g+CUUoCVhLO69YgLUD0+4Lwun4vmuUyTyD35N+q/moXG57Zc5cW492VtCrhX3IMvthSnJdiLCoFdrGsbY3EU=", "ARC-Authentication-Results": "i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=quarantine dis=none) header.from=suse.com;\n spf=pass smtp.mailfrom=suse.com;\n dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com\n header.b=Y3XDAm+V; arc=none smtp.client-ip=209.85.221.47", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=suse.com; s=google; t=1777391204; x=1777996004;\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=ycsCVSVbXnO73EBGsa9NkUp/8I4UNQARemQ6U5oYXqA=;\n b=Y3XDAm+VTfoxQSQwp7E4Xki9wvYBDUKcIAKv/BhPyPSiX4oW0zsJnF6gufYeTRP8zn\n 1EvrF7+N/JllJOXB3TijXnlRPmHOLy83x+vDlZEoHiWdMqSO5T4RHdkrF9FxIPS1AnJi\n C8vkAaOSA7w/xXbmy0YQtWEnm1/P2qB/v0YztpdmldX3crKJglMMflxG02aRy41j7I2M\n 4O17XoPc9c7bYy6LDN+ymvyv4eMaYy75C92fGGqjQrPv7Fb/lT7uVn6CIHOhqqeINhbM\n dIUjPejjGeQ826K6Ia65NCnPu0FkSKOhxZkjdaT1R5qxCSYdD16xdKPC7TDBt6igQ+m+\n +F0Q==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1777391204; x=1777996004;\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=ycsCVSVbXnO73EBGsa9NkUp/8I4UNQARemQ6U5oYXqA=;\n b=O3zW9QnVsCxrVnLBLjts5Bn4I1WroeP76F1g2eIW05eaJT6b6316WAor8DpXbB09tg\n 3JL38POqyotBiu/9T1W+157vABBI8Vk0NEQn5p9geeWw7D2nyNcUHH1ElxfWpevMraiJ\n ATVwQW1ZccX+GC9FS8IXWXyY3wT+7wbmhacJEcsGz3bGvp0P9Ur2GVdrVUE3KW34WfZz\n UNMDW0SfBa1p/QsJCgsJHlVKLhr911TQ0TnRBgqgQSsUl9Ano2F8vHVcdeVRxUojnv8h\n CQgJhH5hpPKBayTHytpsAbz0nf+myhgXdyOfF12P0gPqvxioudc5XHcg0/HiCQtbx3VZ\n bUPw==", "X-Gm-Message-State": "AOJu0Yww9SoY2OfquTzq5TvQLhBcQZvHBP4zymMCeMw9BbBvS8dZin6o\n\tL7R3IoxPkXWLGrnh7ubFvsNUaLZqyb0qBjiGLmSHuPftBYE0zCQEfA4fFT04W9PGiVK3Z11HILJ\n\t05nKz/YWo+w==", "X-Gm-Gg": "AeBDietOYjhKgdRd4qrZ1ggik7+Pc9WZC+C5wL81TfR58hW7LI1MLqtJ6QPABzccmXH\n\t/3c2+j/21M3Md46AeI8G0gBIRkQjtanyCopxDMOEL2+ggpy1VzpBBFHBykCGjZx4mfuEhaDtVPS\n\teJZ/+miU0W5qtVJ/EZNOq5nH/PsBiB0hZZHdZo1VHpGe23thv8X29ZQGORq53fO2hFAWZULhRLa\n\tYf62dgDdaAo4ecAzGshpZzKqFj9L9Qvt9ZTjoQbDvWo/lTg8DtJ7kxZ4wu2WbjrlO555/WMDZ5a\n\tXAYJ9W8g9EXPDFfi7j4ZBBG8b3r/VGmmvSzuCfpWpzdto5yRv8EQYct19YOz3Jj9YeHCahXcDSp\n\t5nyNqonldXhWaZ6bdo5VEmWh0B2dxr4Jo/l7Ktbfo8vTLLXiecMxwBRcBB6V2z6Xl8CoS6VaLu8\n\t3RKGHkLKlR/N7y9/+W/Hz2WTed4/QwRyx+KHlKP1lYo5D2", "X-Received": "by 2002:a05:6000:1787:b0:43d:1c7a:8b5b with SMTP id\n ffacd0b85a97d-4464b2ace42mr6887767f8f.40.1777391203694;\n Tue, 28 Apr 2026 08:46:43 -0700 (PDT)", "From": "Henrique Carvalho <henrique.carvalho@suse.com>", "To": "linux-cifs@vger.kernel.org", "Cc": "sfrench@samba.org,\n\tlinkinjeon@kernel.org,\n\tmetze@samba.org,\n\tpc@manguebit.com,\n\tronniesahlberg@gmail.com,\n\tsprasad@microsoft.com,\n\ttom@talpey.com,\n\tbharathsm@microsoft.com,\n\tematsumiya@suse.de,\n\tHenrique Carvalho <henrique.carvalho@suse.com>", "Subject": "[PATCH 02/11] smb: client: refactor negotiate context assembly", "Date": "Tue, 28 Apr 2026 12:46:00 -0300", "Message-ID": "<20260428154604.222551-5-henrique.carvalho@suse.com>", "X-Mailer": "git-send-email 2.53.0", "In-Reply-To": "<20260428154604.222551-1-henrique.carvalho@suse.com>", "References": "<20260428154604.222551-1-henrique.carvalho@suse.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": "Introduce struct neg_ctx, smb2_neg_context_len() and add_context() to\nhandle alignment, pointer advancement, and counter increment in one\nplace, eliminating repetitive code.\n\nAlso fix missing ALIGN() for posix negotiate context.\n\nSigned-off-by: Henrique Carvalho <henrique.carvalho@suse.com>\n---\n fs/smb/client/smb2pdu.c | 106 +++++++++++++++++++++-------------------\n 1 file changed, 56 insertions(+), 50 deletions(-)", "diff": "diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c\nindex cddb1ae04e83..bac88a612d5d 100644\n--- a/fs/smb/client/smb2pdu.c\n+++ b/fs/smb/client/smb2pdu.c\n@@ -618,7 +618,15 @@ static int smb2_ioctl_req_init(u32 opcode, struct cifs_tcon *tcon,\n \n /* For explanation of negotiate contexts see MS-SMB2 section 2.2.3.1 */\n \n-static void\n+static inline unsigned int\n+smb2_neg_context_len(const void *p)\n+{\n+\tconst struct smb2_neg_context *ctx = p;\n+\n+\treturn sizeof(*ctx) + le16_to_cpu(ctx->DataLength);\n+}\n+\n+static unsigned int\n build_preauth_ctxt(struct smb2_preauth_neg_context *pneg_ctxt)\n {\n \tpneg_ctxt->ContextType = SMB2_PREAUTH_INTEGRITY_CAPABILITIES;\n@@ -627,9 +635,10 @@ build_preauth_ctxt(struct smb2_preauth_neg_context *pneg_ctxt)\n \tpneg_ctxt->SaltLength = cpu_to_le16(SMB311_SALT_SIZE);\n \tget_random_bytes(pneg_ctxt->Salt, SMB311_SALT_SIZE);\n \tpneg_ctxt->HashAlgorithms = SMB2_PREAUTH_INTEGRITY_SHA512;\n+\treturn smb2_neg_context_len(pneg_ctxt);\n }\n \n-static void\n+static unsigned int\n build_compression_ctxt(struct smb2_compression_capabilities_context *pneg_ctxt)\n {\n \tpneg_ctxt->ContextType = SMB2_COMPRESSION_CAPABILITIES;\n@@ -640,13 +649,13 @@ build_compression_ctxt(struct smb2_compression_capabilities_context *pneg_ctxt)\n \tpneg_ctxt->CompressionAlgorithms[0] = SMB3_COMPRESS_LZ77;\n \tpneg_ctxt->CompressionAlgorithms[1] = SMB3_COMPRESS_LZ77_HUFF;\n \tpneg_ctxt->CompressionAlgorithms[2] = SMB3_COMPRESS_LZNT1;\n+\treturn smb2_neg_context_len(pneg_ctxt);\n }\n \n static unsigned int\n build_signing_ctxt(struct smb2_signing_capabilities *pneg_ctxt)\n {\n-\tunsigned int ctxt_len = sizeof(struct smb2_signing_capabilities);\n-\tunsigned short num_algs = 1; /* number of signing algorithms sent */\n+\tconst unsigned short num_algs = 1; /* number of signing algorithms sent */\n \n \tpneg_ctxt->ContextType = SMB2_SIGNING_CAPABILITIES;\n \t/*\n@@ -658,13 +667,11 @@ build_signing_ctxt(struct smb2_signing_capabilities *pneg_ctxt)\n \tpneg_ctxt->SigningAlgorithmCount = cpu_to_le16(num_algs);\n \tpneg_ctxt->SigningAlgorithms[0] = cpu_to_le16(SIGNING_ALG_AES_CMAC);\n \n-\tctxt_len += sizeof(__le16) * num_algs;\n-\tctxt_len = ALIGN(ctxt_len, 8);\n-\treturn ctxt_len;\n+\treturn smb2_neg_context_len(pneg_ctxt);\n \t/* TBD add SIGNING_ALG_AES_GMAC and/or SIGNING_ALG_HMAC_SHA256 */\n }\n \n-static void\n+static unsigned int\n build_encrypt_ctxt(struct smb2_encryption_neg_context *pneg_ctxt)\n {\n \tpneg_ctxt->ContextType = SMB2_ENCRYPTION_CAPABILITIES;\n@@ -684,6 +691,7 @@ build_encrypt_ctxt(struct smb2_encryption_neg_context *pneg_ctxt)\n \t\tpneg_ctxt->Ciphers[0] = SMB2_ENCRYPTION_AES128_GCM;\n \t\tpneg_ctxt->Ciphers[1] = SMB2_ENCRYPTION_AES128_CCM;\n \t}\n+\treturn smb2_neg_context_len(pneg_ctxt);\n }\n \n static unsigned int\n@@ -695,11 +703,11 @@ build_netname_ctxt(struct smb2_netname_neg_context *pneg_ctxt, char *hostname)\n \n \t/* copy up to max of first 100 bytes of server name to NetName field */\n \tpneg_ctxt->DataLength = cpu_to_le16(2 * cifs_strtoUTF16(pneg_ctxt->NetName, hostname, 100, cp));\n-\t/* context size is DataLength + minimal smb2_neg_context */\n-\treturn ALIGN(le16_to_cpu(pneg_ctxt->DataLength) + sizeof(struct smb2_neg_context), 8);\n+\n+\treturn smb2_neg_context_len(pneg_ctxt);\n }\n \n-static void\n+static unsigned int\n build_posix_ctxt(struct smb2_posix_neg_context *pneg_ctxt)\n {\n \tpneg_ctxt->ContextType = SMB2_POSIX_EXTENSIONS_AVAILABLE;\n@@ -721,15 +729,31 @@ build_posix_ctxt(struct smb2_posix_neg_context *pneg_ctxt)\n \tpneg_ctxt->Name[13] = 0x8B;\n \tpneg_ctxt->Name[14] = 0xCD;\n \tpneg_ctxt->Name[15] = 0x7C;\n+\treturn smb2_neg_context_len(pneg_ctxt);\n+}\n+\n+struct neg_ctx {\n+\tchar *pos;\n+\tunsigned int len;\n+\tunsigned int cnt;\n+};\n+\n+static inline void\n+add_context(struct neg_ctx *nc, unsigned int ctx_len)\n+{\n+\tunsigned int aligned_len = ALIGN(ctx_len, 8);\n+\n+\tnc->pos += aligned_len;\n+\tnc->len += aligned_len;\n+\tnc->cnt++;\n }\n \n static void\n assemble_neg_contexts(struct smb2_negotiate_req *req,\n \t\t struct TCP_Server_Info *server, unsigned int *total_len)\n {\n-\tunsigned int ctxt_len, neg_context_count;\n+\tstruct neg_ctx nc;\n \tstruct TCP_Server_Info *pserver;\n-\tchar *pneg_ctxt;\n \tchar *hostname;\n \n \tif (*total_len > 200) {\n@@ -744,18 +768,15 @@ assemble_neg_contexts(struct smb2_negotiate_req *req,\n \t */\n \t*total_len = ALIGN(*total_len, 8);\n \n-\tpneg_ctxt = (*total_len) + (char *)req;\n \treq->NegotiateContextOffset = cpu_to_le32(*total_len);\n \n-\tbuild_preauth_ctxt((struct smb2_preauth_neg_context *)pneg_ctxt);\n-\tctxt_len = ALIGN(sizeof(struct smb2_preauth_neg_context), 8);\n-\t*total_len += ctxt_len;\n-\tpneg_ctxt += ctxt_len;\n+\tnc.pos = (*total_len) + (char *)req;\n+\tnc.len = *total_len;\n+\tnc.cnt = 0;\n+\n+\tadd_context(&nc, build_preauth_ctxt((struct smb2_preauth_neg_context *)nc.pos));\n \n-\tbuild_encrypt_ctxt((struct smb2_encryption_neg_context *)pneg_ctxt);\n-\tctxt_len = ALIGN(sizeof(struct smb2_encryption_neg_context), 8);\n-\t*total_len += ctxt_len;\n-\tpneg_ctxt += ctxt_len;\n+\tadd_context(&nc, build_encrypt_ctxt((struct smb2_encryption_neg_context *)nc.pos));\n \n \t/*\n \t * secondary channels don't have the hostname field populated\n@@ -764,41 +785,26 @@ assemble_neg_contexts(struct smb2_negotiate_req *req,\n \tpserver = SERVER_IS_CHAN(server) ? server->primary_server : server;\n \tcifs_server_lock(pserver);\n \thostname = pserver->hostname;\n-\tif (hostname && (hostname[0] != 0)) {\n-\t\tctxt_len = build_netname_ctxt((struct smb2_netname_neg_context *)pneg_ctxt,\n-\t\t\t\t\t hostname);\n-\t\t*total_len += ctxt_len;\n-\t\tpneg_ctxt += ctxt_len;\n-\t\tneg_context_count = 3;\n-\t} else\n-\t\tneg_context_count = 2;\n+\tif (hostname && (hostname[0] != 0))\n+\t\tadd_context(&nc,\n+\t\t\t build_netname_ctxt((struct smb2_netname_neg_context *)nc.pos,\n+\t\t\t\t\t hostname));\n \tcifs_server_unlock(pserver);\n \n-\tbuild_posix_ctxt((struct smb2_posix_neg_context *)pneg_ctxt);\n-\t*total_len += sizeof(struct smb2_posix_neg_context);\n-\tpneg_ctxt += sizeof(struct smb2_posix_neg_context);\n-\tneg_context_count++;\n+\tadd_context(&nc, build_posix_ctxt((struct smb2_posix_neg_context *)nc.pos));\n \n-\tif (server->compression.requested) {\n-\t\tbuild_compression_ctxt((struct smb2_compression_capabilities_context *)\n-\t\t\t\tpneg_ctxt);\n-\t\tctxt_len = ALIGN(sizeof(struct smb2_compression_capabilities_context), 8);\n-\t\t*total_len += ctxt_len;\n-\t\tpneg_ctxt += ctxt_len;\n-\t\tneg_context_count++;\n-\t}\n+\tif (server->compression.requested)\n+\t\tadd_context(&nc,\n+\t\t\t build_compression_ctxt(\n+\t\t\t\t (struct smb2_compression_capabilities_context *)nc.pos));\n \n-\tif (enable_negotiate_signing) {\n-\t\tctxt_len = build_signing_ctxt((struct smb2_signing_capabilities *)\n-\t\t\t\tpneg_ctxt);\n-\t\t*total_len += ctxt_len;\n-\t\tpneg_ctxt += ctxt_len;\n-\t\tneg_context_count++;\n-\t}\n+\tif (enable_negotiate_signing)\n+\t\tadd_context(&nc, build_signing_ctxt((struct smb2_signing_capabilities *)nc.pos));\n \n \t/* check for and add transport_capabilities and signing capabilities */\n-\treq->NegotiateContextCount = cpu_to_le16(neg_context_count);\n+\treq->NegotiateContextCount = cpu_to_le16(nc.cnt);\n \n+\t*total_len = nc.len;\n }\n \n /* If invalid preauth context warn but use what we requested, SHA-512 */\n", "prefixes": [ "02/11" ] }