From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-io1-f46.google.com (mail-io1-f46.google.com [209.85.166.46]) (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 AE244145FF9 for ; Tue, 27 Feb 2024 18:07:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709057250; cv=none; b=QHc2ZULpqXDl7Y5PZ89GaJtYRu1apkCaMeNhW11XkNBKqEEQShIayAHwMplATf+5FEM1Z0UOeFZG0pDlW6gFgCm+vAgLaccJCL8sfj/BdCY2o8u3svvR9DwhPwXOtnK6ima+8Vbhs8AtXYZrafk+mo/+vYOEm+R8mUbZzFbVpDA= 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.46 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="d+iQnuXL" Received: by mail-io1-f46.google.com with SMTP id ca18e2360f4ac-7bed9fb159fso225151739f.1 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=bbUsa3VpKCxTgPIU++niUZqDN+u/xOFBUoFAyqK3n4grTBP1EmLjIH0n9WciVUxzSZ axw7VpwbGGZCRtax845TMPSJAXZ1juQPm3d+mCEblp3tJkrbATdhqVY+vUsOMFXoxGcg +47rU3zl2KCA3llzQcQTgLXMstSIRt7Z+z2OpJOOw4AAFwwVWg3RfbRoGg+J7JgCOIaH qiqxkk0/O+U9o4WppOdIW1z/NYG+jBmnw7sNkCLc/t+D8mYR3fHyLWcCFVG993L6mlCK X6oGb+z106HZb+/XKiq13YLTGIvwB9D2vhE1tjN59Mp89aHM4Z7fE2+CMbfxmAyPp479 srIw== X-Forwarded-Encrypted: i=1; AJvYcCUXvtG8+H/JABivj0nUBeBuTngnTe76LGR8JEu0cdhfPlTLMEMVZDmjR2O4yrhajHpTaogrdm7CPKmoT50Tipl7VcX+2SQ7xbvZ6U0= X-Gm-Message-State: AOJu0Yx3mQPfmIB/0Oi1UsQZtS+QXMJmTwpDg5kVbfPJ61G90WA5q6D/ PKeNqAsl09Q14xDPy/Q1FNa0crvg4B6H36+YW8xfDTI8ZdpacA8KxiZj930teg== X-Google-Smtp-Source: AGHT+IFpahrVJDe+RkqjDhxBgm48d+nhk6O3nvQnCIgFv/bhnbFyY12knPOFjwYUx9hP01B6x+R36g== 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-alpha@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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3FC73C5478C for ; Tue, 27 Feb 2024 18:07:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=TQpQpBafKnTqE3aR4l7pR2sqnay6Wh8nbJP5fjL9Ejw=; b=ZOnLIONc88cnFX xJ8HVezaLNmjE58TbJQQFOZHPR6qPJUhzUvX9xqtlmP7mrmMxKZD/tjaa4GDRiMGxtoW7+iEqoRB8 B3dqSH5Ary90VD0jYhAaFjSZOBI/AJzLUGdfH8IBVr2sxElsMFYzaZKAJ4ZzBZC+7ooPslB3rjUWP T12zhqjDtopk21yq9rsH8xIF98QVVN94Dzf5uMYNGtJi+eF4cc5+hwe6F99GgKoq6rNjbR9kiT8VW szpWOeFAaCH/f9pKNbNXh2lZiDMcx1xu+QAytIyZw0cZKTLzsstWXO5lRYj8aD5Zi7Ew4rDePGzKn 9PdBqlBBPuiqWzgpX78A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rf1rf-00000006MH2-30KY; Tue, 27 Feb 2024 18:07:39 +0000 Received: from mail-il1-x135.google.com ([2607:f8b0:4864:20::135]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rf1rc-00000006MBj-0qJL for linux-snps-arc@lists.infradead.org; Tue, 27 Feb 2024 18:07:37 +0000 Received: by mail-il1-x135.google.com with SMTP id e9e14a558f8ab-3651b948db6so9852915ab.0 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=lists.infradead.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=feMHyykf4cTtY0rT0EygPG/jHlDAUJ9DFCtqcCx0h+yCQDHiRnXqDbY5bB93HGFGmi 14czncGGxCq4sleYepI0dmDDYf/N0xCE8hniES2VK73eG8ScpwGl2khhpINqtffLkTlq 3jQjLhK7uvsSpmYCrZRPrSSifsXN8SFLtaZpc= 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=SK6FWf5+L+BB5fvGe78lecVdtG0UvynKREwE8+MLCYBRHvksJLlx3wO0fHzdp80NzU wEYYwXSHX+w+VsWtfioGYuGCOUE2xq/VnNiTJwBmGUNISl1NL0wdzDxAyMuBVvhWxmGo fS3pxdupzslpW1cYgV2emoiyOgch7y4Prqo3e+HaUv5esavvAQJMsavwXwAxXAppriDo 10eDMHx6i91cKPJ6/yD0WESzzRrEa8hClsmSVWTMWLje/pJuxh1dx/P99cnm3F4rvBAg whxoA1ZL+PXqDMWRFOMEQGlifIb1BIU7QbStl2UTwD0BND0J6ITeszF4P3z0MY57AEpk 12JA== X-Forwarded-Encrypted: i=1; AJvYcCXIZGQM3QnyvXs86OQgNzlwTHztS+ZLNUKUJH0PAg4RVnFcD10NOJ1AI85nEXEbcJ+k+xxiIxi0kYzjsgsot5u1d73RBL7aSrz1/p+Z3to59U18 X-Gm-Message-State: AOJu0Yw1Ruer23ONwZXmW61Q6Y7d/K8H0YkxEI04uoiGHzI+bYv8VQ28 +r2vEtn/W7kD9yzaG94hliRXzpR15UpRFcM/ZLmFAgqHGTZMiF+7JDMP9OezrQ== X-Google-Smtp-Source: AGHT+IFpahrVJDe+RkqjDhxBgm48d+nhk6O3nvQnCIgFv/bhnbFyY12knPOFjwYUx9hP01B6x+R36g== 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> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <94a2b919-e03b-4ade-b13e-7774849dc02b@csgroup.eu> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240227_100736_257720_4DFE5A03 X-CRM114-Status: GOOD ( 17.72 ) X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+linux-snps-arc=archiver.kernel.org@lists.infradead.org On Tue, Feb 27, 2024 at 07:02:59AM +0000, Christophe Leroy wrote: > = > = > Le 26/02/2024 =E0 20:09, Rick Edgecombe a =E9crit=A0: > > 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 =3D 0; > info.length =3D len; > info.align_mask =3D PAGE_MASK & ((1ul << pshift) - 1); > info.align_offset =3D 0; But one cleanup that is possible from explicitly zero-initializing the whole structure would be dropping all the individual "=3D 0" assignments. :) -- = Kees Cook _______________________________________________ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 44524C5478C for ; Tue, 27 Feb 2024 18:08:21 +0000 (UTC) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=R37LDvvc; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4TklpW5Bmwz3dLQ for ; Wed, 28 Feb 2024 05:08:19 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=R37LDvvc; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=chromium.org (client-ip=2607:f8b0:4864:20::d2c; helo=mail-io1-xd2c.google.com; envelope-from=keescook@chromium.org; receiver=lists.ozlabs.org) Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Tklnf633cz3cnt for ; Wed, 28 Feb 2024 05:07:32 +1100 (AEDT) Received: by mail-io1-xd2c.google.com with SMTP id ca18e2360f4ac-7c48fc56752so147134039f.3 for ; Tue, 27 Feb 2024 10:07:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1709057248; x=1709662048; darn=lists.ozlabs.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=R37LDvvct7Zin/I8So/le+vgh28M+YfOPZLP9gOBeY+/GB04BtWL5a4Vtjj9NY7bcr dhkAg4jmJUpisIXj+DPVpGlKrGYmypn9l5qIbRlss8374/Cme92g6tdC6XHMgjnNf2EQ pNbYbpZt+K3EMJoD4aOa15OnOjKioZaLYVk8E= 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=kG1RED9pWJJMsEIUpnqrEkK7/lYF2L5m6xSHe/0hmTLgUTxOw97CiwmzGQN5Hc1s3B 3Me0DO4sMBtyajV6feEtlFBDwsT6pRMkFD3dtZUS9xeqgsCO2WMRluBghediF4XxyxQ4 NCYYFxtCfx7SbeaZZUtWOGiEhegIHWQRiiuBeps7xQdaEOAYeYT7czDIjwRBggq8FgSu CKanWodRIhuzsfTgaA6cGhKcRKXz1zjjAlfTPRPes+OdaWL6tx25uJp3FDFeEK32rGVN AsYzhinrXqoSF1Igo2fYpbyy8g1bO4IiF9VVC2FLotZxyXR6/QmQzML/1X28g3Y6Vm0q O0QA== X-Forwarded-Encrypted: i=1; AJvYcCWZhawiaI/0TnekegJyTEaMKYVYEfWkFf6+nLwdTSvrzVGsQfb29y2Sq+vJFtD5IH3H0fUsRRQLx5TewKXF2DaPtYulhumHLqdbKB0Vng== X-Gm-Message-State: AOJu0Yw5j++r/EfD8Dv8LxKGQa/RN41n0uqRNK0+SOvcHAB9uR+nCgPO 98NNyHYWlyL6GOh3bpoZo63g/f4n83PvWt+GVJsifJcTawigWTWeVOLV/1Y7ww== X-Google-Smtp-Source: AGHT+IFpahrVJDe+RkqjDhxBgm48d+nhk6O3nvQnCIgFv/bhnbFyY12knPOFjwYUx9hP01B6x+R36g== 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 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> 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> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "luto@kernel.org" , "linux-sh@vger.kernel.org" , "peterz@infradead.org" , "dave.hansen@linux.intel.com" , "linux-mips@vger.kernel.org" , "linux-mm@kvack.org" , "hpa@zytor.com" , "sparclinux@vger.kernel.org" , "linux-s390@vger.kernel.org" , "x86@kernel.org" , "linux-csky@vger.kernel.org" , "mingo@redhat.com" , "linux-snps-arc@lists.infradead.org" , "Liam.Howlett@oracle.com" , "broonie@kernel.org" , "bp@alien8.de" , "loongarch@lists.linux.dev" , "tglx@linutronix.de" , "linux-arm-kernel@lists.infradead.org" , "debug@rivosinc.com" , "linux-parisc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-alpha@vger.kernel.org" , "akpm@linux-foundation.org" , Rick Edgecombe , "linuxppc-dev@lists.ozlabs.org" , "kirill.shutemov@linux.intel.com" Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 874C5C54798 for ; Tue, 27 Feb 2024 18:07:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3FcYBZfwpHsjiJH3EbNUmL0fh1+SFfG1xp44bdCwiuQ=; b=ONsMNqMBPikM8z ofsoZpRB0CDaLqN8OZEQJ+EYygquQeiAlOyD+lXYmgpp8on8JITtLMuJd96Wnyq+i0QOUSDmpqiAS yJgaLYHkO1a+guOLXfB6DZvCe0dk7x+Ffi3zEumuxNhmHWDcx40c9FRAJDLDXvxHcnY/MU8YEqPEF qeQx4x3HkbnxrLddzer4Ge0QX/z45pENegKGpt2uWMcL7FlgD0NzKUvyoh8OUGZ/JxltqHsUL6gLs DDhvLnpwPAKyvB9ASr0jV2n+RfNxKOoGjPwj0I3I2Ks+du+rv6HCoC9icI84Tshxjy7NydFE2c9X6 kR69Sl/V+F90CnlPl0RA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rf1rg-00000006MHI-1FYl; Tue, 27 Feb 2024 18:07:40 +0000 Received: from mail-il1-x135.google.com ([2607:f8b0:4864:20::135]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rf1rc-00000006MBl-0qEF for linux-arm-kernel@lists.infradead.org; Tue, 27 Feb 2024 18:07:37 +0000 Received: by mail-il1-x135.google.com with SMTP id e9e14a558f8ab-3650dcd38a0so10986195ab.1 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=lists.infradead.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=feMHyykf4cTtY0rT0EygPG/jHlDAUJ9DFCtqcCx0h+yCQDHiRnXqDbY5bB93HGFGmi 14czncGGxCq4sleYepI0dmDDYf/N0xCE8hniES2VK73eG8ScpwGl2khhpINqtffLkTlq 3jQjLhK7uvsSpmYCrZRPrSSifsXN8SFLtaZpc= 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=wqq3fhIcGkLI6Aypx5haaOt236JLH9SPnddLmawb1W3iqeTdIa1Frhzkj0+ISiF3Sh FEXIOKjdZyonf2RGm19M4jwtf0pRTq9OHP5AUTYJOQB7n555vpvVX4YzBLqFmBTk5sRn myq1GWV+oQm8nabrpGOu2iH6hmkACi0yKAm3zhE8Jw/ukAEk8VXKxPDW3fQCEaULNNT1 ArnTwOguhQpn7lAyj+hnlrSxuf1eLh536S/LX0d9wBrXqRTEP9iQDVCnEGYVT+S4SWDN UiNmgFtZ4D0f/qkjPN6v5HEphT+VEgEus8tImlP62Alw0d0QKM9Whq5Lc9poyTfkpxUS jpgw== X-Forwarded-Encrypted: i=1; AJvYcCXu33+0+Oe+cTxaFV73Wnwi0jWG6Auj1TRBsPEAKgCaiFPKPu81OTDQ1oeG6eef2A2vFh3mAXpzfNikFRoHM2hg6nfPMR0peDemXEANARP3V3lY/Ow= X-Gm-Message-State: AOJu0Yz3F8CaeImp0rfQq7q8yvcRhiwM3r1c1NZE+hzPmniKB+nvPdvA oNY5e3tyiUuX+xY8yhOtqWPKpXyAsPoZXAY920uzNB4qF14Juw2kf+2shUPQig== X-Google-Smtp-Source: AGHT+IFpahrVJDe+RkqjDhxBgm48d+nhk6O3nvQnCIgFv/bhnbFyY12knPOFjwYUx9hP01B6x+R36g== 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> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <94a2b919-e03b-4ade-b13e-7774849dc02b@csgroup.eu> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240227_100736_256524_32D785F2 X-CRM114-Status: GOOD ( 19.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Feb 27, 2024 at 07:02:59AM +0000, Christophe Leroy wrote: > = > = > Le 26/02/2024 =E0 20:09, Rick Edgecombe a =E9crit=A0: > > 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 =3D 0; > info.length =3D len; > info.align_mask =3D PAGE_MASK & ((1ul << pshift) - 1); > info.align_offset =3D 0; But one cleanup that is possible from explicitly zero-initializing the whole structure would be dropping all the individual "=3D 0" assignments. :) -- = Kees Cook _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel