Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2086487rbb; Tue, 27 Feb 2024 10:08:04 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW6cUT4r6a3s+uoXfzmtDnKPDGkJj0aXeuNOBcYS/IeNdWXveaLxz0KZIrXV2B3+Jv69QKKtpJLQOILHJ+Lj4GevGe8uo6XpsCjp1XA2w== X-Google-Smtp-Source: AGHT+IH0+xC2hxdgrZE6NgawKqMVFl3IQOe4gf5zumsZ0CInMBPG4H2gnJqN3r/Aojxsen9G/vka X-Received: by 2002:a17:903:2281:b0:1d9:ce46:6ebd with SMTP id b1-20020a170903228100b001d9ce466ebdmr12555882plh.16.1709057284116; Tue, 27 Feb 2024 10:08:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709057284; cv=pass; d=google.com; s=arc-20160816; b=erlyKwF+TXjC/OOOacJA+dHodGKCGpSWJuPWL7DTrAPq3hAK8SltzXB0Ok9dgqsDUX 0kMhxXDXYZie1defqrQtOZL/MHseju08CZXhfB+YH8zKvJjKOjeeRoHfp8kuhNqUZu3b Xn7BfZ+r01YAuFDVMnFxxsjb9QBUuOmDH0bO/e0gSxhIJS7iuXlJgarLs0U9J6PbTpQ8 mnfQ19XoZu0FUXo4ig47mztkFqIDOlnIKfcxza4gWrngC/2KqPwh15YXnF6730YrH5Jd qSgxfSQDwBKgCiHSvvQ753CJ4rYOhklc0VeN7ECV/QvcdakhV7XytxUc+x5i1y722CLl k8Lw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=mgrI9FN30eAJ2XZAfY9sJBg3TkLiivRBpbDR17SPpEo=; fh=RgbDirH7odTOZvMXcBZNSMQbpBwGgGgxQelx6+9azLg=; b=A/i8zzVYHKBelPMZxmiWdDI0Tea3eqn83vnPJ2LLM+TERUXZLrqnGrfFecePqbW0JJ 1nsTHBD9brKjmbcsmHjbk6D0XlgF+o7ep35oWfckww4fbIC6J9Az6hOtIF+fO3qh2iPZ lCTeRP6mOPPXHaZaOV8OgjGrca1n355hpdGtRem4fZgsr5+z1Lg2mCnWDAA5C0ci+myR dNusCypX/RS9RHwAoITJcc/UIOU6BMvvnF9RmhIOV0pP+5xpKk5msfDhUfnWsRK16rRV r3iWcir0Uv1OfFSWGut+ihKVOlFrQQkEovUah19ywi25a6EexBIKf6x6gj/lpY0tbgh8 7I2g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=d+iQnuXL; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-83798-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83798-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id q12-20020a170902f78c00b001dcbc8ec888si1274456pln.339.2024.02.27.10.08.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 10:08:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-83798-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=d+iQnuXL; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-83798-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83798-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id CB0CE28E3AE for ; Tue, 27 Feb 2024 18:08:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C833614830F; Tue, 27 Feb 2024 18:07:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="d+iQnuXL" Received: from mail-il1-f169.google.com (mail-il1-f169.google.com [209.85.166.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C42EA146908 for ; Tue, 27 Feb 2024 18:07:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709057250; cv=none; b=EndrKopRGKa2DffWUVCzgWluZQLfqM4MALA9KwwnJm4pgw/kPgD8KYAwIgrqUpBCMFpeqBXAZfww6E6zNn9+nmJbc9IImKYNB8cGy2rEbT7j7I8BoGo86B2b8eovZ9sk33vlohq+mkK7Ii6r5hvTDChTTm9GVaFK0qhiDSNgV7U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709057250; c=relaxed/simple; bh=hDsO9qgv2V890oQySpFfqyCZWrqkIn/rAE/+zRviBYc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=qRyPPQg2BZhHBlq9v0fwq5JpK9LidgZ2i4QjaNC1uznNbhfXGSgzycat7/HIcQdIMM5ySfwk1rSI0eqetkRKkGYQxcq8fqBp+uOI6OA/RaC+bmiqh4IAjFju/MKGnRzTgXWmmOEaCo5AnxL1lqIYMsv59FFs0WGp8ZrLSAyL7VU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=d+iQnuXL; arc=none smtp.client-ip=209.85.166.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-il1-f169.google.com with SMTP id e9e14a558f8ab-364f791a428so15826955ab.3 for ; Tue, 27 Feb 2024 10:07:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1709057248; x=1709662048; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=mgrI9FN30eAJ2XZAfY9sJBg3TkLiivRBpbDR17SPpEo=; b=d+iQnuXLgKZDLaXx97j3ZKk+HiTOuQlqJBwLJEYO9svRMD4/QqZkaA9oMup/6e+RJ8 tj+8l3QfTp2EGhMAEuxGkM8V8y4ixD2Msf+7eCEOi9siXYV9WxIwItMnFGqXWwtT4LAx VPJFJDLg4jyshNCHJX13Ew+uPZlcUwwIXdT4I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709057248; x=1709662048; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=mgrI9FN30eAJ2XZAfY9sJBg3TkLiivRBpbDR17SPpEo=; b=ghUwkx+Kj1k6V3ytMkes7tJSDWenxI2RnvGbBry+bVh8UxhRZVq9jMURXp76pTlHYR QLUpBjcVUPQWEyrU72PGd5P9+qcIXMP6MsJd8X1lRBkyhiD4uB+TvOzfTAXNi3XJQic6 HM5ufhCOQ5C4KFPvaAkJE6MuiZsIfwQm6AQ+cTEsUy9cwnuplk9pwdJxRGbJFEIXiJfQ MrTGqNztkBhGm8GTlJWWKREaOPwq/HWuK97JTKUr+sin0XpDj0LuoAXtluh0xvS9e62p Ui8e0H5h3324ZFIGJDAF24/hH7seHs3S/NIui39zEkG02xi/IOvM6QA+D2KEDIQiIVO2 /Mbg== X-Forwarded-Encrypted: i=1; AJvYcCW26PgWJdX08rS6ChER9sQdHiBCnAmQofigPZz2YlIUz5tjtZG7SHDjLejvsh2KyUs1up4I2Ywr8kDCGTRoLoZrDeK3n0w1OTtwcnYA X-Gm-Message-State: AOJu0YxizvJoHy4sAU6FDAeQpxp1n9XEdw4szEeTDnn6NCqXduaChnVt Gkr6sh2BkcbPHk4wPq5fjYhs2CULfZla/Cu13FNQ1WzlQiiqpIyIOAlzzRC75w== X-Received: by 2002:a05:6e02:522:b0:363:bb5a:3329 with SMTP id h2-20020a056e02052200b00363bb5a3329mr11593022ils.1.1709057247927; Tue, 27 Feb 2024 10:07:27 -0800 (PST) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id fa42-20020a056a002d2a00b006e55b674e66sm10411pfb.171.2024.02.27.10.07.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 10:07:27 -0800 (PST) Date: Tue, 27 Feb 2024 10:07:26 -0800 From: Kees Cook To: Christophe Leroy Cc: Rick Edgecombe , "Liam.Howlett@oracle.com" , "akpm@linux-foundation.org" , "debug@rivosinc.com" , "broonie@kernel.org" , "kirill.shutemov@linux.intel.com" , "tglx@linutronix.de" , "mingo@redhat.com" , "bp@alien8.de" , "dave.hansen@linux.intel.com" , "x86@kernel.org" , "luto@kernel.org" , "peterz@infradead.org" , "hpa@zytor.com" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , "linux-alpha@vger.kernel.org" , "linux-snps-arc@lists.infradead.org" , "linux-arm-kernel@lists.infradead.org" , "linux-csky@vger.kernel.org" , "loongarch@lists.linux.dev" , "linux-mips@vger.kernel.org" , "linux-parisc@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" , "linux-s390@vger.kernel.org" , "linux-sh@vger.kernel.org" , "sparclinux@vger.kernel.org" Subject: Re: [PATCH v2 5/9] mm: Initialize struct vm_unmapped_area_info Message-ID: <202402271004.7145FDB53F@keescook> References: <20240226190951.3240433-1-rick.p.edgecombe@intel.com> <20240226190951.3240433-6-rick.p.edgecombe@intel.com> <94a2b919-e03b-4ade-b13e-7774849dc02b@csgroup.eu> 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=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <94a2b919-e03b-4ade-b13e-7774849dc02b@csgroup.eu> On Tue, Feb 27, 2024 at 07:02:59AM +0000, Christophe Leroy wrote: > > > Le 26/02/2024 ? 20:09, Rick Edgecombe a ?crit?: > > Future changes will need to add a field to struct vm_unmapped_area_info. > > This would cause trouble for any archs that don't initialize the > > struct. Currently every user sets each field, so if new fields are > > added, the core code parsing the struct will see garbage in the new > > field. > > > > It could be possible to initialize the new field for each arch to 0, but > > instead simply inialize the field with a C99 struct inializing syntax. > > Why doing a full init of the struct when all fields are re-written a few > lines after ? It's a nice change for robustness and makes future changes easier. It's not actually wasteful since the compiler will throw away all redundant stores. > If I take the exemple of powerpc function slice_find_area_bottomup(): > > struct vm_unmapped_area_info info; > > info.flags = 0; > info.length = len; > info.align_mask = PAGE_MASK & ((1ul << pshift) - 1); > info.align_offset = 0; But one cleanup that is possible from explicitly zero-initializing the whole structure would be dropping all the individual "= 0" assignments. :) -- Kees Cook