Files
linux/drivers/net/wireless/mediatek/mt76/mt7615/mt7615_trace.h
Azeem Shaikh d6b484b5cb wifi: mt76: Replace strlcpy() with strscpy()
strlcpy() reads the entire source buffer first.
This read may exceed the destination size limit.
This is both inefficient and can lead to linear read
overflows if a source string is not NUL-terminated [1].
In an effort to remove strlcpy() completely [2], replace
strlcpy() here with strscpy().

Direct replacement is safe here since DEV_ASSIGN is only used by
TRACE macros and the return values are ignored.

[1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy
[2] https://github.com/KSPP/linux/issues/89

Signed-off-by: Azeem Shaikh <azeemshaikh38@gmail.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230703181256.3712079-1-azeemshaikh38@gmail.com
2023-08-02 13:09:41 +03:00

57 lines
1.2 KiB
C

/* SPDX-License-Identifier: ISC */
/*
* Copyright (C) 2019 Lorenzo Bianconi <lorenzo@kernel.org>
*/
#if !defined(__MT7615_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
#define __MT7615_TRACE_H
#include <linux/tracepoint.h>
#include "mt7615.h"
#undef TRACE_SYSTEM
#define TRACE_SYSTEM mt7615
#define MAXNAME 32
#define DEV_ENTRY __array(char, wiphy_name, 32)
#define DEV_ASSIGN strscpy(__entry->wiphy_name, \
wiphy_name(mt76_hw(dev)->wiphy), MAXNAME)
#define DEV_PR_FMT "%s"
#define DEV_PR_ARG __entry->wiphy_name
#define TOKEN_ENTRY __field(u16, token)
#define TOKEN_ASSIGN __entry->token = token
#define TOKEN_PR_FMT " %d"
#define TOKEN_PR_ARG __entry->token
DECLARE_EVENT_CLASS(dev_token,
TP_PROTO(struct mt7615_dev *dev, u16 token),
TP_ARGS(dev, token),
TP_STRUCT__entry(
DEV_ENTRY
TOKEN_ENTRY
),
TP_fast_assign(
DEV_ASSIGN;
TOKEN_ASSIGN;
),
TP_printk(
DEV_PR_FMT TOKEN_PR_FMT,
DEV_PR_ARG, TOKEN_PR_ARG
)
);
DEFINE_EVENT(dev_token, mac_tx_free,
TP_PROTO(struct mt7615_dev *dev, u16 token),
TP_ARGS(dev, token)
);
#endif
#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH .
#undef TRACE_INCLUDE_FILE
#define TRACE_INCLUDE_FILE mt7615_trace
#include <trace/define_trace.h>