aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/scripts/python/net_dropmonitor.py
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2016-06-14 18:14:12 -0400
committerPablo Neira Ayuso <pablo@netfilter.org>2016-06-23 07:58:55 -0400
commit9847371a84b0be330f4bc4aaa98904101ee8573d (patch)
tree4e00cd02b27d230a508db9b2d2c1c0088be1d2d6 /tools/perf/scripts/python/net_dropmonitor.py
parent6c8dee9842461e6ee6eb46081478999b3d5cb297 (diff)
netfilter: Allow xt_owner in any user namespace
Making this work is a little tricky as it really isn't kosher to change the xt_owner_match_info in a check function. Without changing xt_owner_match_info we need to know the user namespace the uids and gids are specified in. In the common case net->user_ns == current_user_ns(). Verify net->user_ns == current_user_ns() in owner_check so we can later assume it in owner_mt. In owner_check also verify that all of the uids and gids specified are in net->user_ns and that the expected min/max relationship exists between the uids and gids in xt_owner_match_info. In owner_mt get the network namespace from the outgoing socket, as this must be the same network namespace as the netfilter rules, and use that network namespace to find the user namespace the uids and gids in xt_match_owner_info are encoded in. Then convert from their encoded from into the kernel internal format for uids and gids and perform the owner match. Similar to ping_group_range, this code does not try to detect noncontiguous UID/GID ranges. Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Kevin Cernekee <cernekee@chromium.org> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'tools/perf/scripts/python/net_dropmonitor.py')
0 files changed, 0 insertions, 0 deletions
org> 2006-06-28 17:59:04 -0400 [PATCH] mark address_space_operations const' href='/cgit/cgit.cgi/litmus-rt-pandaboard.git/commit/fs/hugetlbfs/inode.c?id=f5e54d6e53a20cef45af7499e86164f0e0d16bb2'>f5e54d6e53a
4b6f5d20b04
92e1d5be91a

1da177e4c3f

d993831fa7f
1da177e4c3f
e4ad08fe64a
1da177e4c3f



e73a75fa7f0


a137e1cc6d6
e73a75fa7f0


a447c093244
e73a75fa7f0




a137e1cc6d6
e73a75fa7f0


2e9b367c227









1da177e4c3f

b39424e274a
1da177e4c3f

a5516438959
1da177e4c3f
68589bc3530
dec4ad86c2f





68589bc3530


1da177e4c3f
a5516438959
dec4ad86c2f

1da177e4c3f

1b1dcc1b57a
1da177e4c3f
1da177e4c3f


1da177e4c3f
a1e78772d72
a5516438959
5a6fe125950

a43a8c39bbb
b45b5bd65f6
4c887265977

b6174df5eec
1da177e4c3f

1b1dcc1b57a
1da177e4c3f




508034a32b8
1da177e4c3f

d2ba27e8007
1da177e4c3f






a5516438959
1da177e4c3f
a5516438959
1da177e4c3f



036e08568cb
a5516438959
036e08568cb



1da177e4c3f
a5516438959
1da177e4c3f







1363c3cd860


1da177e4c3f
a5516438959
1da177e4c3f
















a5516438959
1da177e4c3f



e63e1e5a6b7













































a5516438959
e63e1e5a6b7

a5516438959

e63e1e5a6b7













a5516438959
e63e1e5a6b7

a5516438959
91bf189c3a7
e63e1e5a6b7

a5516438959
e63e1e5a6b7


a5516438959
e63e1e5a6b7














91bf189c3a7


e63e1e5a6b7



91bf189c3a7

e63e1e5a6b7
91bf189c3a7
e63e1e5a6b7
91bf189c3a7
e63e1e5a6b7







a5516438959

e63e1e5a6b7








a5516438959
e63e1e5a6b7



800d15a53e7



1da177e4c3f



800d15a53e7


1da177e4c3f
800d15a53e7
1da177e4c3f


1da177e4c3f

fba2591bf4e
1da177e4c3f




b45b5bd65f6
1da177e4c3f
a5516438959
b45b5bd65f6
a5516438959
1da177e4c3f

a43a8c39bbb
1da177e4c3f



















a43a8c39bbb
1da177e4c3f



a43a8c39bbb
1da177e4c3f



b45b5bd65f6
149f4211afd


ddc0a51d2e3
1da177e4c3f
22fe4042181



1da177e4c3f
1da177e4c3f




6b09b9df05f
1da177e4c3f



1da177e4c3f
856fc295055
1da177e4c3f



856fc295055
1da177e4c3f

1da177e4c3f
856fc295055



1da177e4c3f
856fc295055


1da177e4c3f

502717f4e11
04f2cbe3569
1da177e4c3f


1da177e4c3f

856fc295055
1da177e4c3f
a5516438959
1da177e4c3f
a5516438959
856fc295055
1da177e4c3f
7aa91e10402
1da177e4c3f



b45b5bd65f6
1da177e4c3f





a5516438959
1da177e4c3f










a5516438959
1da177e4c3f













1da177e4c3f






1da177e4c3f


a43a8c39bbb
1da177e4c3f
6bfde05bf5c






71fe804b6d5
1da177e4c3f












d8c76e6f45c
1da177e4c3f























77c70de15a7
1da177e4c3f
77c70de15a7
1da177e4c3f












d8c76e6f45c
1da177e4c3f

















77c70de15a7
1da177e4c3f
77c70de15a7
1da177e4c3f















6649a386323
1da177e4c3f


d85f33855c3
6649a386323

1da177e4c3f


726c3342231
1da177e4c3f
726c3342231
a5516438959
1da177e4c3f

a5516438959
1da177e4c3f

74a8a65c526







1da177e4c3f















96527980d4c
























e18b890bb08
1da177e4c3f


96527980d4c
1da177e4c3f

96527980d4c

e94b1766097
96527980d4c

1da177e4c3f
96527980d4c
1da177e4c3f


1da177e4c3f

96527980d4c
1da177e4c3f



f5e54d6e53a
800d15a53e7

1da177e4c3f


96527980d4c
51cc50685a4
96527980d4c


a35afb830f8
96527980d4c

4b6f5d20b04
e63e1e5a6b7
1da177e4c3f




92e1d5be91a
1da177e4c3f











92e1d5be91a
1da177e4c3f


ee9b6d61a2a
1da177e4c3f


149f4211afd
1da177e4c3f

10f19a86a5e
1da177e4c3f




e73a75fa7f0


a137e1cc6d6

1da177e4c3f


1da177e4c3f
e73a75fa7f0

b4c07bce796

e73a75fa7f0

















75897d60a54
e73a75fa7f0


e73a75fa7f0



a137e1cc6d6


e73a75fa7f0

1da177e4c3f
e73a75fa7f0






a137e1cc6d6












e73a75fa7f0
b4c07bce796


e73a75fa7f0

1da177e4c3f
a137e1cc6d6











1da177e4c3f
e73a75fa7f0



c12ddba0939
1da177e4c3f










10f19a86a5e

1da177e4c3f

77c70de15a7

1da177e4c3f
a137e1cc6d6
1da177e4c3f
1da177e4c3f






a137e1cc6d6
1da177e4c3f





a137e1cc6d6

1da177e4c3f



















9a119c056dc
1da177e4c3f





9a119c056dc

1da177e4c3f







9a119c056dc
1da177e4c3f




9a119c056dc
1da177e4c3f



454e2398be9

1da177e4c3f
454e2398be9
1da177e4c3f









ef1ff6b8c08
1da177e4c3f
ef1ff6b8c08
1da177e4c3f

353d5c30c66
6bfde05bf5c
1da177e4c3f



2c48b9c4557

1da177e4c3f
1da177e4c3f
353d5c30c66
5bc98594d59


ef1ff6b8c08
353d5c30c66

2584e517320

353d5c30c66

2584e517320
353d5c30c66
2584e517320
1da177e4c3f
1da177e4c3f
9d66586f772
1da177e4c3f

2c48b9c4557

1da177e4c3f

2c48b9c4557
1da177e4c3f
77c70de15a7

1da177e4c3f
ce8d2cdf3d2
1da177e4c3f
b45b5bd65f6
a5516438959
5a6fe125950

b45b5bd65f6

2c48b9c4557
1da177e4c3f

ce8d2cdf3d2

2c48b9c4557
ce8d2cdf3d2

b4d232e65fa
ce8d2cdf3d2
1da177e4c3f

b45b5bd65f6

1da177e4c3f
2c48b9c4557
1da177e4c3f
353d5c30c66



1da177e4c3f







e0bf68ddec4



1da177e4c3f

20c2df83d25
1da177e4c3f
e0bf68ddec4
1da177e4c3f
















e0bf68ddec4

1da177e4c3f






e0bf68ddec4
1da177e4c3f





1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034














                                                         
                         




                            
                             
                        


                              
                         
                       



                           
                        


                        
                                                   
                                                            
                                                       

                                                                    

                                                             
                                      
                                                  
                                                        



                             


                                   
                     


                
                                     




                                        
                                       


                              









                                                      

                                                                             
                                                           

                            
                                             
 
          





                                                                      


                                                  
 
                                                               

                               

                                                        
                                    
                            


                                                              
 
                                        
                                                                    

                                                               
                         
 

                                               
                                                            

                                    
                                      




                   
                                     

   
                                       






                                                                            
                                             
 
                                     



                               
                                
                                                            



                                       
                   
                                                      







                                                          


                                                
            
                                                    
















                                                                      
                                                             



         













































                                                                            
                                             

                                                        

                                                          













                                    
                                                      

                                  
                                      
                       

                                                                              
                                       


                                              
                                                                    














                                                                           


                                             



                                                                          

                                                                              
                 
                             
                                        
                                            







                                                         

                                                      








                                                 
                                                               



                                      



                                                                 



                       


                                                                                
 
              


                       

                                                 
                                                                         




                                     
                                                                  
 
                                               
                                                       
                                                           

                            
                         



















                                                                          
                                



                                            
                                                     



                                                       
                                     


                           
                                                                              
 



                                             
         




                                                     
                                            



                                              
                  
                                                                   



                                   
                                                                   

                                       
                  



                                                                       
                   


                                                                         

                                     
                                           
                                                                             


         

                                                                 
                      
                                                         
                                               
 
                                            
                                     
 
                                    



                                                                 
                                          





                                                                       
                                               










                                               
                                                          













                                                                            






                                                  


                                                                                
                                                                
                                          






                                                                             
                                                             












                                                                                          
                                         























                                                                     
                                      
         
                                                                                












                                                                              
                               

















                                                                                                     
                                      
 
                                                               















                                                                   
                           


                                                      
                                                

                           


                 
                                                                       
 
                                                                      
                                                         

                                      
                                         

                                              







                                                                           















                                                         
























                                                                             
                                                 


                                                                  
                                                            

                                       

                                                         
                                                                 

                                                  
                            
         


                             

                                                        
                                                             



                                                                    
                                                               

                                                


                                                   
 
                                


                                                                             
                                        

 
                                                          
                                                 




                                                            
                                                                       











                                            
                                                                   


                                            
                                                      


                                                  
                                                 

                                               
                                               




                                                                        


                                       

                                                                   


                         
 

                                                     

                                 

















                                                           
                                                        


                                



                                                                            


                                                       

                              
 






                                                                            












                                                                            
                        


                                                                                

                              
         











                                                                  
                 



                                                                            
                       










                                                                    

                                     

                                                                            

                                     
                           
                                        
                                                     






                                                                       
                                       





                                               

                                                              



















                                                                  
                                                                





                                                                             

                                                     







                                                
                                                                 




                                                                             
                                             



                                                

                                                                          
 
                                                                             









                                                    
                                   
 
                                                                             

 
                                                                            
                                                                           



                            

                            
                                 
 
                     


                                        
                                                                          

                                                 

                                                                              

                                     
                                               
                 
         
 
                                            
                                 

                                                     

                                                   

                                    
                                              
                        

                                                                         
                   
                                
 
                        
                                           

                                                                           

                               
                                          

                             

                        
                                                          

                                                    
                                                                
 

                    

                    
           
                        
               



                                             







                                         



                                                      

                                                                            
                                                         
                                           
                          
















                                                           

                                                 






                                                   
                                                 





                              
/*
 * hugetlbpage-backed filesystem.  Based on ramfs.
 *
 * William Irwin, 2002
 *
 * Copyright (C) 2002 Linus Torvalds.
 */

#include <linux/module.h>
#include <linux/thread_info.h>
#include <asm/current.h>
#include <linux/sched.h>		/* remove ASAP */
#include <linux/fs.h>
#include <linux/mount.h>
#include <linux/file.h>
#include <linux/kernel.h>
#include <linux/writeback.h>
#include <linux/pagemap.h>
#include <linux/highmem.h>
#include <linux/init.h>
#include <linux/string.h>
#include <linux/capability.h>
#include <linux/ctype.h>
#include <linux/backing-dev.h>
#include <linux/hugetlb.h>
#include <linux/pagevec.h>
#include <linux/parser.h>
#include <linux/mman.h>
#include <linux/slab.h>
#include <linux/dnotify.h>
#include <linux/statfs.h>
#include <linux/security.h>
#include <linux/magic.h>

#include <asm/uaccess.h>

static const struct super_operations hugetlbfs_ops;
static const struct address_space_operations hugetlbfs_aops;
const struct file_operations hugetlbfs_file_operations;
static const struct inode_operations hugetlbfs_dir_inode_operations;
static const struct inode_operations hugetlbfs_inode_operations;

static struct backing_dev_info hugetlbfs_backing_dev_info = {
	.name		= "hugetlbfs",
	.ra_pages	= 0,	/* No readahead */
	.capabilities	= BDI_CAP_NO_ACCT_AND_WRITEBACK,
};

int sysctl_hugetlb_shm_group;

enum {
	Opt_size, Opt_nr_inodes,
	Opt_mode, Opt_uid, Opt_gid,
	Opt_pagesize,
	Opt_err,
};

static const match_table_t tokens = {
	{Opt_size,	"size=%s"},
	{Opt_nr_inodes,	"nr_inodes=%s"},
	{Opt_mode,	"mode=%o"},
	{Opt_uid,	"uid=%u"},
	{Opt_gid,	"gid=%u"},
	{Opt_pagesize,	"pagesize=%s"},
	{Opt_err,	NULL},
};

static void huge_pagevec_release(struct pagevec *pvec)
{
	int i;

	for (i = 0; i < pagevec_count(pvec); ++i)
		put_page(pvec->pages[i]);

	pagevec_reinit(pvec);
}

static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma)
{
	struct inode *inode = file->f_path.dentry->d_inode;
	loff_t len, vma_len;
	int ret;
	struct hstate *h = hstate_file(file);

	/*
	 * vma address alignment (but not the pgoff alignment) has
	 * already been checked by prepare_hugepage_range.  If you add
	 * any error returns here, do so after setting VM_HUGETLB, so
	 * is_vm_hugetlb_page tests below unmap_region go the right
	 * way when do_mmap_pgoff unwinds (may be important on powerpc
	 * and ia64).
	 */
	vma->vm_flags |= VM_HUGETLB | VM_RESERVED;
	vma->vm_ops = &hugetlb_vm_ops;

	if (vma->vm_pgoff & ~(huge_page_mask(h) >> PAGE_SHIFT))
		return -EINVAL;

	vma_len = (loff_t)(vma->vm_end - vma->vm_start);

	mutex_lock(&inode->i_mutex);
	file_accessed(file);

	ret = -ENOMEM;
	len = vma_len + ((loff_t)vma->vm_pgoff << PAGE_SHIFT);

	if (hugetlb_reserve_pages(inode,
				vma->vm_pgoff >> huge_page_order(h),
				len >> huge_page_shift(h), vma,
				vma->vm_flags))
		goto out;

	ret = 0;
	hugetlb_prefault_arch_hook(vma->vm_mm);
	if (vma->vm_flags & VM_WRITE && inode->i_size < len)
		inode->i_size = len;
out:
	mutex_unlock(&inode->i_mutex);

	return ret;
}

/*
 * Called under down_write(mmap_sem).
 */

#ifndef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
static unsigned long
hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
		unsigned long len, unsigned long pgoff, unsigned long flags)
{
	struct mm_struct *mm = current->mm;
	struct vm_area_struct *vma;
	unsigned long start_addr;
	struct hstate *h = hstate_file(file);

	if (len & ~huge_page_mask(h))
		return -EINVAL;
	if (len > TASK_SIZE)
		return -ENOMEM;

	if (flags & MAP_FIXED) {
		if (prepare_hugepage_range(file, addr, len))
			return -EINVAL;
		return addr;
	}

	if (addr) {
		addr = ALIGN(addr, huge_page_size(h));
		vma = find_vma(mm, addr);
		if (TASK_SIZE - len >= addr &&
		    (!vma || addr + len <= vma->vm_start))
			return addr;
	}

	start_addr = mm->free_area_cache;

	if (len <= mm->cached_hole_size)
		start_addr = TASK_UNMAPPED_BASE;

full_search:
	addr = ALIGN(start_addr, huge_page_size(h));

	for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
		/* At this point:  (!vma || addr < vma->vm_end). */
		if (TASK_SIZE - len < addr) {
			/*
			 * Start a new search - just in case we missed
			 * some holes.
			 */
			if (start_addr != TASK_UNMAPPED_BASE) {
				start_addr = TASK_UNMAPPED_BASE;
				goto full_search;
			}
			return -ENOMEM;
		}

		if (!vma || addr + len <= vma->vm_start)
			return addr;
		addr = ALIGN(vma->vm_end, huge_page_size(h));
	}
}
#endif

static int
hugetlbfs_read_actor(struct page *page, unsigned long offset,
			char __user *buf, unsigned long count,
			unsigned long size)
{
	char *kaddr;
	unsigned long left, copied = 0;
	int i, chunksize;

	if (size > count)
		size = count;