linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc: Add compat_sys_truncate
@ 2009-07-23 15:12 Chase Douglas
  2009-07-27  0:37 ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 4+ messages in thread
From: Chase Douglas @ 2009-07-23 15:12 UTC (permalink / raw)
  To: linuxppc-dev

The truncate syscall has a signed long parameter, so when using a 32- 
bit userspace with a 64-bit kernel the argument is zero-extended  
instead of sign-extended. Adding the compat_sys_truncate function  
fixes the issue.

This was noticed during an LSB truncate test failure. The test was  
checking for the correct error number set when truncate is called with  
a length of -1. The test can be found at:

http://bzr.linuxfoundation.org/lsb/devel/runtime-test?cmd=inventory;rev=stewb%40linux-foundation.org-20090626205411-sfb23cc0tjj7jzgm;path=modules/vsx-pcts/tset/POSIX.os/files/truncate/

Signed-off-by: Chase Douglas <cndougla@linux.vnet.ibm.com>

diff --git a/arch/powerpc/include/asm/systbl.h b/arch/powerpc/include/ 
asm/systbl.h
index 370600c..3cca167 100644
--- a/arch/powerpc/include/asm/systbl.h
+++ b/arch/powerpc/include/asm/systbl.h
@@ -95,7 +95,7 @@ SYSCALL(reboot)
SYSX(sys_ni_syscall,compat_sys_old_readdir,sys_old_readdir)
SYSCALL_SPU(mmap)
SYSCALL_SPU(munmap)
-SYSCALL_SPU(truncate)
+COMPAT_SYS_SPU(truncate)
SYSCALL_SPU(ftruncate)
SYSCALL_SPU(fchmod)
SYSCALL_SPU(fchown)
diff --git a/arch/powerpc/kernel/sys_ppc32.c b/arch/powerpc/kernel/ 
sys_ppc32.c
index bb1cfcf..da9a65b 100644
--- a/arch/powerpc/kernel/sys_ppc32.c
+++ b/arch/powerpc/kernel/sys_ppc32.c
@@ -343,6 +343,12 @@ off_t ppc32_lseek(unsigned int fd, u32 offset,  
unsigned int origin)
        return sys_lseek(fd, (int)offset, origin);
}

+long compat_sys_truncate(const char __user * path, u32 length)
+{
+       /* sign extend length */
+       return sys_truncate(path, (int)length);
+}
+
/* Note: it is necessary to treat bufsiz as an unsigned int,
  * with the corresponding cast to a signed int to insure that the
  * proper conversion (sign extension) between the register  
representation of a signed int (msr in 32-bit mode)

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

* Re: [PATCH] powerpc: Add compat_sys_truncate
  2009-07-23 15:12 [PATCH] powerpc: Add compat_sys_truncate Chase Douglas
@ 2009-07-27  0:37 ` Benjamin Herrenschmidt
  2009-07-27  2:23   ` Chase Douglas
  0 siblings, 1 reply; 4+ messages in thread
From: Benjamin Herrenschmidt @ 2009-07-27  0:37 UTC (permalink / raw)
  To: Chase Douglas; +Cc: linuxppc-dev

On Thu, 2009-07-23 at 11:12 -0400, Chase Douglas wrote:
> The truncate syscall has a signed long parameter, so when using a 32- 
> bit userspace with a 64-bit kernel the argument is zero-extended  
> instead of sign-extended. Adding the compat_sys_truncate function  
> fixes the issue.
> 
> This was noticed during an LSB truncate test failure. The test was  
> checking for the correct error number set when truncate is called with  
> a length of -1. The test can be found at:

Hi Chase !

Unfortunately, your patch have been mangled by your mailer
our your mail gateway in about every possible way (word
wrapped, tabs and whitespace damaged etc...)

I'll hand apply this time around but please, look into
fixing your setup :-)

Cheers,
Ben.

> http://bzr.linuxfoundation.org/lsb/devel/runtime-test?cmd=inventory;rev=stewb%40linux-foundation.org-20090626205411-sfb23cc0tjj7jzgm;path=modules/vsx-pcts/tset/POSIX.os/files/truncate/
> 
> Signed-off-by: Chase Douglas <cndougla@linux.vnet.ibm.com>
> 
> diff --git a/arch/powerpc/include/asm/systbl.h b/arch/powerpc/include/ 
> asm/systbl.h
> index 370600c..3cca167 100644
> --- a/arch/powerpc/include/asm/systbl.h
> +++ b/arch/powerpc/include/asm/systbl.h
> @@ -95,7 +95,7 @@ SYSCALL(reboot)
> SYSX(sys_ni_syscall,compat_sys_old_readdir,sys_old_readdir)
> SYSCALL_SPU(mmap)
> SYSCALL_SPU(munmap)
> -SYSCALL_SPU(truncate)
> +COMPAT_SYS_SPU(truncate)
> SYSCALL_SPU(ftruncate)
> SYSCALL_SPU(fchmod)
> SYSCALL_SPU(fchown)
> diff --git a/arch/powerpc/kernel/sys_ppc32.c b/arch/powerpc/kernel/ 
> sys_ppc32.c
> index bb1cfcf..da9a65b 100644
> --- a/arch/powerpc/kernel/sys_ppc32.c
> +++ b/arch/powerpc/kernel/sys_ppc32.c
> @@ -343,6 +343,12 @@ off_t ppc32_lseek(unsigned int fd, u32 offset,  
> unsigned int origin)
>         return sys_lseek(fd, (int)offset, origin);
> }
> 
> +long compat_sys_truncate(const char __user * path, u32 length)
> +{
> +       /* sign extend length */
> +       return sys_truncate(path, (int)length);
> +}
> +
> /* Note: it is necessary to treat bufsiz as an unsigned int,
>   * with the corresponding cast to a signed int to insure that the
>   * proper conversion (sign extension) between the register  
> representation of a signed int (msr in 32-bit mode)
> 
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev

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

* Re: [PATCH] powerpc: Add compat_sys_truncate
  2009-07-27  0:37 ` Benjamin Herrenschmidt
@ 2009-07-27  2:23   ` Chase Douglas
  2009-07-27  4:34     ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 4+ messages in thread
From: Chase Douglas @ 2009-07-27  2:23 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev

On Jul 26, 2009, at 8:37 PM, Benjamin Herrenschmidt wrote:
> Unfortunately, your patch have been mangled by your mailer
> our your mail gateway in about every possible way (word
> wrapped, tabs and whitespace damaged etc...)

Sorry about that! I made sure my mailer (OS X's Mail) sent it as plain  
text, but I don't know of any settings for specifying line width or  
white space handling. I'll have to do some more digging or use a  
different mailer for patches.

Thanks,
Chase

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

* Re: [PATCH] powerpc: Add compat_sys_truncate
  2009-07-27  2:23   ` Chase Douglas
@ 2009-07-27  4:34     ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 4+ messages in thread
From: Benjamin Herrenschmidt @ 2009-07-27  4:34 UTC (permalink / raw)
  To: Chase Douglas; +Cc: linuxppc-dev

On Sun, 2009-07-26 at 22:23 -0400, Chase Douglas wrote:
> On Jul 26, 2009, at 8:37 PM, Benjamin Herrenschmidt wrote:
> > Unfortunately, your patch have been mangled by your mailer
> > our your mail gateway in about every possible way (word
> > wrapped, tabs and whitespace damaged etc...)
> 
> Sorry about that! I made sure my mailer (OS X's Mail) sent it as plain  
> text, but I don't know of any settings for specifying line width or  
> white space handling. I'll have to do some more digging or use a  
> different mailer for patches.

I'm sure you can find somebody else using OS X who can help :-)

I've also heard there may be a problem with our vnet servers but
I don't know for sure.

Cheers,
Ben.

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

end of thread, other threads:[~2009-07-27  4:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-23 15:12 [PATCH] powerpc: Add compat_sys_truncate Chase Douglas
2009-07-27  0:37 ` Benjamin Herrenschmidt
2009-07-27  2:23   ` Chase Douglas
2009-07-27  4:34     ` Benjamin Herrenschmidt

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).