public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Willy Tarreau <w@1wt.eu>
To: ????????? <faye.zixun@gmail.com>
Cc: linux-kernel mlist <linux-kernel@vger.kernel.org>,
	linux-stable mlist <stable@kernel.org>
Subject: Re: [stable] Ioctl in 2.6.35.22 change the argument value?
Date: Thu, 30 Jun 2011 08:31:30 +0200	[thread overview]
Message-ID: <20110630063130.GC26670@1wt.eu> (raw)
In-Reply-To: <BANLkTin9JkWbOHjbZSRTHye+sbr3HpLrBw@mail.gmail.com>

Hello,

On Wed, Jun 29, 2011 at 11:09:26PM -0700, ????????? wrote:
> Hello everybody,
> 
> When I want to get the block size about the block device(DM or real),I
> use the system API like "ioctl(int fd, BLKGETSIZE,long size)".
> Everything works fine. But when I pass the third parameter whose type
> is "int", the first parameter fd will be changed to zero. It only
> happened on x86_64 and 2.6.35 ,on  2.6.38 and 32bit will not occur,
> I've already tested on them.
> (My PC:Linux server-group 2.6.35-22-server #33-Ubuntu SMP Sun Sep 19
> 20:48:58 UTC 2010 x86_64 GNU/Linux)
> here is the test code:
> int main(){
>         int fd;
>         int blksize ;
>         fd = open("/dev/sda",O_RDONLY,0);
>         ioctl(fd, BLKGETSIZE,&blksize) ;
>         close(fd);
> }
> If I change the fd type as long( int fd ==> long fd ) , won't occur
> again. I quite sure the ioctl syscall when return to userspace changes
> the fd's value.

This is expected, check the ioctl list (man ioctl_list) :
       0x00001260   BLKGETSIZE   unsigned long *

So it returns a long, and you need to have blksize declared as long
and not as int. On 32-bit systems, both are the same size so your
bug has no effect.

Please also note that this is irrelevant to the stable list.

Regards,
Willy


      reply	other threads:[~2011-06-30  6:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-30  5:26 Ioctl in 2.6.35.22 change the argument value? 孙子荀
2011-06-30  6:09 ` 孙子荀
2011-06-30  6:31   ` Willy Tarreau [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=20110630063130.GC26670@1wt.eu \
    --to=w@1wt.eu \
    --cc=faye.zixun@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@kernel.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