Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2112380imm; Mon, 3 Sep 2018 19:42:17 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZV5+qjMN3iL/ukvFaAMk3KA+HBIdrpAax0qwXmmXGWoD0XSA2VhdY4RIrAzfzVaJP6+4IW X-Received: by 2002:a17:902:b7c3:: with SMTP id v3-v6mr31492980plz.238.1536028937292; Mon, 03 Sep 2018 19:42:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536028937; cv=none; d=google.com; s=arc-20160816; b=0YhTrTlUCHQb7JeP39NhyYGAqqWLzYgwGWjOP3jtaAKgmN1bFXGpNKGT+IG4FkMt2D RS3bBr/E9eHMMR7O2OEFb92N+NBewSQuJgmrq4g0bbKBbcyFQxvm6gMpVUdO4vg265FZ MvI6n8uNMIe0TWsrqnHP65elDc35oul/dwo5tKqROzS9CXucxHeKBu9hIzbcKFJlun2h z0aXg2KiOir+j6epmgQzLjHFWjusTbrqqHYEjmKb+po/uw162lkBqTsssVyklbaokQuv oJGyb2g6W69cdncrKqgnHy+fQEfb88/HIlBPWxdPjTd/nj6n235StpgB4TBeB+oufTd+ LxAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=FLySk63nUYnPfBhWcOtMnf2UlcdiW+c1lsQ4o3I15F0=; b=CQMdjC5fEssmTbXEIl2pfbew6m+EWmMEGfHEr13jFCBVS6Kki45S4AphVwj6R8siEh n4AZiDyWSrnpsxmPTTx+KVeF03BXat025UsWX0ZrwJUNJbYwMpNzW0G3NVoeaLI3pVDg Hda839ABjIQ/ehlLKHD4kOAH7J22hHCTunvizV1h4vmhO7v9BBId5+adb+XiP0iQ9UlQ Wot3maPLnmGFalyM7LBGUn7FWAZ1MWX15jD88aoAfOCG7E17TNtS5aMvICQBTmzu8rRI 9cog/K23Mo23IaPvmcPu6k5gyUbIAg05mtDE2MMXIb9wIiiWOhK3/0mWV+2oyBrq+GZ6 TghQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=s+ns+3hc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f2-v6si20340352pgg.552.2018.09.03.19.42.00; Mon, 03 Sep 2018 19:42:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=s+ns+3hc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726134AbeIDHDu (ORCPT + 99 others); Tue, 4 Sep 2018 03:03:50 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:36532 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725837AbeIDHDu (ORCPT ); Tue, 4 Sep 2018 03:03:50 -0400 Received: by mail-pf1-f193.google.com with SMTP id b11-v6so911092pfo.3; Mon, 03 Sep 2018 19:40:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=FLySk63nUYnPfBhWcOtMnf2UlcdiW+c1lsQ4o3I15F0=; b=s+ns+3hcORvTinpTEoK5P45nFFTl2Gipu8/4xu0O92wLi1PsEYEvviUIMsCNNF4Vvi KXc5Z/Jxig7bTy56JY0HliUuz86ON75ldbAluzQwZeKYsO6ijUB00y8fnrauGecT94PL ME5sjEYTY+xe6oDhOcnOkorTcobFUf7qGZldPOBA/OIAk1MRFnZTrAcTzuL3e84CREOK 0MFrCX9SIXFDPuQGthLzt7yPNZreYrVJksDX+scNlfV1ICT5MFrcfZX9djzpr/tlTfej 0/pO1cwzj9E0Ai8PhU+9ZXbX8n62u9TdGYo35YjaeDj0vJMuDA55eXPzssxW9uLau+vO ezjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=FLySk63nUYnPfBhWcOtMnf2UlcdiW+c1lsQ4o3I15F0=; b=BycH0Btb3nYY6c7Ocdz7cIODOKqKTjI3/hJ1w82QFrCwtdBzfLIeV7yexH/+m8AkDx tI6gk1KfZIrKQr62Khg6/wR9qtiMpYkNchl9qqvb3+g91BdF6tOeWD0PmCT+nu97uctI p4WrMKMyv64ChwCsgcUxLIShUieyma4evbFLG5JxFOHkr9ivqn7XDlrJ38T0XYhs3iba fDMTfKM/kuTY7PB+6DyvJyNNzb2xWlKc+5W5f9fNBJ8uP+313SUmdiWRIZsR20lSMvyf H9uHnMZEt6Zm2tNsrOgZ7muo6RiTTkK1bdDlqVTHJMf7oE9RJ51Gz4bEzjYG7NQemL7M MWFw== X-Gm-Message-State: APzg51BSTyt3ewUgb/6ieojJY6o/LdZLMYkPXF2Xl1iUxEyfO20XELnF tAL2pNwsQDR5cSD2NFbs4zdxMLy2 X-Received: by 2002:a62:de04:: with SMTP id h4-v6mr28704891pfg.258.1536028855948; Mon, 03 Sep 2018 19:40:55 -0700 (PDT) Received: from dsa-mb.local ([2601:282:800:fd80:1145:f235:fa5f:50ca]) by smtp.googlemail.com with ESMTPSA id t12-v6sm32806802pgg.72.2018.09.03.19.40.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Sep 2018 19:40:54 -0700 (PDT) Subject: Re: [PATCH] net: ipv6: route: Fix a sleep-in-atomic-context bug in ip6_convert_metrics() To: Jia-Ju Bai , davem@davemloft.net, kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <20180901111958.26529-1-baijiaju1990@gmail.com> From: David Ahern Message-ID: <94b1372d-43da-1a9a-9cde-40c855050552@gmail.com> Date: Mon, 3 Sep 2018 20:40:52 -0600 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180901111958.26529-1-baijiaju1990@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/1/18 5:19 AM, Jia-Ju Bai wrote: > The kernel module may sleep with holding a spinlock. > > The function call paths (from bottom to top) in Linux-4.16 are: > > [FUNC] kzalloc(GFP_KERNEL) > net/ipv6/route.c, 2430: > kzalloc in ip6_convert_metrics > net/ipv6/route.c, 2890: > ip6_convert_metrics in ip6_route_add > net/ipv6/addrconf.c, 2322: > ip6_route_add in addrconf_prefix_route > net/ipv6/addrconf.c, 3331: > addrconf_prefix_route in fixup_permanent_addr > net/ipv6/addrconf.c, 3354: > fixup_permanent_addr in addrconf_permanent_addr > net/ipv6/addrconf.c, 3358: > _raw_write_lock_bh in addrconf_permanent_addr > > To fix this bug, GFP_KERNEL is replaced with GFP_ATOMIC. > > This bug is found by my static analysis tool DSAC. No kernel change is needed. Your static analysis tool and you in sending out patches need to take into context. ip6_convert_metrics only calls kzalloc when fc_mx is set. fc_mx is only set via the RTA_METRICS attribute and only from the userspace call path. Hence, kzalloc with GFP_KERNEL is the appropriate argument.