Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.

Bug 1318890

Summary: glibc: nss_db: long group entries are skipped
Product: Red Hat Enterprise Linux 7 Reporter: Frank Hirtz <fhirtz>
Component: glibcAssignee: Florian Weimer <fweimer>
Status: CLOSED ERRATA QA Contact: Sergey Kolosov <skolosov>
Severity: high Docs Contact:
Priority: urgent    
Version: 7.2CC: alanm, ashankar, codonell, fkrska, fweimer, mcermak, mnewsome, mpetlan, pfrankli, skolosov
Target Milestone: rcKeywords: FastFix, Patch, ZStream
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: glibc-2.17-158.el7 Doc Type: Bug Fix
Doc Text:
Cause: The nss_db Name Service Switch module fails to request larger result buffers when parsing group entries. Consequence: Group entries whose size falls into a specific range are skipped. Fix: nss_db now detects that the group list does not fit into the result buffer and requests are larger buffer. Result: Group entries in the affected size range are processed correctly.
Story Points: ---
Clone Of:
: 1321861 1388637 (view as bug list) Environment:
Last Closed: 2017-08-01 18:06:55 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1321861    
Bug Blocks: 1388637, 1390370    

Description Frank Hirtz 2016-03-18 03:59:42 UTC
Description of problem:
The client discovered this when testing with RHEL7 against a sizable groups.db file. The 'getet groups' list was truncated and was missing most entries. Florian had a look and submitted the following upstream patch which was tested to resolve the issue:

https://sourceware.org/bugzilla/show_bug.cgi?id=19837

<snip>
nss_db: No retries for some long lines with a larger buffer
_nss_db_get*ent_r returns the wrong error code if parse_line fails.  As a result, only long lines which are large enough not to fit into the caller-provided buffer result in ERANGE with NSS_STATUS_TRYAGAIN.  If parse_line detects that there is not enough room, NSS_STATUS_NOTFOUND is returned, which stops enumeration.

Patch for later reference (I will post it to libc-alpha as well):

diff --git a/nss/nss_db/db-XXX.c b/nss/nss_db/db-XXX.c
index 03c18d7..125a5e9 100644
--- a/nss/nss_db/db-XXX.c
+++ b/nss/nss_db/db-XXX.c
@@ -288,8 +288,8 @@ CONCAT(_nss_db_get,ENTNAME_r) (struct STRUCTURE *result, char *buffer,
 	    }
 	  if (err < 0)
 	    {
-	      H_ERRNO_SET (HOST_NOT_FOUND);
-	      status = NSS_STATUS_NOTFOUND;
+	      H_ERRNO_SET (NETDB_INTERNAL);
+	      status = NSS_STATUS_TRYAGAIN;
 	      break;
 	    }
</snip>

Version-Release number of selected component (if applicable):
glibc-2.17-106.el7_2.4

How reproducible:

Steps to Reproduce:
1.Have long "group" entries (many users/group) and generate/use NSS_db in nsswitch.

2. List group with "getent group"
3. Note that the listing is truncated

I can't include the client's db file unfortunately that we were using for replication, but this patch was tested and corrected the client issue.

Comment 1 Florian Weimer 2016-03-29 09:30:16 UTC
Upstream commit:

https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=a6033052d08027f745867e5e346852da1959226c

Reproducer (needs to run as root):
    
    perl -e \
      'print "large:x:999:" . join(",", map {"user$_"} (1 .. 135))."\n"' \
      >> /etc/group
    cd /var/db
    make
    getent -s db group
    
After the fix, the last command should list the "large" group.
    
The magic number 135 has been chosen so that the line is shorter than
1024 bytes, but the pointers required to encode the member array will
cross the threshold, triggering the bug.

Comment 17 errata-xmlrpc 2017-08-01 18:06:55 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2017:1916