linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hugh Dickins <hugh@veritas.com>
To: Amar Lior <lior@cs.huji.ac.il>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Problem
Date: Tue, 31 Dec 2002 17:38:45 +0000 (GMT)	[thread overview]
Message-ID: <Pine.LNX.4.44.0212311717400.1688-100000@localhost.localdomain> (raw)
In-Reply-To: <Pine.LNX.4.20_heb2.08.0212311818280.29471-100000@mos214.cs.huji.ac.il>

On Tue, 31 Dec 2002, Amar Lior wrote:
> 
> I found a bug that cause the kernel to lockup.

In 2.4, yes.  Coincidentally, Mikael Starvik reported this just a
couple of weeks ago, though it has been lurking there for a long time.
In 2.5 it was fixed (in ignorance of the problem) a little while ago,
and Marcelo already has fix below in his BK tree towards 2.4.20-pre3.

Anyway, thanks a lot for making sure we know about it.  (The code was
_nearly_ right, the loop should have terminated when nr returned from
file_read_actor becomes 0: but there were _two_ declarations of nr,
and the nr tested to terminate the loop remained 1 throughout).

Hugh

diff -Nru a/mm/shmem.c b/mm/shmem.c
--- a/mm/shmem.c	Thu Dec 26 22:32:38 2002
+++ b/mm/shmem.c	Thu Dec 26 22:32:38 2002
@@ -919,14 +919,13 @@
 	struct inode *inode = filp->f_dentry->d_inode;
 	struct address_space *mapping = inode->i_mapping;
 	unsigned long index, offset;
-	int nr = 1;
 
 	index = *ppos >> PAGE_CACHE_SHIFT;
 	offset = *ppos & ~PAGE_CACHE_MASK;
 
-	while (nr && desc->count) {
+	for (;;) {
 		struct page *page;
-		unsigned long end_index, nr;
+		unsigned long end_index, nr, ret;
 
 		end_index = inode->i_size >> PAGE_CACHE_SHIFT;
 		if (index > end_index)
@@ -956,12 +955,14 @@
 		 * "pos" here (the actor routine has to update the user buffer
 		 * pointers and the remaining count).
 		 */
-		nr = file_read_actor(desc, page, offset, nr);
-		offset += nr;
+		ret = file_read_actor(desc, page, offset, nr);
+		offset += ret;
 		index += offset >> PAGE_CACHE_SHIFT;
 		offset &= ~PAGE_CACHE_MASK;
 	
 		page_cache_release(page);
+		if (ret != nr || !desc->count)
+			break;
 	}
 
 	*ppos = ((loff_t) index << PAGE_CACHE_SHIFT) + offset;


  reply	other threads:[~2002-12-31 17:29 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-31 16:19 Problem Amar Lior
2002-12-31 17:38 ` Hugh Dickins [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-04-27  1:35 PROBLEM Thomas Kayser
2006-02-03 12:02 PROBLEM Badri Pillai
2004-12-24  4:22 PROBLEM Scott Mollica
2004-12-27  3:28 ` PROBLEM Adrian Bunk
2003-12-19 18:10 PROBLEM Federico Freire
2003-12-19 18:25 ` PROBLEM Jean-Philippe Woot de Trixhe
2003-12-19 19:29   ` PROBLEM Jose Luis Domingo Lopez
2003-11-30  4:07 PROBLEM Mike Morrell
2003-11-30  6:05 ` PROBLEM Chris Ernst
2003-10-21 13:39 PROBLEM laurent.miaille
2003-03-13 21:40 Problem Smiler
2003-03-09 11:49 PROBLEM Kósa Ferenc
2003-03-09 12:55 ` PROBLEM John Bradford
2002-12-31 16:18 PROBLEM Amar Lior
2002-08-29 19:55 Problem Ryan White
2002-08-14 14:20 PROBLEM Bob Kruger
2001-09-11 23:16 Problem George Lloyd

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=Pine.LNX.4.44.0212311717400.1688-100000@localhost.localdomain \
    --to=hugh@veritas.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lior@cs.huji.ac.il \
    /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).