From patchwork Tue Apr 23 07:54:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13639459 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BCDD6C4345F for ; Tue, 23 Apr 2024 07:56:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2C4176B00C3; Tue, 23 Apr 2024 03:56:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 273D96B00C2; Tue, 23 Apr 2024 03:56:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 115A36B00C5; Tue, 23 Apr 2024 03:56:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id E4C6E6B00C2 for ; Tue, 23 Apr 2024 03:56:06 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 9304540D02 for ; Tue, 23 Apr 2024 07:56:06 +0000 (UTC) X-FDA: 82040038332.29.330878A Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) by imf24.hostedemail.com (Postfix) with ESMTP id 7F11318000D for ; Tue, 23 Apr 2024 07:56:04 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=weissschuh.net header.s=mail header.b=Z4eTOEAy; spf=pass (imf24.hostedemail.com: domain of linux@weissschuh.net designates 159.69.126.157 as permitted sender) smtp.mailfrom=linux@weissschuh.net; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713858965; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=reLIALz4yrGPa2Maf42WE5W2xh6MNwrmYJFLiHtadB4=; b=Jm5/iaojfq5QEQZa5gqRNF001wOeSfzJmL3NgGWBh7hGD3FT3zosEB7tbDzwTs0EipD6GS uMb/8l4wMyAyue49jv6PtZGhjwT4i81O2wAAm++nLwb0nndhKC14B1LsG08qhlgRWZt8IQ wZhyECrM3e6eF5ZhNVGw5z5sD3RAG5g= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713858965; a=rsa-sha256; cv=none; b=0iBclhePqGqCyyDWJ14sIvD+K8SIpHsFUbSWtU3qLW3Xy+6H4qjW6aLh4O+agR2wBB3xG0 tlBCJnlfOmi97Yl+NGOFCQURmycSN4O0CipNthjgoMd44sqCuPogUoWCBpRHzGzM5FWkNL hRFH1Vc5rcziCWDv3Wg6+Pf8Bifxxyw= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=weissschuh.net header.s=mail header.b=Z4eTOEAy; spf=pass (imf24.hostedemail.com: domain of linux@weissschuh.net designates 159.69.126.157 as permitted sender) smtp.mailfrom=linux@weissschuh.net; dmarc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1713858962; bh=D/3OJwMoANYNDnHN43YEhKh/XOzsWgZJBxcvKVpFvHo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Z4eTOEAyeZGZRhMLErDlHrOzyIn7K/DlkM60MPZgILl0NsHakg85D489lgcJ2pyps w8ZjrPHlpbLbeknooUuGV8AX44PHoyXa1MFbZ8JyqpCmrdU3drnEDl22/6rS7GAbFk mLBVLjPqI1ce59ORnQdEOqbJ1Zk5A8F74faI2Ijw= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Tue, 23 Apr 2024 09:54:36 +0200 Subject: [PATCH v3 01/11] stackleak: don't modify ctl_table argument MIME-Version: 1.0 Message-Id: <20240423-sysctl-const-handler-v3-1-e0beccb836e2@weissschuh.net> References: <20240423-sysctl-const-handler-v3-0-e0beccb836e2@weissschuh.net> In-Reply-To: <20240423-sysctl-const-handler-v3-0-e0beccb836e2@weissschuh.net> To: Luis Chamberlain , Joel Granados , Kees Cook Cc: Eric Dumazet , Dave Chinner , linux-fsdevel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-mm@kvack.org, linux-security-module@vger.kernel.org, bpf@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-xfs@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, kexec@lists.infradead.org, linux-hardening@vger.kernel.org, bridge@lists.linux.dev, lvs-devel@vger.kernel.org, linux-rdma@vger.kernel.org, rds-devel@oss.oracle.com, linux-sctp@vger.kernel.org, linux-nfs@vger.kernel.org, apparmor@lists.ubuntu.com, =?utf-8?q?Thomas_Wei?= =?utf-8?q?=C3=9Fschuh?= X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1713858961; l=1205; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=D/3OJwMoANYNDnHN43YEhKh/XOzsWgZJBxcvKVpFvHo=; b=1RhNomBbqj6XFaD6ZYOxEHBLV6bfBHp2WGUjkt4XBn/Ez17CpMDHBnau1hMCabUBp0fIJIUhv lq3ewsWLz9gCbCEhY4DcLZnRRhb9Y2u6rar0aoKgOs7QrHrAJv1mc4Z X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= X-Stat-Signature: 6rq9xkdw33r3mdudxdco8nenq5446nwt X-Rspamd-Queue-Id: 7F11318000D X-Rspamd-Server: rspam06 X-Rspam-User: X-HE-Tag: 1713858964-35127 X-HE-Meta: U2FsdGVkX1+fTsT/goaCRPAwh15ZEchiyojVY3lhKlGlgUwSgJt1k9WXiy8PU1K7tAKTcidpdYAzTWgP4F1rDfQp7X5Tuh01a8Sr/xxRZMmaGSmGpHzyts0kiyMblynB1bAmAGbUsUE4+oNdUJ1KEO5P9i8+yb7vaavAlbAe27hWzvnaFFKeWxPU3mC5wqkHoRyyQywCIOa1i6ZyQ2BJz5iB4+zZ196VCKSX7MxYfs/hlpGUoZr1fVzPmQuRzr3e8s2tv7lC9zoMmbaok/JQHh/wWw2huCYLUcbeShrnOPWD0i8EJpOlvpjMKg3E8YqUq9U4x90DDUzjXgvCPCTA07hF6ObcfcBWN9pp9hla9yTHLzNLrED879xaw7EIQXO9gInb8I6Aniesr7DupOKRzoKOEtm40jz+eh+33Ud3pm0Y3daVnT+5YVD41q/PbBQT/NQBq3qrDHeig+o7ImOh9yIJ51zuEJAeU6lT00GKsQUL/ggXd8GMPd4HD1zauE5g3772icbr+//65zvVEt2VlCMmIfrYRgy9eDNyDuMyoThe4CI75CbzOZVtZHKzwCitkqjnP3W1qjhy3nByHD6inok8NA7Rb1qfjWWGKJVPuCQvXobyDWlK9NYnnkZ0oHcabk5ek8Vm1dqBIEyOazrXTp1wbncrz5YbGmx9VbGvGyQmd3QsVL/cZyubb+fEZKWCvKMZHbA8s1QHxclYsTJT8T/IuGSIp9bX9BBeJunPfJ/XnYqG/dnVh1UaTitq1wCwJuHUvb8rqGBrPHItR6KOQf/8MRu16x+9hj3edfItChKNLgGjvMNMq6O0dDTubFNpCcTzyyAHImo= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: In a future commit the proc_handlers will change to "const struct ctl_table". As a preparation for that adapt the logic to work with a temporary variable, similar to how it is done in other parts of the kernel. Fixes: 964c9dff0091 ("stackleak: Allow runtime disabling of kernel stack erasing") Acked-by: Kees Cook Signed-off-by: Thomas Weißschuh --- kernel/stackleak.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kernel/stackleak.c b/kernel/stackleak.c index d099f3affcf1..558b9d6d28d3 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;