public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Mitch Williams <mitch.a.williams@intel.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] disallow seeks and appends on sysfs files
Date: Sat, 22 Jan 2005 00:05:56 -0800	[thread overview]
Message-ID: <20050122080556.GA6999@kroah.com> (raw)
In-Reply-To: <Pine.CYG.4.58.0501211441430.3364@mawilli1-desk2.amr.corp.intel.com>

On Fri, Jan 21, 2005 at 02:49:39PM -0800, Mitch Williams wrote:
> This patch causes sysfs to return errors if the caller attempts to append
> to or seek on a sysfs file.

And what happens to it today if you do either of these?

Also, isn't this two different things?

> 
> Generated from 2.6.11-rc1.
> 
> Signed-off-by: Mitch Williams <mitch.a.williams@intel.com>
> 
> diff -uprN -X dontdiff linux-2.6.11-clean/fs/sysfs/file.c linux-2.6.11/fs/sysfs/file.c
> --- linux-2.6.11-clean/fs/sysfs/file.c	2004-12-24 13:33:50.000000000 -0800
> +++ linux-2.6.11/fs/sysfs/file.c	2005-01-21 13:09:21.000000000 -0800
> @@ -281,6 +281,11 @@ static int check_perm(struct inode * ino
>  	if (!ops)
>  		goto Eaccess;
> 
> +	/* Is the file is open for append?  Sorry, we don't do that. */
> +	if (file->f_flags & O_APPEND) {
> +		goto Einval;
> +	}

Please, no {} for one line if statements.  Like the one above it :)



> +
>  	/* File needs write support.
>  	 * The inode's perms must say it's ok,
>  	 * and we must have a store method.
> @@ -312,6 +302,10 @@ static int check_perm(struct inode * ino
>  		file->private_data = buffer;
>  	} else
>  		error = -ENOMEM;
> +
> +	/*  Set mode bits to disallow seeking.  */
> +	file->f_mode &= ~(FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE);
> +
>  	goto Done;
> 
>   Einval:
> @@ -368,7 +343,7 @@ static int sysfs_release(struct inode *
>  struct file_operations sysfs_file_operations = {
>  	.read		= sysfs_read_file,
>  	.write		= sysfs_write_file,
> -	.llseek		= generic_file_llseek,
> +	.llseek		= no_llseek,
>  	.open		= sysfs_open_file,
>  	.release	= sysfs_release,
>  };

-- 

  reply	other threads:[~2005-01-22  8:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-21 22:49 [PATCH 1/3] disallow seeks and appends on sysfs files Mitch Williams
2005-01-22  8:05 ` Greg KH [this message]
2005-01-24 18:16   ` Mitch Williams
2005-01-24 21:40     ` Greg KH

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=20050122080556.GA6999@kroah.com \
    --to=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mitch.a.williams@intel.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