Uploaded image for project: 'Lustre'
  1. Lustre
  2. LU-15798

RHEL9 / gcc-11 adds -Wstringop-overread false warnings

Details

    • Improvement
    • Resolution: Fixed
    • Minor
    • None
    • None
    • None
    • 9223372036854775807

    Description

      gcc-11 stringop-overread reports a false positive on
      changelog record name.

      Use _Pragma to exclude the diagnostic for this case.

      Attachments

        Issue Links

          Activity

            [LU-15798] RHEL9 / gcc-11 adds -Wstringop-overread false warnings

            All patches landed.

            simmonsja James A Simmons added a comment - All patches landed.
            xinliang Xinliang Liu added a comment - This issue can be fixed by patch: https://review.whamcloud.com/c/fs/lustre-release/+/53624

            "xinliang <xinliang.liu@linaro.org>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/53685
            Subject: LU-15798 build: fix gcc-11 -Wstringop-overread warnings
            Project: fs/lustre-release
            Branch: master
            Current Patch Set: 1
            Commit: d14dc3ce31e06bacdb79e2c2457b65669c554358

            gerrit Gerrit Updater added a comment - "xinliang <xinliang.liu@linaro.org>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/53685 Subject: LU-15798 build: fix gcc-11 -Wstringop-overread warnings Project: fs/lustre-release Branch: master Current Patch Set: 1 Commit: d14dc3ce31e06bacdb79e2c2457b65669c554358
            xinliang Xinliang Liu added a comment -

            Find that the below commit breaks the compiling on rhel9.2.

            efc5c8d4de60 LU-16335 build: remove _GNU_SOURCE dependency in lustre_user.h

            ~/work/lustre/lustre-release$ git log -p efc5c8d4de60 --  lustre//include/uapi/linux/lustre/lustre_user.h
            Author: Lai Siyao <lai.siyao@whamcloud.com>
            Date:   Thu Dec 1 03:17:00 2022 -0500
            
            
                LU-16335 build: remove _GNU_SOURCE dependency in lustre_user.h
                
                The lustre_user.h header uses the non-standard strchrnul() function
                in userspace.  This will always leads to LC_IOC_REMOVE_ENTRY configure
                check to fail, and in the end "lfs rm_entry" always returns -ENOTSUP.
                
                Implement an alternative approach to avoid external dependencies on
                the lustre_user.h header.  Also, LC_IOC_REMOVE_ENTRY is itself
                unnecessary, the code can check for LL_IOC_REMOVE_ENTRY directly.
                
                Replace the NFS-specific -ENOTSUP error return code with -EOPNOTSUPP.
                
                Fix the compile test_400[ab] checks to not use "-std=c99" to verify
                that the uapi headers are usable without this dependency.
                
            ...
            diff --git a/lustre/include/uapi/linux/lustre/lustre_user.h b/lustre/include/uapi/linux/lustre/lustre_user.h
            index 1b1e60acf805..36e1e70b9224 100644
            --- a/lustre/include/uapi/linux/lustre/lustre_user.h
            +++ b/lustre/include/uapi/linux/lustre/lustre_user.h
            @@ -2033,7 +2033,11 @@ static inline char *changelog_rec_name(const struct changelog_rec *rec)
             
             static inline char *changelog_rec_sname(const struct changelog_rec *rec)
             {
            -       return strchrnul(changelog_rec_name(rec), '\0') + 1;
            +       char *str = changelog_rec_name(rec);
            +
            +       while (*str != '\0')
            +               str++;
            +       return str + 1;
             }
              
            xinliang Xinliang Liu added a comment - Find that the below commit breaks the compiling on rhel9.2. efc5c8d4de60 LU-16335 build: remove _GNU_SOURCE dependency in lustre_user.h ~/work/lustre/lustre-release$ git log -p efc5c8d4de60 --  lustre //include/uapi/linux/lustre/lustre_user.h Author: Lai Siyao <lai.siyao@whamcloud.com> Date:   Thu Dec 1 03:17:00 2022 -0500     LU-16335 build: remove _GNU_SOURCE dependency in lustre_user.h          The lustre_user.h header uses the non-standard strchrnul() function     in userspace.  This will always leads to LC_IOC_REMOVE_ENTRY configure     check to fail, and in the end "lfs rm_entry" always returns -ENOTSUP.          Implement an alternative approach to avoid external dependencies on     the lustre_user.h header.  Also, LC_IOC_REMOVE_ENTRY is itself     unnecessary, the code can check for LL_IOC_REMOVE_ENTRY directly.          Replace the NFS-specific -ENOTSUP error return code with -EOPNOTSUPP.          Fix the compile test_400[ab] checks to not use "-std=c99" to verify     that the uapi headers are usable without this dependency.      ... diff --git a/lustre/include/uapi/linux/lustre/lustre_user.h b/lustre/include/uapi/linux/lustre/lustre_user.h index 1b1e60acf805..36e1e70b9224 100644 --- a/lustre/include/uapi/linux/lustre/lustre_user.h +++ b/lustre/include/uapi/linux/lustre/lustre_user.h @@ -2033,7 +2033,11 @@ static inline char *changelog_rec_name( const struct changelog_rec *rec) static inline char *changelog_rec_sname( const struct changelog_rec *rec) { -       return strchrnul(changelog_rec_name(rec), '\0' ) + 1; +       char *str = changelog_rec_name(rec); + +       while (*str != '\0' ) +               str++; +       return str + 1; }
            xinliang Xinliang Liu added a comment -

            Thanks, stancheff for the info, it seems an Aarch64 specific issue.

            xinliang Xinliang Liu added a comment - Thanks, stancheff  for the info, it seems an Aarch64 specific issue.

            Yes, make and make rpms both work.

            With gcc-12 I do see a few issues with configure and with compiling:

            In function ‘strnlen’,
                inlined from ‘lov_iocontrol’ at /home/shaun/lustre-release/lustre/lov/lov_obd.c:1079:4:
            include/linux/fortify-string.h:23:34: error: array subscript 112 is outside array bounds of ‘void[112]’ [-Werror=array-bounds]
               23 |             __builtin_constant_p(*__p)) {                       \
                  |                                  ^~~~
            include/linux/fortify-string.h:141:24: note: in expansion of macro ‘__compiletime_strlen’
              141 |         size_t p_len = __compiletime_strlen(p);
                  |                        ^~~~~~~~~~~~~~~~~~~~
            In file included from include/linux/fs.h:44,
                             from /home/shaun/lustre-release/libcfs/include/libcfs/linux/linux-misc.h:35,
                             from /home/shaun/lustre-release/libcfs/include/libcfs/libcfs.h:43:
            In function ‘kmalloc’,
                inlined from ‘lov_iocontrol’ at /home/shaun/lustre-release/lustre/lov/lov_obd.c:1072:3:
            include/linux/slab.h:611:24: note: at offset 112 into object of size 112 allocated by ‘kmem_cache_alloc_trace’
              611 |                 return kmem_cache_alloc_trace(
                  |                        ^~~~~~~~~~~~~~~~~~~~~~~
              612 |                                 kmalloc_caches[kmalloc_type(flags)][index],
                  |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              613 |                                 flags, size);
                  |                                 ~~~~~~~~~~~~
            cc1: all warnings being treated as errors
            
            stancheff Shaun Tancheff added a comment - Yes, make and make rpms both work. With gcc-12 I do see a few issues with configure and with compiling: In function ‘strnlen’, inlined from ‘lov_iocontrol’ at /home/shaun/lustre-release/lustre/lov/lov_obd.c:1079:4: include/linux/fortify-string.h:23:34: error: array subscript 112 is outside array bounds of ‘void[112]’ [-Werror=array-bounds] 23 | __builtin_constant_p(*__p)) { \ | ^~~~ include/linux/fortify-string.h:141:24: note: in expansion of macro ‘__compiletime_strlen’ 141 | size_t p_len = __compiletime_strlen(p); | ^~~~~~~~~~~~~~~~~~~~ In file included from include/linux/fs.h:44, from /home/shaun/lustre-release/libcfs/include/libcfs/linux/linux-misc.h:35, from /home/shaun/lustre-release/libcfs/include/libcfs/libcfs.h:43: In function ‘kmalloc’, inlined from ‘lov_iocontrol’ at /home/shaun/lustre-release/lustre/lov/lov_obd.c:1072:3: include/linux/slab.h:611:24: note: at offset 112 into object of size 112 allocated by ‘kmem_cache_alloc_trace’ 611 | return kmem_cache_alloc_trace( | ^~~~~~~~~~~~~~~~~~~~~~~ 612 | kmalloc_caches[kmalloc_type(flags)][index], | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 613 | flags, size); | ~~~~~~~~~~~~ cc1: all warnings being treated as errors
            xinliang Xinliang Liu added a comment - - edited

            @stancheff have tried make rpms? Just make no compile error.

            xinliang Xinliang Liu added a comment - - edited @ stancheff have tried make rpms? Just make no compile error.
            xinliang Xinliang Liu added a comment -

            Yes, it is aarch64.

            xinliang Xinliang Liu added a comment - Yes, it is aarch64.

            Strange that I do not see this on x86_64 ... it this aarch64?

            stancheff Shaun Tancheff added a comment - Strange that I do not see this on x86_64 ... it this aarch64?
            xinliang Xinliang Liu added a comment -

            This issue still exists on rhel9.2:

            /tmp/rpmbuild-lustre-jenkins-SCTCWlBO/BUILD/lustre-2.15.58_59_g2ddb1d3_dirty/lustre/include/uapi/linux/lustre/lustre_user.h:2095:16: error: 'strlen' reading 1 or more bytes from a region of size 0 [-Werror=stringop-overread]
             2095 |         return strlen(changelog_rec_sname(rec));
                  |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
            xinliang Xinliang Liu added a comment - This issue still exists on rhel9.2: /tmp/rpmbuild-lustre-jenkins-SCTCWlBO/BUILD/lustre-2.15.58_59_g2ddb1d3_dirty/lustre/include/uapi/linux/lustre/lustre_user.h:2095:16: error: 'strlen' reading 1 or more bytes from a region of size 0 [-Werror=stringop-overread] 2095 | return strlen(changelog_rec_sname(rec)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

            People

              stancheff Shaun Tancheff
              stancheff Shaun Tancheff
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: