OpenPrinting / OpenPrinting/cups-browsed

Review locking/multi-threading implementation

Open
#36 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C
Stars
49
Forks
19
PR merge metrics
No merged PRs in 30d

Description

According to @evilsocket, cups-browsed can be held up for an extended period of time:

The lock acquired here doesn't get unlocked until the IPP server has responded. A malicious IPP server can keep the connection going effectively remotely causing a DoS of the service.

I believe there's also a race condition because internally examine_discovered_printer_record then tries to unlock and relocks after a while.

We should review the locking and multi-threading implementation in cups-browsed to ensure we don't deadlock and don't wait indefinitely for a printer to respond. In particular, a short timeout (10 seconds?) should be set on any printer connection so that we minimize the chances of a misbehaving printer from preventing cups-browsed from setting up local print queues for legacy applications.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in daemon/cups-browsed.c at the lock referenced near line 5031, then trace examine_discovered_printer_record and its unlock/relock behavior. Review the printer connection paths for deadlock or indefinite waits; done means locking is safe and misbehaving printers cannot block setup indefinitely, with a short timeout applied where appropriate.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
backend, networking, security
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.