From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/11649 Path: news.gmane.org!.POSTED!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] fix undefined behavior in ptrace Date: Tue, 4 Jul 2017 17:10:58 -0400 Message-ID: <20170704211058.GO1627@brightrain.aerifal.cx> References: <20170628132513.15483-1-amonakov@ispras.ru> <20170628151328.GD1627@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1499202676 19447 195.159.176.226 (4 Jul 2017 21:11:16 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 4 Jul 2017 21:11:16 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-11662-gllmg-musl=m.gmane.org@lists.openwall.com Tue Jul 04 23:11:11 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1dSV6B-0004kk-EX for gllmg-musl@m.gmane.org; Tue, 04 Jul 2017 23:11:07 +0200 Original-Received: (qmail 24502 invoked by uid 550); 4 Jul 2017 21:11:11 -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 24481 invoked from network); 4 Jul 2017 21:11:10 -0000 Content-Disposition: inline In-Reply-To: Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:11649 Archived-At: On Wed, Jun 28, 2017 at 06:22:12PM +0300, Alexander Monakov wrote: > On Wed, 28 Jun 2017, Rich Felker wrote: > > I think there's still UB here, reading more args than were passed. > > These calls to va_arg should probably be dependent on the particular > > req; I don't see any reason for it to be compile-time dependent on the > > presence of one particular req value. > > I raised that last year but there was no response: > http://www.openwall.com/lists/musl/2016/05/04/18 I'm sorry for overlooking it then. Could you submit a fleshed-out patch that uses that approach? Assuming the arg types are always the same, and only the number of args varies by command, a nicer approach than nested if's with a bunch of equality comparisons each might be a switch statement to map commands to # of args, then if (nargs>=1) pid = va_arg(ap, pid_t); if (nargs>=2) addr = va_arg(ap, void *); ... Thoughts? Rich