On morello architecture, use of kernel pointers in the uapi structures is not permitted, due to different alignment requirements. Modify these to be unsigned longs.
Signed-off-by: Joshua Lant joshualant@gmail.com --- include/uapi/linux/netfilter/xt_IDLETIMER.h | 6 +- net/netfilter/xt_IDLETIMER.c | 132 ++++++++++---------- 2 files changed, 70 insertions(+), 68 deletions(-)
diff --git a/include/uapi/linux/netfilter/xt_IDLETIMER.h b/include/uapi/linux/netfilter/xt_IDLETIMER.h index 7bfb31a66fc9..eef4aa6c6649 100644 --- a/include/uapi/linux/netfilter/xt_IDLETIMER.h +++ b/include/uapi/linux/netfilter/xt_IDLETIMER.h @@ -25,7 +25,8 @@ struct idletimer_tg_info { char label[MAX_IDLETIMER_LABEL_SIZE];
/* for kernel module internal use only */ - struct idletimer_tg *timer __attribute__((aligned(8))); + /* corresponds to the idletimer_tg struct */ + unsigned long timer __attribute__((aligned(8))); };
struct idletimer_tg_info_v1 { @@ -37,6 +38,7 @@ struct idletimer_tg_info_v1 { __u8 timer_type;
/* for kernel module internal use only */ - struct idletimer_tg *timer __attribute__((aligned(8))); + /* corresponds to the idletimer_tg struct */ + unsigned long timer __attribute__((aligned(8))); }; #endif diff --git a/net/netfilter/xt_IDLETIMER.c b/net/netfilter/xt_IDLETIMER.c index db720efa811d..70d48e1d58e8 100644 --- a/net/netfilter/xt_IDLETIMER.c +++ b/net/netfilter/xt_IDLETIMER.c @@ -137,7 +137,7 @@ static int idletimer_tg_create(struct idletimer_tg_info *info) { int ret;
- info->timer = kzalloc(sizeof(*info->timer), GFP_KERNEL); + info->timer = (unsigned long) kzalloc(sizeof(struct idletimer_tg), GFP_KERNEL); if (!info->timer) { ret = -ENOMEM; goto out; @@ -148,36 +148,36 @@ static int idletimer_tg_create(struct idletimer_tg_info *info) goto out_free_timer;
sysfs_attr_init(&info->timer->attr.attr); - info->timer->attr.attr.name = kstrdup(info->label, GFP_KERNEL); - if (!info->timer->attr.attr.name) { + ((struct idletimer_tg *)info->timer)->attr.attr.name = kstrdup(info->label, GFP_KERNEL); + if (!((struct idletimer_tg *)info->timer)->attr.attr.name) { ret = -ENOMEM; goto out_free_timer; } - info->timer->attr.attr.mode = 0444; - info->timer->attr.show = idletimer_tg_show; + ((struct idletimer_tg *)info->timer)->attr.attr.mode = 0444; + ((struct idletimer_tg *)info->timer)->attr.show = idletimer_tg_show;
- ret = sysfs_create_file(idletimer_tg_kobj, &info->timer->attr.attr); + ret = sysfs_create_file(idletimer_tg_kobj, &((struct idletimer_tg *)info->timer)->attr.attr); if (ret < 0) { pr_debug("couldn't add file to sysfs"); goto out_free_attr; }
- list_add(&info->timer->entry, &idletimer_tg_list); + list_add(&((struct idletimer_tg *)info->timer)->entry, &idletimer_tg_list);
- timer_setup(&info->timer->timer, idletimer_tg_expired, 0); - info->timer->refcnt = 1; + timer_setup(&((struct idletimer_tg *)info->timer)->timer, idletimer_tg_expired, 0); + ((struct idletimer_tg *)info->timer)->refcnt = 1;
- INIT_WORK(&info->timer->work, idletimer_tg_work); + INIT_WORK(&((struct idletimer_tg *)info->timer)->work, idletimer_tg_work);
- mod_timer(&info->timer->timer, + mod_timer(&((struct idletimer_tg *)info->timer)->timer, msecs_to_jiffies(info->timeout * 1000) + jiffies);
return 0;
out_free_attr: - kfree(info->timer->attr.attr.name); + kfree(((struct idletimer_tg *)info->timer)->attr.attr.name); out_free_timer: - kfree(info->timer); + kfree(((struct idletimer_tg *)info->timer)); out: return ret; } @@ -186,7 +186,7 @@ static int idletimer_tg_create_v1(struct idletimer_tg_info_v1 *info) { int ret;
- info->timer = kmalloc(sizeof(*info->timer), GFP_KERNEL); + info->timer = (unsigned long) kmalloc(sizeof(struct idletimer_tg), GFP_KERNEL); if (!info->timer) { ret = -ENOMEM; goto out; @@ -196,16 +196,16 @@ static int idletimer_tg_create_v1(struct idletimer_tg_info_v1 *info) if (ret < 0) goto out_free_timer;
- sysfs_attr_init(&info->timer->attr.attr); - info->timer->attr.attr.name = kstrdup(info->label, GFP_KERNEL); - if (!info->timer->attr.attr.name) { + sysfs_attr_init(&((struct idletimer_tg *)info->timer)->attr.attr); + ((struct idletimer_tg *)info->timer)->attr.attr.name = kstrdup(info->label, GFP_KERNEL); + if (!((struct idletimer_tg *)info->timer)->attr.attr.name) { ret = -ENOMEM; goto out_free_timer; } - info->timer->attr.attr.mode = 0444; - info->timer->attr.show = idletimer_tg_show; + ((struct idletimer_tg *)info->timer)->attr.attr.mode = 0444; + ((struct idletimer_tg *)info->timer)->attr.show = idletimer_tg_show;
- ret = sysfs_create_file(idletimer_tg_kobj, &info->timer->attr.attr); + ret = sysfs_create_file(idletimer_tg_kobj, &((struct idletimer_tg *)info->timer)->attr.attr); if (ret < 0) { pr_debug("couldn't add file to sysfs"); goto out_free_attr; @@ -214,32 +214,32 @@ static int idletimer_tg_create_v1(struct idletimer_tg_info_v1 *info) /* notify userspace */ kobject_uevent(idletimer_tg_kobj,KOBJ_ADD);
- list_add(&info->timer->entry, &idletimer_tg_list); + list_add(&((struct idletimer_tg *)info->timer)->entry, &idletimer_tg_list); pr_debug("timer type value is %u", info->timer_type); - info->timer->timer_type = info->timer_type; - info->timer->refcnt = 1; + ((struct idletimer_tg *)info->timer)->timer_type = info->timer_type; + ((struct idletimer_tg *)info->timer)->refcnt = 1;
- INIT_WORK(&info->timer->work, idletimer_tg_work); + INIT_WORK(&((struct idletimer_tg *)info->timer)->work, idletimer_tg_work);
- if (info->timer->timer_type & XT_IDLETIMER_ALARM) { + if (((struct idletimer_tg *)info->timer)->timer_type & XT_IDLETIMER_ALARM) { ktime_t tout; - alarm_init(&info->timer->alarm, ALARM_BOOTTIME, + alarm_init(&((struct idletimer_tg *)info->timer)->alarm, ALARM_BOOTTIME, idletimer_tg_alarmproc); - info->timer->alarm.data = info->timer; + ((struct idletimer_tg *)info->timer)->alarm.data = ((struct idletimer_tg *)info->timer); tout = ktime_set(info->timeout, 0); - alarm_start_relative(&info->timer->alarm, tout); + alarm_start_relative(&((struct idletimer_tg *)info->timer)->alarm, tout); } else { - timer_setup(&info->timer->timer, idletimer_tg_expired, 0); - mod_timer(&info->timer->timer, + timer_setup(&((struct idletimer_tg *)info->timer)->timer, idletimer_tg_expired, 0); + mod_timer(&((struct idletimer_tg *)info->timer)->timer, msecs_to_jiffies(info->timeout * 1000) + jiffies); }
return 0;
out_free_attr: - kfree(info->timer->attr.attr.name); + kfree(((struct idletimer_tg *)info->timer)->attr.attr.name); out_free_timer: - kfree(info->timer); + kfree(((struct idletimer_tg *)info->timer)); out: return ret; } @@ -255,7 +255,7 @@ static unsigned int idletimer_tg_target(struct sk_buff *skb, pr_debug("resetting timer %s, timeout period %u\n", info->label, info->timeout);
- mod_timer(&info->timer->timer, + mod_timer(&((struct idletimer_tg *)info->timer)->timer, msecs_to_jiffies(info->timeout * 1000) + jiffies);
return XT_CONTINUE; @@ -272,11 +272,11 @@ static unsigned int idletimer_tg_target_v1(struct sk_buff *skb, pr_debug("resetting timer %s, timeout period %u\n", info->label, info->timeout);
- if (info->timer->timer_type & XT_IDLETIMER_ALARM) { + if (((struct idletimer_tg *)info->timer)->timer_type & XT_IDLETIMER_ALARM) { ktime_t tout = ktime_set(info->timeout, 0); - alarm_start_relative(&info->timer->alarm, tout); + alarm_start_relative(&((struct idletimer_tg *)info->timer)->alarm, tout); } else { - mod_timer(&info->timer->timer, + mod_timer(&((struct idletimer_tg *)info->timer)->timer, msecs_to_jiffies(info->timeout * 1000) + jiffies); }
@@ -318,14 +318,14 @@ static int idletimer_tg_checkentry(const struct xt_tgchk_param *par) } mutex_lock(&list_mutex);
- info->timer = __idletimer_tg_find_by_label(info->label); - if (info->timer) { - info->timer->refcnt++; - mod_timer(&info->timer->timer, + info->timer = (unsigned long) __idletimer_tg_find_by_label(info->label); + if (((struct idletimer_tg *)info->timer)) { + ((struct idletimer_tg *)info->timer)->refcnt++; + mod_timer(&((struct idletimer_tg *)info->timer)->timer, msecs_to_jiffies(info->timeout * 1000) + jiffies);
pr_debug("increased refcnt of timer %s to %u\n", - info->label, info->timer->refcnt); + info->label, ((struct idletimer_tg *)info->timer)->refcnt); } else { ret = idletimer_tg_create(info); if (ret < 0) { @@ -363,31 +363,31 @@ static int idletimer_tg_checkentry_v1(const struct xt_tgchk_param *par)
mutex_lock(&list_mutex);
- info->timer = __idletimer_tg_find_by_label(info->label); + info->timer = (unsigned long) __idletimer_tg_find_by_label(info->label); if (info->timer) { - if (info->timer->timer_type != info->timer_type) { + if (((struct idletimer_tg *)info->timer)->timer_type != info->timer_type) { pr_debug("Adding/Replacing rule with same label and different timer type is not allowed\n"); mutex_unlock(&list_mutex); return -EINVAL; }
- info->timer->refcnt++; + ((struct idletimer_tg *)info->timer)->refcnt++; if (info->timer_type & XT_IDLETIMER_ALARM) { /* calculate remaining expiry time */ - ktime_t tout = alarm_expires_remaining(&info->timer->alarm); + ktime_t tout = alarm_expires_remaining(&((struct idletimer_tg *)info->timer)->alarm); struct timespec64 ktimespec = ktime_to_timespec64(tout);
if (ktimespec.tv_sec > 0) { pr_debug("time_expiry_remaining %lld\n", ktimespec.tv_sec); - alarm_start_relative(&info->timer->alarm, tout); + alarm_start_relative(&((struct idletimer_tg *)info->timer)->alarm, tout); } } else { - mod_timer(&info->timer->timer, + mod_timer(&((struct idletimer_tg *)info->timer)->timer, msecs_to_jiffies(info->timeout * 1000) + jiffies); } pr_debug("increased refcnt of timer %s to %u\n", - info->label, info->timer->refcnt); + info->label, ((struct idletimer_tg *)info->timer)->refcnt); } else { ret = idletimer_tg_create_v1(info); if (ret < 0) { @@ -409,18 +409,18 @@ static void idletimer_tg_destroy(const struct xt_tgdtor_param *par)
mutex_lock(&list_mutex);
- if (--info->timer->refcnt == 0) { + if (--((struct idletimer_tg *)info->timer)->refcnt == 0) { pr_debug("deleting timer %s\n", info->label);
- list_del(&info->timer->entry); - timer_shutdown_sync(&info->timer->timer); - cancel_work_sync(&info->timer->work); - sysfs_remove_file(idletimer_tg_kobj, &info->timer->attr.attr); - kfree(info->timer->attr.attr.name); - kfree(info->timer); + list_del(&((struct idletimer_tg *)info->timer)->entry); + timer_shutdown_sync(&((struct idletimer_tg *)info->timer)->timer); + cancel_work_sync(&((struct idletimer_tg *)info->timer)->work); + sysfs_remove_file(idletimer_tg_kobj, &((struct idletimer_tg *)info->timer)->attr.attr); + kfree(((struct idletimer_tg *)info->timer)->attr.attr.name); + kfree(((struct idletimer_tg *)info->timer)); } else { pr_debug("decreased refcnt of timer %s to %u\n", - info->label, info->timer->refcnt); + info->label, ((struct idletimer_tg *)info->timer)->refcnt); }
mutex_unlock(&list_mutex); @@ -434,22 +434,22 @@ static void idletimer_tg_destroy_v1(const struct xt_tgdtor_param *par)
mutex_lock(&list_mutex);
- if (--info->timer->refcnt == 0) { + if (--((struct idletimer_tg *)info->timer)->refcnt == 0) { pr_debug("deleting timer %s\n", info->label);
- list_del(&info->timer->entry); - if (info->timer->timer_type & XT_IDLETIMER_ALARM) { - alarm_cancel(&info->timer->alarm); + list_del(&((struct idletimer_tg *)info->timer)->entry); + if (((struct idletimer_tg *)info->timer)->timer_type & XT_IDLETIMER_ALARM) { + alarm_cancel(&((struct idletimer_tg *)info->timer)->alarm); } else { - timer_shutdown_sync(&info->timer->timer); + timer_shutdown_sync(&((struct idletimer_tg *)info->timer)->timer); } - cancel_work_sync(&info->timer->work); - sysfs_remove_file(idletimer_tg_kobj, &info->timer->attr.attr); - kfree(info->timer->attr.attr.name); - kfree(info->timer); + cancel_work_sync(&((struct idletimer_tg *)info->timer)->work); + sysfs_remove_file(idletimer_tg_kobj, &((struct idletimer_tg *)info->timer)->attr.attr); + kfree(((struct idletimer_tg *)info->timer)->attr.attr.name); + kfree(((struct idletimer_tg *)info->timer)); } else { pr_debug("decreased refcnt of timer %s to %u\n", - info->label, info->timer->refcnt); + info->label, ((struct idletimer_tg *)info->timer)->refcnt); }
mutex_unlock(&list_mutex);