From patchwork Sun Jul 17 10:34:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 72171 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp175558qga; Sun, 17 Jul 2016 03:35:08 -0700 (PDT) X-Received: by 10.98.92.65 with SMTP id q62mr37149205pfb.26.1468751706403; Sun, 17 Jul 2016 03:35:06 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id yk6si3923925pab.73.2016.07.17.03.35.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Jul 2016 03:35:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 070341A1E30; Sun, 17 Jul 2016 03:35:50 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received: from mail-wm0-x22c.google.com (mail-wm0-x22c.google.com [IPv6:2a00:1450:400c:c09::22c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 8AB2C1A1E16 for ; Sun, 17 Jul 2016 03:35:48 -0700 (PDT) Received: by mail-wm0-x22c.google.com with SMTP id f126so72752862wma.1 for ; Sun, 17 Jul 2016 03:35:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6mzda2x6xfa++gWuH553cVh41MTUOnmtSc6hxSIxUz8=; b=a1+cEeNcRFw6FZW1KfdJvHOKflfS8AZRDkegYHrQ9FMJNg8i+zddeixksM2iGW6fwA MzWvCwmBZUAqWBo0jfDx92Bu2uUGHVpgSr8koBzmJV6hIcKnMANIUGQ6XGLkfPYtrjiP 4BZ/ykPg0KxpXFvPl6biQ/rXc44DOTgLGpKIE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6mzda2x6xfa++gWuH553cVh41MTUOnmtSc6hxSIxUz8=; b=C8m/RQ3UhFFON0DX2v/1jEqpBlagZZOyLRSNVJDP1noLHQkg9e7ntZMYWaZqvDcIFP +otbUVlWjnulrypT2EnSFTJj7Sp/7mhNV/UPD2M8eBDZMqS86JzARMkg+A16hLIeWO3k XdQ0ZqZQ+LDjmbYLKsSINykkDRr9/THBQtovA2ZustWzUNvuUNztcX9KMsau5+aghgj0 3buMaAn4dXo7KKVKJ9IB5bgRLQ9v1Ky2ii/fqVjhssUlIenm3ejqToJpgGZW8WgVkEbQ mxfkf99Q0tI+0R/FP8tCiqbrS6IzYNkqYb2wW7lt4/WjgjYJkDKGQABTwl6vGgiR+Is6 nrHg== X-Gm-Message-State: ALyK8tK7Hc5sXpTAzw3Gjh10qV7tdHAM07/yB0gM6q10s/fTeO9iQklM2JZAOzXXCsFcru0y X-Received: by 10.28.185.202 with SMTP id j193mr49331895wmf.78.1468751698804; Sun, 17 Jul 2016 03:34:58 -0700 (PDT) Received: from localhost.localdomain (ip16-2-212-87.adsl2.static.versatel.nl. [87.212.2.16]) by smtp.gmail.com with ESMTPSA id d64sm7075922wmc.22.2016.07.17.03.34.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 17 Jul 2016 03:34:58 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, lersek@redhat.com, afish@apple.com, liming.gao@intel.com, steven.shi@intel.com, yonghong.zhu@intel.com, michael.d.kinney@intel.com, jordan.l.justen@intel.com Date: Sun, 17 Jul 2016 12:34:43 +0200 Message-Id: <1468751686-28047-7-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1468751686-28047-1-git-send-email-ard.biesheuvel@linaro.org> References: <1468751686-28047-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v3 6/9] MdePkg: disallow open coded varargs implementation on optimizing GCC X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: bruce@cran.org.uk, pbonzini@redhat.com, Ard Biesheuvel , ting.ye@intel.com, qin.long@intel.com MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" The open coded varargs implementation that performs pointer arithmetic on the last named parameter of a function to calculate the addresses of variadic parameters and subsequently derefences them is fragile, and break spectacularly when used under GCC with optimization enabled. So explicitly disallow this combination. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- MdePkg/Include/Base.h | 5 +++++ 1 file changed, 5 insertions(+) -- 1.9.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h index e03fa8239284..95400f993e6b 100644 --- a/MdePkg/Include/Base.h +++ b/MdePkg/Include/Base.h @@ -635,6 +635,11 @@ typedef __builtin_va_list VA_LIST; #endif #else + +#if defined(__GNUC__) && defined(__OPTIMIZE__) +#error This VA_LIST implementation is incompatible with GCC optimization +#endif + /// /// Variable used to traverse the list of arguments. This type can vary by /// implementation and could be an array or structure.