From patchwork Mon Oct 9 14:11:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 9993557 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3369B602D7 for ; Mon, 9 Oct 2017 14:14:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 25665287F8 for ; Mon, 9 Oct 2017 14:14:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 19901287FA; Mon, 9 Oct 2017 14:14:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A25FC287F8 for ; Mon, 9 Oct 2017 14:14:03 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e1YmZ-0006vs-64; Mon, 09 Oct 2017 14:11:47 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e1YmX-0006vR-WC for xen-devel@lists.xenproject.org; Mon, 09 Oct 2017 14:11:46 +0000 Received: from [85.158.139.211] by server-6.bemta-5.messagelabs.com id 20/B2-02228-1A38BD95; Mon, 09 Oct 2017 14:11:45 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupjkeJIrShJLcpLzFFi42JxWrohUndB8+1 Igz9b9S2+b5nM5MDocfjDFZYAxijWzLyk/IoE1oyrf8+zFUznqvj16wxzA+N3ji5GTg4JAX+J de8fM4LYbALKEj87e9lAbBEBPYmmA8+B4hwczAK6Eqt+aoCEhQU8JY6f/8cGEmYRUJH494wZJ MwrYCGx/sdRJoiJ8hK72i6ygpRwClhKfPjoDBIWAippbTzKDmErSHRMP8YE0SoocXLmExYQm1 lAQuLgixfMExh5ZyFJzUKSWsDItIpRozi1qCy1SNfQSC+pKDM9oyQ3MTNH19DAVC83tbg4MT0 1JzGpWC85P3cTIzBsGIBgB2PfLOdDjJIcTEqivFvrbkcK8SXlp1RmJBZnxBeV5qQWH2KU4eBQ kuCtbwLKCRalpqdWpGXmAAMYJi3BwaMkwru8ESjNW1yQmFucmQ6ROsWoy9Fx8+4fJiGWvPy8V Clx3iyQGQIgRRmleXAjYNF0iVFWSpiXEegoIZ6C1KLczBJU+VeM4hyMSsK8G0Gm8GTmlcBteg V0BBPQEYzFN0COKElESEk1MJY4+zc/yRfsN99ovfXcm8TtFqtl7TcZvl8zef8ilSpVLevZdvN MvoZUJvAV3Zlaerqmt/LI9uOKXtMTflv/qLUx+b5uyZf30Q8sL2veva2+RIVv0QTFxGW3Q38e 1cw6d1lZxFXw+ovYrebaL2eWMKVs+KInrMDVc9mtY7Hl5r/aE798/amnUqHEUpyRaKjFXFScC ACRWTkRoQIAAA== X-Env-Sender: prvs=44851d431=wei.liu2@citrix.com X-Msg-Ref: server-5.tower-206.messagelabs.com!1507558302!104527432!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 27217 invoked from network); 9 Oct 2017 14:11:44 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-5.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 9 Oct 2017 14:11:44 -0000 X-IronPort-AV: E=Sophos;i="5.42,500,1500940800"; d="scan'208";a="442995613" From: Wei Liu To: Xen-devel Date: Mon, 9 Oct 2017 15:11:18 +0100 Message-ID: <20171009141119.32595-3-wei.liu2@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171009141119.32595-1-wei.liu2@citrix.com> References: <20171009141119.32595-1-wei.liu2@citrix.com> MIME-Version: 1.0 Cc: Andrew Cooper Subject: [Xen-devel] [PATCH v2 2/3] xen/ubsan: Implement __ubsan_handle_nonnull_arg() X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Andrew Cooper This hook appears to be missing from the Linux ubsan implemention. This patch is a forward port of https://lkml.org/lkml/2014/10/20/182 Signed-off-by: Andrew Cooper Reviewed-by: Wei Liu Acked-by: Jan Beulich --- xen/common/ubsan/ubsan.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/xen/common/ubsan/ubsan.c b/xen/common/ubsan/ubsan.c index fb0409df1b..685b4de0d6 100644 --- a/xen/common/ubsan/ubsan.c +++ b/xen/common/ubsan/ubsan.c @@ -328,6 +328,25 @@ void __ubsan_handle_type_mismatch(struct type_mismatch_data *data, } EXPORT_SYMBOL(__ubsan_handle_type_mismatch); +void __ubsan_handle_nonnull_arg(struct nonnull_arg_data *data) +{ + unsigned long flags; + + if (suppress_report(&data->location)) + return; + + ubsan_prologue(&data->location, &flags); + + pr_err("null pointer passed as argument %d, declared with nonnull attribute\n", + data->arg_index); + + if (location_is_valid(&data->attr_location)) + print_source_location("nonnull attribute declared in ", + &data->attr_location); + + ubsan_epilogue(&flags); +} + void __ubsan_handle_nonnull_return(struct nonnull_return_data *data) { unsigned long flags;