[{"id":3681931,"web_url":"http://patchwork.ozlabs.org/comment/3681931/","msgid":"<2026042426-prance-each-273d@gregkh>","list_archive_url":null,"date":"2026-04-24T10:02:35","subject":"Re: [PATCH] smb: client: Fix error cleanup in\n smb_extract_iter_to_rdma()","submitter":{"id":11800,"url":"http://patchwork.ozlabs.org/api/people/11800/","name":"Greg Kroah-Hartman","email":"gregkh@linuxfoundation.org"},"content":"On Fri, Apr 24, 2026 at 10:56:11AM +0100, David Howells wrote:\n>     \n> Fix smb_extract_iter_to_rdma() to use pre-decrement, not post-decrement, so\n> that it cleans up the correct slots.\n> \n> Fixes: e5fbdde43017 (\"cifs: Add a function to build an RDMA SGE list from an iterator\")\n> Closes: https://sashiko.dev/#/patchset/20260326104544.509518-1-dhowells%40redhat.com\n> Signed-off-by: David Howells <dhowells@redhat.com>\n> cc: Steve French <sfrench@samba.org>\n> cc: Stefan Metzmacher <metze@samba.org>\n> cc: Paulo Alcantara <pc@manguebit.org>\n> cc: Tom Talpey <tom@talpey.com>\n> cc: linux-cifs@vger.kernel.org\n> cc: linux-fsdevel@vger.kernel.org\n> ---\n>  fs/smb/client/smbdirect.c |    2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n> \n> diff --git a/fs/smb/client/smbdirect.c b/fs/smb/client/smbdirect.c\n> index 7d5f66bdbb30..4978755c035c 100644\n> --- a/fs/smb/client/smbdirect.c\n> +++ b/fs/smb/client/smbdirect.c\n> @@ -3394,7 +3394,7 @@ static ssize_t smb_extract_iter_to_rdma(struct iov_iter *iter, size_t len,\n>  \n>  \tif (ret < 0) {\n>  \t\twhile (rdma->nr_sge > before) {\n> -\t\t\tstruct ib_sge *sge = &rdma->sge[rdma->nr_sge--];\n> +\t\t\tstruct ib_sge *sge = &rdma->sge[--rdma->nr_sge];\n>  \n>  \t\t\tib_dma_unmap_single(rdma->device, sge->addr, sge->length,\n>  \t\t\t\t\t    rdma->direction);\n> \n> \n<formletter>\n\nThis is not the correct way to submit patches for inclusion in the\nstable kernel tree.  Please read:\n    https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html\nfor how to do this properly.\n\n</formletter>","headers":{"Return-Path":"\n <linux-cifs+bounces-11079-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 (1024-bit key;\n unprotected) header.d=linuxfoundation.org header.i=@linuxfoundation.org\n header.a=rsa-sha256 header.s=korg header.b=a+fqX52Q;\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-11079-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (1024-bit key) header.d=linuxfoundation.org\n header.i=@linuxfoundation.org header.b=\"a+fqX52Q\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201"],"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)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g27n03PHbz1yDD\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 24 Apr 2026 20:02:44 +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 C41A330010C1\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 24 Apr 2026 10:02:41 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 2665A3603FE;\n\tFri, 24 Apr 2026 10:02:38 +0000 (UTC)","from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org\n [10.30.226.201])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id EDEC735F8B7;\n\tFri, 24 Apr 2026 10:02:37 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id 3D3EBC19425;\n\tFri, 24 Apr 2026 10:02:37 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777024958; cv=none;\n b=aj2mDyR6poUgeyJ4P7TZcyDvmrSoRJV6LY956QANOaMc0HkXYmF2S691V9Sd0sG04Elf7TQOo24c6s+2EcDImyKwL+r8NB07rFOboWfHxZfMPMqeAIRV4a1OvEwjf/GJ2OgJmuQlHGFaLIt3QofhuhoLy+/rBrM+1v5+RfUpW2s=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777024958; c=relaxed/simple;\n\tbh=CjUeLPA3EenRqh7MNr2AcUzrVFrPzT99dnMj15b6S4k=;\n\th=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version:\n\t Content-Type:Content-Disposition:In-Reply-To;\n b=H/3hWbjGaSxvbe55eXxdnOlob1Ck+KsKuafF8EbdOj5ychRytUREKSDDp/50fs/dQDyMTJ9GLImxYvr/Gny8fUg6vQP5TL7RvFVE3KG3647/FFGqqH8WLMS5hmyYxkNuhoumFsG8wLX+6J2C9eJ1xOAPxo8iTOgWTio4c8StBFc=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dkim=pass (1024-bit key) header.d=linuxfoundation.org\n header.i=@linuxfoundation.org header.b=a+fqX52Q;\n arc=none smtp.client-ip=10.30.226.201","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org;\n\ts=korg; t=1777024957;\n\tbh=CjUeLPA3EenRqh7MNr2AcUzrVFrPzT99dnMj15b6S4k=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=a+fqX52Qv6brwSH8UrA5Xs8BwlGCjAQCp/Ph0sJdbtx+Mu7MuFOJGvIYrEs4CXXMS\n\t +Hrcj6NOgJJy7cc4VncAzD9VDBT+k0TtmQE65bbIZLluus73MZHN2n28vBqnVv08+a\n\t i7hPRM7FFqji0HXu4oqpUxdzKbk8l1xPP+qwCeP0=","Date":"Fri, 24 Apr 2026 12:02:35 +0200","From":"Greg KH <gregkh@linuxfoundation.org>","To":"David Howells <dhowells@redhat.com>","Cc":"Steve French <sfrench@samba.org>, Stefan Metzmacher <metze@samba.org>,\n\tPaulo Alcantara <pc@manguebit.org>, Tom Talpey <tom@talpey.com>,\n\tlinux-cifs@vger.kernel.org, linux-fsdevel@vger.kernel.org,\n\tlinux-kernel@vger.kernel.org, stable@vger.kernel.org","Subject":"Re: [PATCH] smb: client: Fix error cleanup in\n smb_extract_iter_to_rdma()","Message-ID":"<2026042426-prance-each-273d@gregkh>","References":"<3418418.1777024571@warthog.procyon.org.uk>","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-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<3418418.1777024571@warthog.procyon.org.uk>"}},{"id":3681993,"web_url":"http://patchwork.ozlabs.org/comment/3681993/","msgid":"<966208b7-b77a-45b9-9dcb-3c8823429318@samba.org>","list_archive_url":null,"date":"2026-04-24T11:39:06","subject":"Re: [PATCH] smb: client: Fix error cleanup in\n smb_extract_iter_to_rdma()","submitter":{"id":8149,"url":"http://patchwork.ozlabs.org/api/people/8149/","name":"Stefan Metzmacher","email":"metze@samba.org"},"content":"Hi David,\n\n>> Fix smb_extract_iter_to_rdma() to use pre-decrement, not post-decrement, so\n>> that it cleans up the correct slots.\n>>\n>> Fixes: e5fbdde43017 (\"cifs: Add a function to build an RDMA SGE list from an iterator\")\n>> Closes: https://sashiko.dev/#/patchset/20260326104544.509518-1-dhowells%40redhat.com\n>> Signed-off-by: David Howells <dhowells@redhat.com>\n>> cc: Steve French <sfrench@samba.org>\n>> cc: Stefan Metzmacher <metze@samba.org>\n>> cc: Paulo Alcantara <pc@manguebit.org>\n>> cc: Tom Talpey <tom@talpey.com>\n>> cc: linux-cifs@vger.kernel.org\n>> cc: linux-fsdevel@vger.kernel.org\n>> ---\n>>   fs/smb/client/smbdirect.c |    2 +-\n>>   1 file changed, 1 insertion(+), 1 deletion(-)\n>>\n>> diff --git a/fs/smb/client/smbdirect.c b/fs/smb/client/smbdirect.c\n>> index 7d5f66bdbb30..4978755c035c 100644\n>> --- a/fs/smb/client/smbdirect.c\n>> +++ b/fs/smb/client/smbdirect.c\n>> @@ -3394,7 +3394,7 @@ static ssize_t smb_extract_iter_to_rdma(struct iov_iter *iter, size_t len,\n>>   \n>>   \tif (ret < 0) {\n>>   \t\twhile (rdma->nr_sge > before) {\n>> -\t\t\tstruct ib_sge *sge = &rdma->sge[rdma->nr_sge--];\n>> +\t\t\tstruct ib_sge *sge = &rdma->sge[--rdma->nr_sge];\n\nCan you please use logic like this?\n\n-               while (state->num_sge > before) {\n-                       struct ib_sge *sge = &state->sge[state->num_sge--];\n+               for (size_t i = before; i < state->num_sge; i++) {\n+                       struct ib_sge *sge = &state->sge[i];\n\nAt least for me that is much easier to understand.\n\nAnd as Greg pointed out we first need a fix for upstream, there\nthe function is smbdirect_map_sges_from_iter in fs/smb/smbdirect/connection.c\n\nAlso the commit message needs to be adjusted for the new name.\n\nThen we need a backportable fix for smb_extract_iter_to_rdma in\nfs/smb/client/smbdirect.c with the same logic.\n\nThanks!\nmetze\n\n>>   \t\t\tib_dma_unmap_single(rdma->device, sge->addr, sge->length,\n>>   \t\t\t\t\t    rdma->direction);\n>>\n>>\n> <formletter>\n> \n> This is not the correct way to submit patches for inclusion in the\n> stable kernel tree.  Please read:\n>      https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html\n> for how to do this properly.\n> \n> </formletter>","headers":{"Return-Path":"\n <linux-cifs+bounces-11080-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 (3072-bit key;\n secure) header.d=samba.org header.i=@samba.org header.a=rsa-sha256\n header.s=42 header.b=M+117sDc;\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-11080-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (3072-bit key) header.d=samba.org header.i=@samba.org\n header.b=\"M+117sDc\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=144.76.82.148","smtp.subspace.kernel.org;\n dmarc=pass (p=quarantine dis=none) header.from=samba.org","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=samba.org"],"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 4g29xJ5Wlkz1yD5\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 24 Apr 2026 21:40:04 +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 BD71D301CDBB\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 24 Apr 2026 11:39:20 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 5211E3BE628;\n\tFri, 24 Apr 2026 11:39:17 +0000 (UTC)","from hr2.samba.org (hr2.samba.org [144.76.82.148])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id A28543BED59;\n\tFri, 24 Apr 2026 11:39:14 +0000 (UTC)","from [127.0.0.2] (localhost [127.0.0.1])\n\tby hr2.samba.org with esmtpsa\n (TLS1.3:ECDHE_SECP256R1__ECDSA_SECP256R1_SHA256__CHACHA20_POLY1305:256)\n\t(Exim)\n\tid 1wGEsG-00000003nNq-2SmM;\n\tFri, 24 Apr 2026 11:39:11 +0000"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777030757; cv=none;\n b=GbOBf02PNtrlf6snmHX+qGQYNGZjbRWXNdpcIS0q2WUDve04BKLdD6KeFlDnF7vEqWy5/K6FL1yNXhQPhyFtN3AySO0dZZIMLKhwmRZIFixnh2eZ7eYrdSAFrUScE/qfCKv66JbbdxyQnKeHMgvwIUYKE1CK9Gkz4oGJa3J5uw4=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777030757; c=relaxed/simple;\n\tbh=Vbw15iUuGReYoDg74B4jVuwCsAm3eNad5N4/DaDRt24=;\n\th=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From:\n\t In-Reply-To:Content-Type;\n b=smnQL6OqJrpLbg1a/3qUKIcBN5l15rIC86KrFO5MyivrsQWn6/kiYQZpNiUF46iWEB/GBzVa2M8budP4Gmc2uEApqAS2QtUeqC9foUPJPo8j+PeQFyxGPLEx0MnyHb7nrUMkmQ2XBCwugP04eYOV09OlKjDNvzr6+hExietqMg4=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=quarantine dis=none) header.from=samba.org;\n spf=pass smtp.mailfrom=samba.org;\n dkim=pass (3072-bit key) header.d=samba.org header.i=@samba.org\n header.b=M+117sDc; arc=none smtp.client-ip=144.76.82.148","DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=samba.org;\n\ts=42; h=From:Cc:To:Date:Message-ID;\n\tbh=vqWcSThc8pjY0oM9PCXkI0BSkRYzt+6om4JQ2IRTrkM=; b=M+117sDce9Z9GeWcvjlIK7G646\n\tAFw6i7n4qtNKPYbT7vf0dZsmj68sxKBqeTTIpzxCXPeXQilmWw+aEi8YVSvkrVTTyufHZIvf7kfRz\n\tU3i4aBqEeFs/aMCaErfktfPQGpWx7TaZMVnwMVaR1+sG0wRzXrbEFMVjIRYaWfpNasHn47JXLDKhf\n\tG9SWpwBI/neGk4zS4CDmm5SaOMxae17LwBXmhIJ41OMiyo+c1+hpemO8MbP7+2NXz7pAxTK1O77dq\n\tmrh7dzOzWU3xTN9JmQFMO56J1WCiNsJ+MM0qwRi+lGhBO+lXvADTHuPmv27eGAbJl0fOfTWKN/Zrc\n\tZqOwGgYlHYa06QrleGc17rClshzzuljGAilOCJdPUClfypeKeKuLlayyBgs5x2JYRZ75Ey0Aj2lJe\n\t+M6k7Re1sqZ1c7oSvO10fGh9oWOczCac+857VtdnmPYhrxnrXcVHJfevl0LEW6m4k3zcp6UMcB8hm\n\t+S8KcGP4Vcmu7G1L7So0g91y;","Message-ID":"<966208b7-b77a-45b9-9dcb-3c8823429318@samba.org>","Date":"Fri, 24 Apr 2026 13:39:06 +0200","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","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH] smb: client: Fix error cleanup in\n smb_extract_iter_to_rdma()","To":"Greg KH <gregkh@linuxfoundation.org>, David Howells <dhowells@redhat.com>","Cc":"Steve French <sfrench@samba.org>, Paulo Alcantara <pc@manguebit.org>,\n Tom Talpey <tom@talpey.com>, linux-cifs@vger.kernel.org,\n linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,\n stable@vger.kernel.org","References":"<3418418.1777024571@warthog.procyon.org.uk>\n <2026042426-prance-each-273d@gregkh>","Content-Language":"en-US","From":"Stefan Metzmacher <metze@samba.org>","In-Reply-To":"<2026042426-prance-each-273d@gregkh>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit"}}]