Message ID | 20231120151419.1661807-4-andriy.shevchenko@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d903:0:b0:430:37f2:e94a with SMTP id dt3csp2334562vqb; Mon, 20 Nov 2023 07:15:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IF8UhZ+W9bM+u4AYI8sQNmuWo+vA6dzVXRM3CARL+eyQPrwv50R89zUyv0NUG9nCZcXX9BO X-Received: by 2002:a17:903:41d2:b0:1cc:3544:ea41 with SMTP id u18-20020a17090341d200b001cc3544ea41mr10637042ple.46.1700493337596; Mon, 20 Nov 2023 07:15:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700493337; cv=none; d=google.com; s=arc-20160816; b=XID/Ad86WWM5j5+Hy+Qq153FItZYwWd5UMZiz2Ij7uJtU/mZqzPWXs6B74c2otE9TJ U85NcFCScgNhOJkGSgbg8JqwLcMA2CZKScmkD+jpZKumh1cO+5Pr1yJy0VUyONHOXs3Y wTrq9gcNUEisI0ic9hvnZ3ihnU58MjhXYZ3Kj+Phj5eAJeKHIbzKMg2zCJGZAv1U/xYF rE6fg75rcgb3+5OpYbOax9pMd65wGd/7csONpV+yEReIdqjo+ee0/liEtPKGrXye4FKh V1bFoAQLZvWEgWoGmKZlsUWwhUHN0zp4kBYCQ4KYj7mWcPhQk3IzXKGazz0Ti14eovPe 07HQ== 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=81zymCTZI14gqo/LjE3x48M7iRkLOUro4olG/Ylk3vc=; fh=3VDKuUpnZHU/E7Q667FFh57Tg9oMevOil/UrLftGKk8=; b=vYspsb7VRBCpg8trI0dVXpGh80TwV9wCIUBLpLSPIF7a0enOa4DGDp07oYsvkavcCO PevddCU5TlEz5/NKxUv4/Ly41OnrXQPwVnoxGvhj10zWnIimkh9ousNNCqFTelREMNsj qDTWgpmOi8Wlnqx9CWu1wd9Oe5da0YaXcCnQoUAq2XlthDWeti66J5XAWFFH75cxzUZR c0HgdTHIWenQIg3gICNKVqaRRl4kpzBryhK5Uu4Ff99hPFVug1rmQIfvlDiZU6E6jzbv AXp73EQEhIOXCvL4CS4CGLnvgQewZh2mhG+YUILwPjExPkQTrZ65SwcFAcV8YF7Aiyka Wgug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kcKTvZvw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id w19-20020a170902d3d300b001b674055d72si7938991plb.621.2023.11.20.07.15.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 07:15:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kcKTvZvw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 2AE638051B38; Mon, 20 Nov 2023 07:15:03 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234402AbjKTPOd (ORCPT <rfc822;heyuhang3455@gmail.com> + 27 others); Mon, 20 Nov 2023 10:14:33 -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 <rfc822;linux-kernel@vger.kernel.org>); 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 <andriy.shevchenko@linux.intel.com> To: Luis Chamberlain <mcgrof@kernel.org>, Kees Cook <keescook@chromium.org>, Andy Shevchenko <andriy.shevchenko@linux.intel.com>, linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> 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: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 20 Nov 2023 07:15:03 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783096501515088876 X-GMAIL-MSGID: 1783096501515088876 |
Series |
params: harden string ops and allocatio ops
|
|
Commit Message
Andy Shevchenko
Nov. 20, 2023, 3:11 p.m. UTC
Prevent allocations from integer overflow by using size_add(). Reviewed-by: Luis Chamberlain <mcgrof@kernel.org> Reviewed-by: Kees Cook <keescook@chromium.org> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> --- 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 <linux/moduleparam.h> #include <linux/device.h> #include <linux/err.h> +#include <linux/overflow.h> #include <linux/slab.h> #include <linux/ctype.h> #include <linux/security.h> @@ -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;