Race condition in C_WaitForSlotEvent
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
Direzione di ricerca
Start with reader-pcsc.c around line 1874, then trace sc_wait_for_event() and accesses to pcsc_global_private_data.pcsc_wait_ctx. Check how the context is initialized, used, and restored across concurrent C_WaitForSlotEvent calls. The issue is resolved when this shared-resource race is addressed and Coverity's reported missing-restore path is accounted for.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
reader-pcsc.c is implemented so that there is some collection of global resources that is available to all possible threads accessing the reader's context. In particular, struct pcsc_global_private_data holds a SCARDCONTEXT in pcsc_wait_ctx which is used for detecting reader events (e.g. insertion/removal of cards). Accessing this global context is typically not a problem with respect to race conditions on (de)initializing or using these global resources, because
- minidriver performs its own separation of threads and processes
- OpenSC's PKCS#11 layer uses
sc_pkcs11_lock()to access some token (C_Initializeuses a global lock to avoid concurrency) - macOS uses one single process (without threads?) to access a token, which should avoid concurrency
However, there is one case in PKCS#11 that isn't covered with a lock: C_WaitForSlotEvent. Here, sc_wait_for_event() is called without being protected with a lock. This poses the risk of modifying the global ressources by different threads at the same time.
Coverity scan reports this problem at reader-pcsc.c:1874:
CID 361010: (#1 of 1): Failure to restore non-local value (MISSING_RESTORE)
42. end_of_path: Value of non-local gpriv->pcsc_wait_ctx that was verified to be -1L is not restored as it was along other paths.
The recommendation here would be to either avoid the global resources or to avoid the race conditions by, e.g. using locks.
- Lingua principale
- C
- Stelle
- 3.1k
- Fork
- 858
- Merge medio
- 4g 4h
- PR unite (30g)
- 16
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di OpenSC/OpenSC
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 2 giorni
-
card lock not released in error pathForse già presa @mvogt1 l’ha presa 5 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
I maintainer di solito rispondono entro 2 giorni
-
Commit from 08.10.26 breaks cachingForse già presa @mvogt1 l’ha presa 5 giorni fa. Apertabug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
I maintainer di solito rispondono entro 2 giorni
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 18/100
OpenSC/OpenSC#3878 · 5 commenti ·
I maintainer di solito rispondono entro 2 giorni
-
enhancement
Difficoltà 3/5 1-2 giorni Idoneità per principianti 66/100
OpenSC/OpenSC#3864 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di OpenSC/OpenSC
Issue simili
-
backlog bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
EchoTools/nevr-runtime#653 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
InfiniTimeOrg/InfiniTime#2492 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
I maintainer di solito rispondono entro 1 giorno
-
base-files: 82_config_generate: regenerate /etc/board.json if 0-bytes / truncated after power cutAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
openwrt/openwrt#25940 · 5 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno