Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle current UBSAN errors on Fedora 39 and Fedora 40 #16378

Closed
wants to merge 1 commit into from

Conversation

mcmilk
Copy link
Contributor

@mcmilk mcmilk commented Jul 22, 2024

Motivation and Context

The fixed size array sa_lengths[1] is used dynamicly and UBSAN warns about it:

[ 1110.124477] ------------[ cut here ]------------
[ 1110.126140] UBSAN: array-index-out-of-bounds in .../sa.c:766:21
[ 1110.130745] index 1 is out of range for type 'uint16_t [1]'

[ 1110.406282] UBSAN: array-index-out-of-bounds in .../sa.c:1934:29
[ 1110.411905] index 1 is out of range for type 'uint16_t [1]'

[ 1110.817251] UBSAN: array-index-out-of-bounds in .../sa.c:1734:24
[ 1110.821635] index 1 is out of range for type 'uint16_t [1]'

Description

Fix the header file and make sa_lengths variable: sa_lengths[1] -> sa_lengths[]

How Has This Been Tested?

Types of changes

  • 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:

The fixed size array sa_lengths[1] is used dynamicly and UBSAN
warns about it:

[ 1110.124477] ------------[ cut here ]------------
[ 1110.126140] UBSAN: array-index-out-of-bounds in .../sa.c:766:21
[ 1110.130745] index 1 is out of range for type 'uint16_t [1]'

[ 1110.406282] UBSAN: array-index-out-of-bounds in .../sa.c:1934:29
[ 1110.411905] index 1 is out of range for type 'uint16_t [1]'

[ 1110.817251] UBSAN: array-index-out-of-bounds in .../sa.c:1734:24
[ 1110.821635] index 1 is out of range for type 'uint16_t [1]'

Fix the header file and make sa_lengths variable:
sa_lengths[1] -> sa_lengths[]

Signed-off-by: Tino Reichardt <milky-zfs@mcmilk.de>
@mcmilk
Copy link
Contributor Author

mcmilk commented Jul 22, 2024

Test run with fix: https://github.com/mcmilk/zfs/actions/runs/10036702203
Test run without fix: https://github.com/mcmilk/zfs/actions/runs/10028261932

You see the UBSAN errors within the vm2: serial console output on Fedora 39 and Fedora 40.

@tonyhutter
Copy link
Contributor

I'd like to go with the workaround in #16380, only because sizeof(sa_hdr_phys_t) would change with this PR, and I'm paranoid that that might break something like:

static int                                                                       
sa_find_sizes(sa_os_t *sa, sa_bulk_attr_t *attr_desc, int attr_count,            
    dmu_buf_t *db, sa_buf_type_t buftype, int full_space, int *index,            
    int *total, boolean_t *will_spill)   
{
...
       hdrsize = (SA_BONUSTYPE_FROM_DB(db) == DMU_OT_ZNODE) ? 0 :                
           sizeof (sa_hdr_phys_t); 

@mcmilk
Copy link
Contributor Author

mcmilk commented Jul 22, 2024

Obsoleted by #16380

@mcmilk mcmilk closed this Jul 22, 2024
@mcmilk mcmilk deleted the fix-fedora-UBSAN-errors branch August 24, 2024 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants