From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Biggers Subject: Re: [PATCH v3 1/1] psi: Fix uaf issue when psi trigger is destroyed while being polled Date: Wed, 12 Jan 2022 11:04:01 -0800 Message-ID: References: <20220111232309.1786347-1-surenb@google.com> Mime-Version: 1.0 Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1642014243; bh=NVaZp2ydCmNzbicjZMh52GQ0rIxQwNb+Kp0iuqAB1/A=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=BLy1WYMWrnDx3II9MNUcyZm67FswTvtppwb42AH+m6CyAg2MsyONUR2F/M0hYKOR0 ltsmh8l9oBFr8Tq1pGZ6topPUBgiLXWzNK8JvPbJ8EEavgueAzlg+ecblHsIYUcy2e r1x1G/yOX1A3VD/FxKp4hHNN3iYMud+KxokmcowWe6SRxsYJjMh6RH+jdJ/IkOiqEM qI9SEHTTrFnqFfju0kVllCSgaZcw9XmeSNb5cRBiKooXwqE2hJnMTBlFfajr3hihdl sWJ+c6VkM0BR767ibjeYM/bZhHMdcsmW7VTzYNSdnFdYkCX1p+TlqD7nv9vSr2Eowv rXm9CF+vgiBIQ== Content-Disposition: inline In-Reply-To: List-ID: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Suren Baghdasaryan Cc: Matthew Wilcox , Johannes Weiner , Linus Torvalds , Tejun Heo , Zefan Li , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Benjamin Segall , Mel Gorman , Daniel Bristot de Oliveira , Jonathan Corbet , "open list:DOCUMENTATION" , LKML , cgroups mailinglist , stable , kernel On Wed, Jan 12, 2022 at 10:53:48AM -0800, Suren Baghdasaryan wrote: > On Wed, Jan 12, 2022 at 10:44 AM Eric Biggers wrote: > > > > On Wed, Jan 12, 2022 at 10:26:08AM -0800, Suren Baghdasaryan wrote: > > > On Wed, Jan 12, 2022 at 10:16 AM Matthew Wilcox wrote: > > > > > > > > On Wed, Jan 12, 2022 at 09:49:00AM -0800, Suren Baghdasaryan wrote: > > > > > > This happens with the following config: > > > > > > > > > > > > CONFIG_CGROUPS=n > > > > > > CONFIG_PSI=y > > > > > > > > > > > > With cgroups disabled these functions are defined as non-static but > > > > > > are not defined in the header > > > > > > (https://elixir.bootlin.com/linux/latest/source/include/linux/psi.h#L28) > > > > > > since the only external user cgroup.c is disabled. The cleanest way to > > > > > > fix these I think is by doing smth like this in psi.c: > > > > > > > > A cleaner way to solve these is simply: > > > > > > > > #ifndef CONFIG_CGROUPS > > > > static struct psi_trigger *psi_trigger_create(...); > > > > ... > > > > #endif > > > > > > > > I tested this works: > > > > > > > > $ cat foo5.c > > > > static int psi(void *); > > > > > > > > int psi(void *x) > > > > { > > > > return (int)(long)x; > > > > } > > > > > > > > int bar(void *x) > > > > { > > > > return psi(x); > > > > } > > > > $ gcc -W -Wall -O2 -c -o foo5.o foo5.c > > > > $ readelf -s foo5.o > > > > > > > > Symbol table '.symtab' contains 4 entries: > > > > Num: Value Size Type Bind Vis Ndx Name > > > > 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND > > > > 1: 0000000000000000 0 FILE LOCAL DEFAULT ABS foo5.c > > > > 2: 0000000000000000 0 SECTION LOCAL DEFAULT 1 .text > > > > 3: 0000000000000000 3 FUNC GLOBAL DEFAULT 1 bar > > > > > > > > > > Thanks Matthew! > > > That looks much cleaner. I'll post a separate patch to fix these. My > > > main concern was whether it's worth adding more code to satisfy this > > > warning but with this approach the code changes are minimal, so I'll > > > go ahead and post it shortly. > > > > Why not simply move the declarations of psi_trigger_create() and > > psi_trigger_destroy() in include/linux/psi.h outside of the > > '#ifdef CONFIG_CGROUPS' block, to match the .c file? > > IIRC this was done to avoid another warning that these functions are > not used outside of psi.c when CONFIG_CGROUPS=n > What tool gave that warning? - Eric