Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp7454108ybp; Wed, 16 Oct 2019 08:54:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqwIZON5F0EhE0QZz9j9y8IpKowXmkg2zQ2TFifoDjPRXFPfy+iGeQEUNS4bdYvJF0qBDQ5c X-Received: by 2002:a17:906:7202:: with SMTP id m2mr39876489ejk.138.1571241244239; Wed, 16 Oct 2019 08:54:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571241244; cv=none; d=google.com; s=arc-20160816; b=PzkDeA7mEtbDUOBUZjnopYq9VfNmx4n8RulZIStUaFfA87IxY0KL21ZdCWzIeRQrS1 Viwhw+TW3lRVKLvpUx4RUBl3wKWIAEAfixT0JEgloLxpFjz6DeQUklDsC6aBQaA9KLld LLACbo56K1gsIJZscnRG+999vqtAclL+qCwM5UfEckjx7QB0VRiOqgAbIYs/K2eQ+WlD 3aN/2V2tWe1oVeCF9L1ooZRXIRz+KCSbPPCi8/5aTS2xzUO3YA3jIaI2lyX/XWTCRK3a skRu5I+6q+B7dGI/WigMITm7E0Ma3Ct9fQ1GECtCz7m7xSL3UgqcdPG0yzFGBDKsM3bG x2qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=VAPCanOinmcpiV6ar1pxm65pqi0HDLH+JLryIKvtM5k=; b=GbqyeV4uaXtbYIdoeASeZre9c8zJc3oLF/UvuvxMQcrTnqCeRlb+cWHsSS+qmW6Scg spPsw1STuB1KZwedirudgDr2HfhmU0NTL2cdh8FbPs8Bn+pvl0XtcHvAg+gFRr4wWJFV Ux14eLMwE2+OIPen7dh+KQoMKBtbxvfa8TLwNvXeMWCNt9HKgq3dD5e9rJIusa81Q5W9 eW5bqpFmolrxt2gZ+yGmyetcoaxagB7rompQn7HyS8PLnRchRt1n6EbQ0GU6D+ej+wZa tNFvkXa/zSiPCZp+1j1Cp4W9Po+gnu2CGIdI7I1BVdRzuggjZkWE0Ro/OSy731aqqnvF 6lVw== 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 ck18si15214429ejb.300.2019.10.16.08.53.41; Wed, 16 Oct 2019 08:54:04 -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; 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 S2393350AbfJPMvC (ORCPT + 99 others); Wed, 16 Oct 2019 08:51:02 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:42233 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405231AbfJPMuj (ORCPT ); Wed, 16 Oct 2019 08:50:39 -0400 Received: from [213.220.153.21] (helo=wittgenstein) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1iKil0-0001Ie-TU; Wed, 16 Oct 2019 12:50:26 +0000 Date: Wed, 16 Oct 2019 14:50:26 +0200 From: Christian Brauner To: Michael Ellerman Cc: cyphar@cyphar.com, mingo@redhat.com, peterz@infradead.org, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org, christian@brauner.io, keescook@chromium.org, linux@rasmusvillemoes.dk, viro@zeniv.linux.org.uk, torvalds@linux-foundation.org, linux-api@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] usercopy: Avoid soft lockups in test_check_nonzero_user() Message-ID: <20191016125025.ktxe55l4doirbxbe@wittgenstein> References: <20191011022447.24249-1-mpe@ellerman.id.au> <20191016122732.13467-1-mpe@ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20191016122732.13467-1-mpe@ellerman.id.au> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 16, 2019 at 11:27:32PM +1100, Michael Ellerman wrote: > On a machine with a 64K PAGE_SIZE, the nested for loops in > test_check_nonzero_user() can lead to soft lockups, eg: > > watchdog: BUG: soft lockup - CPU#4 stuck for 22s! [modprobe:611] > Modules linked in: test_user_copy(+) vmx_crypto gf128mul crc32c_vpmsum virtio_balloon ip_tables x_tables autofs4 > CPU: 4 PID: 611 Comm: modprobe Tainted: G L 5.4.0-rc1-gcc-8.2.0-00001-gf5a1a536fa14-dirty #1151 > ... > NIP __might_sleep+0x20/0xc0 > LR __might_fault+0x40/0x60 > Call Trace: > check_zeroed_user+0x12c/0x200 > test_user_copy_init+0x67c/0x1210 [test_user_copy] > do_one_initcall+0x60/0x340 > do_init_module+0x7c/0x2f0 > load_module+0x2d94/0x30e0 > __do_sys_finit_module+0xc8/0x150 > system_call+0x5c/0x68 > > Even with a 4K PAGE_SIZE the test takes multiple seconds. Instead > tweak it to only scan a 1024 byte region, but make it cross the > page boundary. > > Fixes: f5a1a536fa14 ("lib: introduce copy_struct_from_user() helper") > Suggested-by: Aleksa Sarai > Signed-off-by: Michael Ellerman Thanks! Acked-by: Christian Brauner