lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4CAB1693.2080301@redhat.com>
Date:	Tue, 05 Oct 2010 14:14:11 +0200
From:	Jerome Marchand <jmarchan@...hat.com>
To:	Matthew Wilcox <matthew@....cx>
CC:	Pavel Emelyanov <xemul@...allels.com>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	xiyou.wangcong@...il.com
Subject: Re: [PATCH v2] procfs: fix numbering in /proc/locks

On 09/30/2010 02:38 PM, Jerome Marchand wrote:
> 
> The lock number in /proc/locks (first field) is implemented by a counter
> (private field of struct seq_file) which is incremented at each call of
> locks_show() and reset to 1 in locks_start() whatever the offset is. It
> should be reset according to the actual position in the list.
> 
> Moreover, locks_show() can be called twice to print a single line thus
> skipping a number. The counter should be incremented in locks_next().
> 
> Signed-off-by: Jerome Marchand <jmarchan@...hat.com>
> ---
>  locks.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/locks.c b/fs/locks.c
> index ab24d49..49d7343 100644
> --- a/fs/locks.c
> +++ b/fs/locks.c
> @@ -2166,19 +2166,19 @@ static int locks_show(struct seq_file *f, void *v)
>  	list_for_each_entry(bfl, &fl->fl_block, fl_block)
>  		lock_get_status(f, bfl, (long)f->private, " ->");
>  
> -	f->private++;
>  	return 0;
>  }
>  
>  static void *locks_start(struct seq_file *f, loff_t *pos)
>  {
>  	lock_kernel();
> -	f->private = (void *)1;
> +	f->private = (void *) (*pos + 1);

That cast trigger a warning on some arch:
"warning: cast to pointer from integer of different size"

There is no real risk here. At worst /proc/locks will show wrong number
if there is more than 2^32 locks, but should I mute the warning it with
something like:
        f->private = (void *) (size_t) (*pos + 1);
?

Thanks,
Jerome

>  	return seq_list_start(&file_lock_list, *pos);
>  }
>  
>  static void *locks_next(struct seq_file *f, void *v, loff_t *pos)
>  {
> +	f->private++;
>  	return seq_list_next(v, &file_lock_list, pos);
>  }
>  
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@...r.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ