Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3617671rdb; Wed, 13 Sep 2023 18:52:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEt1UoIeDuAPLjGUaqqiPVWV/nIJH7O0h2rjCXWQX6aa5WLee6bf4BBo/5uxP9xe3TLldu6 X-Received: by 2002:a05:6a20:bf11:b0:140:a25:1c1d with SMTP id gc17-20020a056a20bf1100b001400a251c1dmr3436541pzb.51.1694656378640; Wed, 13 Sep 2023 18:52:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694656378; cv=none; d=google.com; s=arc-20160816; b=Vbw5NggkjwVnX2LJ8EGTxju/V8cWt3Jf7HH1tVA9CyyF4FM2raLg4M232PgdqQOH1M /92sMOZ043yJkOKUTbmdmcfWINVtXGMYROSlEu8ulkyFCpvQ7prryVi2TNKRQJO6nRXE 67OiLva+MQPY46iXk52rdI/z/g+UDQHx1TM3HE3NrsmNnE65/BBWTjmz2xJprSWaIMTE 3H8VRzXOxdrHgi2ax3kmuI1KR3Wyw+ZhgWCGzl6s6AbKWQpzUPkjdhQAeJxfprSIKqQM XBKGHnitTdOWeT7swA/kPZHk7nQ/qCWRASVu1Uu95TMApftl05K6nl7QCWTVqEW9eVp4 WsoQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3+o1klssi8z6V7Hutl80JDMigLiMWnI+Ey057vo8Nc4=; fh=bHBp+PJACSvucKAvnO3bf9DILRtfHT5RT33jsVWkQ4A=; b=lUlSXlvv2XRnRvcf69CjIeLzI/AufEiVeDyJvUuncZT+/pd87s+o0Nav2USDWTtEv1 chNc3+0bBVZvZw9FTJlYXOytnONCWWifbPVF+fjkSv/HS6Pxmy3QGqCKxXNzbASTt8uf Ys2UtQTAz+AmQNH4B95xBij4pmWRfC/DpxWRM6pX5VZz5s6grCopHHCrwZN2qSl4ExDq sGFGGTrQQBM+TEqU3C0pBU5Q3kdfR5QxBqDg/wXK5B1mImjXFCwfGunXlpAcY0QWGKJd 2wIsZHtTBy7IlZkVvw4neQ9VxDwO6qVsJYWfqHkdD1DGvbPA9eQL4Mj42O53EHZ+3jPP qDBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QTUysuG4; 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 Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id g14-20020a17090a4b0e00b002680f4e8969si560844pjh.95.2023.09.13.18.52.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 18:52:58 -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=QTUysuG4; 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 0D432808E668; Tue, 12 Sep 2023 08:08:07 -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 S236257AbjILPIC (ORCPT + 99 others); Tue, 12 Sep 2023 11:08:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236236AbjILPHt (ORCPT ); Tue, 12 Sep 2023 11:07:49 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80419CEB for ; Tue, 12 Sep 2023 08:07:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694531265; x=1726067265; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IZARSdoFCqlQ8R698PWQsBWxz7kOn+9GL/Gy+QZMtVQ=; b=QTUysuG4oGVdHe7Sxr2STVwLOAenqsdONirLY/pR793dMV3OJlfWAbou p9/63hxXp2vsERnpVb6KvyG780FIVuVqTnbsSp/N130hHaeVjY2Yc8zS4 tLI8ULo8jlWYFTQSYot4fUuNbNYHInlRt5P1/NAP+8uQe/lpCo+aJTf0I Vd8NRJ/KUdD7HOHp+HTLmZbKUgOA/VIHWApuBZvb0WDs7kt8q7qCNV98f YBfphW91H1jUuf1/H4i4Ze/KeSBO9ZNlrJWN54udfQqV4WiyvOf4H19oS xxyfFuOWSEU5egt1gXzvGj69chyGJGBFPy7l/uYbHTJOl9rYyKbmerlct Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10831"; a="368662560" X-IronPort-AV: E=Sophos;i="6.02,139,1688454000"; d="scan'208";a="368662560" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2023 08:05:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10831"; a="773065029" X-IronPort-AV: E=Sophos;i="6.02,139,1688454000"; d="scan'208";a="773065029" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 12 Sep 2023 08:05:55 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 8E53FBC2; Tue, 12 Sep 2023 18:05:54 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-kernel@vger.kernel.org Cc: Luis Chamberlain Subject: [PATCH v1 4/6] params: Use size_add() for kmalloc() Date: Tue, 12 Sep 2023 18:05:49 +0300 Message-Id: <20230912150551.401537-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230912150551.401537-1-andriy.shevchenko@linux.intel.com> References: <20230912150551.401537-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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]); Tue, 12 Sep 2023 08:08:07 -0700 (PDT) Prevent allocations from integer overflow by using size_add(). 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 930a5dc2f004..fd11c731475f 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; - p = kmalloc(sizeof(*p) + size, GFP_KERNEL); + p = kmalloc(size_add(sizeof(*p), size), GFP_KERNEL); if (!p) return NULL; -- 2.40.0.1.gaa8946217a0b