Received: by 10.223.185.111 with SMTP id b44csp901485wrg; Fri, 9 Mar 2018 16:24:24 -0800 (PST) X-Google-Smtp-Source: AG47ELta7DOCNw0CqDjzinHlLlKlnJsIIimdaMQYaFKi4nT301qJmh9jS5Kbb+WBVbxzzTKyYV8M X-Received: by 2002:a17:902:6a17:: with SMTP id m23-v6mr327675plk.342.1520641464741; Fri, 09 Mar 2018 16:24:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520641464; cv=none; d=google.com; s=arc-20160816; b=Q4+v0KwUIiRQYgL/zq6UwrBZe0mRxl3/D14V9CbRRZHz78+Tr7bIEYqDeNa3i6SvNK oEGU6FrL5jUxv1UYK7Pl7tixFNIuG0o/Q9t5TSSFg2zOA2ZsnuzGYqPfkhme+CJ9DD4e BjtfGeo59rIZpKECMPMFXzYsaXBfry5ay4shY1utKIKxukEGooXwHH07LPjDPBtCCIh7 cFzd/uwBi7dFux76CeFC6moaQFa3/RR6nccElzdUWedmisO8FxT8DwFqya7L4wA5xU/4 HxUqJXOI+Z22JqWHxpL3+PdO9NXODzRbgg9IegoP86qnmAtxVdP/aaKTtrMvyLeE8IyY JT5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=9kRH7/ErWT5DJn23ZrTrsX2LUVqvfFfwYWAgDAN1RBE=; b=F9NbK1uYhMRYq0OABty1SVuBbBaIdl+hsjqeIKQoZrtoQF1t9eXsFxAiDXNTJ73T32 3MaREU7HVSnnmXgZTJXWgCWJZUj7NKaS7swr1RS7YwZqmLrs5r1VkkGH5HLTKIhmdTT+ ldoJQSTGLQ073MSXUa8+XHS3GDXUHGzGpcSHNikkrUUOJ/TVhA4mAZ6nEumyv4KBYUyp X2rwGe+prCXntd7qkzRC4fSh8etw6PcF5CnHyrIAE1I2FKf/xnNVYO1G3uBLtAVbbWx0 1d/PtibhFdDf0tC7A22nhdSAqifuTnzAnB3H3z9+Ze9mAanNYdxe+isBHPK5CbwlY6tq OUCQ== ARC-Authentication-Results: i=1; mx.google.com; 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 a5-v6si1714409pll.348.2018.03.09.16.24.10; Fri, 09 Mar 2018 16:24:24 -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; 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 S1751996AbeCJAXM (ORCPT + 99 others); Fri, 9 Mar 2018 19:23:12 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:40336 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933680AbeCJAXH (ORCPT ); Fri, 9 Mar 2018 19:23:07 -0500 Received: from localhost (unknown [185.236.200.248]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 8D26C11A6; Sat, 10 Mar 2018 00:23:06 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "ast@kernel.org, daniel@iogearbox.net, stable@vger.kernel.org, Eric Dumazet" , syzbot , Daniel Borkmann , Eric Dumazet Subject: [PATCH 4.9 63/65] bpf: add schedule points in percpu arrays management Date: Fri, 9 Mar 2018 16:19:03 -0800 Message-Id: <20180310001830.358238552@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180310001824.927996722@linuxfoundation.org> References: <20180310001824.927996722@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 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 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet [ upstream commit 32fff239de37ef226d5b66329dd133f64d63b22d ] syszbot managed to trigger RCU detected stalls in bpf_array_free_percpu() It takes time to allocate a huge percpu map, but even more time to free it. Since we run in process context, use cond_resched() to yield cpu if needed. Fixes: a10423b87a7e ("bpf: introduce BPF_MAP_TYPE_PERCPU_ARRAY map") Signed-off-by: Eric Dumazet Reported-by: syzbot Signed-off-by: Daniel Borkmann Signed-off-by: Greg Kroah-Hartman --- kernel/bpf/arraymap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/kernel/bpf/arraymap.c +++ b/kernel/bpf/arraymap.c @@ -20,8 +20,10 @@ static void bpf_array_free_percpu(struct { int i; - for (i = 0; i < array->map.max_entries; i++) + for (i = 0; i < array->map.max_entries; i++) { free_percpu(array->pptrs[i]); + cond_resched(); + } } static int bpf_array_alloc_percpu(struct bpf_array *array) @@ -37,6 +39,7 @@ static int bpf_array_alloc_percpu(struct return -ENOMEM; } array->pptrs[i] = ptr; + cond_resched(); } return 0;