-
Notifications
You must be signed in to change notification settings - Fork 47
RTEMS: fix off-by-one array read in cpu_ticks() #88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
f03775e
4561489
4da2a47
864dfee
104f437
5e030a3
9a7f284
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,20 +40,37 @@ | |
|
|
||
| #include <devIocStats.h> | ||
|
|
||
| /* This would otherwise need _KERNEL to be defined... */ | ||
| extern struct ifnet *ifnet; | ||
| /* The kernel-internal `struct ifnet` linked list (walked via if_next) is | ||
| * gone under libbsd -- ifnet is now a CK_STAILQ and if_ierrors/if_oerrors | ||
| * are behind the if_get_counter KPI, neither meant for use outside the | ||
| * kernel proper. getifaddrs()/struct if_data is the portable, userspace- | ||
| * visible way to get the same per-interface error counts: each interface | ||
| * contributes one AF_LINK entry whose ifa_data is its struct if_data. */ | ||
| #include <ifaddrs.h> | ||
| #include <net/if.h> | ||
| #include <sys/socket.h> | ||
|
Comment on lines
+43
to
+51
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, does this need some kind of version check? |
||
|
|
||
| int devIocStatsInitIFErrors(void) { return 0; } | ||
|
|
||
| int devIocStatsGetIFErrors(ifErrInfo *pval) { | ||
| struct ifnet *ifp; | ||
| struct ifaddrs *addrs, *ifa; | ||
|
|
||
| /* add all interfaces' errors */ | ||
| pval->ierrors = 0; | ||
| pval->oerrors = 0; | ||
| for (ifp = ifnet; ifp != NULL; ifp = ifp->if_next) { | ||
| pval->ierrors += ifp->if_ierrors; | ||
| pval->oerrors += ifp->if_oerrors; | ||
|
|
||
| if (getifaddrs(&addrs) < 0) { | ||
| return -1; | ||
| } | ||
|
|
||
| for (ifa = addrs; ifa != NULL; ifa = ifa->ifa_next) { | ||
| if (ifa->ifa_addr != NULL && ifa->ifa_addr->sa_family == AF_LINK && | ||
| ifa->ifa_data != NULL) { | ||
| struct if_data *ifd = (struct if_data *)ifa->ifa_data; | ||
| pval->ierrors += ifd->ifi_ierrors; | ||
| pval->oerrors += ifd->ifi_oerrors; | ||
| } | ||
| } | ||
|
|
||
| freeifaddrs(addrs); | ||
| return 0; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,17 +45,21 @@ int devIocStatsInitSuspTasks(void) { return 0; } | |
| int devIocStatsGetSuspTasks(int *pval) { | ||
| Objects_Control *o; | ||
| Objects_Id id = OBJECTS_ID_INITIAL_INDEX; | ||
| Objects_Id nid; | ||
| int n = 0; | ||
| Objects_Locations l; | ||
|
|
||
| /* count all suspended (LOCAL -- cannot deal with remote ones ATM) tasks */ | ||
| while ((o = _Objects_Get_next(&_RTEMS_tasks_Information, id, &l, &nid))) { | ||
| if ((RTEMS_ALREADY_SUSPENDED == rtems_task_is_suspended(nid))) { | ||
| /* count all suspended (LOCAL -- cannot deal with remote ones ATM) tasks. | ||
| * _Objects_Get_next()'s signature/semantics changed: no more separate | ||
| * Objects_Locations out-param (it now just returns NULL when nothing | ||
| * local is found), the object information comes first, and id doubles | ||
| * as both the search-from input and the next-id output. It locks the | ||
| * object allocator mutex when it finds something, which the caller must | ||
| * release -- see cpukit/libcsupport/src/resource_snapshot.c for the | ||
| * reference usage this follows. */ | ||
| while ((o = _Objects_Get_next(id, &_RTEMS_tasks_Information.Objects, &id))) { | ||
| if ((RTEMS_ALREADY_SUSPENDED == rtems_task_is_suspended(o->id))) { | ||
|
Comment on lines
+50
to
+59
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't this need a conditional on RTEMS version? Also, I think the comment is a bit overly verbose. Saying that the syntax is changed is relevant in the commit message but not in the code IMO. |
||
| n++; | ||
| } | ||
| _Thread_Enable_dispatch(); | ||
| id = nid; | ||
| _Objects_Allocator_unlock(); | ||
| } | ||
| *pval = n; | ||
| return 0; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need these comments?