Repository navigation
Fix dangling active_job pointer in ippeveprinter delete_job - #207
Closed
tanjiroK-coder wants to merge 1 commit into
Closed
tanjiroK-coder wants to merge 1 commit into
tanjiroK-coder wants to merge 1 commit into
Conversation
A job that is canceled or aborted before it is processed never goes through process_job(), so printer->active_job keeps pointing at it. clean_jobs() then frees the job 60 seconds later, and the next Create-Job, Print-Job, Get-Printer-Attributes, or Cancel-Jobs request dereferences freed memory. Clear the pointer in delete_job().
michaelrsweet
left a comment
Member
There was a problem hiding this comment.
I think we need to take a writer lock on the printer before changing active_job, but will confirm...
Member
|
OK, looks like the only caller is |
michaelrsweet
added a commit
that referenced
this pull request
Nov 4, 2026
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
create_job()pointsprinter->active_jobat each new job and onlyprocess_job()resets it, but a job can finish without ever being processed: Cancel-Job or Cancel-Jobs on a held job that has no document data yet, or the abort paths infinish_document_data()/finish_document_uri()(for example Print-URI with adocument-urithat cannot be read). About 60 seconds laterclean_jobs()frees that job throughdelete_job()whileactive_jobstill points at it, so the next Create-Job or Print-Job (create_job()), Get-Printer-Attributes (queued-job-count) or Cancel-Jobs dereferences freed memory, and Cancel-Jobs can also writestate,cancelandcompletedthrough the stale pointer. None of these operations need authentication by default, so any client that can reach the printer can trigger it. I reproduced it on the ASan build with ipptool: Create-Job, Cancel-Job, a 63 secondDELAY, then Get-Printer-Attributes gives a heap-use-after-free READ at ippeveprinter.c:3763 (freed bydelete_jobfromclean_jobs, allocated increate_job), and Print-URI withfile:///nonexistent/doc.pdffollowed by Create-Job after the delay hits it at ippeveprinter.c:1241. Clearing the pointer indelete_job()covers every way a job can complete, andclean_jobs()already holds the printer write lock at that point. With the change both sequences run clean under ASan andmake testin tools passes; I left out a regression test because the fixed 60 second cleanup would add over a minute torun-tests.sh, but the ipptool file is small if you want it.Changelog:
- Fixed a use-after-free in ippeveprinter after a canceled or aborted job was removed from the job history.