public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] minix: bug widening a binary "not" operation
@ 2013-05-16  7:51 Dan Carpenter
  2013-05-29 22:28 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2013-05-16  7:51 UTC (permalink / raw)
  To: Al Viro; +Cc: linux-kernel, kernel-janitors

"chunk_size" is an unsigned int and "pos" is an unsigned long.  The
"& ~(chunk_size-1)" operation clears the high 32 bits unintentionally.

The ALIGN() macro does the correct thing.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/fs/minix/dir.c b/fs/minix/dir.c
index a9ed6f3..09b0c96 100644
--- a/fs/minix/dir.c
+++ b/fs/minix/dir.c
@@ -95,7 +95,7 @@ static int minix_readdir(struct file * filp, void * dirent, filldir_t filldir)
 	char *name;
 	__u32 inumber;
 
-	pos = (pos + chunk_size-1) & ~(chunk_size-1);
+	pos = ALIGN(pos, chunk_size);
 	if (pos >= inode->i_size)
 		goto done;
 

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [patch] minix: bug widening a binary "not" operation
  2013-05-16  7:51 [patch] minix: bug widening a binary "not" operation Dan Carpenter
@ 2013-05-29 22:28 ` Andrew Morton
  2013-05-30  6:52   ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2013-05-29 22:28 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Al Viro, linux-kernel, kernel-janitors

On Thu, 16 May 2013 10:51:49 +0300 Dan Carpenter <dan.carpenter@oracle.com> wrote:

> "chunk_size" is an unsigned int and "pos" is an unsigned long.  The
> "& ~(chunk_size-1)" operation clears the high 32 bits unintentionally.
> 
> The ALIGN() macro does the correct thing.
> 
> ...
>
> @@ -95,7 +95,7 @@ static int minix_readdir(struct file * filp, void * dirent, filldir_t filldir)
>  	char *name;
>  	__u32 inumber;
>  
> -	pos = (pos + chunk_size-1) & ~(chunk_size-1);
> +	pos = ALIGN(pos, chunk_size);
>  	if (pos >= inode->i_size)
>  		goto done;
>  

I'm suspecting there aren't many minix filesystems out there with a >4G
directory ;)

But we should fix it to set a good example, and to quieten
whatever-tool-i-suspect-you-were-using(?).

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch] minix: bug widening a binary "not" operation
  2013-05-29 22:28 ` Andrew Morton
@ 2013-05-30  6:52   ` Dan Carpenter
  0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2013-05-30  6:52 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Al Viro, linux-kernel, kernel-janitors

On Wed, May 29, 2013 at 03:28:26PM -0700, Andrew Morton wrote:

> But we should fix it to set a good example, and to quieten
> whatever-tool-i-suspect-you-were-using(?).

Linus wrote some Sparse patches that check for this but they haven't
been merged yet.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-05-30  6:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-16  7:51 [patch] minix: bug widening a binary "not" operation Dan Carpenter
2013-05-29 22:28 ` Andrew Morton
2013-05-30  6:52   ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox