@@ -349,12 +349,52 @@ static int ipt_ulog_checkentry(const char *tablename,
349349 return 1 ;
350350}
351351
352+ #ifdef CONFIG_COMPAT
353+ struct compat_ipt_ulog_info {
354+ compat_uint_t nl_group ;
355+ compat_size_t copy_range ;
356+ compat_size_t qthreshold ;
357+ char prefix [ULOG_PREFIX_LEN ];
358+ };
359+
360+ static void compat_from_user (void * dst , void * src )
361+ {
362+ struct compat_ipt_ulog_info * cl = src ;
363+ struct ipt_ulog_info l = {
364+ .nl_group = cl -> nl_group ,
365+ .copy_range = cl -> copy_range ,
366+ .qthreshold = cl -> qthreshold ,
367+ };
368+
369+ memcpy (l .prefix , cl -> prefix , sizeof (l .prefix ));
370+ memcpy (dst , & l , sizeof (l ));
371+ }
372+
373+ static int compat_to_user (void __user * dst , void * src )
374+ {
375+ struct ipt_ulog_info * l = src ;
376+ struct compat_ipt_ulog_info cl = {
377+ .nl_group = l -> nl_group ,
378+ .copy_range = l -> copy_range ,
379+ .qthreshold = l -> qthreshold ,
380+ };
381+
382+ memcpy (cl .prefix , l -> prefix , sizeof (cl .prefix ));
383+ return copy_to_user (dst , & cl , sizeof (cl )) ? - EFAULT : 0 ;
384+ }
385+ #endif /* CONFIG_COMPAT */
386+
352387static struct xt_target ipt_ulog_reg = {
353388 .name = "ULOG" ,
354389 .family = AF_INET ,
355390 .target = ipt_ulog_target ,
356391 .targetsize = sizeof (struct ipt_ulog_info ),
357392 .checkentry = ipt_ulog_checkentry ,
393+ #ifdef CONFIG_COMPAT
394+ .compatsize = sizeof (struct compat_ipt_ulog_info ),
395+ .compat_from_user = compat_from_user ,
396+ .compat_to_user = compat_to_user ,
397+ #endif
358398 .me = THIS_MODULE ,
359399};
360400
0 commit comments