Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9118698pxu; Mon, 28 Dec 2020 07:06:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJx1r6yOQ6TE0W79QZigBFXJzy/rgDut98hXEMLyfwxauAc4wGi3QZrSJ0BOU5VEg42+Ol36 X-Received: by 2002:a17:906:30c4:: with SMTP id b4mr41387685ejb.456.1609167982078; Mon, 28 Dec 2020 07:06:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609167982; cv=none; d=google.com; s=arc-20160816; b=fyhmLjL/tpfZwpqRj08MykTBBy/gyXwLBgfKzuRXPUxXje4mSEXJUd4V3vhVx0ZxBM 5cxtaZGsuJmMtnWl+e2uEHsFtGfy/kC++l+4WATGkrujmygtKnNunRqCMbfmnPlcnOnP 9vIkHkbM5EaClaovMXcdNLkxYdaU1yA1630wCCkr1xEyQQKpNCSKoTGVcpX10yMmt7M+ i6N04Npzd7S9CpotolT2QIcPd2wEB9g3U4UdO3zLTb8yLyEkTP5nnfFYQo6YCKhd3nG7 X0aiTshMOeDupceA2yoZzEgGjseWCdEMka5Oyy1IAV1eSf84lkZ4G3fDNCw7agc/f/mp eaJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VIowJ0x7pAsPk7HjEkJa1jl+0JRAjXdffmoBEwaZ56E=; b=rLWVgl4rE3239sAwp203HSlgGXXpBJ79Pa0ZVsXY3PHrqPeUjf9A4BCMTQmGufG3ks hT8p4hOViCUIGH8OiLbaKWPJ6Lpv94bB111Mde1xKKQLFoFQr7WLQA89N9vZrdVd0auX BiBXKUOesjBcXCWoPvyuzFicUG9eTBBBRc19Fa/6RAwZkqk3q9l71VGWaTjohViKj/D1 pwJkd/njhPVVFtYWQL2eUSD558WTIO6bTUz2LWzApd+rxgBEhdV34Kvx8WV1VgDP98U7 LTbnVU1vYBsaCx6x6FI5vSvFqko3MmxakF+ZkjnB5lSL+woNFvlR9HnwQZsQP3brRl/l 1riw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XN80wcoI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e8si20391090edq.377.2020.12.28.07.05.59; Mon, 28 Dec 2020 07:06:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XN80wcoI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392534AbgL1PA4 (ORCPT + 99 others); Mon, 28 Dec 2020 10:00:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:48592 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2440225AbgL1ONk (ORCPT ); Mon, 28 Dec 2020 09:13:40 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 58EBF207A9; Mon, 28 Dec 2020 14:12:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609164780; bh=5q5Y9s5C1q7o1t5RfIRykLjMtnHKqtXg45MqgLD44QY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XN80wcoIPWX64LlTmeKaZwoaB4CQMynrjqYNEt5RwHWOeXyXMz4AjJsW8hzXykqcz aWUCR+uiiRHOa1UISenGRZp+zAND5saf+2Gr2NklhhCFWtp2CTWEccldnB0mRFHeMz SQpEl9fvY1hxjbVRRYddNnpSqNkv2D5KWLEhalMQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrii Nakryiko , Alexei Starovoitov , Martin KaFai Lau , Sasha Levin Subject: [PATCH 5.10 295/717] bpf: Fix bpf_put_raw_tracepoint()s use of __module_address() Date: Mon, 28 Dec 2020 13:44:53 +0100 Message-Id: <20201228125035.159490812@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrii Nakryiko [ Upstream commit 12cc126df82c96c89706aa207ad27c56f219047c ] __module_address() needs to be called with preemption disabled or with module_mutex taken. preempt_disable() is enough for read-only uses, which is what this fix does. Also, module_put() does internal check for NULL, so drop it as well. Fixes: a38d1107f937 ("bpf: support raw tracepoints in modules") Signed-off-by: Andrii Nakryiko Signed-off-by: Alexei Starovoitov Acked-by: Martin KaFai Lau Link: https://lore.kernel.org/bpf/20201203204634.1325171-2-andrii@kernel.org Signed-off-by: Sasha Levin --- kernel/trace/bpf_trace.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c index a125ea5e04cd7..0dde84b9d29fe 100644 --- a/kernel/trace/bpf_trace.c +++ b/kernel/trace/bpf_trace.c @@ -2041,10 +2041,12 @@ struct bpf_raw_event_map *bpf_get_raw_tracepoint(const char *name) void bpf_put_raw_tracepoint(struct bpf_raw_event_map *btp) { - struct module *mod = __module_address((unsigned long)btp); + struct module *mod; - if (mod) - module_put(mod); + preempt_disable(); + mod = __module_address((unsigned long)btp); + module_put(mod); + preempt_enable(); } static __always_inline -- 2.27.0