Subject: Re: [PATCH] ipipe: Avoid recursive faults on root work overflow References: From: Jan Kiszka Message-ID: <60b53af5-352f-b4ee-089e-961616896fda@siemens.com> Date: Thu, 1 Jul 2021 11:01:59 +0200 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: Discussions about the Xenomai project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Xenomai , Greg Gallagher On 01.07.21 09:19, Jan Kiszka via Xenomai wrote: > From: Jan Kiszka > > On some archs, WARN* is implemented by triggering a fault. This can > cause troubles if we are already in a fault and try to submit too much > root work. Convert to open-coded warning and stack dump. > > Signed-off-by: Jan Kiszka > --- > > Doesn't solve the overflow you've seen, Mauro, but should give a better > hint. > > kernel/ipipe/core.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/kernel/ipipe/core.c b/kernel/ipipe/core.c > index 99a88e4d620e..485db973b81b 100644 > --- a/kernel/ipipe/core.c > +++ b/kernel/ipipe/core.c > @@ -2027,9 +2027,16 @@ void __ipipe_post_work_root(struct ipipe_work_header *work) > cpu = ipipe_processor_id(); > tail = per_cpu(work_tail, cpu); > > - if (WARN_ON_ONCE((unsigned char *)tail + work->size >= > - per_cpu(work_buf, cpu) + WORKBUF_SIZE)) > + if (unlikely((unsigned char *)tail + work->size >= > + per_cpu(work_buf, cpu) + WORKBUF_SIZE)) { > + static volatile unsigned long once; > + if (!test_and_set_bit(0, &once)) { > + ipipe_prepare_panic(); > + pr_err("I-pipe root work queue overflow! System may be unstable now.\n"); > + dump_stack(); > + } > goto out; > + } > > /* Work handling is deferred, so data has to be copied. */ > memcpy(tail, work, work->size); > Possibly relevant for ARM/64 as well. Patch is in 4.19 and head noarch trees now. Jan -- Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux