Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3215702ybl; Fri, 20 Dec 2019 05:49:46 -0800 (PST) X-Google-Smtp-Source: APXvYqzcq5/id4OYMraJQY0i9WcfpdHWss6y4aya0vr6f/yYdvxfAfdjbdDWVwR5zhukMjAuoiML X-Received: by 2002:a9d:12f1:: with SMTP id g104mr15625217otg.334.1576849786790; Fri, 20 Dec 2019 05:49:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576849786; cv=none; d=google.com; s=arc-20160816; b=DbJAK2VL39/6Cc8I9lF6n8JN3odn80CZL+BD+qG5SniP+RkQBj9Wnwvuvoxm1Va3Ba d/2xlaErW9N6pQrIZgWBE9BRgR6p0Uf6c4vnPvjL4qN1EDhMjS+7YYO0TQzrxoqLwNaU UzhbuI5Q6vQ3FUIBivVdlwFnkFSRrS7dBwTf7KVOk5RfCBOTwNZCkv+UeLiujqRc4sdh x4QqtOJBW8pUNQzPXBqryg20NDtosBAjaSn6WTueHrIgIIdCZewU+tW98bDJzKzSupwi HB4/ulGpnwfF90prKXO3zEe0ntypUiaS87bMWc6d6RUUf6d3RZHp+Cs7VpApuepXS5Yi YTaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Hg5STfXorHKAxgt7CaWaH0qAIyfvoSiPfhGulZ9vBv8=; b=ocsQDru+WQBQYL4DV9Cyj2n+uy8KYvT3fPEk2g0b0jhVL2D87ZTI08Dl9IMNtH4i7t 3k34+rlU6ZE9U/1oN2+ndy5Xq/zy0bpnAtTn/b5DuHDK+HPI0tWj3YE5BKSGNWiQSFsM Zhr4tvzpR+D/beZXc5Mj3savu7AxOpAf0b+dfnAD5xiUqy8e21pedxQnuce72vA5xS4U yEL7+Fidj7jfMUW6i9xyWKc+3vnrM69Nddr6HqnYj7RAR75pyuEN7O/WxvLn6PbQLGkJ AIe7w0wz0r0D0EuFfo8FUITxfeXywqOSP5kf9yYLSEQWOrBjcaySL+m2Fdf5/UrMhA6n bubA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=lT23K32L; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s65si4719133otb.260.2019.12.20.05.49.32; Fri, 20 Dec 2019 05:49:46 -0800 (PST) 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=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=lT23K32L; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727388AbfLTNsU (ORCPT + 99 others); Fri, 20 Dec 2019 08:48:20 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:44713 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727344AbfLTNsU (ORCPT ); Fri, 20 Dec 2019 08:48:20 -0500 Received: by mail-lj1-f194.google.com with SMTP id u71so10063914lje.11 for ; Fri, 20 Dec 2019 05:48:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Hg5STfXorHKAxgt7CaWaH0qAIyfvoSiPfhGulZ9vBv8=; b=lT23K32LbiDEbYb65nadstYYsp2GiYsKzxqGzErTJn8D52OkkMPTdyzYQmzvl9+RUq 3IjIaJUk/J4ocH88aoRlpeiLQuEnhYp6eQz9lh4845y4VzNHX2qtvjqJz4PFe5ncz1+H PdifeQDe3K0qQoK4/go4kXEzajBzlAn3rKdqb6Pr1HFiqXpyvDXWvyWBJ6RLTaSCxQR8 Gmi0DXs3hsJffLRbQAk79csR8QPO8zkpuiuPcqcwAFSUG35fqQGsMWA3jaD+kjDRDQ/Z u2vOXQ/saHm1m9izdWVHbOUM+ZJI2nceZx16OUbaNqS3d+xClCSTcamoABNPbNRE/Mh7 x8NQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Hg5STfXorHKAxgt7CaWaH0qAIyfvoSiPfhGulZ9vBv8=; b=bXnElVON+NADOR3r8+/HvP4uE64/T7lZRw+pmJlPB9PznagvUCuXbdCvyj0Zu9EoCj JqeA/Xl2dvnVmY1V6N8sUTjVDgfgeiFfUcjIVWYtnxk3c8DqxHZP7IeXKDWK00paFZge WZeR2mvE0oU02k+EblWnj7hEP0O73ls2eJzgvUW9UyPiFoH4mYjUi8pPuoGos9Cvw9ji L71cqc1WoxP2d+jfmByfU/bpCp62e+3aMlCKKhHekbCIByw2SVr2kghmSzk3n4A0NMoh LT3Wwx9qjeW1oJiZLgs/Lp6em0KXwNeqIi6oySpsscxUtM1+OlS6qHoO9amnRwUzBr/m z7gQ== X-Gm-Message-State: APjAAAWAmcR838D1eUjVuh8uCcBJ1D6MvgeYYerP6V2ZwGER1OIt4ytz JqWUYmiLtFl4mazamasBT5OsMptxPE6iN18cyJQX X-Received: by 2002:a2e:8188:: with SMTP id e8mr3316742ljg.57.1576849697917; Fri, 20 Dec 2019 05:48:17 -0800 (PST) MIME-Version: 1.0 References: <1576836441-4140-1-git-send-email-yanghui.def@gmail.com> In-Reply-To: <1576836441-4140-1-git-send-email-yanghui.def@gmail.com> From: Paul Moore Date: Fri, 20 Dec 2019 08:48:06 -0500 Message-ID: Subject: Re: [PATCH] netnode.c : fix sel_netnode_hash be destroyed To: hui yang Cc: Stephen Smalley , Eric Paris , selinux@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 20, 2019 at 5:07 AM hui yang wrote: > From: YangHui > > we often find below error : > [ 30.729718] Unable to handle kernel paging request at virtual address fffffffffffffffc > [ 30.747478] Kernel BUG at sel_netnode_find+0x6c/0xf0 [verbose debug info unavailable] > [ 30.818858] PC is at sel_netnode_find+0x6c/0xf0 > [ 30.824671] LR is at sel_netnode_sid+0x3c/0x248 > [ 30.829170] pc : [] lr : [] pstate: a0400145 > [ 30.833701] sp : ffffffc026f27c50 > [ 30.841319] x29: ffffffc026f27c50 x28: ffffffc026f27e40 > [ 30.849634] x27: ffffff8009132000 x26: 0000000000000000 > [ 30.854932] x25: ffffffc016f0aa80 x24: 0000000000000000 > [ 30.860224] x23: ffffffc026f27e38 x22: ffffffc026f27d34 > [ 30.865520] x21: 000000000000000a x20: ffffffc026f27e40 > [ 30.870818] x19: 000000000000000a x18: 0000007a13b48000 > [ 30.876118] x17: 0000007a16ca93c0 x16: ffffff8008e56b2c > [ 30.881406] x15: 0000000000000020 x14: 002dc6bffa5d9e00 > [ 30.886701] x13: 203a644974654e4c x12: 00000000000017c1 > [ 30.891997] x11: 0000000000000000 x10: 0000000000000001 > [ 30.897292] x9 : 0000000000000002 x8 : ffffff8009933090 > [ 30.902588] x7 : ffffffc0725fd090 x6 : 0000000004fd9f2c > [ 30.907881] x5 : 0000000000000000 x4 : 0000000000000000 > [ 30.913176] x3 : 00000001ffffffff x2 : 0000000000000000 > [ 30.918475] x1 : ffffff800a10ca80 x0 : ffffffffffffffe8 > some sel_netnode_hash[idx].list==NULL,so happend this. > I add spin_lock_bh on sel_netnode_init. > > Signed-off-by: YangHui > --- > security/selinux/netnode.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/security/selinux/netnode.c b/security/selinux/netnode.c > index 9ab84ef..aa0eeb7 100644 > --- a/security/selinux/netnode.c > +++ b/security/selinux/netnode.c > @@ -293,11 +293,12 @@ static __init int sel_netnode_init(void) > > if (!selinux_enabled) > return 0; > - > + spin_lock_bh(&sel_netnode_lock); > for (iter = 0; iter < SEL_NETNODE_HASH_SIZE; iter++) { > INIT_LIST_HEAD(&sel_netnode_hash[iter].list); > sel_netnode_hash[iter].size = 0; > } > + spin_unlock_bh(&sel_netnode_lock); > > return 0; > } I'm confused as to why this patch solved your problem. The sel_netnode_init() function is only run once during early boot and there shouldn't be any other threads trying to access the netnode cache at this point. Can you explain the conditions under which you see this problem? What kernel are you using (stock distro kernel? upstream? Android?)? Can you reproduce this problem? Can you provide source code line numbers associated with the func/offset lines in the backtrace above? -- paul moore www.paul-moore.com