linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Driver-Core: devtmpfs - reset inode permissions before unlinking
@ 2010-01-13 13:16 Kay Sievers
  2010-01-14  3:49 ` Greg KH
  2010-01-14 20:53 ` Henrique de Moraes Holschuh
  0 siblings, 2 replies; 11+ messages in thread
From: Kay Sievers @ 2010-01-13 13:16 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel

From: Kay Sievers <kay.sievers@vrfy.org>
Subject: Driver-Core: devtmpfs - reset inode permissions before unlinking

Before unlinking the inode, reset the current permissions of possible
references like hardlinks, so granted permissions can not be retained
across the device lifetime by creating hardlinks, in the unusual case
that there is a user-writable directory on the same filesystem.

Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
---
 drivers/base/devtmpfs.c |   13 +++++++++++++
 1 file changed, 13 insertions(+)

--- a/drivers/base/devtmpfs.c
+++ b/drivers/base/devtmpfs.c
@@ -301,6 +301,19 @@ int devtmpfs_delete_node(struct device *
 		if (dentry->d_inode) {
 			err = vfs_getattr(nd.path.mnt, dentry, &stat);
 			if (!err && dev_mynode(dev, dentry->d_inode, &stat)) {
+				struct iattr newattrs;
+				/*
+				 * before unlinking this node, reset permissions
+				 * of possible references like hardlinks
+				 */
+				newattrs.ia_uid = 0;
+				newattrs.ia_gid = 0;
+				newattrs.ia_mode = stat.mode & ~0777;
+				newattrs.ia_valid =
+					ATTR_UID|ATTR_GID|ATTR_MODE;
+				mutex_lock(&dentry->d_inode->i_mutex);
+				notify_change(dentry, &newattrs);
+				mutex_unlock(&dentry->d_inode->i_mutex);
 				err = vfs_unlink(nd.path.dentry->d_inode,
 						 dentry);
 				if (!err || err == -ENOENT)



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2010-01-17  3:33 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-13 13:16 Driver-Core: devtmpfs - reset inode permissions before unlinking Kay Sievers
2010-01-14  3:49 ` Greg KH
2010-01-14  5:11   ` Kay Sievers
2010-01-14 20:53 ` Henrique de Moraes Holschuh
2010-01-14 20:59   ` Kay Sievers
2010-01-14 21:07     ` Henrique de Moraes Holschuh
2010-01-14 21:45       ` Kay Sievers
2010-01-16  2:26         ` Henrique de Moraes Holschuh
2010-01-16  3:31           ` Greg KH
2010-01-17  3:33             ` Henrique de Moraes Holschuh
2010-01-14 21:00   ` Henrique de Moraes Holschuh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).