All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Tejun Heo <tj@kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>
Cc: ebiederm@xmission.com, linux-kernel@vger.kernel.org
Subject: [PATCH] sysfs: move assignment to be under lock in sysfs_remove_dir()
Date: Tue, 29 Oct 2013 15:09:39 -0700	[thread overview]
Message-ID: <20131029220939.GA23060@kroah.com> (raw)

From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Linus noticed that the assignment of sd isn't protected by the lock in
sysfs_remove_dir(), so move the assignment of the variable under the
lock to be safe.

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---

Tejun, any objection to this patch?  You consolidated the locks back in
2007 on this function, and nothing has changed there since then, so odds
are it's not a problem, but nice to be safe, right?

 fs/sysfs/dir.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index eab59de4..2609f934 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -856,9 +856,10 @@ void sysfs_remove(struct sysfs_dirent *sd)
  */
 void sysfs_remove_dir(struct kobject *kobj)
 {
-	struct sysfs_dirent *sd = kobj->sd;
+	struct sysfs_dirent *sd;
 
 	spin_lock(&sysfs_assoc_lock);
+	sd = kobj->sd;
 	kobj->sd = NULL;
 	spin_unlock(&sysfs_assoc_lock);
 

             reply	other threads:[~2013-10-29 22:09 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-29 22:09 Greg KH [this message]
2013-10-30  0:39 ` [PATCH] sysfs: move assignment to be under lock in sysfs_remove_dir() Eric W. Biederman
2013-10-30  1:25   ` Linus Torvalds
2013-10-30  5:29     ` Eric W. Biederman
2013-10-30 13:28       ` Tejun Heo
2013-10-30 14:28         ` [PATCH driver-core-next] sysfs: rename sysfs_assoc_lock and explain what it's about Tejun Heo
2013-10-30 22:29           ` Eric W. Biederman
2013-10-31 17:11             ` Tejun Heo
2013-10-30 21:41         ` [PATCH] sysfs: move assignment to be under lock in sysfs_remove_dir() Eric W. Biederman
2013-10-30 22:00           ` Tejun Heo
2013-10-30 22:38           ` Greg KH
2013-10-30 13:14 ` Tejun Heo
2013-10-30 21:42 ` Eric W. Biederman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131029220939.GA23060@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=ebiederm@xmission.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.