lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 13 Feb 2007 16:26:25 -0800
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Eric Van Hensbergen <ericvh@...il.com>
Cc:	linux-kernel@...r.kernel.org, v9fs-developer@...ts.sourceforge.net,
	ericvh@...il.com
Subject: Re: [RESEND][PATCH] 9p: add write-cache support to loose cache mode

> On Tue, 13 Feb 2007 17:55:31 -0600 Eric Van Hensbergen <ericvh@...il.com> wrote:
> +static int v9fs_vfs_writepage(struct page *page, struct writeback_control *wbc)
> +{
> +	char *buffer = NULL;
> +	struct address_space *mapping = page->mapping;
> +	int retval = -EIO;
> +	loff_t offset = 0;
> +	loff_t pageoffset = 0;
> +	unsigned long end_index;

Cosmetic detail: pgoff_t here.

> +	int count = PAGE_CACHE_SIZE;
> +	struct file *filp = v9fs_find_file(page);
> +	struct inode *inode = mapping->host;
> +
> +	dprintk(DEBUG_VFS, "page: %p\n", page);
> +
> +	if ((!inode) || (!filp))
> +		goto UnlockPage;
> +
> +	end_index = inode->i_size >> PAGE_CACHE_SHIFT;
> +
> +	/* complicated case at end of file */
> +	if (page->index >= end_index) {
> +		/* things got complicated... */
> +		count = inode->i_size & (PAGE_CACHE_SIZE - 1);
> +		if (page->index >= end_index + 1 || !count)
> +			return 0;	/* truncated - don't care */
> +	}
> +
> +	/* get buffer */
> +	buffer = kmap(page) + pageoffset;

kmap_atomic() is faster and less deadlocky.  But presumably v9fs_write()
prevents that.

> +	offset = ((loff_t) page->index << PAGE_CACHE_SHIFT) + pageoffset;
> +
> +	page_cache_get(page);
> +
> +	retval = v9fs_write(filp, NULL, buffer, count, &offset);
> +
> +	if (retval < 0) {
> +		dprintk(DEBUG_ERROR, "error: %d\n", retval);
> +		ClearPageUptodate(page);
> +		goto UnmapPage;
> +	}

I think you'll find that the ->writepage() caller handles all this.  The
callers also set AS_EIO, which this code forgot.

> +	if (retval < count) {
> +		dprintk(DEBUG_ERROR, "Short write\n");
> +	}
> +
> +	if (offset > inode->i_size) {
> +		inode->i_size = offset;
> +	}

Can this happen??

If so, mark_inode_dirty() seems to be missing.

> +	if (PageError(page))
> +		ClearPageError(page);

Is this needed?

> +	SetPageUptodate(page);

I'd expect that v9fs_writepage() is only ever called against uptodate pages?

> +	retval = 0;
> +
> +      UnmapPage:
>  	kunmap(page);
> +      UnlockPage:
>  	unlock_page(page);
> +	page_cache_release(page);
> +
>  	return retval;
>  }
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ