<!-- 
RSS generated by JIRA (9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c) at Sat Feb 10 02:00:55 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-6520] Potential null pointer deref in mdt_stack_init and mdt_quota_init</title>
                <link>https://jira.whamcloud.com/browse/LU-6520</link>
                <project id="10000" key="LU">Lustre</project>
                    <description>&lt;p&gt;smatch highlighted problematic code in mdt_stack_init and mdt_quota_init&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;        lcfg = lustre_cfg_new(LCFG_SETUP, bufs);
        if (lcfg == NULL)
                GOTO(class_detach, rc = -ENOMEM);
...
class_detach:
        if (rc)
                class_detach(obd, lcfg);
lcfg_cleanup:
        lustre_cfg_free(lcfg);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;note that while lustre_cfs_Free is basically kfree, which is ok to work with NULL pointers, in reality it does&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 inline void lustre_cfg_free(struct lustre_cfg *lcfg)
{
#ifdef __KERNEL__
        OBD_FREE(lcfg, lustre_cfg_len(lcfg-&amp;gt;lcfg_bufcount, lcfg-&amp;gt;lcfg_buflens));
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;which makes it not ok.&lt;/p&gt;</description>
                <environment></environment>
        <key id="29711">LU-6520</key>
            <summary>Potential null pointer deref in mdt_stack_init and mdt_quota_init</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="1" iconUrl="https://jira.whamcloud.com/images/icons/statuses/open.png" description="The issue is open and ready for the assignee to start work on it.">Open</status>
                    <statusCategory id="2" key="new" colorName="default"/>
                                    <resolution id="-1">Unresolved</resolution>
                                        <assignee username="wc-triage">WC Triage</assignee>
                                    <reporter username="green">Oleg Drokin</reporter>
                        <labels>
                    </labels>
                <created>Mon, 27 Apr 2015 05:03:50 +0000</created>
                <updated>Sun, 30 Jan 2022 10:21:44 +0000</updated>
                                            <version>Lustre 2.15.0</version>
                                                        <due></due>
                            <votes>0</votes>
                                    <watches>3</watches>
                                                                            <comments>
                            <comment id="115633" author="uvaze" created="Mon, 18 May 2015 09:01:29 +0000"  >&lt;p&gt;Hi,&lt;br/&gt;
lustre_cfg_free code is as below-&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 inline void lustre_cfg_free(struct lustre_cfg *lcfg)
{
#ifdef __KERNEL__
         OBD_FREE(lcfg, lustre_cfg_len(lcfg-&amp;gt;lcfg_bufcount, lcfg-&amp;gt;lcfg_buflens));
#else /* ! __KERNEL__ */
    free(lcfg);
#endif /* __KERNEL__ */
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;OBD_FREE  calls  OBD_FREE_PRE(ptr, size, &quot;kfreed&quot;);&lt;br/&gt;
OBD_FREE_PRE asserts the pointer.&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;#define OBD_FREE_PRE(ptr, size, name)                                   \
        LASSERT(ptr);                                                   \
        obd_memory_sub(size);                                           \
        CDEBUG(D_MALLOC, name &quot; &apos;&quot; #ptr &quot;&apos;: %d at %p.\n&quot;,               \
               (int)(size), ptr);                                       \
        POISON(ptr, 0x5a, size)
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;So this LASSERT will fail if lcfg pointer is NULL.&lt;/p&gt;

&lt;p&gt;I think this way we will get logs why memory allocation failed.&lt;br/&gt;
And it is not causing dereferencing  of NULL pointer.&lt;/p&gt;

&lt;p&gt;Having said that we can add extra check lcfg != NULL in lustre_cfg_free. But this will not give us reason of failure.&lt;/p&gt;

&lt;p&gt;-Ulka&lt;/p&gt;
</comment>
                            <comment id="121613" author="green" created="Sun, 19 Jul 2015 03:44:28 +0000"  >&lt;p&gt;The this is - if we add the check, then we&apos;ll avoid the crash and whatever the failure is, memory allocator will print us something in dmesg.&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|hzxbrj:</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>