Grant access to hardware (UARTs, I2C, etc.) via custom udev rules

Bug #1923363 reported by Dave Jones
20
This bug affects 3 people
Affects Status Importance Assigned to Milestone
cloud-init (Ubuntu)
Fix Released
Undecided
Unassigned
Impish
Won't Fix
Undecided
Unassigned
Jammy
Confirmed
Undecided
Unassigned
Kinetic
Won't Fix
Undecided
Unassigned
Lunar
Won't Fix
Undecided
Unassigned
Mantic
Fix Released
Undecided
Unassigned
ubiquity (Ubuntu)
Invalid
Undecided
Unassigned
Impish
Invalid
Undecided
Unassigned
Jammy
Invalid
Undecided
Unassigned
Kinetic
Invalid
Undecided
Unassigned
Lunar
Invalid
Undecided
Unassigned
Mantic
Invalid
Undecided
Unassigned
ubuntu-settings (Ubuntu)
Fix Released
Undecided
Dave Jones
Impish
Won't Fix
Undecided
Unassigned
Jammy
Confirmed
Undecided
Dave Jones
Kinetic
Won't Fix
Undecided
Unassigned
Lunar
Won't Fix
Undecided
Unassigned
Mantic
Fix Released
Undecided
Dave Jones
user-setup (Ubuntu)
Invalid
Undecided
Unassigned
Impish
Invalid
Undecided
Unassigned
Jammy
Invalid
Undecided
Unassigned
Kinetic
Invalid
Undecided
Unassigned
Lunar
Invalid
Undecided
Unassigned
Mantic
Invalid
Undecided
Unassigned

Bug Description

We're attempting to make the GPIO system on the Raspberry Pi images work "out of the box" on the new image. By default, GPIO kernel devices are made available to members of the "dialout" group which the initial user is added to by default on our server images. However, we've noticed that this isn't the case on the desktop images.

The regression potential is minimal; the group already exists and we're simply adding the freshly created user to a new group and not removing any existing memberships. The group in question ("dialout") is also rarely used these days except for providing access to serial consoles, and as mentioned above is already a default membership on the server images. The change has been tested on the desktop image successfully.

A test build of the updated image will be made under https://launchpad.net/~waveform/+archive/ubuntu/ubiquity and I'll attach a debdiff shortly.

Related branches

Revision history for this message
Dave Jones (waveform) wrote :

Attach debdiff for user-setup. This will need uploading before ubiquity's copy of the package can be sync'd.

Revision history for this message
Steve Langasek (vorlon) wrote :

I'm unclear why the default user is part of the dialout group on server images either. If you look at the history of user-setup, you'll see that we once (10 years ago) had the default user in dialout, but this was reverted because it wasn't needed for ppp access (that uses dip) and users shouldn't have direct access to serial ttys by default. In particular, if there is a serial console, having access to the tty means the user may have access to intercept root passwords being sent on the line.

Do you know where the dialout group is being added by default on servers, and if there has already been discussion of this issue?

I expect that the GPIO devices are not serial TTYs. Is there a good reason to use the dialout group for these devices instead of a different (perhaps new) group?

Changed in user-setup (Ubuntu):
status: New → Incomplete
Changed in ubiquity (Ubuntu):
status: New → Incomplete
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

@vorlon this is the same user that already is in `sudo` & `lxd` groups, thus they can do that anyway.

To use the real UART rx/tx pins one has to disable bluetooth and use /dev/ttyAMA0

For gpio pins, I see that some use group `gpio` and then mark /dev/gpiomem to be owned by gpio group.

We should be able to create a new groupname and use that one, as long as the udev rule for it has the matching group.

Dave, is this to access ttyAMA0 or to access something else? i2c, gpiomem, etc?

Revision history for this message
Dave Jones (waveform) wrote :

@vorlon on the question of where it's added by default, that's in the cloud-init default configuration which lives in /etc/cloud/cloud.cfg and contains the following stanza (redacted for brevity):

system_info:
    ...
    default_user:
        ...
        groups: [adm, audio, cdrom, dialout, dip, floppy, lxd, netdev, plugdev, sudo, video]

I'd echo xnox's point that as the user is being added to adm and sudo, I don't think there's any particular security concern here.

On the subject of choice of groups, it would be nice to echo raspios' setup which is to use a "gpio" group to permit access to the GPIO related devices (/dev/gpiomem, /dev/gpiochip*), an "spi" group for the SPI buses (/dev/spidev*), and an "i2c" group for the I2C buses (/dev/i2c-*).

However, I ran out of time to go fiddling with defining new groups and ensuring the default user is in all those new groups on both the desktop and server images. Upstream in Debian (and hence in Ubuntu), "dialout" is already used for GPIO access (which makes sense given the serial pins are part of the GPIO header, just like SPI and I2C), and (as noted above) we already add the user to this group on the server image, so it seems a reasonable approach to achieve the ultimate goal of providing the default user access to the GPIO header without having to jump to root to do so.

And just to answer @xnox's query as to what exactly this is for, it's access to the GPIO header as a whole, including i2c, gpiomem (although ideally gpiochip* actually as that's the preferred device to use for GPIO access now), etc. just in case that's not clear from the above.

Dave Jones (waveform)
Changed in user-setup (Ubuntu):
status: Incomplete → New
Changed in ubiquity (Ubuntu):
status: Incomplete → New
tags: added: fr-1316
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in ubiquity (Ubuntu):
status: New → Confirmed
Changed in user-setup (Ubuntu):
status: New → Confirmed
Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Is this still a thing for impish?

Changed in user-setup (Ubuntu Impish):
status: Confirmed → Incomplete
Changed in ubiquity (Ubuntu Impish):
status: Confirmed → Incomplete
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for user-setup (Ubuntu Impish) because there has been no activity for 60 days.]

Changed in user-setup (Ubuntu Impish):
status: Incomplete → Expired
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for user-setup (Ubuntu) because there has been no activity for 60 days.]

Changed in user-setup (Ubuntu):
status: Incomplete → Expired
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for ubiquity (Ubuntu) because there has been no activity for 60 days.]

Changed in ubiquity (Ubuntu):
status: Incomplete → Expired
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for ubiquity (Ubuntu Impish) because there has been no activity for 60 days.]

Changed in ubiquity (Ubuntu Impish):
status: Incomplete → Expired
Revision history for this message
Dave Jones (waveform) wrote :

Argh, this slipped off my radar; yes, it was still a thing in impish *and* jammy.

Changed in ubiquity (Ubuntu Kinetic):
status: Expired → New
Changed in user-setup (Ubuntu Kinetic):
status: Expired → Incomplete
status: Incomplete → New
Changed in user-setup (Ubuntu Impish):
status: Expired → Won't Fix
Changed in ubiquity (Ubuntu Impish):
status: Expired → Won't Fix
Revision history for this message
Dave Jones (waveform) wrote :

I'll rebase the patch and check it still works on a modern image.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in ubiquity (Ubuntu Jammy):
status: New → Confirmed
Changed in ubiquity (Ubuntu):
status: New → Confirmed
Changed in user-setup (Ubuntu Jammy):
status: New → Confirmed
Changed in user-setup (Ubuntu):
status: New → Confirmed
Dave Jones (waveform)
summary: - [FFe] Users are not added to the dialout group
+ Users are not added to the dialout group
Revision history for this message
Dave Jones (waveform) wrote : Re: Users are not added to the dialout group

This additionally causes issues with accessing certain /dev/video* devices for hardware acceleration, which is probably quite an important feature for the desktop image.

summary: - Users are not added to the dialout group
+ Users are not added to various groups (dialout, video, etc.)
Changed in user-setup (Ubuntu Jammy):
milestone: none → ubuntu-22.04.1
Revision history for this message
Dave Jones (waveform) wrote : Re: Users are not added to various groups (dialout, video, etc.)

Added the video group, rebased the debdiff for kinetic, and generated it with git-diff instead of debdiff (apparently debdiff doesn't understand symlinks).

Dave Jones (waveform)
Changed in user-setup (Ubuntu Jammy):
milestone: ubuntu-22.04.1 → ubuntu-22.04.2
Dave Jones (waveform)
Changed in user-setup (Ubuntu Kinetic):
status: Confirmed → Won't Fix
Changed in ubiquity (Ubuntu Kinetic):
status: Confirmed → Won't Fix
Revision history for this message
Dave Jones (waveform) wrote :

There will be no further releases of lunar; hence won't fix for this release

Changed in user-setup (Ubuntu Lunar):
status: Confirmed → Won't Fix
Changed in ubiquity (Ubuntu Lunar):
status: Confirmed → Won't Fix
Revision history for this message
Dave Jones (waveform) wrote :

Re-generated for mantic (and refined the changelog entry a bit too)

Revision history for this message
Dave Jones (waveform) wrote :

Adding a merge request for ubiquity as it turns out the user-setup embedded in ubiquity is not the one from the archive (yet?).

Revision history for this message
Dave Jones (waveform) wrote :

Per vorlon's comments on the merge request, I've closed the merge and will re-submit an alternative method using udev rules instead of group membership. Adding ubuntu-settings for the udev rules, and cloud-init as we presumably want to remove membership in those groups from server instances too.

tags: added: foundations-todo
summary: - Users are not added to various groups (dialout, video, etc.)
+ Grant access to hardware (UARTs, I2C, etc.) via custom udev rules
Changed in cloud-init (Ubuntu Impish):
status: New → Won't Fix
Changed in cloud-init (Ubuntu Jammy):
status: New → Confirmed
Changed in cloud-init (Ubuntu Kinetic):
status: New → Won't Fix
Changed in cloud-init (Ubuntu Lunar):
status: New → Won't Fix
Changed in cloud-init (Ubuntu Mantic):
status: New → Confirmed
Changed in ubiquity (Ubuntu Impish):
status: Won't Fix → Invalid
Changed in ubiquity (Ubuntu Jammy):
status: Confirmed → Invalid
Changed in ubiquity (Ubuntu Kinetic):
status: Won't Fix → Invalid
Changed in ubiquity (Ubuntu Lunar):
status: Won't Fix → Invalid
Changed in ubiquity (Ubuntu Mantic):
status: Confirmed → Invalid
Changed in ubuntu-settings (Ubuntu Impish):
status: New → Won't Fix
Changed in ubuntu-settings (Ubuntu Jammy):
status: New → Confirmed
Changed in ubuntu-settings (Ubuntu Kinetic):
status: New → Won't Fix
Changed in ubuntu-settings (Ubuntu Lunar):
status: New → Won't Fix
Changed in ubuntu-settings (Ubuntu Mantic):
status: New → Confirmed
Changed in user-setup (Ubuntu Impish):
status: Won't Fix → Invalid
Dave Jones (waveform)
Changed in user-setup (Ubuntu Jammy):
status: Confirmed → Invalid
Changed in user-setup (Ubuntu Kinetic):
status: Won't Fix → Invalid
Changed in user-setup (Ubuntu Lunar):
status: Won't Fix → Invalid
Changed in user-setup (Ubuntu Mantic):
status: Confirmed → Invalid
Revision history for this message
Dave Jones (waveform) wrote :

Added PR for cloud-init to remove the default groups that were removed (ages ago) from the desktop image (excepting the lxd group which was added in a reasonably recent commit and so is presumably wanted): https://github.com/canonical/cloud-init/pull/4258

Dave Jones (waveform)
Changed in ubuntu-settings (Ubuntu Mantic):
assignee: nobody → Dave Jones (waveform)
Changed in ubuntu-settings (Ubuntu Jammy):
assignee: nobody → Dave Jones (waveform)
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package cloud-init - 23.3~4ga31370af-0ubuntu1

---------------
cloud-init (23.3~4ga31370af-0ubuntu1) mantic; urgency=medium

  * Upstream snapshot based on upstream/main at a31370af.
    - Bugs fixed in this snapshot: (LP: #1923363, #2028562, #2028784)
  * d/cloud-init.maintscript: Remove the unused hook-network-manager
    conffile. (LP: #2027861)
  * d/control: Add python3-passlib as needed for testing

 -- James Falcon <email address hidden> Mon, 31 Jul 2023 11:38:42 -0500

Changed in cloud-init (Ubuntu Mantic):
status: Confirmed → Fix Released
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

Does this have FFe?

Revision history for this message
Steve Langasek (vorlon) wrote :

it does now

Changed in ubuntu-settings (Ubuntu Mantic):
status: Confirmed → Triaged
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ubuntu-settings - 23.10.5

---------------
ubuntu-settings (23.10.5) mantic; urgency=medium

  * ubuntu-raspi-settings: Add macb ethernet driver to the eth0 rename list
    to support Raspberry Pi 5 (LP: #2037642)
  * ubuntu-raspi-settings: Use uaccess instead of group membership to control
    access to GPIO devices (LP: #1923363)
  * ubuntu-settings, ubuntu-raspi-settings-desktop: Override lintian warnings
    about netplan configuration mode and growroot.service

 -- Dave Jones <email address hidden> Fri, 22 Sep 2023 11:13:46 +0100

Changed in ubuntu-settings (Ubuntu Mantic):
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.