From: Andries.Brouwer@cwi.nl
To: drepper@redhat.com, linux-kernel@vger.kernel.org
Cc: akpm@digeo.com, torvalds@transmeta.com
Subject: [PATCH] readlink in /proc w/ overlong path
Date: Sun, 30 Mar 2003 14:43:41 +0200 (MEST) [thread overview]
Message-ID: <UTC200303301243.h2UChfg10861.aeb@smtp.cwi.nl> (raw)
> Trying to read the overlong target of a /proc/*/fd/N file descriptor
> leads with the current BK kernel to a segfault in the kernel.
Yes. Below a patch.
Andries
diff -u --recursive --new-file -X /linux/dontdiff a/fs/proc/base.c b/fs/proc/base.c
--- a/fs/proc/base.c Sun Feb 23 22:47:55 2003
+++ b/fs/proc/base.c Sun Mar 30 14:32:35 2003
@@ -565,10 +565,10 @@
}
static int do_proc_readlink(struct dentry *dentry, struct vfsmount *mnt,
- char * buffer, int buflen)
+ char *buffer, int buflen)
{
struct inode * inode;
- char * tmp = (char*)__get_free_page(GFP_KERNEL), *path;
+ char *tmp = (char*)__get_free_page(GFP_KERNEL), *path;
int len;
if (!tmp)
@@ -576,13 +576,17 @@
inode = dentry->d_inode;
path = d_path(dentry, mnt, tmp, PAGE_SIZE);
+ len = PTR_ERR(path);
+ if (IS_ERR(path))
+ goto out;
len = tmp + PAGE_SIZE - 1 - path;
- if (len < buflen)
- buflen = len;
- copy_to_user(buffer, path, buflen);
+ if (len > buflen)
+ len = buflen;
+ copy_to_user(buffer, path, len);
+ out:
free_page((unsigned long)tmp);
- return buflen;
+ return len;
}
static int proc_pid_readlink(struct dentry * dentry, char * buffer, int buflen)
reply other threads:[~2003-03-30 12:32 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=UTC200303301243.h2UChfg10861.aeb@smtp.cwi.nl \
--to=andries.brouwer@cwi.nl \
--cc=akpm@digeo.com \
--cc=drepper@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.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
all inboxes | Powered by JetHome®