qcacmn: Add wlan_cfg80211_nla_put_u64_64bit()

OSIF currently defines function wlan_cfg80211_nla_put_u64() which
provides an interface to the Linux Kernel's nla_put_u64()
functionality. This wrapper handles the fact that the underlying API
has a different name and signature depending upon kernel version.
However, this function has a limitation, namely that if it has to pad
the skb, it will use a netlink pad attribute that may not be defined
in the same enum as the u64 attribute. This can lead to attribute
parsing issues by the recipient.

To avoid this problem, introduce wlan_cfg80211_nla_put_u64_64bit(),
which allows the caller to provide the pad attribute id. This will
ensure that the u64 attribute and the pad attribute are from the same
enum, and hence should prevent nla_parse() issues.

Change-Id: I9e4183fa088248abfdda435b9d5e159400521969
CRs-Fixed: 3414639
Цей коміт міститься в:
Jeff Johnson
2023-02-22 18:49:50 -08:00
зафіксовано Madan Koyyalamudi
джерело 7f60898cfc
коміт 0eda2812d9

Переглянути файл

@@ -496,6 +496,22 @@ wlan_cfg80211_nla_parse_nested(struct nlattr *tb[],
#define nla_parse(...) (obsolete, use wlan_cfg80211_nla_parse)
#define nla_parse_nested(...) (obsolete, use wlan_cfg80211_nla_parse_nested)
/**
* wlan_cfg80211_nla_put_u64() - Add u64 attribute to an skb and align it
* @skb: SKB to add attribute(s) to
* @attrtype: u64 attribute id
* @value: u64 attribute value
*
* This function adds a u64 attribute, and optionally a pad attribute, to the
* skb. If this function adds a pad attribute, that pad attribute is defined
* in enum qca_wlan_vendor_attr, so only 64-bit attributes that are defined
* in enum qca_wlan_vendor_attr should use this interface. For other u64
* attributes, use function wlan_cfg80211_nla_put_u64_64bit() since that
* allows the pad attribute to be specified.
*
* Return: 0 if u64 attribute and optional pad attribute added to skb,
* negative errno if operation fails
*/
#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 7, 0))
static inline int
wlan_cfg80211_nla_put_u64(struct sk_buff *skb, int attrtype, u64 value)
@@ -510,6 +526,38 @@ wlan_cfg80211_nla_put_u64(struct sk_buff *skb, int attrtype, u64 value)
}
#endif
/**
* wlan_cfg80211_nla_put_u64_64bit() - Add u64 attribute to an skb and align it
* @skb: SKB to add attribute(s) to
* @attrtype: u64 attribute id
* @value: u64 attribute value
* @padattr: padding attribute id
*
* This function adds a u64 attribute, and optionally a pad attribute,
* to the skb. Unlike wlan_cfg80211_nla_put_u64() which can only be
* used with attributes defined in enum qca_wlan_vendor_attr, this
* function can be used with attributes defined in any enum, provided
* that the enum also defines a pad attribute.
*
* Return: 0 if u64 attribute and optional pad attribute added to skb,
* negative errno if operation fails
*/
#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 7, 0))
static inline int
wlan_cfg80211_nla_put_u64_64bit(struct sk_buff *skb, int attrtype,
u64 value, int padattr)
{
return nla_put_u64(skb, attrtype, value);
}
#else
static inline int
wlan_cfg80211_nla_put_u64_64bit(struct sk_buff *skb, int attrtype,
u64 value, int padattr)
{
return nla_put_u64_64bit(skb, attrtype, value, padattr);
}
#endif
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0))
static inline ssize_t
wlan_cfg80211_nla_strscpy(char *dst, const struct nlattr *nla, size_t dstsize)