Skip to content

Commit 23d07a9

Browse files
arndbgregkh
authored andcommitted
drop_monitor: work around gcc-10 stringop-overflow warning
[ Upstream commit dc30b40 ] The current gcc-10 snapshot produces a false-positive warning: net/core/drop_monitor.c: In function 'trace_drop_common.constprop': cc1: error: writing 8 bytes into a region of size 0 [-Werror=stringop-overflow=] In file included from net/core/drop_monitor.c:23: include/uapi/linux/net_dropmon.h:36:8: note: at offset 0 to object 'entries' with size 4 declared here 36 | __u32 entries; | ^~~~~~~ I reported this in the gcc bugzilla, but in case it does not get fixed in the release, work around it by using a temporary variable. Fixes: 9a8afc8 ("Network Drop Monitor: Adding drop monitor implementation & Netlink protocol") Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94881 Signed-off-by: Arnd Bergmann <[email protected]> Acked-by: Neil Horman <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent f0d331d commit 23d07a9

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

net/core/drop_monitor.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ static void sched_send_work(unsigned long _data)
159159
static void trace_drop_common(struct sk_buff *skb, void *location)
160160
{
161161
struct net_dm_alert_msg *msg;
162+
struct net_dm_drop_point *point;
162163
struct nlmsghdr *nlh;
163164
struct nlattr *nla;
164165
int i;
@@ -177,11 +178,13 @@ static void trace_drop_common(struct sk_buff *skb, void *location)
177178
nlh = (struct nlmsghdr *)dskb->data;
178179
nla = genlmsg_data(nlmsg_data(nlh));
179180
msg = nla_data(nla);
181+
point = msg->points;
180182
for (i = 0; i < msg->entries; i++) {
181-
if (!memcmp(&location, msg->points[i].pc, sizeof(void *))) {
182-
msg->points[i].count++;
183+
if (!memcmp(&location, &point->pc, sizeof(void *))) {
184+
point->count++;
183185
goto out;
184186
}
187+
point++;
185188
}
186189
if (msg->entries == dm_hit_limit)
187190
goto out;
@@ -190,8 +193,8 @@ static void trace_drop_common(struct sk_buff *skb, void *location)
190193
*/
191194
__nla_reserve_nohdr(dskb, sizeof(struct net_dm_drop_point));
192195
nla->nla_len += NLA_ALIGN(sizeof(struct net_dm_drop_point));
193-
memcpy(msg->points[msg->entries].pc, &location, sizeof(void *));
194-
msg->points[msg->entries].count = 1;
196+
memcpy(point->pc, &location, sizeof(void *));
197+
point->count = 1;
195198
msg->entries++;
196199

197200
if (!timer_pending(&data->send_timer)) {

0 commit comments

Comments
 (0)