Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1265686ybl; Tue, 13 Aug 2019 09:48:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqwJ0JOOtb3pCygjflHabLn8kxT/78PjjHt8HhXJsdY8cKRWteMouewfRKeMp+50Gpew52Uy X-Received: by 2002:a65:4505:: with SMTP id n5mr31725919pgq.301.1565714926720; Tue, 13 Aug 2019 09:48:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565714926; cv=none; d=google.com; s=arc-20160816; b=E82hH76uRf8n5bg75s8rBqAaG2Cp3zE3ts3aZ0lsXXbbfhZE2izF2vCIRO8IDySyRu 4FCCQ6KgnfkL2hCklp4QMA8KXcGSgz4U4u/dx/2ccdmxXmyn4D1jVLkAtKA/feBvtwJi lDrlcHa3LEFplP4ilj1Opd1nrJd3FqbYlLp8f1vMRozZWHFSp3Nxqt+5vIDsqIG+/XIa BHlUXgKK+n8rvsmGHh2o5Eu6kh3bs+kxx+OCNbiLbqW66LgfWZE4WjL03Sy16pmePPzL bYz3PzGLv1HboVXahKnA12Ul0rKz8zFBqCf0lR5YLAlwhUgNaNIeOPAVVK4TiswAjzcv DIIw== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=gwutMZePQAQMTk7cBw/KqulkxGEzPqnQaqzy++1lXMw=; b=n0lNlZYoinENpmhEwUD2OmPxKwJXmaXL2i5GbXWpA7RZzbekVGKMP8Udr1Ig+Q1sXg uuf+a1AjpKgG++3lkI6P5TCjxvzUQzb6OYPuzfN4l3hX2v9gMHYXHD4FGibJvckLF18C W8wo4QUPbJkgFUG9YLf6nfcnwMIHD69v4WMTzSaYRbCgjSmRES/epsvVrcKdDZqx5t4i QeggegY9xuNIw7YYeL6PCGtODxUl1Khj2uxQtzmeeuc+aK9fd/lxFbWSzWb/qTneIXy6 fiI6t9acpIaJtMDUaBWo7wjrBKYE6t2FMKq+lAfsBTzRaTdUNvkDEdMXFwAmRT/x/xUs 0EWg== 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 n6si62945473pgp.424.2019.08.13.09.48.29; Tue, 13 Aug 2019 09:48:46 -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 S1728120AbfHMP7C convert rfc822-to-8bit (ORCPT + 99 others); Tue, 13 Aug 2019 11:59:02 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:35317 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727577AbfHMP7C (ORCPT ); Tue, 13 Aug 2019 11:59:02 -0400 Received: from bigeasy by Galois.linutronix.de with local (Exim 4.80) (envelope-from ) id 1hxZCM-0001z8-BK; Tue, 13 Aug 2019 17:58:58 +0200 Date: Tue, 13 Aug 2019 17:58:58 +0200 From: Sebastian Andrzej Siewior To: Juri Lelli Cc: rostedt@goodmis.org, tglx@linutronix.de, linux-rt-users@vger.kernel.org, linux-kernel@vger.kernel.org, williams@redhat.com Subject: Re: [PATCH] net/xfrm/xfrm_ipcomp: Use {get,put}_cpu_light Message-ID: <20190813155858.e4bcbkom2vsiafhh@linutronix.de> References: <20190717072019.13681-1-juri.lelli@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8BIT In-Reply-To: <20190717072019.13681-1-juri.lelli@redhat.com> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-07-17 09:20:19 [+0200], Juri Lelli wrote: > The following BUG has been reported while running ipsec tests. … > Hi, > > This has been found on a 4.19.x-rt kernel, but 5.x-rt(s) are affected as > well. > > Best, > > Juri > --- > net/xfrm/xfrm_ipcomp.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/net/xfrm/xfrm_ipcomp.c b/net/xfrm/xfrm_ipcomp.c > index a00ec715aa46..39d9e663384f 100644 > --- a/net/xfrm/xfrm_ipcomp.c > +++ b/net/xfrm/xfrm_ipcomp.c > @@ -45,7 +45,7 @@ static int ipcomp_decompress(struct xfrm_state *x, struct sk_buff *skb) > const int plen = skb->len; > int dlen = IPCOMP_SCRATCH_SIZE; > const u8 *start = skb->data; > - const int cpu = get_cpu(); > + const int cpu = get_cpu_light(); By using get_cpu_light() you don't forbid another function to invoke ipcomp_decompress() on the same CPU. That means that > u8 *scratch = *per_cpu_ptr(ipcomp_scratches, cpu); scratch buffer here could be used by two tasks on the same CPU. You are aware of that right? According to your backtrace you get here from NAPI which means BH which means it is enough to use smp_processor_id() in such a case. ipcomp_compress() is using the very same buffer while invoking local_bh_disable() before using the buffer to ensure nothing else is using the buffer on this CPU. This will work in v5.2-RT because the new softirq code uses a local_lock() as part of local_bh_disable(). This does not work on v4.19-RT and earlier. For v4.19 and earlier I suggest to use a local_lock(). For v5.2 and later I suggest to replace get_cpu() with smp_processor_id(). Ideally a with a lockdep annotation to ensure that BH is disabled (which we don't have). > struct crypto_comp *tfm = *per_cpu_ptr(ipcd->tfms, cpu); > int err = crypto_comp_decompress(tfm, start, plen, scratch, &dlen); Sebastian