Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp62058ybp; Thu, 3 Oct 2019 10:11:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqwa7OfL1dXpznpZVeXtZtbysqIavH0GUN0Ljwf8frbUFaGteS3bCQmnqNRH12LZgkd+CySP X-Received: by 2002:a17:906:3281:: with SMTP id 1mr8713866ejw.181.1570122692432; Thu, 03 Oct 2019 10:11:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570122692; cv=none; d=google.com; s=arc-20160816; b=GOVU1PQSyreFWzo9NU1oc07eSM9nWXQxpyiSN0sErxUqQ077bEU9bUqeWpXTAnED19 b34JQ+G05HQU5/40J4r41fgMN2aZRM4QFMFyc/9k/n63YB/yOA0RzQ5yVhwADUpmgbFt sldnOI+4PHG0m93ThAnM7ZDFwXlOGASw90AjK4EhjtGkKYtiLZDesSdObbFxPUaZ366J QYWDvE442OGp/8LfCXIqswHacTNP8eiHGxiHafnL3/g0REwrRRftsRJBGRWraoU2zBYG 1/3GkGjACJZE6jaZ5CKdYGEgHp1cei1JgwByt7NlARh0fjJvVdUqEHmPwpEHo+7Pz5iA qBHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WVhM7zZf/4jiUdrS5fFFQrOw2Ua+IMqTRYVVYr8ysxI=; b=hau/EeGUMB1cjFj3Mm8BmV+dWk7qVKQW/HAjFVMH1oSMkskVQcRKW9lGyQI4l65/0u LSzwosvo0yPbSK3+60lcsorIesDdl9l/tpiwIfIPkPTfIpJAjeRkw9/Gf30QyjcZiQdL ygBSjBL1AY7dgwGYA3fqickSzkg5hKvuWW5L9dc2NfE8lslY2/ByPQD8CY6f6fH+HxRm nAO37lsuFrCa1+HXXBA+9hPgSjCdUgay1EX7orMeTG+jGZ9c4wqsmD2lsW1m9WBjODdy AdXd4klprpMq4DFz0f16U2WR42zvAWRbUWWMmWn08Q41bM77hJMSyBvw19qNbB3S6ego 0eYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0wAxpSxg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id oz19si1563044ejb.93.2019.10.03.10.11.07; Thu, 03 Oct 2019 10:11:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0wAxpSxg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2393376AbfJCRJd (ORCPT + 99 others); Thu, 3 Oct 2019 13:09:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:42410 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404120AbfJCQeG (ORCPT ); Thu, 3 Oct 2019 12:34:06 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BD143222CD; Thu, 3 Oct 2019 16:34:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570120446; bh=yHF9RoZHB6Qm3RCjepEVe+GJFwIebmGSDxiefTu0FjM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0wAxpSxgVR3USm/qzWJwWhz5EEk/MF0Y1MKFLkNR5d4IPcr65VRxuDZrTzGI5iNGD j7eR1u/HgdDJQdhsZC0U5g+ZgolrYzBDIS90oxU4lbjjjBBxiEeqtCpQU1XD97Mmkq dtlOSOzRbnAKLOPA5lB7Tx9/e5mffrarHm2gaR0o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joonwon Kang , Kees Cook Subject: [PATCH 5.2 225/313] randstruct: Check member structs in is_pure_ops_struct() Date: Thu, 3 Oct 2019 17:53:23 +0200 Message-Id: <20191003154555.184833719@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003154533.590915454@linuxfoundation.org> References: <20191003154533.590915454@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joonwon Kang commit 60f2c82ed20bde57c362e66f796cf9e0e38a6dbb upstream. While no uses in the kernel triggered this case, it was possible to have a false negative where a struct contains other structs which contain only function pointers because of unreachable code in is_pure_ops_struct(). Signed-off-by: Joonwon Kang Link: https://lore.kernel.org/r/20190727155841.GA13586@host Fixes: 313dd1b62921 ("gcc-plugins: Add the randstruct plugin") Cc: stable@vger.kernel.org Signed-off-by: Kees Cook Signed-off-by: Greg Kroah-Hartman --- scripts/gcc-plugins/randomize_layout_plugin.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) --- a/scripts/gcc-plugins/randomize_layout_plugin.c +++ b/scripts/gcc-plugins/randomize_layout_plugin.c @@ -443,13 +443,13 @@ static int is_pure_ops_struct(const_tree if (node == fieldtype) continue; - if (!is_fptr(fieldtype)) - return 0; - - if (code != RECORD_TYPE && code != UNION_TYPE) + if (code == RECORD_TYPE || code == UNION_TYPE) { + if (!is_pure_ops_struct(fieldtype)) + return 0; continue; + } - if (!is_pure_ops_struct(fieldtype)) + if (!is_fptr(fieldtype)) return 0; }