From patchwork Thu Apr 21 23:36:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12822494 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54FF1C433F5 for ; Thu, 21 Apr 2022 23:36:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DFD626B0082; Thu, 21 Apr 2022 19:36:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DAE706B0083; Thu, 21 Apr 2022 19:36:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C73EF6B0085; Thu, 21 Apr 2022 19:36:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.26]) by kanga.kvack.org (Postfix) with ESMTP id B8E796B0082 for ; Thu, 21 Apr 2022 19:36:09 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 8F1BD60279 for ; Thu, 21 Apr 2022 23:36:09 +0000 (UTC) X-FDA: 79382496858.01.CDBFAFC Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf21.hostedemail.com (Postfix) with ESMTP id A617F1C0024 for ; Thu, 21 Apr 2022 23:36:07 +0000 (UTC) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 9062161EB9; Thu, 21 Apr 2022 23:36:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7E09C385A7; Thu, 21 Apr 2022 23:36:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1650584168; bh=IeHWkgVqOFZYBcD3UCEb6fsykXZrS6zVdkxAwURYZ8o=; h=Date:To:From:In-Reply-To:Subject:From; b=hWKhkPcddd81NiKFF2uKb+B8tduVIelemb/cNJk9mwRYCh7JZ81wSHbwyjP6Jjtq6 ER+TqT30mv4XUjKpRX4TjCGQtqxFkeC1cxQjeFp3uC1Afo4sLzBysb42faNHyq6G0f dKj6KhalQPdGZpNs/3c2hmkDTsCh9HbKpZgkbvdA= Date: Thu, 21 Apr 2022 16:36:07 -0700 To: tarasmadan@google.com,glider@google.com,elver@google.com,dvyukov@google.com,bigeasy@linutronix.de,andreyknvl@gmail.com,nogikh@google.com,akpm@linux-foundation.org,patches@lists.linux.dev,linux-mm@kvack.org,mm-commits@vger.kernel.org,torvalds@linux-foundation.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20220421163508.66028a9ac2d9fb6ea05b1342@linux-foundation.org> Subject: [patch 12/13] kcov: don't generate a warning on vm_insert_page()'s failure Message-Id: <20220421233607.E7E09C385A7@smtp.kernel.org> X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: A617F1C0024 X-Stat-Signature: jt114m85asn9mbsec3qzyht4f7setrhm Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=hWKhkPcd; dmarc=none; spf=pass (imf21.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-HE-Tag: 1650584167-140531 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Aleksandr Nogikh Subject: kcov: don't generate a warning on vm_insert_page()'s failure vm_insert_page()'s failure is not an unexpected condition, so don't do WARN_ONCE() in such a case. Instead, print a kernel message and just return an error code. This flaw has been reported under an OOM condition by sysbot (https://lkml.kernel.org/r/Ylkr2xrVbhQYwNLf@elver.google.com). The message is mainly for the benefit of the test log, in this case the fuzzer's log so that humans inspecting the log can figure out what was going on. KCOV is a testing tool, so I think being a little more chatty when KCOV unexpectedly is about to fail will save someone debugging time. We don't want the WARN, because it's not a kernel bug that syzbot should report, and failure can happen if the fuzzer tries hard enough (as above). Link: https://lkml.kernel.org/r/20220401182512.249282-1-nogikh@google.com Fixes: b3d7fe86fbd0 ("kcov: properly handle subsequent mmap calls"), Signed-off-by: Aleksandr Nogikh Acked-by: Marco Elver Cc: Dmitry Vyukov Cc: Andrey Konovalov Cc: Alexander Potapenko Cc: Taras Madan Cc: Sebastian Andrzej Siewior Signed-off-by: Andrew Morton --- kernel/kcov.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/kernel/kcov.c~kcov-dont-generate-a-warning-on-vm_insert_pages-failure +++ a/kernel/kcov.c @@ -475,8 +475,11 @@ static int kcov_mmap(struct file *filep, vma->vm_flags |= VM_DONTEXPAND; for (off = 0; off < size; off += PAGE_SIZE) { page = vmalloc_to_page(kcov->area + off); - if (vm_insert_page(vma, vma->vm_start + off, page)) - WARN_ONCE(1, "vm_insert_page() failed"); + res = vm_insert_page(vma, vma->vm_start + off, page); + if (res) { + pr_warn_once("kcov: vm_insert_page() failed\n"); + return res; + } } return 0; exit: