@@ -101,8 +101,11 @@ static ssize_t freeze_show(struct gfs2_sbd *sdp, char *buf)
101101
102102static ssize_t freeze_store (struct gfs2_sbd * sdp , const char * buf , size_t len )
103103{
104- int error ;
105- int n = simple_strtol (buf , NULL , 0 );
104+ int error , n ;
105+
106+ error = kstrtoint (buf , 0 , & n );
107+ if (error )
108+ return error ;
106109
107110 if (!capable (CAP_SYS_ADMIN ))
108111 return - EPERM ;
@@ -134,10 +137,16 @@ static ssize_t withdraw_show(struct gfs2_sbd *sdp, char *buf)
134137
135138static ssize_t withdraw_store (struct gfs2_sbd * sdp , const char * buf , size_t len )
136139{
140+ int error , val ;
141+
137142 if (!capable (CAP_SYS_ADMIN ))
138143 return - EPERM ;
139144
140- if (simple_strtol (buf , NULL , 0 ) != 1 )
145+ error = kstrtoint (buf , 0 , & val );
146+ if (error )
147+ return error ;
148+
149+ if (val != 1 )
141150 return - EINVAL ;
142151
143152 gfs2_lm_withdraw (sdp , "withdrawing from cluster at user's request\n" );
@@ -148,10 +157,16 @@ static ssize_t withdraw_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
148157static ssize_t statfs_sync_store (struct gfs2_sbd * sdp , const char * buf ,
149158 size_t len )
150159{
160+ int error , val ;
161+
151162 if (!capable (CAP_SYS_ADMIN ))
152163 return - EPERM ;
153164
154- if (simple_strtol (buf , NULL , 0 ) != 1 )
165+ error = kstrtoint (buf , 0 , & val );
166+ if (error )
167+ return error ;
168+
169+ if (val != 1 )
155170 return - EINVAL ;
156171
157172 gfs2_statfs_sync (sdp -> sd_vfs , 0 );
@@ -161,10 +176,16 @@ static ssize_t statfs_sync_store(struct gfs2_sbd *sdp, const char *buf,
161176static ssize_t quota_sync_store (struct gfs2_sbd * sdp , const char * buf ,
162177 size_t len )
163178{
179+ int error , val ;
180+
164181 if (!capable (CAP_SYS_ADMIN ))
165182 return - EPERM ;
166183
167- if (simple_strtol (buf , NULL , 0 ) != 1 )
184+ error = kstrtoint (buf , 0 , & val );
185+ if (error )
186+ return error ;
187+
188+ if (val != 1 )
168189 return - EINVAL ;
169190
170191 gfs2_quota_sync (sdp -> sd_vfs , 0 );
@@ -181,7 +202,9 @@ static ssize_t quota_refresh_user_store(struct gfs2_sbd *sdp, const char *buf,
181202 if (!capable (CAP_SYS_ADMIN ))
182203 return - EPERM ;
183204
184- id = simple_strtoul (buf , NULL , 0 );
205+ error = kstrtou32 (buf , 0 , & id );
206+ if (error )
207+ return error ;
185208
186209 qid = make_kqid (current_user_ns (), USRQUOTA , id );
187210 if (!qid_valid (qid ))
@@ -201,7 +224,9 @@ static ssize_t quota_refresh_group_store(struct gfs2_sbd *sdp, const char *buf,
201224 if (!capable (CAP_SYS_ADMIN ))
202225 return - EPERM ;
203226
204- id = simple_strtoul (buf , NULL , 0 );
227+ error = kstrtou32 (buf , 0 , & id );
228+ if (error )
229+ return error ;
205230
206231 qid = make_kqid (current_user_ns (), GRPQUOTA , id );
207232 if (!qid_valid (qid ))
@@ -324,10 +349,11 @@ static ssize_t block_show(struct gfs2_sbd *sdp, char *buf)
324349static ssize_t block_store (struct gfs2_sbd * sdp , const char * buf , size_t len )
325350{
326351 struct lm_lockstruct * ls = & sdp -> sd_lockstruct ;
327- ssize_t ret = len ;
328- int val ;
352+ int ret , val ;
329353
330- val = simple_strtol (buf , NULL , 0 );
354+ ret = kstrtoint (buf , 0 , & val );
355+ if (ret )
356+ return ret ;
331357
332358 if (val == 1 )
333359 set_bit (DFL_BLOCK_LOCKS , & ls -> ls_recover_flags );
@@ -336,9 +362,9 @@ static ssize_t block_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
336362 smp_mb__after_atomic ();
337363 gfs2_glock_thaw (sdp );
338364 } else {
339- ret = - EINVAL ;
365+ return - EINVAL ;
340366 }
341- return ret ;
367+ return len ;
342368}
343369
344370static ssize_t wdack_show (struct gfs2_sbd * sdp , char * buf )
@@ -350,17 +376,18 @@ static ssize_t wdack_show(struct gfs2_sbd *sdp, char *buf)
350376
351377static ssize_t wdack_store (struct gfs2_sbd * sdp , const char * buf , size_t len )
352378{
353- ssize_t ret = len ;
354- int val ;
379+ int ret , val ;
355380
356- val = simple_strtol (buf , NULL , 0 );
381+ ret = kstrtoint (buf , 0 , & val );
382+ if (ret )
383+ return ret ;
357384
358385 if ((val == 1 ) &&
359386 !strcmp (sdp -> sd_lockstruct .ls_ops -> lm_proto_name , "lock_dlm" ))
360387 complete (& sdp -> sd_wdack );
361388 else
362- ret = - EINVAL ;
363- return ret ;
389+ return - EINVAL ;
390+ return len ;
364391}
365392
366393static ssize_t lkfirst_show (struct gfs2_sbd * sdp , char * buf )
@@ -553,11 +580,14 @@ static ssize_t tune_set(struct gfs2_sbd *sdp, unsigned int *field,
553580{
554581 struct gfs2_tune * gt = & sdp -> sd_tune ;
555582 unsigned int x ;
583+ int error ;
556584
557585 if (!capable (CAP_SYS_ADMIN ))
558586 return - EPERM ;
559587
560- x = simple_strtoul (buf , NULL , 0 );
588+ error = kstrtouint (buf , 0 , & x );
589+ if (error )
590+ return error ;
561591
562592 if (check_zero && !x )
563593 return - EINVAL ;
0 commit comments