From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DFCE3C48BE8 for ; Sun, 13 Jun 2021 20:04:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BEE776128B for ; Sun, 13 Jun 2021 20:04:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231906AbhFMUGk (ORCPT ); Sun, 13 Jun 2021 16:06:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231788AbhFMUGj (ORCPT ); Sun, 13 Jun 2021 16:06:39 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEA25C061574; Sun, 13 Jun 2021 13:04:37 -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-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=5jdQRt7Z6/fU16jagmX4zMd3V2C9IXzmhJfviU+tOnQ=; b=hQ/qBOQmNo7mysrvLMExqqTH+J ME/ZUm3b9yftNm/SBF+rKA9X6l6xSER9K/SDj3slAaJ3Uu+4Q5ah/8TCY5TyP0/6QfW6pxC6WZXlU FbnDKUmpHncA6xtYMa9Zjcmj/c51Bjw+d5mNGJB9KgMTyEnqp6p2nj+VlZ5zOW6ICr3agJlsICCT7 WLdmqufNVzTdXwlTVNfBBc58vB/K0Od+EafPW4WHo/oTAI+UsSoN6cJiI8zhdHcRfPA5SJ1Ck9PnN dJc6+xooSRrtySmcz4MH5criXvgTsvRXk9pfK4dcNxdIqm6IVtECaCPWtu3vWoJEMlVS8kk/zdFuO Wpyy1l4A==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lsWLC-004lqs-Vt; Sun, 13 Jun 2021 20:04:21 +0000 Date: Sun, 13 Jun 2021 21:04:18 +0100 From: Matthew Wilcox To: David Mozes Cc: "linux-fsdevel@vger.kernel.org" , Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Darren Hart , linux-kernel@vger.kernel.org Subject: Re: futex/call -to plist_for_each_entry_safe with head=NULL Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jun 13, 2021 at 12:24:52PM +0000, David Mozes wrote: > Hi *, > Under a very high load of io traffic, we got the below  BUG trace. > We can see that: > plist_for_each_entry_safe(this, next, &hb1->chain, list) { >                 if (match_futex (&this->key, &key1)) >   > were called with hb1 = NULL at futex_wake_up function. > And there is no protection on the code regarding such a scenario. >   > The NULL can  be geting from: > hb1 = hash_futex(&key1); >   > How can we protect against such a situation? Can you reproduce it without loading proprietary modules? Your analysis doesn't quite make sense: hb1 = hash_futex(&key1); hb2 = hash_futex(&key2); retry_private: double_lock_hb(hb1, hb2); If hb1 were NULL, then the oops would come earlier, in double_lock_hb(). > RIP: 0010:do_futex+0xdf/0xa90 >   > 0xffffffff81138eff is in do_futex (kernel/futex.c:1748). > 1743                                       put_futex_key(&key1); > 1744                                       cond_resched(); > 1745                                       goto retry; > 1746                       } > 1747       > 1748                       plist_for_each_entry_safe(this, next, &hb1->chain, list) { > 1749                                       if (match_futex (&this->key, &key1)) { > 1750                                                       if (this->pi_state || this->rt_waiter) { > 1751                                                                       ret = -EINVAL; > 1752                                                                       goto out_unlock; > (gdb) >   >   >   > plist_for_each_entry_safe(this, next, &hb1->chain, list) { >                 if (match_futex (&this->key, &key1)) { >   >   >   >   > This happened in kernel  4.19.149 running on Azure vm >   >   > Thx > David > Reply > Forward > MO >