linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/7] remove invalid reference to list iterator variable
@ 2012-07-08 11:37 Julia Lawall
  2012-07-08 11:37 ` [PATCH 1/7] drivers/isdn/mISDN/stack.c: " Julia Lawall
                   ` (6 more replies)
  0 siblings, 7 replies; 18+ messages in thread
From: Julia Lawall @ 2012-07-08 11:37 UTC (permalink / raw)
  To: linux-kernel; +Cc: kernel-janitors

If list_for_each_entry, etc complete a traversal of the list, the iterator
variable ends up pointing to an address at an offset from the list head,
and not a meaningful structure.  Thus this value should not be used after
the end of the iterator.

The complete semantic match that finds this problem is:
(http://coccinelle.lip6.fr/)

@@
identifier c,member;
expression E,x;
iterator name list_for_each_entry;
iterator name list_for_each_entry_reverse;
iterator name list_for_each_entry_continue;
iterator name list_for_each_entry_continue_reverse;
iterator name list_for_each_entry_from;
iterator name list_for_each_entry_safe;
iterator name list_for_each_entry_safe_continue;
iterator name list_for_each_entry_safe_from;
iterator name list_for_each_entry_safe_reverse;
iterator name hlist_for_each_entry;
iterator name hlist_for_each_entry_continue;
iterator name hlist_for_each_entry_from;
iterator name hlist_for_each_entry_safe;
statement S;
@@

(
list_for_each_entry(c,...,member) { ... when != break;
                                 when forall
                                 when strict
}
|
list_for_each_entry_reverse(c,...,member) { ... when != break;
                                 when forall
                                 when strict
}
|
list_for_each_entry_continue(c,...,member) { ... when != break;
                                 when forall
                                 when strict
}
|
list_for_each_entry_continue_reverse(c,...,member) { ... when != break;
                                 when forall
                                 when strict
}
|
list_for_each_entry_from(c,...,member) { ... when != break;
                                 when forall
                                 when strict
}
|
list_for_each_entry_safe(c,...,member) { ... when != break;
                                 when forall
                                 when strict
}
|
list_for_each_entry_safe_continue(c,...,member) { ... when != break;
                                 when forall
                                 when strict
}
|
list_for_each_entry_safe_from(c,...,member) { ... when != break;
                                 when forall
                                 when strict
}
|
list_for_each_entry_safe_reverse(c,...,member) { ... when != break;
                                 when forall
                                 when strict
}
)
...
(
list_for_each_entry(c,...) S
|
list_for_each_entry_reverse(c,...) S
|
list_for_each_entry_continue(c,...) S
|
list_for_each_entry_continue_reverse(c,...) S
|
list_for_each_entry_from(c,...) S
|
list_for_each_entry_safe(c,...) S
|
list_for_each_entry_safe(x,c,...) S
|
list_for_each_entry_safe_continue(c,...) S
|
list_for_each_entry_safe_continue(x,c,...) S
|
list_for_each_entry_safe_from(c,...) S
|
list_for_each_entry_safe_from(x,c,...) S
|
list_for_each_entry_safe_reverse(c,...) S
|
list_for_each_entry_safe_reverse(x,c,...) S
|
hlist_for_each_entry(c,...) S
|
hlist_for_each_entry_continue(c,...) S
|
hlist_for_each_entry_from(c,...) S
|
hlist_for_each_entry_safe(c,...) S
|
list_remove_head(x,c,...)
|
sizeof(<+...c...+>)
|
&c->member
|
c = E
|
*c
)


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2012-08-20 18:31 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-08 11:37 [PATCH 0/7] remove invalid reference to list iterator variable Julia Lawall
2012-07-08 11:37 ` [PATCH 1/7] drivers/isdn/mISDN/stack.c: " Julia Lawall
2012-07-09 22:24   ` David Miller
2012-07-08 11:37 ` [PATCH 2/7] net/rxrpc/ar-peer.c: " Julia Lawall
2012-07-09 22:24   ` David Miller
2012-07-08 11:37 ` [PATCH 3/7] mm/slub.c: " Julia Lawall
2012-07-09  9:04   ` Pekka Enberg
2012-07-09 13:53   ` Christoph Lameter
2012-07-08 11:37 ` [PATCH 4/7] drivers/gpu/drm: " Julia Lawall
2012-07-08 20:52   ` Paul Menzel
2012-07-08 20:56     ` Julia Lawall
2012-07-08 11:37 ` [PATCH 5/7] drivers/iommu/tegra-smmu.c: " Julia Lawall
2012-07-23 17:59   ` Stephen Warren
2012-07-24  8:45     ` Hiroshi Doyu
2012-07-08 11:37 ` [PATCH 6/7] drivers/net/ethernet/broadcom/cnic.c: " Julia Lawall
2012-07-09 22:25   ` David Miller
2012-07-08 11:37 ` [PATCH 7/7] drivers/s390/scsi/zfcp_cfdc.c: " Julia Lawall
2012-08-20 18:30   ` Steffen Maier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).