Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3341441pxb; Mon, 18 Oct 2021 13:10:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDpIXshDL/jwfUIvNDq0dpkYTlBxNq6EozkbJ2EQ/RYx0o8EZBscBVHZhSQiCqWyvz3zlt X-Received: by 2002:a17:90a:db51:: with SMTP id u17mr1127134pjx.171.1634587806429; Mon, 18 Oct 2021 13:10:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634587806; cv=none; d=google.com; s=arc-20160816; b=lh2Cd5JR/o/+/uUjsEJGVpR3e0G1iHBpywQvSmYAPIyoqk2g5CGyzLiEHZbO6/AAK7 CL52eBcuY8xHWFse69bZc081EFe9DU6yysIgVkiw3PKZYq8GlQwngmQzrtt/iASV91av kGYoFjkKtKpgWPIjtYYpBlkjBoiMgwO+eiQyhx408uLStFASpNPt17IkSg3rg1Q4cyfx NO51sgwGKmQbmTi+wr1d8YGo2sXbIeeLTpu3QnphVeFeT8/5IJrvn3sCGILgGXIzHGDp 1DUqYzPod4j2neIhhPlXsIeorXyEKMB23U0InqEw7QJ0yjDReJWCzYHteVDW02HaO+yJ S37Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=P7i+8tzdlX15v2uc/1AFeD1pxJKxbaEOuZd11PWxgJ0=; b=lYtveeuGDRCZ1EONPvxweqO4RoWU5nfpq3E8gXDsTsp+cql64FSNudwm7fLiQj0lfL vYtXDyfsK7kvM5SXP+20Dq6/7qcBHkpUeyrL6qcUj9sj7VGmueGHYYeS+KyUJlrHSqkb uCwtyFzSv40YDxc2xpquZbQtE1SLA8u2aMnbwW9GCJxNHKKkb+Cv7ODmM5AKFJVoYt1y b5vm2rDTluKkwEGHPFRFIh+h0GzcI+PP7QesKrDjjVh/2ReFFEvLxNEM8R18w8zq+v2k RqB1/thzcGa0jKzrx6p2eVZv5X4Nn7iPMF7ln3BH6afT7PcYnLfQ+rPDt0XAtT6Agh/k 9gUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=r8m9DNRZ; 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 v185si16059719pgd.445.2021.10.18.13.09.52; Mon, 18 Oct 2021 13:10:06 -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; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=r8m9DNRZ; 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 S232200AbhJRUKi (ORCPT + 99 others); Mon, 18 Oct 2021 16:10:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229941AbhJRUKi (ORCPT ); Mon, 18 Oct 2021 16:10:38 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F535C06161C for ; Mon, 18 Oct 2021 13:08:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=P7i+8tzdlX15v2uc/1AFeD1pxJKxbaEOuZd11PWxgJ0=; b=r8m9DNRZ9bpPh5Pa1MuG37G/gw drH1gEgJXmKfOAzbmRG3HoShsLYeztQeGkgiEsTfCZRVSFI/+WEOgCjVr2W9N/yj7cjs0P2y9s+8T VIE80Lz4L+xIRtqdk+UmamesQ4q2XmB0Ke+5/HESdI8Ul7BL1/rYvV+ZKtmmEX+ru4rD+A+aNoKcS /zWylxAHha5ARTcXO/wYi9QqK4f0Z5NLc8Rg85yrhi9Q4vcNZX5Wms9NZ0YExkVuEryu3ig4+KLUn ISSIaCj5/JZDj+SemvuQgVLdKrHelFTRQRA+fBwnVMZA3kqV5NZ9J+pEk6BmzvY7WnzT2ZyXIwC/n rjs5VrWw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mcYto-00BEba-Il; Mon, 18 Oct 2021 20:06:35 +0000 Date: Mon, 18 Oct 2021 21:06:20 +0100 From: Matthew Wilcox To: Jiasheng Jiang Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] XArray: Fix xa_to_node by adding xa_is_node Message-ID: References: <1634028170-1753612-1-git-send-email-jiasheng@iscas.ac.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1634028170-1753612-1-git-send-email-jiasheng@iscas.ac.cn> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 12, 2021 at 08:42:50AM +0000, Jiasheng Jiang wrote: > 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. No. This is test code, and it knows what it's doing. I suppose we could add an XA_BUG_ON(xa, !xa_is_node(xa_head(xa))); but that seems pointless. This patch is definitely wrong. > 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 >