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=-16.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham 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 E829AC433E0 for ; Fri, 26 Mar 2021 09:32:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BCE9D61A49 for ; Fri, 26 Mar 2021 09:32:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230179AbhCZJcY (ORCPT ); Fri, 26 Mar 2021 05:32:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:35896 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229773AbhCZJcB (ORCPT ); Fri, 26 Mar 2021 05:32:01 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D96A761A36; Fri, 26 Mar 2021 09:31:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1616751120; bh=ubfXR8EL0Nl5t2d25uT9t1S9l5tjLbIQe0W8EAvq7No=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=isJSVcGvh/NE5+1o6I2m9d8Cb7Ui/S01Ynz/6l02kiouudbvkx0u8W5Noutb3ZGlV Vzw4HWKBjkOaBuEVK4BO4qKe2YdSwZ1b5Gnj5g6BBl3wNHCPMqC3w6RDKLWOv9OZcQ sz5DEsJVPkjbn3745PQIO+1nqNn0JaQrnCuVAd3g= Date: Fri, 26 Mar 2021 10:31:57 +0100 From: Greg Kroah-Hartman To: Du Cheng Cc: "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, Shuah Khan , syzbot+3eec59e770685e3dc879@syzkaller.appspotmail.com Subject: Re: [PATCH] net:qrtr: fix allocator flag of idr_alloc_u32() in qrtr_port_assign() Message-ID: References: <20210326033345.162531-1-ducheng2@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210326033345.162531-1-ducheng2@gmail.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Fri, Mar 26, 2021 at 11:33:45AM +0800, Du Cheng wrote: > change the allocator flag of idr_alloc_u32 from GFP_ATOMIC to > GFP_KERNEL, as GFP_ATOMIC caused BUG: "using smp_processor_id() in > preemptible" as reported by syzkaller. > > Reported-by: syzbot+3eec59e770685e3dc879@syzkaller.appspotmail.com > Signed-off-by: Du Cheng > --- > Hi David & Jakub, > > Although this is a simple fix to make syzkaller happy, I feel that maybe a more > proper fix is to convert qrtr_ports from using IDR to radix_tree (which is in > fact xarray) ? > > I found some previous work done in 2019 by Matthew Wilcox: > https://lore.kernel.org/netdev/20190820223259.22348-1-willy@infradead.org/t/#mcb60ad4c34e35a6183c7353c8a44ceedfcff297d > but that was not merged as of now. My wild guess is that it was probably > in conflicti with the conversion of radix_tree to xarray during 2020, and that > might cause the direct use of xarray in qrtr.c unfavorable. > > Shall I proceed with converting qrtr_pors to use radix_tree (or just xarray)? Try it and see. But how would that resolve this issue? Those other structures would also need to allocate memory at this point in time and you need to tell it if it can sleep or not. > diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c > index edb6ac17ceca..ee42e1e1d4d4 100644 > --- a/net/qrtr/qrtr.c > +++ b/net/qrtr/qrtr.c > @@ -722,17 +722,17 @@ static int qrtr_port_assign(struct qrtr_sock *ipc, int *port) > mutex_lock(&qrtr_port_lock); > if (!*port) { > min_port = QRTR_MIN_EPH_SOCKET; > - rc = idr_alloc_u32(&qrtr_ports, ipc, &min_port, QRTR_MAX_EPH_SOCKET, GFP_ATOMIC); > + rc = idr_alloc_u32(&qrtr_ports, ipc, &min_port, QRTR_MAX_EPH_SOCKET, GFP_KERNEL); Are you sure that you can sleep in this code path? thanks, greg k-h