From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0535DC4363A for ; Tue, 27 Oct 2020 10:12:36 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3DFD5206FB for ; Tue, 27 Oct 2020 10:12:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="MwRfiitN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3DFD5206FB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:35642 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kXLxy-0004CA-7h for qemu-devel@archiver.kernel.org; Tue, 27 Oct 2020 06:12:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57902) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kXLwu-0003G1-Ax for qemu-devel@nongnu.org; Tue, 27 Oct 2020 06:11:28 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:50699) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kXLwr-0004WW-Tv for qemu-devel@nongnu.org; Tue, 27 Oct 2020 06:11:27 -0400 Received: by mail-wm1-x341.google.com with SMTP id 13so791889wmf.0 for ; Tue, 27 Oct 2020 03:11:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=references:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version:content-transfer-encoding; bh=bChuqpm8371HXxABvjXwg677auScCJoJmhAUxg5huRA=; b=MwRfiitNjE6U9G3Lx8t19HjCyzrOmnAxH9/M7hwcPZx+iJzan4WpHL62UNFe2efpw0 oBt/SbNybaBkUfgFJge+fOKkOtS9Am+LfR7d/w5PcT533hE2geFloKByYTabAM4cA9v1 lx43Wd9L88i4c7dA2/Ao9yvUQeWoyskexxd4/cDr58WFEjaGGyVBH1SZVMnBi08oquH0 B8esTsN+FCFvjmwIkNCITbOVWcQpEhGwNw5mNs3GvTd6xLBmuArfrxhPQtj7yeAwn1io ya9p3/vigNwXxSLgJqufIrrpdHHNoo9MXnVBSJLeWp1k1DhMyaPQ07/FNfuVAzxry/+N CsJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:date:message-id:mime-version:content-transfer-encoding; bh=bChuqpm8371HXxABvjXwg677auScCJoJmhAUxg5huRA=; b=mCktRGKajdVkkBzee/p0PxZUqBM+LbjfRO7/cjiwcKsYaOVc34NJtYjeZl+HupIfUK mTZ80qFdN+lsSCw89TPwRTiU4xYD7A6SdPu9odJfxcSEevAeTA5D4CJ1tHpq3GWrw6Mf Z1XLlY6Mq6wtGsF5dbnhfNkFloaSMqSco82jFajDt8U7X5PhAAN3+yjXV5cUWdHCje8i AUGqTWVNRGFcmn5RdfdprcDdNbCyrsnCk/iFALHEFJmYq0yZfeK5rnWf+nDc8e60Tn13 Z1dRfdFsq8u1vX1FC5//M5jTj5wAYIj/aLNhwiQiy7KeQi0aL+tsw+mP4BeUtsVJ/5dx RzcA== X-Gm-Message-State: AOAM532uNowwcHRVuVPJEA6VGMkF2HmANZw+gaL/YqSyIiNSvQYSdsS2 5PPYrTKoKUx8qZE61H1vYLylkQ== X-Google-Smtp-Source: ABdhPJwZkZRNQKZesqXTVhp1+NIrQxXwg0q1A83J0AbB7s22UiZQMqD31teD4fU+ns7l6+nqpo+XkA== X-Received: by 2002:a1c:7f97:: with SMTP id a145mr1932892wmd.160.1603793481108; Tue, 27 Oct 2020 03:11:21 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id r3sm1364782wrm.51.2020.10.27.03.11.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Oct 2020 03:11:19 -0700 (PDT) Received: from zen (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id DF13A1FF7E; Tue, 27 Oct 2020 10:11:18 +0000 (GMT) References: <20201023200645.1055-1-dbuono@linux.vnet.ibm.com> <20201023200645.1055-5-dbuono@linux.vnet.ibm.com> User-agent: mu4e 1.5.6; emacs 28.0.50 From: Alex =?utf-8?Q?Benn=C3=A9e?= To: Daniele Buono Subject: Re: [PATCH v2 4/6] cfi: Initial support for cfi-icall in QEMU In-reply-to: <20201023200645.1055-5-dbuono@linux.vnet.ibm.com> Date: Tue, 27 Oct 2020 10:11:18 +0000 Message-ID: <874kmgf06x.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2a00:1450:4864:20::341; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x341.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , =?utf-8?Q?Daniel_P_=2E_Berrang=C3=A9?= , Stefan Weil , qemu-devel@nongnu.org, Alexander Bulekov , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Daniele Buono writes: > LLVM/Clang, supports runtime checks for forward-edge Control-Flow > Integrity (CFI). > > CFI on indirect function calls (cfi-icall) ensures that, in indirect > function calls, the function called is of the right signature for the > pointer type defined at compile time. > > For this check to work, the code must always respect the function > signature when using function pointer, the function must be defined > at compile time, and be compiled with link-time optimization. > > This rules out, for example, shared libraries that are dynamically loaded > (given that functions are not known at compile time), and code that is > dynamically generated at run-time. > > This patch: > > 1) Introduces the CONFIG_CFI flag to support cfi in QEMU > > 2) Introduces a decorator to allow the definition of "sensitive" > functions, where a non-instrumented function may be called at runtime > through a pointer. The decorator will take care of disabling cfi-icall > checks on such functions, when cfi is enabled. > > 3) Marks functions currently in QEMU that exhibit such behavior, > in particular: > - The function in TCG that calls pre-compiled TBs > - The function in TCI that interprets instructions > - Functions in the plugin infrastructures that jump to callbacks > - Functions in util that directly call a signal handler > > 4) Add a new section in MAINTAINERS with me as a maintainer for > include/qemu/sanitizers.h, in case a maintainer is deemed > necessary for this feature > > Signed-off-by: Daniele Buono > --- > MAINTAINERS | 5 +++++ > accel/tcg/cpu-exec.c | 9 +++++++++ > include/qemu/sanitizers.h | 22 ++++++++++++++++++++++ > plugins/core.c | 25 +++++++++++++++++++++++++ > plugins/loader.c | 5 +++++ With the changes Paolo suggested (QEMU_DISABLE_CFI and use compilers.h) then for the plugin bits: Acked-by: Alex Benn=C3=A9e --=20 Alex Benn=C3=A9e