<!-- 
RSS generated by JIRA (9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c) at Sat Feb 10 01:57:54 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-6174] do_div() silently truncates divisor to uint32_t</title>
                <link>https://jira.whamcloud.com/browse/LU-6174</link>
                <project id="10000" key="LU">Lustre</project>
                    <description>&lt;p&gt;The Linux do_div() silently truncates divisor to uint32_t, even on x86_64:&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; 
25 # define do_div(n,base) ({                                      \
26         uint32_t __base = (base);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Any code that uses 64-bit divisor will end up with incorrect result whenever the higher 32 bits aren&apos;t all zero. And when the lower 32 bits are all zero, it will end up with a division by zero error.&lt;/p&gt;

&lt;p&gt;It happens on both x86_64 and i686. I&apos;ve verified it on a x86_64 VM.&lt;/p&gt;

&lt;p&gt;So any code that looks like the following is BAD:&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; 
uint64_t foo, bar;
......
if (bar != 0)
    do_div(foo, bar);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;There seemed to be plenty of such code in Lustre, e.g.:&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; 
void fld_cache_fini(struct fld_cache *cache)
        __u64 pct;
......
        if (cache-&amp;gt;fci_stat.fst_count &amp;gt; 0) {
                pct = cache-&amp;gt;fci_stat.fst_cache * 100;
                do_div(pct, cache-&amp;gt;fci_stat.fst_count);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I&apos;d suggest to go through and verify all callers of do_div(). In addition, it&apos;d be good to add a warning on do_div() in our patch checker script.&lt;/p&gt;</description>
                <environment></environment>
        <key id="28443">LU-6174</key>
            <summary>do_div() silently truncates divisor to uint32_t</summary>
                <type id="1" iconUrl="https://jira.whamcloud.com/secure/viewavatar?size=xsmall&amp;avatarId=11303&amp;avatarType=issuetype">Bug</type>
                                            <priority id="3" iconUrl="https://jira.whamcloud.com/images/icons/priorities/major.svg">Major</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="simmonsja">James A Simmons</assignee>
                                    <reporter username="isaac">Isaac Huang</reporter>
                        <labels>
                    </labels>
                <created>Thu, 29 Jan 2015 00:04:20 +0000</created>
                <updated>Wed, 25 Oct 2023 23:02:44 +0000</updated>
                            <resolved>Wed, 25 Oct 2023 23:02:44 +0000</resolved>
                                                    <fixVersion>Lustre 2.16.0</fixVersion>
                                        <due></due>
                            <votes>0</votes>
                                    <watches>7</watches>
                                                                            <comments>
                            <comment id="105400" author="green" created="Mon, 2 Feb 2015 18:59:14 +0000"  >&lt;p&gt;Did some existing bug in lustre prompted this? Is there a patch? where?&lt;/p&gt;</comment>
                            <comment id="106124" author="isaac" created="Fri, 6 Feb 2015 21:57:35 +0000"  >&lt;p&gt;I just happened to notice that the divisor was silently truncated, and grep&apos;ed through Lustre code and found a few vulnerable places. There&apos;s no existing bug as far as I know, but it does look like something that may cause us trouble in the future.&lt;/p&gt;</comment>
                            <comment id="144793" author="simmonsja" created="Mon, 7 Mar 2016 18:39:02 +0000"  >&lt;p&gt;If the divisor is u64 then the correct function to use is  div64_u64_rem() which is in math64.h. We will have to do a code audit for this.&lt;/p&gt;</comment>
                            <comment id="258260" author="gerrit" created="Wed, 13 Nov 2019 21:43:25 +0000"  >&lt;p&gt;James Simmons (jsimmons@infradead.org) uploaded a new patch: &lt;a href=&quot;https://review.whamcloud.com/36749&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://review.whamcloud.com/36749&lt;/a&gt;&lt;br/&gt;
Subject: &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-6174&quot; title=&quot;do_div() silently truncates divisor to uint32_t&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-6174&quot;&gt;&lt;del&gt;LU-6174&lt;/del&gt;&lt;/a&gt; nrs: perform proper division&lt;br/&gt;
Project: fs/lustre-release&lt;br/&gt;
Branch: master&lt;br/&gt;
Current Patch Set: 1&lt;br/&gt;
Commit: d6c660becccb9264c67055eca1dfb3046d4b53b4&lt;/p&gt;</comment>
                            <comment id="258261" author="gerrit" created="Wed, 13 Nov 2019 21:48:02 +0000"  >&lt;p&gt;James Simmons (jsimmons@infradead.org) uploaded a new patch: &lt;a href=&quot;https://review.whamcloud.com/36750&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://review.whamcloud.com/36750&lt;/a&gt;&lt;br/&gt;
Subject: &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-6174&quot; title=&quot;do_div() silently truncates divisor to uint32_t&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-6174&quot;&gt;&lt;del&gt;LU-6174&lt;/del&gt;&lt;/a&gt; osd-ldiskfs: perform proper division&lt;br/&gt;
Project: fs/lustre-release&lt;br/&gt;
Branch: master&lt;br/&gt;
Current Patch Set: 1&lt;br/&gt;
Commit: e85a22ff25f77bc1e840b979389cab16f16c7583&lt;/p&gt;</comment>
                            <comment id="258263" author="gerrit" created="Wed, 13 Nov 2019 21:58:08 +0000"  >&lt;p&gt;James Simmons (jsimmons@infradead.org) uploaded a new patch: &lt;a href=&quot;https://review.whamcloud.com/36751&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://review.whamcloud.com/36751&lt;/a&gt;&lt;br/&gt;
Subject: &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-6174&quot; title=&quot;do_div() silently truncates divisor to uint32_t&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-6174&quot;&gt;&lt;del&gt;LU-6174&lt;/del&gt;&lt;/a&gt; obd: perform proper division&lt;br/&gt;
Project: fs/lustre-release&lt;br/&gt;
Branch: master&lt;br/&gt;
Current Patch Set: 1&lt;br/&gt;
Commit: e1f43c1c33933337c0c5ed395546504f51cc7f10&lt;/p&gt;</comment>
                            <comment id="259846" author="gerrit" created="Sat, 14 Dec 2019 05:57:48 +0000"  >&lt;p&gt;Oleg Drokin (green@whamcloud.com) merged in patch &lt;a href=&quot;https://review.whamcloud.com/36751/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://review.whamcloud.com/36751/&lt;/a&gt;&lt;br/&gt;
Subject: &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-6174&quot; title=&quot;do_div() silently truncates divisor to uint32_t&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-6174&quot;&gt;&lt;del&gt;LU-6174&lt;/del&gt;&lt;/a&gt; obd: perform proper division&lt;br/&gt;
Project: fs/lustre-release&lt;br/&gt;
Branch: master&lt;br/&gt;
Current Patch Set: &lt;br/&gt;
Commit: e8f793f620f40eff540b2b49ecab00c0b9de3fc5&lt;/p&gt;</comment>
                            <comment id="265398" author="gerrit" created="Tue, 17 Mar 2020 03:40:07 +0000"  >&lt;p&gt;Oleg Drokin (green@whamcloud.com) merged in patch &lt;a href=&quot;https://review.whamcloud.com/36749/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://review.whamcloud.com/36749/&lt;/a&gt;&lt;br/&gt;
Subject: &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-6174&quot; title=&quot;do_div() silently truncates divisor to uint32_t&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-6174&quot;&gt;&lt;del&gt;LU-6174&lt;/del&gt;&lt;/a&gt; nrs: perform proper division&lt;br/&gt;
Project: fs/lustre-release&lt;br/&gt;
Branch: master&lt;br/&gt;
Current Patch Set: &lt;br/&gt;
Commit: c80319213c6dc4ac9826a1bd10c75373e08db837&lt;/p&gt;</comment>
                            <comment id="265913" author="gerrit" created="Tue, 24 Mar 2020 05:15:32 +0000"  >&lt;p&gt;Oleg Drokin (green@whamcloud.com) merged in patch &lt;a href=&quot;https://review.whamcloud.com/36750/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://review.whamcloud.com/36750/&lt;/a&gt;&lt;br/&gt;
Subject: &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-6174&quot; title=&quot;do_div() silently truncates divisor to uint32_t&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-6174&quot;&gt;&lt;del&gt;LU-6174&lt;/del&gt;&lt;/a&gt; osd-ldiskfs: perform proper division&lt;br/&gt;
Project: fs/lustre-release&lt;br/&gt;
Branch: master&lt;br/&gt;
Current Patch Set: &lt;br/&gt;
Commit: ed2c88b78c88b13f9cbcb3430909350915363ae5&lt;/p&gt;</comment>
                            <comment id="265971" author="pjones" created="Tue, 24 Mar 2020 11:32:41 +0000"  >&lt;p&gt;Seems to be complete for 2.14&lt;/p&gt;</comment>
                            <comment id="266003" author="simmonsja" created="Tue, 24 Mar 2020 13:50:40 +0000"  >&lt;p&gt;Only thing I can see left is the lov / lod handling.&lt;/p&gt;</comment>
                            <comment id="266353" author="gerrit" created="Mon, 30 Mar 2020 17:13:59 +0000"  >&lt;p&gt;James Simmons (jsimmons@infradead.org) uploaded a new patch: &lt;a href=&quot;https://review.whamcloud.com/38101&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://review.whamcloud.com/38101&lt;/a&gt;&lt;br/&gt;
Subject: &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-6174&quot; title=&quot;do_div() silently truncates divisor to uint32_t&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-6174&quot;&gt;&lt;del&gt;LU-6174&lt;/del&gt;&lt;/a&gt; lod: remove incorrect ll_do_div64&lt;br/&gt;
Project: fs/lustre-release&lt;br/&gt;
Branch: master&lt;br/&gt;
Current Patch Set: 1&lt;br/&gt;
Commit: 6883cec5d4806489d36260184bc64ed42d27689a&lt;/p&gt;</comment>
                            <comment id="266584" author="simmonsja" created="Wed, 1 Apr 2020 16:31:50 +0000"  >&lt;p&gt;Just lov layer needs to be fixed but it needs a more complex solution.&lt;/p&gt;</comment>
                            <comment id="267046" author="gerrit" created="Tue, 7 Apr 2020 17:18:29 +0000"  >&lt;p&gt;Oleg Drokin (green@whamcloud.com) merged in patch &lt;a href=&quot;https://review.whamcloud.com/38101/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://review.whamcloud.com/38101/&lt;/a&gt;&lt;br/&gt;
Subject: &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-6174&quot; title=&quot;do_div() silently truncates divisor to uint32_t&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-6174&quot;&gt;&lt;del&gt;LU-6174&lt;/del&gt;&lt;/a&gt; lod: remove incorrect ll_do_div64&lt;br/&gt;
Project: fs/lustre-release&lt;br/&gt;
Branch: master&lt;br/&gt;
Current Patch Set: &lt;br/&gt;
Commit: 12ed98d4ef294b78393bc9acb2aefd570b263855&lt;/p&gt;</comment>
                            <comment id="275256" author="gerrit" created="Mon, 13 Jul 2020 14:34:00 +0000"  >&lt;p&gt;James Simmons (jsimmons@infradead.org) uploaded a new patch: &lt;a href=&quot;https://review.whamcloud.com/39343&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://review.whamcloud.com/39343&lt;/a&gt;&lt;br/&gt;
Subject: &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-6174&quot; title=&quot;do_div() silently truncates divisor to uint32_t&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-6174&quot;&gt;&lt;del&gt;LU-6174&lt;/del&gt;&lt;/a&gt; lov: use standard Linux 64 divison macros&lt;br/&gt;
Project: fs/lustre-release&lt;br/&gt;
Branch: master&lt;br/&gt;
Current Patch Set: 1&lt;br/&gt;
Commit: cb42ed3f095bb4f7e09b7826651d47b1aaee91f9&lt;/p&gt;</comment>
                            <comment id="298182" author="adilger" created="Thu, 8 Apr 2021 03:29:28 +0000"  >&lt;p&gt;The new test_54c in patch &lt;a href=&quot;https://review.whamcloud.com/43230&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://review.whamcloud.com/43230&lt;/a&gt; &quot;&lt;tt&gt;&lt;a href=&quot;https://jira.whamcloud.com/browse/LU-8137&quot; title=&quot;fix llverdev to be able to write and verify large files in the filesystem&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-8137&quot;&gt;&lt;del&gt;LU-8137&lt;/del&gt;&lt;/a&gt; utils: fix llverdev for use on regular files&lt;/tt&gt;&quot; should exercise the &lt;tt&gt;do_div()&lt;/tt&gt; code reasonably, since it is creating a 2000-stripe file and writing at offsets over &lt;tt&gt;16TB * OST_COUNT&lt;/tt&gt;, but I don&apos;t know yet how long that test will take to run (it may need to be SLOW).&lt;/p&gt;</comment>
                            <comment id="298450" author="adilger" created="Fri, 9 Apr 2021 22:03:14 +0000"  >&lt;p&gt;It probably makes sense to further improve the &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-8137&quot; title=&quot;fix llverdev to be able to write and verify large files in the filesystem&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-8137&quot;&gt;&lt;del&gt;LU-8137&lt;/del&gt;&lt;/a&gt; test to explicitly use both small and a large file offsets (and a constant timestamp for the whole test run) with a widely-striped file (overstriped with &quot;&lt;tt&gt;&lt;del&gt;C 2000&lt;/tt&gt;&quot;) to cover critical offsets within the file (e.g. 0, 16000GB, ..., 1024 * 16000GB, 2000 * 16000GB with corresponding &lt;tt&gt;&lt;/del&gt;-size&lt;/tt&gt; values that cover the interesting region), without having to exhaustively write a huge file.  All of the writes should be done first, then the reads in a separate step, to catch cases where offsets are miscalculated and alias/modulo to a smaller offset.&lt;/p&gt;</comment>
                            <comment id="322986" author="gerrit" created="Tue, 18 Jan 2022 09:18:13 +0000"  >&lt;p&gt;&quot;Etienne AUJAMES &amp;lt;eaujames@ddn.com&amp;gt;&quot; uploaded a new patch: &lt;a href=&quot;https://review.whamcloud.com/46164&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://review.whamcloud.com/46164&lt;/a&gt;&lt;br/&gt;
Subject: &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-6174&quot; title=&quot;do_div() silently truncates divisor to uint32_t&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-6174&quot;&gt;&lt;del&gt;LU-6174&lt;/del&gt;&lt;/a&gt; nrs: perform proper division&lt;br/&gt;
Project: fs/lustre-release&lt;br/&gt;
Branch: b2_12&lt;br/&gt;
Current Patch Set: 1&lt;br/&gt;
Commit: 231695666b25f725fa7363a2f4a7d4af532a338d&lt;/p&gt;</comment>
                            <comment id="390564" author="gerrit" created="Wed, 25 Oct 2023 18:02:13 +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/+/39343/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://review.whamcloud.com/c/fs/lustre-release/+/39343/&lt;/a&gt;&lt;br/&gt;
Subject: &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-6174&quot; title=&quot;do_div() silently truncates divisor to uint32_t&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-6174&quot;&gt;&lt;del&gt;LU-6174&lt;/del&gt;&lt;/a&gt; lov: use standard Linux 64 divison macros&lt;br/&gt;
Project: fs/lustre-release&lt;br/&gt;
Branch: master&lt;br/&gt;
Current Patch Set: &lt;br/&gt;
Commit: 6eee4ea5b63e592eb3eb0cc5a91f787226a863e2&lt;/p&gt;</comment>
                            <comment id="390605" author="pjones" created="Wed, 25 Oct 2023 19:45:40 +0000"  >&lt;p&gt;Is this body of work now complete - or is more work needed?&lt;/p&gt;</comment>
                            <comment id="390645" author="simmonsja" created="Wed, 25 Oct 2023 23:02:44 +0000"  >&lt;p&gt;It is finally complete!!!!&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Related</name>
                                            <outwardlinks description="is related to ">
                                        <issuelink>
            <issuekey id="36907">LU-8137</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="47864">LU-9887</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="28414">LU-6163</issuekey>
        </issuelink>
                            </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|hzx55j:</customfieldvalue>

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