Bug 1470124 - _nl_load_locale_from_archive SIGFPE divide by zero
_nl_load_locale_from_archive SIGFPE divide by zero
Status: NEW
Product: Fedora
Classification: Fedora
Component: glibc (Show other bugs)
x86_64 Linux
unspecified Severity unspecified
: ---
: ---
Assigned To: Carlos O'Donell
Fedora Extras Quality Assurance
Depends On:
  Show dependency treegraph
Reported: 2017-07-12 08:21 EDT by John Reiser
Modified: 2017-11-19 21:57 EST (History)
8 users (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description John Reiser 2017-07-12 08:21:20 EDT
Description of problem: _nl_load_locale_from_archive defends incompletely against dividing by zero.

Version-Release number of selected component (if applicable):

How reproducible: every time (if particular corruption in locale archive)

Steps to Reproduce:
1. Inspect code for _nl_load_locale_from_archive()

Actual results: In glibc-2.24-59-g86ac4a7/locale/loadarchive.c near lines 277 through 282:
  /* Avoid division by 0 if the file is corrupted.  */
  if (__glibc_unlikely (head->namehash_size == 0))
    goto close_and_out;

  idx = hval % head->namehash_size;
  incr = 1 + hval % (head->namehash_size - 2);

The check defends against dividing by zero in the first modulo operation ('%') but not the second (on the next line).  The check should be expanded to "head->namehash_size <= 2".

The declaration in locarchive.h is
  uint32_t namehash_size;
It seems to me that some heuristic such as (namehash_size >= (0xful << 28)) also is appropriate, to detect extremely unlikely large values [in this case 4,026,531,840 and larger].

Expected results:  Correct defense against dividing by zero in all modulo operations ('%' operator).

Additional info:
Comment 1 Florian Weimer 2017-07-12 08:27:37 EDT
Out of curiosity, how did you encounter this bug?
Comment 2 John Reiser 2017-07-12 08:56:30 EDT
(In reply to Florian Weimer from comment #1)
> Out of curiosity, how did you encounter this bug?

A side effect of investigating https://bugzilla.redhat.com/show_bug.cgi?id=1468778
Comment 3 Fedora End Of Life 2017-11-16 13:37:32 EST
This message is a reminder that Fedora 25 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 25. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '25'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 25 is end of life. If you would still like
to see this bug fixed and are able to reproduce it against a later version
of Fedora, you are encouraged  change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.
Comment 4 John Reiser 2017-11-19 21:57:53 EST
The problem persists in
which is the source for

Note You need to log in before you can comment on or make changes to this bug.