@@ -87,10 +87,6 @@ static struct ctl_table user_table[] = {
8787 UCOUNT_ENTRY ("max_fanotify_groups" ),
8888 UCOUNT_ENTRY ("max_fanotify_marks" ),
8989#endif
90- { },
91- { },
92- { },
93- { },
9490 { }
9591};
9692#endif /* CONFIG_SYSCTL */
@@ -263,29 +259,29 @@ void dec_ucount(struct ucounts *ucounts, enum ucount_type type)
263259 put_ucounts (ucounts );
264260}
265261
266- long inc_rlimit_ucounts (struct ucounts * ucounts , enum ucount_type type , long v )
262+ long inc_rlimit_ucounts (struct ucounts * ucounts , enum rlimit_type type , long v )
267263{
268264 struct ucounts * iter ;
269265 long max = LONG_MAX ;
270266 long ret = 0 ;
271267
272268 for (iter = ucounts ; iter ; iter = iter -> ns -> ucounts ) {
273- long new = atomic_long_add_return (v , & iter -> ucount [type ]);
269+ long new = atomic_long_add_return (v , & iter -> rlimit [type ]);
274270 if (new < 0 || new > max )
275271 ret = LONG_MAX ;
276272 else if (iter == ucounts )
277273 ret = new ;
278- max = READ_ONCE (iter -> ns -> ucount_max [ type ] );
274+ max = get_userns_rlimit_max (iter -> ns , type );
279275 }
280276 return ret ;
281277}
282278
283- bool dec_rlimit_ucounts (struct ucounts * ucounts , enum ucount_type type , long v )
279+ bool dec_rlimit_ucounts (struct ucounts * ucounts , enum rlimit_type type , long v )
284280{
285281 struct ucounts * iter ;
286282 long new = -1 ; /* Silence compiler warning */
287283 for (iter = ucounts ; iter ; iter = iter -> ns -> ucounts ) {
288- long dec = atomic_long_sub_return (v , & iter -> ucount [type ]);
284+ long dec = atomic_long_sub_return (v , & iter -> rlimit [type ]);
289285 WARN_ON_ONCE (dec < 0 );
290286 if (iter == ucounts )
291287 new = dec ;
@@ -294,37 +290,37 @@ bool dec_rlimit_ucounts(struct ucounts *ucounts, enum ucount_type type, long v)
294290}
295291
296292static void do_dec_rlimit_put_ucounts (struct ucounts * ucounts ,
297- struct ucounts * last , enum ucount_type type )
293+ struct ucounts * last , enum rlimit_type type )
298294{
299295 struct ucounts * iter , * next ;
300296 for (iter = ucounts ; iter != last ; iter = next ) {
301- long dec = atomic_long_sub_return (1 , & iter -> ucount [type ]);
297+ long dec = atomic_long_sub_return (1 , & iter -> rlimit [type ]);
302298 WARN_ON_ONCE (dec < 0 );
303299 next = iter -> ns -> ucounts ;
304300 if (dec == 0 )
305301 put_ucounts (iter );
306302 }
307303}
308304
309- void dec_rlimit_put_ucounts (struct ucounts * ucounts , enum ucount_type type )
305+ void dec_rlimit_put_ucounts (struct ucounts * ucounts , enum rlimit_type type )
310306{
311307 do_dec_rlimit_put_ucounts (ucounts , NULL , type );
312308}
313309
314- long inc_rlimit_get_ucounts (struct ucounts * ucounts , enum ucount_type type )
310+ long inc_rlimit_get_ucounts (struct ucounts * ucounts , enum rlimit_type type )
315311{
316312 /* Caller must hold a reference to ucounts */
317313 struct ucounts * iter ;
318314 long max = LONG_MAX ;
319315 long dec , ret = 0 ;
320316
321317 for (iter = ucounts ; iter ; iter = iter -> ns -> ucounts ) {
322- long new = atomic_long_add_return (1 , & iter -> ucount [type ]);
318+ long new = atomic_long_add_return (1 , & iter -> rlimit [type ]);
323319 if (new < 0 || new > max )
324320 goto unwind ;
325321 if (iter == ucounts )
326322 ret = new ;
327- max = READ_ONCE (iter -> ns -> ucount_max [ type ] );
323+ max = get_userns_rlimit_max (iter -> ns , type );
328324 /*
329325 * Grab an extra ucount reference for the caller when
330326 * the rlimit count was previously 0.
@@ -336,24 +332,24 @@ long inc_rlimit_get_ucounts(struct ucounts *ucounts, enum ucount_type type)
336332 }
337333 return ret ;
338334dec_unwind :
339- dec = atomic_long_sub_return (1 , & iter -> ucount [type ]);
335+ dec = atomic_long_sub_return (1 , & iter -> rlimit [type ]);
340336 WARN_ON_ONCE (dec < 0 );
341337unwind :
342338 do_dec_rlimit_put_ucounts (ucounts , iter , type );
343339 return 0 ;
344340}
345341
346- bool is_ucounts_overlimit (struct ucounts * ucounts , enum ucount_type type , unsigned long rlimit )
342+ bool is_rlimit_overlimit (struct ucounts * ucounts , enum rlimit_type type , unsigned long rlimit )
347343{
348344 struct ucounts * iter ;
349345 long max = rlimit ;
350346 if (rlimit > LONG_MAX )
351347 max = LONG_MAX ;
352348 for (iter = ucounts ; iter ; iter = iter -> ns -> ucounts ) {
353- long val = get_ucounts_value (iter , type );
349+ long val = get_rlimit_value (iter , type );
354350 if (val < 0 || val > max )
355351 return true;
356- max = READ_ONCE (iter -> ns -> ucount_max [ type ] );
352+ max = get_userns_rlimit_max (iter -> ns , type );
357353 }
358354 return false;
359355}
0 commit comments