Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp965183pxb; Fri, 22 Jan 2021 03:58:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJxT5ieYsGknd/HJHbMb+JO0iyoIxDR2ULbeL5zJN0z96HN06LG4hhdjnbWAzff/lBkxKsQJ X-Received: by 2002:a05:6402:94f:: with SMTP id h15mr2887397edz.106.1611316705594; Fri, 22 Jan 2021 03:58:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611316705; cv=none; d=google.com; s=arc-20160816; b=p8oYB59627qSpgS1/z2YRH50xAaasgvbq92PJmYU06BDUWd3KikqWK89W6oB8jZ07m pEBNrOKYvOWMNU3eRkBX/ZWnrxQAIEUmidLwazinVLFtdYO8DIDihAj/reXGfa4GnthT RtcQUG0kYUQiCzZxQ1UuRAjAJFVuU/tk8VJ8i6fOK232itrFkAO1i84BUVqJd9k+OnHf zBI1dLrv+abTifwq+lTPpaaAABulczCjfy/Q3GdNJouVnYMo09dAzIRr0sZQ7D8VnQOn IVsF95YH8uaR0dl7P6BQZFxByax9MeV8y55NAcTmqtIyvHiSPvUQDo/BCmRa85IkGxIW rtTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=SCnaF15EPNrfgrK6dBdeC8tlww9WLBPjwWjE6RDsogo=; b=1LAmciph0u6G7CXcr9R9Am4QTEuIGUOhxxsYwmEjP6C2U6Bl+FZ5CNZEHbgqSZ1AeP jGiP1lwXY4xxngFC3PpEgWUn2otkcgyaW4yNaZDmOsDgJP207Jdp5F3Y++41q1HltKmj EwEgCCOvpwyguf+vSkcQ8ByFnmSohFLzczqJfd5fo6tLi/Zol/xmunjTLKrc1Z6eDGHq x22eGqmjFV3tEUrK9TzlkW+IHF8YA/FihTEuV+e5O09Vyb13/Xdm+SGai6zOOUL5v+pP z65gjVRMdfjxdxLQB5jfXysWW5sNA5rybcowzIDJfA/ysWN2+0Nf2yrQxh0r4nFHDkPy MjAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wgQTA9L3; 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 v12si3365733edy.585.2021.01.22.03.58.02; Fri, 22 Jan 2021 03:58:25 -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=wgQTA9L3; 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 S1727401AbhAVLzT (ORCPT + 99 others); Fri, 22 Jan 2021 06:55:19 -0500 Received: from mail.kernel.org ([198.145.29.99]:53372 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728062AbhAVLAL (ORCPT ); Fri, 22 Jan 2021 06:00:11 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2CF57235DD; Fri, 22 Jan 2021 10:59:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1611313169; bh=WOPhFI7l2O3aeqpheaCHgCUoNQOnVQEkGsb/DxneUks=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=wgQTA9L39OsGUBukWkkW9DfHGP5Vl53tTNpJxLQ4g94TxA1WMjFVOw14gHaUJSogG y5lnF8LFKXHC3v505MEX2V8o61f+fO6NsjEQgpKI8P4ukJPnc42HR9jZVaLy0isqKg Bjuid1KkUf8DHsOzNDPWFvqv3Lrl9RS9eBQ6FLOA= Date: Fri, 22 Jan 2021 11:59:27 +0100 From: Greg KH To: Steven Rostedt Cc: Denis Efremov , Gaurav Kohli , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, stable@vger.kernel.org, Julia Lawall Subject: Re: [PATCH v1] trace: Fix race in trace_open and buffer resize call Message-ID: References: <1601976833-24377-1-git-send-email-gkohli@codeaurora.org> <20210121140951.2a554a5e@gandalf.local.home> <021b1b38-47ce-bc8b-3867-99160cc85523@linux.com> <20210121153732.43d7b96b@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210121153732.43d7b96b@gandalf.local.home> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 21, 2021 at 03:37:32PM -0500, Steven Rostedt wrote: > On Thu, 21 Jan 2021 23:15:22 +0300 > Denis Efremov wrote: > > > On 1/21/21 10:09 PM, Steven Rostedt wrote: > > > On Thu, 21 Jan 2021 17:30:40 +0300 > > > Denis Efremov wrote: > > > > > >> Hi, > > >> > > >> This patch (CVE-2020-27825) was tagged with > > >> Fixes: b23d7a5f4a07a ("ring-buffer: speed up buffer resets by avoiding synchronize_rcu for each CPU") > > >> > > >> I'm not an expert here but it seems like b23d7a5f4a07a only refactored > > >> ring_buffer_reset_cpu() by introducing reset_disabled_cpu_buffer() without > > >> significant changes. Hence, mutex_lock(&buffer->mutex)/mutex_unlock(&buffer->mutex) > > >> can be backported further than b23d7a5f4a07a~ and to all LTS kernels. Is > > >> b23d7a5f4a07a the actual cause of the bug? > > >> > > > > > > Ug, that looks to be a mistake. Looking back at the thread about this: > > > > > > https://lore.kernel.org/linux-arm-msm/20200915141304.41fa7c30@gandalf.local.home/ > > > > I see from the link that it was planned to backport the patch to LTS kernels: > > > > > Actually we are seeing issue in older kernel like 4.19/4.14/5.4 and there below patch was not > > > present in stable branches: > > > Commit b23d7a5f4a07 ("ring-buffer: speed up buffer resets by avoiding synchronize_rcu for each CPU") > > > > The point is that it's not backported yet. Maybe because of Fixes tag. I've discovered > > this while trying to formalize CVE-2020-27825 bug in cvehound > > https://github.com/evdenis/cvehound/blob/master/cvehound/cve/CVE-2020-27825.cocci > > > > I think that the backport to the 4.4+ should be something like: > > > > diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c > > index 547a3a5ac57b..2171b377bbc1 100644 > > --- a/kernel/trace/ring_buffer.c > > +++ b/kernel/trace/ring_buffer.c > > @@ -4295,6 +4295,8 @@ void ring_buffer_reset_cpu(struct ring_buffer *buffer, int cpu) > > if (!cpumask_test_cpu(cpu, buffer->cpumask)) > > return; > > > > + mutex_lock(&buffer->mutex); > > + > > atomic_inc(&buffer->resize_disabled); > > atomic_inc(&cpu_buffer->record_disabled); > > > > @@ -4317,6 +4319,8 @@ void ring_buffer_reset_cpu(struct ring_buffer *buffer, int cpu) > > > > atomic_dec(&cpu_buffer->record_disabled); > > atomic_dec(&buffer->resize_disabled); > > + > > + mutex_unlock(&buffer->mutex); > > } > > EXPORT_SYMBOL_GPL(ring_buffer_reset_cpu); > > > > That could possibly work. Ok, so what can I do here? Can someone resend this as a backport to the other stable kernels in this way so that I can queue it up? thanks, greg k-h