Skip to content

Commit 823f05d

Browse files
dvyukovHridya Valsaraju
authored andcommitted
UPSTREAM: netfilter: x_tables: fix pointer leaks to userspace
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. Bug: 187527909 Fixes: ec2318904965 ("xtables: extend matches and targets with .usersize") Signed-off-by: Dmitry Vyukov <dvyukov@google.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Change-Id: If4d4beb7429c38d9b359cb2a929c71aef84f6cd0 (cherry picked from commit 1e98ffea5a8935ec040ab72299e349cb44b8defd) Signed-off-by: Hridya Valsaraju <hridya@google.com>
1 parent 86cb772 commit 823f05d

5 files changed

Lines changed: 5 additions & 2 deletions

File tree

net/netfilter/xt_IDLETIMER.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,7 @@ static struct xt_target idletimer_tg __read_mostly = {
497497
.family = NFPROTO_UNSPEC,
498498
.target = idletimer_tg_target,
499499
.targetsize = sizeof(struct idletimer_tg_info),
500+
.usersize = offsetof(struct idletimer_tg_info, timer),
500501
.checkentry = idletimer_tg_checkentry,
501502
.destroy = idletimer_tg_destroy,
502503
.me = THIS_MODULE,

net/netfilter/xt_LED.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ static struct xt_target led_tg_reg __read_mostly = {
198198
.family = NFPROTO_UNSPEC,
199199
.target = led_tg,
200200
.targetsize = sizeof(struct xt_led_info),
201+
.usersize = offsetof(struct xt_led_info, internal_data),
201202
.checkentry = led_tg_check,
202203
.destroy = led_tg_destroy,
203204
.me = THIS_MODULE,

net/netfilter/xt_limit.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,8 @@ static struct xt_match limit_mt_reg __read_mostly = {
192192
.compatsize = sizeof(struct compat_xt_rateinfo),
193193
.compat_from_user = limit_mt_compat_from_user,
194194
.compat_to_user = limit_mt_compat_to_user,
195-
#else
196-
.usersize = offsetof(struct xt_rateinfo, prev),
197195
#endif
196+
.usersize = offsetof(struct xt_rateinfo, prev),
198197
.me = THIS_MODULE,
199198
};
200199

net/netfilter/xt_nfacct.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ static struct xt_match nfacct_mt_reg __read_mostly = {
6262
.match = nfacct_mt,
6363
.destroy = nfacct_mt_destroy,
6464
.matchsize = sizeof(struct xt_nfacct_match_info),
65+
.usersize = offsetof(struct xt_nfacct_match_info, nfacct),
6566
.me = THIS_MODULE,
6667
};
6768

net/netfilter/xt_statistic.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ static struct xt_match xt_statistic_mt_reg __read_mostly = {
8484
.checkentry = statistic_mt_check,
8585
.destroy = statistic_mt_destroy,
8686
.matchsize = sizeof(struct xt_statistic_info),
87+
.usersize = offsetof(struct xt_statistic_info, master),
8788
.me = THIS_MODULE,
8889
};
8990

0 commit comments

Comments
 (0)