From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SUBJ_OBFU_PUNCT_FEW autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 26701 invoked from network); 3 Oct 2020 02:37:19 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 3 Oct 2020 02:37:19 -0000 Received: (qmail 11375 invoked by uid 550); 3 Oct 2020 02:37:16 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 11357 invoked from network); 3 Oct 2020 02:37:16 -0000 Date: Fri, 2 Oct 2020 22:37:03 -0400 From: Rich Felker To: musl@lists.openwall.com Cc: Static Php Message-ID: <20201003023703.GT17637@brightrain.aerifal.cx> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] runtime error: initgroups(www-data, 33) failed (5: I/O error) On Sat, Oct 03, 2020 at 09:06:50AM +0800, Static Php wrote: > I has this runtime error on Ubuntu 18.04.5 LTS, CPU is AMD EPYC Processor. > > Kernel: 5.4.0-49-generic #53~18.04.1-Ubuntu (other kernel also has this > problem) > > more details: https://github.com/richfelker/musl-cross-make/issues/107 > > strace: > > execve("./a.out", ["./a.out"], 0x7fff12cd26d0 /* 20 vars */) = 0 > > > > arch_prctl(ARCH_SET_FS, 0x7ff53bb3b618) = 0 > > > > set_tid_address(0x7ff53bb3bbe8) = 40778 > > > > socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0) = 3 > > > > brk(NULL) = 0x555556f23000 > > > > brk(0x555556f25000) = 0x555556f25000 > > > > mmap(0x555556f23000, 4096, PROT_NONE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, > > -1, 0) = 0x555556f23000 > > > > mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = > > 0x7ff53bb39000 > > > > connect(3, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 24) = 0 > > > > sendmsg(3, {msg_name=NULL, msg_namelen=0, > > msg_iov=[{iov_base="\2\0\0\0\17\0\0\0\t\0\0\0", iov_len=12}, > > {iov_base="www-data\0", iov_len=9}], msg_iovlen=2, msg_controllen=0, > > msg_flags=0}, MSG_NOSIGNAL) = 21 > > > > readv(3, [{iov_base="\2\0\0\0\1\0\0\0\0\0\0", iov_len=11}, {iov_base="\0", > > iov_len=1024}], 2) = 12 > > > > mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = > > 0x7ff53bb38000 > > > > close(3) = 0 > > > > munmap(0x7ff53bb39000, 4096) = 0 > > > > munmap(0x7ff53bb38000, 4096) = 0 > > > > ioctl(1, TIOCGWINSZ, {ws_row=59, ws_col=225, ws_xpixel=1575, > > ws_ypixel=826}) = 0 > > > > writev(1, [{iov_base="err=-1, errno=5", iov_len=15}, {iov_base="\n", > > iov_len=1}], 2err=-1, errno=5 > > > > ) = 16 > > > > exit_group(0) = ? > > > > +++ exited with 0 +++ > > Ah, this looks like a bug in musl causing a zero-groups response from nscd to be interpreted as an error rather than success with no members: if (!fread(nscdbuf, sizeof(*nscdbuf)*resp[INITGRNGRPS], 1, f)) { if (!ferror(f)) errno = EIO; goto cleanup; } The problem is that this code was written assuming the fread call returns 1 on success, but fread has a stupid corner case (which we used to get wrong) where a zero-length read is required by the standard to return 0 even though logically it should return nmemb. You can work around the problem by adding www-data to a useless dummy group. I'll prepare a patch for musl, though, and post it here as a follow-up soon. Thanks for the report! Rich