zfs icon indicating copy to clipboard operation
zfs copied to clipboard

Fix missing semicolon in trace_dbuf.h

Open dberlin opened this issue 1 year ago • 3 comments

Motivation and Context

Missing semicolon in trace_dbuf causes compilation errors on newer kernels.

Description

On fedora 40, on the 6.9.4 kernel (in updates-testing), assign_str expands to a "do { } while(0)" loop. Without this semicolon, the while(0) is unterminated, causing a cascade of unhelpful errors (admittedly, it does identify the missing semicolon in that jumble, just not in a helpful way). With this semicolon, it compiles fine. It also compiles fine on 6.8.11 (the previous kernel). I have not tested earlier kernels than that, but at worst it should add a pointless semicolon.

Also, all other instances in the source tree are already terminated with semicolons:

include/os/linux/zfs/sys/trace_dbuf.h
64:                     __assign_str(os_spa,                            \
			spa_name(DB_DNODE(db)->dn_objset->os_spa));	\
67:                     __assign_str(os_spa, "NULL");                   \
83:             __assign_str(os_spa, "NULL")                            \

include/os/linux/zfs/sys/trace_dbgmsg.h
62:         __assign_str(msg, msg);

(This change is fixing is line 83 above)

How Has This Been Tested?

Compilation of 6.8.11 kernel module, compilation of 6.9.4 kernel module on fedora 40

Types of changes

  • [x] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Performance enhancement (non-breaking change which improves efficiency)
  • [ ] Code cleanup (non-breaking change which makes code smaller or more readable)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)
  • [ ] Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • [ ] Documentation (a change to man pages or other documentation)

Checklist:

  • [x] My code follows the OpenZFS code style requirements.
  • [x] I have updated the documentation accordingly.
  • [x] I have read the contributing document.
  • [ ] I have added tests to cover my changes.
  • [ ] I have run the ZFS Test Suite with this change applied.
  • [x] All commit messages are properly formatted and contain Signed-off-by.

dberlin avatar Jun 18 '24 15:06 dberlin

Because i was lazy and did it from the github UI, it didn't wrap the commit message properly. I'll fix it in a sec.

dberlin avatar Jun 18 '24 15:06 dberlin

while this does allow for compilation, it also exposes a lot of stringop-overread warnings for me (reading 511 bytes from a region of size 7) i'm assuming these can be safely ignored, but maybe worth looking into?

compiled on vanilla kernel.org Linux 6.9.6, in tree, using ./configure --enable-linux-builtin and ./copy-builtin

In file included from ./include/trace/define_trace.h:103,
                 from ./include/zfs/os/linux/zfs/sys/trace_dbuf.h:158,
                 from fs/zfs/os/linux/zfs/trace.c:45:
./include/zfs/os/linux/zfs/sys/trace_dbuf.h: In function ‘perf_trace_zfs_dbuf_class’:
./include/linux/fortify-string.h:110:33: warning: ‘__builtin_memcpy’ reading 511 bytes from a region of size 7 [-Wstringop-overread]
  110 | #define __underlying_memcpy     __builtin_memcpy
      |                                 ^
./include/trace/perf.h:51:11: note: in definition of macro ‘DECLARE_EVENT_CLASS’
   51 |         { assign; }                                                     \
      |           ^~~~~~
./include/zfs/os/linux/zfs/sys/trace_dbuf.h:111:9: note: in expansion of macro ‘TP_fast_assign’
  111 |         TP_fast_assign(DBUF_TP_FAST_ASSIGN),
      |         ^~~~~~~~~~~~~~
./include/linux/fortify-string.h:633:9: note: in expansion of macro ‘__underlying_memcpy’
  633 |         __underlying_##op(p, q, __fortify_size);                        \
      |         ^~~~~~~~~~~~~
./include/linux/fortify-string.h:678:26: note: in expansion of macro ‘__fortify_memcpy_chk’
  678 | #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
      |                          ^~~~~~~~~~~~~~~~~~~~
./include/trace/stages/stage6_event_callback.h:40:17: note: in expansion of macro ‘memcpy’
   40 |                 memcpy(__str__, __data_offsets.dst##_ptr_ ? :           \
      |                 ^~~~~~
./include/zfs/os/linux/zfs/sys/trace_dbuf.h:64:25: note: in expansion of macro ‘__assign_str’
   64 |                         __assign_str(os_spa,                            \
      |                         ^~~~~~~~~~~~
./include/zfs/os/linux/zfs/sys/trace_dbuf.h:111:24: note: in expansion of macro ‘DBUF_TP_FAST_ASSIGN’
  111 |         TP_fast_assign(DBUF_TP_FAST_ASSIGN),
      |                        ^~~~~~~~~~~~~~~~~~~

jcadduono avatar Jun 23 '24 18:06 jcadduono

while this does allow for compilation, it also exposes a lot of stringop-overread warnings for me (reading 511 bytes from a region of size 7) i'm assuming these can be safely ignored, but maybe worth looking into?

I assume this is also in 6.9.x?

In file included from ./include/trace/define_trace.h:103,
                 from ./include/zfs/os/linux/zfs/sys/trace_dbuf.h:158,
                 from fs/zfs/os/linux/zfs/trace.c:45:
./include/zfs/os/linux/zfs/sys/trace_dbuf.h: In function ‘perf_trace_zfs_dbuf_class’:
./include/linux/fortify-string.h:110:33: warning: ‘__builtin_memcpy’ reading 511 bytes from a region of size 7 [-Wstringop-overread]
  110 | #define __underlying_memcpy     __builtin_memcpy
      |                                 ^
./include/trace/perf.h:51:11: note: in definition of macro ‘DECLARE_EVENT_CLASS’
   51 |         { assign; }                                                     \
      |           ^~~~~~
./include/zfs/os/linux/zfs/sys/trace_dbuf.h:111:9: note: in expansion of macro ‘TP_fast_assign’
  111 |         TP_fast_assign(DBUF_TP_FAST_ASSIGN),
      |         ^~~~~~~~~~~~~~
./include/linux/fortify-string.h:633:9: note: in expansion of macro ‘__underlying_memcpy’
  633 |         __underlying_##op(p, q, __fortify_size);                        \
      |         ^~~~~~~~~~~~~
./include/linux/fortify-string.h:678:26: note: in expansion of macro ‘__fortify_memcpy_chk’
  678 | #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
      |                          ^~~~~~~~~~~~~~~~~~~~
./include/trace/stages/stage6_event_callback.h:40:17: note: in expansion of macro ‘memcpy’
   40 |                 memcpy(__str__, __data_offsets.dst##_ptr_ ? :           \
      |                 ^~~~~~
./include/zfs/os/linux/zfs/sys/trace_dbuf.h:64:25: note: in expansion of macro ‘__assign_str’
   64 |                         __assign_str(os_spa,                            \
      |                         ^~~~~~~~~~~~
./include/zfs/os/linux/zfs/sys/trace_dbuf.h:111:24: note: in expansion of macro ‘DBUF_TP_FAST_ASSIGN’
  111 |         TP_fast_assign(DBUF_TP_FAST_ASSIGN),
      |                        ^~~~~~~~~~~~~~~~~~~

Yeah, I would assume this is a flexible array member or something that isn't annotated right.

dberlin avatar Jun 23 '24 20:06 dberlin