@@ -783,6 +783,11 @@ struct io_task_work {
783783 task_work_func_t func ;
784784};
785785
786+ enum {
787+ IORING_RSRC_FILE = 0 ,
788+ IORING_RSRC_BUFFER = 1 ,
789+ };
790+
786791/*
787792 * NOTE! Each of the iocb union members has the file pointer
788793 * 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,
96719676 IORING_FEAT_SUBMIT_STABLE | IORING_FEAT_RW_CUR_POS |
96729677 IORING_FEAT_CUR_PERSONALITY | IORING_FEAT_FAST_POLL |
96739678 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 ;
96759681
96769682 if (copy_to_user (params , p , sizeof (* p ))) {
96779683 ret = - EFAULT ;
@@ -9911,21 +9917,21 @@ static int io_register_files_update(struct io_ring_ctx *ctx, void __user *arg,
99119917}
99129918
99139919static int io_register_rsrc_update (struct io_ring_ctx * ctx , void __user * arg ,
9914- unsigned size )
9920+ unsigned size , unsigned type )
99159921{
99169922 struct io_uring_rsrc_update2 up ;
99179923
99189924 if (size != sizeof (up ))
99199925 return - EINVAL ;
99209926 if (copy_from_user (& up , arg , sizeof (up )))
99219927 return - EFAULT ;
9922- if (!up .nr )
9928+ if (!up .nr || up . resv )
99239929 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 );
99259931}
99269932
99279933static int io_register_rsrc (struct io_ring_ctx * ctx , void __user * arg ,
9928- unsigned int size )
9934+ unsigned int size , unsigned int type )
99299935{
99309936 struct io_uring_rsrc_register rr ;
99319937
@@ -9936,10 +9942,10 @@ static int io_register_rsrc(struct io_ring_ctx *ctx, void __user *arg,
99369942 memset (& rr , 0 , sizeof (rr ));
99379943 if (copy_from_user (& rr , arg , size ))
99389944 return - EFAULT ;
9939- if (!rr .nr )
9945+ if (!rr .nr || rr . resv || rr . resv2 )
99409946 return - EINVAL ;
99419947
9942- switch (rr . type ) {
9948+ switch (type ) {
99439949 case IORING_RSRC_FILE :
99449950 return io_sqe_files_register (ctx , u64_to_user_ptr (rr .data ),
99459951 rr .nr , u64_to_user_ptr (rr .tags ));
@@ -9961,8 +9967,10 @@ static bool io_register_op_must_quiesce(int op)
99619967 case IORING_REGISTER_PROBE :
99629968 case IORING_REGISTER_PERSONALITY :
99639969 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 :
99669974 return false;
99679975 default :
99689976 return true;
@@ -10088,11 +10096,19 @@ static int __io_uring_register(struct io_ring_ctx *ctx, unsigned opcode,
1008810096 case IORING_REGISTER_RESTRICTIONS :
1008910097 ret = io_register_restrictions (ctx , arg , nr_args );
1009010098 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 );
1009310108 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 );
1009610112 break ;
1009710113 default :
1009810114 ret = - EINVAL ;
0 commit comments