Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2217263pxb; Tue, 12 Oct 2021 01:47:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9p01kkYKuJzhnfTEOBqhSR9QP/3EBuUXx+CiHZeT3lcEjb7KyGd2hNrUg1/oIlLhbackw X-Received: by 2002:a17:906:d92e:: with SMTP id rn14mr30761773ejb.526.1634028474169; Tue, 12 Oct 2021 01:47:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634028474; cv=none; d=google.com; s=arc-20160816; b=bYWhA4ieT3r/0HqZikS75kZ0sJ3LxJU4gd4Uzkp5rBfV5INNJZVv4fbghW9zzt6jBQ in+Ia79uy6IEVeQCiTVwWpnHev6ijbWbZWxLEksXWqrRBSRHBzdzXt845+g9ceCU5fqb XOK8x3eDLlL0XhjAVAMcX6wbtq6hXecLwAjnKroqgoN9ms+0IfHU5tAw/MP0Jo5+C04s 9LkJDO8nOqEy+K3MUiqj1cO2AIf4x2ugr6dcU0a3qk4fapA4Wj+/aWDgfKlWEZpK8ljU Ds80sVW3VBxp1T/bA+8kJS9G0uBWo1tXH+iECqY/U8RE+/KGS2qSfwzboGWMkv0knQB/ cZ2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=aYu4aB24+puYcfzW2SwqkWc8Rw28kDppQNNwzAvMW9s=; b=aJUsDKkL+MDcKXepcaOyBw8WU8LrGRCGnDrnUz3k5OoKqWRuPKjFC21NmoY14vMA6l T9BJgkurwAA+PeN43MgWEj/D7OJ4+IGBAX/SKYRONzy9zpg3phrrFr+HgiC8g34ek+d8 0AxuBB9MsXruIm5mhwAsD5bEx5xVm/gto82w4Jd4F3vTyv1iL7jJ3AlFSERRz+HgWZWR KfFZy3CGrtpIjJN2xjI5524n8AAlKpKO91pjunEtH8UJKmNu2HHR2RQpm3+SyTvjVhC9 X46gUBv1FqnDFjRwEwPbdH1MNXTkjUxjMHdo4FUXVqWf3VoLt3HF5c9fPZhNYlTjpY36 It8w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hc43si22780391ejc.189.2021.10.12.01.47.30; Tue, 12 Oct 2021 01:47:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235253AbhJLIpQ (ORCPT + 99 others); Tue, 12 Oct 2021 04:45:16 -0400 Received: from smtp23.cstnet.cn ([159.226.251.23]:40656 "EHLO cstnet.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235237AbhJLIpQ (ORCPT ); Tue, 12 Oct 2021 04:45:16 -0400 Received: from localhost.localdomain (unknown [124.16.138.128]) by APP-03 (Coremail) with SMTP id rQCowAC3vamLSmVhcXBJAw--.40210S2; Tue, 12 Oct 2021 16:42:51 +0800 (CST) From: Jiasheng Jiang To: willy@infradead.org, akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, Jiasheng Jiang Subject: [PATCH] XArray: Fix xa_to_node by adding xa_is_node Date: Tue, 12 Oct 2021 08:42:50 +0000 Message-Id: <1634028170-1753612-1-git-send-email-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.7.4 X-CM-TRANSID: rQCowAC3vamLSmVhcXBJAw--.40210S2 X-Coremail-Antispam: 1UD129KBjvdXoW7Xr43JrW5Zry5AF4xAr48Xrb_yoWkJrbEka 1xWr1ftr1Y9Fs3Xw1jganYq3yvy395CFWFqw1kGFZxC34UJr9rXr95Zr1q93ZF9rZ09Fy7 Jr45ArWakryxCjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbcxFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8w A2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j 6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oV Cq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY02Avz4vE14v_GFyl 42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJV WUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAK I48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r 4UMIIF0xvE42xK8VAvwI8IcIk0rVWrZr1j6s0DMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF 0xvEx4A2jsIEc7CjxVAFwI0_Jr0_GrUvcSsGvfC2KfnxnUUI43ZEXa7VUjxR65UUUUU== X-Originating-IP: [124.16.138.128] X-CM-SenderInfo: pmld2xxhqjqxpvfd2hldfou0/ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Directly using xa_to_node may lead to the compulsory type conversion of unknown type,which is unsafe. So it might be better that adding xa_is_node before. Fixes: 58d6ea3 ("xarray: Add XArray unconditional store operations") Signed-off-by: Jiasheng Jiang --- lib/test_xarray.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/test_xarray.c b/lib/test_xarray.c index 8b1c318..7ad3d51 100644 --- a/lib/test_xarray.c +++ b/lib/test_xarray.c @@ -606,8 +606,10 @@ static noinline void check_multi_store(struct xarray *xa) XA_BUG_ON(xa, xa_load(xa, 1) != xa_mk_value(0)); XA_BUG_ON(xa, xa_load(xa, 2) != NULL); rcu_read_lock(); - XA_BUG_ON(xa, xa_to_node(xa_head(xa))->count != 2); - XA_BUG_ON(xa, xa_to_node(xa_head(xa))->nr_values != 2); + if (xa_is_node(xa_head(xa))) { + XA_BUG_ON(xa, xa_to_node(xa_head(xa))->count != 2); + XA_BUG_ON(xa, xa_to_node(xa_head(xa))->nr_values != 2); + } rcu_read_unlock(); /* Storing adjacent to the value does not alter the value */ -- 2.7.4