From owner-svn-src-all@FreeBSD.ORG Mon May 5 22:20:05 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B3DADDB for ; Mon, 5 May 2014 22:20:05 +0000 (UTC) Received: from mail-pd0-f177.google.com (mail-pd0-f177.google.com [209.85.192.177]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 84F95BF8 for ; Mon, 5 May 2014 22:20:05 +0000 (UTC) Received: by mail-pd0-f177.google.com with SMTP id p10so3144018pdj.22 for ; Mon, 05 May 2014 15:19:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:content-type:mime-version:subject:from :in-reply-to:date:cc:content-transfer-encoding:message-id:references :to; bh=Evw6yi28scFhgS+JMehy9SpPct7EFvcCv7cA8GAC6ic=; b=YNWkX0BMDSpwyznHwTuixB1AX3Q+XLlTIFhrTfy06D49N028qLTC+Q+RZtqW9lbR3C 07zgUFlWAT18OCjKbbnrFrCyi2wMcjHzqd0qZuq4y9bET30f5vPWlNOWw/cU21xQWJ3o aAIXVREDGocuqaj9UJ/a9ff9KvutGsZlcweaJseGfvMGQp+tHUAuONjdl4AtxTxcru/0 f4v3u0hhrn2cGXY+SjnrCXFDjobD8lWiNMLWYqBZcq1yokn+BUq9upENYKf9pjzjPthm 4f18TIwNGEGiNFp4wq9vvnXxwnvrqCeN2R2b5JngCBd45mYSg1DRFaNatuf5bhtCai+g dAUQ== X-Gm-Message-State: ALoCoQmfhd7dh11r4wsYDzcZmek5WRIy0HNB7a9rBiPprpzj17ANAebwCGHNVL6CW+PnCsUUB86E X-Received: by 10.66.252.69 with SMTP id zq5mr77861427pac.54.1399328398860; Mon, 05 May 2014 15:19:58 -0700 (PDT) Received: from [10.64.26.239] (dc1-prod.netflix.com. [69.53.236.251]) by mx.google.com with ESMTPSA id ai11sm28636978pac.30.2014.05.05.15.19.57 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 05 May 2014 15:19:58 -0700 (PDT) Sender: Warner Losh X-Google-Original-From: Warner Losh Content-Type: text/plain; charset=iso-8859-1 Mime-Version: 1.0 (Mac OS X Mail 7.2 \(1874\)) Subject: Re: svn commit: r265367 - head/lib/libc/regex From: Warner Losh In-Reply-To: <53680C72.10809@FreeBSD.org> Date: Mon, 5 May 2014 16:19:54 -0600 Content-Transfer-Encoding: quoted-printable Message-Id: <04AFAEF4-1AF7-4310-9248-8654B1EAA560@gmail.com> References: <201405051641.s45GfFje086423@svn.freebsd.org> <5367CD77.40909@freebsd.org> <5367EB54.1080109@FreeBSD.org> <3C7CFFB7-5C84-4AC1-9A81-C718D184E87B@FreeBSD.org> <53680C72.10809@FreeBSD.org> To: Pedro Giffuni X-Mailer: Apple Mail (2.1874) Cc: svn-src-head@freebsd.org, Andrey Chernov , svn-src-all@freebsd.org, src-committers@freebsd.org, David Chisnall X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 May 2014 22:20:05 -0000 On May 5, 2014, at 4:10 PM, Pedro Giffuni wrote: > El 5/5/2014 4:21 PM, David Chisnall escribi=F3: >> On 5 May 2014, at 20:49, Pedro Giffuni wrote: >>=20 >>> Yes, but I reverted it because there are other ways to check for = overflows without the performance hit. >>=20 >=20 > FWIW, in this particular case I think the overflow simply doesn't = happen: apparently it is easier to be hit by a DoS first. >=20 >=20 >> Do we have a good reusable routine for doing this somewhere? Clang = and gcc both have some idiom recognisers that try to spot when people = are attempting to do this. Clang also has a builtin, which would be = good to use when available. Overflow checking is very cheap on modern = CPUs (add, branch on carry), so it would be nice if we could start = looking for this malloc() and realloc() pattern and replacing the = multiply with something that checks for the error. >>=20 >=20 > We don't. OpenBSD introduced an extension: reallocarray(). We do. reallocf(), which first appeared in FreeBSD 3.0. Warner