Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 78ffb70 in mainline


Ignore:
Timestamp:
2010-12-19T14:14:47Z (11 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master
Children:
be942bc, eff1f033
Parents:
40dc422
Message:

ipc_irq_register() and ipc_irq_unregister() should check for out-of-limit INRs
passed from userspace.

Location:
kernel/generic
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/ddi/irq.h

    r40dc422 r78ffb70  
    189189extern hash_table_t irq_uspace_hash_table;
    190190
     191extern inr_t last_inr;
     192
    191193extern void irq_init(size_t, size_t);
    192194extern void irq_initialize(irq_t *);
  • kernel/generic/src/ddi/irq.c

    r40dc422 r78ffb70  
    136136static size_t buckets;
    137137
     138/** Last valid INR. */
     139inr_t last_inr = 0;
     140
    138141/** Initialize IRQ subsystem.
    139142 *
     
    145148{
    146149        buckets = chains;
     150        last_inr = inrs - 1;
     151
    147152        /*
    148153         * Be smart about the choice of the hash table operations.
  • kernel/generic/src/ipc/irq.c

    r40dc422 r78ffb70  
    131131/** Register an answerbox as a receiving end for IRQ notifications.
    132132 *
    133  * @param box     Receiving answerbox.
    134  * @param inr     IRQ number.
    135  * @param devno   Device number.
    136  * @param imethod Interface and method to be associated
    137  *                with the notification.
    138  * @param ucode   Uspace pointer to top-half pseudocode.
    139  *
    140  * @return EBADMEM, ENOENT or EEXISTS on failure or 0 on success.
     133 * @param box           Receiving answerbox.
     134 * @param inr           IRQ number.
     135 * @param devno         Device number.
     136 * @param imethod       Interface and method to be associated with the
     137 *                      notification.
     138 * @param ucode         Uspace pointer to top-half pseudocode.
     139 * @return              EOK on success or a negative error code.
    141140 *
    142141 */
     
    148147                (sysarg_t) devno
    149148        };
     149
     150        if ((inr < 0) || (inr > last_inr))
     151                return ELIMIT;
    150152       
    151153        irq_code_t *code;
     
    208210/** Unregister task from IRQ notification.
    209211 *
    210  * @param box   Answerbox associated with the notification.
    211  * @param inr   IRQ number.
    212  * @param devno Device number.
    213  *
     212 * @param box           Answerbox associated with the notification.
     213 * @param inr           IRQ number.
     214 * @param devno         Device number.
     215 * @return              EOK on success or a negative error code.
    214216 */
    215217int ipc_irq_unregister(answerbox_t *box, inr_t inr, devno_t devno)
     
    219221                (sysarg_t) devno
    220222        };
     223
     224        if ((inr < 0) || (inr > last_inr))
     225                return ELIMIT;
    221226       
    222227        irq_spinlock_lock(&irq_uspace_hash_table_lock, true);
Note: See TracChangeset for help on using the changeset viewer.