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] [day] [month] [year] [list]
Message-ID: <eb572576-89f4-c192-09ab-b4585d09b75a@huaweicloud.com>
Date: Mon, 25 Aug 2025 17:36:02 +0800
From: Yu Kuai <yukuai1@...weicloud.com>
To: Christoph Hellwig <hch@...radead.org>, Ming Lei <ming.lei@...hat.com>
Cc: Yu Kuai <yukuai1@...weicloud.com>, axboe@...nel.dk, rajeevm@....com,
 linux-block@...r.kernel.org, linux-kernel@...r.kernel.org,
 yi.zhang@...wei.com, yangerkun@...wei.com, johnny.chenyi@...wei.com,
 linux-fsdevel@...r.kernel.org, "yukuai (C)" <yukuai3@...wei.com>
Subject: Re: [PATCH] loop: fix zero sized loop for block special file

Hi,

在 2025/08/25 17:18, Christoph Hellwig 写道:
> On Mon, Aug 25, 2025 at 04:56:55PM +0800, Ming Lei wrote:
>> `stat $BDEV_PATH` never works for getting bdev size, so it looks wrong
>> to call vfs_getattr_nosec() with bdev path for retrieving bdev's size.
> 
> Exactly.
> 

Ok.
>> So just wondering why not take the following more readable way?
>>
>> 	/* vfs_getattr() never works for retrieving bdev size */
>> 	if (S_ISBLK(stat.mode)) {
>> 		loopsize = i_size_read(file->f_mapping->host);
>> 	} else {
>>            ret = vfs_getattr_nosec(&file->f_path, &stat, STATX_SIZE, 0);
>>            if (ret)
>>                    return 0;
>>            loopsize = stat.size;
>> 	}

Just we can't use stat.mode here, I'll replace it with:

S_ISBLK(file_inode(file)->i_mode)

Thanks,
Kuai

>>
>> Also the above looks like how application reads file size in case of bdev
>> involved.
> 
> That's not just more readable, but simply the way to go.  Maybe split
> it into a helper for readability, though.
> .
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ