From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/9069 Path: news.gmane.org!not-for-mail From: Alexander Cherepanov Newsgroups: gmane.linux.lib.musl.general Subject: Re: string word-at-a-time and atomic.h FAQ on twitter Date: Sat, 9 Jan 2016 00:59:55 +0300 Message-ID: <5690315B.5010206@openwall.com> References: <20160105164640.GL23362@port70.net> <20160105175040.GA238@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1452290413 15919 80.91.229.3 (8 Jan 2016 22:00:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 8 Jan 2016 22:00:13 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-9082-gllmg-musl=m.gmane.org@lists.openwall.com Fri Jan 08 23:00:12 2016 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1aHf4s-0000xv-MT for gllmg-musl@m.gmane.org; Fri, 08 Jan 2016 23:00:10 +0100 Original-Received: (qmail 23764 invoked by uid 550); 8 Jan 2016 22:00:07 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 23743 invoked from network); 8 Jan 2016 22:00:07 -0000 X-Enigmail-Draft-Status: N1110 In-Reply-To: <20160105175040.GA238@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:9069 Archived-At: On 2016-01-05 20:50, Rich Felker wrote: > So we could just consider trying to drop the OOB > accesses. Do we have a list of affected functions? That might be nice > to include. I think it would be nice to have a full list of intentional UB. For example, this: http://git.musl-libc.org/cgit/musl/tree/src/stdio/vsnprintf.c#n33 if (n > (char *)0+SIZE_MAX-s-1) n = (char *)0+SIZE_MAX-s-1; If I understand the code correctly, fixing it will require changes to the FILE structure. Are there such plans? >> this takes care of oob access, but the bytes outside the passed >> object might change concurrently i.e. strlen might introduce a >> data race: again this is a problem on the abstract c language >> level that may be solved e.g. by making all accesses to those >> bytes relaxed atomic, but user code is not under libc control. >> in practice the code works if HASZERO reads the word once so it >> does arithmetics with a consistent value (because the memory >> model of the underlying machine does not treat such race >> undefined and it does not propagate unspecified value bits nor >> has trap representations). > > Indeed, this seems like less of a practical concern. HASZERO reads the word twice so this should be a problem for unoptimized code on big-endian platforms. -- Alexander Cherepanov