<!-- 
RSS generated by JIRA (9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c) at Sat Feb 10 01:22:08 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-2074] Fix &apos;copy into fixed size buffer&apos; errors</title>
                <link>https://jira.whamcloud.com/browse/LU-2074</link>
                <project id="10000" key="LU">Lustre</project>
                    <description>&lt;p&gt;Thanks to the Coverity tool, we found some &apos;security best practices violations&apos; in the Lustre code, and more specifically cases of copy into fixed size buffer.&lt;br/&gt;
This is typically where we should use strlcpy() instead of strcpy() or strlcat() instead of strcat() because the size of the source buffer is not known.&lt;/p&gt;

&lt;p&gt;I will propose a patch to address the issues.&lt;/p&gt;</description>
                <environment></environment>
        <key id="16214">LU-2074</key>
            <summary>Fix &apos;copy into fixed size buffer&apos; errors</summary>
                <type id="7" iconUrl="https://jira.whamcloud.com/images/icons/issuetypes/task_agile.png">Technical task</type>
                            <parent id="17451">LU-2753</parent>
                                    <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="keith">Keith Mannthey</assignee>
                                    <reporter username="sebastien.buisson">Sebastien Buisson</reporter>
                        <labels>
                            <label>build</label>
                            <label>coverity</label>
                            <label>ptr</label>
                    </labels>
                <created>Tue, 2 Oct 2012 10:44:02 +0000</created>
                <updated>Tue, 1 Oct 2013 13:58:55 +0000</updated>
                            <resolved>Tue, 1 Oct 2013 13:58:55 +0000</resolved>
                                    <version>Lustre 2.4.0</version>
                    <version>Lustre 2.1.3</version>
                                    <fixVersion>Lustre 2.5.0</fixVersion>
                                        <due></due>
                            <votes>0</votes>
                                    <watches>5</watches>
                                                                            <comments>
                            <comment id="45861" author="sebastien.buisson" created="Tue, 2 Oct 2012 10:56:46 +0000"  >&lt;p&gt;The patch is available here:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://review.whamcloud.com/4154&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://review.whamcloud.com/4154&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Could you please review it?&lt;/p&gt;</comment>
                            <comment id="45880" author="keith" created="Tue, 2 Oct 2012 13:39:34 +0000"  >&lt;p&gt;I will take a look at it. &lt;/p&gt;</comment>
                            <comment id="46678" author="keith" created="Wed, 17 Oct 2012 12:52:37 +0000"  >&lt;p&gt;Sabastien as per our discussion in review. &lt;/p&gt;

&lt;p&gt;I will look in the compilation issue.  Lustre has both kernel and userspace context I will look around and see what the issue is.  &lt;/p&gt;


&lt;p&gt;Is it safe to say that:&lt;br/&gt;
In general the spots that Coverity found have unsafe data types where the receiving buffer may be smaller then the sending buffer? I agree char * can be vague. As mentioned some spots are safe and not identified by the tool and we are protecting against overflows where we will go and trample on neighboring data.  What this patch seems to be attempting to do is truncate the message down to the receiving message size. &lt;/p&gt;

&lt;p&gt;What happens when a message does get truncated?  Likely a user of the data will have a random failure as the data is incomplete. Some data is lost.  I would agree that truncation is better than overflow and random corruption. It seems there is at least a 3rd option which is audit and see if some of these tricky situations can be resolved through fundamental code changes and tricky spots add level of checking and add E2BIG errors when we will truncate.  If we stop fitting into the receiving buffers I would rather we raise an error and stop than continue on with only part of the data.&lt;/p&gt;

&lt;p&gt;Does this seem reasonable? &lt;/p&gt;</comment>
                            <comment id="46709" author="sebastien.buisson" created="Thu, 18 Oct 2012 03:49:36 +0000"  >&lt;p&gt;The initial purpose of the patch was to avoid some buffer overflow issues found by Coverity. But I agree we could try to detect cases of truncation, and return an E2BIG error instead of continuing with partial data.&lt;br/&gt;
Hopefully strlcpy() and strlcat() make truncation detection easy. Please tell me if you can find out what is going on with the compilation issue.&lt;/p&gt;

&lt;p&gt;Cheers,&lt;br/&gt;
Sebastien.&lt;/p&gt;</comment>
                            <comment id="51165" author="keith" created="Thu, 24 Jan 2013 20:25:05 +0000"  >&lt;p&gt;This issue is blocked on a build issue. &lt;br/&gt;
&lt;a href=&quot;http://jira.whamcloud.com/browse/LU-2662&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;http://jira.whamcloud.com/browse/LU-2662&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="62851" author="dmiter" created="Tue, 23 Jul 2013 21:31:46 +0000"  >&lt;p&gt;The usage of strlcpy function brings additionally dependencies to userspace binaries. The following patch is required to build without error. I think it&apos;s a bad idea to use this function and add additional dependencies.&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;diff --git a/lnet/utils/Makefile.am b/lnet/utils/Makefile.am
index f11a21a..6c01d7a 100644
--- a/lnet/utils/Makefile.am
+++ b/lnet/utils/Makefile.am
@@ -70,17 +70,17 @@ endif
 wirecheck_SOURCES = wirecheck.c
 
 ptlctl_SOURCES = ptlctl.c
-ptlctl_LDADD =  -L. -lptlctl $(LIBCFSUTIL) $(LIBCFS) $(LIBREADLINE) $(LIBEFENCE)
+ptlctl_LDADD =  -L. -lptlctl $(LIBCFSUTIL) $(LIBCFS) $(LIBREADLINE) $(LIBEFENCE) $(PTHREAD_LIBS)
 ptlctl_DEPENDENCIES = libptlctl.a
 
 routerstat_SOURCES = routerstat.c
 
 debugctl_SOURCES = debugctl.c
-debugctl_LDADD = -L. -lptlctl $(LIBCFSUTIL) $(LIBREADLINE) $(LIBEFENCE)
+debugctl_LDADD = -L. -lptlctl $(LIBCFSUTIL) $(LIBCFS) $(LIBREADLINE) $(LIBEFENCE) $(PTHREAD_LIBS)
 debugctl_DEPENDENCIES = libptlctl.a
 
 lst_SOURCES = lst.c
-lst_LDADD = -L. -lptlctl $(LIBCFSUTIL) $(LIBCFS) $(LIBREADLINE) $(LIBEFENCE)
+lst_LDADD = -L. -lptlctl $(LIBCFSUTIL) $(LIBCFS) $(LIBREADLINE) $(LIBEFENCE) $(PTHREAD_LIBS)
 lst_DEPENDENCIES = libptlctl.a
 
 LND_LIBS =

diff --git a/lustre/utils/Makefile.am b/lustre/utils/Makefile.am
index 23bde35..a500d67 100644
--- a/lustre/utils/Makefile.am
+++ b/lustre/utils/Makefile.am
@@ -58,7 +58,7 @@ lustre_rsync_LDADD :=  liblustreapi.a $(LIBPTLCTL) $(PTHREAD_LIBS) $(LIBREADLINE
 lustre_rsync_DEPENDENCIES := $(LIBPTLCTL) liblustreapi.a
 
 ll_recover_lost_found_objs_SOURCES = ll_recover_lost_found_objs.c
-ll_recover_lost_found_objs_LDADD := $(LIBPTLCTL)
+ll_recover_lost_found_objs_LDADD := $(LIBPTLCTL) $(PTHREAD_LIBS)
 ll_recover_lost_found_objs_DEPENDENCIES := $(LIBPTLCTL)
 
 lshowmount_SOURCES = lshowmount.c nidlist.c nidlist.h
@@ -118,14 +118,14 @@ obdbarrier_SOURCES = obdbarrier.c obdiolib.c obdiolib.h
 req_layout_SOURCES = req-layout.c
 
 llog_reader_SOURCES = llog_reader.c
-llog_reader_LDADD := $(LIBPTLCTL)
+llog_reader_LDADD := $(LIBPTLCTL) $(PTHREAD_LIBS)
 llog_reader_DEPENDENCIES := $(LIBPTLCTL)
 
 lr_reader_SOURCES = lr_reader.c
 
 mount_lustre_SOURCES = mount_lustre.c mount_utils.c mount_utils.h
 mount_lustre_CPPFLAGS = $(AM_CPPFLAGS)
-mount_lustre_LDADD := $(LIBPTLCTL)
+mount_lustre_LDADD := $(LIBPTLCTL) $(PTHREAD_LIBS)
 mount_lustre_DEPENDENCIES := $(LIBPTLCTL)
 if LDISKFS_ENABLED
 mount_lustre_SOURCES += mount_utils_ldiskfs.c
@@ -139,7 +139,7 @@ endif
 
 mkfs_lustre_SOURCES = mkfs_lustre.c mount_utils.c mount_utils.h
 mkfs_lustre_CPPFLAGS = -UTUNEFS $(AM_CPPFLAGS)
-mkfs_lustre_LDADD := $(LIBPTLCTL)
+mkfs_lustre_LDADD := $(LIBPTLCTL) $(PTHREAD_LIBS)
 mkfs_lustre_DEPENDENCIES := $(LIBPTLCTL)
 if LDISKFS_ENABLED
 mkfs_lustre_SOURCES += mount_utils_ldiskfs.c
@@ -168,10 +168,12 @@ tunefs_lustre_LDFLAGS = -pthread -rdynamic -ldl
 endif
 
 l_getidentity_SOURCES = l_getidentity.c
-l_getidentity_LDADD := $(LIBPTLCTL)
+l_getidentity_LDADD := $(LIBPTLCTL) $(PTHREAD_LIBS)
 l_getidentity_DEPENDENCIES := $(LIBPTLCTL)
 
 ltrack_stats_SOURCES = ltrack_stats.c
+ltrack_stats_LDADD := $(LIBPTLCTL) $(PTHREAD_LIBS)
+ltrack_stats_DEPENDENCIES := $(LIBPTLCTL)
 
 EXTRA_DIST = $(sbin_scripts) $(bin_scripts)
 
diff --git a/lustre/utils/ltrack_stats.c b/lustre/utils/ltrack_stats.c
index eed0fcc..de5a3d6 100644
--- a/lustre/utils/ltrack_stats.c
+++ b/lustre/utils/ltrack_stats.c
@@ -45,7 +45,9 @@
 #include &amp;lt;signal.h&amp;gt;
 #include &amp;lt;string.h&amp;gt;
 #include &amp;lt;stdlib.h&amp;gt;
+#include &amp;lt;errno.h&amp;gt;
 
+extern size_t strlcpy(char *dst, const char *src, size_t len);
 
 #define TRACK_BY_GID 0
 #define TRACK_BY_PPID 1
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                            <comment id="62862" author="keith" created="Tue, 23 Jul 2013 23:14:55 +0000"  >&lt;p&gt;Dmitry,  Can you confirm that patch works for lbuild and this 2074 patch?&lt;br/&gt;
I have been able to build local before just not in the lbuild/autotest framework.  &lt;/p&gt;</comment>
                            <comment id="62920" author="dmiter" created="Wed, 24 Jul 2013 18:54:08 +0000"  >&lt;p&gt;Patch Set 16: Verified&lt;br/&gt;
Build Successful &lt;br/&gt;
&lt;a href=&quot;http://build.whamcloud.com/job/lustre-reviews/16913/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://build.whamcloud.com/job/lustre-reviews/16913/&lt;/a&gt; : SUCCESS&lt;/p&gt;</comment>
                            <comment id="68045" author="pjones" created="Tue, 1 Oct 2013 13:58:55 +0000"  >&lt;p&gt;Landed for 2.5.0&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|hzv4wn:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10090" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>4328</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                </customfields>
    </item>
</channel>
</rss>