Skip to content

Fail to remove volume with semi-colliding names #26168

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

Closed
kriansa opened this issue May 21, 2025 · 5 comments · Fixed by #26217
Closed

Fail to remove volume with semi-colliding names #26168

kriansa opened this issue May 21, 2025 · 5 comments · Fixed by #26217
Assignees
Labels
bugweek kind/bug Categorizes issue or PR as related to a bug. sqlite Bugs pertaining to the sqlite database backend triaged Issue has been triaged

Comments

@kriansa
Copy link

kriansa commented May 21, 2025

Issue Description

If you happen to have two volume names that have almost the same name, but separated by commas and underlines respectively, removing the one with underlines will fail.

Steps to reproduce the issue

Steps to reproduce the issue

  1. podman volume create test-test
  2. podman volume create test_test
  3. podman volume rm test_test

Describe the results you received

It errors with the message:

Error: more than one result for volume name test_test: volume already exists

Describe the results you expected

It should simply output the volume name instead. Now if you try and remove the test-test first, it will work.

I haven't tested many operations with this behavior yet, but I'm assuming there are other flows that probably behave equally when facing collision in container names.

podman info output

host:
  arch: amd64
  buildahVersion: 1.39.4
  cgroupControllers:
  - cpu
  - memory
  - pids
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: conmon-1:2.1.13-1
    path: /usr/bin/conmon
    version: 'conmon version 2.1.13, commit: 82de887596ed8ee6d9b2ee85e4f167f307bb569b'
  cpuUtilization:
    idlePercent: 95.75
    systemPercent: 1.29
    userPercent: 2.96
  cpus: 12
  databaseBackend: sqlite
  distribution:
    distribution: arch
    version: unknown
  eventLogger: journald
  freeLocks: 2045
  hostname: daniel-desktop.lan.cx
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 10000
      size: 65536
    uidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 10000
      size: 65536
  kernel: 6.14.6-arch1-1
  linkmode: dynamic
  logDriver: journald
  memFree: 9554493440
  memTotal: 33429688320
  networkBackend: netavark
  networkBackendInfo:
    backend: netavark
    dns:
      package: aardvark-dns-1.14.0-1
      path: /usr/lib/podman/aardvark-dns
      version: aardvark-dns 1.14.0
    package: netavark-1.14.1-1
    path: /usr/lib/podman/netavark
    version: netavark 1.14.1
  ociRuntime:
    name: crun
    package: crun-1.21-1
    path: /usr/bin/crun
    version: |-
      crun version 1.21
      commit: 10269840aa07fb7e6b7e1acff6198692d8ff5c88
      rundir: /run/user/1000/crun
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +YAJL
  os: linux
  pasta:
    executable: /usr/bin/pasta
    package: passt-2025_05_12.8ec1341-1
    version: ""
  remoteSocket:
    exists: true
    path: /run/user/1000/podman/podman.sock
  rootlessNetworkCmd: pasta
  security:
    apparmorEnabled: false
    capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
    rootless: true
    seccompEnabled: true
    seccompProfilePath: /etc/containers/seccomp.json
    selinuxEnabled: false
  serviceIsRemote: false
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: slirp4netns-1.3.2-1
    version: |-
      slirp4netns version 1.3.2
      commit: 0f13345bcef588d2bb70d662d41e92ee8a816d85
      libslirp: 4.9.0
      SLIRP_CONFIG_VERSION_MAX: 6
      libseccomp: 2.5.6
  swapFree: 34359681024
  swapTotal: 34359734272
  uptime: 46h 58m 18.00s (Approximately 1.92 days)
  variant: ""
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  - ipvlan
  volume:
  - local
registries: {}
store:
  configFile: /home/dpereira/.config/containers/storage.conf
  containerStore:
    number: 2
    paused: 0
    running: 2
    stopped: 0
  graphDriverName: overlay
  graphOptions: {}
  graphRoot: /home/dpereira/.local/share/containers/storage
  graphRootAllocated: 134729433088
  graphRootUsed: 92176044032
  graphStatus:
    Backing Filesystem: xfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Supports shifting: "false"
    Supports volatile: "true"
    Using metacopy: "false"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 2
  runRoot: /run/user/1000/containers
  transientStore: false
  volumePath: /home/dpereira/.local/share/containers/storage/volumes
version:
  APIVersion: 5.4.2
  Built: 1745099855
  BuiltTime: Sat Apr 19 18:57:35 2025
  GitCommit: be85287fcf4590961614ee37be65eeb315e5d9ff
  GoVersion: go1.24.2
  Os: linux
  OsArch: linux/amd64
  Version: 5.4.2

Podman in a container

No

Privileged Or Rootless

Rootless

Upstream Latest Release

Yes

Additional environment details

N/A

Additional information

N/A

@kriansa kriansa added the kind/bug Categorizes issue or PR as related to a bug. label May 21, 2025
@Luap99
Copy link
Member

Luap99 commented May 21, 2025

Oh my, looks like our SQL db queries are not safe
cc @mheon

An underscore ("_") in the LIKE pattern matches any single character in the string

Therefore the db returns two return values when asking for test_test.

@Luap99 Luap99 added the triaged Issue has been triaged label May 21, 2025
@Luap99
Copy link
Member

Luap99 commented May 21, 2025

Oh and it is even worse as LIKE is not case sensitive either by default, a volume name a and A causes the same error.

@Luap99 Luap99 added the sqlite Bugs pertaining to the sqlite database backend label May 21, 2025
@mheon
Copy link
Member

mheon commented May 21, 2025

Marking as bug week and self-assigning

@mheon mheon added the bugweek label May 21, 2025
@mheon mheon self-assigned this May 21, 2025
@rhatdan
Copy link
Member

rhatdan commented May 22, 2025

A simple fix, would be go through the results when more then one returned and only return exact match, or just use a different call into database.

@kriansa
Copy link
Author

kriansa commented May 22, 2025

Or escaping the characters _ and % from the input.

Edit: it won't work for the case-insensitive issue, but I would expect that vol names should probably be case-insensitive

mheon added a commit to mheon/libpod that referenced this issue May 27, 2025
Specifically, this does two things:

1. Turn on case-sensitive LIKE queries. Technically, this is not
specific to volumes, as it will also affect container and pod
lookups - but there, it only affects IDs. So `podman rm abc123`
will not be the same as `podman rm ABC123` but I don't think
anyone was manually entering uppercase SHA256 hash IDs so it
shouldn't matter.

2. Escape the _ and % characters in volume lookup queries. These
are SQLite wildcards, and meant that `podman volume rm test_1`
would also match `podman volume rm testa2` (or any character in
place of the underscore). This isn't done with pod and container
lookups, but again those just use LIKE for IDs - so technically
`podman volume rm abc_123` probably works and removes containers
with an ID matching that pattern... I don't think that matters
though.

Fixes containers#26168

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugweek kind/bug Categorizes issue or PR as related to a bug. sqlite Bugs pertaining to the sqlite database backend triaged Issue has been triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants