From patchwork Mon Dec 4 07:52:21 2023 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: 13477857 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="ci3b+tBl" Received: from todd.t-8ch.de (todd.t-8ch.de [IPv6:2a01:4f8:c010:41de::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A430FF; Sun, 3 Dec 2023 23:52:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1701676352; bh=IxovWkSQa7nkG31gg70HY4PZ86eNzdXLGZdnYvGdlOk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ci3b+tBlQJ2I4Tnz6Uq8xCRvClO69u71LCh7Jwtj+5JsnWUJoaWhvTg3js+PuZNVW tirBQ8o0jdqrYvHi8MAckWJ8O/mudw3ffSFWracoTmFkEf2CtxM9hp7OXWuLsgmKJf 8DARgLvu9Mjh2qEXOkDlubwYy0CivYcuPoJ8UMQo= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 04 Dec 2023 08:52:21 +0100 Subject: [PATCH v2 08/18] stackleak: don't modify ctl_table argument Precedence: bulk X-Mailing-List: linux-hardening@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231204-const-sysctl-v2-8-7a5060b11447@weissschuh.net> References: <20231204-const-sysctl-v2-0-7a5060b11447@weissschuh.net> In-Reply-To: <20231204-const-sysctl-v2-0-7a5060b11447@weissschuh.net> To: Kees Cook , "Gustavo A. R. Silva" , Luis Chamberlain , Iurii Zaikin , Greg Kroah-Hartman , Joel Granados Cc: linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1701676350; l=1076; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=IxovWkSQa7nkG31gg70HY4PZ86eNzdXLGZdnYvGdlOk=; b=qMyrGJ0w/4+XhOWDiE66KEjMCj0gweurC/6oQwk/Krqtt1DIpUqZeI5jGJHKrmVOFeGke54pt YQi71Ea3sghBwYXo0q8Kz3ZhIgB+zOH6G6jdpErT6vSnyCISy0KxjSU X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= 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. Signed-off-by: Thomas Weißschuh Acked-by: Kees Cook --- 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;