From patchwork Thu Apr 6 21:18:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9668445 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 F1E6B602B3 for ; Thu, 6 Apr 2017 21:19:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 39F14285E4 for ; Thu, 6 Apr 2017 21:19:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D417285E8; Thu, 6 Apr 2017 21:19:34 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 64C22285E4 for ; Thu, 6 Apr 2017 21:19:33 +0000 (UTC) Received: (qmail 29728 invoked by uid 550); 6 Apr 2017 21:19:19 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 28578 invoked from network); 6 Apr 2017 21:19:15 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7X+rUVY/ac82K63Qv5axgU5g01cFNPlMpJvghTLTkj4=; b=SnCyK6XAIQpiLeHUwhaTFDgFkgYXVeg62XMAcMO0g6LreeVY0XHvJ9Wol61v3ZRDEm hmqI6Sj0bKoRG3dL+k0ix/NDHucuuw6yQS3yUgByg+YtK6uPKhgWYKoU7cJoPZKfr50R /LRJYG08YSwlh8TGcu9xmEo/W8gkZvR3NBLcU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7X+rUVY/ac82K63Qv5axgU5g01cFNPlMpJvghTLTkj4=; b=V2Dx0mx930vSjfYPcV7bp86z2ymbKWxIKrzovgmtK5/lTN6JVaHc6NgbvTCOg03dSD anOTttCeuFM08VHeSjURGh/bkM0Ts+hPnRsPPPz2Fr2OjOzIRXfhRqRR26pKxyWSXCpi J6r4HLWWvfeJTkS4+EoSmj8RfINcIvUOomiuGtYfzhGncpXas9TcwdNbwzTKXcx59wzP 6yxZPwEG1pYuZJBM9ZgFllNr27hF4xUPM7oQNEvlNpOP9UTm2TE3BylEnB7CzjWtIH7w M/oaQlCxZZKvfOsoHfVRZYRp888OTg3SsicnK0Eghm/mTvuU06R8LfsjezQIivEMqqMx GGzQ== X-Gm-Message-State: AFeK/H11a9oRuRubhwqk9DvpK3trZTahmvbyElcnf47cyB8y27zmgivDASr0Y/A2TS9XSi2g X-Received: by 10.84.253.15 with SMTP id z15mr45366053pll.142.1491513543950; Thu, 06 Apr 2017 14:19:03 -0700 (PDT) From: Kees Cook To: kernel-hardening@lists.openwall.com Cc: Kees Cook , Michael Leibowitz Date: Thu, 6 Apr 2017 14:18:19 -0700 Message-Id: <1491513513-84351-5-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491513513-84351-1-git-send-email-keescook@chromium.org> References: <1491513513-84351-1-git-send-email-keescook@chromium.org> Subject: [kernel-hardening] [PATCH 04/18] randstruct: Differentiate bad cast warnings X-Virus-Scanned: ClamAV using ClamSMTP This updates the bad cast warnings to be more specific about which kind of comparison failed. Signed-off-by: Kees Cook --- scripts/gcc-plugins/randomize_layout_plugin.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/gcc-plugins/randomize_layout_plugin.c b/scripts/gcc-plugins/randomize_layout_plugin.c index 6e5dccc4f221..dc03a6beb06b 100644 --- a/scripts/gcc-plugins/randomize_layout_plugin.c +++ b/scripts/gcc-plugins/randomize_layout_plugin.c @@ -668,7 +668,7 @@ static void check_bad_casts_in_constructor(tree var, tree init) if (!lookup_attribute("randomize_performed", TYPE_ATTRIBUTES(val_type))) continue; - inform(DECL_SOURCE_LOCATION(var), "found mismatched struct pointer types: %qT and %qT\n", TYPE_MAIN_VARIANT(field_type), TYPE_MAIN_VARIANT(val_type)); + inform(DECL_SOURCE_LOCATION(var), "found mismatched constructor struct pointer types: %qT and %qT\n", TYPE_MAIN_VARIANT(field_type), TYPE_MAIN_VARIANT(val_type)); } } @@ -837,7 +837,7 @@ static unsigned int find_bad_casts_execute(void) #ifndef __DEBUG_PLUGIN if (lookup_attribute("randomize_performed", TYPE_ATTRIBUTES(ptr_lhs_type))) #endif - inform(gimple_location(stmt), "found mismatched struct pointer types: %qT and %qT\n", ptr_lhs_type, ptr_rhs_type); + inform(gimple_location(stmt), "found mismatched rhs struct pointer types: %qT and %qT\n", ptr_lhs_type, ptr_rhs_type); continue; } @@ -860,7 +860,7 @@ static unsigned int find_bad_casts_execute(void) #ifndef __DEBUG_PLUGIN if (lookup_attribute("randomize_performed", TYPE_ATTRIBUTES(op0_type))) #endif - inform(gimple_location(stmt), "found mismatched struct pointer types: %qT and %qT\n", ptr_lhs_type, op0_type); + inform(gimple_location(stmt), "found mismatched op0 struct pointer types: %qT and %qT\n", ptr_lhs_type, op0_type); } else { const_tree ssa_name_var = SSA_NAME_VAR(rhs1); /* skip bogus type casts introduced by container_of */ @@ -870,7 +870,7 @@ static unsigned int find_bad_casts_execute(void) #ifndef __DEBUG_PLUGIN if (lookup_attribute("randomize_performed", TYPE_ATTRIBUTES(ptr_rhs_type))) #endif - inform(gimple_location(stmt), "found mismatched struct pointer types: %qT and %qT\n", ptr_lhs_type, ptr_rhs_type); + inform(gimple_location(stmt), "found mismatched ssa struct pointer types: %qT and %qT\n", ptr_lhs_type, ptr_rhs_type); } }