<!-- 
RSS generated by JIRA (9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c) at Sat Feb 10 03:19:50 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>Whamcloud Community JIRA</title>
    <link>https://jira.whamcloud.com</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.4.14</version>
        <build-number>940014</build-number>
        <build-date>05-12-2023</build-date>
    </build-info>


<item>
            <title>[LU-15615] memory leak on use_t10_grd path in tgt_checksum_niobuf_t10pi</title>
                <link>https://jira.whamcloud.com/browse/LU-15615</link>
                <project id="10000" key="LU">Lustre</project>
                    <description>&lt;p&gt;It looks like tgt_checksum_niobuf_t10pi() can leak memory if we ever set rc to nonzero, some of the conditions appear to set it without any visible warnings:&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;  &#160; &#160; &#160; req = cfs_crypto_hash_init(cfs_alg, NULL, 0);
&#160; &#160; &#160; &#160; if (IS_ERR(req)) {
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; CERROR(&quot;%s: unable to initialize checksum hash %s\n&quot;,
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;tgt_name(tgt), cfs_crypto_hash_name(cfs_alg));
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; return PTR_ERR(req);
&#160; &#160; &#160; &#160; }
...
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; if (use_t10_grd) {
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; used = DIV_ROUND_UP(local_nb[i].lnb_len, sector_size);
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; if (used &amp;gt; (guard_number - used_number)) {
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; rc = -E2BIG;
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; break;
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; }
...
&#160; &#160; &#160; &#160; if (rc)
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; GOTO(out, rc);
...
&#160; &#160; &#160; &#160; rc = cfs_crypto_hash_final(req, (unsigned char *)&amp;amp;cksum, &amp;amp;bufsize);
  &#160; &#160; &#160; if (rc == 0)
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; *check_sum = cksum;
out:
&#160; &#160; &#160; &#160; __free_page(__page);
&#160; &#160; &#160; &#160; return rc;
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;This not only leads to leaking the req, but also the allocated page might be tied in the crypto hash calcs I imagine (passed in as sg buffer with a reference to be potentially freed in the final?)&lt;/p&gt;</description>
                <environment></environment>
        <key id="68952">LU-15615</key>
            <summary>memory leak on use_t10_grd path in tgt_checksum_niobuf_t10pi</summary>
                <type id="1" iconUrl="https://jira.whamcloud.com/secure/viewavatar?size=xsmall&amp;avatarId=11303&amp;avatarType=issuetype">Bug</type>
                                            <priority id="4" iconUrl="https://jira.whamcloud.com/images/icons/priorities/minor.svg">Minor</priority>
                        <status id="5" iconUrl="https://jira.whamcloud.com/images/icons/statuses/resolved.png" description="A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.">Resolved</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="1">Fixed</resolution>
                                        <assignee username="green">Oleg Drokin</assignee>
                                    <reporter username="green">Oleg Drokin</reporter>
                        <labels>
                    </labels>
                <created>Fri, 4 Mar 2022 06:40:47 +0000</created>
                <updated>Mon, 1 May 2023 06:31:57 +0000</updated>
                            <resolved>Mon, 1 May 2023 06:31:45 +0000</resolved>
                                                    <fixVersion>Lustre 2.16.0</fixVersion>
                                        <due></due>
                            <votes>0</votes>
                                    <watches>7</watches>
                                                                            <comments>
                            <comment id="328148" author="adilger" created="Fri, 4 Mar 2022 21:14:32 +0000"  >&lt;p&gt;It looks like the &quot;&lt;tt&gt;if (use_t10_grd)&lt;/tt&gt;&quot; condition is only true if there are T10-PI hardware checksums enabled on the underlying storage because of the &lt;tt&gt;lnb_guard_disk&lt;/tt&gt; check:&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
                use_t10_grd = t10_cksum_type &amp;amp;&amp;amp; opc == OST_READ &amp;amp;&amp;amp;
                              local_nb[i].lnb_len == PAGE_SIZE &amp;amp;&amp;amp;
                              local_nb[i].lnb_guard_disk;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;and &lt;tt&gt;lnb_guard_disk&lt;/tt&gt; should only be set if T10-PI is enabled in the hardware, but I could be wrong about the code flow.&lt;/p&gt;

&lt;p&gt;In either case, for a potential fix for the memory leak for both of the &quot;&lt;tt&gt;if (rc) break;&lt;/tt&gt;&quot; conditions, something like the following should work:&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
out:
        bufsize = sizeof(cksum);  
        rc2 = cfs_crypto_hash_final(req, (unsigned &lt;span class=&quot;code-object&quot;&gt;char&lt;/span&gt; *)&amp;amp;cksum, &amp;amp;bufsize);
        &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (rc2 &amp;amp;&amp;amp; !rc)
                rc = rc2;
            
        &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (!rc)              
                *check_sum = cksum; 
        __free_page(__page);

        &lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; rc;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;However, that doesn&apos;t explain why this code path is being taken - it should never happen that there is not enough space for the GRD tag in the allocated buffer unless there is an error somewhere else in the code.&lt;/p&gt;</comment>
                            <comment id="328152" author="adilger" created="Fri, 4 Mar 2022 21:27:08 +0000"  >&lt;p&gt;It probably makes sense to add at least a CERROR() to this branch, similar to the one in &lt;tt&gt;obd_page_dif_generate_buffer()&lt;/tt&gt;, since this is a &quot;should never happen&quot; code path:&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
                CERROR(&lt;span class=&quot;code-quote&quot;&gt;&quot;%s: unexpected used guard number of DIF %u/%u, data length %u, sector size %u: rc = %d\n&quot;&lt;/span&gt;,
                               obd_name, used, guard_number, length,
                               sector_size, rc);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                            <comment id="328153" author="adilger" created="Fri, 4 Mar 2022 21:31:52 +0000"  >&lt;p&gt;I see that there is also a separate path were there could be a leak &lt;tt&gt;kmap(page)&lt;/tt&gt;, though this would at least print a &lt;tt&gt;CERROR()&lt;/tt&gt;, and &lt;tt&gt;kmap()&lt;/tt&gt; (AFAIK) cannot tolerate a large number of different pages being mapped at once:&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
&lt;span class=&quot;code-object&quot;&gt;int&lt;/span&gt; obd_page_dif_generate_buffer(&lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;code-object&quot;&gt;char&lt;/span&gt; *obd_name, struct page *page,
                                 __u32 offset, __u32 length,
                                 __u16 *guard_start, &lt;span class=&quot;code-object&quot;&gt;int&lt;/span&gt; guard_number,
                                 &lt;span class=&quot;code-object&quot;&gt;int&lt;/span&gt; *used_number, &lt;span class=&quot;code-object&quot;&gt;int&lt;/span&gt; sector_size,
                                 obd_dif_csum_fn *fn)
{
        data_buf = kmap(page) + offset;
        &lt;span class=&quot;code-keyword&quot;&gt;while&lt;/span&gt; (i &amp;lt; end) {
                &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (used &amp;gt;= guard_number) {
                        CERROR(&lt;span class=&quot;code-quote&quot;&gt;&quot;%s: unexpected used guard number of DIF %u/%u, &quot;&lt;/span&gt;
                               &lt;span class=&quot;code-quote&quot;&gt;&quot;data length %u, sector size %u: rc = %d\n&quot;&lt;/span&gt;,
                               obd_name, used, guard_number, length,
                               sector_size, -E2BIG);
                        &lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; -E2BIG;
                }
                :
        }
        kunmap(page);
        *used_number = used;

        &lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; 0;
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;I don&apos;t think this is a primary concern, but should also be fixed to instead always call &lt;tt&gt;kunmap()&lt;/tt&gt;, like:&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
                        GOTO(out_unmap, rc = -E2BIG);
                }
                :
        }
        *used_number = used;
out_unmap:
        kunmap(page);

        &lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; rc;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                            <comment id="368486" author="gerrit" created="Wed, 5 Apr 2023 03:46:14 +0000"  >&lt;p&gt;&quot;Li Dongyang &amp;lt;dongyangli@ddn.com&amp;gt;&quot; uploaded a new patch: &lt;a href=&quot;https://review.whamcloud.com/c/fs/lustre-release/+/50539&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://review.whamcloud.com/c/fs/lustre-release/+/50539&lt;/a&gt;&lt;br/&gt;
Subject: &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-15615&quot; title=&quot;memory leak on use_t10_grd path in tgt_checksum_niobuf_t10pi&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-15615&quot;&gt;&lt;del&gt;LU-15615&lt;/del&gt;&lt;/a&gt; target: Free t10pi crypto state on error&lt;br/&gt;
Project: fs/lustre-release&lt;br/&gt;
Branch: master&lt;br/&gt;
Current Patch Set: 1&lt;br/&gt;
Commit: db8a8c405ebd70d93410847f07ebe033a622df83&lt;/p&gt;</comment>
                            <comment id="371006" author="gerrit" created="Mon, 1 May 2023 04:11:01 +0000"  >&lt;p&gt;&quot;Oleg Drokin &amp;lt;green@whamcloud.com&amp;gt;&quot; merged in patch &lt;a href=&quot;https://review.whamcloud.com/c/fs/lustre-release/+/50539/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://review.whamcloud.com/c/fs/lustre-release/+/50539/&lt;/a&gt;&lt;br/&gt;
Subject: &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-15615&quot; title=&quot;memory leak on use_t10_grd path in tgt_checksum_niobuf_t10pi&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-15615&quot;&gt;&lt;del&gt;LU-15615&lt;/del&gt;&lt;/a&gt; target: Free t10pi crypto state on error&lt;br/&gt;
Project: fs/lustre-release&lt;br/&gt;
Branch: master&lt;br/&gt;
Current Patch Set: &lt;br/&gt;
Commit: 6a88222bd6a1c0f5bd45fb40b88af226db8bd29a&lt;/p&gt;</comment>
                            <comment id="371027" author="pjones" created="Mon, 1 May 2023 06:31:45 +0000"  >&lt;p&gt;Landed for 2.16&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Related</name>
                                            <outwardlinks description="is related to ">
                                        <issuelink>
            <issuekey id="68877">LU-15598</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is related to">
                                                        </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                            <customfield id="customfield_10890" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10390" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|i02jwf:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10090" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10060" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                        <customfieldname>Severity</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10022"><![CDATA[3]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                        </customfields>
    </item>
</channel>
</rss>