From: Prasanna S Panchamukhi <prasanna@in.ibm.com>
To: linux-kernel@vger.kernel.org, systemtap@sources.redhat.com
Cc: akpm@osdl.org, Andi Kleen <ak@suse.de>,
davem@davemloft.net, suparna@in.ibm.com,
richardj_moore@uk.ibm.com
Subject: Re: [RFC] [PATCH 1/6] Kprobes: Allow/deny exclusive write access to inodes
Date: Tue, 9 May 2006 12:29:17 +0530 [thread overview]
Message-ID: <20060509065917.GA22493@in.ibm.com> (raw)
In-Reply-To: <20060509065455.GA11630@in.ibm.com>
This patch adds two new wrapper routines to namei.c file
to decrement and increment the inode writecount. Other
routine deny_write_access() decrements the inode
writecount for a given file pointer. But there is no
wrapper routine that decrement's the inode writecount
for a given inode pointer. Also there is no routine that
increment's the inode writecount, if it less than zero.
Even the existing deny_write_access() is modified to use
the new wrapper routine. Kprobe's user-space probes uses
these wrapper routines to get and release exclusive
write access to the probed binary.
Signed-off-by: Prasanna S Panchamukhi <prasanna@in.ibm.com>
fs/namei.c | 34 +++++++++++++++++++++++++++++++---
include/linux/namei.h | 2 ++
2 files changed, 33 insertions(+), 3 deletions(-)
diff -puN fs/namei.c~kprobes_userspace_probes-denywrite-to-inode fs/namei.c
--- linux-2.6.17-rc3-mm1/fs/namei.c~kprobes_userspace_probes-denywrite-to-inode 2006-05-09 10:08:38.000000000 +0530
+++ linux-2.6.17-rc3-mm1-prasanna/fs/namei.c 2006-05-09 10:08:39.000000000 +0530
@@ -322,10 +322,13 @@ int get_write_access(struct inode * inod
return 0;
}
-int deny_write_access(struct file * file)
+/* This routine decrements the writecount for a given inode to
+ * get exclusive write access, so that the file on which probes
+ * are currently applied does not change. User-space probes
+ * uses this routine.
+ */
+int deny_write_access_to_inode(struct inode *inode)
{
- struct inode *inode = file->f_dentry->d_inode;
-
spin_lock(&inode->i_lock);
if (atomic_read(&inode->i_writecount) > 0) {
spin_unlock(&inode->i_lock);
@@ -337,6 +340,31 @@ int deny_write_access(struct file * file
return 0;
}
+/* This routine increments the writecount for a given inode.
+ * to release the write lock. User-space probes uses this
+ * routine.
+ */
+int write_access_to_inode(struct inode *inode)
+{
+ spin_lock(&inode->i_lock);
+ if (atomic_read(&inode->i_writecount) >= 0) {
+ spin_unlock(&inode->i_lock);
+ return -ETXTBSY;
+ }
+ atomic_inc(&inode->i_writecount);
+ spin_unlock(&inode->i_lock);
+
+ return 0;
+}
+
+/* Wrapper routine that decrements the writecount for a given file pointer. */
+int deny_write_access(struct file * file)
+{
+ struct inode *inode = file->f_dentry->d_inode;
+
+ return deny_write_access_to_inode(inode);
+}
+
void path_release(struct nameidata *nd)
{
dput(nd->dentry);
diff -puN include/linux/namei.h~kprobes_userspace_probes-denywrite-to-inode include/linux/namei.h
--- linux-2.6.17-rc3-mm1/include/linux/namei.h~kprobes_userspace_probes-denywrite-to-inode 2006-05-09 10:08:38.000000000 +0530
+++ linux-2.6.17-rc3-mm1-prasanna/include/linux/namei.h 2006-05-09 10:08:39.000000000 +0530
@@ -81,6 +81,8 @@ extern int follow_up(struct vfsmount **,
extern struct dentry *lock_rename(struct dentry *, struct dentry *);
extern void unlock_rename(struct dentry *, struct dentry *);
+extern int deny_write_access_to_inode(struct inode *inode);
+extern int write_access_to_inode(struct inode *inode);
static inline void nd_set_link(struct nameidata *nd, char *path)
{
_
--
Prasanna S Panchamukhi
Linux Technology Center
India Software Labs, IBM Bangalore
Email: prasanna@in.ibm.com
Ph: 91-80-41776329
next prev parent reply other threads:[~2006-05-09 6:59 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-09 6:54 [RFC] [PATCH 0/6] Kprobes: User-space probes support for i386 Prasanna S Panchamukhi
2006-05-09 6:59 ` Prasanna S Panchamukhi [this message]
2006-05-09 7:01 ` [RFC] [PATCH 2/6] Kprobes: Get one pagetable entry Prasanna S Panchamukhi
2006-05-09 7:05 ` [RFC] [PATCH 3/6] Kprobes: New interfaces for user-space probes Prasanna S Panchamukhi
2006-05-09 7:09 ` [RFC] [PATCH 4/6] Kprobes: Insert probes on non-memory resident pages Prasanna S Panchamukhi
2006-05-09 7:12 ` [RFC] [PATCH 5/6] Kprobes: Single step the original instruction out-of-line Prasanna S Panchamukhi
2006-05-09 7:15 ` [RFC] [PATCH 6/6] Kprobes: Remove breakpoints from the copied pages Prasanna S Panchamukhi
2006-05-09 17:04 ` Hugh Dickins
2006-05-10 12:17 ` Prasanna S Panchamukhi
2006-05-10 15:17 ` Hugh Dickins
2006-05-09 9:38 ` [RFC] [PATCH 5/6] Kprobes: Single step the original instruction out-of-line Christoph Hellwig
2006-05-10 0:47 ` bibo,mao
2006-05-10 14:19 ` Richard J Moore
2006-05-09 9:37 ` [RFC] [PATCH 4/6] Kprobes: Insert probes on non-memory resident pages Christoph Hellwig
2006-05-09 9:36 ` [RFC] [PATCH 3/6] Kprobes: New interfaces for user-space probes Christoph Hellwig
2006-05-09 15:11 ` Richard J Moore
2006-05-09 15:18 ` Christoph Hellwig
2006-05-09 17:41 ` Frank Ch. Eigler
2006-05-09 20:40 ` Adrian Bunk
2006-05-09 20:58 ` Frank Ch. Eigler
2006-05-09 22:35 ` Christoph Hellwig
2006-05-09 9:34 ` [RFC] [PATCH 2/6] Kprobes: Get one pagetable entry Christoph Hellwig
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=20060509065917.GA22493@in.ibm.com \
--to=prasanna@in.ibm.com \
--cc=ak@suse.de \
--cc=akpm@osdl.org \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=richardj_moore@uk.ibm.com \
--cc=suparna@in.ibm.com \
--cc=systemtap@sources.redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome