From patchwork Mon Oct 28 01:08:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrii Nakryiko X-Patchwork-Id: 13852775 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 8C415D13590 for ; Mon, 28 Oct 2024 01:09:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 18D346B0095; Sun, 27 Oct 2024 21:09:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 13A8D6B0096; Sun, 27 Oct 2024 21:09:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E81B96B0098; Sun, 27 Oct 2024 21:09:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id B832B6B0095 for ; Sun, 27 Oct 2024 21:09:18 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 8FE211A1D42 for ; Mon, 28 Oct 2024 01:08:38 +0000 (UTC) X-FDA: 82721226924.23.5462835 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf27.hostedemail.com (Postfix) with ESMTP id B3FF440003 for ; Mon, 28 Oct 2024 01:08:53 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=hHZTZEzL; spf=pass (imf27.hostedemail.com: domain of andrii@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=andrii@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1730077599; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=VNfE2dhpfJDeCKjiK8JyTgTQKSCpEFH7HHO0t/e8HY0=; b=w/mEFprFAUhV3bh8F7/buqnmzIYObGMoKSvWGWRCSywS7dGg8SJCaCYBsO9627BhJu7ZpX GPbWALkdFJUhSaGrtiJpskCkoCklFf7fppJSNl/v5wUW+/Nhm1LUy15iEYKe1cnEA2nAri oNPOkBBhof9dvLJWj5zAWBiiKM7QHs0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730077599; a=rsa-sha256; cv=none; b=2sIS+286BA6TNw4b5dkr5QtAdkux/XGYV2Z4PNC7Xy4LTG9bbMBJm5xDG8indf0vI/MS6W 5F56ScMUQIj/E0f+szbCsuJymHu1rZwGjnFySIWyl0KG/zMEEXTuNBGJv4k667CRe6ZweK N3kd0F/IsJH/MyPxIiqVA1dLI0/ITsg= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=hHZTZEzL; spf=pass (imf27.hostedemail.com: domain of andrii@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=andrii@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id E8E295C49C1; Mon, 28 Oct 2024 01:08:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B52B2C4CEC3; Mon, 28 Oct 2024 01:09:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730077755; bh=d0t2KdzFB54YqijRSkN8zgCUkKArImLR1/o5M57T+Y4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hHZTZEzLr1iL3FHbaDuT4QMbEbbJCKfdJHak1Cphw3Io7OVy4N+9xviZFpn66aI1f PlJOkge1nFNeUdTsUnrOMPN1hqSeV1o0gMm9Lg/U2BhrunABIRUiRijxF0F2+CkU8d v58avLtFpLU/wQJTBPSWS4XGJpq96/WS8igjo7MUUUodF4yAQ3kroN4bJHsKngkHlT l8xJpHr70NPY6NK78bXQv05YYUiquo6oYCTtSTdJKylBEBOTHst9WNjrRy8s45NIDO bgUj7V6k42jCxv/1X9EWh7uooH0Cih40WwIP7W2TzNwQMR6cvih5Yu9jll42E3zSyv TwSiGKYcMRJ4g== From: Andrii Nakryiko To: linux-trace-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, peterz@infradead.org Cc: oleg@redhat.com, rostedt@goodmis.org, mhiramat@kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, jolsa@kernel.org, paulmck@kernel.org, willy@infradead.org, surenb@google.com, mjguzik@gmail.com, brauner@kernel.org, jannh@google.com, mhocko@kernel.org, vbabka@suse.cz, shakeel.butt@linux.dev, hannes@cmpxchg.org, Liam.Howlett@oracle.com, lorenzo.stoakes@oracle.com, david@redhat.com, arnd@arndb.de, richard.weiyang@gmail.com, zhangpeng.00@bytedance.com, linmiaohe@huawei.com, viro@zeniv.linux.org.uk, hca@linux.ibm.com, Andrii Nakryiko Subject: [PATCH v4 tip/perf/core 3/4] uprobes: simplify find_active_uprobe_rcu() VMA checks Date: Sun, 27 Oct 2024 18:08:17 -0700 Message-ID: <20241028010818.2487581-4-andrii@kernel.org> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241028010818.2487581-1-andrii@kernel.org> References: <20241028010818.2487581-1-andrii@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: B3FF440003 X-Stat-Signature: 84dbaq3x8qkscsenydpf8irkugdzjp98 X-HE-Tag: 1730077733-624912 X-HE-Meta: U2FsdGVkX1/CH/99zL1rz8DCAclaj3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n7SKR/b6h/NhQ6+XN3S7tOTBFUYMx1MuowDe9uu/fd2errUTxqTl6gH3+j3vu1u/84aJXIW7QtnP4A2yWhC5Aj3UK2UYmRW6LIoLNfCeNpmp70X8fJ+IOxErj0HIQ1imOSjlAycvIpRIVfWHHfI0doPuEdZI3dbnPs04U6c64r3R09mZ4Af42qNDzwpQsuAZ/Y3L/LvJ8HM+qH/N9zlDhdxby+P5mMYok3y+QxHgzoHLMcOMOTAQAddFWcE2lqjvA0h04DZBGHpH6ZiHSpA== 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: List-Subscribe: List-Unsubscribe: At the point where find_active_uprobe_rcu() is used we know that VMA in question has triggered software breakpoint, so we don't need to validate vma->vm_flags. Keep only vma->vm_file NULL check. Acked-by: Oleg Nesterov Suggested-by: Oleg Nesterov Signed-off-by: Andrii Nakryiko Reviewed-by: Masami Hiramatsu (Google) --- kernel/events/uprobes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index 4ef4b51776eb..290c445768fa 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c @@ -2084,7 +2084,7 @@ static struct uprobe *find_active_uprobe_rcu(unsigned long bp_vaddr, int *is_swb mmap_read_lock(mm); vma = vma_lookup(mm, bp_vaddr); if (vma) { - if (valid_vma(vma, false)) { + if (vma->vm_file) { struct inode *inode = file_inode(vma->vm_file); loff_t offset = vaddr_to_offset(vma, bp_vaddr);