* [linux-lvm] lvm fails when /proc/devices contains "-1 smblk"
@ 2012-03-16 6:28 John Mesmon
2012-03-17 9:46 ` Zdenek Kabelac
0 siblings, 1 reply; 5+ messages in thread
From: John Mesmon @ 2012-03-16 6:28 UTC (permalink / raw)
To: linux-lvm
It filters out all the possible devices, resulting in almost all
operations failing (maybe all, I haven't checked that far).
Introduced by c929a0b3c8c1cd4a32458b5db0aa3d221a949aad
My opinion is that there is no need for the check that commit adds, It
can only break things (when the range of valid block devices changes).
For reference, the relavent portion of my /proc/devices:
Character devices:
1 mem
4 /dev/vc/0
4 tty
...
251 macvtap
252 kcopy
253 bsg
254 rtc
Block devices:
-1 smblk
1 ramdisk
256 rfd
257 ssfdc
259 blkext
7 loop
...
--
Cody
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [linux-lvm] lvm fails when /proc/devices contains "-1 smblk"
2012-03-16 6:28 [linux-lvm] lvm fails when /proc/devices contains "-1 smblk" John Mesmon
@ 2012-03-17 9:46 ` Zdenek Kabelac
2012-03-17 16:12 ` Alasdair G Kergon
0 siblings, 1 reply; 5+ messages in thread
From: Zdenek Kabelac @ 2012-03-17 9:46 UTC (permalink / raw)
To: LVM general discussion and development; +Cc: John Mesmon
Dne 16.3.2012 07:28, John Mesmon napsal(a):
> It filters out all the possible devices, resulting in almost all
> operations failing (maybe all, I haven't checked that far).
>
> Introduced by c929a0b3c8c1cd4a32458b5db0aa3d221a949aad
>
> My opinion is that there is no need for the check that commit adds, It
> can only break things (when the range of valid block devices changes).
I thin you should made your opinion after checking the code around this check
- since then you would notice, that parsed number is used as an index to
static array and using '-1' obviously makes an access outside of the memory
allocated for this mapping array.
The fact it's used to work before this commit means, that overwritten memory
in front of this array was not that much important for lvm executable.
> For reference, the relavent portion of my /proc/devices:
>
> Character devices:
> 1 mem
> 4 /dev/vc/0
> 4 tty
> ...
> 251 macvtap
> 252 kcopy
> 253 bsg
> 254 rtc
>
> Block devices:
> -1 smblk
> 1 ramdisk
> 256 rfd
> 257 ssfdc
> 259 blkext
> 7 loop
While saying that - we may add support for several majors with negative
numbers, but it somehow doesn't make sense to me yet.
(Since the filter's mapping table supports majors in range [0..4096> )
If I check kernel headers or glibc headers, then major & minor numbers
are always handled as unsigned numbers.
So how is that, that your /proc/devices shows it as '-1' ??
What are major/minor numbers of devices that belong to 'smblk' ??
How did you came to such block device ??
Is that actually anything from upstream kernel ??
Zdenek
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [linux-lvm] lvm fails when /proc/devices contains "-1 smblk"
2012-03-17 9:46 ` Zdenek Kabelac
@ 2012-03-17 16:12 ` Alasdair G Kergon
2012-03-17 17:31 ` Maxim Levitsky
0 siblings, 1 reply; 5+ messages in thread
From: Alasdair G Kergon @ 2012-03-17 16:12 UTC (permalink / raw)
To: John Mesmon, maximlevitsky; +Cc: LVM general discussion and development
> Dne 16.3.2012 07:28, John Mesmon napsal(a):
> > Block devices:
> > -1 smblk
That's outside the range of valid major numbers and surely shouldn't be getting
exposed to userspace in /proc/devices.
static struct mtd_blktrans_ops sm_ftl_ops = {
.name = "smblk",
.major = -1,
Why's -1 being used?
Alasdair
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [linux-lvm] lvm fails when /proc/devices contains "-1 smblk"
2012-03-17 16:12 ` Alasdair G Kergon
@ 2012-03-17 17:31 ` Maxim Levitsky
2012-03-17 20:51 ` Zdenek Kabelac
0 siblings, 1 reply; 5+ messages in thread
From: Maxim Levitsky @ 2012-03-17 17:31 UTC (permalink / raw)
To: Alasdair G Kergon; +Cc: John Mesmon, LVM general discussion and development
On Sat, 2012-03-17 at 16:12 +0000, Alasdair G Kergon wrote:
> > Dne 16.3.2012 07:28, John Mesmon napsal(a):
> > > Block devices:
> > > -1 smblk
>
> That's outside the range of valid major numbers and surely shouldn't be getting
> exposed to userspace in /proc/devices.
>
> static struct mtd_blktrans_ops sm_ftl_ops = {
> .name = "smblk",
> .major = -1,
>
> Why's -1 being used?
>
> Alasdair
Woops. I accidentally assigned it 4096 major.
I probably thought that it will get me dynamic major number, sorry!
Will fix soon!
Best regards,
Maxim Levitsky
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [linux-lvm] lvm fails when /proc/devices contains "-1 smblk"
2012-03-17 17:31 ` Maxim Levitsky
@ 2012-03-17 20:51 ` Zdenek Kabelac
0 siblings, 0 replies; 5+ messages in thread
From: Zdenek Kabelac @ 2012-03-17 20:51 UTC (permalink / raw)
To: linux-lvm
Dne 17.3.2012 18:31, Maxim Levitsky napsal(a):
> On Sat, 2012-03-17 at 16:12 +0000, Alasdair G Kergon wrote:
>>> Dne 16.3.2012 07:28, John Mesmon napsal(a):
>>>> Block devices:
>>>> -1 smblk
>>
>> That's outside the range of valid major numbers and surely shouldn't be getting
>> exposed to userspace in /proc/devices.
>>
>> static struct mtd_blktrans_ops sm_ftl_ops = {
>> .name = "smblk",
>> .major = -1,
>>
>> Why's -1 being used?
>>
>> Alasdair
>
> Woops. I accidentally assigned it 4096 major.
> I probably thought that it will get me dynamic major number, sorry!
> Will fix soon!
>
So I've made couple experiments, and it seem that numbers printed via
/proc/devices are actually not reflecting kernel reality.
It seems that if the kernel driver uses i.e. 'major == -4290'
then cat /proc/devices shows exactly this number (-4290).
But the device physically appears with major 3902.
So obviously kernel masks 0xfff and it's using it as unsigned number.
I'll update lvm code to go with same logic - while probably giving a user
warning, the major number used for device is not correct (so they could fixed
just like in smblk case).
Also I guess kernel patch which would fix this behavior might be useful as
well, but lvm needs to work with old kernels anyway.
Zdenek
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-03-17 20:51 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-16 6:28 [linux-lvm] lvm fails when /proc/devices contains "-1 smblk" John Mesmon
2012-03-17 9:46 ` Zdenek Kabelac
2012-03-17 16:12 ` Alasdair G Kergon
2012-03-17 17:31 ` Maxim Levitsky
2012-03-17 20:51 ` Zdenek Kabelac
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).