<!-- 
RSS generated by JIRA (9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c) at Sat Feb 10 01:47:33 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-4985] Return value of kthread_run truncated to 32-bit int in ll_sa thread and elsewhere</title>
                <link>https://jira.whamcloud.com/browse/LU-4985</link>
                <project id="10000" key="LU">Lustre</project>
                    <description>&lt;p&gt;Several places in the Lustre code store the result of kthread_run, which is of 64-bit type task_struct *, in a 32-bit integer.  Depending on the value of the pointer, this will be interpreted as an error by the IS_ERR_VALUE macro.&lt;/p&gt;

&lt;p&gt;This problem exists, for example, with the creation of statahead threads, ll_sa.&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;static int start_statahead_thread(struct inode *dir, struct dentry *dentry)
{
...
        int rc;
...
        rc = PTR_ERR(kthread_run(ll_statahead_thread, dentry-&amp;gt;d_parent,
                                 &quot;ll_sa_%u&quot;, lli-&amp;gt;lli_opendir_pid));
        thread = &amp;amp;sai-&amp;gt;sai_thread;
        if (IS_ERR_VALUE(rc)) {
                CERROR(&quot;can&apos;t start ll_sa thread, rc: %d\n&quot;, rc);

                spin_lock(&amp;amp;lli-&amp;gt;lli_sa_lock);
                thread_set_flags(thread, SVC_STOPPED);
                thread_set_flags(&amp;amp;sai-&amp;gt;sai_agl_thread, SVC_STOPPED);
                spin_unlock(&amp;amp;lli-&amp;gt;lli_sa_lock);

                ll_sai_put(sai);
                GOTO(out, rc = -EAGAIN);
        }
...
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This can cause a general protection fault if the sai struct is accessed by the ll_sa thread after it has been freed.  Here is an example in which the return value from kthread_run is incorrectly interpreted as an error:&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;2014-04-18T04:37:49.706791-05:00 c0-0c1s2n3 LustreError: 11453:0:(statahead.c:1588:start_statahead_thread()) can&apos;t start ll_sa thread, rc: -3968
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The -3968 which is reported as the rc of the kthread_run is not a valid error number.  It is the result of truncating the returned task_struct pointer to a 32-bit int.&lt;/p&gt;

&lt;p&gt;There are other places in Lustre which handle the return value of kthread_run incorrectly.  We need to go through and make sure the return value of kthread_run is handled correctly in all cases.  The correct way to handle it would be like this:&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;struct task_struct *task = kthread_run(...)

if (IS_ERR(task)) {
        rc = PTR_ERR(task);
        CERROR(..)
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</description>
                <environment></environment>
        <key id="24506">LU-4985</key>
            <summary>Return value of kthread_run truncated to 32-bit int in ll_sa thread and elsewhere</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="jhammond">John Hammond</assignee>
                                    <reporter username="haasken">Ryan Haasken</reporter>
                        <labels>
                            <label>patch</label>
                    </labels>
                <created>Wed, 30 Apr 2014 16:39:18 +0000</created>
                <updated>Thu, 5 Jun 2014 19:14:27 +0000</updated>
                            <resolved>Wed, 14 May 2014 14:12:04 +0000</resolved>
                                                    <fixVersion>Lustre 2.6.0</fixVersion>
                                        <due></due>
                            <votes>0</votes>
                                    <watches>10</watches>
                                                                            <comments>
                            <comment id="82870" author="jlevi" created="Wed, 30 Apr 2014 17:06:51 +0000"  >&lt;p&gt;John,&lt;br/&gt;
Can you look at this one and comment on the priority?&lt;br/&gt;
Thank you!&lt;/p&gt;</comment>
                            <comment id="82886" author="jhammond" created="Wed, 30 Apr 2014 17:38:59 +0000"  >&lt;p&gt;This looks like 2.5.*. Is that correct Ryan?&lt;/p&gt;

&lt;p&gt;This is fixed in 2.6.0 by &lt;a href=&quot;http://review.whamcloud.com/#/c/6759/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://review.whamcloud.com/#/c/6759/&lt;/a&gt; for &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-3498&quot; title=&quot;most uses of IS_ERR_VALUE() are incorrect&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-3498&quot;&gt;&lt;del&gt;LU-3498&lt;/del&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I would say major/critical. Most of &lt;a href=&quot;http://review.whamcloud.com/#/c/6759/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://review.whamcloud.com/#/c/6759/&lt;/a&gt; can probably be ported to 2.5 without too much fuss.&lt;/p&gt;</comment>
                            <comment id="82895" author="haasken" created="Wed, 30 Apr 2014 18:47:35 +0000"  >&lt;p&gt;John, that&apos;s correct, it&apos;s 2.5.*.&lt;/p&gt;

&lt;p&gt;I didn&apos;t see &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-3498&quot; title=&quot;most uses of IS_ERR_VALUE() are incorrect&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-3498&quot;&gt;&lt;del&gt;LU-3498&lt;/del&gt;&lt;/a&gt; before, but it looks like &lt;a href=&quot;http://review.whamcloud.com/#/c/6759/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://review.whamcloud.com/#/c/6759/&lt;/a&gt; fixes most of the kthread_run calls.  Should we port that to b2_5 then?&lt;/p&gt;

&lt;p&gt;It looks like there are still a few remaining spots that need fixing in master as well:&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;  File              Function                              Line
0 lfsck_layout.c    lfsck_layout_master_prep              4318 rc = PTR_ERR(kthread_run(lfsck_layout_assistant, lta, &quot;lfsck_layout&quot;));
1 lfsck_lib.c       lfsck_start                           2238 rc = PTR_ERR(kthread_run(lfsck_master_engine, lta, &quot;lfsck&quot;));
2 lfsck_namespace.c lfsck_namespace_double_scan           1534 rc = PTR_ERR(kthread_run(lfsck_namespace_double_scan_main, lta,
3 ofd_io.c          ofd_start_inconsistency_verification_  230 rc = PTR_ERR(kthread_run(ofd_inconsistency_verification_main, ofd,
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                            <comment id="82896" author="haasken" created="Wed, 30 Apr 2014 18:48:59 +0000"  >&lt;p&gt;Actually, I take back the comment about the four calls to kthread_run above.  In each of those cases, rc is a long int, so it should be okay.&lt;/p&gt;</comment>
                            <comment id="82945" author="haasken" created="Wed, 30 Apr 2014 22:46:43 +0000"  >&lt;p&gt;Here is the port for b2_5:  &lt;a href=&quot;http://review.whamcloud.com/#/c/10178/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://review.whamcloud.com/#/c/10178/&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="82960" author="adilger" created="Thu, 1 May 2014 00:42:54 +0000"  >&lt;p&gt;It wouldn&apos;t be terrible to fix the four remaining cases to assign the return value to a task_struct pointer for consistency with the other callers. &lt;/p&gt;</comment>
                            <comment id="83553" author="haasken" created="Thu, 8 May 2014 18:15:40 +0000"  >&lt;p&gt;Here&apos;s a patch against master to change the remaining four cases to match the rest: &lt;a href=&quot;http://review.whamcloud.com/#/c/10266/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://review.whamcloud.com/#/c/10266/&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="84083" author="simmonsja" created="Wed, 14 May 2014 14:07:42 +0000"  >&lt;p&gt;Patch landed to master. Ticket can be closed.&lt;/p&gt;</comment>
                            <comment id="84086" author="pjones" created="Wed, 14 May 2014 14:12:04 +0000"  >&lt;p&gt;Landed for 2.6&lt;/p&gt;</comment>
                            <comment id="84093" author="haasken" created="Wed, 14 May 2014 15:40:51 +0000"  >&lt;p&gt;The b2_5 port of the patch which fixed &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-3498&quot; title=&quot;most uses of IS_ERR_VALUE() are incorrect&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-3498&quot;&gt;&lt;del&gt;LU-3498&lt;/del&gt;&lt;/a&gt; is ready to land as well:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://review.whamcloud.com/#/c/10178/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://review.whamcloud.com/#/c/10178/&lt;/a&gt;&lt;/p&gt;</comment>
                    </comments>
                    <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|hzwlif:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10090" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>13809</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>