Skip to content

Question about pointer equality #1437

@iii-i

Description

@iii-i

I've been looking into kpatch on s390x in context of a compiler issue and came up with the following experiment: iii-i/linux@0f400db.

One part of it is a kernel function that returns its own address:

void *patchme(void) { return patchme; }

and we replace it using kpatch:

void *patchme(void) { printk(KERN_NOTICE "patched\n"); return patchme; }

Another part is a sysfs knob to compare patchme with patchme():

	printk(KERN_NOTICE "patchme=0x%lx patchme()=0x%lx\n",
	       (unsigned long)patchme, (unsigned long)patchme());

The output before patching is as expected, the values match:

patchme=0x3ffe0962f78 patchme()=0x3ffe0962f78

After patching the values don't match anymore:

patched
patchme=0x3ffe0962f78 patchme()=0x3ff600a16c8

One may argue, and most likely be correct, that this is an artificially created scenario, which will probably not affect a real workload.

But still I would like to ask: is this an acceptable behavior?
If yes, would it be reasonable to add this to the list of limitations / things to watch out for?
If no, what would be a good way to deal with this? The only thing I can come up with now is to perform all address loads via GOT instead of using relative addressing, but this will probably slow the kernel down quite a bit.

Edit: adding @Andreas-Krebbel and @sumanthkorikkar to the discussion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions