Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp216001lqh; Wed, 27 Mar 2024 22:27:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUCigmkHTHdKxClehvDywYu+VaMvVMi77vdxRr6LH95qw87kIxXw+EjUsm/q+JggCuSGVzPIMx6IQQA1R7mqB1GNTZ9yZZM6K9j04pRug== X-Google-Smtp-Source: AGHT+IH8SPGnJdGJvFX5XHxyPOHf1N4NmPYn4E2eR+9dIJzXtcJ1lHrXDUQUQI9iP+YYN9Lbo0Sg X-Received: by 2002:a17:90a:b78e:b0:29c:6ff8:fa32 with SMTP id m14-20020a17090ab78e00b0029c6ff8fa32mr1521164pjr.3.1711603665909; Wed, 27 Mar 2024 22:27:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711603665; cv=pass; d=google.com; s=arc-20160816; b=0WaD39crnpDjWZUY3nDcgPv+PTdA1P4l2866jtLfVRlfChw6ettDsvYID0924FQnnl uNNdqUVwchIbyYWNEJciJslp6HWBA5Ny2aCqSybVAAmmeGZe2Z+EmE9TMSopXKiaWg8S MG/u7YZCv6BkCEoKcnyZL26BUZ4IBfw9UOMtp6CwUhmh0VgMY2MbfvsaEtVIkbzGR3Nr XR5JRu/hHgaYm+uto76NJ6KakDMb7OiVrUWWkEwEQhS3kRAzKSaBQ7nff4r0OfAf9SvU P1FSWdMowo9nHJQEQ+mfJoENEnBbr6EgO5tMX0M0Zis3EQqdwuyRCJ6bDmjS8pSvDt8x bpZA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:references:in-reply-to :user-agent:subject:cc:to:from:date:dkim-signature; bh=nNDoNeVkx3lsLGt6cZnB5tXn8fXGFUJdOBK7O79ATdU=; fh=Yl+L3YCx9ot1zyakK3t3IeSVWNFsxM7pL0mgsPPA+2c=; b=I1kPlMPT6y8b4n2jfPYs/nHs1/rbmNH9p/NsqSEyhbtltPN3xxwIZxdjUDSR2AUX0p j6rfeaLSe58hJVu+QkauwJGIsU57E+JQlWDBlzdxgP7r6N4h/ydDe2xTT/3Pk/9qh2vf PdRktM0IMDt/jRuVIkVaZvkGAaeqs2nrVShrLB3sWyXUC3Tjfw8IOGf8zGn6s5xglTJ0 vb7ikoY7OnD13Ccd7FGZPJ6EqILAaC86AyOVTpHjMBiqvHLK53pFAbikZiKKejNO10Lm aYf24RmwtXj71HjEXLAmObATbxDavYU456FOLmuxuw+Ol9yP4diTEQt7c3eeYKamwL85 MyZA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ftCGu+1t; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-122424-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122424-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id pt13-20020a17090b3d0d00b0029dd90451dfsi3911362pjb.0.2024.03.27.22.27.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 22:27:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-122424-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ftCGu+1t; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-122424-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122424-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id A9EA1B2370E for ; Thu, 28 Mar 2024 05:27:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 37FC74594E; Thu, 28 Mar 2024 05:26:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ftCGu+1t" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 60400D304; Thu, 28 Mar 2024 05:26:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711603613; cv=none; b=byNtoDNEGGaM1NCl1KzyjXNJiy5Jxt9wsHUvtYU/qn0653O7eB8blcnsrc9lVKNn9C5fgFayIciRvqffD8l6dQlBVfhLsxaMA9KWppKrwRIYWIWgAOTYYLUByOjdXatmTVyEd79t3WRQafX39ZHJdWm7I82yvkFygANRVT9WNN4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711603613; c=relaxed/simple; bh=nNDoNeVkx3lsLGt6cZnB5tXn8fXGFUJdOBK7O79ATdU=; h=Date:From:To:CC:Subject:In-Reply-To:References:Message-ID: MIME-Version:Content-Type; b=ECB89x2SawtFL3czzWGXy/qsAXwupcylgEvHtIShjwRUXl3vSNrgGvXGIykA76Llyr6VilWqQUsJPM4A4hjCC9eNhnhTQQ54LZrNTzmx6/hbp47OiE3+/vyomTOSMEsPn1nKifiBzF2FyRhU7f4/i1C/TXCcRp8mIHxglBq6hwc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ftCGu+1t; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B59AC433C7; Thu, 28 Mar 2024 05:26:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711603612; bh=nNDoNeVkx3lsLGt6cZnB5tXn8fXGFUJdOBK7O79ATdU=; h=Date:From:To:CC:Subject:In-Reply-To:References:From; b=ftCGu+1tDZdMw5dOxoF9vvq5lW+Otcl56AJxf643bHo1VJ5VGf/spkG0S6e7keS5b 3YNukZhqfwv456jxgF36e0xgoYG9zhIvJ3ttaQMH1AmV7s4z4+ebybPPFVp/yWcEks KTFqAXz+7ILgE0JfV3qaWxjhhNGCkNQNdyzjd9gjl4Eao1JD17HQIc8fg8HktBRAvq mY2JoV0CP4Gh/xYYJckAjNUOhn2bEJ3Sq2Iav8rMsI/3plZC/CbSS3zyIfLeu74Z08 9cxeC7lc6pVCe+mmmOKY3oQAQpEFVNOKkL9Xtd92UTp5BLZ/wrDVG7EpC6XAoUg90Y 9rflje1TTvQDQ== Date: Wed, 27 Mar 2024 23:26:51 -0600 From: Kees Cook To: "Luck, Tony" , Kees Cook CC: "linux-kernel@vger.kernel.org" , linux-hardening@vger.kernel.org Subject: Re: __randomize_layout; User-Agent: K-9 Mail for Android In-Reply-To: References: Message-ID: <1B6E0664-D1B5-4FCC-A874-8A9587924687@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On March 27, 2024 9:21:59 AM MDT, "Luck, Tony" w= rote: >This e-mail is to check you on whether that __randomize_layout can shuffl= e the >fields inside that nested union/structure=2E I tried some experiments, an= d in a >few kernel builds I saw the whole block move to different offsets, but th= e order >of x86_vendor, x86, x86_model, and x86_reserved was preserved=2E Yes, this is an intentional behavior: __randomize_layout will only apply t= o the struct it is attached to, and is not enabled for any substructs (anon= ymous or otherwise)=2E >But experiments aren't proof=2E Nor defense against future versions of >scripts/gcc-plugins/randomize_layout_plugin=2Ec becoming smarter or >more aggressive about changing layout=2E The behavior is also supported natively by Clang -- neither implementation= is likely to ever change its treatment of substructs as it would kind of c= ause chaos=2E So you're all good! :) --=20 Kees Cook