Skip to content

Commit

Permalink
netfilter: x_tables: fix pointer leaks to userspace
Browse files Browse the repository at this point in the history
Several netfilter matches and targets put kernel pointers into
info objects, but don't set usersize in descriptors.
This leads to kernel pointer leaks if a match/target is set
and then read back to userspace.

Properly set usersize for these matches/targets.

Found with manual code inspection.

Fixes: ec23189 ("xtables: extend matches and targets with .usersize")
Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  • Loading branch information
Dmitry Vyukov authored and Pablo Neira Ayuso committed Jan 31, 2018
1 parent 0b8d907 commit 1e98ffe
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions net/netfilter/xt_IDLETIMER.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ static struct xt_target idletimer_tg __read_mostly = {
.family = NFPROTO_UNSPEC,
.target = idletimer_tg_target,
.targetsize = sizeof(struct idletimer_tg_info),
.usersize = offsetof(struct idletimer_tg_info, timer),
.checkentry = idletimer_tg_checkentry,
.destroy = idletimer_tg_destroy,
.me = THIS_MODULE,
Expand Down
1 change: 1 addition & 0 deletions net/netfilter/xt_LED.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ static struct xt_target led_tg_reg __read_mostly = {
.family = NFPROTO_UNSPEC,
.target = led_tg,
.targetsize = sizeof(struct xt_led_info),
.usersize = offsetof(struct xt_led_info, internal_data),
.checkentry = led_tg_check,
.destroy = led_tg_destroy,
.me = THIS_MODULE,
Expand Down
3 changes: 1 addition & 2 deletions net/netfilter/xt_limit.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,8 @@ static struct xt_match limit_mt_reg __read_mostly = {
.compatsize = sizeof(struct compat_xt_rateinfo),
.compat_from_user = limit_mt_compat_from_user,
.compat_to_user = limit_mt_compat_to_user,
#else
.usersize = offsetof(struct xt_rateinfo, prev),
#endif
.usersize = offsetof(struct xt_rateinfo, prev),
.me = THIS_MODULE,
};

Expand Down
1 change: 1 addition & 0 deletions net/netfilter/xt_nfacct.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ static struct xt_match nfacct_mt_reg __read_mostly = {
.match = nfacct_mt,
.destroy = nfacct_mt_destroy,
.matchsize = sizeof(struct xt_nfacct_match_info),
.usersize = offsetof(struct xt_nfacct_match_info, nfacct),
.me = THIS_MODULE,
};

Expand Down
1 change: 1 addition & 0 deletions net/netfilter/xt_statistic.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ static struct xt_match xt_statistic_mt_reg __read_mostly = {
.checkentry = statistic_mt_check,
.destroy = statistic_mt_destroy,
.matchsize = sizeof(struct xt_statistic_info),
.usersize = offsetof(struct xt_statistic_info, master),
.me = THIS_MODULE,
};

Expand Down

0 comments on commit 1e98ffe

Please sign in to comment.