From: Shuah Khan <skhan@linuxfoundation.org> To: gregkh@linuxfoundation.org, keescook@chromium.org, peterz@infradead.org Cc: Shuah Khan <skhan@linuxfoundation.org>, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH 11/13] drivers/staging/rtl8188eu: convert stats to use seqnum_ops Date: Tue, 10 Nov 2020 12:53:37 -0700 [thread overview] Message-ID: <07ada10228dbd8d8954a30d6604fef2db762be69.1605027593.git.skhan@linuxfoundation.org> (raw) In-Reply-To: <cover.1605027593.git.skhan@linuxfoundation.org> seqnum_ops api is introduced to be used when a variable is used as a sequence/stat counter and doesn't guard object lifetimes. This clearly differentiates atomic_t usages that guard object lifetimes. seqnum32 variables wrap around to INT_MIN when it overflows and should not be used to guard resource lifetimes, device usage and open counts that control state changes, and pm states. atomic_t variables used for stats are atomic counters. Overflow will wrap around and reset the stats and no change with the conversion. Convert them to use seqnum_ops. This conversion replaces inc_return() with _inc() followed by _read(). Signed-off-by: Shuah Khan <skhan@linuxfoundation.org> --- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 23 ++++++++++++++----- .../staging/rtl8188eu/include/rtw_mlme_ext.h | 3 ++- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index b3eddcb83cd0..31dd9d31dd9a 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -7,6 +7,7 @@ #define _RTW_MLME_EXT_C_ #include <linux/ieee80211.h> +#include <linux/seqnum_ops.h> #include <asm/unaligned.h> #include <osdep_service.h> @@ -3860,7 +3861,7 @@ static void init_mlme_ext_priv_value(struct adapter *padapter) _12M_RATE_, _24M_RATE_, 0xff, }; - atomic_set(&pmlmeext->event_seq, 0); + seqnum32_set(&pmlmeext->event_seq, 0); pmlmeext->mgnt_seq = 0;/* reset to zero when disconnect at client mode */ pmlmeext->cur_channel = padapter->registrypriv.channel; @@ -4189,7 +4190,9 @@ void report_survey_event(struct adapter *padapter, pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); pc2h_evt_hdr->len = sizeof(struct survey_event); pc2h_evt_hdr->ID = _Survey_EVT_; - pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); + + seqnum32_inc(&pmlmeext->event_seq); + pc2h_evt_hdr->seq = seqnum32_read(&pmlmeext->event_seq); psurvey_evt = (struct survey_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); @@ -4239,7 +4242,9 @@ void report_surveydone_event(struct adapter *padapter) pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); pc2h_evt_hdr->len = sizeof(struct surveydone_event); pc2h_evt_hdr->ID = _SurveyDone_EVT_; - pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); + + seqnum32_inc(&pmlmeext->event_seq); + pc2h_evt_hdr->seq = seqnum32_read(&pmlmeext->event_seq); psurveydone_evt = (struct surveydone_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); psurveydone_evt->bss_cnt = pmlmeext->sitesurvey_res.bss_cnt; @@ -4283,7 +4288,9 @@ void report_join_res(struct adapter *padapter, int res) pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); pc2h_evt_hdr->len = sizeof(struct joinbss_event); pc2h_evt_hdr->ID = _JoinBss_EVT_; - pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); + + seqnum32_inc(&pmlmeext->event_seq); + pc2h_evt_hdr->seq = seqnum32_read(&pmlmeext->event_seq); pjoinbss_evt = (struct joinbss_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); memcpy((unsigned char *)(&pjoinbss_evt->network.network), &pmlmeinfo->network, sizeof(struct wlan_bssid_ex)); @@ -4333,7 +4340,9 @@ void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); pc2h_evt_hdr->len = sizeof(struct stadel_event); pc2h_evt_hdr->ID = _DelSTA_EVT_; - pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); + + seqnum32_inc(&pmlmeext->event_seq); + pc2h_evt_hdr->seq = seqnum32_read(&pmlmeext->event_seq); pdel_sta_evt = (struct stadel_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); ether_addr_copy((unsigned char *)(&pdel_sta_evt->macaddr), MacAddr); @@ -4386,7 +4395,9 @@ void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); pc2h_evt_hdr->len = sizeof(struct stassoc_event); pc2h_evt_hdr->ID = _AddSTA_EVT_; - pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); + + seqnum32_inc(&pmlmeext->event_seq); + pc2h_evt_hdr->seq = seqnum32_read(&pmlmeext->event_seq); padd_sta_evt = (struct stassoc_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); ether_addr_copy((unsigned char *)(&padd_sta_evt->macaddr), MacAddr); diff --git a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h index b11a6886a083..09b7e3bb2738 100644 --- a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h @@ -7,6 +7,7 @@ #ifndef __RTW_MLME_EXT_H_ #define __RTW_MLME_EXT_H_ +#include <linux/seqnum_ops.h> #include <osdep_service.h> #include <drv_types.h> #include <wlan_bssdef.h> @@ -393,7 +394,7 @@ struct p2p_oper_class_map { struct mlme_ext_priv { struct adapter *padapter; u8 mlmeext_init; - atomic_t event_seq; + struct seqnum32 event_seq; u16 mgnt_seq; unsigned char cur_channel; -- 2.27.0
WARNING: multiple messages have this Message-ID (diff)
From: Shuah Khan <skhan@linuxfoundation.org> To: gregkh@linuxfoundation.org, keescook@chromium.org, peterz@infradead.org Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Shuah Khan <skhan@linuxfoundation.org> Subject: [PATCH 11/13] drivers/staging/rtl8188eu: convert stats to use seqnum_ops Date: Tue, 10 Nov 2020 12:53:37 -0700 [thread overview] Message-ID: <07ada10228dbd8d8954a30d6604fef2db762be69.1605027593.git.skhan@linuxfoundation.org> (raw) In-Reply-To: <cover.1605027593.git.skhan@linuxfoundation.org> seqnum_ops api is introduced to be used when a variable is used as a sequence/stat counter and doesn't guard object lifetimes. This clearly differentiates atomic_t usages that guard object lifetimes. seqnum32 variables wrap around to INT_MIN when it overflows and should not be used to guard resource lifetimes, device usage and open counts that control state changes, and pm states. atomic_t variables used for stats are atomic counters. Overflow will wrap around and reset the stats and no change with the conversion. Convert them to use seqnum_ops. This conversion replaces inc_return() with _inc() followed by _read(). Signed-off-by: Shuah Khan <skhan@linuxfoundation.org> --- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 23 ++++++++++++++----- .../staging/rtl8188eu/include/rtw_mlme_ext.h | 3 ++- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index b3eddcb83cd0..31dd9d31dd9a 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -7,6 +7,7 @@ #define _RTW_MLME_EXT_C_ #include <linux/ieee80211.h> +#include <linux/seqnum_ops.h> #include <asm/unaligned.h> #include <osdep_service.h> @@ -3860,7 +3861,7 @@ static void init_mlme_ext_priv_value(struct adapter *padapter) _12M_RATE_, _24M_RATE_, 0xff, }; - atomic_set(&pmlmeext->event_seq, 0); + seqnum32_set(&pmlmeext->event_seq, 0); pmlmeext->mgnt_seq = 0;/* reset to zero when disconnect at client mode */ pmlmeext->cur_channel = padapter->registrypriv.channel; @@ -4189,7 +4190,9 @@ void report_survey_event(struct adapter *padapter, pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); pc2h_evt_hdr->len = sizeof(struct survey_event); pc2h_evt_hdr->ID = _Survey_EVT_; - pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); + + seqnum32_inc(&pmlmeext->event_seq); + pc2h_evt_hdr->seq = seqnum32_read(&pmlmeext->event_seq); psurvey_evt = (struct survey_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); @@ -4239,7 +4242,9 @@ void report_surveydone_event(struct adapter *padapter) pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); pc2h_evt_hdr->len = sizeof(struct surveydone_event); pc2h_evt_hdr->ID = _SurveyDone_EVT_; - pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); + + seqnum32_inc(&pmlmeext->event_seq); + pc2h_evt_hdr->seq = seqnum32_read(&pmlmeext->event_seq); psurveydone_evt = (struct surveydone_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); psurveydone_evt->bss_cnt = pmlmeext->sitesurvey_res.bss_cnt; @@ -4283,7 +4288,9 @@ void report_join_res(struct adapter *padapter, int res) pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); pc2h_evt_hdr->len = sizeof(struct joinbss_event); pc2h_evt_hdr->ID = _JoinBss_EVT_; - pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); + + seqnum32_inc(&pmlmeext->event_seq); + pc2h_evt_hdr->seq = seqnum32_read(&pmlmeext->event_seq); pjoinbss_evt = (struct joinbss_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); memcpy((unsigned char *)(&pjoinbss_evt->network.network), &pmlmeinfo->network, sizeof(struct wlan_bssid_ex)); @@ -4333,7 +4340,9 @@ void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); pc2h_evt_hdr->len = sizeof(struct stadel_event); pc2h_evt_hdr->ID = _DelSTA_EVT_; - pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); + + seqnum32_inc(&pmlmeext->event_seq); + pc2h_evt_hdr->seq = seqnum32_read(&pmlmeext->event_seq); pdel_sta_evt = (struct stadel_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); ether_addr_copy((unsigned char *)(&pdel_sta_evt->macaddr), MacAddr); @@ -4386,7 +4395,9 @@ void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); pc2h_evt_hdr->len = sizeof(struct stassoc_event); pc2h_evt_hdr->ID = _AddSTA_EVT_; - pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); + + seqnum32_inc(&pmlmeext->event_seq); + pc2h_evt_hdr->seq = seqnum32_read(&pmlmeext->event_seq); padd_sta_evt = (struct stassoc_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); ether_addr_copy((unsigned char *)(&padd_sta_evt->macaddr), MacAddr); diff --git a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h index b11a6886a083..09b7e3bb2738 100644 --- a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h @@ -7,6 +7,7 @@ #ifndef __RTW_MLME_EXT_H_ #define __RTW_MLME_EXT_H_ +#include <linux/seqnum_ops.h> #include <osdep_service.h> #include <drv_types.h> #include <wlan_bssdef.h> @@ -393,7 +394,7 @@ struct p2p_oper_class_map { struct mlme_ext_priv { struct adapter *padapter; u8 mlmeext_init; - atomic_t event_seq; + struct seqnum32 event_seq; u16 mgnt_seq; unsigned char cur_channel; -- 2.27.0 _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
next prev parent reply other threads:[~2020-11-10 19:55 UTC|newest] Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-11-10 19:53 [PATCH 00/13] Introduce seqnum_ops Shuah Khan 2020-11-10 19:53 ` [PATCH 01/13] seqnum_ops: Introduce Sequence Number Ops Shuah Khan 2020-11-10 20:41 ` Greg KH 2020-11-10 20:43 ` Greg KH 2020-11-11 0:18 ` Kees Cook 2020-11-11 19:23 ` Shuah Khan 2020-11-12 12:36 ` Matthew Wilcox 2020-11-12 16:17 ` Shuah Khan 2020-11-12 16:45 ` Greg KH 2020-11-12 16:59 ` Shuah Khan 2020-11-12 21:27 ` Shuah Khan 2020-11-17 12:27 ` Peter Zijlstra 2020-11-10 21:03 ` Matthew Wilcox 2020-11-10 22:58 ` Shuah Khan 2020-11-11 0:20 ` Kees Cook 2020-11-11 15:42 ` Shuah Khan 2020-11-11 8:23 ` Peter Zijlstra 2020-11-11 15:56 ` Shuah Khan 2020-11-11 16:04 ` Peter Zijlstra 2020-11-11 17:34 ` Shuah Khan 2020-11-11 17:50 ` Peter Zijlstra 2020-11-11 18:28 ` Shuah Khan 2020-11-11 20:15 ` Peter Zijlstra 2020-11-12 13:29 ` Greg KH 2020-11-10 19:53 ` [PATCH 02/13] selftests:lib:test_seqnum_ops: add new test for seqnum_ops Shuah Khan 2020-11-10 19:53 ` [PATCH 03/13] drivers/acpi: convert seqno seqnum_ops Shuah Khan 2020-11-10 19:53 ` [PATCH 04/13] drivers/acpi/apei: convert seqno to seqnum_ops Shuah Khan 2020-11-10 19:53 ` [PATCH 05/13] drivers/base/test/test_async_driver_probe: convert to use seqnum_ops Shuah Khan 2020-11-10 19:53 ` [PATCH 06/13] drivers/char/ipmi: convert stats " Shuah Khan 2020-11-10 19:53 ` [PATCH 07/13] drivers/edac: convert pci counters to seqnum_ops Shuah Khan 2020-11-10 19:53 ` [PATCH 08/13] drivers/oprofile: convert stats to use seqnum_ops Shuah Khan 2020-11-10 19:53 ` [PATCH 09/13] drivers/staging/rtl8723bs: " Shuah Khan 2020-11-10 19:53 ` Shuah Khan 2020-11-10 19:53 ` [PATCH 10/13] usb: usbip/vhci: convert seqno to seqnum_ops Shuah Khan 2020-11-10 19:53 ` Shuah Khan [this message] 2020-11-10 19:53 ` [PATCH 11/13] drivers/staging/rtl8188eu: convert stats to use seqnum_ops Shuah Khan 2020-11-10 19:53 ` [PATCH 12/13] drivers/staging/unisys/visorhba: " Shuah Khan 2020-11-10 19:53 ` Shuah Khan 2020-11-10 20:42 ` Greg KH 2020-11-10 20:42 ` Greg KH 2020-11-10 21:02 ` Shuah Khan 2020-11-10 21:02 ` Shuah Khan 2020-11-10 19:53 ` [PATCH 13/13] security/integrity/ima: converts stats to seqnum_ops Shuah Khan 2020-11-11 8:51 ` kernel test robot 2020-11-11 8:51 ` kernel test robot 2020-11-10 20:44 ` [PATCH 00/13] Introduce seqnum_ops Alan Stern 2020-11-10 22:42 ` Shuah Khan 2020-11-11 4:33 ` Matthew Wilcox 2020-11-11 16:03 ` Shuah Khan 2020-11-11 16:41 ` Matthew Wilcox
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=07ada10228dbd8d8954a30d6604fef2db762be69.1605027593.git.skhan@linuxfoundation.org \ --to=skhan@linuxfoundation.org \ --cc=devel@driverdev.osuosl.org \ --cc=gregkh@linuxfoundation.org \ --cc=keescook@chromium.org \ --cc=linux-kernel@vger.kernel.org \ --cc=peterz@infradead.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.