Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp73824ybp; Thu, 3 Oct 2019 10:20:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqz2vtTA/KRzrb5CHhmfHU3A+eIoNCwxKF3P6U5QHIqrx9tm28b8wJ8bCI1PNj8jLFAzKf92 X-Received: by 2002:a17:906:1c05:: with SMTP id k5mr8829556ejg.286.1570123259743; Thu, 03 Oct 2019 10:20:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570123259; cv=none; d=google.com; s=arc-20160816; b=xlmPBi+WQOt+NyoVVT2panm/wl2AlwrlmZ0aE/xjeH4i0/ljWbQ45OUdrPGz/rWRYo RBr4cTwh/3MeLzhFqTpKSFjL+OxQjvz0ayXsyZ6g3WGfmpww664kzOPveSx8UGUejMP6 aSP7j5RM01BhHtU/Xmy1RM4tcIr5PrLh2LsDAtvHz2TVhGDkIDidmnf6udBL5NPd9vHF WcnoJmj1Gzqr55HPIBuPWErgMRin8teOd6QmSCPSUP1PwxnpDI3q36DkLlicrTBKE7Rv hWjl4vtS4REOl3J7GzNr1QR7szreCfA4CDELvcJ+8z2k5WAEOeikYMftgRnedxRYQoz7 +jkA== 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=MF+9TlNql1LMuP4kPJVsmeWReb/yvrG7AgVp8ugDlIJfYuW8npCzfciQygbrAsJniC upKJ10gCo+GybBo1sv9WNY8XYeMTp7w3uNLCGOLUqKGG+MpxygcOzoG+GnaJYeAeZHRD JHO6c2sxqaTd+B4FD1CIiyunuXSJOXDr7U5Jl2Lqo42NUtM4qqqo24b4YRfB2yUuOPic RJvHMZ2UaPQPU1iMEEQyqg9HFw44FNc1iS1KssSrJk1rhkYsXvU+HrrZecOQSigv+Wr5 fQQJ3+YmxiQPajKcjI1A6zOsygBryemattzM1dGJVVpEje34ZGfmSHPHzLgDaiuxE/CO 8xUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SP+uD7o4; 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 m22si1502958ejr.368.2019.10.03.10.20.34; Thu, 03 Oct 2019 10:20:59 -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=SP+uD7o4; 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 S2390374AbfJCQWr (ORCPT + 99 others); Thu, 3 Oct 2019 12:22:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:51464 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390365AbfJCQWm (ORCPT ); Thu, 3 Oct 2019 12:22:42 -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 0665D20659; Thu, 3 Oct 2019 16:22:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570119761; bh=yHF9RoZHB6Qm3RCjepEVe+GJFwIebmGSDxiefTu0FjM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SP+uD7o4NiSFowI2Qys5boR9QOdlg1D3yqE2uFRSejjSUVwDyekoPfY9iau4QGKtF zDpXCuHQXzC+VDl/UadBEZMllvghL3IQl57HiKXG0MPY5X/E6Cxy74WwxYRcMbSvz1 /U7Zqr5Tjdo5yVI1cZMHwVQhgm5PR9KVamP6J0L8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joonwon Kang , Kees Cook Subject: [PATCH 4.19 156/211] randstruct: Check member structs in is_pure_ops_struct() Date: Thu, 3 Oct 2019 17:53:42 +0200 Message-Id: <20191003154523.683939067@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003154447.010950442@linuxfoundation.org> References: <20191003154447.010950442@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; }