From patchwork Sun Jan 19 18:23:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ethan Carter Edwards X-Patchwork-Id: 13944561 Received: from mout-p-103.mailbox.org (mout-p-103.mailbox.org [80.241.56.161]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9345536D; Sun, 19 Jan 2025 18:23:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.241.56.161 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737311020; cv=none; b=XVEF5eM6ZkuQLxUsNvCrfBDblShfW17krN1MLuV7xI7Av6DSHPlD9VxASc4aC0bQaU2NdMbIMlJC5pNRnJMcMQ/5KTs4gm9jasqu4IG6uek2hClxp+SGqbcfy0rsFeZQEoalYGuqGcB4zRjiikz1E2Y9UENzKi9YBV1QwwLKx10= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737311020; c=relaxed/simple; bh=iCLjkD9BXmzArrieHDa2TuhM5dfkQZbzSxGvhU7YU1k=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=UJrVq9EtoBWYfDq7ByalrVERRnYyFOzhk5l/tGbkNNnKk5JMWSbZuU049vTOzg9QrxTNk6wOI26qTSyPEtTNfcvpB4Djw19mMUewKK5yELT+6GuLqPGuWMkq4FRhrZ3DVRE3wAEe6ovuU6tGsRxS5uSaBwDTvTDftb0Kq8GV224= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ethancedwards.com; spf=pass smtp.mailfrom=ethancedwards.com; dkim=pass (2048-bit key) header.d=ethancedwards.com header.i=@ethancedwards.com header.b=Q83GecbS; arc=none smtp.client-ip=80.241.56.161 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ethancedwards.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ethancedwards.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ethancedwards.com header.i=@ethancedwards.com header.b="Q83GecbS" Received: from smtp2.mailbox.org (smtp2.mailbox.org [10.196.197.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-103.mailbox.org (Postfix) with ESMTPS id 4Ybhg932hJz9s2L; Sun, 19 Jan 2025 19:23:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ethancedwards.com; s=MBO0001; t=1737311013; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=/KGoDwqG4ed2dZMwbpmR67Xf+mOEwFNKNvbnBK6Ourk=; b=Q83GecbSNSu1oMT+2eiLfM2n3roUhBRY3/pL2XpWQst8t3jHmM0ZWDpW4wuXNZypjzsAhr AETELv7eaAU3Myt1/mMw/vZzgKWjw0stnn8utoyRJX384W7Ft/DdsMKmu4y7Ar+UCtCHP8 A+6bNFs+7w7FlmPOTZKqOZzfnQ7xK1rewTsCcPL+QNVdyW7pq/OHcQ1PdhH0mPeqWY75nC djO61k+i8hs2XM5Spj3Rth1ffRQC4XJiJSBT4Cr4mLNGW2E64S0KwG2mGVAqufu4gX8JMt njPX3TUwfcq/DOP/+5dp+6AhR7/KY0eeVnKVaXw8swid1zGA5SEgQnx1w56cHw== Date: Sun, 19 Jan 2025 13:23:29 -0500 From: Ethan Carter Edwards To: mingo@redhat.com Cc: "linux-kernel@vger.kernel.org" , "linux-hardening@vger.kernel.org" , "kernel-hardening@lists.openwall.com" , "bsegall@google.com" , "peterz@infradead.org" Subject: [PATCH v2] sched/topology: change kzalloc to kcalloc Message-ID: Precedence: bulk X-Mailing-List: linux-hardening@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline We are replacing any instances of kzalloc(size * count, ...) with kcalloc(count, size, ...) due to risk of overflow [1]. [1] https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments Link: https://github.com/KSPP/linux/issues/162 Signed-off-by: Ethan Carter Edwards --- V2: fix email client formatting. kernel/sched/topology.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c index 9748a4c8d668..17eb12819563 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -1920,7 +1920,7 @@ void sched_init_numa(int offline_node) */ sched_domains_numa_levels = 0; - masks = kzalloc(sizeof(void *) * nr_levels, GFP_KERNEL); + masks = kcalloc(nr_levels, sizeof(void *), GFP_KERNEL); if (!masks) return; @@ -1929,7 +1929,7 @@ void sched_init_numa(int offline_node) * CPUs of nodes that are that many hops away from us. */ for (i = 0; i < nr_levels; i++) { - masks[i] = kzalloc(nr_node_ids * sizeof(void *), GFP_KERNEL); + masks[i] = kcalloc(nr_node_ids, sizeof(void *), GFP_KERNEL); if (!masks[i]) return;