Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp18346rdb; Mon, 22 Jan 2024 10:27:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IGuHoDNvZqchsajXmJgH5LDLW9lCZhWtjjODEiOGZlfR54u5HvJFL9EzbvpNpKTtq54vjQ8 X-Received: by 2002:a17:906:db07:b0:a2c:d9fb:ed3d with SMTP id xj7-20020a170906db0700b00a2cd9fbed3dmr2750230ejb.78.1705948062593; Mon, 22 Jan 2024 10:27:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705948062; cv=pass; d=google.com; s=arc-20160816; b=ouxFKkY5aeIifTPqMA4tJY3gGgAqLtdsqOVJBgKf7lPlS/xB393/SIamrq3Yc8ADSX Q05pP6EdLpyytHSwnalQwKe9Hu2j3Xp88ct7Ec8F+lz8wqRrBySWgnTsZ39W/wx605Po +LpAu4fcTfEFMYx5YMIT5dYkFoZsgQcw3Qtq7EH3JV5u0Q8rAMgZnTWfxKaqKnEmywG8 gv1tcfoTWP6g9qQHIzEqL8RVCz9Lj9UTavMyrzj7mKvVwc+qfc3h1vTS0CDzfeBj65ZV r0jMDHtJNO7XdQZAoRrPD+dL2iCNIDy9ZbrEYO1j7zAVrZkHgvkmX1DO7jPkfgWZAwPB k5ww== 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:references:in-reply-to:message-id :subject:cc:to:from:date; bh=IDuLROwkDlrkR440nzI002pe6vK+1PfhawyvOAOz+W4=; fh=UerIcNH8+yarGFkPyJjy3S6im0qOoLQjKOg+xljOgS0=; b=vD/x+JyeKn4U71FyaP28Dl0dfLjRagg7AJ2t0xR6a3ztQT8DfqkmNIf3iB5Lfzo150 9bjDwOalxhJTvqnIbypO3McVEzr+xLnXvbamTeNGmLd/Qwq0myhe4BQuhvV57tIbMj/h o4QaucZFwhvinJXnpfJUFs/i8bkOxDgLZTGaZgBSHVEOtqJcohaUpbmZqW7JGKGZEsva Jtac36lDeWc44qqyC3+H68mRMYO/NTXvYnbj2gojTGrHaufaoR2ptlEiocZLu9k+pEEy VXyLxyHko3NUrjKnoSrgtnJfBLeXYyWu1KdFZ7KiBLG2/3bNvooAdAR+ShXlVfwsSHFc yjig== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-33858-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-33858-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id k19-20020a1709067ad300b00a2de44e0182si7560087ejo.850.2024.01.22.10.27.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 10:27:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-33858-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-33858-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-33858-linux.lists.archive=gmail.com@vger.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 am.mirrors.kernel.org (Postfix) with ESMTPS id E63911F30E53 for ; Mon, 22 Jan 2024 18:19:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3BBD948CD4; Mon, 22 Jan 2024 17:48:38 +0000 (UTC) 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 BB20548CC1 for ; Mon, 22 Jan 2024 17:48:37 +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=1705945717; cv=none; b=bnP9vv1h9qm07P7A2flle5VuKjiy+APSYFVhwlZ7lDiKPp87YcVv76aoSRWIMA5WYXC72jmKxsm0gvxJLX1tLHapfzy+Av65yBBlUeBR1XzOkuzu47MMkq7pm7ni7Qlrg4AluNGX0sY7f2vCXTL+2gfari/MDDZ9MUHZvLCW27E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705945717; c=relaxed/simple; bh=3F3G5Ww1SUZQsUMoJIkzqcCLWxQapyaD7dFyElSipKM=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GtJi/W0hQfmbxUC09e2E+7hLIU4K5ZxY8zaSaY0xYwjZ5dJFiOpwr0kzfAB/OTlmZxzKlFTnagKSBnB0cVJ1Qm/kztjvNngGKcMfZFPv7TXXhUf0QEMl34QZ4tLWNUhYB3RwjHaJWeucIyjsD7HpKDApx/KhyTtZt3PgmYlmbqc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E05E7C433F1; Mon, 22 Jan 2024 17:48:35 +0000 (UTC) Date: Mon, 22 Jan 2024 12:50:04 -0500 From: Steven Rostedt To: Mathieu Desnoyers Cc: Geert Uytterhoeven , Kees Cook , Linus Torvalds , linux-kernel@vger.kernel.org, Masami Hiramatsu , Mark Rutland , Andrew Morton , Christian Brauner , Al Viro , Ajay Kaher Subject: Re: [for-linus][PATCH 1/3] eventfs: Have the inodes all for files and directories all be the same Message-ID: <20240122125004.7bbf0b70@gandalf.local.home> In-Reply-To: References: <20240117143548.595884070@goodmis.org> <20240117143810.531966508@goodmis.org> <20240122100630.6a400dd3@gandalf.local.home> X-Mailer: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) 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=US-ASCII Content-Transfer-Encoding: 7bit On Mon, 22 Jan 2024 12:14:36 -0500 Mathieu Desnoyers wrote: > > Why use an improvised hashing function (re-purposed from > scripts/kconfig/symbol.c to a use-case which is exposed through a That hash is just salt to the real hash function, which is the siphash_1u32(). I added the name hash so that each file will get a little different salt to the hash. The siphash_1u32() is what the rest of the kernel uses for hashing kernel address space. > userspace ABI prone to kernel address leaks) rather than simply > reserving values by setting bits in a bitmap ? > > How many inodes do we realistically expect to have there ? If I only do directories, it is actually significantly less. > > On my 6.1.0 kernel: > > find /sys/kernel/tracing | wc -l > 15598 > > (mainly due to TRACE_EVENT ABI files) > > Hashing risks: > > - Exposing kernel addresses if the hashing algorithm is broken, Well this was my biggest concern, but if I truncate at least a nibble, with the unique salt to the algorithm for each file, how easily does that expose kernel addresses. The ei itself, is created from kmalloc() so you would at best get a heap address. But with the missing nibble (if I mask it with ((1 << 28) - 1), and much more taken away for 64 bit systems), and the added unique salt, is it possible for this to expose anything that could be used in an attack? > - Collisions if users are unlucky (which could trigger those > 'find' errors). > > Those 15598 inode values fit within a single page (bitmap of > 1922 bytes). > > So I would recommend simply adding a bitmap per tracefs filesystem > instance to keep track of inode number allocation. And how do I recover this bit after the inode is freed, but then referenced again? > > Creation/removal of files/directories in tracefs should not be > a fast-path anyway, so who cares about the speed of a find first > bit within a single page ? > When an inode is no longer referenced, it is freed. When it is referenced again, I want it to be recreated with the same inode number it had previously. How would having a bitmask help with that? I need a way to map an ei structure with a unique number without adding another 4 bytes to the structure itself. -- Steve