-
Notifications
You must be signed in to change notification settings - Fork 336
kpatch-build: Make local static twining stricter #1053
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
This fixes the error on RHEL8.0 test macro-printk: ERROR: fib_semantics.o: object size mismatch: __msg.66237 Mentioned in PR #993 . |
|
Looks good. Would it be possible to create a unit test for this one? |
Sure, I'll do that. |
|
Thanks. We want the unit tests to be as comprehensive as possible. I think some overlap between unit tests and integration tests is ok. |
This is a test for dynup/kpatch#1053. The following patch was used with a RHEL-8.0 kernel: diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c index 446204c..5b73a01 100644 --- a/net/ipv4/fib_semantics.c +++ b/net/ipv4/fib_semantics.c @@ -1025,6 +1025,7 @@ static bool fib_valid_prefsrc(struct fib_config *cfg, __be32 fib_prefsrc) fi->fib_metrics->metrics); } +#include "kpatch-macros.h" struct fib_info *fib_create_info(struct fib_config *cfg, struct netlink_ext_ack *extack) { @@ -1058,6 +1059,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg, #endif err = -ENOBUFS; + KPATCH_PRINTK("[fib_create_info]: create error err is %d\n",err); if (fib_info_cnt >= fib_info_hash_size) { unsigned int new_size = fib_info_hash_size << 1; struct hlist_head *new_info_hash; @@ -1078,6 +1080,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg, if (!fib_info_hash_size) goto failure; } + KPATCH_PRINTK("[fib_create_info]: 2 create error err is %d\n",err); fi = kzalloc(sizeof(*fi)+nhs*sizeof(struct fib_nh), GFP_KERNEL); if (!fi) @@ -1093,6 +1096,8 @@ struct fib_info *fib_create_info(struct fib_config *cfg, fi->fib_metrics = (struct dst_metrics *)&dst_default_metrics; } fib_info_cnt++; + KPATCH_PRINTK("[fib_create_info]: 3 create error err is %d\n",err); + fi->fib_net = net; fi->fib_protocol = cfg->fc_protocol; fi->fib_scope = cfg->fc_scope; @@ -1109,8 +1114,10 @@ struct fib_info *fib_create_info(struct fib_config *cfg, if (!nexthop_nh->nh_pcpu_rth_output) goto failure; } endfor_nexthops(fi) + KPATCH_PRINTK("[fib_create_info]: 4 create error err is %d\n",err); err = fib_convert_metrics(fi, cfg); + KPATCH_PRINTK("[fib_create_info]: 5 create error err is %d\n",err); if (err) goto failure; @@ -1172,6 +1179,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg, nh->nh_weight = 1; #endif } + KPATCH_PRINTK("[fib_create_info]: 6 create error err is %d\n",err); if (fib_props[cfg->fc_type].error) { if (cfg->fc_gw || cfg->fc_oif || cfg->fc_mp) { @@ -1193,6 +1201,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg, goto err_inval; } } + KPATCH_PRINTK("[fib_create_info]: 7 create error err is %d\n",err); if (cfg->fc_scope > RT_SCOPE_HOST) { NL_SET_ERR_MSG(extack, "Invalid scope"); @@ -1231,6 +1240,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg, if (linkdown == fi->fib_nhs) fi->fib_flags |= RTNH_F_LINKDOWN; } + KPATCH_PRINTK("[fib_create_info]: 8 create error err is %d\n",err); if (fi->fib_prefsrc && !fib_valid_prefsrc(cfg, fi->fib_prefsrc)) { NL_SET_ERR_MSG(extack, "Invalid prefsrc address"); @@ -1240,6 +1250,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg, change_nexthops(fi) { fib_info_update_nh_saddr(net, nexthop_nh); } endfor_nexthops(fi) + KPATCH_PRINTK("[fib_create_info]: 9 create error err is %d\n",err); fib_rebalance(fi); @@ -1251,6 +1262,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg, ofi->fib_treeref++; return ofi; } + KPATCH_PRINTK("[fib_create_info]: 10 create error err is %d\n",err); fi->fib_treeref++; refcount_set(&fi->fib_clntref, 1); @@ -1274,6 +1286,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg, hlist_add_head(&nexthop_nh->nh_hash, head); } endfor_nexthops(fi) spin_unlock_bh(&fib_info_lock); + KPATCH_PRINTK("[fib_create_info]: 11 create error err is %d\n",err); return fi; err_inval: @@ -1284,6 +1297,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg, fi->fib_dead = 1; free_fib_info(fi); } + KPATCH_PRINTK("[fib_create_info]: 12 create error err is %d\n",err); return ERR_PTR(err); } Signed-off-by: Julien Thierry <jthierry@redhat.com>
sm00th
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise looks good. I assume this PR will also contain obj-file submodule pointer bump when dynup/kpatch-unit-test-objs#20 is merged.
kpatch-build/create-diff-object.c
Outdated
| if (kpatch_mangled_strcmp(patched_sym->name, sym->name)) | ||
| continue; | ||
|
|
||
| return rela_toc->sym; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might as well return patched_sym here for readability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, I forgot to replace this reference.
Thanks for spotting it.
I'll update this along with the submodule update once dynup/kpatch-unit-test-objs#20 is merged.
The current code to find the twin of a local static variable allows two variables of the same name to be wrongly matched with the other's twin. While there isn't a magic formula to avoid this, make stricter requirements for twining static local from the original object with a symbol from the patched object. This reduces the risk of erroneous matches. Signed-off-by: Julien Thierry <jthierry@redhat.com>
6e6823f to
68530e4
Compare
This is supposedly fixed by dynup#1053 and should be re-enabled when it is merged. Signed-off-by: Artem Savkov <asavkov@redhat.com>
This is supposedly fixed by dynup#1053 and should be re-enabled when it is merged. Signed-off-by: Artem Savkov <asavkov@redhat.com>
This is supposedly fixed by dynup#1053 and should be re-enabled when it is merged. Signed-off-by: Artem Savkov <asavkov@redhat.com>
|
I think all the requested changes were done for this PR and that it's approved. Any thing left before merging it? |
The current code to find the twin of a local static variable allows two
variables of the same name to be wrongly matched with the other's twin.
While there isn't a magic formula to avoid this, make stricter
requirements for twining static local from the original object with
a symbol from the patched object. This reduces the risk of erroneous
matches.
Signed-off-by: Julien Thierry jthierry@redhat.com