Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2350182pxb; Mon, 20 Sep 2021 19:44:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwy92fvWvP3tOSJCKm2oPfw/fJkkufVtqRBmnH+9dezGrV3Fsq1PZWHIKbWH9gyWJOr6C/F X-Received: by 2002:a5d:9693:: with SMTP id m19mr21305051ion.181.1632192297944; Mon, 20 Sep 2021 19:44:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632192297; cv=none; d=google.com; s=arc-20160816; b=bIT1ry7gBiTTAVpQG+Dnyzs8xPN61iGF97GSUrRwhoHwW6UZebyvbq82jQQCvneaPt uDi9nOG7Yrhwc4HHZtVUm7lEdq6OLO1BYLmzKbIi9osfCuf1w5sJF/YK0LjmhUjlgnNg g2dgTiFZGdIlpwhRscTib7V2zczqG10UzSm7tRhrvSJyBmmQFBuTrigs03uHzpY3jzRj mMyAjx4dd3jj0AcpwvisSrhCrAavay0UIp31oCfD9QMxJl1v6sHLRLNz5UlAKtEJrEr3 JDMCxJWaxEfFapUODGmyO76YbyEETReJ/jPQpC80omRrR4Xu0N+0gOSoRe4zDyz27/PW qvbA== 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=KXpk9ZEVAQ7ZURo/XoCXc7E5EYeBSCUCGvIqYHF9sBA=; b=o+BACmrdC5193avoL5J6otDo1MD3dMusnAbPGgRtYDw3DaTTVSaT4Acngs4fWggr4u QWZawCLC1Urx7eTIVwZgID0rLFA9+pHhyomkguio81FZ70CZgyRQvEQTl7w5fx7jeXnq HbKSQ8MXhSnBMssj+MlzTXIYRQ0sD26p0KhajdCh+YbSUtxSfFmdOffAhzbIbgkgxWWG Jdcq9uaqujNjHBIwgIJ0DsAg0zh7xAUfH0GY7m/5fCIo4nrrV7yk1u88HG9pvhW5LJ6/ 3r28ei8wKYtRIXkHM9Lc/cnzEWmxTBRSptSpFRF2DsG6kbZWPKVVikHLJzOYPIO1aAyB i0LQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SumXrDGK; 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 c17si16975279jam.29.2021.09.20.19.44.46; Mon, 20 Sep 2021 19:44:57 -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=SumXrDGK; 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 S1378112AbhITSWx (ORCPT + 99 others); Mon, 20 Sep 2021 14:22:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:36230 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376854AbhITSOu (ORCPT ); Mon, 20 Sep 2021 14:14:50 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 208FB6124A; Mon, 20 Sep 2021 17:21:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632158503; bh=6yGfmn/V5GRFXHZ7rd7ies1EaLYbCbDS8HQJDrxk+8w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SumXrDGKuTyHAPlBz88dvtVtPyeuvZwe63wJueV+BLdXW8CqOuYzXQ71tytBhSzRL 57B181M93cvJrEZ/bq0QJ8axV/IxCP4gk3sIh1o/oBq/EbogQx+UPB4t2fR/81NnI2 fn6fuF3UQDRkFWPTTZ+MKXX+lf3uiV4PmJM7cOBA= 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.4 185/260] lib/test_stackinit: Fix static initializer test Date: Mon, 20 Sep 2021 18:43:23 +0200 Message-Id: <20210920163937.399223934@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163931.123590023@linuxfoundation.org> References: <20210920163931.123590023@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 @@ -208,18 +207,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 {