Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp13329529rwl; Wed, 4 Jan 2023 06:47:36 -0800 (PST) X-Google-Smtp-Source: AMrXdXsWwdehe1l2ukL+ZvpJHgDrN6/W5AsKCW/HYPBVZ+MLj/UujHPV1TdGwwefy+mt55m+lUeg X-Received: by 2002:a17:902:e403:b0:192:b3cc:dca5 with SMTP id m3-20020a170902e40300b00192b3ccdca5mr14626351ple.45.1672843655797; Wed, 04 Jan 2023 06:47:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672843655; cv=none; d=google.com; s=arc-20160816; b=KAqKbAipv2woj7Zget98nffW6PGwaOQkJRSJphVddZsqiLIYQyFpUm7MtWHbxZoKsd sQQF9Da9iv+2iaE+o3JXHkYHWFHnkfdjCPBXzYDd0tHou2jSzcI4VIty3ST/YH0l5r7b IITkz0pfW74ArgouXHCpju63o79Rf0lSz4ngO6UAXLC1GmnS+PS+nAkmdKZ1xsT/KWYQ LIkE46yb+xCLgCcbWw33ycYnfX/eQHvsnBCt7wSjreDPvCfaNW7LgB4E3aD5v/CWwWT2 8Gmz5FIfhg81tajDj6l1jq5Qi0qMtYaq2O62Nh9WhensnoWjxhQVSXnhrsbM3dKS6Lly 6Etg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:message-id:date:from :content-transfer-encoding:mime-version:subject:dkim-signature; bh=r18xklAWjx+TF7cp4UJMeABFqPp5Oxq9PAiHHqbB0/I=; b=YFxOM6ZjLXxibdw5w+qO3mdDPizLVL5qUcXa80Y1f5Gd9yLSNU7XBDXJZgviY2nCAQ M8juM2K7Sm2nCRXm0a27t7T4sViN+Y5w/hKZ6JyB7zOjTAbHfbUvI4WTxoOOF0g1WITr sUm3X8SN2d5hGC9jbMVAQR4Usl+y9IegLwE+l8hoyCxIIEh0IY/sOzuCwsl65cXOWFip bOhU1wMc8VcZuD8HKUxQRuaC7/uOqrz5dsCI43y2VsmNgrBgbMEjE2L9eb9NQ3mIRhCl rsbEro/xvOfdJmIg/iy1/pY59/V+2cmAaC2fpuojQeWkwNkDGN16fDFaN+osS2ekXvy/ D1Ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=PtY+76ii; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m10-20020a170902db0a00b00192bac60af2si14375609plx.473.2023.01.04.06.47.28; Wed, 04 Jan 2023 06:47:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=PtY+76ii; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235246AbjADOjM (ORCPT + 59 others); Wed, 4 Jan 2023 09:39:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234523AbjADOjK (ORCPT ); Wed, 4 Jan 2023 09:39:10 -0500 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 115FADA9 for ; Wed, 4 Jan 2023 06:39:09 -0800 (PST) Received: by mail-ej1-x635.google.com with SMTP id jo4so83099972ejb.7 for ; Wed, 04 Jan 2023 06:39:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=cc:to:message-id:date:from:content-transfer-encoding:mime-version :subject:from:to:cc:subject:date:message-id:reply-to; bh=r18xklAWjx+TF7cp4UJMeABFqPp5Oxq9PAiHHqbB0/I=; b=PtY+76iieGZzTCVc1gjR6aZ+8MvRz9PqsQ0ayTQxgKbt8QP7cSj/FZbnfstwRXPrMI 73s3I45OrA0oT2wKijU9NsqK7vtDWmHe3gBEfBLL23YK4TapuYRy+z8JV7JBDFlIfxk1 LbwDPzTXFQQv21t1CW87DQCQA/KsosQnCRulQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:message-id:date:from:content-transfer-encoding:mime-version :subject:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=r18xklAWjx+TF7cp4UJMeABFqPp5Oxq9PAiHHqbB0/I=; b=TB3m0jR3OotxovnhJ8waA29KOJNl/wyPFq7jGSmlPGzCh8WmCXrW8DX8LqEgErfi0b XphNEzFkqNALEE4tocN+jf4DEk11glgKq8ejUlOrxsR4ZNM0kvpMpZKdDBcLBUZ30pSc qFaJY86V65Yogj5J8VpNIoc7QfkOFXMU45GSYGBdT6IJsCJccRODCOLcMmjW6vghNA/k q3s4ceyS8nnswJWPlkHRHaoF3fQ0WkZKxiIjeZvyV+HNsoIHMZzm9z0q/F9ednE66zZM nzjt7gRLilMVf+SJoCWvutALvteDYREwsRl4sq7wnVLX091DSbd5CBycgMZQixcVGVBh Tbpg== X-Gm-Message-State: AFqh2kq5pYLI+WU9hezk6jCThHgs/0/Fx7Kclwm1UDNd7K3JzJqfUZwV j+zJCQ2tgQYFviT5K2L98U4kSw== X-Received: by 2002:a17:907:7d8f:b0:7b5:911c:9b12 with SMTP id oz15-20020a1709077d8f00b007b5911c9b12mr51581842ejc.1.1672843147655; Wed, 04 Jan 2023 06:39:07 -0800 (PST) Received: from alco.roam.corp.google.com ([2620:0:1059:10:a438:c7da:62e0:36f4]) by smtp.gmail.com with ESMTPSA id c8-20020a170906924800b0078de26f66b9sm15386659ejx.114.2023.01.04.06.39.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jan 2023 06:39:07 -0800 (PST) Subject: [PATCH v6 0/3] kexec: Add new parameter to limit the access to kexec MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAHWPtWMC/43PwWrDMAwG4FcpPs8lsp3a7mnvMXawZbkxSxOw27 BR8u4TPZZQchK/4P+EHqJRLdTE+fAQlZbSyjxxOH0cBA5hupAsibNQnVIAYGQqLcSR5A/9EspKjW 4SfLQEYLV2WXAzhkYy1jDhwN3pPo68HEq7zfXveWkBHl/v0QVkJ3PsIakOs7PwiUOdr+V+Pc71Ir 6ZXNQORjGDxjsNGiHGfoPROxjNjKFsyCsfUj5tMGYHY5gJ0XUeXfLO4QbT72B6ZiAmbTFkjfb1qX Vd/wFLtDDu2gEAAA== From: Ricardo Ribalda Date: Wed, 04 Jan 2023 15:38:45 +0100 Message-Id: <20221114-disable-kexec-reset-v6-0-6a8531a09b9a@chromium.org> To: Philipp Rudo , Eric Biederman , "Guilherme G. Piccoli" , Jonathan Corbet Cc: Ricardo Ribalda , linux-doc@vger.kernel.org, Sergey Senozhatsky , "Joel Fernandes (Google)" , Baoquan He , Petr Tesarik , kexec@lists.infradead.org, Bagas Sanjaya , Steven Rostedt , linux-kernel@vger.kernel.org, Ross Zwisler X-Mailer: b4 0.11.0-dev-696ae X-Developer-Signature: v=1; a=openpgp-sha256; l=2772; i=ribalda@chromium.org; h=from:subject:message-id; bh=OajjYlRvNHsgrXyvUbmCD5R6Ksvr+o7Qr/VxU7sn1d0=; b=owEBbQKS/ZANAwAKAdE30T7POsSIAcsmYgBjtY970v3EmwV32lI5jOI4b9gfVlAvFBW6wkzR0+PI jpl8aYOJAjMEAAEKAB0WIQREDzjr+/4oCDLSsx7RN9E+zzrEiAUCY7WPewAKCRDRN9E+zzrEiHrJD/ 9fEKDNuonXKXxBHNhx0IxcHbN/OOBcBuWjqTI4prRhjr/F/h2r6uFgSrokHEbNdjPBJhCLSFw5qmqP 5duMbJPDtzDnLBpZz7oWggPB0qGuGbdE0dJK+/6CeXDIWQaeLztkqPrP47gPG6o4XRia7wChR91J6V Of7wnXxZsxpfaKxNQOsLrCXPvIaplJZgH43vq6g9Got8Di372Ks2FcenODuE71OrmXf0N230vXajSC SHBKQalEt+J+c/bp+UFr3jAmessUxYoWC39B/F+apr/zq3YuebgeEbrmVV7XuHAuHozA5zsarWHfw8 meopL40YT/+AtimjB0bSIAd+Pd6pLDL4QY8NASwiYpAzX4X+8YV4qsKadvC1LUcQegcvUcwr2+g1c0 J1RpnKvE1t/ow4X1K+adRNCuaW2J0M06e2vNQnw+UhAVP+FsSoT+4TN8lgQt+A0JqqDBxAmwZA2VCN wLVNLFaRGPmK8aOx/5T3IdHg+HmcoMINhKOVNTh2Ruz9V0+jS69vJkOSocMZh61ljBJ2i82LcGIy4w 48f4f4p18CEzOjcdT6VPgOiSea4fRLfFcT5UOznlJtl9lk/W3AHPJe3PdVloA0hT57DPAJardujq4D xSpdxH9QMBvGdsR0eeh3eLVxiVXnXFufRy3WjyvpHLyzeVbC7H2Ao3dGDMPA== X-Developer-Key: i=ribalda@chromium.org; a=openpgp; fpr=9EC3BB66E2FC129A6F90B39556A0D81F9F782DA9 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add two parameter to specify how many times a kexec kernel can be loaded. These parameter allow hardening the system. While we are at it, fix a documentation issue and refactor some code. To: Jonathan Corbet To: Eric Biederman Cc: linux-doc@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: kexec@lists.infradead.org Cc: Joel Fernandes (Google) Cc: Sergey Senozhatsky Cc: Steven Rostedt Cc: Ross Zwisler To: Philipp Rudo To: Guilherme G. Piccoli Cc: Bagas Sanjaya Cc: Petr Tesarik Cc: Baoquan He Signed-off-by: Ricardo Ribalda --- Changes in v6: - Fix kexec type on kexec_file - Match the length of the table borders to the sections underline (Thanks Bagas!) - Fix typo on kexec_load_limit_reboot (Thanks Petr!) - Improve commit message (Thanks Baoquan!) - Link to v5: https://lore.kernel.org/r/20221114-disable-kexec-reset-v5-0-1bd37caf3c75@chromium.org Changes in v5: - Remove maxlen from ctl_table. Thanks Steven! - Link to v4: https://lore.kernel.org/r/20221114-disable-kexec-reset-v4-0-ab809c8d988c@chromium.org Changes in v4 (Thanks Steven!): - Uses sysctl instead or module_parameters - Pass image type instead of boolean to permitted - Fix typo on flag handling - Return -EINVAL for values that does not change the current value. - Link to v3: https://lore.kernel.org/r/20221114-disable-kexec-reset-v3-0-4ef4e929adf6@chromium.org Changes in v3: - s/paramter/parameter/ Thanks Ghilherme! - s/permited/permitted/ Thanks Joel! - Link to v2: https://lore.kernel.org/r/20221114-disable-kexec-reset-v2-0-c498313c1bb5@chromium.org Changes in v2: - Instead of kexec_reboot_disabled, add two new counters (Thanks Philipp!) - Link to v1: https://lore.kernel.org/r/20221114-disable-kexec-reset-v1-0-fb51d20cf871@chromium.org --- Ricardo Ribalda (3): Documentation: sysctl: Correct kexec_load_disabled kexec: Factor out kexec_load_permitted kexec: Introduce sysctl parameters kexec_load_limit_* Documentation/admin-guide/sysctl/kernel.rst | 25 +++++++- include/linux/kexec.h | 3 +- kernel/kexec.c | 4 +- kernel/kexec_core.c | 94 ++++++++++++++++++++++++++++- kernel/kexec_file.c | 11 ++-- 5 files changed, 127 insertions(+), 10 deletions(-) --- base-commit: 479174d402bcf60789106eedc4def3957c060bad change-id: 20221114-disable-kexec-reset-19b7e117338f Best regards, -- Ricardo Ribalda