<!-- 
RSS generated by JIRA (9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c) at Sat Feb 10 02:52:00 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-12371] Odd behavior on lustre client listxattr for directories</title>
                <link>https://jira.whamcloud.com/browse/LU-12371</link>
                <project id="10000" key="LU">Lustre</project>
                    <description>&lt;blockquote&gt;
&lt;p&gt;Our backup software found an unusual result when listing xattrs for directories.&lt;/p&gt;

&lt;p&gt;On the client side, when requesting the buffer size for the list:&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;
listxattr(&lt;span class=&quot;code-quote&quot;&gt;&quot;foo&quot;&lt;/span&gt;, NULL, 0)&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;= 36 (bytes)
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;But when the list is actually read, it comes up short:&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;
listxattr(&lt;span class=&quot;code-quote&quot;&gt;&quot;foo&quot;&lt;/span&gt;, &lt;span class=&quot;code-quote&quot;&gt;&quot;trusted.link\0trusted.lma\0&quot;&lt;/span&gt;, 256) = 25 (bytes)
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;On the server side, on an ldiskfs mount, the results are more consistent.&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;
listxattr(&lt;span class=&quot;code-quote&quot;&gt;&quot;foo&quot;&lt;/span&gt;, NULL, 0)&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;= 25
listxattr(&lt;span class=&quot;code-quote&quot;&gt;&quot;foo&quot;&lt;/span&gt;, &lt;span class=&quot;code-quote&quot;&gt;&quot;trusted.lma\0trusted.link\0&quot;&lt;/span&gt;, 256) = 25
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;

&lt;p&gt;It seems like a bug in the following piece of code:&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;
ssize_t ll_listxattr(struct dentry *dentry, &lt;span class=&quot;code-object&quot;&gt;char&lt;/span&gt; *buffer, size_t size)
{

&#160; &#160; &#160; &#160; /*
&#160; &#160; &#160; &#160; &#160;* If we&apos;re being called to get the size of the xattr list
&#160; &#160; &#160; &#160; &#160;* (size == 0) then just assume that a lustre.lov xattr
&#160; &#160; &#160; &#160; &#160;* exists.
&#160; &#160; &#160; &#160; &#160;*/
&#160; &#160; &#160; &#160; &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (!size)
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; RETURN(rc + sizeof(XATTR_LUSTRE_LOV));
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This is true for regular files, but not directories (or at least not all&lt;br/&gt;
of them).&#160; As a starting point, something like the following should fix&lt;br/&gt;
the immediate problem you see:&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;
&#160; &#160; &#160; &#160; &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (!size) {
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; rc += S_ISREG(inode-&amp;gt;i_mode) ? sizeof(XATTR_LUSTRE_LOV) : 0;
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; RETURN(rc);
&#160; &#160; &#160; &#160; }
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;though it is still not wholly correct.&#160; We should go through xattr_type_filter()&lt;br/&gt;
in all cases, so that e.g. it filters out &lt;tt&gt;trusted.* xattrs&lt;/tt&gt; for regular users.&lt;br/&gt;
I guess it depends on whether one considers the returned buffer size &quot;large&lt;br/&gt;
enough to hold all xattrs&quot;, or &quot;exactly the size of the returned xattrs&quot;.&#160; The&lt;br/&gt;
latter is definitely more forgiving and could be fixed immediately in your code,&lt;br/&gt;
rather than depending on a fix to propagate into all of the installed Lustre&lt;br/&gt;
systems you are running on.&lt;/p&gt;</description>
                <environment>CentOS 6 &amp;amp; 7, Vmware workstation virtual machine test environement</environment>
        <key id="55813">LU-12371</key>
            <summary>Odd behavior on lustre client listxattr for directories</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="2">Won&apos;t Fix</resolution>
                                        <assignee username="adilger">Andreas Dilger</assignee>
                                    <reporter username="kwebb">Kristin Webb</reporter>
                        <labels>
                            <label>easy</label>
                    </labels>
                <created>Fri, 31 May 2019 21:09:30 +0000</created>
                <updated>Fri, 7 Jan 2022 20:01:54 +0000</updated>
                            <resolved>Wed, 12 Jun 2019 01:34:53 +0000</resolved>
                                    <version>Lustre 2.7.0</version>
                    <version>Lustre 2.10.8</version>
                                                        <due></due>
                            <votes>0</votes>
                                    <watches>3</watches>
                                                                            <comments>
                            <comment id="248961" author="adilger" created="Tue, 11 Jun 2019 07:18:50 +0000"  >&lt;p&gt;Kristin,&lt;br/&gt;
I looked into this code a bit further, and it isn&apos;t clear that it is practical to avoid inflating the xattr list size in this manner without adding overhead to this operation.  As it stands, returning the too-large xattr list size is trivial to execute, and is safe because at worst the buffer is allocated a few bytes larger than needed.  The proposed patch in my original comment is &lt;em&gt;mostly&lt;/em&gt; correct, but does not handle the case where a directory has a default file layout attached, so would return a &lt;b&gt;too-small&lt;/b&gt; buffer size, and likely cause the caller to be unhappy and/or corrupt memory when the list is too long (== as implemented today).&lt;/p&gt;

&lt;p&gt;Also, while the likelihood is rare, it is possible for there to be a race condition between calling &lt;tt&gt;listxattr(list=NULL)&lt;/tt&gt; to fetch the buffer size, and &lt;tt&gt;listxattr()&lt;/tt&gt; with the allocated buffer to fetch the actual xattr names.  This means that the list size may be larger or smaller than &lt;tt&gt;listxattr()&lt;/tt&gt; originally reported, so it is safer to assume that the returned buffer size is a reasonable estimate, but have retry logic in the caller if an error is returned like &lt;tt&gt;ERANGE&lt;/tt&gt; indicating the buffer is too small, and be accepting if the buffer is too large.&lt;/p&gt;</comment>
                            <comment id="248996" author="kwebb" created="Tue, 11 Jun 2019 14:46:00 +0000"  >&lt;p&gt;I agree.&#160; I also see the race condition between calls and that is something that software that manages/uses xattr&apos;s needs to be aware of.&#160; Thank you for taking a look into this.&#160; Do I need to do anything to close out the ticket?&lt;/p&gt;

&lt;p&gt;Kris&lt;/p&gt;</comment>
                            <comment id="278552" author="gerrit" created="Tue, 1 Sep 2020 20:47:00 +0000"  >&lt;p&gt;Andreas Dilger (adilger@whamcloud.com) uploaded a new patch: &lt;a href=&quot;https://review.whamcloud.com/39791&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://review.whamcloud.com/39791&lt;/a&gt;&lt;br/&gt;
Subject: &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-12371&quot; title=&quot;Odd behavior on lustre client listxattr for directories&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-12371&quot;&gt;&lt;del&gt;LU-12371&lt;/del&gt;&lt;/a&gt; llite: don&apos;t inflate listxattr for dirs&lt;br/&gt;
Project: fs/lustre-release&lt;br/&gt;
Branch: master&lt;br/&gt;
Current Patch Set: 1&lt;br/&gt;
Commit: 0b25d5d00c8e1b5131b78231a16082f61bdc1379&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Related</name>
                                                                <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_10040" key="com.atlassian.jira.plugin.system.customfieldtypes:labels">
                        <customfieldname>Epic</customfieldname>
                        <customfieldvalues>
                                        <label>client</label>
    
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10030" key="com.atlassian.jira.plugin.system.customfieldtypes:labels">
                        <customfieldname>Epic/Theme</customfieldname>
                        <customfieldvalues>
                                        <label>client</label>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_10390" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|i00hcv:</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>
                                                                                                                                                                                                                                                                                                                                                                                                                </customfields>
    </item>
</channel>
</rss>