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
@@ -466,8 +462,6 @@ static int ebt_verify_pointers(const struct ebt_replace *repl,
466
462
/* we make userspace set this right,
467
463
* so there is no misunderstanding
468
464
*/
469
- BUGPRINT ("EBT_ENTRY_OR_ENTRIES shouldn't be set "
470
- "in distinguisher\n" );
471
465
return - EINVAL ;
472
466
}
473
467
if (i != NF_BR_NUMHOOKS )
@@ -485,18 +479,14 @@ static int ebt_verify_pointers(const struct ebt_replace *repl,
485
479
offset += e -> next_offset ;
486
480
}
487
481
}
488
- if (offset != limit ) {
489
- BUGPRINT ("entries_size too small\n" );
482
+ if (offset != limit )
490
483
return - EINVAL ;
491
- }
492
484
493
485
/* check if all valid hooks have a chain */
494
486
for (i = 0 ; i < NF_BR_NUMHOOKS ; i ++ ) {
495
487
if (!newinfo -> hook_entry [i ] &&
496
- (valid_hooks & (1 << i ))) {
497
- BUGPRINT ("Valid hook without chain\n" );
488
+ (valid_hooks & (1 << i )))
498
489
return - EINVAL ;
499
- }
500
490
}
501
491
return 0 ;
502
492
}
@@ -523,42 +513,34 @@ ebt_check_entry_size_and_hooks(const struct ebt_entry *e,
523
513
/* this checks if the previous chain has as many entries
524
514
* as it said it has
525
515
*/
526
- if (* n != * cnt ) {
527
- BUGPRINT ("nentries does not equal the nr of entries "
528
- "in the chain\n" );
516
+ if (* n != * cnt )
529
517
return - EINVAL ;
530
- }
518
+
531
519
if (((struct ebt_entries * )e )-> policy != EBT_DROP &&
532
520
((struct ebt_entries * )e )-> policy != EBT_ACCEPT ) {
533
521
/* only RETURN from udc */
534
522
if (i != NF_BR_NUMHOOKS ||
535
- ((struct ebt_entries * )e )-> policy != EBT_RETURN ) {
536
- BUGPRINT ("bad policy\n" );
523
+ ((struct ebt_entries * )e )-> policy != EBT_RETURN )
537
524
return - EINVAL ;
538
- }
539
525
}
540
526
if (i == NF_BR_NUMHOOKS ) /* it's a user defined chain */
541
527
(* udc_cnt )++ ;
542
- if (((struct ebt_entries * )e )-> counter_offset != * totalcnt ) {
543
- BUGPRINT ("counter_offset != totalcnt" );
528
+ if (((struct ebt_entries * )e )-> counter_offset != * totalcnt )
544
529
return - EINVAL ;
545
- }
546
530
* n = ((struct ebt_entries * )e )-> nentries ;
547
531
* cnt = 0 ;
548
532
return 0 ;
549
533
}
550
534
/* a plain old entry, heh */
551
535
if (sizeof (struct ebt_entry ) > e -> watchers_offset ||
552
536
e -> watchers_offset > e -> target_offset ||
553
- e -> target_offset >= e -> next_offset ) {
554
- BUGPRINT ("entry offsets not in right order\n" );
537
+ e -> target_offset >= e -> next_offset )
555
538
return - EINVAL ;
556
- }
539
+
557
540
/* this is not checked anywhere else */
558
- if (e -> next_offset - e -> target_offset < sizeof (struct ebt_entry_target )) {
559
- BUGPRINT ("target size too small\n" );
541
+ if (e -> next_offset - e -> target_offset < sizeof (struct ebt_entry_target ))
560
542
return - EINVAL ;
561
- }
543
+
562
544
(* cnt )++ ;
563
545
(* totalcnt )++ ;
564
546
return 0 ;
@@ -678,18 +660,15 @@ ebt_check_entry(struct ebt_entry *e, struct net *net,
678
660
if (e -> bitmask == 0 )
679
661
return 0 ;
680
662
681
- if (e -> bitmask & ~EBT_F_MASK ) {
682
- BUGPRINT ("Unknown flag for bitmask\n" );
663
+ if (e -> bitmask & ~EBT_F_MASK )
683
664
return - EINVAL ;
684
- }
685
- if (e -> invflags & ~EBT_INV_MASK ) {
686
- BUGPRINT ("Unknown flag for inv bitmask\n" );
665
+
666
+ if (e -> invflags & ~EBT_INV_MASK )
687
667
return - EINVAL ;
688
- }
689
- if ((e -> bitmask & EBT_NOPROTO ) && (e -> bitmask & EBT_802_3 )) {
690
- BUGPRINT ("NOPROTO & 802_3 not allowed\n" );
668
+
669
+ if ((e -> bitmask & EBT_NOPROTO ) && (e -> bitmask & EBT_802_3 ))
691
670
return - EINVAL ;
692
- }
671
+
693
672
/* what hook do we belong to? */
694
673
for (i = 0 ; i < NF_BR_NUMHOOKS ; i ++ ) {
695
674
if (!newinfo -> hook_entry [i ])
@@ -748,13 +727,11 @@ ebt_check_entry(struct ebt_entry *e, struct net *net,
748
727
t -> u .target = target ;
749
728
if (t -> u .target == & ebt_standard_target ) {
750
729
if (gap < sizeof (struct ebt_standard_target )) {
751
- BUGPRINT ("Standard target size too big\n" );
752
730
ret = - EFAULT ;
753
731
goto cleanup_watchers ;
754
732
}
755
733
if (((struct ebt_standard_target * )t )-> verdict <
756
734
- NUM_STANDARD_TARGETS ) {
757
- BUGPRINT ("Invalid standard target\n" );
758
735
ret = - EFAULT ;
759
736
goto cleanup_watchers ;
760
737
}
@@ -813,10 +790,9 @@ static int check_chainloops(const struct ebt_entries *chain, struct ebt_cl_stack
813
790
if (strcmp (t -> u .name , EBT_STANDARD_TARGET ))
814
791
goto letscontinue ;
815
792
if (e -> target_offset + sizeof (struct ebt_standard_target ) >
816
- e -> next_offset ) {
817
- BUGPRINT ("Standard target size too big\n" );
793
+ e -> next_offset )
818
794
return -1 ;
819
- }
795
+
820
796
verdict = ((struct ebt_standard_target * )t )-> verdict ;
821
797
if (verdict >= 0 ) { /* jump to another chain */
822
798
struct ebt_entries * hlp2 =
@@ -825,14 +801,12 @@ static int check_chainloops(const struct ebt_entries *chain, struct ebt_cl_stack
825
801
if (hlp2 == cl_s [i ].cs .chaininfo )
826
802
break ;
827
803
/* bad destination or loop */
828
- if (i == udc_cnt ) {
829
- BUGPRINT ("bad destination\n" );
804
+ if (i == udc_cnt )
830
805
return -1 ;
831
- }
832
- if (cl_s [i ].cs .n ) {
833
- BUGPRINT ("loop\n" );
806
+
807
+ if (cl_s [i ].cs .n )
834
808
return -1 ;
835
- }
809
+
836
810
if (cl_s [i ].hookmask & (1 << hooknr ))
837
811
goto letscontinue ;
838
812
/* this can't be 0, so the loop test is correct */
@@ -865,24 +839,21 @@ static int translate_table(struct net *net, const char *name,
865
839
i = 0 ;
866
840
while (i < NF_BR_NUMHOOKS && !newinfo -> hook_entry [i ])
867
841
i ++ ;
868
- if (i == NF_BR_NUMHOOKS ) {
869
- BUGPRINT ("No valid hooks specified\n" );
842
+ if (i == NF_BR_NUMHOOKS )
870
843
return - EINVAL ;
871
- }
872
- if (newinfo -> hook_entry [i ] != (struct ebt_entries * )newinfo -> entries ) {
873
- BUGPRINT ("Chains don't start at beginning\n" );
844
+
845
+ if (newinfo -> hook_entry [i ] != (struct ebt_entries * )newinfo -> entries )
874
846
return - EINVAL ;
875
- }
847
+
876
848
/* make sure chains are ordered after each other in same order
877
849
* as their corresponding hooks
878
850
*/
879
851
for (j = i + 1 ; j < NF_BR_NUMHOOKS ; j ++ ) {
880
852
if (!newinfo -> hook_entry [j ])
881
853
continue ;
882
- if (newinfo -> hook_entry [j ] <= newinfo -> hook_entry [i ]) {
883
- BUGPRINT ("Hook order must be followed\n" );
854
+ if (newinfo -> hook_entry [j ] <= newinfo -> hook_entry [i ])
884
855
return - EINVAL ;
885
- }
856
+
886
857
i = j ;
887
858
}
888
859
@@ -900,15 +871,11 @@ static int translate_table(struct net *net, const char *name,
900
871
if (ret != 0 )
901
872
return ret ;
902
873
903
- if (i != j ) {
904
- BUGPRINT ("nentries does not equal the nr of entries in the "
905
- "(last) chain\n" );
874
+ if (i != j )
906
875
return - EINVAL ;
907
- }
908
- if (k != newinfo -> nentries ) {
909
- BUGPRINT ("Total nentries is wrong\n" );
876
+
877
+ if (k != newinfo -> nentries )
910
878
return - EINVAL ;
911
- }
912
879
913
880
/* get the location of the udc, put them in an array
914
881
* while we're at it, allocate the chainstack
@@ -942,7 +909,6 @@ static int translate_table(struct net *net, const char *name,
942
909
ebt_get_udc_positions , newinfo , & i , cl_s );
943
910
/* sanity check */
944
911
if (i != udc_cnt ) {
945
- BUGPRINT ("i != udc_cnt\n" );
946
912
vfree (cl_s );
947
913
return - EFAULT ;
948
914
}
@@ -1042,7 +1008,6 @@ static int do_replace_finish(struct net *net, struct ebt_replace *repl,
1042
1008
goto free_unlock ;
1043
1009
1044
1010
if (repl -> num_counters && repl -> num_counters != t -> private -> nentries ) {
1045
- BUGPRINT ("Wrong nr. of counters requested\n" );
1046
1011
ret = - EINVAL ;
1047
1012
goto free_unlock ;
1048
1013
}
@@ -1118,15 +1083,12 @@ static int do_replace(struct net *net, const void __user *user,
1118
1083
if (copy_from_user (& tmp , user , sizeof (tmp )) != 0 )
1119
1084
return - EFAULT ;
1120
1085
1121
- if (len != sizeof (tmp ) + tmp .entries_size ) {
1122
- BUGPRINT ("Wrong len argument\n" );
1086
+ if (len != sizeof (tmp ) + tmp .entries_size )
1123
1087
return - EINVAL ;
1124
- }
1125
1088
1126
- if (tmp .entries_size == 0 ) {
1127
- BUGPRINT ("Entries_size never zero\n" );
1089
+ if (tmp .entries_size == 0 )
1128
1090
return - EINVAL ;
1129
- }
1091
+
1130
1092
/* overflow check */
1131
1093
if (tmp .nentries >= ((INT_MAX - sizeof (struct ebt_table_info )) /
1132
1094
NR_CPUS - SMP_CACHE_BYTES ) / sizeof (struct ebt_counter ))
@@ -1153,7 +1115,6 @@ static int do_replace(struct net *net, const void __user *user,
1153
1115
}
1154
1116
if (copy_from_user (
1155
1117
newinfo -> entries , tmp .entries , tmp .entries_size ) != 0 ) {
1156
- BUGPRINT ("Couldn't copy entries from userspace\n" );
1157
1118
ret = - EFAULT ;
1158
1119
goto free_entries ;
1159
1120
}
@@ -1194,10 +1155,8 @@ int ebt_register_table(struct net *net, const struct ebt_table *input_table,
1194
1155
1195
1156
if (input_table == NULL || (repl = input_table -> table ) == NULL ||
1196
1157
repl -> entries == NULL || repl -> entries_size == 0 ||
1197
- repl -> counters != NULL || input_table -> private != NULL ) {
1198
- BUGPRINT ("Bad table data for ebt_register_table!!!\n" );
1158
+ repl -> counters != NULL || input_table -> private != NULL )
1199
1159
return - EINVAL ;
1200
- }
1201
1160
1202
1161
/* Don't add one table to multiple lists. */
1203
1162
table = kmemdup (input_table , sizeof (struct ebt_table ), GFP_KERNEL );
@@ -1235,13 +1194,10 @@ int ebt_register_table(struct net *net, const struct ebt_table *input_table,
1235
1194
((char * )repl -> hook_entry [i ] - repl -> entries );
1236
1195
}
1237
1196
ret = translate_table (net , repl -> name , newinfo );
1238
- if (ret != 0 ) {
1239
- BUGPRINT ("Translate_table failed\n" );
1197
+ if (ret != 0 )
1240
1198
goto free_chainstack ;
1241
- }
1242
1199
1243
1200
if (table -> check && table -> check (newinfo , table -> valid_hooks )) {
1244
- BUGPRINT ("The table doesn't like its own initial data, lol\n" );
1245
1201
ret = - EINVAL ;
1246
1202
goto free_chainstack ;
1247
1203
}
@@ -1252,7 +1208,6 @@ int ebt_register_table(struct net *net, const struct ebt_table *input_table,
1252
1208
list_for_each_entry (t , & net -> xt .tables [NFPROTO_BRIDGE ], list ) {
1253
1209
if (strcmp (t -> name , table -> name ) == 0 ) {
1254
1210
ret = - EEXIST ;
1255
- BUGPRINT ("Table name already exists\n" );
1256
1211
goto free_unlock ;
1257
1212
}
1258
1213
}
@@ -1320,7 +1275,6 @@ static int do_update_counters(struct net *net, const char *name,
1320
1275
goto free_tmp ;
1321
1276
1322
1277
if (num_counters != t -> private -> nentries ) {
1323
- BUGPRINT ("Wrong nr of counters\n" );
1324
1278
ret = - EINVAL ;
1325
1279
goto unlock_mutex ;
1326
1280
}
@@ -1447,10 +1401,8 @@ static int copy_counters_to_user(struct ebt_table *t,
1447
1401
if (num_counters == 0 )
1448
1402
return 0 ;
1449
1403
1450
- if (num_counters != nentries ) {
1451
- BUGPRINT ("Num_counters wrong\n" );
1404
+ if (num_counters != nentries )
1452
1405
return - EINVAL ;
1453
- }
1454
1406
1455
1407
counterstmp = vmalloc (array_size (nentries , sizeof (* counterstmp )));
1456
1408
if (!counterstmp )
@@ -1496,15 +1448,11 @@ static int copy_everything_to_user(struct ebt_table *t, void __user *user,
1496
1448
(tmp .num_counters ? nentries * sizeof (struct ebt_counter ) : 0 ))
1497
1449
return - EINVAL ;
1498
1450
1499
- if (tmp .nentries != nentries ) {
1500
- BUGPRINT ("Nentries wrong\n" );
1451
+ if (tmp .nentries != nentries )
1501
1452
return - EINVAL ;
1502
- }
1503
1453
1504
- if (tmp .entries_size != entries_size ) {
1505
- BUGPRINT ("Wrong size\n" );
1454
+ if (tmp .entries_size != entries_size )
1506
1455
return - EINVAL ;
1507
- }
1508
1456
1509
1457
ret = copy_counters_to_user (t , oldcounters , tmp .counters ,
1510
1458
tmp .num_counters , nentries );
@@ -1576,7 +1524,6 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
1576
1524
}
1577
1525
mutex_unlock (& ebt_mutex );
1578
1526
if (copy_to_user (user , & tmp , * len ) != 0 ) {
1579
- BUGPRINT ("c2u Didn't work\n" );
1580
1527
ret = - EFAULT ;
1581
1528
break ;
1582
1529
}
0 commit comments