From mboxrd@z Thu Jan 1 00:00:00 1970 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 90C74158A3F for ; Wed, 19 Jun 2024 20:51:16 +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=1718830276; cv=none; b=kR2qjaseQpAQek2h2Y6yT3h6yki1aS8iK3nGCrzcokRxK4GpcquSLyVsXD2V5CvtqziNgV8N7ExWEGG14OfTIy2plaeAzHFPFzwhuQjvIAW6u4HzJ9Ay8IKAqsobUQj8UfVZRFmJVGNBiON7cKXmJz4slESoqRMJastQ4xDYaiI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718830276; c=relaxed/simple; bh=U7Aue/9gZakibq2SShV4eRH7fTOmLT2KdGybqwW2Qx0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Y8s0h4cCzBf0fTDAtnWk934BqIxv9hfV7y47QnRpZBbxKoV4byJBuMDh3BRsKeOKrzTttk9XKZRr1QxXzMvaki+ypIqVK4OEbyWdfJ4bbKdn82npDyiiFMyLv4bmjSs2RpM174caQXfR3gmtVmEW7G/N82IHOwQzUou68rngXKw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Evp2+z9n; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Evp2+z9n" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29CF0C2BBFC; Wed, 19 Jun 2024 20:51:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718830276; bh=U7Aue/9gZakibq2SShV4eRH7fTOmLT2KdGybqwW2Qx0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Evp2+z9npj82wDOpAkNemSiY48JqFv549BCbR0qNjqdz8vdm6sYYnqokMGSmCenYv O7NZhLO4kPEdV41qPplzORf9TRb31bM+7s3l6b3iyb0ckYgyZGTdj2+ontnr4fYXDB 0C0oIaYQImPDbhPA3PnQXsTSLTsDz+6wGwscaNpoHnaZL7uy6Ja2+9fBNLN+jJef9y tEw8HDL0HXCFQBjRzCe7s5DGIEc5V698kuHgDfME/tPys/BlJtq2kBZDKLzUMxFD3V p/Iad5ADhu7af36wQXmmirhKVZAUk3xd5QJQlT+M47Bcj1JUJuuEgPumr8di0lYJu4 gWqdO7cwT/KgQ== Date: Wed, 19 Jun 2024 13:51:15 -0700 From: Kees Cook To: Thomas =?iso-8859-1?Q?Wei=DFschuh?= Cc: Joel Granados , Luis Chamberlain , Andrew Morton , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] sysctl: treewide: constify the ctl_table argument of proc_handlers Message-ID: <202406191350.BB98FF1@keescook> References: <20240619-sysctl-const-handler-v2-1-e36d00707097@weissschuh.net> 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: <20240619-sysctl-const-handler-v2-1-e36d00707097@weissschuh.net> On Wed, Jun 19, 2024 at 12:09:00PM +0200, Thomas Weißschuh wrote: > Adapt the proc_hander function signature to make it clear that handlers > are not supposed to modify their ctl_table argument. > > This is also a prerequisite to moving the static ctl_table structs into > read-only data. > > The patch was mostly generated by coccinelle with the following script: > > @@ > identifier func, ctl, write, buffer, lenp, ppos; > @@ > > int func( > - struct ctl_table *ctl, > + const struct ctl_table *ctl, > int write, void *buffer, size_t *lenp, loff_t *ppos) > { ... } > > In addition to the scripted changes some other changes are done: > > * The "typedef proc_handler" in include/linux/sysctl.h is changed to use > the "const ctl_table". > > * The prototypes of non-static handlers in header-files are adapted > to match the changes of their respective definitions. > > * kernel/watchdog.c: proc_watchdog_common() > This is called from a proc_handler itself and is als calling back > into another proc_handler, making it necessary to change it as part > of the proc_handler migration. > > No functional change. > > Signed-off-by: Thomas Weißschuh This looks good! I'll be glad to see these all be read-only. :) Reviewed-by: Kees Cook -- Kees Cook