Message ID | 20230912150551.401537-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:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp580237vqx; Tue, 12 Sep 2023 10:54:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHpQfJ3j1QrxZt/zJl/33XFlYXkMQQh/J2VfaL4LiSbKAuaJrQQEgh7zNxwiYCb0h+bLuxl X-Received: by 2002:a05:6a21:32a5:b0:14b:887a:6d70 with SMTP id yt37-20020a056a2132a500b0014b887a6d70mr190233pzb.15.1694541261249; Tue, 12 Sep 2023 10:54:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694541261; cv=none; d=google.com; s=arc-20160816; b=z6Kpm8xdCipIDXk8pv4GnXG5ZnreL3XhxCOB7J0adyMTr0b8TR3r0fmLzQ4lZXofOu BPT468P5PTDCtji6tymOMfxh8od7zA07iVUuy+VHr/jLTN1HfeDXa8HGecsiqFMu9Xd0 vuicrtYiDqsLE0+aXL+aP4UJp/+WY/7FToRVTDSENxbBjQCIRgl7b3x0zcgrPki25SOZ 0Cgy9+Mai+Yfo1ftS1RvhNXOk3Du8SmQpnT5xZsdm6VO3fGhcrB9tm8BPDoaOODyWcaM DJTPY5UbHVm0f0tIqEmhnCwc+aVeL45eKwbtBb3OGXyt57ql1CLUympcFyiLI84MlnjD MqtQ== 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 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id y4-20020a056a00180400b0068ace3816d7si8553365pfa.387.2023.09.12.10.54.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 10:54:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; 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 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id 25FE481A0C1A; Tue, 12 Sep 2023 08:08:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236281AbjILPID (ORCPT <rfc822;pwkd43@gmail.com> + 37 others); Tue, 12 Sep 2023 11:08:03 -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 <rfc822;linux-kernel@vger.kernel.org>); 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 <linux-kernel@vger.kernel.org>; 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 <andriy.shevchenko@linux.intel.com> To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>, linux-kernel@vger.kernel.org Cc: Luis Chamberlain <mcgrof@kernel.org> 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: <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 (agentk.vger.email [0.0.0.0]); Tue, 12 Sep 2023 08:08:08 -0700 (PDT) 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776855297347056711 X-GMAIL-MSGID: 1776855297347056711 |
Series |
[v1,1/6] params: Use sysfs_emit() to instead of scnprintf()
|
|
Commit Message
Andy Shevchenko
Sept. 12, 2023, 3:05 p.m. UTC
Prevent allocations from integer overflow by using size_add().
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 930a5dc2f004..fd11c731475f 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;