Revision dec24b3b339487e58ce2da2875e9ee0316cc7e70 authored by Kees Cook on 20 June 2023, 19:42:38 UTC, committed by Paolo Abeni on 22 June 2023, 09:27:47 UTC
struct mux_adth actually ends with multiple struct mux_adth_dg members.
This is seen both in the comments about the member:

/**
 * struct mux_adth - Structure of the Aggregated Datagram Table Header.
 ...
 * @dg:		datagramm table with variable length
 */

and in the preparation for populating it:

                        adth_dg_size = offsetof(struct mux_adth, dg) +
                                        ul_adb->dg_count[i] * sizeof(*dg);
			...
                        adth_dg_size -= offsetof(struct mux_adth, dg);
                        memcpy(&adth->dg, ul_adb->dg[i], adth_dg_size);

This was reported as a run-time false positive warning:

memcpy: detected field-spanning write (size 16) of single field "&adth->dg" at drivers/net/wwan/iosm/iosm_ipc_mux_codec.c:852 (size 8)

Adjust the struct mux_adth definition and associated sizeof() math; no binary
output differences are observed in the resulting object file.

Reported-by: Florian Klink <flokli@flokli.de>
Closes: https://lore.kernel.org/lkml/dbfa25f5-64c8-5574-4f5d-0151ba95d232@gmail.com/
Fixes: 1f52d7b62285 ("net: wwan: iosm: Enable M.2 7360 WWAN card support")
Cc: M Chetan Kumar <m.chetan.kumar@intel.com>
Cc: Bagas Sanjaya <bagasdotme@gmail.com>
Cc: Intel Corporation <linuxwwan@intel.com>
Cc: Loic Poulain <loic.poulain@linaro.org>
Cc: Sergey Ryazanov <ryazanov.s.a@gmail.com>
Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: netdev@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Link: https://lore.kernel.org/r/20230620194234.never.023-kees@kernel.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 2174a08
Raw File
842_debugfs.h
/* SPDX-License-Identifier: GPL-2.0 */

#ifndef __842_DEBUGFS_H__
#define __842_DEBUGFS_H__

#include <linux/debugfs.h>

static bool sw842_template_counts;
module_param_named(template_counts, sw842_template_counts, bool, 0444);

static atomic_t template_count[OPS_MAX], template_repeat_count,
	template_zeros_count, template_short_data_count, template_end_count;

static struct dentry *sw842_debugfs_root;

static int __init sw842_debugfs_create(void)
{
	umode_t m = S_IRUGO | S_IWUSR;
	int i;

	if (!debugfs_initialized())
		return -ENODEV;

	sw842_debugfs_root = debugfs_create_dir(MODULE_NAME, NULL);

	for (i = 0; i < ARRAY_SIZE(template_count); i++) {
		char name[32];

		snprintf(name, 32, "template_%02x", i);
		debugfs_create_atomic_t(name, m, sw842_debugfs_root,
					&template_count[i]);
	}
	debugfs_create_atomic_t("template_repeat", m, sw842_debugfs_root,
				&template_repeat_count);
	debugfs_create_atomic_t("template_zeros", m, sw842_debugfs_root,
				&template_zeros_count);
	debugfs_create_atomic_t("template_short_data", m, sw842_debugfs_root,
				&template_short_data_count);
	debugfs_create_atomic_t("template_end", m, sw842_debugfs_root,
				&template_end_count);

	return 0;
}

static void __exit sw842_debugfs_remove(void)
{
	debugfs_remove_recursive(sw842_debugfs_root);
}

#endif
back to top