Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1733961pxb; Thu, 16 Sep 2021 14:17:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzF0lpHHmz6lP1c93m8f6bAcasDrU/Cc/Vyzs+RMnwm5afq7qFEbv4C5/ci5siClG4fCrqh X-Received: by 2002:a05:6e02:486:: with SMTP id b6mr5518371ils.163.1631827074291; Thu, 16 Sep 2021 14:17:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631827074; cv=none; d=google.com; s=arc-20160816; b=APffTsQcSDbHafbqnGGbqrusWmodtT8sfeiHpa5vkjuzMrA4JkLkxxEcj8NmIphTuj 3qCt8uQmR1NfZv7Kcl+Nx1hlSjTKS9RcPSRVmk12sszWIoF6cKQS7IfMtRqkjOY0Hp6S G5saB9DUuNYYQctNP2moyey6qozTGlkxUXgiMxWxkuY1iPWbXmWJcZr1Gy9trT0jW9U3 Sy5XZFogeIPru6ddvOepE8lFagKeaS2vlUeK6IXdPTedF8JAnE9mCEMUZBMuQ76wxmwR oNcTN/zv+RRcb4hmqMFppooQBP8GX+ipcJosFlwSu/SnjgbmTn008LaHm+ZIR1ptn1Wz 78Jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Rs1uBcnI37rFhqe/G18Rxw7DxbiyfPBO9nnfhnx1cpo=; b=0W+50fZZVuz0dh/Wj5Bb7qpCMarBw0aLUMWpdZ0RK+nj7V6+l0Ey/7vLbUnKLrSWeh jhlL3VkxpEALNcTgixzAIFapuKkqbKDtf7t3p3QLqR17KImnlL7lXOC7aacJNIAnzdiw PQUt+Dd8YEllgRXTtkqow9wktE2AgBWP7cvj3ESOzZ4h9OghR3St8rYWphSa8qv6gTg4 67KhWYVF3E7sIfUN3ycE0RKsdnFCQCqIwn64Tn5FrLGXbPqMR3uQqs5V18j8kPduP2bv HOUVSO58/bW1TQyMaCvMK9qc4d3DqR0GGrz65TsyBzOa8jXZ/umgIjABE5pIQ8NguXah eYRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kQ2gXQE8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p16si3966537iov.22.2021.09.16.14.17.40; Thu, 16 Sep 2021 14:17:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kQ2gXQE8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240708AbhIPQdD (ORCPT + 99 others); Thu, 16 Sep 2021 12:33:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:60150 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242112AbhIPQY1 (ORCPT ); Thu, 16 Sep 2021 12:24:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A95EC61350; Thu, 16 Sep 2021 16:16:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631808980; bh=rWNi77wSCjZjarPicrsk0idQ5DGpAWrXi7WaW93lZ6E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kQ2gXQE8KAqRgU/HtACos4ehCHwNfOCR9yRbueiGtqtUo584YnIo1b23YlEqE0OrJ gM1EjgYHmLDnkBMWlXLBgJ3+Jo0xxzvHamGSZeT1LdXmY29dnwrEgC3/OzBguPJOUT g0e/a6moLdfGNHdKJqL5Lmv0nxz08R14Et+DCVB8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ard Biesheuvel , Kees Cook Subject: [PATCH 5.10 294/306] lib/test_stackinit: Fix static initializer test Date: Thu, 16 Sep 2021 18:00:39 +0200 Message-Id: <20210916155804.121940814@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155753.903069397@linuxfoundation.org> References: <20210916155753.903069397@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kees Cook commit f9398f15605a50110bf570aaa361163a85113dd1 upstream. The static initializer test got accidentally converted to a dynamic initializer. Fix this and retain the giant padding hole without using an aligned struct member. Fixes: 50ceaa95ea09 ("lib: Introduce test_stackinit module") Cc: Ard Biesheuvel Cc: stable@vger.kernel.org Signed-off-by: Kees Cook Link: https://lore.kernel.org/r/20210723221933.3431999-2-keescook@chromium.org Signed-off-by: Greg Kroah-Hartman --- lib/test_stackinit.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) --- a/lib/test_stackinit.c +++ b/lib/test_stackinit.c @@ -67,10 +67,10 @@ static bool range_contains(char *haystac #define INIT_STRUCT_none /**/ #define INIT_STRUCT_zero = { } #define INIT_STRUCT_static_partial = { .two = 0, } -#define INIT_STRUCT_static_all = { .one = arg->one, \ - .two = arg->two, \ - .three = arg->three, \ - .four = arg->four, \ +#define INIT_STRUCT_static_all = { .one = 0, \ + .two = 0, \ + .three = 0, \ + .four = 0, \ } #define INIT_STRUCT_dynamic_partial = { .two = arg->two, } #define INIT_STRUCT_dynamic_all = { .one = arg->one, \ @@ -84,8 +84,7 @@ static bool range_contains(char *haystac var.one = 0; \ var.two = 0; \ var.three = 0; \ - memset(&var.four, 0, \ - sizeof(var.four)) + var.four = 0 /* * @name: unique string name for the test @@ -210,18 +209,13 @@ struct test_small_hole { unsigned long four; }; -/* Try to trigger unhandled padding in a structure. */ -struct test_aligned { - u32 internal1; - u64 internal2; -} __aligned(64); - +/* Trigger unhandled padding in a structure. */ struct test_big_hole { u8 one; u8 two; u8 three; /* 61 byte padding hole here. */ - struct test_aligned four; + u8 four __aligned(64); } __aligned(64); struct test_trailing_hole {