Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1951899lqm; Fri, 3 May 2024 10:55:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVeaiC2NqGGYo3PZCavc6gFERLyoxlBsDrDGLNG5l7K6lMpY8YjSibCJwuq7u3lP93c0gD77UiEsKE5yfxeW+VDI2pIy//o7uEGneBFYw== X-Google-Smtp-Source: AGHT+IEkokdYjZoqIcbRqg8YoAZ9Vcbq52Oy2NTJU7Bppzm1OfQI5CB5ftTpENd153WIOF8HTl2O X-Received: by 2002:a50:9f85:0:b0:572:5f28:1f25 with SMTP id c5-20020a509f85000000b005725f281f25mr2166969edf.7.1714758957199; Fri, 03 May 2024 10:55:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714758957; cv=pass; d=google.com; s=arc-20160816; b=B+KBw7Zn2BZp08pkUpOC57+I613vV4kWPbuIs9KthJsJvJVUBdI7QC7PJuWKj/85ez M1xLdzKcfETKQ8VPNsC352FhUBCCzvE1yaxLfuAZzZAsX6k6cnf7K5UJXJZLW/BstGR+ KZ+GYoHwsN/PpH3l8eSR/eeLYnR1JDlxEjM9bftqvCTRBNDAPc0t7/Se8Ux7P9SzeLlR 3OVskbKl+VPlMKChlgGPUlPGEgHRLcj12c+TmSJFB9U/b03a1tqTTr8wK8sJeR/AVeU1 LuePzA7hg0LywfebSDCswQlmiLW2WlhitnPIvy3XX1p+upUjiuvGhRHED0SCtNiqQC7Z 8C5w== 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=P3szH4sxaPwAp0vnc9Q5nq9mDwhSGAgkyGp9dC8w3aY=; fh=1F+jc5ACmVdaCq+YlGjVc9gguoQqQnyCeV40PsBbMVc=; b=qbn2De/W/Thory0KJtoC8jm11P+9cXlIMs5lwEJgexa0HESnQPD2gWhoG+W/MkrITr PWxvCsdZebvDKaMWLAV80rvTi971qh/q5B7wehZaAESb+S5dosfLFHJjdLK33zzLLe6G yDIPdKkvV3VMA7cNIPQ44C9TCXufVqX24rIcG+qJwQHxtn7osLzXPnyJv+jPno2NLMGd Qtirakbs4zO9Xs6H8a9qdxxd/7kSr4KozXyvn9Y9zRXHMvViCHeMU/WM14+Bmf1p0yhE FT5K0kUmwtvFXXvnQi7H2H2JEn7P4d3hVNPKbwSilgJL2/Lnvrt/Kt3Nq7BVsYMpxibS +BRg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=I7Bpelm0; 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-167993-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167993-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.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 e10-20020a056402190a00b0057271a83c82si1753397edz.80.2024.05.03.10.55.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 10:55:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-167993-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; dkim=pass header.i=@chromium.org header.s=google header.b=I7Bpelm0; 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-167993-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167993-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 am.mirrors.kernel.org (Postfix) with ESMTPS id E84E41F22A92 for ; Fri, 3 May 2024 17:55:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3ECFE1586F4; Fri, 3 May 2024 17:55:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="I7Bpelm0" Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (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 2954813B593 for ; Fri, 3 May 2024 17:55:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714758938; cv=none; b=jEzTdeH7vrk03LyJ1pLsCQJQgw4Gcjeu6V9wqO9FJDjUDztc9J9+eXn9cRBFCmQSg/aL/6t4YS6gqWZGL0UTJU6Xx2XD2xAjOufaZWnr8skSQok7MITLWxHOyCuRHKHZTJ9L5gniTGP9R3IftBAnK61w4B/Jlqkd1eYqDLIPo8k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714758938; c=relaxed/simple; bh=y3FTe/yZF4coOVNZnP08rsN6uKtTbcXmWT1Sw/5yX0A=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=tBDnzir3fgNIWhViMEQJC41axOkv+HqXXdzYBqxli0zncEwDj4HQ0s0edE2O7nE0sZnpHmXeI93PjSz3OL745Hvw0TirFnC9wHuLyLK/ytu6khb8aB+WswYpy9zX+egQLd5p65hLK2oFs+4mYqcEgXeMxCfbzAgS+82X201z9rY= 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=I7Bpelm0; arc=none smtp.client-ip=209.85.214.170 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-pl1-f170.google.com with SMTP id d9443c01a7336-1eb24e3a2d9so70131285ad.1 for ; Fri, 03 May 2024 10:55:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714758935; x=1715363735; 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=P3szH4sxaPwAp0vnc9Q5nq9mDwhSGAgkyGp9dC8w3aY=; b=I7Bpelm0zmKoC7Il/cXvk491ccGh2erQBEUqfCrAaKsj7rD/V1Wri2IPC7V+ZZPGtZ SfUV2Sl/25OfdQjW7AXVYlm/MZViHGfzrtGBcgk3I26rPOW4uWpKw70FiBEbSfVXqaIx erQri9AeiWXq33z4IQEpZc3NDR06D1jd+n/8o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714758935; x=1715363735; 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=P3szH4sxaPwAp0vnc9Q5nq9mDwhSGAgkyGp9dC8w3aY=; b=XCny8BBbMHl8+JV/P32KlpVN7Nbprjiu0F1BVFfQ25OnVTfQDuTMGkpGWzCJLE/FK9 oAPsvOWsonHzeob7m8+XCxg5i79qvGRH1Fuq/1f3+uHETXaM9/yfL5nH24RZK6D9OQSH JtMXKzbQODKXU5plvwbPzmy88jT96sWanGXWgxe7TaQacqmJLS6nGrNXRHhUHW0k2ou5 GZ6cbe+f2xgMv/drB5XZIDRkUxcZY3SdE6gCiNhoCPXXEg09GNrTLMBbkasELj2H9XnM 84ciW92jmQHtdFZxJ6xJRzsVLrWfrExlf96k57/ES9YliJOiiMTfMgK8bhoYQdsuncnS Zccg== X-Forwarded-Encrypted: i=1; AJvYcCXIc+2mGWK4MhwIy8pc32vjV46E/2QtFp9W88Ks+1awSZWmVPX7pe/FHvLzIzcR/HNZDcDr1ZZzt4LpN2lKRIxJDR09pwAS5BpPYkYN X-Gm-Message-State: AOJu0YxJJ6LWbe06x+7O0he9FxYXyTFrZSfGHRhpnCOdLK0ZZXvSr0Wf q5yvjQ5jnYYGviDRdAvtnUqQXzKRI7dn894ikiTOImfY+sLcdATiLDPjIfTKDQ== X-Received: by 2002:a17:902:7615:b0:1e4:b4f5:5cfa with SMTP id k21-20020a170902761500b001e4b4f55cfamr3282835pll.27.1714758935489; Fri, 03 May 2024 10:55:35 -0700 (PDT) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id q7-20020a17090311c700b001e97772524asm3526577plh.234.2024.05.03.10.55.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 10:55:34 -0700 (PDT) Date: Fri, 3 May 2024 10:55:33 -0700 From: Kees Cook To: Thomas =?iso-8859-1?Q?Wei=DFschuh?= Cc: Alexander Popov , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Luis Chamberlain , Joel Granados Subject: Re: [PATCH] stackleak: don't modify ctl_table argument Message-ID: <202405031054.9FFA75B@keescook> References: <20240503-sysctl-const-stackleak-v1-1-603fecb19170@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: <20240503-sysctl-const-stackleak-v1-1-603fecb19170@weissschuh.net> On Fri, May 03, 2024 at 03:44:09PM +0200, Thomas Wei?schuh wrote: > Sysctl handlers are not supposed to modify the ctl_table passed to them. > Adapt the logic to work with a temporary > variable, similar to how it is done in other parts of the kernel. > > This is also a prerequisite to enforce the immutability of the argument > through the callbacks prototy. > > Fixes: 964c9dff0091 ("stackleak: Allow runtime disabling of kernel stack erasing") > Cc: stable@vger.kernel.org I realize I've already Acked, but does this actually need to be CCed to stable? > Acked-by: Kees Cook > Reviewed-by: Luis Chamberlain > Signed-off-by: Thomas Wei?schuh > --- > This was split out of my sysctl-const-handler series [0]. > > As that series will take some more time, submit the patch on its own, > as it is a generic bugfix that is valuable on its own. > And I can get it out of my books. > > Changelog in contrast to the patch in the series: > * Reword commit message to remove strong relation to the constification > * Cc stable > > [0] https://lore.kernel.org/lkml/20240423-sysctl-const-handler-v3-0-e0beccb836e2@weissschuh.net/ > > Cc: Joel Granados > --- > kernel/stackleak.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/kernel/stackleak.c b/kernel/stackleak.c > index 34c9d81eea94..b292e5ca0b7d 100644 > --- a/kernel/stackleak.c > +++ b/kernel/stackleak.c > @@ -27,10 +27,11 @@ static int stack_erasing_sysctl(struct ctl_table *table, int write, > int ret = 0; > int state = !static_branch_unlikely(&stack_erasing_bypass); > int prev_state = state; > + struct ctl_table tmp = *table; > > - table->data = &state; > - table->maxlen = sizeof(int); > - ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); > + tmp.data = &state; > + tmp.maxlen = sizeof(int); > + ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); > state = !!state; > if (ret || !write || state == prev_state) > return ret; I can pick this up; thanks! -Kees > > --- > base-commit: f03359bca01bf4372cf2c118cd9a987a5951b1c8 > change-id: 20240503-sysctl-const-stackleak-af3e67bc65b0 > > Best regards, > -- > Thomas Wei?schuh > -- Kees Cook