@@ -783,6 +783,11 @@ struct io_task_work {
783
783
task_work_func_t func ;
784
784
};
785
785
786
+ enum {
787
+ IORING_RSRC_FILE = 0 ,
788
+ IORING_RSRC_BUFFER = 1 ,
789
+ };
790
+
786
791
/*
787
792
* NOTE! Each of the iocb union members has the file pointer
788
793
* as the first entry in their struct definition. So you can
@@ -9671,7 +9676,8 @@ static int io_uring_create(unsigned entries, struct io_uring_params *p,
9671
9676
IORING_FEAT_SUBMIT_STABLE | IORING_FEAT_RW_CUR_POS |
9672
9677
IORING_FEAT_CUR_PERSONALITY | IORING_FEAT_FAST_POLL |
9673
9678
IORING_FEAT_POLL_32BITS | IORING_FEAT_SQPOLL_NONFIXED |
9674
- IORING_FEAT_EXT_ARG | IORING_FEAT_NATIVE_WORKERS ;
9679
+ IORING_FEAT_EXT_ARG | IORING_FEAT_NATIVE_WORKERS |
9680
+ IORING_FEAT_RSRC_TAGS ;
9675
9681
9676
9682
if (copy_to_user (params , p , sizeof (* p ))) {
9677
9683
ret = - EFAULT ;
@@ -9911,21 +9917,21 @@ static int io_register_files_update(struct io_ring_ctx *ctx, void __user *arg,
9911
9917
}
9912
9918
9913
9919
static int io_register_rsrc_update (struct io_ring_ctx * ctx , void __user * arg ,
9914
- unsigned size )
9920
+ unsigned size , unsigned type )
9915
9921
{
9916
9922
struct io_uring_rsrc_update2 up ;
9917
9923
9918
9924
if (size != sizeof (up ))
9919
9925
return - EINVAL ;
9920
9926
if (copy_from_user (& up , arg , sizeof (up )))
9921
9927
return - EFAULT ;
9922
- if (!up .nr )
9928
+ if (!up .nr || up . resv )
9923
9929
return - EINVAL ;
9924
- return __io_register_rsrc_update (ctx , up . type , & up , up .nr );
9930
+ return __io_register_rsrc_update (ctx , type , & up , up .nr );
9925
9931
}
9926
9932
9927
9933
static int io_register_rsrc (struct io_ring_ctx * ctx , void __user * arg ,
9928
- unsigned int size )
9934
+ unsigned int size , unsigned int type )
9929
9935
{
9930
9936
struct io_uring_rsrc_register rr ;
9931
9937
@@ -9936,10 +9942,10 @@ static int io_register_rsrc(struct io_ring_ctx *ctx, void __user *arg,
9936
9942
memset (& rr , 0 , sizeof (rr ));
9937
9943
if (copy_from_user (& rr , arg , size ))
9938
9944
return - EFAULT ;
9939
- if (!rr .nr )
9945
+ if (!rr .nr || rr . resv || rr . resv2 )
9940
9946
return - EINVAL ;
9941
9947
9942
- switch (rr . type ) {
9948
+ switch (type ) {
9943
9949
case IORING_RSRC_FILE :
9944
9950
return io_sqe_files_register (ctx , u64_to_user_ptr (rr .data ),
9945
9951
rr .nr , u64_to_user_ptr (rr .tags ));
@@ -9961,8 +9967,10 @@ static bool io_register_op_must_quiesce(int op)
9961
9967
case IORING_REGISTER_PROBE :
9962
9968
case IORING_REGISTER_PERSONALITY :
9963
9969
case IORING_UNREGISTER_PERSONALITY :
9964
- case IORING_REGISTER_RSRC :
9965
- case IORING_REGISTER_RSRC_UPDATE :
9970
+ case IORING_REGISTER_FILES2 :
9971
+ case IORING_REGISTER_FILES_UPDATE2 :
9972
+ case IORING_REGISTER_BUFFERS2 :
9973
+ case IORING_REGISTER_BUFFERS_UPDATE :
9966
9974
return false;
9967
9975
default :
9968
9976
return true;
@@ -10088,11 +10096,19 @@ static int __io_uring_register(struct io_ring_ctx *ctx, unsigned opcode,
10088
10096
case IORING_REGISTER_RESTRICTIONS :
10089
10097
ret = io_register_restrictions (ctx , arg , nr_args );
10090
10098
break ;
10091
- case IORING_REGISTER_RSRC :
10092
- ret = io_register_rsrc (ctx , arg , nr_args );
10099
+ case IORING_REGISTER_FILES2 :
10100
+ ret = io_register_rsrc (ctx , arg , nr_args , IORING_RSRC_FILE );
10101
+ break ;
10102
+ case IORING_REGISTER_FILES_UPDATE2 :
10103
+ ret = io_register_rsrc_update (ctx , arg , nr_args ,
10104
+ IORING_RSRC_FILE );
10105
+ break ;
10106
+ case IORING_REGISTER_BUFFERS2 :
10107
+ ret = io_register_rsrc (ctx , arg , nr_args , IORING_RSRC_BUFFER );
10093
10108
break ;
10094
- case IORING_REGISTER_RSRC_UPDATE :
10095
- ret = io_register_rsrc_update (ctx , arg , nr_args );
10109
+ case IORING_REGISTER_BUFFERS_UPDATE :
10110
+ ret = io_register_rsrc_update (ctx , arg , nr_args ,
10111
+ IORING_RSRC_BUFFER );
10096
10112
break ;
10097
10113
default :
10098
10114
ret = - EINVAL ;
0 commit comments