Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config-linux: Add restriction for duplicated device path #647

Merged

Conversation

Mashimiao
Copy link

I think runtime should generate an error, if devices has duplicated device path.
Because we don't know which one is really needed.

Signed-off-by: Ma Shimiao njmiaoge@126.com

@@ -121,6 +121,9 @@ Each entry has the following structure:
* **`uid`** *(uint32, OPTIONAL)* - id of device owner.
* **`gid`** *(uint32, OPTIONAL)* - id of device group.

If a `devices` contains duplicated devices with same `path`, the runtime MUST generate an error.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplication in the devices array is a subset of this issue, which is that a path in devices already exists in the container filesystem being constructed. Besides an earlier devices entry, this could also happen if a file (in the "everything is a file" sense) exists in the root.path directory at the target location, although you could also have conflicts sure to mounts entries. I think this line should be under the path entry above with text like:

If a file already exists at path that does not match the requested file, the runtime MUST generate an error instead of creating the requested file.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about this?
If a file already exists at path that does not match the requested device, the runtime MUST generate an error.
We don't care what runtime already did now, we need it to generate an error and return.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we link to POSIX to define file (like I did in my earlier comment)? I think that helps clarify the intended "everything is a file" semantics so readers don't wonder "but what happens if a directory exists at path?" and similar.

* **`major, minor`** *(int64, REQUIRED unless **`type`** is `p`)* - [major, minor numbers][devices] for the device.
Same `major, minor` for different devices is acceptable, but it is not recommended.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe move this back outside the properties list and say something like:

Using the same type, major, and minor for multiple devices entries is allowed but not recommend.

@Mashimiao
Copy link
Author

Mashimiao commented Jan 6, 2017 via email

@wking
Copy link
Contributor

wking commented Jan 6, 2017

It doesn't matter about duplicated type, we can add same type devices.

You can use the same major on multiple devices too. What we're recommending is that you don't use the same (type, major, minor) tuple.

@Mashimiao
Copy link
Author

Mashimiao commented Jan 6, 2017 via email

@wking
Copy link
Contributor

wking commented Jan 6, 2017 via email

@Mashimiao
Copy link
Author

Mashimiao commented Jan 6, 2017 via email

@wking
Copy link
Contributor

wking commented Jan 6, 2017 via email

@Mashimiao
Copy link
Author

In major.3, the description says a device ID consist of two parts: major, minor.
In my opinion, As ID, it should be unique. I'm not sure why it is not in Kernel.
I still think let major,minor to be unique is better for devices.
But if @opencontainers/runtime-spec-maintainers object, I can remove it in this PR.

@wking
Copy link
Contributor

wking commented Jan 6, 2017 via email

@Mashimiao
Copy link
Author

Mashimiao commented Jan 6, 2017 via email

@wking
Copy link
Contributor

wking commented Jan 6, 2017 via email

@@ -608,6 +610,7 @@ The values MUST be absolute paths in the [container namespace][container-namespa
[cgroup-v2]: https://www.kernel.org/doc/Documentation/cgroup-v2.txt
[devices]: https://www.kernel.org/doc/Documentation/devices.txt
[devpts]: https://www.kernel.org/doc/Documentation/filesystems/devpts.txt
[file.1]: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_164
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, thanks

@hqhq
Copy link
Contributor

hqhq commented Jan 6, 2017

I agree the recommend against should to the whole (type, major, minor) tuple.

@Mashimiao
Copy link
Author

Mashimiao commented Jan 6, 2017

I'm not sure how Kernel manage devices currently.
From here it seems identify by type and major,minor is reasonable. But Kernel seems does not work like that.

@wking
Copy link
Contributor

wking commented Jan 6, 2017 via email

@Mashimiao
Copy link
Author

@opencontainers/runtime-spec-maintainers PTAL

@hqhq
Copy link
Contributor

hqhq commented Jan 10, 2017

LGTM

Approved with PullApprove

@Mashimiao
Copy link
Author

@mrunalp @vbatts @dqminh PTAL

* **`major, minor`** *(int64, REQUIRED unless **`type`** is `p`)* - [major, minor numbers][devices] for the device.
* **`fileMode`** *(uint32, OPTIONAL)* - file mode for the device.
You can also control access to devices [with cgroups](#device-whitelist).
* **`uid`** *(uint32, OPTIONAL)* - id of device owner.
* **`gid`** *(uint32, OPTIONAL)* - id of device group.

Using same `type` and `major, minor` for mulitple devices is allowed, but not recommended.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe replace:

`type` and `major, minor`

with:

`type`, `major`, and `minor`

major and minor are separate properties, so I don't think we want them in the same monospace span.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And "allowed but not recommended" sound like "SHOULD NOT".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also typo at mulitple

@RobDolinMS RobDolinMS added this to the 1.0.0 milestone Jan 11, 2017
@Mashimiao
Copy link
Author

@wking @RobDolinMS @mrunalp @hqhq PTAL

* **`major, minor`** *(int64, REQUIRED unless **`type`** is `p`)* - [major, minor numbers][devices] for the device.
* **`fileMode`** *(uint32, OPTIONAL)* - file mode for the device.
You can also control access to devices [with cgroups](#device-whitelist).
* **`uid`** *(uint32, OPTIONAL)* - id of device owner.
* **`gid`** *(uint32, OPTIONAL)* - id of device group.

Same `type`, `major` and `minor` SHOULD NOT be used for multiple devices.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: “Same” → “The same”. Otherwise a78a4c1 looks good to me.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, thanks

I think runtime should generate an error, if devices has
duplicated device path.
Because we don't know which one is really needed.

Signed-off-by: Ma Shimiao <mashimiao.fnst@cn.fujitsu.com>
@hqhq
Copy link
Contributor

hqhq commented Jan 12, 2017

LGTM

Approved with PullApprove

1 similar comment
@mrunalp
Copy link
Contributor

mrunalp commented Jan 12, 2017

LGTM

Approved with PullApprove

@mrunalp mrunalp merged commit c0206be into opencontainers:master Jan 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants