lkml.org 
[lkml]   [2021]   [Jul]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 2/2] ipc: WARN if trying to remove ipc object which is absent
    Date
    Lets produce a warning if we trying to remove non-existing
    IPC object from IPC namespace kht/idr structures.

    This allows to catch possible bugs when ipc_rmid() function was
    called with inconsistent struct ipc_ids*, struct kern_ipc_perm*
    arguments.

    Cc: Andrew Morton <akpm@linux-foundation.org>
    Cc: Milton Miller <miltonm@bga.com>
    Cc: Jack Miller <millerjo@us.ibm.com>
    Cc: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
    Cc: Alexander Mikhalitsyn <alexander@mihalicyn.com>
    Signed-off-by: Alexander Mikhalitsyn <alexander.mikhalitsyn@virtuozzo.com>
    ---
    ipc/util.c | 6 +++---
    1 file changed, 3 insertions(+), 3 deletions(-)

    diff --git a/ipc/util.c b/ipc/util.c
    index 0027e47626b7..45bb8ce6c42c 100644
    --- a/ipc/util.c
    +++ b/ipc/util.c
    @@ -447,8 +447,8 @@ static int ipcget_public(struct ipc_namespace *ns, struct ipc_ids *ids,
    static void ipc_kht_remove(struct ipc_ids *ids, struct kern_ipc_perm *ipcp)
    {
    if (ipcp->key != IPC_PRIVATE)
    - rhashtable_remove_fast(&ids->key_ht, &ipcp->khtnode,
    - ipc_kht_params);
    + WARN_ON(rhashtable_remove_fast(&ids->key_ht, &ipcp->khtnode,
    + ipc_kht_params));
    }

    /**
    @@ -498,7 +498,7 @@ void ipc_rmid(struct ipc_ids *ids, struct kern_ipc_perm *ipcp)
    {
    int idx = ipcid_to_idx(ipcp->id);

    - idr_remove(&ids->ipcs_idr, idx);
    + WARN_ON(idr_remove(&ids->ipcs_idr, idx) != ipcp);
    ipc_kht_remove(ids, ipcp);
    ids->in_use--;
    ipcp->deleted = true;
    --
    2.31.1
    \
     
     \ /
      Last update: 2021-07-06 15:41    [W:3.290 / U:0.728 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site