Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1280982

Re: [PATCH] livepatch: fix race between enabled_store() and klp_unregister_patch()

From Josh Poimboeuf <jpoimboe@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH] livepatch: fix race between enabled_store() and klp_unregister_patch()
Date 2015-12-01 17:00 +0100
Message-ID <qAVvs-38i-19@gated-at.bofh.it> (permalink)
References <qAnN7-6GB-9@gated-at.bofh.it> <qAHLQ-2RM-9@gated-at.bofh.it> <qAOX0-7lw-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue, Dec 01, 2015 at 09:50:23AM +0100, Jiri Slaby wrote:
> On 12/01/2015, 02:11 AM, Josh Poimboeuf wrote:
> > When I try to recreate something similar by putting a delay in
> > enabled_store(), klp_free_patch() just sleeps on its call to
> > kobject_put() until enabled_store() returns.  The unregister stack looks
> > like:
> > 
> >   [<ffffffff812e966b>] __kernfs_remove+0x1fb/0x380
> >   [<ffffffff812ea273>] kernfs_remove+0x23/0x40
> >   [<ffffffff812ec601>] sysfs_remove_dir+0x51/0x80
> >   [<ffffffff81407fb8>] kobject_del+0x18/0x50
> >   [<ffffffff8140804a>] kobject_release+0x5a/0x190
> >   [<ffffffff81407f27>] kobject_put+0x27/0x50
> 
> What about _put outside of klp_mutex in klp_unregister_patch (and maybe
> the other _put's as well)? Plus Li Bin's patch.

This approach sounds the best to me.  I think all _put's for the patch
kobj need to be outside the mutex.  There's also a _put for the patch
kobj in the klp_init_patch() error path which needs to be moved out.

I think the rest of the _put's (for object and func kobjs) are fine as
they are, because they don't have corresponding sysfs functions which
get the mutex.

-- 
Josh
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: [PATCH] livepatch: fix race between enabled_store() and  klp_unregister_patch() Josh Poimboeuf <jpoimboe@redhat.com> - 2015-12-01 02:20 +0100
  Re: [PATCH] livepatch: fix race between enabled_store() and  klp_unregister_patch() libin <huawei.libin@huawei.com> - 2015-12-01 03:50 +0100
  Re: [PATCH] livepatch: fix race between enabled_store() and  klp_unregister_patch() Jiri Slaby <jslaby@suse.cz> - 2015-12-01 10:00 +0100
    Re: [PATCH] livepatch: fix race between enabled_store() and  klp_unregister_patch() Petr Mladek <pmladek@suse.com> - 2015-12-01 15:20 +0100
      Re: [PATCH] livepatch: fix race between enabled_store() and  klp_unregister_patch() Jiri Slaby <jslaby@suse.cz> - 2015-12-01 15:30 +0100
        Re: [PATCH] livepatch: fix race between enabled_store() and  klp_unregister_patch() Petr Mladek <pmladek@suse.com> - 2015-12-01 18:00 +0100
    Re: [PATCH] livepatch: fix race between enabled_store() and  klp_unregister_patch() Josh Poimboeuf <jpoimboe@redhat.com> - 2015-12-01 17:00 +0100

csiph-web