From patchwork Mon Oct 2 12:48:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 14818 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1610123vqb; Mon, 2 Oct 2023 11:22:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH1ndcATdz9h/znKk1abJ1qK52IDMC0UyV2JXX6A23lzH/LdSpQpBiv2zlqssX6NVjUjgkT X-Received: by 2002:a17:902:b708:b0:1c5:9f52:6a5b with SMTP id d8-20020a170902b70800b001c59f526a5bmr8943932pls.42.1696270938296; Mon, 02 Oct 2023 11:22:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696270938; cv=none; d=google.com; s=arc-20160816; b=LSBkkUvh73g83uuYK68R1W6uFJY01zjzGwGDuMZRNbkFb0BbynxAcComdGE6TvlSh5 tyP6u8alSdAh2ZS9ku7zSCQYtyh6hFs1Q9E7PjatGugX0+pAa2uePdiTcagG3WUt0gEx jMeE9n7fxUkHXA7IS6US9060iVSiUJQCGDUbVe/9tuMirc7b2ana+er+lssSJzolHVKR c4w/Jl5/Ar7kMmg3qlHeSHrNpSJsirjUW+L3lMYoGxkKbgX4P6tLahDU8UOchjmEm8Vo oh+5Bs/xEyP823K06G2OYAQ2aMrHhlUbjtTfsqJCcZnQwXjOBMSAAaOSxDenPWoY2Ksv Apew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=L1/7YsIjcpGErDvJhK1np80qSx0KRG38OOFbtAY8tD0=; fh=oVbnzL2KMzayBCxXzlIJHVRmweFMJVXx7xFAc95882A=; b=ys6b47ZZ8u/BGB4H3i6Gbu5D8IYmVr0XxsYbBmgDXWsPmlm93QEKz06dwTwSlFVqun WaMPw5+O2XltUva528Yu+eaX6v0zs4aS2LL59bonCrIC7zblsjTbmCcWCtU1DhlUc8bs CH2g8JvIiu52L1JiWip/RhnFx9weLVuV9YzhujcSI46FBco7co+rn4Xd3r1I0VcXF0Y+ FCR3x7mGkvzQmBTJjLqEWOF/UgZtwxjNscjYOMf6UmqhNBY5pl02LlB35S9Fx3fIKzRO vWIHkV6vpFGQjbkRpJsvLbaWu2OuUulTK4uEomGwieKQTU0B0Z8iNd2JPOEkjY9pM0IC zc6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=eODZ2kHe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id li16-20020a170903295000b001bc02b730f3si25073625plb.242.2023.10.02.11.22.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 11:22:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=eODZ2kHe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 9CD79809D3C0; Mon, 2 Oct 2023 05:49:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237062AbjJBMtJ (ORCPT + 18 others); Mon, 2 Oct 2023 08:49:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231138AbjJBMtI (ORCPT ); Mon, 2 Oct 2023 08:49:08 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F7C0A6; Mon, 2 Oct 2023 05:49:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696250945; x=1727786945; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=YwAIlro9IwnHVZWXrpT/1pxHBCu++yJ5R+zkC9sbLRY=; b=eODZ2kHebx3ECLhzGQwZdNRVkG/bHACROm7X93P0YyIkxQCWSxQzB49I 8CSn+IeiAMc2lDQHTXimd6G6isoInkmJH0EB72iaZrhzpXurME2aP0RVX VpPqolQ4O3OnrG1d9fygb8sZMDXO+PVBal2Mz3z58d83BKTThongJqpm6 6mlc1Xwaq3qwZpfBb8QROtb9fuvM5DVu26gmSHaCRQHBrWBvaF0axxNBj 3/nc16Jjyi11Gus3gGk0aQkkZ85jyigwXrCQxEaDdcoJQ5Gaasa5UsWVQ nXY1F1BDEeVitUXIJEc3tEOoXXsjO/8EueMIQLOkUwhuSK13OU8uE20Wl g==; X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="381517977" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="381517977" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Oct 2023 05:49:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="894127811" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="894127811" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 02 Oct 2023 05:47:42 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id E2AC214AF; Mon, 2 Oct 2023 15:49:01 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Luis Chamberlain , Kees Cook , Greg Kroah-Hartman Subject: [PATCH v2 0/5] params: harden string ops and allocatio ops Date: Mon, 2 Oct 2023 15:48:51 +0300 Message-Id: <20231002124856.2455696-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 02 Oct 2023 05:49:16 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778668995453630384 X-GMAIL-MSGID: 1778668995453630384 A couple of patches are for get the string ops, used in the module, slightly harden. On top a few cleanups. Since the main part is rather hardening, I think the Kees' tree is the best fit for the series, but I'm open for another option(s). Changelog v2: - dropped the s*printf() --> sysfs_emit() conversion as it revealed an issue, i.e. reuse getters with non-page-aligned pointer, which would be addressed separately - added cover letter and clarified the possible route for the series (Luis) Andy Shevchenko (5): params: Introduce the param_unknown_fn type params: Do not go over the limit when getting the string length params: Use size_add() for kmalloc() params: Sort headers params: Fix multi-line comment style include/linux/moduleparam.h | 6 ++--- kernel/params.c | 52 ++++++++++++++++++++----------------- 2 files changed, 31 insertions(+), 27 deletions(-) Reviewed-by: Kees Cook Reviewed-by: Luis Chamberlain