From patchwork Mon Feb 28 17:23:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 547107 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66CADC433FE for ; Mon, 28 Feb 2022 17:47:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235921AbiB1Rsc (ORCPT ); Mon, 28 Feb 2022 12:48:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239034AbiB1RsB (ORCPT ); Mon, 28 Feb 2022 12:48:01 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D7F9A0BD4; Mon, 28 Feb 2022 09:38:24 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 8D74FB815A6; Mon, 28 Feb 2022 17:38:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3203C340E7; Mon, 28 Feb 2022 17:38:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069902; bh=DPJAuAPFM8K/Q36q1OmOYafTxEDA+plBeNeaVns3Bl8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=arzL1d9ETt2yC1WOmAqpUc6taXuPuTLo/+2sx1ZCLJTBptqSZf4BaUQ/e/mEFNtDZ m14+PiI+ouPsqJvuyzyoHzzpKTye1CtK0j9hnIpTwfY3Nm1nYVFhnifyYQStz28qV5 pgkAsCA+FiM3EwRjtEzDoYFaUylHDcfQH7k12PgM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot , Eric Dumazet , Alexei Starovoitov , Stanislav Fomichev , Brian Vazquez Subject: [PATCH 5.15 054/139] bpf: Add schedule points in batch ops Date: Mon, 28 Feb 2022 18:23:48 +0100 Message-Id: <20220228172353.386435815@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172347.614588246@linuxfoundation.org> References: <20220228172347.614588246@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Eric Dumazet commit 75134f16e7dd0007aa474b281935c5f42e79f2c8 upstream. syzbot reported various soft lockups caused by bpf batch operations. INFO: task kworker/1:1:27 blocked for more than 140 seconds. INFO: task hung in rcu_barrier Nothing prevents batch ops to process huge amount of data, we need to add schedule points in them. Note that maybe_wait_bpf_programs(map) calls from generic_map_delete_batch() can be factorized by moving the call after the loop. This will be done later in -next tree once we get this fix merged, unless there is strong opinion doing this optimization sooner. Fixes: aa2e93b8e58e ("bpf: Add generic support for update and delete batch ops") Fixes: cb4d03ab499d ("bpf: Add generic support for lookup batch op") Reported-by: syzbot Signed-off-by: Eric Dumazet Signed-off-by: Alexei Starovoitov Reviewed-by: Stanislav Fomichev Acked-by: Brian Vazquez Link: https://lore.kernel.org/bpf/20220217181902.808742-1-eric.dumazet@gmail.com Signed-off-by: Greg Kroah-Hartman --- kernel/bpf/syscall.c | 3 +++ 1 file changed, 3 insertions(+) --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -1337,6 +1337,7 @@ int generic_map_delete_batch(struct bpf_ maybe_wait_bpf_programs(map); if (err) break; + cond_resched(); } if (copy_to_user(&uattr->batch.count, &cp, sizeof(cp))) err = -EFAULT; @@ -1394,6 +1395,7 @@ int generic_map_update_batch(struct bpf_ if (err) break; + cond_resched(); } if (copy_to_user(&uattr->batch.count, &cp, sizeof(cp))) @@ -1491,6 +1493,7 @@ int generic_map_lookup_batch(struct bpf_ swap(prev_key, key); retry = MAP_LOOKUP_RETRIES; cp++; + cond_resched(); } if (err == -EFAULT)