From nobody Thu Dec 18 18:00:53 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF6EEC5AD4C for ; Mon, 20 Nov 2023 15:14:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234405AbjKTPOe (ORCPT ); Mon, 20 Nov 2023 10:14:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234151AbjKTPO3 (ORCPT ); Mon, 20 Nov 2023 10:14:29 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7B3FA4; Mon, 20 Nov 2023 07:14:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700493265; x=1732029265; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=D5Ir1Vj8OLtklsn72GYygYA1+G2UYfWZWZVSidHq6PI=; b=kcKTvZvwVGtGylf8gdQDbV6eMPUKloNWG8khdyNa0a2vCPMKl/VR/fcJ weRdhwkgBnA/hhMzWTwx4D6sIOHvf/avkufbI3LXmF+q45/r/Te0pf5Wr ha61WZfBYjpkrEwVA6OVuZLKR6RKmGBaWXjx9nURxwQQzF7llUPiF3+j3 AvMfVPLFBlMnGVa9+a1BfC1bB/SLCUnLLusBxGngAratzb4ivnWBJvcR9 72cu+s/+dLZd1AImLm6I1OP0MA+6FX8hi2TvUWESXZhEV/iHMn/POWOSD 8U4pXSToIu5teX6CpdGlaYFjxADvuN3FxptSvtq5RXhIifBzknypmqDuk g==; X-IronPort-AV: E=McAfee;i="6600,9927,10900"; a="422730970" X-IronPort-AV: E=Sophos;i="6.04,214,1695711600"; d="scan'208";a="422730970" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Nov 2023 07:14:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10900"; a="1097766557" X-IronPort-AV: E=Sophos;i="6.04,214,1695711600"; d="scan'208";a="1097766557" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 20 Nov 2023 07:14:22 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 6093C12A; Mon, 20 Nov 2023 17:14:21 +0200 (EET) From: Andy Shevchenko To: Luis Chamberlain , Kees Cook , Andy Shevchenko , linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman Subject: [PATCH v3 3/5] params: Use size_add() for kmalloc() Date: Mon, 20 Nov 2023 17:11:44 +0200 Message-ID: <20231120151419.1661807-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20231120151419.1661807-1-andriy.shevchenko@linux.intel.com> References: <20231120151419.1661807-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Prevent allocations from integer overflow by using size_add(). Reviewed-by: Luis Chamberlain Reviewed-by: Kees Cook Signed-off-by: Andy Shevchenko --- kernel/params.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/params.c b/kernel/params.c index f8e3c4139854..c3a029fe183d 100644 --- a/kernel/params.c +++ b/kernel/params.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -48,7 +49,7 @@ static void *kmalloc_parameter(unsigned int size) { struct kmalloced_param *p; =20 - p =3D kmalloc(sizeof(*p) + size, GFP_KERNEL); + p =3D kmalloc(size_add(sizeof(*p), size), GFP_KERNEL); if (!p) return NULL; =20 --=20 2.43.0.rc1.1.gbec44491f096