linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stefani Seibold <stefani@seibold.net>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>
Subject: Re: [PATCH] Fix proc_file_write missing ppos update
Date: Fri, 07 Aug 2009 23:43:07 +0200	[thread overview]
Message-ID: <1249681387.17422.10.camel@wall-e> (raw)
In-Reply-To: <20090807135806.ffd068e9.akpm@linux-foundation.org>

Am Freitag, den 07.08.2009, 13:58 -0700 schrieb Andrew Morton: 
> On Fri, 07 Aug 2009 22:27:10 +0200
> Stefani Seibold <stefani@seibold.net> wrote:
> 
> > The following fix a long standing issue in the proc_file_write function,
> > which doesn't update the ppos file position pointer.
> > 
> > This prevent the usage of multiple sequently writes on an opened proc
> > file, because it is impossible to distinguish these due the offset is
> > always 0.
> > 
> > Signed-off-by: Stefani Seibold <stefani@seibold.net>
> > 
> >  generic.c |    3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > --- linux-2.6.31-rc4.orig/fs/proc/generic.c	2009-08-07 22:05:57.000000000 +0200
> > +++ linux-2.6.30-rc4/fs/proc/generic.c	2009-08-07 22:06:22.000000000 +0200
> > @@ -219,9 +219,10 @@
> >  		pde->pde_users++;
> >  		spin_unlock(&pde->pde_unload_lock);
> >  
> > -		/* FIXME: does this routine need ppos?  probably... */
> >  		rv = pde->write_proc(file, buffer, count, pde->data);
> >  		pde_users_dec(pde);
> > +		if (rv > 0)
> > +			*ppos += rv;
> >  	}
> >  	return rv;
> >  }
> 
> Yes, that's odd.
> 
> I worry that there might be procfs write handlers which are looking at
> *ppos and whose behaviour might be altered by this patch.
> 
> <searches a bit>
> 
> Look at arch/s390/appldata/appldata_base.c:appldata_timer_handler().
> 
> static int
> appldata_timer_handler(ctl_table *ctl, int write, struct file *filp,
> 			   void __user *buffer, size_t *lenp, loff_t *ppos)
> {
> 	int len;
> 	char buf[2];
> 
> 	if (!*lenp || *ppos) {
> 		*lenp = 0;
> 		return 0;
> 	}
> 
> 

This function will be handled IMHO by the proc_sys_call_handler which
has nothing to do with the proc_file_write.
/proc/sys/... file access should be not touched because there are
handled differently. 

> Prior to your change, an application which opened that proc file and
> repeatedly wrote to the fd would repeatedly start and stop the timer.
> 
> After your change, the second and successive writes would have no
> effect unless the application was changed to lseek back to the start of
> the "file".
> 
> And that was just the second file I looked at via
> 
> 	$EDITOR $(grep -l '[*]ppos' $(grep -rl _proc_ .))

Yes, i think you are right, i have forseen also that there maybe some
pitfalls. The question is: is there any appplication which will be
broken by this patch?

So what is your suggestion? Should we drop this patch or should we
analyze the users and fix it?

My opinion is to fix it, because it is wrong and it limits the usage of
the proc_write operation. Many embedded developers like me count on proc
support, because it is much simpler to use than the seqfile thing.

  reply	other threads:[~2009-08-07 21:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1249676830.27640.16.camel@wall-e>
2009-08-07 20:58 ` [PATCH] Fix proc_file_write missing ppos update Andrew Morton
2009-08-07 21:43   ` Stefani Seibold [this message]
2009-08-07 22:16     ` Andrew Morton
2009-08-08  6:59       ` Eric W. Biederman
2009-08-08  9:29         ` Stefani Seibold

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=1249681387.17422.10.camel@wall-e \
    --to=stefani@seibold.net \
    --cc=akpm@linux-foundation.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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 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).