31
31
/* needed for logical [in,out]-dev filtering */
32
32
#include "../br_private.h"
33
33
34
- #define BUGPRINT (format , args ...) printk("kernel msg: ebtables bug: please "\
35
- "report to author: "format, ## args)
36
- /* #define BUGPRINT(format, args...) */
37
-
38
34
/* Each cpu has its own set of counters, so there is no need for write_lock in
39
35
* the softirq
40
36
* For reading or updating the counters, the user context needs to
@@ -453,8 +449,6 @@ static int ebt_verify_pointers(const struct ebt_replace *repl,
453
449
/* we make userspace set this right,
454
450
* so there is no misunderstanding
455
451
*/
456
- BUGPRINT ("EBT_ENTRY_OR_ENTRIES shouldn't be set "
457
- "in distinguisher\n" );
458
452
return - EINVAL ;
459
453
}
460
454
if (i != NF_BR_NUMHOOKS )
@@ -472,18 +466,14 @@ static int ebt_verify_pointers(const struct ebt_replace *repl,
472
466
offset += e -> next_offset ;
473
467
}
474
468
}
475
- if (offset != limit ) {
476
- BUGPRINT ("entries_size too small\n" );
469
+ if (offset != limit )
477
470
return - EINVAL ;
478
- }
479
471
480
472
/* check if all valid hooks have a chain */
481
473
for (i = 0 ; i < NF_BR_NUMHOOKS ; i ++ ) {
482
474
if (!newinfo -> hook_entry [i ] &&
483
- (valid_hooks & (1 << i ))) {
484
- BUGPRINT ("Valid hook without chain\n" );
475
+ (valid_hooks & (1 << i )))
485
476
return - EINVAL ;
486
- }
487
477
}
488
478
return 0 ;
489
479
}
@@ -510,42 +500,34 @@ ebt_check_entry_size_and_hooks(const struct ebt_entry *e,
510
500
/* this checks if the previous chain has as many entries
511
501
* as it said it has
512
502
*/
513
- if (* n != * cnt ) {
514
- BUGPRINT ("nentries does not equal the nr of entries "
515
- "in the chain\n" );
503
+ if (* n != * cnt )
516
504
return - EINVAL ;
517
- }
505
+
518
506
if (((struct ebt_entries * )e )-> policy != EBT_DROP &&
519
507
((struct ebt_entries * )e )-> policy != EBT_ACCEPT ) {
520
508
/* only RETURN from udc */
521
509
if (i != NF_BR_NUMHOOKS ||
522
- ((struct ebt_entries * )e )-> policy != EBT_RETURN ) {
523
- BUGPRINT ("bad policy\n" );
510
+ ((struct ebt_entries * )e )-> policy != EBT_RETURN )
524
511
return - EINVAL ;
525
- }
526
512
}
527
513
if (i == NF_BR_NUMHOOKS ) /* it's a user defined chain */
528
514
(* udc_cnt )++ ;
529
- if (((struct ebt_entries * )e )-> counter_offset != * totalcnt ) {
530
- BUGPRINT ("counter_offset != totalcnt" );
515
+ if (((struct ebt_entries * )e )-> counter_offset != * totalcnt )
531
516
return - EINVAL ;
532
- }
533
517
* n = ((struct ebt_entries * )e )-> nentries ;
534
518
* cnt = 0 ;
535
519
return 0 ;
536
520
}
537
521
/* a plain old entry, heh */
538
522
if (sizeof (struct ebt_entry ) > e -> watchers_offset ||
539
523
e -> watchers_offset > e -> target_offset ||
540
- e -> target_offset >= e -> next_offset ) {
541
- BUGPRINT ("entry offsets not in right order\n" );
524
+ e -> target_offset >= e -> next_offset )
542
525
return - EINVAL ;
543
- }
526
+
544
527
/* this is not checked anywhere else */
545
- if (e -> next_offset - e -> target_offset < sizeof (struct ebt_entry_target )) {
546
- BUGPRINT ("target size too small\n" );
528
+ if (e -> next_offset - e -> target_offset < sizeof (struct ebt_entry_target ))
547
529
return - EINVAL ;
548
- }
530
+
549
531
(* cnt )++ ;
550
532
(* totalcnt )++ ;
551
533
return 0 ;
@@ -665,18 +647,15 @@ ebt_check_entry(struct ebt_entry *e, struct net *net,
665
647
if (e -> bitmask == 0 )
666
648
return 0 ;
667
649
668
- if (e -> bitmask & ~EBT_F_MASK ) {
669
- BUGPRINT ("Unknown flag for bitmask\n" );
650
+ if (e -> bitmask & ~EBT_F_MASK )
670
651
return - EINVAL ;
671
- }
672
- if (e -> invflags & ~EBT_INV_MASK ) {
673
- BUGPRINT ("Unknown flag for inv bitmask\n" );
652
+
653
+ if (e -> invflags & ~EBT_INV_MASK )
674
654
return - EINVAL ;
675
- }
676
- if ((e -> bitmask & EBT_NOPROTO ) && (e -> bitmask & EBT_802_3 )) {
677
- BUGPRINT ("NOPROTO & 802_3 not allowed\n" );
655
+
656
+ if ((e -> bitmask & EBT_NOPROTO ) && (e -> bitmask & EBT_802_3 ))
678
657
return - EINVAL ;
679
- }
658
+
680
659
/* what hook do we belong to? */
681
660
for (i = 0 ; i < NF_BR_NUMHOOKS ; i ++ ) {
682
661
if (!newinfo -> hook_entry [i ])
@@ -735,13 +714,11 @@ ebt_check_entry(struct ebt_entry *e, struct net *net,
735
714
t -> u .target = target ;
736
715
if (t -> u .target == & ebt_standard_target ) {
737
716
if (gap < sizeof (struct ebt_standard_target )) {
738
- BUGPRINT ("Standard target size too big\n" );
739
717
ret = - EFAULT ;
740
718
goto cleanup_watchers ;
741
719
}
742
720
if (((struct ebt_standard_target * )t )-> verdict <
743
721
- NUM_STANDARD_TARGETS ) {
744
- BUGPRINT ("Invalid standard target\n" );
745
722
ret = - EFAULT ;
746
723
goto cleanup_watchers ;
747
724
}
@@ -801,10 +778,9 @@ static int check_chainloops(const struct ebt_entries *chain, struct ebt_cl_stack
801
778
if (strcmp (t -> u .name , EBT_STANDARD_TARGET ))
802
779
goto letscontinue ;
803
780
if (e -> target_offset + sizeof (struct ebt_standard_target ) >
804
- e -> next_offset ) {
805
- BUGPRINT ("Standard target size too big\n" );
781
+ e -> next_offset )
806
782
return -1 ;
807
- }
783
+
808
784
verdict = ((struct ebt_standard_target * )t )-> verdict ;
809
785
if (verdict >= 0 ) { /* jump to another chain */
810
786
struct ebt_entries * hlp2 =
@@ -813,14 +789,12 @@ static int check_chainloops(const struct ebt_entries *chain, struct ebt_cl_stack
813
789
if (hlp2 == cl_s [i ].cs .chaininfo )
814
790
break ;
815
791
/* bad destination or loop */
816
- if (i == udc_cnt ) {
817
- BUGPRINT ("bad destination\n" );
792
+ if (i == udc_cnt )
818
793
return -1 ;
819
- }
820
- if (cl_s [i ].cs .n ) {
821
- BUGPRINT ("loop\n" );
794
+
795
+ if (cl_s [i ].cs .n )
822
796
return -1 ;
823
- }
797
+
824
798
if (cl_s [i ].hookmask & (1 << hooknr ))
825
799
goto letscontinue ;
826
800
/* this can't be 0, so the loop test is correct */
@@ -853,24 +827,21 @@ static int translate_table(struct net *net, const char *name,
853
827
i = 0 ;
854
828
while (i < NF_BR_NUMHOOKS && !newinfo -> hook_entry [i ])
855
829
i ++ ;
856
- if (i == NF_BR_NUMHOOKS ) {
857
- BUGPRINT ("No valid hooks specified\n" );
830
+ if (i == NF_BR_NUMHOOKS )
858
831
return - EINVAL ;
859
- }
860
- if (newinfo -> hook_entry [i ] != (struct ebt_entries * )newinfo -> entries ) {
861
- BUGPRINT ("Chains don't start at beginning\n" );
832
+
833
+ if (newinfo -> hook_entry [i ] != (struct ebt_entries * )newinfo -> entries )
862
834
return - EINVAL ;
863
- }
835
+
864
836
/* make sure chains are ordered after each other in same order
865
837
* as their corresponding hooks
866
838
*/
867
839
for (j = i + 1 ; j < NF_BR_NUMHOOKS ; j ++ ) {
868
840
if (!newinfo -> hook_entry [j ])
869
841
continue ;
870
- if (newinfo -> hook_entry [j ] <= newinfo -> hook_entry [i ]) {
871
- BUGPRINT ("Hook order must be followed\n" );
842
+ if (newinfo -> hook_entry [j ] <= newinfo -> hook_entry [i ])
872
843
return - EINVAL ;
873
- }
844
+
874
845
i = j ;
875
846
}
876
847
@@ -888,15 +859,11 @@ static int translate_table(struct net *net, const char *name,
888
859
if (ret != 0 )
889
860
return ret ;
890
861
891
- if (i != j ) {
892
- BUGPRINT ("nentries does not equal the nr of entries in the "
893
- "(last) chain\n" );
862
+ if (i != j )
894
863
return - EINVAL ;
895
- }
896
- if (k != newinfo -> nentries ) {
897
- BUGPRINT ("Total nentries is wrong\n" );
864
+
865
+ if (k != newinfo -> nentries )
898
866
return - EINVAL ;
899
- }
900
867
901
868
/* get the location of the udc, put them in an array
902
869
* while we're at it, allocate the chainstack
@@ -929,7 +896,6 @@ static int translate_table(struct net *net, const char *name,
929
896
ebt_get_udc_positions , newinfo , & i , cl_s );
930
897
/* sanity check */
931
898
if (i != udc_cnt ) {
932
- BUGPRINT ("i != udc_cnt\n" );
933
899
vfree (cl_s );
934
900
return - EFAULT ;
935
901
}
@@ -1030,7 +996,6 @@ static int do_replace_finish(struct net *net, struct ebt_replace *repl,
1030
996
goto free_unlock ;
1031
997
1032
998
if (repl -> num_counters && repl -> num_counters != t -> private -> nentries ) {
1033
- BUGPRINT ("Wrong nr. of counters requested\n" );
1034
999
ret = - EINVAL ;
1035
1000
goto free_unlock ;
1036
1001
}
@@ -1115,15 +1080,12 @@ static int do_replace(struct net *net, const void __user *user,
1115
1080
if (copy_from_user (& tmp , user , sizeof (tmp )) != 0 )
1116
1081
return - EFAULT ;
1117
1082
1118
- if (len != sizeof (tmp ) + tmp .entries_size ) {
1119
- BUGPRINT ("Wrong len argument\n" );
1083
+ if (len != sizeof (tmp ) + tmp .entries_size )
1120
1084
return - EINVAL ;
1121
- }
1122
1085
1123
- if (tmp .entries_size == 0 ) {
1124
- BUGPRINT ("Entries_size never zero\n" );
1086
+ if (tmp .entries_size == 0 )
1125
1087
return - EINVAL ;
1126
- }
1088
+
1127
1089
/* overflow check */
1128
1090
if (tmp .nentries >= ((INT_MAX - sizeof (struct ebt_table_info )) /
1129
1091
NR_CPUS - SMP_CACHE_BYTES ) / sizeof (struct ebt_counter ))
@@ -1150,7 +1112,6 @@ static int do_replace(struct net *net, const void __user *user,
1150
1112
}
1151
1113
if (copy_from_user (
1152
1114
newinfo -> entries , tmp .entries , tmp .entries_size ) != 0 ) {
1153
- BUGPRINT ("Couldn't copy entries from userspace\n" );
1154
1115
ret = - EFAULT ;
1155
1116
goto free_entries ;
1156
1117
}
@@ -1197,10 +1158,8 @@ int ebt_register_table(struct net *net, const struct ebt_table *input_table,
1197
1158
1198
1159
if (input_table == NULL || (repl = input_table -> table ) == NULL ||
1199
1160
repl -> entries == NULL || repl -> entries_size == 0 ||
1200
- repl -> counters != NULL || input_table -> private != NULL ) {
1201
- BUGPRINT ("Bad table data for ebt_register_table!!!\n" );
1161
+ repl -> counters != NULL || input_table -> private != NULL )
1202
1162
return - EINVAL ;
1203
- }
1204
1163
1205
1164
/* Don't add one table to multiple lists. */
1206
1165
table = kmemdup (input_table , sizeof (struct ebt_table ), GFP_KERNEL );
@@ -1238,13 +1197,10 @@ int ebt_register_table(struct net *net, const struct ebt_table *input_table,
1238
1197
((char * )repl -> hook_entry [i ] - repl -> entries );
1239
1198
}
1240
1199
ret = translate_table (net , repl -> name , newinfo );
1241
- if (ret != 0 ) {
1242
- BUGPRINT ("Translate_table failed\n" );
1200
+ if (ret != 0 )
1243
1201
goto free_chainstack ;
1244
- }
1245
1202
1246
1203
if (table -> check && table -> check (newinfo , table -> valid_hooks )) {
1247
- BUGPRINT ("The table doesn't like its own initial data, lol\n" );
1248
1204
ret = - EINVAL ;
1249
1205
goto free_chainstack ;
1250
1206
}
@@ -1255,7 +1211,6 @@ int ebt_register_table(struct net *net, const struct ebt_table *input_table,
1255
1211
list_for_each_entry (t , & net -> xt .tables [NFPROTO_BRIDGE ], list ) {
1256
1212
if (strcmp (t -> name , table -> name ) == 0 ) {
1257
1213
ret = - EEXIST ;
1258
- BUGPRINT ("Table name already exists\n" );
1259
1214
goto free_unlock ;
1260
1215
}
1261
1216
}
@@ -1327,7 +1282,6 @@ static int do_update_counters(struct net *net, const char *name,
1327
1282
goto free_tmp ;
1328
1283
1329
1284
if (num_counters != t -> private -> nentries ) {
1330
- BUGPRINT ("Wrong nr of counters\n" );
1331
1285
ret = - EINVAL ;
1332
1286
goto unlock_mutex ;
1333
1287
}
@@ -1452,10 +1406,8 @@ static int copy_counters_to_user(struct ebt_table *t,
1452
1406
if (num_counters == 0 )
1453
1407
return 0 ;
1454
1408
1455
- if (num_counters != nentries ) {
1456
- BUGPRINT ("Num_counters wrong\n" );
1409
+ if (num_counters != nentries )
1457
1410
return - EINVAL ;
1458
- }
1459
1411
1460
1412
counterstmp = vmalloc (nentries * sizeof (* counterstmp ));
1461
1413
if (!counterstmp )
@@ -1501,15 +1453,11 @@ static int copy_everything_to_user(struct ebt_table *t, void __user *user,
1501
1453
(tmp .num_counters ? nentries * sizeof (struct ebt_counter ) : 0 ))
1502
1454
return - EINVAL ;
1503
1455
1504
- if (tmp .nentries != nentries ) {
1505
- BUGPRINT ("Nentries wrong\n" );
1456
+ if (tmp .nentries != nentries )
1506
1457
return - EINVAL ;
1507
- }
1508
1458
1509
- if (tmp .entries_size != entries_size ) {
1510
- BUGPRINT ("Wrong size\n" );
1459
+ if (tmp .entries_size != entries_size )
1511
1460
return - EINVAL ;
1512
- }
1513
1461
1514
1462
ret = copy_counters_to_user (t , oldcounters , tmp .counters ,
1515
1463
tmp .num_counters , nentries );
@@ -1581,7 +1529,6 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
1581
1529
}
1582
1530
mutex_unlock (& ebt_mutex );
1583
1531
if (copy_to_user (user , & tmp , * len ) != 0 ) {
1584
- BUGPRINT ("c2u Didn't work\n" );
1585
1532
ret = - EFAULT ;
1586
1533
break ;
1587
1534
}
0 commit comments