public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] fcntl.2: F_OFD_XXX needs flock64
Date: Wed, 17 Aug 2016 09:44:15 +0200	[thread overview]
Message-ID: <20160817074415.GA5817@rei.lan> (raw)
In-Reply-To: <2c79788f-c74a-49e8-fa81-0e9cf4e2d75f@gmail.com>

Hi!
> > If we pass struct flock to the F_OFD_XXX fcntl() it will fail with
> > EINVAL with a 32bit binary. That is because glibc uses fcntl64() by
> > default but the struct flock uses 32bit off_t for 32bit binaries (unless
> > _FILE_OFFSET_BITS=64) and kernel always expect flock64 for F_OFD_XXX in
> > fcntl64(). Hence kernel will read some garbage that is a few bytes after
> > the 32bit flock structure in this case which will likely end up with the
> > syscall returning EINVAL.
> 
> Okay -- I confirm the problem you report. I'm just not sure that the
> patch below is the best fix. So, to summarize:

Either we do that or we have to translate the flock{} to flock64{} at
the runtime if F_OFD_XXX was the fcntl() cmd. However the problem is
that we have no idea if _FILE_OFFSET_BITS was set or not once we reach
fcntl.c in glibc. So the whole translation would have been put into the
fcntl.h header into some ugly macro or we would have to do some trickery
like passing down the sizeof(struct flock) as additional fcntl
parameter.

> One solution would be your patch below, but it feels wrong: on 64-bit
> flock{} suffices, and is consistent with the traditional F_* operations.
> An alternative would be a note in the man page that says something along
> the lines that on 32-bit, one must compile with -D_FILE_OFFSET_BITS=64
> when using the F_OFD operations.

That would be solution as well.

-- 
Cyril Hrubis
chrubis@suse.cz

      parent reply	other threads:[~2016-08-17  7:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-16 11:55 [LTP] [PATCH] fcntl.2: F_OFD_XXX needs flock64 Cyril Hrubis
2016-08-16 14:34 ` Cyril Hrubis
2016-08-16 20:04 ` Michael Kerrisk
2016-08-16 23:41   ` Jeff Layton
2016-08-17  1:08     ` Michael Kerrisk
2016-08-17  8:10     ` Cyril Hrubis
2016-08-17 11:44       ` Jeff Layton
2016-08-17 11:53         ` Cyril Hrubis
2016-08-17 13:14           ` Jeff Layton
2016-08-17 13:19             ` Cyril Hrubis
2016-08-17 13:34               ` Jeff Layton
2016-08-17 13:34                 ` Cyril Hrubis
2016-08-17 19:44         ` Michael Kerrisk
2016-08-17  7:44   ` Cyril Hrubis [this message]

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=20160817074415.GA5817@rei.lan \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /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