linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Chris Metcalf <cmetcalf@tilera.com>
Cc: linux-arch@vger.kernel.org,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [tile] sys_llseek() can *not* be used as compat_sys_llseek() there
Date: Wed, 27 Feb 2013 19:41:57 +0000	[thread overview]
Message-ID: <20130227194156.GQ4503@ZenIV.linux.org.uk> (raw)
In-Reply-To: <512E5471.2060908@tilera.com>

On Wed, Feb 27, 2013 at 01:46:09PM -0500, Chris Metcalf wrote:
> On 2/24/2013 7:29 PM, Al Viro wrote:
> > 	Unless I'm seriously misreading your code, you have all arguments of
> > compat syscall sign-extended by asm glue.  If that's the case, consider
> > what will happen to 32bit binary doing
> > 	llseek(fd, 0, 0xffffffff, &pos, SEEK_CUR)
> > on 32bit and 64bit hosts resp.  The former will move the current position
> > by 4Gb forward; the latter - by one byte backwards...
> 
> Without testing this (I'm in an airport), I think you might be right.  But the fix seems like it might just be changing the parameters of the llseek syscall in read_write.c to be "unsigned int" for offset_high and offset_low.  That would let the usual syscall-wrappers code properly zero-extend the high bits.

... and screw binary compatibility on 64bit architectures that have llseek(2).
I also thought that there's no such thing - after all, any such architecture
has perfectly usable lseek(2).  No such luck - parisc64, ppc64, sparc64, s390x
and sh64 all have both of those.  AFAICS, glibc does not use llseek(2) on any
of those and any userland code directly using that syscall would be rather
dumb, but then this is precisely the sort of userland code likely to screw
it up.

I don't know; it's a borderline case, but strictly speaking we would be
breaking syscall ABI compatibility on those architectures by doing that.
OTOH, the real rule is more squishy - "don't break real userland code",
so...  Hell knows.

Linus, do you have any comments on that proposal?  Basically, that would make
sys_llseek() ignore upper 32 bits of offset_low on 64bit targets.  Benefit:
fixes bug in tile compat, removes the need of compat wrapper on mips, slightly
simpler rules for populating compat syscall tables.  Cost: changes behaviour
of llseek(2) for 64bit binaries on parisc, ppc, sparc, s390, sh64.  AFAIK,
glibc ignores that syscall on those targets, so affected userland would have
to do it manually via syscall(__NR_llseek,...).

TBH, I'd rather solve it by providing a mips-style wrapper for tile, but...

  reply	other threads:[~2013-02-27 19:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-25  0:29 [tile] sys_llseek() can *not* be used as compat_sys_llseek() there Al Viro
2013-02-27 18:46 ` Chris Metcalf
2013-02-27 19:41   ` Al Viro [this message]
2013-03-04 16:19     ` [PATCH] tile: work around bug in the generic sys_llseek Chris Metcalf
2013-03-04 16:54       ` Al Viro
2013-03-04 17:45         ` Chris Metcalf
2013-03-04 18:37         ` [PATCH] tile: properly use COMPAT_SYSCALL_DEFINEx Chris Metcalf

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=20130227194156.GQ4503@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=cmetcalf@tilera.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /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).