From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E6663C35294 for ; Mon, 7 Feb 2022 11:39:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386693AbiBGLfY (ORCPT ); Mon, 7 Feb 2022 06:35:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384086AbiBGLYl (ORCPT ); Mon, 7 Feb 2022 06:24:41 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AA3AC043181; Mon, 7 Feb 2022 03:24:41 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 290E7B81028; Mon, 7 Feb 2022 11:24:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 52033C004E1; Mon, 7 Feb 2022 11:24:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233079; bh=KA0v6uzmrpCq8CZngEmIzixkjPkWni2L1J8EWKJLKg4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aygwEb0CYYhKshccfKdNiK32+hxkZCKTEm+rUhreEzTrl8LE4S7c8qDzrYa1tyQT6 5dHwo09gmohfI+/JMtA/mTXNbneUHeYAmt7keorf7Mtbl8KdvdVFc7QmKsGaYf3kMt I4+DPf2W5U6NfFqNHFvt6AGeSowi75xjQ4iCP9ec= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , Uma Shankar , Mario Kleiner Subject: [PATCH 5.15 001/110] drm/i915: Disable DSB usage for now Date: Mon, 7 Feb 2022 12:05:34 +0100 Message-Id: <20220207103802.334366967@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ville Syrj=C3=A4l=C3=A4 commit 99510e1afb4863a225207146bd988064c5fd0629 upstream. Turns out the DSB has trouble correctly loading the gamma LUT. >From a cursory look maybe like some entries do not load properly, or they get loaded with some gibberish. Unfortunately our current kms_color/etc. tests do not seem to catch this. I had a brief look at the generated DSB batch and it looked correct. Tried a few quick tricks like writing the index register twice/etc. but didn't see any improvement. Also tried switching to the 10bit gamma mode in case there is yet another issue with the multi-segment mode, but even the 10bit mode was showing issues. Switching to mmio fixes all of it. I suppose one theory is that maybe the DSB bangs on the LUT too quickly and it can't keep up and instead some data either gets dropped or corrupted. To confirm that someone should try to slow down the DSB's progress a bit. Another thought was that maybe the LUT has crappy dual porting and you get contention if you try to load it during active scanout. But why then would the mmio path work, unless it's just sufficiently slow? Whatever the case, this is currently busted so let's disable it until we get to the root of the problem. Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/3916 Signed-off-by: Ville Syrj=C3=A4l=C3=A4 Link: https://patchwork.freedesktop.org/patch/msgid/20211014181856.17581-2-= ville.syrjala@linux.intel.com Reviewed-by: Uma Shankar Cc: Mario Kleiner Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/gpu/drm/i915/i915_pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/gpu/drm/i915/i915_pci.c +++ b/drivers/gpu/drm/i915/i915_pci.c @@ -865,7 +865,7 @@ static const struct intel_device_info js }, \ TGL_CURSOR_OFFSETS, \ .has_global_mocs =3D 1, \ - .display.has_dsb =3D 1 + .display.has_dsb =3D 0 /* FIXME: LUT load is broken with DSB */ =20 static const struct intel_device_info tgl_info =3D { GEN12_FEATURES, From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C1DEC4167E for ; Mon, 7 Feb 2022 11:39:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386146AbiBGLdr (ORCPT ); Mon, 7 Feb 2022 06:33:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232134AbiBGLZC (ORCPT ); Mon, 7 Feb 2022 06:25:02 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFD92C043181; Mon, 7 Feb 2022 03:24:56 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 6C312B811A6; Mon, 7 Feb 2022 11:24:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7CBABC004E1; Mon, 7 Feb 2022 11:24:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233094; bh=CEnQ53IN8cOKxoel8rwqWyPAl4pA6ktgqF4J4Ryl9Jk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X3XprcwV1uNt4TCEZbOi5AAD4fGOUi2LyE4X1kgbr0uPSJf9DaM1i9GFeevMUT+QL EN1VeTChBxnUJQTjhxQ4+1/fHvWW1e8ExK3BrjgbFIICgu+NQ11j+Tog0Cm+TWvnwe QPua4pJHNMEBDOzzE6kYhpe5KoTlTp5TtelUEck4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vratislav Bendel , Paul Moore Subject: [PATCH 5.15 002/110] selinux: fix double free of cond_list on error paths Date: Mon, 7 Feb 2022 12:05:35 +0100 Message-Id: <20220207103802.364896619@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Vratislav Bendel commit 186edf7e368c40d06cf727a1ad14698ea67b74ad upstream. On error path from cond_read_list() and duplicate_policydb_cond_list() the cond_list_destroy() gets called a second time in caller functions, resulting in NULL pointer deref. Fix this by resetting the cond_list_len to 0 in cond_list_destroy(), making subsequent calls a noop. Also consistently reset the cond_list pointer to NULL after freeing. Cc: stable@vger.kernel.org Signed-off-by: Vratislav Bendel [PM: fix line lengths in the description] Signed-off-by: Paul Moore Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- security/selinux/ss/conditional.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/security/selinux/ss/conditional.c +++ b/security/selinux/ss/conditional.c @@ -152,6 +152,8 @@ static void cond_list_destroy(struct pol for (i =3D 0; i < p->cond_list_len; i++) cond_node_destroy(&p->cond_list[i]); kfree(p->cond_list); + p->cond_list =3D NULL; + p->cond_list_len =3D 0; } =20 void cond_policydb_destroy(struct policydb *p) @@ -441,7 +443,6 @@ int cond_read_list(struct policydb *p, v return 0; err: cond_list_destroy(p); - p->cond_list =3D NULL; return rc; } =20 From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E3E1C433EF for ; Mon, 7 Feb 2022 11:39:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386161AbiBGLdt (ORCPT ); Mon, 7 Feb 2022 06:33:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233007AbiBGLZC (ORCPT ); Mon, 7 Feb 2022 06:25:02 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 349BBC043188; Mon, 7 Feb 2022 03:24:58 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B6B666077B; Mon, 7 Feb 2022 11:24:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8767CC004E1; Mon, 7 Feb 2022 11:24:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233097; bh=vhAEzco/UHCmcxF7QDa7KCLTLJqPXpSuTCLSQsFmnXo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IFOZmOmM3D/eHS7XTMR0jjrCYxkeqHfHM2lcOPb+i2kfIOwy9uT3RzHzc2q8Oyl/1 ZSOwc70pcEvqZAiPBl/UIOas3ToYarW6/B727a/qroFs/v3QgAt+cOmaB13fzSZ5ej EsDu2ldwTI6IXdNKsMM5eg2qOmvk2dzKXxXTEMRc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gaosheng Cui , Richard Guy Briggs , Paul Moore Subject: [PATCH 5.15 003/110] audit: improve audit queue handling when "audit=1" on cmdline Date: Mon, 7 Feb 2022 12:05:36 +0100 Message-Id: <20220207103802.395720866@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Paul Moore commit f26d04331360d42dbd6b58448bd98e4edbfbe1c5 upstream. When an admin enables audit at early boot via the "audit=3D1" kernel command line the audit queue behavior is slightly different; the audit subsystem goes to greater lengths to avoid dropping records, which unfortunately can result in problems when the audit daemon is forcibly stopped for an extended period of time. This patch makes a number of changes designed to improve the audit queuing behavior so that leaving the audit daemon in a stopped state for an extended period does not cause a significant impact to the system. - kauditd_send_queue() is now limited to looping through the passed queue only once per call. This not only prevents the function from looping indefinitely when records are returned to the current queue, it also allows any recovery handling in kauditd_thread() to take place when kauditd_send_queue() returns. - Transient netlink send errors seen as -EAGAIN now cause the record to be returned to the retry queue instead of going to the hold queue. The intention of the hold queue is to store, perhaps for an extended period of time, the events which led up to the audit daemon going offline. The retry queue remains a temporary queue intended to protect against transient issues between the kernel and the audit daemon. - The retry queue is now limited by the audit_backlog_limit setting, the same as the other queues. This allows admins to bound the size of all of the audit queues on the system. - kauditd_rehold_skb() now returns records to the end of the hold queue to ensure ordering is preserved in the face of recent changes to kauditd_send_queue(). Cc: stable@vger.kernel.org Fixes: 5b52330bbfe63 ("audit: fix auditd/kernel connection state tracking") Fixes: f4b3ee3c85551 ("audit: improve robustness of the audit queue handlin= g") Reported-by: Gaosheng Cui Tested-by: Gaosheng Cui Reviewed-by: Richard Guy Briggs Signed-off-by: Paul Moore Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- kernel/audit.c | 62 +++++++++++++++++++++++++++++++++++++++-------------= ----- 1 file changed, 43 insertions(+), 19 deletions(-) --- a/kernel/audit.c +++ b/kernel/audit.c @@ -541,20 +541,22 @@ static void kauditd_printk_skb(struct sk /** * kauditd_rehold_skb - Handle a audit record send failure in the hold que= ue * @skb: audit record + * @error: error code (unused) * * Description: * This should only be used by the kauditd_thread when it fails to flush t= he * hold queue. */ -static void kauditd_rehold_skb(struct sk_buff *skb) +static void kauditd_rehold_skb(struct sk_buff *skb, __always_unused int er= ror) { - /* put the record back in the queue at the same place */ - skb_queue_head(&audit_hold_queue, skb); + /* put the record back in the queue */ + skb_queue_tail(&audit_hold_queue, skb); } =20 /** * kauditd_hold_skb - Queue an audit record, waiting for auditd * @skb: audit record + * @error: error code * * Description: * Queue the audit record, waiting for an instance of auditd. When this @@ -564,19 +566,31 @@ static void kauditd_rehold_skb(struct sk * and queue it, if we have room. If we want to hold on to the record, bu= t we * don't have room, record a record lost message. */ -static void kauditd_hold_skb(struct sk_buff *skb) +static void kauditd_hold_skb(struct sk_buff *skb, int error) { /* at this point it is uncertain if we will ever send this to auditd so * try to send the message via printk before we go any further */ kauditd_printk_skb(skb); =20 /* can we just silently drop the message? */ - if (!audit_default) { - kfree_skb(skb); - return; + if (!audit_default) + goto drop; + + /* the hold queue is only for when the daemon goes away completely, + * not -EAGAIN failures; if we are in a -EAGAIN state requeue the + * record on the retry queue unless it's full, in which case drop it + */ + if (error =3D=3D -EAGAIN) { + if (!audit_backlog_limit || + skb_queue_len(&audit_retry_queue) < audit_backlog_limit) { + skb_queue_tail(&audit_retry_queue, skb); + return; + } + audit_log_lost("kauditd retry queue overflow"); + goto drop; } =20 - /* if we have room, queue the message */ + /* if we have room in the hold queue, queue the message */ if (!audit_backlog_limit || skb_queue_len(&audit_hold_queue) < audit_backlog_limit) { skb_queue_tail(&audit_hold_queue, skb); @@ -585,24 +599,32 @@ static void kauditd_hold_skb(struct sk_b =20 /* we have no other options - drop the message */ audit_log_lost("kauditd hold queue overflow"); +drop: kfree_skb(skb); } =20 /** * kauditd_retry_skb - Queue an audit record, attempt to send again to aud= itd * @skb: audit record + * @error: error code (unused) * * Description: * Not as serious as kauditd_hold_skb() as we still have a connected audit= d, * but for some reason we are having problems sending it audit records so * queue the given record and attempt to resend. */ -static void kauditd_retry_skb(struct sk_buff *skb) +static void kauditd_retry_skb(struct sk_buff *skb, __always_unused int err= or) { - /* NOTE: because records should only live in the retry queue for a - * short period of time, before either being sent or moved to the hold - * queue, we don't currently enforce a limit on this queue */ - skb_queue_tail(&audit_retry_queue, skb); + if (!audit_backlog_limit || + skb_queue_len(&audit_retry_queue) < audit_backlog_limit) { + skb_queue_tail(&audit_retry_queue, skb); + return; + } + + /* we have to drop the record, send it via printk as a last effort */ + kauditd_printk_skb(skb); + audit_log_lost("kauditd retry queue overflow"); + kfree_skb(skb); } =20 /** @@ -640,7 +662,7 @@ static void auditd_reset(const struct au /* flush the retry queue to the hold queue, but don't touch the main * queue since we need to process that normally for multicast */ while ((skb =3D skb_dequeue(&audit_retry_queue))) - kauditd_hold_skb(skb); + kauditd_hold_skb(skb, -ECONNREFUSED); } =20 /** @@ -714,16 +736,18 @@ static int kauditd_send_queue(struct soc struct sk_buff_head *queue, unsigned int retry_limit, void (*skb_hook)(struct sk_buff *skb), - void (*err_hook)(struct sk_buff *skb)) + void (*err_hook)(struct sk_buff *skb, int error)) { int rc =3D 0; - struct sk_buff *skb; + struct sk_buff *skb =3D NULL; + struct sk_buff *skb_tail; unsigned int failed =3D 0; =20 /* NOTE: kauditd_thread takes care of all our locking, we just use * the netlink info passed to us (e.g. sk and portid) */ =20 - while ((skb =3D skb_dequeue(queue))) { + skb_tail =3D skb_peek_tail(queue); + while ((skb !=3D skb_tail) && (skb =3D skb_dequeue(queue))) { /* call the skb_hook for each skb we touch */ if (skb_hook) (*skb_hook)(skb); @@ -731,7 +755,7 @@ static int kauditd_send_queue(struct soc /* can we send to anyone via unicast? */ if (!sk) { if (err_hook) - (*err_hook)(skb); + (*err_hook)(skb, -ECONNREFUSED); continue; } =20 @@ -745,7 +769,7 @@ retry: rc =3D=3D -ECONNREFUSED || rc =3D=3D -EPERM) { sk =3D NULL; if (err_hook) - (*err_hook)(skb); + (*err_hook)(skb, rc); if (rc =3D=3D -EAGAIN) rc =3D 0; /* continue to drain the queue */ From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E0DFC4167B for ; Mon, 7 Feb 2022 11:39:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386176AbiBGLdv (ORCPT ); Mon, 7 Feb 2022 06:33:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234936AbiBGLZC (ORCPT ); Mon, 7 Feb 2022 06:25:02 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32FCEC043189; Mon, 7 Feb 2022 03:25:01 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BCDE76077B; Mon, 7 Feb 2022 11:25:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69A43C004E1; Mon, 7 Feb 2022 11:24:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233100; bh=UBUGUaJZe93yLz+nk7Ton8WJCc+VGhP2Z/SUcF67TSE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D1QCKwMvqrqOY0PBmIDwvsgpmfBWF561OZJGbdMc+oizXCQ/u/1+F/GKaVoqbI2VB Z5WGPTW8JfAp+GA9nrVU9z4Ai28ziNIDvL6IFZ+oWrQueZuwplzPzJzG5ykmS2sJEd MGrZQV7D45NGNmhtx8xUC8YbdneSCOX2cH46DXMQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zeal Robot , Minghao Chi , Shakeel Butt , Manfred Spraul , Arnd Bergmann , Yang Guang , Davidlohr Bueso , Randy Dunlap , Bhaskar Chowdhury , Vasily Averin , Andrew Morton , Linus Torvalds Subject: [PATCH 5.15 004/110] ipc/sem: do not sleep with a spin lock held Date: Mon, 7 Feb 2022 12:05:37 +0100 Message-Id: <20220207103802.427673715@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Minghao Chi commit 520ba724061cef59763e2b6f5b26e8387c2e5822 upstream. We can't call kvfree() with a spin lock held, so defer it. Link: https://lkml.kernel.org/r/20211223031207.556189-1-chi.minghao@zte.com= .cn Fixes: fc37a3b8b438 ("[PATCH] ipc sem: use kvmalloc for sem_undo allocation= ") Reported-by: Zeal Robot Signed-off-by: Minghao Chi Reviewed-by: Shakeel Butt Reviewed-by: Manfred Spraul Cc: Arnd Bergmann Cc: Yang Guang Cc: Davidlohr Bueso Cc: Randy Dunlap Cc: Bhaskar Chowdhury Cc: Vasily Averin Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- ipc/sem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/ipc/sem.c +++ b/ipc/sem.c @@ -1964,6 +1964,7 @@ static struct sem_undo *find_alloc_undo( */ un =3D lookup_undo(ulp, semid); if (un) { + spin_unlock(&ulp->lock); kvfree(new); goto success; } @@ -1976,9 +1977,8 @@ static struct sem_undo *find_alloc_undo( ipc_assert_locked_object(&sma->sem_perm); list_add(&new->list_id, &sma->list_id); un =3D new; - -success: spin_unlock(&ulp->lock); +success: sem_unlock(sma, -1); out: return un; From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE52BC46467 for ; Mon, 7 Feb 2022 11:39:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386192AbiBGLdz (ORCPT ); Mon, 7 Feb 2022 06:33:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239868AbiBGLZH (ORCPT ); Mon, 7 Feb 2022 06:25:07 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9C23C043188; Mon, 7 Feb 2022 03:25:05 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 652F2B81158; Mon, 7 Feb 2022 11:25:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A419AC004E1; Mon, 7 Feb 2022 11:25:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233103; bh=OOrci6zsJTgNVekK33PRhoxSHZ4Cd74TJOKyCSGkGLA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E7ObEN/qJKjf8LAbkFspi27W1DWEG7CPG7AcAaJ8pEW1ba2bCGZ8qPYaDuJh8QrEN 6HCu5soMilMep6oCzUH8vnUSEIaGQa/3DhY9lKT4iNThx0nnl4p5sf91H8D2jHAudf xiM6ZYssPLlIhYZUvy2mYko43vR1diboEGxdWQJQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Patrice Chotard , Lukas Wunner , Mark Brown Subject: [PATCH 5.15 005/110] spi: stm32-qspi: Update spi registering Date: Mon, 7 Feb 2022 12:05:38 +0100 Message-Id: <20220207103802.467844676@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Patrice Chotard commit e4d63473d3110afd170e6e0e48494d3789d26136 upstream. Some device driver need to communicate to qspi device during the remove process, qspi controller must be functional when spi_unregister_master() is called. To ensure this, replace devm_spi_register_master() by spi_register_master() and spi_unregister_master() is called directly in .remove callback before stopping the qspi controller. This issue was put in evidence using kernel v5.11 and later with a spi-nor which supports the software reset feature introduced by commit d73ee7534cc5 ("mtd: spi-nor: core: perform a Soft Reset on shutdown") Fixes: c530cd1d9d5e ("spi: spi-mem: add stm32 qspi controller") Signed-off-by: Patrice Chotard Cc: # 5.8.x Reviewed-by: Lukas Wunner Link: https://lore.kernel.org/r/20220117121744.29729-1-patrice.chotard@foss= .st.com Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/spi/spi-stm32-qspi.c | 47 +++++++++++++++-----------------------= ----- 1 file changed, 17 insertions(+), 30 deletions(-) --- a/drivers/spi/spi-stm32-qspi.c +++ b/drivers/spi/spi-stm32-qspi.c @@ -688,7 +688,7 @@ static int stm32_qspi_probe(struct platf struct resource *res; int ret, irq; =20 - ctrl =3D spi_alloc_master(dev, sizeof(*qspi)); + ctrl =3D devm_spi_alloc_master(dev, sizeof(*qspi)); if (!ctrl) return -ENOMEM; =20 @@ -697,58 +697,46 @@ static int stm32_qspi_probe(struct platf =20 res =3D platform_get_resource_byname(pdev, IORESOURCE_MEM, "qspi"); qspi->io_base =3D devm_ioremap_resource(dev, res); - if (IS_ERR(qspi->io_base)) { - ret =3D PTR_ERR(qspi->io_base); - goto err_master_put; - } + if (IS_ERR(qspi->io_base)) + return PTR_ERR(qspi->io_base); =20 qspi->phys_base =3D res->start; =20 res =3D platform_get_resource_byname(pdev, IORESOURCE_MEM, "qspi_mm"); qspi->mm_base =3D devm_ioremap_resource(dev, res); - if (IS_ERR(qspi->mm_base)) { - ret =3D PTR_ERR(qspi->mm_base); - goto err_master_put; - } + if (IS_ERR(qspi->mm_base)) + return PTR_ERR(qspi->mm_base); =20 qspi->mm_size =3D resource_size(res); - if (qspi->mm_size > STM32_QSPI_MAX_MMAP_SZ) { - ret =3D -EINVAL; - goto err_master_put; - } + if (qspi->mm_size > STM32_QSPI_MAX_MMAP_SZ) + return -EINVAL; =20 irq =3D platform_get_irq(pdev, 0); - if (irq < 0) { - ret =3D irq; - goto err_master_put; - } + if (irq < 0) + return irq; =20 ret =3D devm_request_irq(dev, irq, stm32_qspi_irq, 0, dev_name(dev), qspi); if (ret) { dev_err(dev, "failed to request irq\n"); - goto err_master_put; + return ret; } =20 init_completion(&qspi->data_completion); init_completion(&qspi->match_completion); =20 qspi->clk =3D devm_clk_get(dev, NULL); - if (IS_ERR(qspi->clk)) { - ret =3D PTR_ERR(qspi->clk); - goto err_master_put; - } + if (IS_ERR(qspi->clk)) + return PTR_ERR(qspi->clk); =20 qspi->clk_rate =3D clk_get_rate(qspi->clk); - if (!qspi->clk_rate) { - ret =3D -EINVAL; - goto err_master_put; - } + if (!qspi->clk_rate) + return -EINVAL; =20 ret =3D clk_prepare_enable(qspi->clk); if (ret) { dev_err(dev, "can not enable the clock\n"); - goto err_master_put; + return ret; } =20 rstc =3D devm_reset_control_get_exclusive(dev, NULL); @@ -784,7 +772,7 @@ static int stm32_qspi_probe(struct platf pm_runtime_enable(dev); pm_runtime_get_noresume(dev); =20 - ret =3D devm_spi_register_master(dev, ctrl); + ret =3D spi_register_master(ctrl); if (ret) goto err_pm_runtime_free; =20 @@ -806,8 +794,6 @@ err_dma_free: stm32_qspi_dma_free(qspi); err_clk_disable: clk_disable_unprepare(qspi->clk); -err_master_put: - spi_master_put(qspi->ctrl); =20 return ret; } @@ -817,6 +803,7 @@ static int stm32_qspi_remove(struct plat struct stm32_qspi *qspi =3D platform_get_drvdata(pdev); =20 pm_runtime_get_sync(qspi->dev); + spi_unregister_master(qspi->ctrl); /* disable qspi */ writel_relaxed(0, qspi->io_base + QSPI_CR); stm32_qspi_dma_free(qspi); From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4C85C433EF for ; Mon, 7 Feb 2022 11:46:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386909AbiBGLiC (ORCPT ); Mon, 7 Feb 2022 06:38:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244593AbiBGLZJ (ORCPT ); Mon, 7 Feb 2022 06:25:09 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FF5BC0401C6; Mon, 7 Feb 2022 03:25:08 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 37984B81028; Mon, 7 Feb 2022 11:25:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E358C340F6; Mon, 7 Feb 2022 11:25:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233106; bh=5IsXqdmiyDuHjCKLVr33FdSRI3q+QbGeX0U1P/98KaI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PntqZ7XK5f0k6/DhgvlMJ4Ih4tj3pVR4qg2+4hmXpi7jRNVSzoz3PYH3UCwgcJrus xhRlp9v2z3T2eWz5YW6ivFRD6oR4tvliRPzyy6VHkSU/Xf+B/C21cHIZtWiB91tOyZ +MnB+nicccytgYn5lvWJclYiSGwmiE00LGNrnG5I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dmitry Osipenko , Mark Brown Subject: [PATCH 5.15 006/110] ASoC: hdmi-codec: Fix OOB memory accesses Date: Mon, 7 Feb 2022 12:05:39 +0100 Message-Id: <20220207103802.499218364@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Dmitry Osipenko commit 06feec6005c9d9500cd286ec440aabf8b2ddd94d upstream. Correct size of iec_status array by changing it to the size of status array of the struct snd_aes_iec958. This fixes out-of-bounds slab read accesses made by memcpy() of the hdmi-codec driver. This problem is reported by KASAN. Cc: stable@vger.kernel.org Signed-off-by: Dmitry Osipenko Link: https://lore.kernel.org/r/20220112195039.1329-1-digetx@gmail.com Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- include/uapi/sound/asound.h | 4 +++- sound/soc/codecs/hdmi-codec.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) --- a/include/uapi/sound/asound.h +++ b/include/uapi/sound/asound.h @@ -56,8 +56,10 @@ * = * *************************************************************************= ***/ =20 +#define AES_IEC958_STATUS_SIZE 24 + struct snd_aes_iec958 { - unsigned char status[24]; /* AES/IEC958 channel status bits */ + unsigned char status[AES_IEC958_STATUS_SIZE]; /* AES/IEC958 channel statu= s bits */ unsigned char subcode[147]; /* AES/IEC958 subcode bits */ unsigned char pad; /* nothing */ unsigned char dig_subframe[4]; /* AES/IEC958 subframe bits */ --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -277,7 +277,7 @@ struct hdmi_codec_priv { bool busy; struct snd_soc_jack *jack; unsigned int jack_status; - u8 iec_status[5]; + u8 iec_status[AES_IEC958_STATUS_SIZE]; }; =20 static const struct snd_soc_dapm_widget hdmi_widgets[] =3D { From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5119C433EF for ; Mon, 7 Feb 2022 11:46:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386812AbiBGLhu (ORCPT ); Mon, 7 Feb 2022 06:37:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352941AbiBGLZO (ORCPT ); Mon, 7 Feb 2022 06:25:14 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8685BC0401C8; Mon, 7 Feb 2022 03:25:11 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 48098B81028; Mon, 7 Feb 2022 11:25:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7DEDFC004E1; Mon, 7 Feb 2022 11:25:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233109; bh=PXxvrLo0f5n0j+2ESXkHAGvNHfjbEgwhgKzsc6FW1F4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iG5vhJGLs+OLRSd+nwub68O2lJD1RSWeaBOdQpYAPHZgrSHe33xT4KyNGoxd018EU xLaPqtUxotsMQG31FRPPQtyzLsLHmu87/+PM4pBNa/y8HetS8StrokdDA3CArGAXxe P1VlJRVXhyblynBl8TUioYeNDQ1eEFq1nZ6oxmPw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Brown Subject: [PATCH 5.15 007/110] ASoC: ops: Reject out of bounds values in snd_soc_put_volsw() Date: Mon, 7 Feb 2022 12:05:40 +0100 Message-Id: <20220207103802.532613748@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Mark Brown commit 817f7c9335ec01e0f5e8caffc4f1dcd5e458a4c0 upstream. We don't currently validate that the values being set are within the range we advertised to userspace as being valid, do so and reject any values that are out of range. Signed-off-by: Mark Brown Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20220124153253.3548853-2-broonie@kernel.org Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/soc/soc-ops.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) --- a/sound/soc/soc-ops.c +++ b/sound/soc/soc-ops.c @@ -316,13 +316,27 @@ int snd_soc_put_volsw(struct snd_kcontro if (sign_bit) mask =3D BIT(sign_bit + 1) - 1; =20 - val =3D ((ucontrol->value.integer.value[0] + min) & mask); + val =3D ucontrol->value.integer.value[0]; + if (mc->platform_max && val > mc->platform_max) + return -EINVAL; + if (val > max - min) + return -EINVAL; + if (val < 0) + return -EINVAL; + val =3D (val + min) & mask; if (invert) val =3D max - val; val_mask =3D mask << shift; val =3D val << shift; if (snd_soc_volsw_is_stereo(mc)) { - val2 =3D ((ucontrol->value.integer.value[1] + min) & mask); + val2 =3D ucontrol->value.integer.value[1]; + if (mc->platform_max && val2 > mc->platform_max) + return -EINVAL; + if (val2 > max - min) + return -EINVAL; + if (val2 < 0) + return -EINVAL; + val2 =3D (val2 + min) & mask; if (invert) val2 =3D max - val2; if (reg =3D=3D reg2) { From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70884C41535 for ; Mon, 7 Feb 2022 11:45:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386775AbiBGLgl (ORCPT ); Mon, 7 Feb 2022 06:36:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357112AbiBGLZS (ORCPT ); Mon, 7 Feb 2022 06:25:18 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDDDEC0401F3; Mon, 7 Feb 2022 03:25:13 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 209EF6077B; Mon, 7 Feb 2022 11:25:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 75370C004E1; Mon, 7 Feb 2022 11:25:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233112; bh=u4UjAcFF1Zp7pNCg0/6sdayjl3EP4O06VFNJH8ux4dM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IP6+ZSaE0tBsu/Jn8k9XBGbUD22AByA4H/iTQR7H9wzUAI7xds+uXZztc0bAxtBM5 V0m96t1uydYB7Lf9wz4WXsJjCfLx0HT7C1TnPolYQlK5wQltFr5DassULGHRmt9e4Z pA50j9P/gyWQorbtF4GxxwwMcbXjZM8gt+AvrSw0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Brown Subject: [PATCH 5.15 008/110] ASoC: ops: Reject out of bounds values in snd_soc_put_volsw_sx() Date: Mon, 7 Feb 2022 12:05:41 +0100 Message-Id: <20220207103802.562124328@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Mark Brown commit 4f1e50d6a9cf9c1b8c859d449b5031cacfa8404e upstream. We don't currently validate that the values being set are within the range we advertised to userspace as being valid, do so and reject any values that are out of range. Signed-off-by: Mark Brown Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20220124153253.3548853-3-broonie@kernel.org Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/soc/soc-ops.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) --- a/sound/soc/soc-ops.c +++ b/sound/soc/soc-ops.c @@ -423,8 +423,15 @@ int snd_soc_put_volsw_sx(struct snd_kcon int err =3D 0; unsigned int val, val_mask; =20 + val =3D ucontrol->value.integer.value[0]; + if (mc->platform_max && val > mc->platform_max) + return -EINVAL; + if (val > max - min) + return -EINVAL; + if (val < 0) + return -EINVAL; val_mask =3D mask << shift; - val =3D (ucontrol->value.integer.value[0] + min) & mask; + val =3D (val + min) & mask; val =3D val << shift; =20 err =3D snd_soc_component_update_bits(component, reg, val_mask, val); From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9ABCAC3527E for ; Mon, 7 Feb 2022 11:45:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378839AbiBGLf6 (ORCPT ); Mon, 7 Feb 2022 06:35:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358128AbiBGLZa (ORCPT ); Mon, 7 Feb 2022 06:25:30 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C2ADC043181; Mon, 7 Feb 2022 03:25:18 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C5C12B81158; Mon, 7 Feb 2022 11:25:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 172C2C004E1; Mon, 7 Feb 2022 11:25:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233115; bh=/hAnYNohmzw9oQdX6Kt9aR6iA/2JH1LYTQg7rMfMCQ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fpIsUQPVyEfpYmxdSz6acPVCmnSlXRWkg+qDbQ1Jzp1PpO+XXrgfm3A7EUFi3If4M kxebcIP7OfX2+Pg9xfmdtEjMI4VupYgyOoy6Cb8sP6MM4S1hxcvDe7ay6vHIDTAXkX eBLoZmMl2sfr489W6Q3djawNbvttoUxtj14wazJc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Brown Subject: [PATCH 5.15 009/110] ASoC: ops: Reject out of bounds values in snd_soc_put_xr_sx() Date: Mon, 7 Feb 2022 12:05:42 +0100 Message-Id: <20220207103802.594628456@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Mark Brown commit 4cf28e9ae6e2e11a044be1bcbcfa1b0d8675fe4d upstream. We don't currently validate that the values being set are within the range we advertised to userspace as being valid, do so and reject any values that are out of range. Signed-off-by: Mark Brown Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20220124153253.3548853-4-broonie@kernel.org Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/soc/soc-ops.c | 2 ++ 1 file changed, 2 insertions(+) --- a/sound/soc/soc-ops.c +++ b/sound/soc/soc-ops.c @@ -879,6 +879,8 @@ int snd_soc_put_xr_sx(struct snd_kcontro long val =3D ucontrol->value.integer.value[0]; unsigned int i; =20 + if (val < mc->min || val > mc->max) + return -EINVAL; if (invert) val =3D max - val; val &=3D mask; From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 077A9C4321E for ; Mon, 7 Feb 2022 11:39:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377042AbiBGLf1 (ORCPT ); Mon, 7 Feb 2022 06:35:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384097AbiBGLYn (ORCPT ); Mon, 7 Feb 2022 06:24:43 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16E02C043181; Mon, 7 Feb 2022 03:24:43 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A003C6077B; Mon, 7 Feb 2022 11:24:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7AD9FC004E1; Mon, 7 Feb 2022 11:24:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233082; bh=xjkRWAuO6sjuAxBcS+6c7kSyPv7Q3Yfk0x1pK5sdx1M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UseLBa1xJglCDP95TlKt0l6aTQak+nZCOBXHcL3HIQIHZdRp991I6rYDtP4FnIRx9 n033RVIZPbBuc6wXSTfUG4zl2PN5sXkRGUzv9Eyylhk4Hu5igiEMrVjwOiJInKvcmI NDLEVpCMFB5sxBW7I5QGDYLXxGBj7cXmn4wLRnJU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jukka Heikintalo , =?UTF-8?q?Pawe=C5=82=20Susicki?= , Jonas Hahnfeld , Takashi Iwai Subject: [PATCH 5.15 010/110] ALSA: usb-audio: Correct quirk for VF0770 Date: Mon, 7 Feb 2022 12:05:43 +0100 Message-Id: <20220207103802.624680247@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jonas Hahnfeld commit 4ee02e20893d2f9e951c7888f2284fa608ddaa35 upstream. This device provides both audio and video. The original quirk added in commit 48827e1d6af5 ("ALSA: usb-audio: Add quirk for VF0770") used USB_DEVICE to match the vendor and product ID. Depending on module order, if snd-usb-audio was asked first, it would match the entire device and uvcvideo wouldn't get to see it. Change the matching to USB_AUDIO_DEVICE to restore uvcvideo matching in all cases. Fixes: 48827e1d6af5 ("ALSA: usb-audio: Add quirk for VF0770") Reported-by: Jukka Heikintalo Tested-by: Jukka Heikintalo Reported-by: Pawe=C5=82 Susicki Tested-by: Pawe=C5=82 Susicki Cc: # 5.4, 5.10, 5.14, 5.15 Signed-off-by: Jonas Hahnfeld Link: https://lore.kernel.org/r/20220131183516.61191-1-hahnjo@hahnjo.de Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/usb/quirks-table.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/sound/usb/quirks-table.h +++ b/sound/usb/quirks-table.h @@ -84,7 +84,7 @@ * combination. */ { - USB_DEVICE(0x041e, 0x4095), + USB_AUDIO_DEVICE(0x041e, 0x4095), .driver_info =3D (unsigned long) &(const struct snd_usb_audio_quirk) { .ifnum =3D QUIRK_ANY_INTERFACE, .type =3D QUIRK_COMPOSITE, From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E6D1C433EF for ; Mon, 7 Feb 2022 11:45:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234229AbiBGLfa (ORCPT ); Mon, 7 Feb 2022 06:35:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384110AbiBGLYs (ORCPT ); Mon, 7 Feb 2022 06:24:48 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91D00C043181; Mon, 7 Feb 2022 03:24:47 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4A21CB81158; Mon, 7 Feb 2022 11:24:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D367C340EB; Mon, 7 Feb 2022 11:24:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233085; bh=5OlD3dhXOCojKO3N7H+U3aupk719bOzjvga7rhxB4wA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J7vJegfj6srU1+87YVha1YzPNd+/7wHTjp+MiZZPZeI9gxXaNEretC31ilQmK8xRJ ZZBp9q/pQvGGlIfVlXlvjQPdfqinR3mT/Zlk0hBrXbcGj3/2zpA1wPY6uv5Cl9+k2z XwM/kicc2ADS6HO2rp3shf65N7yG5eUHuLTjrPnM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexander Sergeyev , Takashi Iwai Subject: [PATCH 5.15 011/110] ALSA: hda: Fix UAF of leds class devs at unbinding Date: Mon, 7 Feb 2022 12:05:44 +0100 Message-Id: <20220207103802.657532100@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Takashi Iwai commit 549f8ffc7b2f7561bea7f90930b6c5104318e87b upstream. The LED class devices that are created by HD-audio codec drivers are registered via devm_led_classdev_register() and associated with the HD-audio codec device. Unfortunately, it turned out that the devres release doesn't work for this case; namely, since the codec resource release happens before the devm call chain, it triggers a NULL dereference or a UAF for a stale set_brightness_delay callback. For fixing the bug, this patch changes the LED class device register and unregister in a manual manner without devres, keeping the instances in hda_gen_spec. Reported-by: Alexander Sergeyev Cc: Link: https://lore.kernel.org/r/20220111195229.a77wrpjclqwrx4bx@localhost.l= ocaldomain Link: https://lore.kernel.org/r/20220126145011.16728-1-tiwai@suse.de Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/pci/hda/hda_generic.c | 17 +++++++++++++++-- sound/pci/hda/hda_generic.h | 3 +++ 2 files changed, 18 insertions(+), 2 deletions(-) --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c @@ -91,6 +91,12 @@ static void snd_hda_gen_spec_free(struct free_kctls(spec); snd_array_free(&spec->paths); snd_array_free(&spec->loopback_list); +#ifdef CONFIG_SND_HDA_GENERIC_LEDS + if (spec->led_cdevs[LED_AUDIO_MUTE]) + led_classdev_unregister(spec->led_cdevs[LED_AUDIO_MUTE]); + if (spec->led_cdevs[LED_AUDIO_MICMUTE]) + led_classdev_unregister(spec->led_cdevs[LED_AUDIO_MICMUTE]); +#endif } =20 /* @@ -3922,7 +3928,10 @@ static int create_mute_led_cdev(struct h enum led_brightness), bool micmute) { + struct hda_gen_spec *spec =3D codec->spec; struct led_classdev *cdev; + int idx =3D micmute ? LED_AUDIO_MICMUTE : LED_AUDIO_MUTE; + int err; =20 cdev =3D devm_kzalloc(&codec->core.dev, sizeof(*cdev), GFP_KERNEL); if (!cdev) @@ -3932,10 +3941,14 @@ static int create_mute_led_cdev(struct h cdev->max_brightness =3D 1; cdev->default_trigger =3D micmute ? "audio-micmute" : "audio-mute"; cdev->brightness_set_blocking =3D callback; - cdev->brightness =3D ledtrig_audio_get(micmute ? LED_AUDIO_MICMUTE : LED_= AUDIO_MUTE); + cdev->brightness =3D ledtrig_audio_get(idx); cdev->flags =3D LED_CORE_SUSPENDRESUME; =20 - return devm_led_classdev_register(&codec->core.dev, cdev); + err =3D led_classdev_register(&codec->core.dev, cdev); + if (err < 0) + return err; + spec->led_cdevs[idx] =3D cdev; + return 0; } =20 /** --- a/sound/pci/hda/hda_generic.h +++ b/sound/pci/hda/hda_generic.h @@ -294,6 +294,9 @@ struct hda_gen_spec { struct hda_jack_callback *cb); void (*mic_autoswitch_hook)(struct hda_codec *codec, struct hda_jack_callback *cb); + + /* leds */ + struct led_classdev *led_cdevs[NUM_AUDIO_LEDS]; }; =20 /* values for add_stereo_mix_input flag */ From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A737C3526C for ; Mon, 7 Feb 2022 11:45:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359202AbiBGLfg (ORCPT ); Mon, 7 Feb 2022 06:35:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384116AbiBGLYt (ORCPT ); Mon, 7 Feb 2022 06:24:49 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09C07C043188; Mon, 7 Feb 2022 03:24:49 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9308F6077B; Mon, 7 Feb 2022 11:24:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 760B5C004E1; Mon, 7 Feb 2022 11:24:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233088; bh=ax9fryblx6QV7qJ+qvkUKsP1d+CzKmmJDTBUlRRYv54=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PPx9L1x7LRw6VORMg+hH5UbCS0mpDm3AfUio4zRGgbCLXfqWAkbp1PKH8easVOLJr P0H3xtG7sy/oS3hM4tA9lJDSQTxFtmDG6hL9Ct6vYe+FkWgFjKIFvBCbpazrPCeyE2 bY/COp5Tg2APrK3wsHvUtQAe3E5Bx2quB8Qhv42E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexander Sergeyev , Takashi Iwai Subject: [PATCH 5.15 012/110] ALSA: hda: realtek: Fix race at concurrent COEF updates Date: Mon, 7 Feb 2022 12:05:45 +0100 Message-Id: <20220207103802.687712648@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Takashi Iwai commit b837a9f5ab3bdfab9233c9f98a6bef717673a3e5 upstream. The COEF access is done with two steps: setting the index then read or write the data. When multiple COEF accesses are performed concurrently, the index and data might be paired unexpectedly. In most cases, this isn't a big problem as the COEF setup is done at the initialization, but some dynamic changes like the mute LED may hit such a race. For avoiding the racy COEF accesses, this patch introduces a new mutex coef_mutex to alc_spec, and wrap the COEF accessing functions with it. Reported-by: Alexander Sergeyev Cc: Link: https://lore.kernel.org/r/20220111195229.a77wrpjclqwrx4bx@localhost.l= ocaldomain Link: https://lore.kernel.org/r/20220131075738.24323-1-tiwai@suse.de Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/pci/hda/patch_realtek.c | 61 ++++++++++++++++++++++++++++++++++---= ----- 1 file changed, 50 insertions(+), 11 deletions(-) --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -97,6 +97,7 @@ struct alc_spec { unsigned int gpio_mic_led_mask; struct alc_coef_led mute_led_coef; struct alc_coef_led mic_led_coef; + struct mutex coef_mutex; =20 hda_nid_t headset_mic_pin; hda_nid_t headphone_mic_pin; @@ -132,8 +133,8 @@ struct alc_spec { * COEF access helper functions */ =20 -static int alc_read_coefex_idx(struct hda_codec *codec, hda_nid_t nid, - unsigned int coef_idx) +static int __alc_read_coefex_idx(struct hda_codec *codec, hda_nid_t nid, + unsigned int coef_idx) { unsigned int val; =20 @@ -142,28 +143,61 @@ static int alc_read_coefex_idx(struct hd return val; } =20 +static int alc_read_coefex_idx(struct hda_codec *codec, hda_nid_t nid, + unsigned int coef_idx) +{ + struct alc_spec *spec =3D codec->spec; + unsigned int val; + + mutex_lock(&spec->coef_mutex); + val =3D __alc_read_coefex_idx(codec, nid, coef_idx); + mutex_unlock(&spec->coef_mutex); + return val; +} + #define alc_read_coef_idx(codec, coef_idx) \ alc_read_coefex_idx(codec, 0x20, coef_idx) =20 -static void alc_write_coefex_idx(struct hda_codec *codec, hda_nid_t nid, - unsigned int coef_idx, unsigned int coef_val) +static void __alc_write_coefex_idx(struct hda_codec *codec, hda_nid_t nid, + unsigned int coef_idx, unsigned int coef_val) { snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, coef_idx); snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PROC_COEF, coef_val); } =20 +static void alc_write_coefex_idx(struct hda_codec *codec, hda_nid_t nid, + unsigned int coef_idx, unsigned int coef_val) +{ + struct alc_spec *spec =3D codec->spec; + + mutex_lock(&spec->coef_mutex); + __alc_write_coefex_idx(codec, nid, coef_idx, coef_val); + mutex_unlock(&spec->coef_mutex); +} + #define alc_write_coef_idx(codec, coef_idx, coef_val) \ alc_write_coefex_idx(codec, 0x20, coef_idx, coef_val) =20 +static void __alc_update_coefex_idx(struct hda_codec *codec, hda_nid_t nid, + unsigned int coef_idx, unsigned int mask, + unsigned int bits_set) +{ + unsigned int val =3D __alc_read_coefex_idx(codec, nid, coef_idx); + + if (val !=3D -1) + __alc_write_coefex_idx(codec, nid, coef_idx, + (val & ~mask) | bits_set); +} + static void alc_update_coefex_idx(struct hda_codec *codec, hda_nid_t nid, unsigned int coef_idx, unsigned int mask, unsigned int bits_set) { - unsigned int val =3D alc_read_coefex_idx(codec, nid, coef_idx); + struct alc_spec *spec =3D codec->spec; =20 - if (val !=3D -1) - alc_write_coefex_idx(codec, nid, coef_idx, - (val & ~mask) | bits_set); + mutex_lock(&spec->coef_mutex); + __alc_update_coefex_idx(codec, nid, coef_idx, mask, bits_set); + mutex_unlock(&spec->coef_mutex); } =20 #define alc_update_coef_idx(codec, coef_idx, mask, bits_set) \ @@ -196,13 +230,17 @@ struct coef_fw { static void alc_process_coef_fw(struct hda_codec *codec, const struct coef_fw *fw) { + struct alc_spec *spec =3D codec->spec; + + mutex_lock(&spec->coef_mutex); for (; fw->nid; fw++) { if (fw->mask =3D=3D (unsigned short)-1) - alc_write_coefex_idx(codec, fw->nid, fw->idx, fw->val); + __alc_write_coefex_idx(codec, fw->nid, fw->idx, fw->val); else - alc_update_coefex_idx(codec, fw->nid, fw->idx, - fw->mask, fw->val); + __alc_update_coefex_idx(codec, fw->nid, fw->idx, + fw->mask, fw->val); } + mutex_unlock(&spec->coef_mutex); } =20 /* @@ -1148,6 +1186,7 @@ static int alc_alloc_spec(struct hda_cod codec->spdif_status_reset =3D 1; codec->forced_resume =3D 1; codec->patch_ops =3D alc_patch_ops; + mutex_init(&spec->coef_mutex); =20 err =3D alc_codec_rename_from_preset(codec); if (err < 0) { From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44CB3C3527D for ; Mon, 7 Feb 2022 11:45:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377711AbiBGLfq (ORCPT ); Mon, 7 Feb 2022 06:35:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384136AbiBGLYw (ORCPT ); Mon, 7 Feb 2022 06:24:52 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 108F1C043181; Mon, 7 Feb 2022 03:24:52 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A0EE461388; Mon, 7 Feb 2022 11:24:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F19DC004E1; Mon, 7 Feb 2022 11:24:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233091; bh=IEgE565Gtb1btIQogTZvSJuRAGwhj+7xF4Okv16Im2o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=egtWY0ngQD5vYuIcFRlTjU6jsQtn2JhjJ2rkJRBhrWmFuN159ERWefPwRbdWUq5jp T2ofMIcbrz2LGXrYJ72INJTkKwX6+gZ7Hx2iIUawKyrNZvP1/LtIdGU/JWH2nE28Ho RYVbb99Klzq8aRhX5drLvw+t66LyBK15UaZfy4BQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Albert=20Geant=C4=83?= , Takashi Iwai Subject: [PATCH 5.15 013/110] ALSA: hda/realtek: Add quirk for ASUS GU603 Date: Mon, 7 Feb 2022 12:05:46 +0100 Message-Id: <20220207103802.718911808@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Albert Geant=C4=83 commit 94db9cc8f8fa2d5426ce79ec4ca16028f7084224 upstream. The ASUS GU603 (Zephyrus M16 - SSID 1043:16b2) requires a quirk similar to other ASUS devices for correctly routing the 4 integrated speakers. This fixes it by adding a corresponding quirk entry, which connects the bass speakers to the proper DAC. Signed-off-by: Albert Geant=C4=83 Cc: Link: https://lore.kernel.org/r/20220131010523.546386-1-albertgeanta@gmail.= com Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+) --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -8854,6 +8854,7 @@ static const struct snd_pci_quirk alc269 SND_PCI_QUIRK(0x1043, 0x1e51, "ASUS Zephyrus M15", ALC294_FIXUP_ASUS_GU50= 2_PINS), SND_PCI_QUIRK(0x1043, 0x1e8e, "ASUS Zephyrus G15", ALC289_FIXUP_ASUS_GA40= 1), SND_PCI_QUIRK(0x1043, 0x1f11, "ASUS Zephyrus G14", ALC289_FIXUP_ASUS_GA40= 1), + SND_PCI_QUIRK(0x1043, 0x16b2, "ASUS GU603", ALC289_FIXUP_ASUS_GA401), SND_PCI_QUIRK(0x1043, 0x3030, "ASUS ZN270IE", ALC256_FIXUP_ASUS_AIO_GPIO2= ), SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC), SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC), From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34F28C35278 for ; Mon, 7 Feb 2022 11:48:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387956AbiBGLmW (ORCPT ); Mon, 7 Feb 2022 06:42:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359408AbiBGL2n (ORCPT ); Mon, 7 Feb 2022 06:28:43 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 361B0C033252; Mon, 7 Feb 2022 03:27:02 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 36FCA60A6B; Mon, 7 Feb 2022 11:27:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0D724C004E1; Mon, 7 Feb 2022 11:27:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233221; bh=9q3/IOuZ6+o3g3xGCTBih0kUoMO02HHzHtG+4luzBNg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PT4aQI2mT1TuCcYOhBctJEX6UAw/ObzwEQrZ97Glfa57GSEDm1+DewHjUtBuut6F7 A8hrdLHqrBfeI9h/r/1WFxvxieKVcexdVM5XsgwzUuGSMLyw3HsvgU8HEPxeijlItF z42q7fuz1a0iwxZ7v5FsWFRxOOZ//BUIf0CTs1PY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christian Lachner , Takashi Iwai Subject: [PATCH 5.15 014/110] ALSA: hda/realtek: Add missing fixup-model entry for Gigabyte X570 ALC1220 quirks Date: Mon, 7 Feb 2022 12:05:47 +0100 Message-Id: <20220207103802.750149389@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Christian Lachner commit 63394a16086fc2152869d7902621e2525e14bc40 upstream. The initial commit of the new Gigabyte X570 ALC1220 quirks lacked the fixup-model entry in alc882_fixup_models[]. It seemed not to cause any ill effects but for completeness sake this commit makes up for that. Signed-off-by: Christian Lachner Cc: Link: https://lore.kernel.org/r/20220129113243.93068-2-gladiac@gmail.com Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+) --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -2660,6 +2660,7 @@ static const struct hda_model_fixup alc8 {.id =3D ALC882_FIXUP_NO_PRIMARY_HP, .name =3D "no-primary-hp"}, {.id =3D ALC887_FIXUP_ASUS_BASS, .name =3D "asus-bass"}, {.id =3D ALC1220_FIXUP_GB_DUAL_CODECS, .name =3D "dual-codecs"}, + {.id =3D ALC1220_FIXUP_GB_X570, .name =3D "gb-x570"}, {.id =3D ALC1220_FIXUP_CLEVO_P950, .name =3D "clevo-p950"}, {} }; From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0985C35294 for ; Mon, 7 Feb 2022 11:45:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386731AbiBGLgY (ORCPT ); Mon, 7 Feb 2022 06:36:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358795AbiBGLZn (ORCPT ); Mon, 7 Feb 2022 06:25:43 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29309C03FEC1; Mon, 7 Feb 2022 03:25:22 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id F3C076149A; Mon, 7 Feb 2022 11:25:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D68CDC004E1; Mon, 7 Feb 2022 11:25:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233121; bh=rZvJ4ZyZHDyPNU3S/M+WkdB/RT1ucA3r+WNcdZmHxi4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UYgqaPaocGJ05eObxo/XBaQcBCEUJlXO2XoDr3i6r8BNAT7BFzmebJxwrTrsoNUv8 yxoEt2xEPCZ29SXA4PexCLfTjknMfi3ZvstM7N2B2qLamTuW6qmxwSvdrsDsFRXyiB RN2M2pR4h16WPaIMyIwwkw56o2HKe7iNFJsjOpEs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christian Lachner , Takashi Iwai Subject: [PATCH 5.15 015/110] ALSA: hda/realtek: Fix silent output on Gigabyte X570S Aorus Master (newer chipset) Date: Mon, 7 Feb 2022 12:05:48 +0100 Message-Id: <20220207103802.781986089@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Christian Lachner commit 41a8601302ecbe704ac970552c33dc942300fc37 upstream. Newer versions of the X570 Master come with a newer revision of the mainboard chipset - the X570S. These boards have the same ALC1220 codec but seem to initialize the codec with a different parameter in Coef 0x7 which causes the output audio to be very low. We therefore write a known-good value to Coef 0x7 to fix that. As the value is the exact same as on the other X570(non-S) boards the same quirk-function can be shared between both generations. This commit adds the Gigabyte X570S Aorus Master to the list of boards using the ALC1220_FIXUP_GB_X570 quirk. This fixes both, the silent output and the no-audio after reboot from windows problems. This work has been tested by the folks over at the level1techs forum here: https://forum.level1techs.com/t/has-anybody-gotten-audio-working-in-linux-o= n-aorus-x570-master/154072 Signed-off-by: Christian Lachner Cc: Link: https://lore.kernel.org/r/20220129113243.93068-3-gladiac@gmail.com Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/pci/hda/patch_realtek.c | 2 ++ 1 file changed, 2 insertions(+) --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -2159,6 +2159,7 @@ static void alc1220_fixup_gb_x570(struct { static const hda_nid_t conn1[] =3D { 0x0c }; static const struct coef_fw gb_x570_coefs[] =3D { + WRITE_COEF(0x07, 0x03c0), WRITE_COEF(0x1a, 0x01c1), WRITE_COEF(0x1b, 0x0202), WRITE_COEF(0x43, 0x3005), @@ -2586,6 +2587,7 @@ static const struct snd_pci_quirk alc882 SND_PCI_QUIRK(0x1458, 0xa0b8, "Gigabyte AZ370-Gaming", ALC1220_FIXUP_GB_D= UAL_CODECS), SND_PCI_QUIRK(0x1458, 0xa0cd, "Gigabyte X570 Aorus Master", ALC1220_FIXUP= _GB_X570), SND_PCI_QUIRK(0x1458, 0xa0ce, "Gigabyte X570 Aorus Xtreme", ALC1220_FIXUP= _CLEVO_P950), + SND_PCI_QUIRK(0x1458, 0xa0d5, "Gigabyte X570S Aorus Master", ALC1220_FIXU= P_GB_X570), SND_PCI_QUIRK(0x1462, 0x11f7, "MSI-GE63", ALC1220_FIXUP_CLEVO_P950), SND_PCI_QUIRK(0x1462, 0x1228, "MSI-GP63", ALC1220_FIXUP_CLEVO_P950), SND_PCI_QUIRK(0x1462, 0x1229, "MSI-GP73", ALC1220_FIXUP_CLEVO_P950), From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85917C3526C for ; Mon, 7 Feb 2022 11:58:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388598AbiBGLoC (ORCPT ); Mon, 7 Feb 2022 06:44:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384248AbiBGL0e (ORCPT ); Mon, 7 Feb 2022 06:26:34 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74049C0401C9; Mon, 7 Feb 2022 03:25:55 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 12DFC6135A; Mon, 7 Feb 2022 11:25:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4EFEC004E1; Mon, 7 Feb 2022 11:25:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233154; bh=Qt3S7UX4NFNycD6cNDXk6cbCpdwYlASoMUr9U9g1V+Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W4WWYzWDkMpwDgSzx8jhAT8UsuUdjTI8glJOnDhJjXnJvoKkPJqq5g9mX0RItQdCN NHBz4kVpWBqvF6B4NLR+RSOOhDoTWgXE9dYd2wV5PyKnoKRT0ROOU+W830GmCQvyz3 pdJGU8CV+jyAQIG4FknXYQOmf5kaoKO3NfA9kGCQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christian Lachner , Takashi Iwai Subject: [PATCH 5.15 016/110] ALSA: hda/realtek: Fix silent output on Gigabyte X570 Aorus Xtreme after reboot from Windows Date: Mon, 7 Feb 2022 12:05:49 +0100 Message-Id: <20220207103802.814239221@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Christian Lachner commit ea3541961376f733373839cc90493aafa8a7f733 upstream. This commit switches the Gigabyte X570 Aorus Xtreme from using the ALC1220_FIXUP_CLEVO_P950 to the ALC1220_FIXUP_GB_X570 quirk. This fixes the no-audio after reboot from windows problem. BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=3D205275 Signed-off-by: Christian Lachner Cc: Link: https://lore.kernel.org/r/20220129113243.93068-4-gladiac@gmail.com Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/pci/hda/patch_realtek.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -2586,7 +2586,7 @@ static const struct snd_pci_quirk alc882 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3/Z87X-UD3H", ALC889_FIXUP= _FRONT_HP_NO_PRESENCE), SND_PCI_QUIRK(0x1458, 0xa0b8, "Gigabyte AZ370-Gaming", ALC1220_FIXUP_GB_D= UAL_CODECS), SND_PCI_QUIRK(0x1458, 0xa0cd, "Gigabyte X570 Aorus Master", ALC1220_FIXUP= _GB_X570), - SND_PCI_QUIRK(0x1458, 0xa0ce, "Gigabyte X570 Aorus Xtreme", ALC1220_FIXUP= _CLEVO_P950), + SND_PCI_QUIRK(0x1458, 0xa0ce, "Gigabyte X570 Aorus Xtreme", ALC1220_FIXUP= _GB_X570), SND_PCI_QUIRK(0x1458, 0xa0d5, "Gigabyte X570S Aorus Master", ALC1220_FIXU= P_GB_X570), SND_PCI_QUIRK(0x1462, 0x11f7, "MSI-GE63", ALC1220_FIXUP_CLEVO_P950), SND_PCI_QUIRK(0x1462, 0x1228, "MSI-GP63", ALC1220_FIXUP_CLEVO_P950), From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B569BC3527C for ; Mon, 7 Feb 2022 11:55:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387252AbiBGLkv (ORCPT ); Mon, 7 Feb 2022 06:40:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384528AbiBGL2M (ORCPT ); Mon, 7 Feb 2022 06:28:12 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2113AC03BFC3; Mon, 7 Feb 2022 03:26:35 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 73B3AB80EBD; Mon, 7 Feb 2022 11:26:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B1FAC004E1; Mon, 7 Feb 2022 11:26:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233187; bh=56Msqycmh59KyAGegnD4FMQN8txHpwKB3hsT4iWHGGY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YYNCr68Ck49EQc22LUHHELtSKmh1Y0RPm7/jQqp5GxoYOiHTrcQ9OpvRfKAP2fZAv HaK7KCK0xJT3lYvIPO3f/U04QIzsNz+PigT1fHkRFjwkRq1yLLYZhcKXso/kZ8o1Ir jWHyYsIhBsyLPBczv/hbdJVIcdw83Du97m972gJY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Qu Wenruo , David Sterba Subject: [PATCH 5.15 017/110] btrfs: dont start transaction for scrub if the fs is mounted read-only Date: Mon, 7 Feb 2022 12:05:50 +0100 Message-Id: <20220207103802.844874622@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Qu Wenruo commit 2d192fc4c1abeb0d04d1c8cd54405ff4a0b0255b upstream. [BUG] The following super simple script would crash btrfs at unmount time, if CONFIG_BTRFS_ASSERT() is set. mkfs.btrfs -f $dev mount $dev $mnt xfs_io -f -c "pwrite 0 4k" $mnt/file umount $mnt mount -r ro $dev $mnt btrfs scrub start -Br $mnt umount $mnt This will trigger the following ASSERT() introduced by commit 0a31daa4b602 ("btrfs: add assertion for empty list of transactions at late stage of umount"). That patch is definitely not the cause, it just makes enough noise for developers. [CAUSE] We will start transaction for the following call chain during scrub: scrub_enumerate_chunks() |- btrfs_inc_block_group_ro() |- btrfs_join_transaction() However for RO mount, there is no running transaction at all, thus btrfs_join_transaction() will start a new transaction. Furthermore, since it's read-only mount, btrfs_sync_fs() will not call btrfs_commit_super() to commit the new but empty transaction. And leads to the ASSERT(). The bug has been there for a long time. Only the new ASSERT() makes it noisy enough to be noticed. [FIX] For read-only scrub on read-only mount, there is no need to start a transaction nor to allocate new chunks in btrfs_inc_block_group_ro(). Just do extra read-only mount check in btrfs_inc_block_group_ro(), and if it's read-only, skip all chunk allocation and go inc_block_group_ro() directly. CC: stable@vger.kernel.org # 5.4+ Signed-off-by: Qu Wenruo Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- fs/btrfs/block-group.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) --- a/fs/btrfs/block-group.c +++ b/fs/btrfs/block-group.c @@ -2511,6 +2511,19 @@ int btrfs_inc_block_group_ro(struct btrf int ret; bool dirty_bg_running; =20 + /* + * This can only happen when we are doing read-only scrub on read-only + * mount. + * In that case we should not start a new transaction on read-only fs. + * Thus here we skip all chunk allocations. + */ + if (sb_rdonly(fs_info->sb)) { + mutex_lock(&fs_info->ro_block_group_mutex); + ret =3D inc_block_group_ro(cache, 0); + mutex_unlock(&fs_info->ro_block_group_mutex); + return ret; + } + do { trans =3D btrfs_join_transaction(fs_info->extent_root); if (IS_ERR(trans)) From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E6B88C4321E for ; Mon, 7 Feb 2022 11:58:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387970AbiBGLm0 (ORCPT ); Mon, 7 Feb 2022 06:42:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359461AbiBGL2o (ORCPT ); Mon, 7 Feb 2022 06:28:44 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 634EAC0302C8; Mon, 7 Feb 2022 03:27:03 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9278660918; Mon, 7 Feb 2022 11:26:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5C8F6C004E1; Mon, 7 Feb 2022 11:26:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233203; bh=QxO093zDJo7jVi0SdrSCYZ7po+xNDDntEvzYsmfgkeA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OZMuo1ABkrj8sUesee/Sr9IIz2S34OAuvxGmuLLUFd+IQhvQgjciKC5GgC9/GiaVr t3/wvxe82u7WTQ9PNhP+yB05qa/0lrmsbdidHMPCelhY8isJvfi+HmrKVgiOb/HY+/ Gs2FTKz/6xxOjp3CwjzuyRfIMqAdCATNfMBA1XBs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nikolay Borisov , Filipe Manana , Shinichiro Kawasaki , David Sterba Subject: [PATCH 5.15 018/110] btrfs: fix deadlock between quota disable and qgroup rescan worker Date: Mon, 7 Feb 2022 12:05:51 +0100 Message-Id: <20220207103802.876475356@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Shin'ichiro Kawasaki commit e804861bd4e69cc5fe1053eedcb024982dde8e48 upstream. Quota disable ioctl starts a transaction before waiting for the qgroup rescan worker completes. However, this wait can be infinite and results in deadlock because of circular dependency among the quota disable ioctl, the qgroup rescan worker and the other task with transaction such as block group relocation task. The deadlock happens with the steps following: 1) Task A calls ioctl to disable quota. It starts a transaction and waits for qgroup rescan worker completes. 2) Task B such as block group relocation task starts a transaction and joins to the transaction that task A started. Then task B commits to the transaction. In this commit, task B waits for a commit by task A. 3) Task C as the qgroup rescan worker starts its job and starts a transaction. In this transaction start, task C waits for completion of the transaction that task A started and task B committed. This deadlock was found with fstests test case btrfs/115 and a zoned null_blk device. The test case enables and disables quota, and the block group reclaim was triggered during the quota disable by chance. The deadlock was also observed by running quota enable and disable in parallel with 'btrfs balance' command on regular null_blk devices. An example report of the deadlock: [372.469894] INFO: task kworker/u16:6:103 blocked for more than 122 secon= ds. [372.479944] Not tainted 5.16.0-rc8 #7 [372.485067] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables = this message. [372.493898] task:kworker/u16:6 state:D stack: 0 pid: 103 ppid: = 2 flags:0x00004000 [372.503285] Workqueue: btrfs-qgroup-rescan btrfs_work_helper [btrfs] [372.510782] Call Trace: [372.514092] [372.521684] __schedule+0xb56/0x4850 [372.530104] ? io_schedule_timeout+0x190/0x190 [372.538842] ? lockdep_hardirqs_on+0x7e/0x100 [372.547092] ? _raw_spin_unlock_irqrestore+0x3e/0x60 [372.555591] schedule+0xe0/0x270 [372.561894] btrfs_commit_transaction+0x18bb/0x2610 [btrfs] [372.570506] ? btrfs_apply_pending_changes+0x50/0x50 [btrfs] [372.578875] ? free_unref_page+0x3f2/0x650 [372.585484] ? finish_wait+0x270/0x270 [372.591594] ? release_extent_buffer+0x224/0x420 [btrfs] [372.599264] btrfs_qgroup_rescan_worker+0xc13/0x10c0 [btrfs] [372.607157] ? lock_release+0x3a9/0x6d0 [372.613054] ? btrfs_qgroup_account_extent+0xda0/0xda0 [btrfs] [372.620960] ? do_raw_spin_lock+0x11e/0x250 [372.627137] ? rwlock_bug.part.0+0x90/0x90 [372.633215] ? lock_is_held_type+0xe4/0x140 [372.639404] btrfs_work_helper+0x1ae/0xa90 [btrfs] [372.646268] process_one_work+0x7e9/0x1320 [372.652321] ? lock_release+0x6d0/0x6d0 [372.658081] ? pwq_dec_nr_in_flight+0x230/0x230 [372.664513] ? rwlock_bug.part.0+0x90/0x90 [372.670529] worker_thread+0x59e/0xf90 [372.676172] ? process_one_work+0x1320/0x1320 [372.682440] kthread+0x3b9/0x490 [372.687550] ? _raw_spin_unlock_irq+0x24/0x50 [372.693811] ? set_kthread_struct+0x100/0x100 [372.700052] ret_from_fork+0x22/0x30 [372.705517] [372.709747] INFO: task btrfs-transacti:2347 blocked for more than 123 se= conds. [372.729827] Not tainted 5.16.0-rc8 #7 [372.745907] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables = this message. [372.767106] task:btrfs-transacti state:D stack: 0 pid: 2347 ppid: = 2 flags:0x00004000 [372.787776] Call Trace: [372.801652] [372.812961] __schedule+0xb56/0x4850 [372.830011] ? io_schedule_timeout+0x190/0x190 [372.852547] ? lockdep_hardirqs_on+0x7e/0x100 [372.871761] ? _raw_spin_unlock_irqrestore+0x3e/0x60 [372.886792] schedule+0xe0/0x270 [372.901685] wait_current_trans+0x22c/0x310 [btrfs] [372.919743] ? btrfs_put_transaction+0x3d0/0x3d0 [btrfs] [372.938923] ? finish_wait+0x270/0x270 [372.959085] ? join_transaction+0xc75/0xe30 [btrfs] [372.977706] start_transaction+0x938/0x10a0 [btrfs] [372.997168] transaction_kthread+0x19d/0x3c0 [btrfs] [373.013021] ? btrfs_cleanup_transaction.isra.0+0xfc0/0xfc0 [btrfs] [373.031678] kthread+0x3b9/0x490 [373.047420] ? _raw_spin_unlock_irq+0x24/0x50 [373.064645] ? set_kthread_struct+0x100/0x100 [373.078571] ret_from_fork+0x22/0x30 [373.091197] [373.105611] INFO: task btrfs:3145 blocked for more than 123 seconds. [373.114147] Not tainted 5.16.0-rc8 #7 [373.120401] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables = this message. [373.130393] task:btrfs state:D stack: 0 pid: 3145 ppid: 31= 41 flags:0x00004000 [373.140998] Call Trace: [373.145501] [373.149654] __schedule+0xb56/0x4850 [373.155306] ? io_schedule_timeout+0x190/0x190 [373.161965] ? lockdep_hardirqs_on+0x7e/0x100 [373.168469] ? _raw_spin_unlock_irqrestore+0x3e/0x60 [373.175468] schedule+0xe0/0x270 [373.180814] wait_for_commit+0x104/0x150 [btrfs] [373.187643] ? test_and_set_bit+0x20/0x20 [btrfs] [373.194772] ? kmem_cache_free+0x124/0x550 [373.201191] ? btrfs_put_transaction+0x69/0x3d0 [btrfs] [373.208738] ? finish_wait+0x270/0x270 [373.214704] ? __btrfs_end_transaction+0x347/0x7b0 [btrfs] [373.222342] btrfs_commit_transaction+0x44d/0x2610 [btrfs] [373.230233] ? join_transaction+0x255/0xe30 [btrfs] [373.237334] ? btrfs_record_root_in_trans+0x4d/0x170 [btrfs] [373.245251] ? btrfs_apply_pending_changes+0x50/0x50 [btrfs] [373.253296] relocate_block_group+0x105/0xc20 [btrfs] [373.260533] ? mutex_lock_io_nested+0x1270/0x1270 [373.267516] ? btrfs_wait_nocow_writers+0x85/0x180 [btrfs] [373.275155] ? merge_reloc_roots+0x710/0x710 [btrfs] [373.283602] ? btrfs_wait_ordered_extents+0xd30/0xd30 [btrfs] [373.291934] ? kmem_cache_free+0x124/0x550 [373.298180] btrfs_relocate_block_group+0x35c/0x930 [btrfs] [373.306047] btrfs_relocate_chunk+0x85/0x210 [btrfs] [373.313229] btrfs_balance+0x12f4/0x2d20 [btrfs] [373.320227] ? lock_release+0x3a9/0x6d0 [373.326206] ? btrfs_relocate_chunk+0x210/0x210 [btrfs] [373.333591] ? lock_is_held_type+0xe4/0x140 [373.340031] ? rcu_read_lock_sched_held+0x3f/0x70 [373.346910] btrfs_ioctl_balance+0x548/0x700 [btrfs] [373.354207] btrfs_ioctl+0x7f2/0x71b0 [btrfs] [373.360774] ? lockdep_hardirqs_on_prepare+0x410/0x410 [373.367957] ? lockdep_hardirqs_on_prepare+0x410/0x410 [373.375327] ? btrfs_ioctl_get_supported_features+0x20/0x20 [btrfs] [373.383841] ? find_held_lock+0x2c/0x110 [373.389993] ? lock_release+0x3a9/0x6d0 [373.395828] ? mntput_no_expire+0xf7/0xad0 [373.402083] ? lock_is_held_type+0xe4/0x140 [373.408249] ? vfs_fileattr_set+0x9f0/0x9f0 [373.414486] ? selinux_file_ioctl+0x349/0x4e0 [373.420938] ? trace_raw_output_lock+0xb4/0xe0 [373.427442] ? selinux_inode_getsecctx+0x80/0x80 [373.434224] ? lockdep_hardirqs_on+0x7e/0x100 [373.440660] ? force_qs_rnp+0x2a0/0x6b0 [373.446534] ? lock_is_held_type+0x9b/0x140 [373.452763] ? __blkcg_punt_bio_submit+0x1b0/0x1b0 [373.459732] ? security_file_ioctl+0x50/0x90 [373.466089] __x64_sys_ioctl+0x127/0x190 [373.472022] do_syscall_64+0x3b/0x90 [373.477513] entry_SYSCALL_64_after_hwframe+0x44/0xae [373.484823] RIP: 0033:0x7f8f4af7e2bb [373.490493] RSP: 002b:00007ffcbf936178 EFLAGS: 00000246 ORIG_RAX: 000000= 0000000010 [373.500197] RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007f8f4af= 7e2bb [373.509451] RDX: 00007ffcbf936220 RSI: 00000000c4009420 RDI: 00000000000= 00003 [373.518659] RBP: 00007ffcbf93774a R08: 0000000000000013 R09: 00007f8f4b0= 2d4e0 [373.527872] R10: 00007f8f4ae87740 R11: 0000000000000246 R12: 00000000000= 00001 [373.537222] R13: 00007ffcbf936220 R14: 0000000000000000 R15: 00000000000= 00002 [373.546506] [373.550878] INFO: task btrfs:3146 blocked for more than 123 seconds. [373.559383] Not tainted 5.16.0-rc8 #7 [373.565748] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables = this message. [373.575748] task:btrfs state:D stack: 0 pid: 3146 ppid: 21= 68 flags:0x00000000 [373.586314] Call Trace: [373.590846] [373.595121] __schedule+0xb56/0x4850 [373.600901] ? __lock_acquire+0x23db/0x5030 [373.607176] ? io_schedule_timeout+0x190/0x190 [373.613954] schedule+0xe0/0x270 [373.619157] schedule_timeout+0x168/0x220 [373.625170] ? usleep_range_state+0x150/0x150 [373.631653] ? mark_held_locks+0x9e/0xe0 [373.637767] ? do_raw_spin_lock+0x11e/0x250 [373.643993] ? lockdep_hardirqs_on_prepare+0x17b/0x410 [373.651267] ? _raw_spin_unlock_irq+0x24/0x50 [373.657677] ? lockdep_hardirqs_on+0x7e/0x100 [373.664103] wait_for_completion+0x163/0x250 [373.670437] ? bit_wait_timeout+0x160/0x160 [373.676585] btrfs_quota_disable+0x176/0x9a0 [btrfs] [373.683979] ? btrfs_quota_enable+0x12f0/0x12f0 [btrfs] [373.691340] ? down_write+0xd0/0x130 [373.696880] ? down_write_killable+0x150/0x150 [373.703352] btrfs_ioctl+0x3945/0x71b0 [btrfs] [373.710061] ? find_held_lock+0x2c/0x110 [373.716192] ? lock_release+0x3a9/0x6d0 [373.722047] ? __handle_mm_fault+0x23cd/0x3050 [373.728486] ? btrfs_ioctl_get_supported_features+0x20/0x20 [btrfs] [373.737032] ? set_pte+0x6a/0x90 [373.742271] ? do_raw_spin_unlock+0x55/0x1f0 [373.748506] ? lock_is_held_type+0xe4/0x140 [373.754792] ? vfs_fileattr_set+0x9f0/0x9f0 [373.761083] ? selinux_file_ioctl+0x349/0x4e0 [373.767521] ? selinux_inode_getsecctx+0x80/0x80 [373.774247] ? __up_read+0x182/0x6e0 [373.780026] ? count_memcg_events.constprop.0+0x46/0x60 [373.787281] ? up_write+0x460/0x460 [373.792932] ? security_file_ioctl+0x50/0x90 [373.799232] __x64_sys_ioctl+0x127/0x190 [373.805237] do_syscall_64+0x3b/0x90 [373.810947] entry_SYSCALL_64_after_hwframe+0x44/0xae [373.818102] RIP: 0033:0x7f1383ea02bb [373.823847] RSP: 002b:00007fffeb4d71f8 EFLAGS: 00000202 ORIG_RAX: 000000= 0000000010 [373.833641] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f1383e= a02bb [373.842961] RDX: 00007fffeb4d7210 RSI: 00000000c0109428 RDI: 00000000000= 00003 [373.852179] RBP: 0000000000000003 R08: 0000000000000003 R09: 00000000000= 00078 [373.861408] R10: 00007f1383daec78 R11: 0000000000000202 R12: 00007fffeb4= d874a [373.870647] R13: 0000000000493099 R14: 0000000000000001 R15: 00000000000= 00000 [373.879838] [373.884018] Showing all locks held in the system: [373.894250] 3 locks held by kworker/4:1/58: [373.900356] 1 lock held by khungtaskd/63: [373.906333] #0: ffffffff8945ff60 (rcu_read_lock){....}-{1:2}, at: debug= _show_all_locks+0x53/0x260 [373.917307] 3 locks held by kworker/u16:6/103: [373.923938] #0: ffff888127b4f138 ((wq_completion)btrfs-qgroup-rescan){+= .+.}-{0:0}, at: process_one_work+0x712/0x1320 [373.936555] #1: ffff88810b817dd8 ((work_completion)(&work->normal_work)= ){+.+.}-{0:0}, at: process_one_work+0x73f/0x1320 [373.951109] #2: ffff888102dd4650 (sb_internal#2){.+.+}-{0:0}, at: btrfs= _qgroup_rescan_worker+0x1f6/0x10c0 [btrfs] [373.964027] 2 locks held by less/1803: [373.969982] #0: ffff88813ed56098 (&tty->ldisc_sem){++++}-{0:0}, at: tty= _ldisc_ref_wait+0x24/0x80 [373.981295] #1: ffffc90000b3b2e8 (&ldata->atomic_read_lock){+.+.}-{3:3}= , at: n_tty_read+0x9e2/0x1060 [373.992969] 1 lock held by btrfs-transacti/2347: [373.999893] #0: ffff88813d4887a8 (&fs_info->transaction_kthread_mutex){= +.+.}-{3:3}, at: transaction_kthread+0xe3/0x3c0 [btrfs] [374.015872] 3 locks held by btrfs/3145: [374.022298] #0: ffff888102dd4460 (sb_writers#18){.+.+}-{0:0}, at: btrfs= _ioctl_balance+0xc3/0x700 [btrfs] [374.034456] #1: ffff88813d48a0a0 (&fs_info->reclaim_bgs_lock){+.+.}-{3:= 3}, at: btrfs_balance+0xfe5/0x2d20 [btrfs] [374.047646] #2: ffff88813d488838 (&fs_info->cleaner_mutex){+.+.}-{3:3},= at: btrfs_relocate_block_group+0x354/0x930 [btrfs] [374.063295] 4 locks held by btrfs/3146: [374.069647] #0: ffff888102dd4460 (sb_writers#18){.+.+}-{0:0}, at: btrfs= _ioctl+0x38b1/0x71b0 [btrfs] [374.081601] #1: ffff88813d488bb8 (&fs_info->subvol_sem){+.+.}-{3:3}, at= : btrfs_ioctl+0x38fd/0x71b0 [btrfs] [374.094283] #2: ffff888102dd4650 (sb_internal#2){.+.+}-{0:0}, at: btrfs= _quota_disable+0xc8/0x9a0 [btrfs] [374.106885] #3: ffff88813d489800 (&fs_info->qgroup_ioctl_lock){+.+.}-{3= :3}, at: btrfs_quota_disable+0xd5/0x9a0 [btrfs] [374.126780] =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D To avoid the deadlock, wait for the qgroup rescan worker to complete before starting the transaction for the quota disable ioctl. Clear BTRFS_FS_QUOTA_ENABLE flag before the wait and the transaction to request the worker to complete. On transaction start failure, set the BTRFS_FS_QUOTA_ENABLE flag again. These BTRFS_FS_QUOTA_ENABLE flag changes can be done safely since the function btrfs_quota_disable is not called concurrently because of fs_info->subvol_sem. Also check the BTRFS_FS_QUOTA_ENABLE flag in qgroup_rescan_init to avoid another qgroup rescan worker to start after the previous qgroup worker completed. CC: stable@vger.kernel.org # 5.4+ Suggested-by: Nikolay Borisov Reviewed-by: Filipe Manana Signed-off-by: Shin'ichiro Kawasaki Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- fs/btrfs/qgroup.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c @@ -1185,9 +1185,24 @@ int btrfs_quota_disable(struct btrfs_fs_ struct btrfs_trans_handle *trans =3D NULL; int ret =3D 0; =20 + /* + * We need to have subvol_sem write locked, to prevent races between + * concurrent tasks trying to disable quotas, because we will unlock + * and relock qgroup_ioctl_lock across BTRFS_FS_QUOTA_ENABLED changes. + */ + lockdep_assert_held_write(&fs_info->subvol_sem); + mutex_lock(&fs_info->qgroup_ioctl_lock); if (!fs_info->quota_root) goto out; + + /* + * Request qgroup rescan worker to complete and wait for it. This wait + * must be done before transaction start for quota disable since it may + * deadlock with transaction by the qgroup rescan worker. + */ + clear_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags); + btrfs_qgroup_wait_for_completion(fs_info, false); mutex_unlock(&fs_info->qgroup_ioctl_lock); =20 /* @@ -1205,14 +1220,13 @@ int btrfs_quota_disable(struct btrfs_fs_ if (IS_ERR(trans)) { ret =3D PTR_ERR(trans); trans =3D NULL; + set_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags); goto out; } =20 if (!fs_info->quota_root) goto out; =20 - clear_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags); - btrfs_qgroup_wait_for_completion(fs_info, false); spin_lock(&fs_info->qgroup_lock); quota_root =3D fs_info->quota_root; fs_info->quota_root =3D NULL; @@ -3379,6 +3393,9 @@ qgroup_rescan_init(struct btrfs_fs_info btrfs_warn(fs_info, "qgroup rescan init failed, qgroup is not enabled"); ret =3D -EINVAL; + } else if (!test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags)) { + /* Quota disable is in progress */ + ret =3D -EBUSY; } =20 if (ret) { From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2286DC35271 for ; Mon, 7 Feb 2022 11:48:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387941AbiBGLmV (ORCPT ); Mon, 7 Feb 2022 06:42:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376352AbiBGL2s (ORCPT ); Mon, 7 Feb 2022 06:28:48 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 866A6C02B74A; Mon, 7 Feb 2022 03:27:05 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 56620B811A6; Mon, 7 Feb 2022 11:26:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79378C004E1; Mon, 7 Feb 2022 11:26:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233206; bh=PPIZ3FNBzNLS7oB1P31CdMJyNI6i1ZhWc0GS/K9Cs1s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gCCwZ8QC9dia0qWVyqGvXW0ns4UHc9+x75m3rhqoYIdizCn7o3/pNBvVAFpxFv6q3 dlBooOHbDNtt+jBAdhGQQtRRJcjzxuhhJrSNQby/QYLgT7bQlnR7Zl/gkxwLeYsK+Q 8mkYOYm0FJyBasK+uEWJL243psSeAw80nBFQnowI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Filipe Manana , David Sterba Subject: [PATCH 5.15 019/110] btrfs: fix use-after-free after failure to create a snapshot Date: Mon, 7 Feb 2022 12:05:52 +0100 Message-Id: <20220207103802.908849578@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Filipe Manana commit 28b21c558a3753171097193b6f6602a94169093a upstream. At ioctl.c:create_snapshot(), we allocate a pending snapshot structure and then attach it to the transaction's list of pending snapshots. After that we call btrfs_commit_transaction(), and if that returns an error we jump to 'fail' label, where we kfree() the pending snapshot structure. This can result in a later use-after-free of the pending snapshot: 1) We allocated the pending snapshot and added it to the transaction's list of pending snapshots; 2) We call btrfs_commit_transaction(), and it fails either at the first call to btrfs_run_delayed_refs() or btrfs_start_dirty_block_groups(). In both cases, we don't abort the transaction and we release our transaction handle. We jump to the 'fail' label and free the pending snapshot structure. We return with the pending snapshot still in the transaction's list; 3) Another task commits the transaction. This time there's no error at all, and then during the transaction commit it accesses a pointer to the pending snapshot structure that the snapshot creation task has already freed, resulting in a user-after-free. This issue could actually be detected by smatch, which produced the following warning: fs/btrfs/ioctl.c:843 create_snapshot() warn: '&pending_snapshot->list' no= t removed from list So fix this by not having the snapshot creation ioctl directly add the pending snapshot to the transaction's list. Instead add the pending snapshot to the transaction handle, and then at btrfs_commit_transaction() we add the snapshot to the list only when we can guarantee that any error returned after that point will result in a transaction abort, in which case the ioctl code can safely free the pending snapshot and no one can access it anymore. CC: stable@vger.kernel.org # 5.10+ Signed-off-by: Filipe Manana Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- fs/btrfs/ioctl.c | 5 +---- fs/btrfs/transaction.c | 24 ++++++++++++++++++++++++ fs/btrfs/transaction.h | 2 ++ 3 files changed, 27 insertions(+), 4 deletions(-) --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -775,10 +775,7 @@ static int create_snapshot(struct btrfs_ goto fail; } =20 - spin_lock(&fs_info->trans_lock); - list_add(&pending_snapshot->list, - &trans->transaction->pending_snapshots); - spin_unlock(&fs_info->trans_lock); + trans->pending_snapshot =3D pending_snapshot; =20 ret =3D btrfs_commit_transaction(trans); if (ret) --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -2033,6 +2033,27 @@ static inline void btrfs_wait_delalloc_f btrfs_wait_ordered_roots(fs_info, U64_MAX, 0, (u64)-1); } =20 +/* + * Add a pending snapshot associated with the given transaction handle to = the + * respective handle. This must be called after the transaction commit sta= rted + * and while holding fs_info->trans_lock. + * This serves to guarantee a caller of btrfs_commit_transaction() that it= can + * safely free the pending snapshot pointer in case btrfs_commit_transacti= on() + * returns an error. + */ +static void add_pending_snapshot(struct btrfs_trans_handle *trans) +{ + struct btrfs_transaction *cur_trans =3D trans->transaction; + + if (!trans->pending_snapshot) + return; + + lockdep_assert_held(&trans->fs_info->trans_lock); + ASSERT(cur_trans->state >=3D TRANS_STATE_COMMIT_START); + + list_add(&trans->pending_snapshot->list, &cur_trans->pending_snapshots); +} + int btrfs_commit_transaction(struct btrfs_trans_handle *trans) { struct btrfs_fs_info *fs_info =3D trans->fs_info; @@ -2106,6 +2127,8 @@ int btrfs_commit_transaction(struct btrf if (cur_trans->state >=3D TRANS_STATE_COMMIT_START) { enum btrfs_trans_state want_state =3D TRANS_STATE_COMPLETED; =20 + add_pending_snapshot(trans); + spin_unlock(&fs_info->trans_lock); refcount_inc(&cur_trans->use_count); =20 @@ -2196,6 +2219,7 @@ int btrfs_commit_transaction(struct btrf * COMMIT_DOING so make sure to wait for num_writers to =3D=3D 1 again. */ spin_lock(&fs_info->trans_lock); + add_pending_snapshot(trans); cur_trans->state =3D TRANS_STATE_COMMIT_DOING; spin_unlock(&fs_info->trans_lock); wait_event(cur_trans->writer_wait, --- a/fs/btrfs/transaction.h +++ b/fs/btrfs/transaction.h @@ -123,6 +123,8 @@ struct btrfs_trans_handle { struct btrfs_transaction *transaction; struct btrfs_block_rsv *block_rsv; struct btrfs_block_rsv *orig_rsv; + /* Set by a task that wants to create a snapshot. */ + struct btrfs_pending_snapshot *pending_snapshot; refcount_t use_count; unsigned int type; /* From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24729C433EF for ; Mon, 7 Feb 2022 11:48:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387277AbiBGLlG (ORCPT ); Mon, 7 Feb 2022 06:41:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239982AbiBGL2R (ORCPT ); Mon, 7 Feb 2022 06:28:17 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B392C03E900; Mon, 7 Feb 2022 03:26:50 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 947466006F; Mon, 7 Feb 2022 11:26:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63A4FC004E1; Mon, 7 Feb 2022 11:26:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233209; bh=Iak8vh7ApDqC2sn/lpRa3bbrO/W7x/7fol5Si/xzUNw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cE+8cg2r36/4Am6hDIf7yIV4gsX6Iwxpx37xRFYlKvdY6S6zhwFuNwk9VjXo2nSYc d9smp3L4kIeSdDS0gqGN9L715yIafCLdB1nO/me5OmKI5y806PSIpH1hyFtMiP+N1n sGXOs7rKSTG4B7r+AWtBJF4G7msZf04oN2PO4kjY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, ron minnich , ng@0x80.stream, Dominique Martinet Subject: [PATCH 5.15 020/110] Revert "fs/9p: search open fids first" Date: Mon, 7 Feb 2022 12:05:53 +0100 Message-Id: <20220207103802.942555907@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Dominique Martinet commit 22e424feb6658c5d6789e45121830357809c59cb upstream. This reverts commit 478ba09edc1f2f2ee27180a06150cb2d1a686f9c. That commit was meant as a fix for setattrs with by fd (e.g. ftruncate) to use an open fid instead of the first fid it found on lookup. The proper fix for that is to use the fid associated with the open file struct, available in iattr->ia_file for such operations, and was actually done just before in 66246641609b ("9p: retrieve fid from file when file instance exist.") As such, this commit is no longer required. Furthermore, changing lookup to return open fids first had unwanted side effects, as it turns out the protocol forbids the use of open fids for further walks (e.g. clone_fid) and we broke mounts for some servers enforcing this rule. Note this only reverts to the old working behaviour, but it's still possible for lookup to return open fids if dentry->d_fsdata is not set, so more work is needed to make sure we respect this rule in the future, for example by adding a flag to the lookup functions to only match certain fid open modes depending on caller requirements. Link: https://lkml.kernel.org/r/20220130130651.712293-1-asmadeus@codewreck.= org Fixes: 478ba09edc1f ("fs/9p: search open fids first") Cc: stable@vger.kernel.org # v5.11+ Reported-by: ron minnich Reported-by: ng@0x80.stream Signed-off-by: Dominique Martinet Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- fs/9p/fid.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) --- a/fs/9p/fid.c +++ b/fs/9p/fid.c @@ -96,12 +96,8 @@ static struct p9_fid *v9fs_fid_find(stru dentry, dentry, from_kuid(&init_user_ns, uid), any); ret =3D NULL; - - if (d_inode(dentry)) - ret =3D v9fs_fid_find_inode(d_inode(dentry), uid); - /* we'll recheck under lock if there's anything to look in */ - if (!ret && dentry->d_fsdata) { + if (dentry->d_fsdata) { struct hlist_head *h =3D (struct hlist_head *)&dentry->d_fsdata; spin_lock(&dentry->d_lock); hlist_for_each_entry(fid, h, dlist) { @@ -112,6 +108,9 @@ static struct p9_fid *v9fs_fid_find(stru } } spin_unlock(&dentry->d_lock); + } else { + if (dentry->d_inode) + ret =3D v9fs_fid_find_inode(dentry->d_inode, uid); } =20 return ret; From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2039DC4332F for ; Mon, 7 Feb 2022 11:55:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387511AbiBGLlU (ORCPT ); Mon, 7 Feb 2022 06:41:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359536AbiBGL2p (ORCPT ); Mon, 7 Feb 2022 06:28:45 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61325C08E834; Mon, 7 Feb 2022 03:26:53 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 7AEA4B80EBD; Mon, 7 Feb 2022 11:26:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8882EC004E1; Mon, 7 Feb 2022 11:26:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233212; bh=JE/jV0p/vLig4xTmzfQk4lQFfn7O51vh4mZW9DF20YE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BP7sXMhYgMS2DG8/uPFdX2hu/5CxNecOti5C+3D7ws6gK7Ku/EOwTbDhw/4u6Dt49 01RNpocPsuNhxpVZ+/hQtlz1r65OFtXeBEgji7dSqaXt3N8vsn8MymuQbSakHqIzZ4 J/lUGsTZqTPsHYXRSC42nuX6YK7fFIG/8ZzFOZFA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nick Lopez , Ilia Mirkin , Karol Herbst Subject: [PATCH 5.15 021/110] drm/nouveau: fix off by one in BIOS boundary checking Date: Mon, 7 Feb 2022 12:05:54 +0100 Message-Id: <20220207103802.973694188@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Nick Lopez commit 1b777d4d9e383d2744fc9b3a09af6ec1893c8b1a upstream. Bounds checking when parsing init scripts embedded in the BIOS reject access to the last byte. This causes driver initialization to fail on Apple eMac's with GeForce 2 MX GPUs, leaving the system with no working console. This is probably only seen on OpenFirmware machines like PowerPC Macs because the BIOS image provided by OF is only the used parts of the ROM, not a power-of-two blocks read from PCI directly so PCs always have empty bytes at the end that are never accessed. Signed-off-by: Nick Lopez Fixes: 4d4e9907ff572 ("drm/nouveau/bios: guard against out-of-bounds access= es to image") Cc: # v4.10+ Reviewed-by: Ilia Mirkin Reviewed-by: Karol Herbst Signed-off-by: Karol Herbst Link: https://patchwork.freedesktop.org/patch/msgid/20220122081906.2633061-= 1-github@glowingmonkey.org Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/gpu/drm/nouveau/nvkm/subdev/bios/base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/base.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/base.c @@ -38,7 +38,7 @@ nvbios_addr(struct nvkm_bios *bios, u32 *addr +=3D bios->imaged_addr; } =20 - if (unlikely(*addr + size >=3D bios->size)) { + if (unlikely(*addr + size > bios->size)) { nvkm_error(&bios->subdev, "OOB %d %08x %08x\n", size, p, *addr); return false; } From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D3AFC35294 for ; Mon, 7 Feb 2022 11:55:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387570AbiBGLlX (ORCPT ); Mon, 7 Feb 2022 06:41:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376276AbiBGL2r (ORCPT ); Mon, 7 Feb 2022 06:28:47 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EA2CC0302E4; Mon, 7 Feb 2022 03:27:01 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 8BCC6B811AF; Mon, 7 Feb 2022 11:26:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98C7EC004E1; Mon, 7 Feb 2022 11:26:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233215; bh=YBYj7yDQGrPkgUYjPfnVySE9VmMenelOOdeQumIsyEE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eV8kIWdiyjMzxYa0UhsXovU5kwzfIPVgAzTISUpm5Cde9q4fJ4IyZjC7d5AuUe1SZ CDnGPUruwwQGxhpkGzuEqPS2TvJKEUgARWnOzGL5F0dCX+7pwn92yiOUoYGJr2Jlzw ocLTDMLD1QI19T5TH5kVJIupPjbnqKvl+rOJKF9M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Jos=C3=A9=20Roberto=20de=20Souza?= , Imre Deak , Tvrtko Ursulin , Chia-Lin Kao Subject: [PATCH 5.15 022/110] drm/i915/adlp: Fix TypeC PHY-ready status readout Date: Mon, 7 Feb 2022 12:05:55 +0100 Message-Id: <20220207103803.006271577@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Imre Deak commit 3c6f13ad723e7206f03bb2752b01d18202b7fc9d upstream. The TCSS_DDI_STATUS register is indexed by tc_port not by the FIA port index, fix this up. This only caused an issue on TC#3/4 ports in legacy mode, as in all other cases the two indices either match (on TC#1/2) or the TCSS_DDI_STATUS_READY flag is set regardless of something being connected or not (on TC#1/2/3/4 in dp-alt and tbt-alt modes). Reported-and-tested-by: Chia-Lin Kao (AceLan) Fixes: 55ce306c2aa1 ("drm/i915/adl_p: Implement TC sequences") Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/4698 Cc: Jos=C3=A9 Roberto de Souza Cc: # v5.14+ Signed-off-by: Imre Deak Reviewed-by: Jos=C3=A9 Roberto de Souza Link: https://patchwork.freedesktop.org/patch/msgid/20220126104356.2022975-= 1-imre.deak@intel.com (cherry picked from commit 516b33460c5bee78b2055637b0547bdb0e6af754) Signed-off-by: Tvrtko Ursulin Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/gpu/drm/i915/display/intel_tc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/gpu/drm/i915/display/intel_tc.c +++ b/drivers/gpu/drm/i915/display/intel_tc.c @@ -291,10 +291,11 @@ static bool icl_tc_phy_status_complete(s static bool adl_tc_phy_status_complete(struct intel_digital_port *dig_port) { struct drm_i915_private *i915 =3D to_i915(dig_port->base.base.dev); + enum tc_port tc_port =3D intel_port_to_tc(i915, dig_port->base.port); struct intel_uncore *uncore =3D &i915->uncore; u32 val; =20 - val =3D intel_uncore_read(uncore, TCSS_DDI_STATUS(dig_port->tc_phy_fia_id= x)); + val =3D intel_uncore_read(uncore, TCSS_DDI_STATUS(tc_port)); if (val =3D=3D 0xffffffff) { drm_dbg_kms(&i915->drm, "Port %s: PHY in TCCOLD, assuming not complete\n", From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F84AC43219 for ; Mon, 7 Feb 2022 11:55:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387740AbiBGLlb (ORCPT ); Mon, 7 Feb 2022 06:41:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378403AbiBGL3N (ORCPT ); Mon, 7 Feb 2022 06:29:13 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D1CEC02B64F; Mon, 7 Feb 2022 03:27:12 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E4A8560A67; Mon, 7 Feb 2022 11:26:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2FDEC004E1; Mon, 7 Feb 2022 11:26:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233218; bh=9i6uG1aZ++DUqweaR8L6Nn40KDQFuqLBEi6rjjyAHXk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PFNzWLwEuu4ABMVxwgKsjAsMIE2iS9AqQyGcTKKJwFyXfC6PPBzWDABrEyli2E9Do JtYGO8JYv6hnha1okjJSHK9vJ/bVt0HHdcZQfgZjxwFwisuESbVHwgbF69Re6SJ1O3 U+eG4lbVi4LDb02aulFJ67Sryd43w7HsHhyTm6Ss= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Evan Quan , Alex Deucher Subject: [PATCH 5.15 023/110] drm/amd/pm: correct the MGpuFanBoost support for Beige Goby Date: Mon, 7 Feb 2022 12:05:56 +0100 Message-Id: <20220207103803.038547260@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Evan Quan commit 3ec5586b4699cfb75cdfa09425e11d121db40773 upstream. The existing way cannot handle Beige Goby well as a different PPTable data structure(PPTable_beige_goby_t instead of PPTable_t) is used there. Signed-off-by: Evan Quan Acked-by: Alex Deucher Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c @@ -3728,14 +3728,14 @@ static ssize_t sienna_cichlid_get_gpu_me =20 static int sienna_cichlid_enable_mgpu_fan_boost(struct smu_context *smu) { - struct smu_table_context *table_context =3D &smu->smu_table; - PPTable_t *smc_pptable =3D table_context->driver_pptable; + uint16_t *mgpu_fan_boost_limit_rpm; =20 + GET_PPTABLE_MEMBER(MGpuFanBoostLimitRpm, &mgpu_fan_boost_limit_rpm); /* * Skip the MGpuFanBoost setting for those ASICs * which do not support it */ - if (!smc_pptable->MGpuFanBoostLimitRpm) + if (*mgpu_fan_boost_limit_rpm =3D=3D 0) return 0; =20 return smu_cmn_send_smc_msg_with_param(smu, From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 157BCC4167D for ; Mon, 7 Feb 2022 11:45:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386746AbiBGLga (ORCPT ); Mon, 7 Feb 2022 06:36:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359847AbiBGLZu (ORCPT ); Mon, 7 Feb 2022 06:25:50 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 447F9C03F938; Mon, 7 Feb 2022 03:25:25 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CA50461426; Mon, 7 Feb 2022 11:25:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AAB8FC340F0; Mon, 7 Feb 2022 11:25:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233124; bh=FpLbFZCwIFwVPBtGjKWXVSV5VFmPi9xFQJzqfubzEq4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2CsyHAkokbcrZTmCM0JUS86H78O2QJ30zz9ORK1Z+4nueF+V4p4/Asxhg2eGh7Ogy V28LkCqv4Md1JlM7TZaPRm+jmcHWdReZMdcqDMW5jdH+/fnRVxg2nuBp251Z3wAxXn Uu8LX893cZ8WvfKhiTHkqDl9Owxv+EklIRyfWidQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Wheeler , Aric Cyr , Stylon Wang , Paul Hsieh , Alex Deucher Subject: [PATCH 5.15 024/110] drm/amd/display: watermark latencies is not enough on DCN31 Date: Mon, 7 Feb 2022 12:05:57 +0100 Message-Id: <20220207103803.068724708@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Paul Hsieh commit f5fa54f45ab41cbb1f99b1208f49554132ffb207 upstream. [Why] The original latencies were causing underflow in some modes. Resolution: 2880x1620@60p when HDR enable [How] 1. Replace with the up-to-date watermark values based on new measurments 2. Correct the ddr_wm_table name to DDR5 on DCN31 Tested-by: Daniel Wheeler Reviewed-by: Aric Cyr Acked-by: Stylon Wang Signed-off-by: Paul Hsieh Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/gpu/drm/amd/display/dc/clk_mgr/dcn31/dcn31_clk_mgr.c | 20 +++++-= ----- 1 file changed, 10 insertions(+), 10 deletions(-) --- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn31/dcn31_clk_mgr.c +++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn31/dcn31_clk_mgr.c @@ -324,38 +324,38 @@ static struct clk_bw_params dcn31_bw_par =20 }; =20 -static struct wm_table ddr4_wm_table =3D { +static struct wm_table ddr5_wm_table =3D { .entries =3D { { .wm_inst =3D WM_A, .wm_type =3D WM_TYPE_PSTATE_CHG, .pstate_latency_us =3D 11.72, - .sr_exit_time_us =3D 6.09, - .sr_enter_plus_exit_time_us =3D 7.14, + .sr_exit_time_us =3D 9, + .sr_enter_plus_exit_time_us =3D 11, .valid =3D true, }, { .wm_inst =3D WM_B, .wm_type =3D WM_TYPE_PSTATE_CHG, .pstate_latency_us =3D 11.72, - .sr_exit_time_us =3D 10.12, - .sr_enter_plus_exit_time_us =3D 11.48, + .sr_exit_time_us =3D 9, + .sr_enter_plus_exit_time_us =3D 11, .valid =3D true, }, { .wm_inst =3D WM_C, .wm_type =3D WM_TYPE_PSTATE_CHG, .pstate_latency_us =3D 11.72, - .sr_exit_time_us =3D 10.12, - .sr_enter_plus_exit_time_us =3D 11.48, + .sr_exit_time_us =3D 9, + .sr_enter_plus_exit_time_us =3D 11, .valid =3D true, }, { .wm_inst =3D WM_D, .wm_type =3D WM_TYPE_PSTATE_CHG, .pstate_latency_us =3D 11.72, - .sr_exit_time_us =3D 10.12, - .sr_enter_plus_exit_time_us =3D 11.48, + .sr_exit_time_us =3D 9, + .sr_enter_plus_exit_time_us =3D 11, .valid =3D true, }, } @@ -683,7 +683,7 @@ void dcn31_clk_mgr_construct( if (ctx->dc_bios->integrated_info->memory_type =3D=3D LpDdr5MemType) { dcn31_bw_params.wm_table =3D lpddr5_wm_table; } else { - dcn31_bw_params.wm_table =3D ddr4_wm_table; + dcn31_bw_params.wm_table =3D ddr5_wm_table; } /* Saved clocks configured at boot for debug purposes */ dcn31_dump_clk_registers(&clk_mgr->base.base.boot_snapshot, &clk_mgr->b= ase.base, &log_info); From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 57DD8C35278 for ; Mon, 7 Feb 2022 11:45:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386758AbiBGLgf (ORCPT ); Mon, 7 Feb 2022 06:36:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380400AbiBGLZx (ORCPT ); Mon, 7 Feb 2022 06:25:53 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9E87C03E946; Mon, 7 Feb 2022 03:25:28 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B7D7E6135A; Mon, 7 Feb 2022 11:25:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A396BC340EB; Mon, 7 Feb 2022 11:25:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233127; bh=Wvu9U0FC7Jn2345zfBPmgze6YuQzHKCpO7jO646nQC4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=opbpBoAxS4VhIspCSbcwW6VjZSF5plrgY3DzWwYWb75j4c+LrOeEec3KPpQeWru7n LEzncAWA0ShYpslJ7JVJLkm9dd3rXEdtAr7WGP0pT5tVwkN3MhD5+A65DbqFgmjg4h 6WTtUb2xc3epMycRNcyDR2R9PBYaS0Q22NpdFjDI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Aun-Ali Zaidi , Harry Wentland , Aditya Garg , Alex Deucher Subject: [PATCH 5.15 025/110] drm/amd/display: Force link_rate as LINK_RATE_RBR2 for 2018 15" Apple Retina panels Date: Mon, 7 Feb 2022 12:05:58 +0100 Message-Id: <20220207103803.101677250@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Aun-Ali Zaidi commit 30fbce374745a9c6af93c775a5ac49a97f822fda upstream. The eDP link rate reported by the DP_MAX_LINK_RATE dpcd register (0xa) is contradictory to the highest rate supported reported by EDID (0xc =3D LINK_RATE_RBR2). The effects of this compounded with commit '4a8ca46bae8a ("drm/amd/display: Default max bpc to 16 for eDP")' results in no display modes being found and a dark panel. For now, simply force the maximum supported link rate for the eDP attached 2018 15" Apple Retina panels. Additionally, we must also check the firmware revision since the device ID reported by the DPCD is identical to that of the more capable 16,1, incorrectly quirking it. We also use said firmware check to quirk the refreshed 15,1 models with Vega graphics as they use a slightly newer firmware version. Tested-by: Aun-Ali Zaidi Reviewed-by: Harry Wentland Signed-off-by: Aun-Ali Zaidi Signed-off-by: Aditya Garg Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c | 20 ++++++++++++++++++= ++ 1 file changed, 20 insertions(+) --- a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c @@ -3913,6 +3913,26 @@ static bool retrieve_link_cap(struct dc_ dp_hw_fw_revision.ieee_fw_rev, sizeof(dp_hw_fw_revision.ieee_fw_rev)); =20 + /* Quirk for Apple MBP 2018 15" Retina panels: wrong DP_MAX_LINK_RATE */ + { + uint8_t str_mbp_2018[] =3D { 101, 68, 21, 103, 98, 97 }; + uint8_t fwrev_mbp_2018[] =3D { 7, 4 }; + uint8_t fwrev_mbp_2018_vega[] =3D { 8, 4 }; + + /* We also check for the firmware revision as 16,1 models have an + * identical device id and are incorrectly quirked otherwise. + */ + if ((link->dpcd_caps.sink_dev_id =3D=3D 0x0010fa) && + !memcmp(link->dpcd_caps.sink_dev_id_str, str_mbp_2018, + sizeof(str_mbp_2018)) && + (!memcmp(link->dpcd_caps.sink_fw_revision, fwrev_mbp_2018, + sizeof(fwrev_mbp_2018)) || + !memcmp(link->dpcd_caps.sink_fw_revision, fwrev_mbp_2018_vega, + sizeof(fwrev_mbp_2018_vega)))) { + link->reported_link_cap.link_rate =3D LINK_RATE_RBR2; + } + } + memset(&link->dpcd_caps.dsc_caps, '\0', sizeof(link->dpcd_caps.dsc_caps)); memset(&link->dpcd_caps.fec_cap, '\0', sizeof(link->dpcd_caps.fec_cap)); From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49A18C43217 for ; Mon, 7 Feb 2022 11:46:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358760AbiBGLhp (ORCPT ); Mon, 7 Feb 2022 06:37:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384228AbiBGL0A (ORCPT ); Mon, 7 Feb 2022 06:26:00 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82714C03FECF; Mon, 7 Feb 2022 03:25:35 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A68CCB811BE; Mon, 7 Feb 2022 11:25:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3AB1C340F0; Mon, 7 Feb 2022 11:25:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233130; bh=RvfjgcB8o1T/+ITst3mAWwtUq/8YKRmzvA/v0luQ6P4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bqb4agpgUY/0kRLNTnMXskKyI16z9DyyRdujcRzbNPdQWccpcRDCQZdxvX72KXI1B T4Bxrm88ThQ+qe3WKYs0Fyf4YI/t0zMhtssFHHRZxuXcY+MyiHHixs4hNPvlBDG3LM 9JgQIUVd9QKg6YmC2TWwQYthYTBQdvEkgJzZmghg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Uday Shankar , James Smart , Sagi Grimberg , Christoph Hellwig Subject: [PATCH 5.15 026/110] nvme-fabrics: fix state check in nvmf_ctlr_matches_baseopts() Date: Mon, 7 Feb 2022 12:05:59 +0100 Message-Id: <20220207103803.132352091@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Uday Shankar commit 6a51abdeb259a56d95f13cc67e3a0838bcda0377 upstream. Controller deletion/reset, immediately followed by or concurrent with a reconnect, is hard failing the connect attempt resulting in a complete loss of connectivity to the controller. In the connect request, fabrics looks for an existing controller with the same address components and aborts the connect if a controller already exists and the duplicate connect option isn't set. The match routine filters out controllers that are dead or dying, so they don't interfere with the new connect request. When NVME_CTRL_DELETING_NOIO was added, it missed updating the state filters in the nvmf_ctlr_matches_baseopts() routine. Thus, when in this new state, it's seen as a live controller and fails the connect request. Correct by adding the DELETING_NIO state to the match checks. Fixes: ecca390e8056 ("nvme: fix deadlock in disconnect during scan_work and= /or ana_work") Cc: # v5.7+ Signed-off-by: Uday Shankar Reviewed-by: James Smart Reviewed-by: Sagi Grimberg Signed-off-by: Christoph Hellwig Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/nvme/host/fabrics.h | 1 + 1 file changed, 1 insertion(+) --- a/drivers/nvme/host/fabrics.h +++ b/drivers/nvme/host/fabrics.h @@ -169,6 +169,7 @@ nvmf_ctlr_matches_baseopts(struct nvme_c struct nvmf_ctrl_options *opts) { if (ctrl->state =3D=3D NVME_CTRL_DELETING || + ctrl->state =3D=3D NVME_CTRL_DELETING_NOIO || ctrl->state =3D=3D NVME_CTRL_DEAD || strcmp(opts->subsysnqn, ctrl->opts->subsysnqn) || strcmp(opts->host->nqn, ctrl->opts->host->nqn) || From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7BFDAC433EF for ; Mon, 7 Feb 2022 11:46:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386860AbiBGLhz (ORCPT ); Mon, 7 Feb 2022 06:37:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355803AbiBGL0B (ORCPT ); Mon, 7 Feb 2022 06:26:01 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CAA8C03E968; Mon, 7 Feb 2022 03:25:38 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B32BEB80EC3; Mon, 7 Feb 2022 11:25:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6A65C004E1; Mon, 7 Feb 2022 11:25:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233133; bh=LLYIADvuVzP5s+T9xBErFHnFjFO3FixGAqGldwSpfRM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SQbRX+/rnigdCUOpT2p5+Zbp9lDJpqpCxfWnIqZY1fCbIlQXdCk51Pt/GEd9ETtQU TJ9/z4aqnKZFlgallqZIZYyvW3o5j0PWGWGjbCxJC7++b8oHNfYwWe8rdMPOoprSv+ Y5phggj+l5LqF41pelcg4tqJro4wuIB1SNy/ZsPI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pasha Tatashin , Zi Yan , David Rientjes , Anshuman Khandual , Paul Turner , Wei Xu , Greg Thelen , Ingo Molnar , Will Deacon , Mike Rapoport , Dave Hansen , "H. Peter Anvin" , "Aneesh Kumar K.V" , Jiri Slaby , Muchun Song , Hugh Dickins , Andrew Morton , Linus Torvalds Subject: [PATCH 5.15 027/110] mm/debug_vm_pgtable: remove pte entry from the page table Date: Mon, 7 Feb 2022 12:06:00 +0100 Message-Id: <20220207103803.165197284@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Pasha Tatashin commit fb5222aae64fe25e5f3ebefde8214dcf3ba33ca5 upstream. Patch series "page table check fixes and cleanups", v5. This patch (of 4): The pte entry that is used in pte_advanced_tests() is never removed from the page table at the end of the test. The issue is detected by page_table_check, to repro compile kernel with the following configs: CONFIG_DEBUG_VM_PGTABLE=3Dy CONFIG_PAGE_TABLE_CHECK=3Dy CONFIG_PAGE_TABLE_CHECK_ENFORCED=3Dy During the boot the following BUG is printed: debug_vm_pgtable: [debug_vm_pgtable ]: Validating architecture pa= ge table helpers ------------[ cut here ]------------ kernel BUG at mm/page_table_check.c:162! invalid opcode: 0000 [#1] PREEMPT SMP PTI CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.16.0-11413-g2c271fe77d52 #3 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.15.0-0-= g2dd4b9b3f840-prebuilt.qemu.org 04/01/2014 ... The entry should be properly removed from the page table before the page is released to the free list. Link: https://lkml.kernel.org/r/20220131203249.2832273-1-pasha.tatashin@sol= een.com Link: https://lkml.kernel.org/r/20220131203249.2832273-2-pasha.tatashin@sol= een.com Fixes: a5c3b9ffb0f4 ("mm/debug_vm_pgtable: add tests validating advanced ar= ch page table helpers") Signed-off-by: Pasha Tatashin Reviewed-by: Zi Yan Tested-by: Zi Yan Acked-by: David Rientjes Reviewed-by: Anshuman Khandual Cc: Paul Turner Cc: Wei Xu Cc: Greg Thelen Cc: Ingo Molnar Cc: Will Deacon Cc: Mike Rapoport Cc: Dave Hansen Cc: H. Peter Anvin Cc: Aneesh Kumar K.V Cc: Jiri Slaby Cc: Muchun Song Cc: Hugh Dickins Cc: [5.9+] Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- mm/debug_vm_pgtable.c | 2 ++ 1 file changed, 2 insertions(+) --- a/mm/debug_vm_pgtable.c +++ b/mm/debug_vm_pgtable.c @@ -171,6 +171,8 @@ static void __init pte_advanced_tests(st ptep_test_and_clear_young(args->vma, args->vaddr, args->ptep); pte =3D ptep_get(args->ptep); WARN_ON(pte_young(pte)); + + ptep_get_and_clear_full(args->mm, args->vaddr, args->ptep, 1); } =20 static void __init pte_savedwrite_tests(struct pgtable_debug_args *args) From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E313C433EF for ; Mon, 7 Feb 2022 11:46:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386970AbiBGLiQ (ORCPT ); Mon, 7 Feb 2022 06:38:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356821AbiBGL0N (ORCPT ); Mon, 7 Feb 2022 06:26:13 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A09BC03E906; Mon, 7 Feb 2022 03:25:41 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id AF518B811BF; Mon, 7 Feb 2022 11:25:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F0199C004E1; Mon, 7 Feb 2022 11:25:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233136; bh=5kuKbyyGYmLTOSeoatF/Dlu5tcSfSUYM07uZYakDJNk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KpwuVeBaRNP2l6qi6V1D48FFbhunrMMyQ2zbaTTf0xzvjhU07An0FpSLCCeNxza+N uVQ4Ldhv+KbXuuSLbXaJFW0VvlumXK/OLEYw9TaZF7+Rl6/5hbHLhmaxumv36ZC6cb 8zrcruOng8wAxm6bxCsmPhnRDppaUjEq5OpfxrbY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mike Rapoport , Christian Dietrich , Khalid Aziz , Andrew Morton , Linus Torvalds Subject: [PATCH 5.15 028/110] mm/pgtable: define pte_index so that preprocessor could recognize it Date: Mon, 7 Feb 2022 12:06:01 +0100 Message-Id: <20220207103803.197708373@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Mike Rapoport commit 314c459a6fe0957b5885fbc65c53d51444092880 upstream. Since commit 974b9b2c68f3 ("mm: consolidate pte_index() and pte_offset_*() definitions") pte_index is a static inline and there is no define for it that can be recognized by the preprocessor. As a result, vm_insert_pages() uses slower loop over vm_insert_page() instead of insert_pages() that amortizes the cost of spinlock operations when inserting multiple pages. Link: https://lkml.kernel.org/r/20220111145457.20748-1-rppt@kernel.org Fixes: 974b9b2c68f3 ("mm: consolidate pte_index() and pte_offset_*() defini= tions") Signed-off-by: Mike Rapoport Reported-by: Christian Dietrich Reviewed-by: Khalid Aziz Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- include/linux/pgtable.h | 1 + 1 file changed, 1 insertion(+) --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -62,6 +62,7 @@ static inline unsigned long pte_index(un { return (address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1); } +#define pte_index pte_index =20 #ifndef pmd_index static inline unsigned long pmd_index(unsigned long address) From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 17335C4167D for ; Mon, 7 Feb 2022 11:46:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386998AbiBGLia (ORCPT ); Mon, 7 Feb 2022 06:38:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351326AbiBGL0W (ORCPT ); Mon, 7 Feb 2022 06:26:22 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 222E6C03FEDF; Mon, 7 Feb 2022 03:25:42 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A654BB811AF; Mon, 7 Feb 2022 11:25:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3F0FC004E1; Mon, 7 Feb 2022 11:25:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233139; bh=/mdKNCS/v4khbOY4M1DC21Yj9S+GLexjOpKckihNDzo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=evuAfXvKDYWesE4R3SyADjBkE9Zk7EGfCbBLPEdobN4Huun5WwirlXFZnkrS9pBKJ Jmol1k+KWW2S46sY/ayvDLQIqkOPJRsKIBsX3YShuoPl3E/Eh+ZkKBsDfP30cZ2O6o HRyUF7RQ63LD9gCFa9T0si9k5QyRhzstmFx5nGoA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lang Yu , David Hildenbrand , Catalin Marinas , Oscar Salvador , Andrew Morton , Linus Torvalds Subject: [PATCH 5.15 029/110] mm/kmemleak: avoid scanning potential huge holes Date: Mon, 7 Feb 2022 12:06:02 +0100 Message-Id: <20220207103803.229033443@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Lang Yu commit c10a0f877fe007021d70f9cada240f42adc2b5db upstream. When using devm_request_free_mem_region() and devm_memremap_pages() to add ZONE_DEVICE memory, if requested free mem region's end pfn were huge(e.g., 0x400000000), the node_end_pfn() will be also huge (see move_pfn_range_to_zone()). Thus it creates a huge hole between node_start_pfn() and node_end_pfn(). We found on some AMD APUs, amdkfd requested such a free mem region and created a huge hole. In such a case, following code snippet was just doing busy test_bit() looping on the huge hole. for (pfn =3D start_pfn; pfn < end_pfn; pfn++) { struct page *page =3D pfn_to_online_page(pfn); if (!page) continue; ... } So we got a soft lockup: watchdog: BUG: soft lockup - CPU#6 stuck for 26s! [bash:1221] CPU: 6 PID: 1221 Comm: bash Not tainted 5.15.0-custom #1 RIP: 0010:pfn_to_online_page+0x5/0xd0 Call Trace: ? kmemleak_scan+0x16a/0x440 kmemleak_write+0x306/0x3a0 ? common_file_perm+0x72/0x170 full_proxy_write+0x5c/0x90 vfs_write+0xb9/0x260 ksys_write+0x67/0xe0 __x64_sys_write+0x1a/0x20 do_syscall_64+0x3b/0xc0 entry_SYSCALL_64_after_hwframe+0x44/0xae I did some tests with the patch. (1) amdgpu module unloaded before the patch: real 0m0.976s user 0m0.000s sys 0m0.968s after the patch: real 0m0.981s user 0m0.000s sys 0m0.973s (2) amdgpu module loaded before the patch: real 0m35.365s user 0m0.000s sys 0m35.354s after the patch: real 0m1.049s user 0m0.000s sys 0m1.042s Link: https://lkml.kernel.org/r/20211108140029.721144-1-lang.yu@amd.com Signed-off-by: Lang Yu Acked-by: David Hildenbrand Acked-by: Catalin Marinas Cc: Oscar Salvador Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- mm/kmemleak.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) --- a/mm/kmemleak.c +++ b/mm/kmemleak.c @@ -1403,7 +1403,8 @@ static void kmemleak_scan(void) { unsigned long flags; struct kmemleak_object *object; - int i; + struct zone *zone; + int __maybe_unused i; int new_leaks =3D 0; =20 jiffies_last_scan =3D jiffies; @@ -1443,9 +1444,9 @@ static void kmemleak_scan(void) * Struct page scanning for each node. */ get_online_mems(); - for_each_online_node(i) { - unsigned long start_pfn =3D node_start_pfn(i); - unsigned long end_pfn =3D node_end_pfn(i); + for_each_populated_zone(zone) { + unsigned long start_pfn =3D zone->zone_start_pfn; + unsigned long end_pfn =3D zone_end_pfn(zone); unsigned long pfn; =20 for (pfn =3D start_pfn; pfn < end_pfn; pfn++) { @@ -1454,8 +1455,8 @@ static void kmemleak_scan(void) if (!page) continue; =20 - /* only scan pages belonging to this node */ - if (page_to_nid(page) !=3D i) + /* only scan pages belonging to this zone */ + if (page_zone(page) !=3D zone) continue; /* only scan if page is in use */ if (page_count(page) =3D=3D 0) From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7413FC3526C for ; Mon, 7 Feb 2022 11:46:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387027AbiBGLin (ORCPT ); Mon, 7 Feb 2022 06:38:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352482AbiBGL0W (ORCPT ); Mon, 7 Feb 2022 06:26:22 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CA4DC03E910; Mon, 7 Feb 2022 03:25:43 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 036C76077B; Mon, 7 Feb 2022 11:25:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E20CBC340EB; Mon, 7 Feb 2022 11:25:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233142; bh=BLyOJI36eHMt72Wa5DjaMq8TiYzOPzbxdmmTZTFuakE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ca9cA0awN41CwBd19+gW5kzRI+mTH/dOgvK/rxC614KQ8itc9epcUTy1Rc6zSDiJE JbU7fMkjIR5KCfvf7Ew35aIQyLIksG825exLF1j0HHSSm9wUyd6pYY9tpmP+qmDMWa UvuGJSQazIhXtdguo9/OWUbapDhSXCAFblwIpPWc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dmitry Monakhov , Dmitry Ivanov , Alexey Lyashkov , "Martin K. Petersen" , Jens Axboe Subject: [PATCH 5.15 030/110] block: bio-integrity: Advance seed correctly for larger interval sizes Date: Mon, 7 Feb 2022 12:06:03 +0100 Message-Id: <20220207103803.263155646@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Martin K. Petersen commit b13e0c71856817fca67159b11abac350e41289f5 upstream. Commit 309a62fa3a9e ("bio-integrity: bio_integrity_advance must update integrity seed") added code to update the integrity seed value when advancing a bio. However, it failed to take into account that the integrity interval might be larger than the 512-byte block layer sector size. This broke bio splitting on PI devices with 4KB logical blocks. The seed value should be advanced by bio_integrity_intervals() and not the number of sectors. Cc: Dmitry Monakhov Cc: stable@vger.kernel.org Fixes: 309a62fa3a9e ("bio-integrity: bio_integrity_advance must update inte= grity seed") Tested-by: Dmitry Ivanov Reported-by: Alexey Lyashkov Signed-off-by: Martin K. Petersen Link: https://lore.kernel.org/r/20220204034209.4193-1-martin.petersen@oracl= e.com Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- block/bio-integrity.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -373,7 +373,7 @@ void bio_integrity_advance(struct bio *b struct blk_integrity *bi =3D blk_get_integrity(bio->bi_bdev->bd_disk); unsigned bytes =3D bio_integrity_bytes(bi, bytes_done >> 9); =20 - bip->bip_iter.bi_sector +=3D bytes_done >> 9; + bip->bip_iter.bi_sector +=3D bio_integrity_intervals(bi, bytes_done >> 9); bvec_iter_advance(bip->bip_vec, &bip->bip_iter, bytes); } =20 From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 876EAC4321E for ; Mon, 7 Feb 2022 11:46:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387053AbiBGLix (ORCPT ); Mon, 7 Feb 2022 06:38:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379840AbiBGL02 (ORCPT ); Mon, 7 Feb 2022 06:26:28 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 319B7C03E92E; Mon, 7 Feb 2022 03:25:48 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id DC728B81028; Mon, 7 Feb 2022 11:25:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EAB5FC004E1; Mon, 7 Feb 2022 11:25:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233145; bh=n9ts40NzW/gNgiYJSJZjAg4qmKmz5RkYXFbhssIVcNM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pqTQmGxULGxO1UGwHtpJNu2+vXV8BJ6MkhibLA9X3q0YlaW6xkPFg49zRvo/uA+9A ABfrHby/8f6V6OUJE1tfOCQ6tV81buGEIRX7puAR5Jt9gW9xW853zNJ2b/KwjN1E0a QgBA0AXB2Nnpi+qjNBnA1E2zk08RLkWnyZGQ2TRU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jordy Zomer , John Stultz , Sumit Semwal Subject: [PATCH 5.15 031/110] dma-buf: heaps: Fix potential spectre v1 gadget Date: Mon, 7 Feb 2022 12:06:04 +0100 Message-Id: <20220207103803.302971173@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Jordy Zomer commit 92c4cfaee6872038563c5b6f2e8e613f9d84d47d upstream. It appears like nr could be a Spectre v1 gadget as it's supplied by a user and used as an array index. Prevent the contents of kernel memory from being leaked to userspace via speculative execution by using array_index_nospec. Signed-off-by: Jordy Zomer Fixes: c02a81fba74f ("dma-buf: Add dma-buf heaps framework") Cc: # v5.6+ Acked-by: John Stultz Signed-off-by: Sumit Semwal [sumits: added fixes and cc: stable tags] Link: https://patchwork.freedesktop.org/patch/msgid/20220129150604.3461652-= 1-jordy@pwning.systems Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/dma-buf/dma-heap.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/dma-buf/dma-heap.c +++ b/drivers/dma-buf/dma-heap.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -135,6 +136,7 @@ static long dma_heap_ioctl(struct file * if (nr >=3D ARRAY_SIZE(dma_heap_ioctl_cmds)) return -EINVAL; =20 + nr =3D array_index_nospec(nr, ARRAY_SIZE(dma_heap_ioctl_cmds)); /* Get the kernel ioctl cmd that matches */ kcmd =3D dma_heap_ioctl_cmds[nr]; =20 From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 118B2C433FE for ; Mon, 7 Feb 2022 11:49:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388642AbiBGLoR (ORCPT ); Mon, 7 Feb 2022 06:44:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384232AbiBGL0a (ORCPT ); Mon, 7 Feb 2022 06:26:30 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 847EDC03E938; Mon, 7 Feb 2022 03:25:49 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1873661388; Mon, 7 Feb 2022 11:25:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DCDBEC004E1; Mon, 7 Feb 2022 11:25:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233148; bh=mEtObQG33qfn2d7Uum/gcizK3oGUXgWfZ3PZj7UOunU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iD/a638ulLYLlgdIFiVzaAU7jvAiZVye0R6DRIeMVdxxvEXmnORMiJFFsVI7OxMDk yDcQkW9hc2CV6dV5GIoRLf2daHIj7Yu7HO1KRojp0bTk+/bbn6LiY9RJsvq5uaYfdS 8Hm7rjabn3PhomoXp7j7+VCfNV1ygymdj8yc7/7M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dennis Dalessandro , Mike Marciniszyn , Jason Gunthorpe Subject: [PATCH 5.15 032/110] IB/hfi1: Fix AIP early init panic Date: Mon, 7 Feb 2022 12:06:05 +0100 Message-Id: <20220207103803.337478670@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Mike Marciniszyn commit 5f8f55b92edd621f056bdf09e572092849fabd83 upstream. An early failure in hfi1_ipoib_setup_rn() can lead to the following panic: BUG: unable to handle kernel NULL pointer dereference at 00000000000001b0 PGD 0 P4D 0 Oops: 0002 [#1] SMP NOPTI Workqueue: events work_for_cpu_fn RIP: 0010:try_to_grab_pending+0x2b/0x140 Code: 1f 44 00 00 41 55 41 54 55 48 89 d5 53 48 89 fb 9c 58 0f 1f 44 00 0= 0 48 89 c2 fa 66 0f 1f 44 00 00 48 89 55 00 40 84 f6 75 77 48 0f ba 2b= 00 72 09 31 c0 5b 5d 41 5c 41 5d c3 48 89 df e8 6c RSP: 0018:ffffb6b3cf7cfa48 EFLAGS: 00010046 RAX: 0000000000000246 RBX: 00000000000001b0 RCX: 0000000000000000 RDX: 0000000000000246 RSI: 0000000000000000 RDI: 00000000000001b0 RBP: ffffb6b3cf7cfa70 R08: 0000000000000f09 R09: 0000000000000001 R10: 0000000000000000 R11: 0000000000000001 R12: 0000000000000000 R13: ffffb6b3cf7cfa90 R14: ffffffff9b2fbfc0 R15: ffff8a4fdf244690 FS: 0000000000000000(0000) GS:ffff8a527f400000(0000) knlGS:0000000000000= 000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00000000000001b0 CR3: 00000017e2410003 CR4: 00000000007706f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 PKRU: 55555554 Call Trace: __cancel_work_timer+0x42/0x190 ? dev_printk_emit+0x4e/0x70 iowait_cancel_work+0x15/0x30 [hfi1] hfi1_ipoib_txreq_deinit+0x5a/0x220 [hfi1] ? dev_err+0x6c/0x90 hfi1_ipoib_netdev_dtor+0x15/0x30 [hfi1] hfi1_ipoib_setup_rn+0x10e/0x150 [hfi1] rdma_init_netdev+0x5a/0x80 [ib_core] ? hfi1_ipoib_free_rdma_netdev+0x20/0x20 [hfi1] ipoib_intf_init+0x6c/0x350 [ib_ipoib] ipoib_intf_alloc+0x5c/0xc0 [ib_ipoib] ipoib_add_one+0xbe/0x300 [ib_ipoib] add_client_context+0x12c/0x1a0 [ib_core] enable_device_and_get+0xdc/0x1d0 [ib_core] ib_register_device+0x572/0x6b0 [ib_core] rvt_register_device+0x11b/0x220 [rdmavt] hfi1_register_ib_device+0x6b4/0x770 [hfi1] do_init_one.isra.20+0x3e3/0x680 [hfi1] local_pci_probe+0x41/0x90 work_for_cpu_fn+0x16/0x20 process_one_work+0x1a7/0x360 ? create_worker+0x1a0/0x1a0 worker_thread+0x1cf/0x390 ? create_worker+0x1a0/0x1a0 kthread+0x116/0x130 ? kthread_flush_work_fn+0x10/0x10 ret_from_fork+0x1f/0x40 The panic happens in hfi1_ipoib_txreq_deinit() because there is a NULL deref when hfi1_ipoib_netdev_dtor() is called in this error case. hfi1_ipoib_txreq_init() and hfi1_ipoib_rxq_init() are self unwinding so fix by adjusting the error paths accordingly. Other changes: - hfi1_ipoib_free_rdma_netdev() is deleted including the free_netdev() since the netdev core code deletes calls free_netdev() - The switch to the accelerated entrances is moved to the success path. Cc: stable@vger.kernel.org Fixes: d99dc602e2a5 ("IB/hfi1: Add functions to transmit datagram ipoib pac= kets") Link: https://lore.kernel.org/r/1642287756-182313-4-git-send-email-mike.mar= ciniszyn@cornelisnetworks.com Reviewed-by: Dennis Dalessandro Signed-off-by: Mike Marciniszyn Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/infiniband/hw/hfi1/ipoib_main.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) --- a/drivers/infiniband/hw/hfi1/ipoib_main.c +++ b/drivers/infiniband/hw/hfi1/ipoib_main.c @@ -168,12 +168,6 @@ static void hfi1_ipoib_netdev_dtor(struc free_percpu(dev->tstats); } =20 -static void hfi1_ipoib_free_rdma_netdev(struct net_device *dev) -{ - hfi1_ipoib_netdev_dtor(dev); - free_netdev(dev); -} - static void hfi1_ipoib_set_id(struct net_device *dev, int id) { struct hfi1_ipoib_dev_priv *priv =3D hfi1_ipoib_priv(dev); @@ -211,24 +205,23 @@ static int hfi1_ipoib_setup_rn(struct ib priv->port_num =3D port_num; priv->netdev_ops =3D netdev->netdev_ops; =20 - netdev->netdev_ops =3D &hfi1_ipoib_netdev_ops; - ib_query_pkey(device, port_num, priv->pkey_index, &priv->pkey); =20 rc =3D hfi1_ipoib_txreq_init(priv); if (rc) { dd_dev_err(dd, "IPoIB netdev TX init - failed(%d)\n", rc); - hfi1_ipoib_free_rdma_netdev(netdev); return rc; } =20 rc =3D hfi1_ipoib_rxq_init(netdev); if (rc) { dd_dev_err(dd, "IPoIB netdev RX init - failed(%d)\n", rc); - hfi1_ipoib_free_rdma_netdev(netdev); + hfi1_ipoib_txreq_deinit(priv); return rc; } =20 + netdev->netdev_ops =3D &hfi1_ipoib_netdev_ops; + netdev->priv_destructor =3D hfi1_ipoib_netdev_dtor; netdev->needs_free_netdev =3D true; =20 From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C543C4332F for ; Mon, 7 Feb 2022 11:49:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388612AbiBGLoI (ORCPT ); Mon, 7 Feb 2022 06:44:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384247AbiBGL0d (ORCPT ); Mon, 7 Feb 2022 06:26:33 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 705E1C043181; Mon, 7 Feb 2022 03:25:52 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0FB1C6149B; Mon, 7 Feb 2022 11:25:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DBEC8C340F0; Mon, 7 Feb 2022 11:25:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233151; bh=rfau10TEWfiRA3xex5IvwTz7/kPBt7AmT1dqmMihsZM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gNDFpDSkBRnzSPy5mdz0G7o7an/6SPaB5t9g/v4IuKEMp8qB4prfw+Y+UY+ytPONs N0qq6cZxlUa3t+fz1DpBtlSI5n/PL1OOluhaIUobP4srxMMmsQMotKDa7k8pm+SwMS j7SjvK8bIvAaWEjknrG/b13uHQo5gi8wZmNmMo5o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Helge Deller , Geert Uytterhoeven , Sven Schnelle , Daniel Vetter Subject: [PATCH 5.15 033/110] Revert "fbcon: Disable accelerated scrolling" Date: Mon, 7 Feb 2022 12:06:06 +0100 Message-Id: <20220207103803.367265845@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Helge Deller commit 87ab9f6b7417349aa197a6c7098d4fdd4beebb74 upstream. This reverts commit 39aead8373b3c20bb5965c024dfb51a94e526151. Revert the first (of 2) commits which disabled scrolling acceleration in fbcon/fbdev. It introduced a regression for fbdev-supported graphic cards because of the performance penalty by doing screen scrolling by software instead of using the existing graphic card 2D hardware acceleration. Console scrolling acceleration was disabled by dropping code which checked at runtime the driver hardware capabilities for the BINFO_HWACCEL_COPYAREA or FBINFO_HWACCEL_FILLRECT flags and if set, it enabled scrollmode SCROLL_MOVE which uses hardware acceleration to move screen contents. After dropping those checks scrollmode was hard-wired to SCROLL_REDRAW instead, which forces all graphic cards to redraw every character at the new screen position when scrolling. This change effectively disabled all hardware-based scrolling acceleration = for ALL drivers, because now all kind of 2D hardware acceleration (bitblt, fillrect) in the drivers isn't used any longer. The original commit message mentions that only 3 DRM drivers (nouveau, omap= drm and gma500) used hardware acceleration in the past and thus code for checki= ng and using scrolling acceleration is obsolete. This statement is NOT TRUE, because beside the DRM drivers there are around= 35 other fbdev drivers which depend on fbdev/fbcon and still provide hardware acceleration for fbdev/fbcon. The original commit message also states that syzbot found lots of bugs in f= bcon and thus it's "often the solution to just delete code and remove features". This is true, and the bugs - which actually affected all users of fbcon, including DRM - were fixed, or code was dropped like e.g. the support for software scrollback in vgacon (commit 973c096f6a85). So to further analyze which bugs were found by syzbot, I've looked through = all patches in drivers/video which were tagged with syzbot or syzkaller back to year 2005. The vast majority fixed the reported issues on a higher level, e= .g. when screen is to be resized, or when font size is to be changed. The few o= nes which touched driver code fixed a real driver bug, e.g. by adding a check. But NONE of those patches touched code of either the SCROLL_MOVE or the SCROLL_REDRAW case. That means, there was no real reason why SCROLL_MOVE had to be ripped-out a= nd just SCROLL_REDRAW had to be used instead. The only reason I can imagine so= far was that SCROLL_MOVE wasn't used by DRM and as such it was assumed that it could go away. That argument completely missed the fact that SCROLL_MOVE is still heavily used by fbdev (non-DRM) drivers. Some people mention that using memcpy() instead of the hardware acceleratio= n is pretty much the same speed. But that's not true, at least not for older gra= phic cards and machines where we see speed decreases by factor 10 and more and t= hus this change leads to console responsiveness way worse than before. That's why the original commit is to be reverted. By reverting we reintroduce hardware-based scrolling acceleration and fix the performance regression for fbdev drivers. There isn't any impact on DRM when reverting those patches. Signed-off-by: Helge Deller Acked-by: Geert Uytterhoeven Acked-by: Sven Schnelle Cc: stable@vger.kernel.org # v5.10+ Signed-off-by: Helge Deller Signed-off-by: Daniel Vetter Link: https://patchwork.freedesktop.org/patch/msgid/20220202135531.92183-3-= deller@gmx.de Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- Documentation/gpu/todo.rst | 21 ------------------ drivers/video/fbdev/core/fbcon.c | 45 ++++++++++++++++++++++++++++++++--= ----- 2 files changed, 37 insertions(+), 29 deletions(-) --- a/Documentation/gpu/todo.rst +++ b/Documentation/gpu/todo.rst @@ -311,27 +311,6 @@ Contact: Daniel Vetter, Noralf Tronnes =20 Level: Advanced =20 -Garbage collect fbdev scrolling acceleration --------------------------------------------- - -Scroll acceleration is disabled in fbcon by hard-wiring p->scrollmode =3D -SCROLL_REDRAW. There's a ton of code this will allow us to remove: - -- lots of code in fbcon.c - -- a bunch of the hooks in fbcon_ops, maybe the remaining hooks could be ca= lled - directly instead of the function table (with a switch on p->rotate) - -- fb_copyarea is unused after this, and can be deleted from all drivers - -Note that not all acceleration code can be deleted, since clearing and cur= sor -support is still accelerated, which might be good candidates for further -deletion projects. - -Contact: Daniel Vetter - -Level: Intermediate - idr_init_base() --------------- =20 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -1025,7 +1025,7 @@ static void fbcon_init(struct vc_data *v struct vc_data *svc =3D *default_mode; struct fbcon_display *t, *p =3D &fb_display[vc->vc_num]; int logo =3D 1, new_rows, new_cols, rows, cols; - int ret; + int cap, ret; =20 if (WARN_ON(info_idx =3D=3D -1)) return; @@ -1034,6 +1034,7 @@ static void fbcon_init(struct vc_data *v con2fb_map[vc->vc_num] =3D info_idx; =20 info =3D registered_fb[con2fb_map[vc->vc_num]]; + cap =3D info->flags; =20 if (logo_shown < 0 && console_loglevel <=3D CONSOLE_LOGLEVEL_QUIET) logo_shown =3D FBCON_LOGO_DONTSHOW; @@ -1135,13 +1136,11 @@ static void fbcon_init(struct vc_data *v =20 ops->graphics =3D 0; =20 - /* - * No more hw acceleration for fbcon. - * - * FIXME: Garbage collect all the now dead code after sufficient time - * has passed. - */ - p->scrollmode =3D SCROLL_REDRAW; + if ((cap & FBINFO_HWACCEL_COPYAREA) && + !(cap & FBINFO_HWACCEL_DISABLED)) + p->scrollmode =3D SCROLL_MOVE; + else /* default to something safe */ + p->scrollmode =3D SCROLL_REDRAW; =20 /* * ++guenther: console.c:vc_allocate() relies on initializing @@ -1953,15 +1952,45 @@ static void updatescrollmode(struct fbco { struct fbcon_ops *ops =3D info->fbcon_par; int fh =3D vc->vc_font.height; + int cap =3D info->flags; + u16 t =3D 0; + int ypan =3D FBCON_SWAP(ops->rotate, info->fix.ypanstep, + info->fix.xpanstep); + int ywrap =3D FBCON_SWAP(ops->rotate, info->fix.ywrapstep, t); int yres =3D FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres); int vyres =3D FBCON_SWAP(ops->rotate, info->var.yres_virtual, info->var.xres_virtual); + int good_pan =3D (cap & FBINFO_HWACCEL_YPAN) && + divides(ypan, vc->vc_font.height) && vyres > yres; + int good_wrap =3D (cap & FBINFO_HWACCEL_YWRAP) && + divides(ywrap, vc->vc_font.height) && + divides(vc->vc_font.height, vyres) && + divides(vc->vc_font.height, yres); + int reading_fast =3D cap & FBINFO_READS_FAST; + int fast_copyarea =3D (cap & FBINFO_HWACCEL_COPYAREA) && + !(cap & FBINFO_HWACCEL_DISABLED); + int fast_imageblit =3D (cap & FBINFO_HWACCEL_IMAGEBLIT) && + !(cap & FBINFO_HWACCEL_DISABLED); =20 p->vrows =3D vyres/fh; if (yres > (fh * (vc->vc_rows + 1))) p->vrows -=3D (yres - (fh * vc->vc_rows)) / fh; if ((yres % fh) && (vyres % fh < yres % fh)) p->vrows--; + + if (good_wrap || good_pan) { + if (reading_fast || fast_copyarea) + p->scrollmode =3D good_wrap ? + SCROLL_WRAP_MOVE : SCROLL_PAN_MOVE; + else + p->scrollmode =3D good_wrap ? SCROLL_REDRAW : + SCROLL_PAN_REDRAW; + } else { + if (reading_fast || (fast_copyarea && !fast_imageblit)) + p->scrollmode =3D SCROLL_MOVE; + else + p->scrollmode =3D SCROLL_REDRAW; + } } =20 #define PITCH(w) (((w) + 7) >> 3) From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44AD7C4707A for ; Mon, 7 Feb 2022 11:48:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387100AbiBGLjN (ORCPT ); Mon, 7 Feb 2022 06:39:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384260AbiBGL1A (ORCPT ); Mon, 7 Feb 2022 06:27:00 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A817C0401E2; Mon, 7 Feb 2022 03:26:00 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 9E80AB80EC3; Mon, 7 Feb 2022 11:25:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E2DCAC004E1; Mon, 7 Feb 2022 11:25:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233157; bh=aD0fW2QKN7a3SuoAXXSIuJoa4pm6mYQpb4fAe05NYCo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZQAUQXoE0+JAVDjz4XphnZXgKpM/+VqB63Jq7hFoTUs17EyylFT9Cqi6kH1ByOqN4 XwxzMzK1KkyyNTzH3r2b/p4mQxIb5HjmK6GOS6DM4ctOehaCX+VocqIkCbLrUn4LK0 i0k8jRUz5Q+UJGeSa91/6L4eKOvZ1/kS6aha7yq4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Helge Deller , Daniel Vetter Subject: [PATCH 5.15 034/110] fbcon: Add option to enable legacy hardware acceleration Date: Mon, 7 Feb 2022 12:06:07 +0100 Message-Id: <20220207103803.407207680@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Helge Deller commit a3f781a9d6114c1d1e01defb7aa234dec45d2a5f upstream. Add a config option CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION to enable bitblt and fillrect hardware acceleration in the framebuffer console. If disabled, such acceleration will not be used, even if it is supported by the graphics hardware driver. If you plan to use DRM as your main graphics output system, you should disable this option since it will prevent compiling in code which isn't used later on when DRM takes over. For all other configurations, e.g. if none of your graphic cards support DRM (yet), DRM isn't available for your architecture, or you can't be sure that the graphic card in the target system will support DRM, you most likely want to enable this option. In the non-accelerated case (e.g. when DRM is used), the inlined fb_scrollmode() function is hardcoded to return SCROLL_REDRAW and as such t= he compiler is able to optimize much unneccesary code away. In this v3 patch version I additionally changed the GETVYRES() and GETVXRES= () macros to take a pointer to the fbcon_display struct. This fixes the build = when console rotation is enabled and helps the compiler again to optimize out co= de. Signed-off-by: Helge Deller Cc: stable@vger.kernel.org # v5.10+ Signed-off-by: Helge Deller Signed-off-by: Daniel Vetter Link: https://patchwork.freedesktop.org/patch/msgid/20220202135531.92183-4-= deller@gmx.de Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/video/console/Kconfig | 20 ++++++++++++++++ drivers/video/fbdev/core/fbcon.c | 39 ++++++++++++++++++++++-----= ----- drivers/video/fbdev/core/fbcon.h | 15 +++++++++++- drivers/video/fbdev/core/fbcon_ccw.c | 10 ++++---- drivers/video/fbdev/core/fbcon_cw.c | 10 ++++---- drivers/video/fbdev/core/fbcon_rotate.h | 4 +-- drivers/video/fbdev/core/fbcon_ud.c | 20 ++++++++-------- 7 files changed, 84 insertions(+), 34 deletions(-) --- a/drivers/video/console/Kconfig +++ b/drivers/video/console/Kconfig @@ -78,6 +78,26 @@ config FRAMEBUFFER_CONSOLE help Low-level framebuffer-based console driver. =20 +config FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION + bool "Enable legacy fbcon hardware acceleration code" + depends on FRAMEBUFFER_CONSOLE + default y if PARISC + default n + help + This option enables the fbcon (framebuffer text-based) hardware + acceleration for graphics drivers which were written for the fbdev + graphics interface. + + On modern machines, on mainstream machines (like x86-64) or when + using a modern Linux distribution those fbdev drivers usually aren't us= ed. + So enabling this option wouldn't have any effect, which is why you want + to disable this option on such newer machines. + + If you compile this kernel for older machines which still require the + fbdev drivers, you may want to say Y. + + If unsure, select n. + config FRAMEBUFFER_CONSOLE_DETECT_PRIMARY bool "Map the console to the primary display device" depends on FRAMEBUFFER_CONSOLE --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -1136,11 +1136,13 @@ static void fbcon_init(struct vc_data *v =20 ops->graphics =3D 0; =20 +#ifdef CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION if ((cap & FBINFO_HWACCEL_COPYAREA) && !(cap & FBINFO_HWACCEL_DISABLED)) p->scrollmode =3D SCROLL_MOVE; else /* default to something safe */ p->scrollmode =3D SCROLL_REDRAW; +#endif =20 /* * ++guenther: console.c:vc_allocate() relies on initializing @@ -1705,7 +1707,7 @@ static bool fbcon_scroll(struct vc_data count =3D vc->vc_rows; if (logo_shown >=3D 0) goto redraw_up; - switch (p->scrollmode) { + switch (fb_scrollmode(p)) { case SCROLL_MOVE: fbcon_redraw_blit(vc, info, p, t, b - t - count, count); @@ -1795,7 +1797,7 @@ static bool fbcon_scroll(struct vc_data count =3D vc->vc_rows; if (logo_shown >=3D 0) goto redraw_down; - switch (p->scrollmode) { + switch (fb_scrollmode(p)) { case SCROLL_MOVE: fbcon_redraw_blit(vc, info, p, b - 1, b - t - count, -count); @@ -1946,12 +1948,12 @@ static void fbcon_bmove_rec(struct vc_da height, width); } =20 -static void updatescrollmode(struct fbcon_display *p, +static void updatescrollmode_accel(struct fbcon_display *p, struct fb_info *info, struct vc_data *vc) { +#ifdef CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION struct fbcon_ops *ops =3D info->fbcon_par; - int fh =3D vc->vc_font.height; int cap =3D info->flags; u16 t =3D 0; int ypan =3D FBCON_SWAP(ops->rotate, info->fix.ypanstep, @@ -1972,12 +1974,6 @@ static void updatescrollmode(struct fbco int fast_imageblit =3D (cap & FBINFO_HWACCEL_IMAGEBLIT) && !(cap & FBINFO_HWACCEL_DISABLED); =20 - p->vrows =3D vyres/fh; - if (yres > (fh * (vc->vc_rows + 1))) - p->vrows -=3D (yres - (fh * vc->vc_rows)) / fh; - if ((yres % fh) && (vyres % fh < yres % fh)) - p->vrows--; - if (good_wrap || good_pan) { if (reading_fast || fast_copyarea) p->scrollmode =3D good_wrap ? @@ -1991,6 +1987,27 @@ static void updatescrollmode(struct fbco else p->scrollmode =3D SCROLL_REDRAW; } +#endif +} + +static void updatescrollmode(struct fbcon_display *p, + struct fb_info *info, + struct vc_data *vc) +{ + struct fbcon_ops *ops =3D info->fbcon_par; + int fh =3D vc->vc_font.height; + int yres =3D FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres); + int vyres =3D FBCON_SWAP(ops->rotate, info->var.yres_virtual, + info->var.xres_virtual); + + p->vrows =3D vyres/fh; + if (yres > (fh * (vc->vc_rows + 1))) + p->vrows -=3D (yres - (fh * vc->vc_rows)) / fh; + if ((yres % fh) && (vyres % fh < yres % fh)) + p->vrows--; + + /* update scrollmode in case hardware acceleration is used */ + updatescrollmode_accel(p, info, vc); } =20 #define PITCH(w) (((w) + 7) >> 3) @@ -2148,7 +2165,7 @@ static int fbcon_switch(struct vc_data * =20 updatescrollmode(p, info, vc); =20 - switch (p->scrollmode) { + switch (fb_scrollmode(p)) { case SCROLL_WRAP_MOVE: scrollback_phys_max =3D p->vrows - vc->vc_rows; break; --- a/drivers/video/fbdev/core/fbcon.h +++ b/drivers/video/fbdev/core/fbcon.h @@ -29,7 +29,9 @@ struct fbcon_display { /* Filled in by the low-level console driver */ const u_char *fontdata; int userfont; /* !=3D 0 if fontdata kmalloc()ed */ - u_short scrollmode; /* Scroll Method */ +#ifdef CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION + u_short scrollmode; /* Scroll Method, use fb_scrollmode() = */ +#endif u_short inverse; /* !=3D 0 text black on white as defau= lt */ short yscroll; /* Hardware scrolling */ int vrows; /* number of virtual rows */ @@ -208,6 +210,17 @@ static inline int attr_col_ec(int shift, #define SCROLL_REDRAW 0x004 #define SCROLL_PAN_REDRAW 0x005 =20 +static inline u_short fb_scrollmode(struct fbcon_display *fb) +{ +#ifdef CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION + return fb->scrollmode; +#else + /* hardcoded to SCROLL_REDRAW if acceleration was disabled. */ + return SCROLL_REDRAW; +#endif +} + + #ifdef CONFIG_FB_TILEBLITTING extern void fbcon_set_tileops(struct vc_data *vc, struct fb_info *info); #endif --- a/drivers/video/fbdev/core/fbcon_ccw.c +++ b/drivers/video/fbdev/core/fbcon_ccw.c @@ -65,7 +65,7 @@ static void ccw_bmove(struct vc_data *vc { struct fbcon_ops *ops =3D info->fbcon_par; struct fb_copyarea area; - u32 vyres =3D GETVYRES(ops->p->scrollmode, info); + u32 vyres =3D GETVYRES(ops->p, info); =20 area.sx =3D sy * vc->vc_font.height; area.sy =3D vyres - ((sx + width) * vc->vc_font.width); @@ -83,7 +83,7 @@ static void ccw_clear(struct vc_data *vc struct fbcon_ops *ops =3D info->fbcon_par; struct fb_fillrect region; int bgshift =3D (vc->vc_hi_font_mask) ? 13 : 12; - u32 vyres =3D GETVYRES(ops->p->scrollmode, info); + u32 vyres =3D GETVYRES(ops->p, info); =20 region.color =3D attr_bgcol_ec(bgshift,vc,info); region.dx =3D sy * vc->vc_font.height; @@ -140,7 +140,7 @@ static void ccw_putcs(struct vc_data *vc u32 cnt, pitch, size; u32 attribute =3D get_attribute(info, scr_readw(s)); u8 *dst, *buf =3D NULL; - u32 vyres =3D GETVYRES(ops->p->scrollmode, info); + u32 vyres =3D GETVYRES(ops->p, info); =20 if (!ops->fontbuffer) return; @@ -229,7 +229,7 @@ static void ccw_cursor(struct vc_data *v int attribute, use_sw =3D vc->vc_cursor_type & CUR_SW; int err =3D 1, dx, dy; char *src; - u32 vyres =3D GETVYRES(ops->p->scrollmode, info); + u32 vyres =3D GETVYRES(ops->p, info); =20 if (!ops->fontbuffer) return; @@ -387,7 +387,7 @@ static int ccw_update_start(struct fb_in { struct fbcon_ops *ops =3D info->fbcon_par; u32 yoffset; - u32 vyres =3D GETVYRES(ops->p->scrollmode, info); + u32 vyres =3D GETVYRES(ops->p, info); int err; =20 yoffset =3D (vyres - info->var.yres) - ops->var.xoffset; --- a/drivers/video/fbdev/core/fbcon_cw.c +++ b/drivers/video/fbdev/core/fbcon_cw.c @@ -50,7 +50,7 @@ static void cw_bmove(struct vc_data *vc, { struct fbcon_ops *ops =3D info->fbcon_par; struct fb_copyarea area; - u32 vxres =3D GETVXRES(ops->p->scrollmode, info); + u32 vxres =3D GETVXRES(ops->p, info); =20 area.sx =3D vxres - ((sy + height) * vc->vc_font.height); area.sy =3D sx * vc->vc_font.width; @@ -68,7 +68,7 @@ static void cw_clear(struct vc_data *vc, struct fbcon_ops *ops =3D info->fbcon_par; struct fb_fillrect region; int bgshift =3D (vc->vc_hi_font_mask) ? 13 : 12; - u32 vxres =3D GETVXRES(ops->p->scrollmode, info); + u32 vxres =3D GETVXRES(ops->p, info); =20 region.color =3D attr_bgcol_ec(bgshift,vc,info); region.dx =3D vxres - ((sy + height) * vc->vc_font.height); @@ -125,7 +125,7 @@ static void cw_putcs(struct vc_data *vc, u32 cnt, pitch, size; u32 attribute =3D get_attribute(info, scr_readw(s)); u8 *dst, *buf =3D NULL; - u32 vxres =3D GETVXRES(ops->p->scrollmode, info); + u32 vxres =3D GETVXRES(ops->p, info); =20 if (!ops->fontbuffer) return; @@ -212,7 +212,7 @@ static void cw_cursor(struct vc_data *vc int attribute, use_sw =3D vc->vc_cursor_type & CUR_SW; int err =3D 1, dx, dy; char *src; - u32 vxres =3D GETVXRES(ops->p->scrollmode, info); + u32 vxres =3D GETVXRES(ops->p, info); =20 if (!ops->fontbuffer) return; @@ -369,7 +369,7 @@ static void cw_cursor(struct vc_data *vc static int cw_update_start(struct fb_info *info) { struct fbcon_ops *ops =3D info->fbcon_par; - u32 vxres =3D GETVXRES(ops->p->scrollmode, info); + u32 vxres =3D GETVXRES(ops->p, info); u32 xoffset; int err; =20 --- a/drivers/video/fbdev/core/fbcon_rotate.h +++ b/drivers/video/fbdev/core/fbcon_rotate.h @@ -12,11 +12,11 @@ #define _FBCON_ROTATE_H =20 #define GETVYRES(s,i) ({ \ - (s =3D=3D SCROLL_REDRAW || s =3D=3D SCROLL_MOVE) ? \ + (fb_scrollmode(s) =3D=3D SCROLL_REDRAW || fb_scrollmode(s) =3D=3D = SCROLL_MOVE) ? \ (i)->var.yres : (i)->var.yres_virtual; }) =20 #define GETVXRES(s,i) ({ \ - (s =3D=3D SCROLL_REDRAW || s =3D=3D SCROLL_MOVE || !(i)->fix.xpans= tep) ? \ + (fb_scrollmode(s) =3D=3D SCROLL_REDRAW || fb_scrollmode(s) =3D=3D = SCROLL_MOVE || !(i)->fix.xpanstep) ? \ (i)->var.xres : (i)->var.xres_virtual; }) =20 =20 --- a/drivers/video/fbdev/core/fbcon_ud.c +++ b/drivers/video/fbdev/core/fbcon_ud.c @@ -50,8 +50,8 @@ static void ud_bmove(struct vc_data *vc, { struct fbcon_ops *ops =3D info->fbcon_par; struct fb_copyarea area; - u32 vyres =3D GETVYRES(ops->p->scrollmode, info); - u32 vxres =3D GETVXRES(ops->p->scrollmode, info); + u32 vyres =3D GETVYRES(ops->p, info); + u32 vxres =3D GETVXRES(ops->p, info); =20 area.sy =3D vyres - ((sy + height) * vc->vc_font.height); area.sx =3D vxres - ((sx + width) * vc->vc_font.width); @@ -69,8 +69,8 @@ static void ud_clear(struct vc_data *vc, struct fbcon_ops *ops =3D info->fbcon_par; struct fb_fillrect region; int bgshift =3D (vc->vc_hi_font_mask) ? 13 : 12; - u32 vyres =3D GETVYRES(ops->p->scrollmode, info); - u32 vxres =3D GETVXRES(ops->p->scrollmode, info); + u32 vyres =3D GETVYRES(ops->p, info); + u32 vxres =3D GETVXRES(ops->p, info); =20 region.color =3D attr_bgcol_ec(bgshift,vc,info); region.dy =3D vyres - ((sy + height) * vc->vc_font.height); @@ -162,8 +162,8 @@ static void ud_putcs(struct vc_data *vc, u32 mod =3D vc->vc_font.width % 8, cnt, pitch, size; u32 attribute =3D get_attribute(info, scr_readw(s)); u8 *dst, *buf =3D NULL; - u32 vyres =3D GETVYRES(ops->p->scrollmode, info); - u32 vxres =3D GETVXRES(ops->p->scrollmode, info); + u32 vyres =3D GETVYRES(ops->p, info); + u32 vxres =3D GETVXRES(ops->p, info); =20 if (!ops->fontbuffer) return; @@ -259,8 +259,8 @@ static void ud_cursor(struct vc_data *vc int attribute, use_sw =3D vc->vc_cursor_type & CUR_SW; int err =3D 1, dx, dy; char *src; - u32 vyres =3D GETVYRES(ops->p->scrollmode, info); - u32 vxres =3D GETVXRES(ops->p->scrollmode, info); + u32 vyres =3D GETVYRES(ops->p, info); + u32 vxres =3D GETVXRES(ops->p, info); =20 if (!ops->fontbuffer) return; @@ -410,8 +410,8 @@ static int ud_update_start(struct fb_inf { struct fbcon_ops *ops =3D info->fbcon_par; int xoffset, yoffset; - u32 vyres =3D GETVYRES(ops->p->scrollmode, info); - u32 vxres =3D GETVXRES(ops->p->scrollmode, info); + u32 vyres =3D GETVYRES(ops->p, info); + u32 vxres =3D GETVXRES(ops->p, info); int err; =20 xoffset =3D vxres - info->var.xres - ops->var.xoffset; From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87F19C4167E for ; Mon, 7 Feb 2022 11:48:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387080AbiBGLjE (ORCPT ); Mon, 7 Feb 2022 06:39:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384307AbiBGL1o (ORCPT ); Mon, 7 Feb 2022 06:27:44 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31944C03FEC0; Mon, 7 Feb 2022 03:26:03 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id DCA83B81158; Mon, 7 Feb 2022 11:26:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0AD41C004E1; Mon, 7 Feb 2022 11:25:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233160; bh=gnZ42VB8luOBpe47zX/EhN1MWbO2bGrsu/FWoeueKY0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bARqaB/alJD46Uj3ajcV9eFhEx5mOiWpuqMPyDa/9p6oiojVxKGD7SMw4dv2cbbSa NHb8JoWYkd5UIogoArm6rP1XFZuYyfH4mxorpnzdRLyE2RYq5rpa8Eb9VZqPy7KcN6 eAhAyKX5weXLmna8bB50LuNMTmX+e3nuEyJyb+No= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paolo Abeni , Mat Martineau , Jakub Kicinski Subject: [PATCH 5.15 035/110] mptcp: fix msk traversal in mptcp_nl_cmd_set_flags() Date: Mon, 7 Feb 2022 12:06:08 +0100 Message-Id: <20220207103803.450454111@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Paolo Abeni commit 8e9eacad7ec7a9cbf262649ebf1fa6e6f6cc7d82 upstream. The MPTCP endpoint list is under RCU protection, guarded by the pernet spinlock. mptcp_nl_cmd_set_flags() traverses the list without acquiring the spin-lock nor under the RCU critical section. This change addresses the issue performing the lookup and the endpoint update under the pernet spinlock. [The upstream commit had to handle a lookup_by_id variable that is only present in 5.17. This version of the patch removes that variable, so the __lookup_addr() function only handles the lookup as it is implemented in 5.15 and 5.16. It also removes one 'const' keyword to prevent a warning due to differing const-ness in the 5.17 version of addresses_equal().] Fixes: 0f9f696a502e ("mptcp: add set_flags command in PM netlink") Signed-off-by: Paolo Abeni Signed-off-by: Mat Martineau Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- net/mptcp/pm_netlink.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -459,6 +459,18 @@ static unsigned int fill_remote_addresse return i; } =20 +static struct mptcp_pm_addr_entry * +__lookup_addr(struct pm_nl_pernet *pernet, struct mptcp_addr_info *info) +{ + struct mptcp_pm_addr_entry *entry; + + list_for_each_entry(entry, &pernet->local_addr_list, list) { + if (addresses_equal(&entry->addr, info, true)) + return entry; + } + return NULL; +} + static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk) { struct sock *sk =3D (struct sock *)msk; @@ -1725,17 +1737,21 @@ static int mptcp_nl_cmd_set_flags(struct if (addr.flags & MPTCP_PM_ADDR_FLAG_BACKUP) bkup =3D 1; =20 - list_for_each_entry(entry, &pernet->local_addr_list, list) { - if (addresses_equal(&entry->addr, &addr.addr, true)) { - mptcp_nl_addr_backup(net, &entry->addr, bkup); - - if (bkup) - entry->flags |=3D MPTCP_PM_ADDR_FLAG_BACKUP; - else - entry->flags &=3D ~MPTCP_PM_ADDR_FLAG_BACKUP; - } + spin_lock_bh(&pernet->lock); + entry =3D __lookup_addr(pernet, &addr.addr); + if (!entry) { + spin_unlock_bh(&pernet->lock); + return -EINVAL; } =20 + if (bkup) + entry->flags |=3D MPTCP_PM_ADDR_FLAG_BACKUP; + else + entry->flags &=3D ~MPTCP_PM_ADDR_FLAG_BACKUP; + addr =3D *entry; + spin_unlock_bh(&pernet->lock); + + mptcp_nl_addr_backup(net, &addr.addr, bkup); return 0; } =20 From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 756CAC4167B for ; Mon, 7 Feb 2022 12:00:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391198AbiBGL6n (ORCPT ); Mon, 7 Feb 2022 06:58:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384322AbiBGL1z (ORCPT ); Mon, 7 Feb 2022 06:27:55 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E8A9C03FEC9; Mon, 7 Feb 2022 03:26:04 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 12D5A614D7; Mon, 7 Feb 2022 11:26:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EAABBC004E1; Mon, 7 Feb 2022 11:26:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233163; bh=XRGvNkqVwgskbwyTHU3F4u6+gEJdsITDycdsfzLfWyI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oBJ5uEnQan3a/PNmUEQIxYlEA4nYkLBebxLzvHMwNpjp/cOWcWNwuHbwsZNfHGU5n 5bM/bgNY5kZlGixUbNGIIIg8JiYpJY/UQT3YcQdYMdnuuRYJLMf3LMNLs7QWf0P9ou VZm/k0zfJ4P04PIWDYSTtukiKjKWfLBPmaDBbuJ4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiasheng Jiang , Mark Brown , James Liao , Kevin Hilman , Frank Wunderlich , Daniel Golle , Guenter Roeck Subject: [PATCH 5.15 036/110] Revert "ASoC: mediatek: Check for error clk pointer" Date: Mon, 7 Feb 2022 12:06:09 +0100 Message-Id: <20220207103803.489983104@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Guenter Roeck This reverts commit 38accfd85e41b7ca547c5a7d4866bbc1462950cb which is commit 9de2b9286a6dd16966959b3cb34fc2ddfd39213e upstream With this patch in the tree, Chromebooks running the affected hardware no longer boot. Bisect points to this patch, and reverting it fixes the problem. An analysis of the code with this patch applied shows: ret =3D init_clks(pdev, clk); if (ret) return ERR_PTR(ret); ... for (j =3D 0; j < MAX_CLKS && data->clk_id[j]; j++) { struct clk *c =3D clk[data->clk_id[j]]; if (IS_ERR(c)) { dev_err(&pdev->dev, "%s: clk unavailable\n", data->name); return ERR_CAST(c); } scpd->clk[j] =3D c; } Not all clocks in the clk_names array have to be present. Only the clocks in the data->clk_id array are actually needed. The code already checks if the required clocks are available and bails out if not. The assumption that all clocks have to be present is wrong, and commit 9de2b9286a6d needs to be reverted. Fixes: 9de2b9286a6d ("ASoC: mediatek: Check for error clk pointer") Cc: Jiasheng Jiang Cc: Mark Brown Cc: James Liao Cc: Kevin Hilman Cc: Matthias Brugger Cc: Daniel Golle Link: https://lore.kernel.org/lkml/20220205014755.699603-1-linux@roeck-us.n= et/ Signed-off-by: Guenter Roeck Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/soc/mediatek/mtk-scpsys.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) --- a/drivers/soc/mediatek/mtk-scpsys.c +++ b/drivers/soc/mediatek/mtk-scpsys.c @@ -411,17 +411,12 @@ out: return ret; } =20 -static int init_clks(struct platform_device *pdev, struct clk **clk) +static void init_clks(struct platform_device *pdev, struct clk **clk) { int i; =20 - for (i =3D CLK_NONE + 1; i < CLK_MAX; i++) { + for (i =3D CLK_NONE + 1; i < CLK_MAX; i++) clk[i] =3D devm_clk_get(&pdev->dev, clk_names[i]); - if (IS_ERR(clk[i])) - return PTR_ERR(clk[i]); - } - - return 0; } =20 static struct scp *init_scp(struct platform_device *pdev, @@ -431,7 +426,7 @@ static struct scp *init_scp(struct platf { struct genpd_onecell_data *pd_data; struct resource *res; - int i, j, ret; + int i, j; struct scp *scp; struct clk *clk[CLK_MAX]; =20 @@ -486,9 +481,7 @@ static struct scp *init_scp(struct platf =20 pd_data->num_domains =3D num; =20 - ret =3D init_clks(pdev, clk); - if (ret) - return ERR_PTR(ret); + init_clks(pdev, clk); =20 for (i =3D 0; i < num; i++) { struct scp_domain *scpd =3D &scp->domains[i]; From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D3FFC433FE for ; Mon, 7 Feb 2022 11:49:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388585AbiBGLoB (ORCPT ); Mon, 7 Feb 2022 06:44:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384361AbiBGL2A (ORCPT ); Mon, 7 Feb 2022 06:28:00 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26AC3C03FEFF; Mon, 7 Feb 2022 03:26:08 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 83E96B811B3; Mon, 7 Feb 2022 11:26:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C95ECC004E1; Mon, 7 Feb 2022 11:26:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233166; bh=tzgF2lLRVeO9JbCxJ6yO7uNVPTSA0/Rh2rbE1TmBoxs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uX7ZnLp0r+ITwFkZPBvmyMgfN/ZG0pFX/kYkXIS60NYtUy31kPRIQ4pF4fttZw7kQ AaGFcdQx9bu0lNERJRl22TINzxqkVZDQeglJ3qp5k+RF0ams6NmAEqNCG5PkDsOd5t ngCHmCq+qr+k2jRdg0SJuaW3L+K39qMOIapdN2rU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Steven Price , James Morse , Marc Zyngier Subject: [PATCH 5.15 037/110] KVM: arm64: Avoid consuming a stale esr value when SError occur Date: Mon, 7 Feb 2022 12:06:10 +0100 Message-Id: <20220207103803.530037238@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: James Morse commit 1c71dbc8a179d99dd9bb7e7fc1888db613cf85de upstream. When any exception other than an IRQ occurs, the CPU updates the ESR_EL2 register with the exception syndrome. An SError may also become pending, and will be synchronised by KVM. KVM notes the exception type, and whether an SError was synchronised in exit_code. When an exception other than an IRQ occurs, fixup_guest_exit() updates vcpu->arch.fault.esr_el2 from the hardware register. When an SError was synchronised, the vcpu esr value is used to determine if the exception was due to an HVC. If so, ELR_EL2 is moved back one instruction. This is so that KVM can process the SError first, and re-execute the HVC if the guest survives the SError. But if an IRQ synchronises an SError, the vcpu's esr value is stale. If the previous non-IRQ exception was an HVC, KVM will corrupt ELR_EL2, causing an unrelated guest instruction to be executed twice. Check ARM_EXCEPTION_CODE() before messing with ELR_EL2, IRQs don't update this register so don't need to check. Fixes: defe21f49bc9 ("KVM: arm64: Move PC rollback on SError to HYP") Cc: stable@vger.kernel.org Reported-by: Steven Price Signed-off-by: James Morse Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/20220127122052.1584324-3-james.morse@arm.com Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- arch/arm64/kvm/hyp/include/hyp/switch.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/arch/arm64/kvm/hyp/include/hyp/switch.h +++ b/arch/arm64/kvm/hyp/include/hyp/switch.h @@ -425,7 +425,8 @@ static inline bool fixup_guest_exit(stru if (ARM_EXCEPTION_CODE(*exit_code) !=3D ARM_EXCEPTION_IRQ) vcpu->arch.fault.esr_el2 =3D read_sysreg_el2(SYS_ESR); =20 - if (ARM_SERROR_PENDING(*exit_code)) { + if (ARM_SERROR_PENDING(*exit_code) && + ARM_EXCEPTION_CODE(*exit_code) !=3D ARM_EXCEPTION_IRQ) { u8 esr_ec =3D kvm_vcpu_trap_get_class(vcpu); =20 /* From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C82FC433EF for ; Mon, 7 Feb 2022 11:48:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387119AbiBGLjV (ORCPT ); Mon, 7 Feb 2022 06:39:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384388AbiBGL2C (ORCPT ); Mon, 7 Feb 2022 06:28:02 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE7D0C03E94F; Mon, 7 Feb 2022 03:26:11 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D9D1C6006F; Mon, 7 Feb 2022 11:26:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B747BC004E1; Mon, 7 Feb 2022 11:26:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233169; bh=pejCLm/dhWAINZ/EwhvHtPsSwaQldnRAQnd2fBpHpUA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ELlspqw27oAiv79KJh4GEIh30BMh/vI0XWm/oT+1wYl4g+xMzn3OZSKOPI0nljVDH 4S78iNalFYWFYjcW4bKsXk5qVHy9ftBfaLRFcy/Mnx4iofksR6mFWlMDBO3yvufWgG ZkfLTEKhVBix7e1J0Lbu+VBrnqGn3pM5Ic0cRJzY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, James Morse , Marc Zyngier Subject: [PATCH 5.15 038/110] KVM: arm64: Stop handle_exit() from handling HVC twice when an SError occurs Date: Mon, 7 Feb 2022 12:06:11 +0100 Message-Id: <20220207103803.561653593@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: James Morse commit 1229630af88620f6e3a621a1ebd1ca14d9340df7 upstream. Prior to commit defe21f49bc9 ("KVM: arm64: Move PC rollback on SError to HYP"), when an SError is synchronised due to another exception, KVM handles the SError first. If the guest survives, the instruction that triggered the original exception is re-exectued to handle the first exception. HVC is treated as a special case as the instruction wouldn't normally be re-exectued, as its not a trap. Commit defe21f49bc9 didn't preserve the behaviour of the 'return 1' that skips the rest of handle_exit(). Since commit defe21f49bc9, KVM will try to handle the SError and the original exception at the same time. When the exception was an HVC, fixup_guest_exit() has already rolled back ELR_EL2, meaning if the guest has virtual SError masked, it will execute and handle the HVC twice. Restore the original behaviour. Fixes: defe21f49bc9 ("KVM: arm64: Move PC rollback on SError to HYP") Cc: stable@vger.kernel.org Signed-off-by: James Morse Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/20220127122052.1584324-4-james.morse@arm.com Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- arch/arm64/kvm/handle_exit.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/arch/arm64/kvm/handle_exit.c +++ b/arch/arm64/kvm/handle_exit.c @@ -226,6 +226,14 @@ int handle_exit(struct kvm_vcpu *vcpu, i { struct kvm_run *run =3D vcpu->run; =20 + if (ARM_SERROR_PENDING(exception_index)) { + /* + * The SError is handled by handle_exit_early(). If the guest + * survives it will re-execute the original instruction. + */ + return 1; + } + exception_index =3D ARM_EXCEPTION_CODE(exception_index); =20 switch (exception_index) { From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B80BBC35273 for ; Mon, 7 Feb 2022 11:49:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237362AbiBGLjn (ORCPT ); Mon, 7 Feb 2022 06:39:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384404AbiBGL2D (ORCPT ); Mon, 7 Feb 2022 06:28:03 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA330C03CA4D; Mon, 7 Feb 2022 03:26:18 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BD93360915; Mon, 7 Feb 2022 11:26:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9602BC004E1; Mon, 7 Feb 2022 11:26:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233172; bh=PKvBXJQu1nVFDRuLrKBgOdM6HGK2rycgt1IfS96CECQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HFA6XzOGMd94/dS8jv9il31rtO9ygeSrORyeilG7gBMVywI06ncqjpJwztjc0jy6e kUmdZvfNff86pDd9gkdAciAlaujcrbkbr9xt/AFWie0G13M7CdEa79396WU+P77VEq 3kXPVOjdKmzOUzHp2wS2HUAzlTlmoYZ0D/AsZU9Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maor Gottlieb , Leon Romanovsky , Jason Gunthorpe Subject: [PATCH 5.15 039/110] RDMA/cma: Use correct address when leaving multicast group Date: Mon, 7 Feb 2022 12:06:12 +0100 Message-Id: <20220207103803.598613108@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Maor Gottlieb commit d9e410ebbed9d091b97bdf45b8a3792e2878dc48 upstream. In RoCE we should use cma_iboe_set_mgid() and not cma_set_mgid to generate the mgid, otherwise we will generate an IGMP for an incorrect address. Fixes: b5de0c60cc30 ("RDMA/cma: Fix use after free race in roce multicast j= oin") Link: https://lore.kernel.org/r/913bc6783fd7a95fe71ad9454e01653ee6fb4a9a.16= 42491047.git.leonro@nvidia.com Signed-off-by: Maor Gottlieb Signed-off-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/infiniband/core/cma.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -67,8 +67,8 @@ static const char * const cma_events[] =3D [RDMA_CM_EVENT_TIMEWAIT_EXIT] =3D "timewait exit", }; =20 -static void cma_set_mgid(struct rdma_id_private *id_priv, struct sockaddr = *addr, - union ib_gid *mgid); +static void cma_iboe_set_mgid(struct sockaddr *addr, union ib_gid *mgid, + enum ib_gid_type gid_type); =20 const char *__attribute_const__ rdma_event_msg(enum rdma_cm_event_type eve= nt) { @@ -1844,17 +1844,19 @@ static void destroy_mc(struct rdma_id_pr if (dev_addr->bound_dev_if) ndev =3D dev_get_by_index(dev_addr->net, dev_addr->bound_dev_if); - if (ndev) { + if (ndev && !send_only) { + enum ib_gid_type gid_type; union ib_gid mgid; =20 - cma_set_mgid(id_priv, (struct sockaddr *)&mc->addr, - &mgid); - - if (!send_only) - cma_igmp_send(ndev, &mgid, false); - - dev_put(ndev); + gid_type =3D id_priv->cma_dev->default_gid_type + [id_priv->id.port_num - + rdma_start_port( + id_priv->cma_dev->device)]; + cma_iboe_set_mgid((struct sockaddr *)&mc->addr, &mgid, + gid_type); + cma_igmp_send(ndev, &mgid, false); } + dev_put(ndev); =20 cancel_work_sync(&mc->iboe_join.work); } From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C511C4321E for ; Mon, 7 Feb 2022 11:49:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379098AbiBGLjs (ORCPT ); Mon, 7 Feb 2022 06:39:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384403AbiBGL2D (ORCPT ); Mon, 7 Feb 2022 06:28:03 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CBEDC043189; Mon, 7 Feb 2022 03:26:17 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 9FE8CB80EC3; Mon, 7 Feb 2022 11:26:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A82B4C340EB; Mon, 7 Feb 2022 11:26:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233175; bh=nX/spthLodhzppYhHdGfbmaXFQuRzGLMi4gWVQbVVgg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hAFE0WzNKEQbYlRWECCnpDjb6Sw2bGEb9w2mj4zniqWHBcvDVMsftwjt5NUqQUz5K fRIitt3klS7J9b2Z5Qdh46Sj/xjoZTR8QWFZkGc6zpO4B7ghTW8V/KZMEiVn2GNQEM Jft6wweEFxmAJUYl55Bqgpx9kl1w41jU9otDY8XA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+e3f96c43d19782dd14a7@syzkaller.appspotmail.com, Jason Gunthorpe , Maor Gottlieb , Leon Romanovsky Subject: [PATCH 5.15 040/110] RDMA/ucma: Protect mc during concurrent multicast leaves Date: Mon, 7 Feb 2022 12:06:13 +0100 Message-Id: <20220207103803.638511265@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Leon Romanovsky commit 36e8169ec973359f671f9ec7213547059cae972e upstream. Partially revert the commit mentioned in the Fixes line to make sure that allocation and erasing multicast struct are locked. BUG: KASAN: use-after-free in ucma_cleanup_multicast drivers/infiniband/c= ore/ucma.c:491 [inline] BUG: KASAN: use-after-free in ucma_destroy_private_ctx+0x914/0xb70 driver= s/infiniband/core/ucma.c:579 Read of size 8 at addr ffff88801bb74b00 by task syz-executor.1/25529 CPU: 0 PID: 25529 Comm: syz-executor.1 Not tainted 5.16.0-rc7-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS G= oogle 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106 print_address_description.constprop.0.cold+0x8d/0x320 mm/kasan/report.c:= 247 __kasan_report mm/kasan/report.c:433 [inline] kasan_report.cold+0x83/0xdf mm/kasan/report.c:450 ucma_cleanup_multicast drivers/infiniband/core/ucma.c:491 [inline] ucma_destroy_private_ctx+0x914/0xb70 drivers/infiniband/core/ucma.c:579 ucma_destroy_id+0x1e6/0x280 drivers/infiniband/core/ucma.c:614 ucma_write+0x25c/0x350 drivers/infiniband/core/ucma.c:1732 vfs_write+0x28e/0xae0 fs/read_write.c:588 ksys_write+0x1ee/0x250 fs/read_write.c:643 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae Currently the xarray search can touch a concurrently freeing mc as the xa_for_each() is not surrounded by any lock. Rather than hold the lock for a full scan hold it only for the effected items, which is usually an empty list. Fixes: 95fe51096b7a ("RDMA/ucma: Remove mc_list and rely on xarray") Link: https://lore.kernel.org/r/1cda5fabb1081e8d16e39a48d3a4f8160cea88b8.16= 42491047.git.leonro@nvidia.com Reported-by: syzbot+e3f96c43d19782dd14a7@syzkaller.appspotmail.com Suggested-by: Jason Gunthorpe Reviewed-by: Maor Gottlieb Signed-off-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/infiniband/core/ucma.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) --- a/drivers/infiniband/core/ucma.c +++ b/drivers/infiniband/core/ucma.c @@ -95,6 +95,7 @@ struct ucma_context { u64 uid; =20 struct list_head list; + struct list_head mc_list; struct work_struct close_work; }; =20 @@ -105,6 +106,7 @@ struct ucma_multicast { =20 u64 uid; u8 join_state; + struct list_head list; struct sockaddr_storage addr; }; =20 @@ -198,6 +200,7 @@ static struct ucma_context *ucma_alloc_c =20 INIT_WORK(&ctx->close_work, ucma_close_id); init_completion(&ctx->comp); + INIT_LIST_HEAD(&ctx->mc_list); /* So list_del() will work if we don't do ucma_finish_ctx() */ INIT_LIST_HEAD(&ctx->list); ctx->file =3D file; @@ -484,19 +487,19 @@ err1: =20 static void ucma_cleanup_multicast(struct ucma_context *ctx) { - struct ucma_multicast *mc; - unsigned long index; + struct ucma_multicast *mc, *tmp; =20 - xa_for_each(&multicast_table, index, mc) { - if (mc->ctx !=3D ctx) - continue; + xa_lock(&multicast_table); + list_for_each_entry_safe(mc, tmp, &ctx->mc_list, list) { + list_del(&mc->list); /* * At this point mc->ctx->ref is 0 so the mc cannot leave the * lock on the reader and this is enough serialization */ - xa_erase(&multicast_table, index); + __xa_erase(&multicast_table, mc->id); kfree(mc); } + xa_unlock(&multicast_table); } =20 static void ucma_cleanup_mc_events(struct ucma_multicast *mc) @@ -1469,12 +1472,16 @@ static ssize_t ucma_process_join(struct mc->uid =3D cmd->uid; memcpy(&mc->addr, addr, cmd->addr_size); =20 - if (xa_alloc(&multicast_table, &mc->id, NULL, xa_limit_32b, + xa_lock(&multicast_table); + if (__xa_alloc(&multicast_table, &mc->id, NULL, xa_limit_32b, GFP_KERNEL)) { ret =3D -ENOMEM; goto err_free_mc; } =20 + list_add_tail(&mc->list, &ctx->mc_list); + xa_unlock(&multicast_table); + mutex_lock(&ctx->mutex); ret =3D rdma_join_multicast(ctx->cm_id, (struct sockaddr *)&mc->addr, join_state, mc); @@ -1500,8 +1507,11 @@ err_leave_multicast: mutex_unlock(&ctx->mutex); ucma_cleanup_mc_events(mc); err_xa_erase: - xa_erase(&multicast_table, mc->id); + xa_lock(&multicast_table); + list_del(&mc->list); + __xa_erase(&multicast_table, mc->id); err_free_mc: + xa_unlock(&multicast_table); kfree(mc); err_put_ctx: ucma_put_ctx(ctx); @@ -1569,15 +1579,17 @@ static ssize_t ucma_leave_multicast(stru mc =3D ERR_PTR(-EINVAL); else if (!refcount_inc_not_zero(&mc->ctx->ref)) mc =3D ERR_PTR(-ENXIO); - else - __xa_erase(&multicast_table, mc->id); - xa_unlock(&multicast_table); =20 if (IS_ERR(mc)) { + xa_unlock(&multicast_table); ret =3D PTR_ERR(mc); goto out; } =20 + list_del(&mc->list); + __xa_erase(&multicast_table, mc->id); + xa_unlock(&multicast_table); + mutex_lock(&mc->ctx->mutex); rdma_leave_multicast(mc->ctx->cm_id, (struct sockaddr *) &mc->addr); mutex_unlock(&mc->ctx->mutex); From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 034EBC433F5 for ; Mon, 7 Feb 2022 11:49:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388552AbiBGLn5 (ORCPT ); Mon, 7 Feb 2022 06:43:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384438AbiBGL2E (ORCPT ); Mon, 7 Feb 2022 06:28:04 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 978B2C03C198; Mon, 7 Feb 2022 03:26:23 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 7417CB811B2; Mon, 7 Feb 2022 11:26:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9AED8C004E1; Mon, 7 Feb 2022 11:26:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233178; bh=4jVbnwfVC3bF207Ch0FiydCtVRc8MucTpP3gbvg3VWc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tevySV0x6JfPleny8H+fp9yJlyehMcvxsjCQ+OwprlD6nr6poe+yvVztbadJeVa+e 6WTNFIJdngHxz3DB75DKaIHJwOnb0gTOG0sOLJDupQFDw7MFNBK2m034PJWQqqEHwr BrFZClW4XSfCcDWgMTCqBsw5boiBVzaki3pM/wD8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Leon Romanovsky , Bernard Metzler , Jason Gunthorpe Subject: [PATCH 5.15 041/110] RDMA/siw: Fix refcounting leak in siw_create_qp() Date: Mon, 7 Feb 2022 12:06:14 +0100 Message-Id: <20220207103803.670073400@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Dan Carpenter commit a75badebfdc0b3823054bedf112edb54d6357c75 upstream. The atomic_inc() needs to be paired with an atomic_dec() on the error path. Fixes: 514aee660df4 ("RDMA: Globally allocate and release QP memory") Link: https://lore.kernel.org/r/20220118091104.GA11671@kili Signed-off-by: Dan Carpenter Reviewed-by: Leon Romanovsky Reviewed-by: Bernard Metzler Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/infiniband/sw/siw/siw_verbs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/infiniband/sw/siw/siw_verbs.c +++ b/drivers/infiniband/sw/siw/siw_verbs.c @@ -311,7 +311,8 @@ int siw_create_qp(struct ib_qp *ibqp, st =20 if (atomic_inc_return(&sdev->num_qp) > SIW_MAX_QP) { siw_dbg(base_dev, "too many QP's\n"); - return -ENOMEM; + rv =3D -ENOMEM; + goto err_atomic; } if (attrs->qp_type !=3D IB_QPT_RC) { siw_dbg(base_dev, "only RC QP's supported\n"); From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D6BEC3527B for ; Mon, 7 Feb 2022 11:55:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387239AbiBGLkm (ORCPT ); Mon, 7 Feb 2022 06:40:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384538AbiBGL2M (ORCPT ); Mon, 7 Feb 2022 06:28:12 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D59D6C03BFD9; Mon, 7 Feb 2022 03:26:35 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C54B060909; Mon, 7 Feb 2022 11:26:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC48AC004E1; Mon, 7 Feb 2022 11:26:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233181; bh=gn4OAdhu+hH8rfibNVVxX0yqlvsmy0BuWCaHNaM1xOs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kJL0RC8XbVpPaTs9zJfOwpsU6XRRwtgIBswbI8M4xn67FouCJv0K+BzB4JGLqP5zN dAFew134IAAYno2DJ/s0q92JAXIPUbZh4+GghQgCOf1KYVhSfkvhCBDrTo8vc3YHY3 P+SO41210E/myAOsXs1INv1CtiWHBsUAzYwP7/zI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dennis Dalessandro , Mike Marciniszyn , Jason Gunthorpe Subject: [PATCH 5.15 042/110] IB/rdmavt: Validate remote_addr during loopback atomic tests Date: Mon, 7 Feb 2022 12:06:15 +0100 Message-Id: <20220207103803.703835249@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Mike Marciniszyn commit 4028bccb003cf67e46632dee7f97ddc5d7b6e685 upstream. The rdma-core test suite sends an unaligned remote address and expects a failure. ERROR: test_atomic_non_aligned_addr (tests.test_atomic.AtomicTest) The qib/hfi1 rc handling validates properly, but the test has the client and server on the same system. The loopback of these operations is a distinct code path. Fix by syntaxing the proposed remote address in the loopback code path. Fixes: 15703461533a ("IB/{hfi1, qib, rdmavt}: Move ruc_loopback to rdmavt") Link: https://lore.kernel.org/r/1642584489-141005-1-git-send-email-mike.mar= ciniszyn@cornelisnetworks.com Reviewed-by: Dennis Dalessandro Signed-off-by: Mike Marciniszyn Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/infiniband/sw/rdmavt/qp.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/infiniband/sw/rdmavt/qp.c +++ b/drivers/infiniband/sw/rdmavt/qp.c @@ -3073,6 +3073,8 @@ do_write: case IB_WR_ATOMIC_FETCH_AND_ADD: if (unlikely(!(qp->qp_access_flags & IB_ACCESS_REMOTE_ATOMIC))) goto inv_err; + if (unlikely(wqe->atomic_wr.remote_addr & (sizeof(u64) - 1))) + goto inv_err; if (unlikely(!rvt_rkey_ok(qp, &qp->r_sge.sge, sizeof(u64), wqe->atomic_wr.remote_addr, wqe->atomic_wr.rkey, From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF7C0C433EF for ; Mon, 7 Feb 2022 11:55:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387332AbiBGLlK (ORCPT ); Mon, 7 Feb 2022 06:41:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238765AbiBGL2R (ORCPT ); Mon, 7 Feb 2022 06:28:17 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0EA4C0364B6; Mon, 7 Feb 2022 03:26:47 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A79E76091A; Mon, 7 Feb 2022 11:26:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87002C004E1; Mon, 7 Feb 2022 11:26:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233184; bh=lV1mkuh7zyPWVcvLXzJOB2GkO6mowb3cwC8cFqZQMqI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qphQZw38ZA6I73laFsNqdqEqAWo6HKF9w3UZeG7BifWgOS1HVwUnOLi65NukDxQei ph9nTa+xpfu7j0ErtyEPhaSJSqr+5OORAQZZKkEvo07Ex6StR7bjOHRUApfeFntXDc SSbdEBpRDBOw0kOT9yBntM6sNLj/GPCrB7eErapc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jared Holzman , Bernard Metzler , Jason Gunthorpe Subject: [PATCH 5.15 043/110] RDMA/siw: Fix broken RDMA Read Fence/Resume logic. Date: Mon, 7 Feb 2022 12:06:16 +0100 Message-Id: <20220207103803.734262243@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Bernard Metzler commit b43a76f423aa304037603fd6165c4a534d2c09a7 upstream. Code unconditionally resumed fenced SQ processing after next RDMA Read completion, even if other RDMA Read responses are still outstanding, or ORQ is full. Also adds comments for better readability of fence processing, and removes orq_get_tail() helper, which is not needed anymore. Fixes: 8b6a361b8c48 ("rdma/siw: receive path") Fixes: a531975279f3 ("rdma/siw: main include file") Link: https://lore.kernel.org/r/20220130170815.1940-1-bmt@zurich.ibm.com Reported-by: Jared Holzman Signed-off-by: Bernard Metzler Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/infiniband/sw/siw/siw.h | 7 +------ drivers/infiniband/sw/siw/siw_qp_rx.c | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 15 deletions(-) --- a/drivers/infiniband/sw/siw/siw.h +++ b/drivers/infiniband/sw/siw/siw.h @@ -644,14 +644,9 @@ static inline struct siw_sqe *orq_get_cu return &qp->orq[qp->orq_get % qp->attrs.orq_size]; } =20 -static inline struct siw_sqe *orq_get_tail(struct siw_qp *qp) -{ - return &qp->orq[qp->orq_put % qp->attrs.orq_size]; -} - static inline struct siw_sqe *orq_get_free(struct siw_qp *qp) { - struct siw_sqe *orq_e =3D orq_get_tail(qp); + struct siw_sqe *orq_e =3D &qp->orq[qp->orq_put % qp->attrs.orq_size]; =20 if (READ_ONCE(orq_e->flags) =3D=3D 0) return orq_e; --- a/drivers/infiniband/sw/siw/siw_qp_rx.c +++ b/drivers/infiniband/sw/siw/siw_qp_rx.c @@ -1153,11 +1153,12 @@ static int siw_check_tx_fence(struct siw =20 spin_lock_irqsave(&qp->orq_lock, flags); =20 - rreq =3D orq_get_current(qp); - /* free current orq entry */ + rreq =3D orq_get_current(qp); WRITE_ONCE(rreq->flags, 0); =20 + qp->orq_get++; + if (qp->tx_ctx.orq_fence) { if (unlikely(tx_waiting->wr_status !=3D SIW_WR_QUEUED)) { pr_warn("siw: [QP %u]: fence resume: bad status %d\n", @@ -1165,10 +1166,12 @@ static int siw_check_tx_fence(struct siw rv =3D -EPROTO; goto out; } - /* resume SQ processing */ + /* resume SQ processing, if possible */ if (tx_waiting->sqe.opcode =3D=3D SIW_OP_READ || tx_waiting->sqe.opcode =3D=3D SIW_OP_READ_LOCAL_INV) { - rreq =3D orq_get_tail(qp); + + /* SQ processing was stopped because of a full ORQ */ + rreq =3D orq_get_free(qp); if (unlikely(!rreq)) { pr_warn("siw: [QP %u]: no ORQE\n", qp_id(qp)); rv =3D -EPROTO; @@ -1181,15 +1184,14 @@ static int siw_check_tx_fence(struct siw resume_tx =3D 1; =20 } else if (siw_orq_empty(qp)) { + /* + * SQ processing was stopped by fenced work request. + * Resume since all previous Read's are now completed. + */ qp->tx_ctx.orq_fence =3D 0; resume_tx =3D 1; - } else { - pr_warn("siw: [QP %u]: fence resume: orq idx: %d:%d\n", - qp_id(qp), qp->orq_get, qp->orq_put); - rv =3D -EPROTO; } } - qp->orq_get++; out: spin_unlock_irqrestore(&qp->orq_lock, flags); =20 From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21309C433EF for ; Mon, 7 Feb 2022 11:45:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238708AbiBGLhk (ORCPT ); Mon, 7 Feb 2022 06:37:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384503AbiBGL2I (ORCPT ); Mon, 7 Feb 2022 06:28:08 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F26E0C03FED7; Mon, 7 Feb 2022 03:26:30 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D40F86077B; Mon, 7 Feb 2022 11:26:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 983BCC004E1; Mon, 7 Feb 2022 11:26:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233190; bh=uV0FX6F9dxSljJGabdenurckJ5uyJsUyGltbrmFkPvg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BnHNBv5RdgSryzrdhbUNyZbBnQiBKxl2Klk9c3I+lF5TUoAAlZkvvMFJmMQxtd/pC cK0tfTtYEfZrLeEHX7060keBd1FJ5tsWAsUp4ZMH3c5ZvIcph2eRRAhNIK1s6lJtYQ IuDT7LSL68klBnRtDxK9mUN+7qYG1cmzfFN/Q3pE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Leon Romanovsky , =?UTF-8?q?H=C3=A5kon=20Bugge?= , Jason Gunthorpe Subject: [PATCH 5.15 044/110] RDMA/mlx4: Dont continue event handler after memory allocation failure Date: Mon, 7 Feb 2022 12:06:17 +0100 Message-Id: <20220207103803.765024801@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Leon Romanovsky commit f3136c4ce7acf64bee43135971ca52a880572e32 upstream. The failure to allocate memory during MLX4_DEV_EVENT_PORT_MGMT_CHANGE event handler will cause skip the assignment logic, but ib_dispatch_event() will be called anyway. Fix it by calling to return instead of break after memory allocation failure. Fixes: 00f5ce99dc6e ("mlx4: Use port management change event instead of smp= _snoop") Link: https://lore.kernel.org/r/12a0e83f18cfad4b5f62654f141e240d04915e10.16= 43622264.git.leonro@nvidia.com Signed-off-by: Leon Romanovsky Reviewed-by: H=C3=A5kon Bugge Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/infiniband/hw/mlx4/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/infiniband/hw/mlx4/main.c +++ b/drivers/infiniband/hw/mlx4/main.c @@ -3249,7 +3249,7 @@ static void mlx4_ib_event(struct mlx4_de case MLX4_DEV_EVENT_PORT_MGMT_CHANGE: ew =3D kmalloc(sizeof *ew, GFP_ATOMIC); if (!ew) - break; + return; =20 INIT_WORK(&ew->work, handle_port_mgmt_change_event); memcpy(&ew->ib_eqe, eqe, sizeof *eqe); From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C82E6C3527E for ; Mon, 7 Feb 2022 11:55:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387264AbiBGLk6 (ORCPT ); Mon, 7 Feb 2022 06:40:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239674AbiBGL2R (ORCPT ); Mon, 7 Feb 2022 06:28:17 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA486C036486; Mon, 7 Feb 2022 03:26:42 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D85EDB80EC3; Mon, 7 Feb 2022 11:26:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E0848C004E1; Mon, 7 Feb 2022 11:26:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233193; bh=4tqbVWyD5n0NTZ+HZNk3x7FdAtAOGFRnc6tGhsbUSB4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gbNWbs7Vzm90zq3Muf6V2EU2t2BMAemqvuaoKJQOM28qHyKk3JgZyCVzEqnEG9Zu5 U2cpGE4A/U9+uH+KzAPkralBh688N9WMnK0Vs+TtJ96awAq1PshqKNrbNK+oZkONw2 CUnYEVBJHFmj0WhxjaqtrYEZnpwmu8KybRaDMDDw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tom Rix , Takashi Iwai Subject: [PATCH 5.15 045/110] ALSA: usb-audio: initialize variables that could ignore errors Date: Mon, 7 Feb 2022 12:06:18 +0100 Message-Id: <20220207103803.795364037@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Tom Rix commit 3da4b7403db87d39bc2613cfd790de1de99a70ab upstream. clang static analysis reports this representative issue mixer.c:1548:35: warning: Assigned value is garbage or undefined ucontrol->value.integer.value[0] =3D val; ^ ~~~ The filter_error() macro allows errors to be ignored. If errors can be ignored, initialize variables so garbage will not be used. Fixes: 48cc42973509 ("ALSA: usb-audio: Filter error from connector kctl ops= , too") Signed-off-by: Tom Rix Link: https://lore.kernel.org/r/20220126182142.1184819-1-trix@redhat.com Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/usb/mixer.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -1496,6 +1496,10 @@ error: usb_audio_err(chip, "cannot get connectors status: req =3D %#x, wValue =3D %#x, wIndex =3D = %#x, type =3D %d\n", UAC_GET_CUR, validx, idx, cval->val_type); + + if (val) + *val =3D 0; + return filter_error(cval, ret); } =20 From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00746C3527D for ; Mon, 7 Feb 2022 11:55:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387398AbiBGLlP (ORCPT ); Mon, 7 Feb 2022 06:41:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346683AbiBGL2R (ORCPT ); Mon, 7 Feb 2022 06:28:17 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83F28C03648B; Mon, 7 Feb 2022 03:26:43 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 54A6160915; Mon, 7 Feb 2022 11:26:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29522C004E1; Mon, 7 Feb 2022 11:26:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233196; bh=8eH1MdEVdu2hKNRuGIzmCqaimYky5xcS1WJ3g2iEc98=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pC67rC949IsYBDuKFWSGdVuBsMHRdxabNFOOmxgF9JTPyD1Vmvi2a3MmvvEfjELMx FgtA0ikr+V4JnJRdsB44w1iP7EJDaM23MRg1Bsi4N/DPOK8qdAKBE2NkDYsZp7I55W u78m7pHVNpmSUmqf8nL9JUTnm8zfpY1uLcNdjiQc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kernel test robot , Takashi Iwai Subject: [PATCH 5.15 046/110] ALSA: hda: Fix signedness of sscanf() arguments Date: Mon, 7 Feb 2022 12:06:19 +0100 Message-Id: <20220207103803.837857370@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Takashi Iwai commit 0444f82766f0b5b9c8302ad802dafa5dd0e722d0 upstream. The %x format of sscanf() takes an unsigned int pointer, while we pass a signed int pointer. Practically it's OK, but this may result in a compile warning. Let's fix it. Fixes: a235d5b8e550 ("ALSA: hda: Allow model option to specify PCI SSID ali= as") Reported-by: kernel test robot Link: https://lore.kernel.org/r/20220127135717.31751-1-tiwai@suse.de Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/pci/hda/hda_auto_parser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/sound/pci/hda/hda_auto_parser.c +++ b/sound/pci/hda/hda_auto_parser.c @@ -985,7 +985,7 @@ void snd_hda_pick_fixup(struct hda_codec int id =3D HDA_FIXUP_ID_NOT_SET; const char *name =3D NULL; const char *type =3D NULL; - int vendor, device; + unsigned int vendor, device; =20 if (codec->fixup_id !=3D HDA_FIXUP_ID_NOT_SET) return; From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 53204C47086 for ; Mon, 7 Feb 2022 11:55:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387656AbiBGLl1 (ORCPT ); Mon, 7 Feb 2022 06:41:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359797AbiBGL2q (ORCPT ); Mon, 7 Feb 2022 06:28:46 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B186C02C451; Mon, 7 Feb 2022 03:27:03 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id F34C0B81158; Mon, 7 Feb 2022 11:26:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 363CFC004E1; Mon, 7 Feb 2022 11:26:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233199; bh=wgI2JfwnGs9YATRBKGTUEYM00WplHCkNomidae7ocq0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0f5GyFz8ib+wdXvFIXOKyyBEOyLmUovADcSXUPARbrOlxheWnIj3ylNf3aO0QkTeY lC5nyeevmeEda4WpjmZMyW+ChmbjlsfKgBqQW8v7QRHottzOI7yDQSVcSsQTDWhVnT 037/OvvJEq11w6g3SYpB+UgJRzMnsG2yaurghuD0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guennadi Liakhovetski , Peter Ujfalusi , Takashi Iwai Subject: [PATCH 5.15 047/110] ALSA: hda: Skip codec shutdown in case the codec is not registered Date: Mon, 7 Feb 2022 12:06:20 +0100 Message-Id: <20220207103803.876984550@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Peter Ujfalusi commit 1c7f0e349aa5f8f80b1cac3d4917405332e14cdf upstream. If the codec->registered is not set then it means that pm_runtime is not yet enabled and the codec->pcm_list_head has not been initialized. The access to the not initialized pcm_list_head will lead a kernel crash during shutdown. Reported-by: Guennadi Liakhovetski Signed-off-by: Peter Ujfalusi Tested-by: Guennadi Liakhovetski Fixes: b98444ed597d ("ALSA: hda: Suspend codec at shutdown") Link: https://lore.kernel.org/r/20220201112144.29411-1-peter.ujfalusi@linux= .intel.com Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/pci/hda/hda_codec.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -3000,6 +3000,10 @@ void snd_hda_codec_shutdown(struct hda_c { struct hda_pcm *cpcm; =20 + /* Skip the shutdown if codec is not registered */ + if (!codec->registered) + return; + list_for_each_entry(cpcm, &codec->pcm_list_head, list) snd_pcm_suspend_all(cpcm->pcm); =20 From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D3F2C43217 for ; Mon, 7 Feb 2022 12:00:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389715AbiBGLux (ORCPT ); Mon, 7 Feb 2022 06:50:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384994AbiBGLa4 (ORCPT ); Mon, 7 Feb 2022 06:30:56 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A4E5C03BFE6; Mon, 7 Feb 2022 03:28:55 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 13F956077B; Mon, 7 Feb 2022 11:28:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C7565C004E1; Mon, 7 Feb 2022 11:28:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233334; bh=klD1XoqszxDtG3NN+zWwtPmHx71bBeUBfpAm8Kv5nLk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lybLKwtyl9XtKEEOkA2ZCNKwlmgrz/ocUtJZl0rKFeh9lVownQZEa2YEi9YUh6kmM 8blzDMj1vA9jJ3l6b31S0dVahGROn3yew2gRsJa1APON39wdrvM3KvRGMYbtOiDAYR t5S3o1G9Vcp/o0VJw1lEgOanY93FnQKHJRAqJFGQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lu Baolu , Guoqing Jiang , Joerg Roedel Subject: [PATCH 5.15 048/110] iommu/vt-d: Fix potential memory leak in intel_setup_irq_remapping() Date: Mon, 7 Feb 2022 12:06:21 +0100 Message-Id: <20220207103803.908885340@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Guoqing Jiang commit 99e675d473eb8cf2deac1376a0f840222fc1adcf upstream. After commit e3beca48a45b ("irqdomain/treewide: Keep firmware node unconditionally allocated"). For tear down scenario, fn is only freed after fail to allocate ir_domain, though it also should be freed in case dmar_enable_qi returns error. Besides free fn, irq_domain and ir_msi_domain need to be removed as well if intel_setup_irq_remapping fails to enable queued invalidation. Improve the rewinding path by add out_free_ir_domain and out_free_fwnode lables per Baolu's suggestion. Fixes: e3beca48a45b ("irqdomain/treewide: Keep firmware node unconditionall= y allocated") Suggested-by: Lu Baolu Signed-off-by: Guoqing Jiang Link: https://lore.kernel.org/r/20220119063640.16864-1-guoqing.jiang@linux.= dev Signed-off-by: Lu Baolu Link: https://lore.kernel.org/r/20220128031002.2219155-3-baolu.lu@linux.int= el.com Signed-off-by: Joerg Roedel Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/iommu/intel/irq_remapping.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) --- a/drivers/iommu/intel/irq_remapping.c +++ b/drivers/iommu/intel/irq_remapping.c @@ -569,9 +569,8 @@ static int intel_setup_irq_remapping(str fn, &intel_ir_domain_ops, iommu); if (!iommu->ir_domain) { - irq_domain_free_fwnode(fn); pr_err("IR%d: failed to allocate irqdomain\n", iommu->seq_id); - goto out_free_bitmap; + goto out_free_fwnode; } iommu->ir_msi_domain =3D arch_create_remap_msi_irq_domain(iommu->ir_domain, @@ -595,7 +594,7 @@ static int intel_setup_irq_remapping(str =20 if (dmar_enable_qi(iommu)) { pr_err("Failed to enable queued invalidation\n"); - goto out_free_bitmap; + goto out_free_ir_domain; } } =20 @@ -619,6 +618,14 @@ static int intel_setup_irq_remapping(str =20 return 0; =20 +out_free_ir_domain: + if (iommu->ir_msi_domain) + irq_domain_remove(iommu->ir_msi_domain); + iommu->ir_msi_domain =3D NULL; + irq_domain_remove(iommu->ir_domain); + iommu->ir_domain =3D NULL; +out_free_fwnode: + irq_domain_free_fwnode(fn); out_free_bitmap: bitmap_free(bitmap); out_free_pages: From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D71AC43217 for ; Mon, 7 Feb 2022 11:55:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387843AbiBGLlj (ORCPT ); Mon, 7 Feb 2022 06:41:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382259AbiBGL3S (ORCPT ); Mon, 7 Feb 2022 06:29:18 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0AF3C02B66A; Mon, 7 Feb 2022 03:27:22 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id F35D3B811B2; Mon, 7 Feb 2022 11:27:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3D363C340F1; Mon, 7 Feb 2022 11:27:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233224; bh=MoTW/brTC+J+UXtfZY4dtaQdrJZe9Uc4Pjt72hZLdi4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ghV6XsvgMMe6/nrjno2KIiWUIeHf74/dfxM8Vg3gV9vEt3FZpmaII3KITpErqDsZZ nsKDREkfB/ZwJvuCySQ8t25+Bmj29rEoLmkTERakLwSRVm0bFTUCxt908L12FPmkx1 ifrKEIrHE/0a8WysUbNTAYYBnh5n3FH4Rm373aok= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joerg Roedel Subject: [PATCH 5.15 049/110] iommu/amd: Fix loop timeout issue in iommu_ga_log_enable() Date: Mon, 7 Feb 2022 12:06:22 +0100 Message-Id: <20220207103803.944639925@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Joerg Roedel commit 9b45a7738eec52bf0f5d8d3d54e822962781c5f2 upstream. The polling loop for the register change in iommu_ga_log_enable() needs to have a udelay() in it. Otherwise the CPU might be faster than the IOMMU hardware and wrongly trigger the WARN_ON() further down the code stream. Use a 10us for udelay(), has there is some hardware where activation of the GA log can take more than a 100ms. A future optimization should move the activation check of the GA log to the point where it gets used for the first time. But that is a bigger change and not suitable for a fix. Fixes: 8bda0cfbdc1a ("iommu/amd: Detect and initialize guest vAPIC log") Signed-off-by: Joerg Roedel Link: https://lore.kernel.org/r/20220204115537.3894-1-joro@8bytes.org Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/iommu/amd/init.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/iommu/amd/init.c +++ b/drivers/iommu/amd/init.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -832,6 +833,7 @@ static int iommu_ga_log_enable(struct am status =3D readl(iommu->mmio_base + MMIO_STATUS_OFFSET); if (status & (MMIO_STATUS_GALOG_RUN_MASK)) break; + udelay(10); } =20 if (WARN_ON(i >=3D LOOP_TIMEOUT)) From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2DC9C35273 for ; Mon, 7 Feb 2022 11:48:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388012AbiBGLme (ORCPT ); Mon, 7 Feb 2022 06:42:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384620AbiBGL32 (ORCPT ); Mon, 7 Feb 2022 06:29:28 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 053D9C03E90D; Mon, 7 Feb 2022 03:27:42 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 9CB11B81158; Mon, 7 Feb 2022 11:27:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5593C004E1; Mon, 7 Feb 2022 11:27:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233261; bh=LAVXAkoXQsExhDaUbdXPoZ77ineNb0J+l7mx3Kv2fAw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MhUf0Eq8/fx9heHkzPgIEA1/pln1yyRBbqpdstq5cettvV1BKQ1TCdVZPZxl0TwKj F/ebaQX6sSacnOUd53T54r8stPkkUoFfZA+63XEgymai0GTU9/up1M0OnnH0tgeW7u DFNfvAkCtep0GvCxAwLHoSe1AixR2A7LSzXIw9+E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kamal Dasu , Florian Fainelli , Mark Brown Subject: [PATCH 5.15 050/110] spi: bcm-qspi: check for valid cs before applying chip select Date: Mon, 7 Feb 2022 12:06:23 +0100 Message-Id: <20220207103803.976347918@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kamal Dasu commit 2cbd27267ffe020af1442b95ec57f59a157ba85c upstream. Apply only valid chip select value. This change fixes case where chip select is set to initial value of '-1' during probe and PM supend and subsequent resume can try to use the value with undefined behaviour. Also in case where gpio based chip select, the check in bcm_qspi_chip_select() shall prevent undefined behaviour on resume. Fixes: fa236a7ef240 ("spi: bcm-qspi: Add Broadcom MSPI driver") Signed-off-by: Kamal Dasu Acked-by: Florian Fainelli Link: https://lore.kernel.org/r/20220127185359.27322-1-kdasu.kdev@gmail.com Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/spi/spi-bcm-qspi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/spi/spi-bcm-qspi.c +++ b/drivers/spi/spi-bcm-qspi.c @@ -552,7 +552,7 @@ static void bcm_qspi_chip_select(struct u32 rd =3D 0; u32 wr =3D 0; =20 - if (qspi->base[CHIP_SELECT]) { + if (cs >=3D 0 && qspi->base[CHIP_SELECT]) { rd =3D bcm_qspi_read(qspi, CHIP_SELECT, 0); wr =3D (rd & ~0xff) | (1 << cs); if (rd =3D=3D wr) From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42CDAC47081 for ; Mon, 7 Feb 2022 11:55:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387224AbiBGLkb (ORCPT ); Mon, 7 Feb 2022 06:40:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384754AbiBGL37 (ORCPT ); Mon, 7 Feb 2022 06:29:59 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B18EC0401DC; Mon, 7 Feb 2022 03:28:19 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 1736BB811BE; Mon, 7 Feb 2022 11:28:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A233C34105; Mon, 7 Feb 2022 11:28:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233296; bh=UQXmFZvWzDM7T2wZ+gPuu+7zNQpmp5zPgxWJTNgyGXI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aq6IU9Ac0g28anXfaCl112u/WLMKHHtio1k8ya51ZrVKxXNmGaazTWehkv6LwAiY6 ExI02T1imwcIA5Z20EH3Kbv7VBy9TdF636ES182qjLDm7wvlhAcmDQO0denAyLperg 2OpKiGauxUXRRvjYmBHUmpAvoMIOnr/Nf9amGjro= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Benjamin Gaignard , Mark Brown Subject: [PATCH 5.15 051/110] spi: mediatek: Avoid NULL pointer crash in interrupt Date: Mon, 7 Feb 2022 12:06:24 +0100 Message-Id: <20220207103804.007505010@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Benjamin Gaignard commit f83a96e5f033fbbd21764705cb9c04234b96218e upstream. In some case, like after a transfer timeout, master->cur_msg pointer is NULL which led to a kernel crash when trying to use master->cur_msg->spi. mtk_spi_can_dma(), pointed by master->can_dma, doesn't use this parameter avoid the problem by setting NULL as second parameter. Fixes: a568231f46322 ("spi: mediatek: Add spi bus for Mediatek MT8173") Signed-off-by: Benjamin Gaignard Link: https://lore.kernel.org/r/20220131141708.888710-1-benjamin.gaignard@c= ollabora.com Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/spi/spi-mt65xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/spi/spi-mt65xx.c +++ b/drivers/spi/spi-mt65xx.c @@ -624,7 +624,7 @@ static irqreturn_t mtk_spi_interrupt(int else mdata->state =3D MTK_SPI_IDLE; =20 - if (!master->can_dma(master, master->cur_msg->spi, trans)) { + if (!master->can_dma(master, NULL, trans)) { if (trans->rx_buf) { cnt =3D mdata->xfer_len / 4; ioread32_rep(mdata->base + SPI_RX_DATA_REG, From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4754DC433F5 for ; Mon, 7 Feb 2022 12:00:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389651AbiBGLuf (ORCPT ); Mon, 7 Feb 2022 06:50:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1383529AbiBGLaS (ORCPT ); Mon, 7 Feb 2022 06:30:18 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BABF7C03E96E; Mon, 7 Feb 2022 03:28:37 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 60744B811A6; Mon, 7 Feb 2022 11:28:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C137C004E1; Mon, 7 Feb 2022 11:28:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233315; bh=ndaHqpqn4sqHYZzskELwPY5K5zp5TlQe607bssm09fg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JB1XPFpTL81HohY5Wwi4v6nugZ+1++8qmVyo5PBDxGUyxuEPpeQ76SCUasJcylqgM LmCbku1EAumh0IvLxeOvaHkxlATo8GZsS8qo/IxI+xUhAE7ZXXACH50qWTbLyRx2pf 3ORHsLTBUOnG06Rrgl3rvTIklx07A5EXbJFPuooM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaoqian Lin , Mark Brown Subject: [PATCH 5.15 052/110] spi: meson-spicc: add IRQ check in meson_spicc_probe Date: Mon, 7 Feb 2022 12:06:25 +0100 Message-Id: <20220207103804.039776054@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Miaoqian Lin commit e937440f7fc444a3e3f1fb75ea65292d6f433a44 upstream. This check misses checking for platform_get_irq()'s call and may passes the negative error codes to devm_request_irq(), which takes unsigned IRQ #, causing it to fail with -EINVAL, overriding an original error code. Stop calling devm_request_irq() with invalid IRQ #s. Fixes: 454fa271bc4e ("spi: Add Meson SPICC driver") Signed-off-by: Miaoqian Lin Link: https://lore.kernel.org/r/20220126110447.24549-1-linmq006@gmail.com Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/spi/spi-meson-spicc.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/drivers/spi/spi-meson-spicc.c +++ b/drivers/spi/spi-meson-spicc.c @@ -693,6 +693,11 @@ static int meson_spicc_probe(struct plat writel_relaxed(0, spicc->base + SPICC_INTREG); =20 irq =3D platform_get_irq(pdev, 0); + if (irq < 0) { + ret =3D irq; + goto out_master; + } + ret =3D devm_request_irq(&pdev->dev, irq, meson_spicc_irq, 0, NULL, spicc); if (ret) { From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7850BC4707A for ; Mon, 7 Feb 2022 12:00:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389668AbiBGLul (ORCPT ); Mon, 7 Feb 2022 06:50:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384832AbiBGLaU (ORCPT ); Mon, 7 Feb 2022 06:30:20 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70D68C03E92D; Mon, 7 Feb 2022 03:28:39 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DB83B6006F; Mon, 7 Feb 2022 11:28:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7BF8C004E1; Mon, 7 Feb 2022 11:28:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233318; bh=+G3hb5+RB2uCCKVlicO2SP2tFVuFlczkrJDxVN1aZDs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q2bGCIZZfGQHm5D4HIOl+uOmn6Wy02r3/jAMuQybFIrLDZEfSDwaDvUqNmh6zbBFs PfZ1PK87brCEpm/CtFoELyjdUkdn0eY/S3W8/6z8pWhPYoOyCE0WoxqZE2IS0bkFxd T7L7w1+OmYHI7EW7DUpDYeQgCcT0wdLmC/5h6/TY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xin Xiong , Xiyu Yang , Xin Tan , Kunihiko Hayashi , Mark Brown Subject: [PATCH 5.15 053/110] spi: uniphier: fix reference count leak in uniphier_spi_probe() Date: Mon, 7 Feb 2022 12:06:26 +0100 Message-Id: <20220207103804.081411702@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Xin Xiong commit 37c2c83ca4f1ef4b6908181ac98e18360af89b42 upstream. The issue happens in several error paths in uniphier_spi_probe(). When either dma_get_slave_caps() or devm_spi_register_master() returns an error code, the function forgets to decrease the refcount of both `dma_rx` and `dma_tx` objects, which may lead to refcount leaks. Fix it by decrementing the reference count of specific objects in those error paths. Signed-off-by: Xin Xiong Signed-off-by: Xiyu Yang Signed-off-by: Xin Tan Reviewed-by: Kunihiko Hayashi Fixes: 28d1dddc59f6 ("spi: uniphier: Add DMA transfer mode support") Link: https://lore.kernel.org/r/20220125101214.35677-1-xiongx18@fudan.edu.cn Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/spi/spi-uniphier.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) --- a/drivers/spi/spi-uniphier.c +++ b/drivers/spi/spi-uniphier.c @@ -726,7 +726,7 @@ static int uniphier_spi_probe(struct pla if (ret) { dev_err(&pdev->dev, "failed to get TX DMA capacities: %d\n", ret); - goto out_disable_clk; + goto out_release_dma; } dma_tx_burst =3D caps.max_burst; } @@ -735,7 +735,7 @@ static int uniphier_spi_probe(struct pla if (IS_ERR_OR_NULL(master->dma_rx)) { if (PTR_ERR(master->dma_rx) =3D=3D -EPROBE_DEFER) { ret =3D -EPROBE_DEFER; - goto out_disable_clk; + goto out_release_dma; } master->dma_rx =3D NULL; dma_rx_burst =3D INT_MAX; @@ -744,7 +744,7 @@ static int uniphier_spi_probe(struct pla if (ret) { dev_err(&pdev->dev, "failed to get RX DMA capacities: %d\n", ret); - goto out_disable_clk; + goto out_release_dma; } dma_rx_burst =3D caps.max_burst; } @@ -753,10 +753,20 @@ static int uniphier_spi_probe(struct pla =20 ret =3D devm_spi_register_master(&pdev->dev, master); if (ret) - goto out_disable_clk; + goto out_release_dma; =20 return 0; =20 +out_release_dma: + if (!IS_ERR_OR_NULL(master->dma_rx)) { + dma_release_channel(master->dma_rx); + master->dma_rx =3D NULL; + } + if (!IS_ERR_OR_NULL(master->dma_tx)) { + dma_release_channel(master->dma_tx); + master->dma_tx =3D NULL; + } + out_disable_clk: clk_disable_unprepare(priv->clk); =20 From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E91EC433FE for ; Mon, 7 Feb 2022 12:00:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389675AbiBGLuo (ORCPT ); Mon, 7 Feb 2022 06:50:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384862AbiBGLaZ (ORCPT ); Mon, 7 Feb 2022 06:30:25 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFF46C03CA4A; Mon, 7 Feb 2022 03:28:42 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 08BD66077B; Mon, 7 Feb 2022 11:28:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DFBAFC340F1; Mon, 7 Feb 2022 11:28:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233321; bh=D1iJwyfsHLPr5Rqzs8UxZzRupRZ+cg/8d6hqnSL8FKo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n/buLgWiw/FS/tztTRImwJpwLkPd6pp65n2AJGtT1ZmHl1vKjrS1fCOVL4mDVPTyC dYlUUl6syHS63Tl6RBbiwxAmDzmcgzuCdYzSX8sEXtty42qpTcF5AvisArZp7pRibg NMXv10V1npBZrwqAo9XEPRpM7ktav+0iG342GcdM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dennis Dalessandro , Mike Marciniszyn , Jason Gunthorpe Subject: [PATCH 5.15 054/110] IB/hfi1: Fix tstats alloc and dealloc Date: Mon, 7 Feb 2022 12:06:27 +0100 Message-Id: <20220207103804.114482943@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Mike Marciniszyn commit e5cce44aff3be9ad2cd52f63f35edbd706181d50 upstream. The tstats allocation is done in the accelerated ndo_init function but the allocation is not tested to succeed. The deallocation is not done in the accelerated ndo_uninit function. Resolve issues by testing for an allocation failure and adding the free_percpu in the uninit function. Fixes: aa0616a9bd52 ("IB/hfi1: switch to core handling of rx/tx byte/packet= counters") Link: https://lore.kernel.org/r/1642287756-182313-5-git-send-email-mike.mar= ciniszyn@cornelisnetworks.com Reviewed-by: Dennis Dalessandro Signed-off-by: Mike Marciniszyn Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/infiniband/hw/hfi1/ipoib_main.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) --- a/drivers/infiniband/hw/hfi1/ipoib_main.c +++ b/drivers/infiniband/hw/hfi1/ipoib_main.c @@ -22,26 +22,35 @@ static int hfi1_ipoib_dev_init(struct ne int ret; =20 dev->tstats =3D netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); + if (!dev->tstats) + return -ENOMEM; =20 ret =3D priv->netdev_ops->ndo_init(dev); if (ret) - return ret; + goto out_ret; =20 ret =3D hfi1_netdev_add_data(priv->dd, qpn_from_mac(priv->netdev->dev_addr), dev); if (ret < 0) { priv->netdev_ops->ndo_uninit(dev); - return ret; + goto out_ret; } =20 return 0; +out_ret: + free_percpu(dev->tstats); + dev->tstats =3D NULL; + return ret; } =20 static void hfi1_ipoib_dev_uninit(struct net_device *dev) { struct hfi1_ipoib_dev_priv *priv =3D hfi1_ipoib_priv(dev); =20 + free_percpu(dev->tstats); + dev->tstats =3D NULL; + hfi1_netdev_remove_data(priv->dd, qpn_from_mac(priv->netdev->dev_addr)); =20 priv->netdev_ops->ndo_uninit(dev); @@ -166,6 +175,7 @@ static void hfi1_ipoib_netdev_dtor(struc hfi1_ipoib_rxq_deinit(priv->netdev); =20 free_percpu(dev->tstats); + dev->tstats =3D NULL; } =20 static void hfi1_ipoib_set_id(struct net_device *dev, int id) From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6DC48C3526C for ; Mon, 7 Feb 2022 12:03:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381975AbiBGL4g (ORCPT ); Mon, 7 Feb 2022 06:56:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384900AbiBGLab (ORCPT ); Mon, 7 Feb 2022 06:30:31 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42886C03C193; Mon, 7 Feb 2022 03:28:45 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 382B06006F; Mon, 7 Feb 2022 11:28:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F227FC004E1; Mon, 7 Feb 2022 11:28:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233324; bh=7QUCjhG7b2OWuM/D+SKi0gaN56aTrCQMmg2TU98RO+E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tPcuJzdFirvmXUL/TljN7v+TYRpLxFnSpWLE1PK9+TvO2hK9pJXI2RWUUhDr1QUq2 kMsHUuQ+ieOUn7C6oFd4b9QJlDmNHAtsii5sorf7rxINvSvAGmu3Z/W9Ek9s2ypU4x sJKw9MdtNddTG55J5dH0bQnzVmyQLFzjjRNnrqjs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Mark Zhang , Leon Romanovsky , Jason Gunthorpe Subject: [PATCH 5.15 055/110] IB/cm: Release previously acquired reference counter in the cm_id_priv Date: Mon, 7 Feb 2022 12:06:28 +0100 Message-Id: <20220207103804.145489928@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Mark Zhang commit b856101a1774b5f1c8c99e8dfdef802856520732 upstream. In failure flow, the reference counter acquired was not released, and the following error was reported: drivers/infiniband/core/cm.c:3373 cm_lap_handler() warn: inconsistent refcounting 'cm_id_priv->refcount.refs.counter': Fixes: 7345201c3963 ("IB/cm: Improve the calling of cm_init_av_for_lap and = cm_init_av_by_path") Link: https://lore.kernel.org/r/7615f23bbb5c5b66d03f6fa13e1c99d51dae6916.16= 42581448.git.leonro@nvidia.com Reported-by: Dan Carpenter Signed-off-by: Mark Zhang Signed-off-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/infiniband/core/cm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/infiniband/core/cm.c +++ b/drivers/infiniband/core/cm.c @@ -3322,7 +3322,7 @@ static int cm_lap_handler(struct cm_work ret =3D cm_init_av_by_path(param->alternate_path, NULL, &alt_av); if (ret) { rdma_destroy_ah_attr(&ah_attr); - return -EINVAL; + goto deref; } =20 spin_lock_irq(&cm_id_priv->lock); From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5FA71C4332F for ; Mon, 7 Feb 2022 12:00:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389696AbiBGLuu (ORCPT ); Mon, 7 Feb 2022 06:50:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384940AbiBGLaw (ORCPT ); Mon, 7 Feb 2022 06:30:52 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0737C03C19D; Mon, 7 Feb 2022 03:28:48 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7D79460918; Mon, 7 Feb 2022 11:28:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 59D89C004E1; Mon, 7 Feb 2022 11:28:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233327; bh=BrOeKKIu/c6Ewayd+Wwum8dmrbUTc5f982drrQndTvc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sF+r6av7Z49dT6C1ebOyd4dnpEW69bkWms6xYiT/nivonCF7a2BF8xEGt41aL7fJP zwJxMScSMC0JBdA7NxwFYPtTZZHOwmhhF30vFCqDtGXADCUUW/kljobr2yciv1V7qo eKkNtUYcVBQuLiMDDv0UsYwwVx99jAEzwkaQk9Go= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miquel Raynal , Alexander Aring , Stefan Schmidt Subject: [PATCH 5.15 056/110] net: ieee802154: hwsim: Ensure proper channel selection at probe time Date: Mon, 7 Feb 2022 12:06:29 +0100 Message-Id: <20220207103804.179284596@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Miquel Raynal commit 1293fccc9e892712d910ec96079d3717307f1d2d upstream. Drivers are expected to set the PHY current_channel and current_page according to their default state. The hwsim driver is advertising being configured on channel 13 by default but that is not reflected in its own internal pib structure. In order to ensure that this driver consider the current channel as being 13 internally, we at least need to set the pib->channel field to 13. Fixes: f25da51fdc38 ("ieee802154: hwsim: add replacement for fakelb") Signed-off-by: Miquel Raynal [stefan@datenfreihafen.org: fixed assigment from page to channel] Acked-by: Alexander Aring Link: https://lore.kernel.org/r/20220125121426.848337-2-miquel.raynal@bootl= in.com Signed-off-by: Stefan Schmidt Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/net/ieee802154/mac802154_hwsim.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/net/ieee802154/mac802154_hwsim.c +++ b/drivers/net/ieee802154/mac802154_hwsim.c @@ -786,6 +786,7 @@ static int hwsim_add_one(struct genl_inf goto err_pib; } =20 + pib->channel =3D 13; rcu_assign_pointer(phy->pib, pib); phy->idx =3D idx; INIT_LIST_HEAD(&phy->edges); From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A6D9C38A04 for ; Mon, 7 Feb 2022 12:03:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391354AbiBGMBd (ORCPT ); Mon, 7 Feb 2022 07:01:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386782AbiBGLgo (ORCPT ); Mon, 7 Feb 2022 06:36:44 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A67E4C03BFDF; Mon, 7 Feb 2022 03:28:53 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 5F441B80EC3; Mon, 7 Feb 2022 11:28:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B87CC004E1; Mon, 7 Feb 2022 11:28:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233331; bh=b13qAo4YSP2y+ta2ne27FSUAmi4yqSLi1KWG0FFTyEU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fNonNAtlpt3AK8ztPbl8XnXo+qrNbfztlwe44olyKo92+tOn12w/BPQQq1euVFZGE Wk5SEohr2NEbg5tt6nSqHf8Cf0N/e8aGCOz4nGATWDTNrVm5H6nOdk73Kj3MDTZ+Ci VGcTvnPCuSagqjMAXVz7tcgRQR8MSTFUUFMvJ7Fs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miquel Raynal , Alexander Aring , Stefan Schmidt Subject: [PATCH 5.15 057/110] net: ieee802154: mcr20a: Fix lifs/sifs periods Date: Mon, 7 Feb 2022 12:06:30 +0100 Message-Id: <20220207103804.213035605@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Miquel Raynal commit d753c4004820a888ec007dd88b271fa9c3172c5c upstream. These periods are expressed in time units (microseconds) while 40 and 12 are the number of symbol durations these periods will last. We need to multiply them both with phy->symbol_duration in order to get these values in microseconds. Fixes: 8c6ad9cc5157 ("ieee802154: Add NXP MCR20A IEEE 802.15.4 transceiver = driver") Signed-off-by: Miquel Raynal Acked-by: Alexander Aring Link: https://lore.kernel.org/r/20220125121426.848337-3-miquel.raynal@bootl= in.com Signed-off-by: Stefan Schmidt Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/net/ieee802154/mcr20a.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/net/ieee802154/mcr20a.c +++ b/drivers/net/ieee802154/mcr20a.c @@ -976,8 +976,8 @@ static void mcr20a_hw_setup(struct mcr20 dev_dbg(printdev(lp), "%s\n", __func__); =20 phy->symbol_duration =3D 16; - phy->lifs_period =3D 40; - phy->sifs_period =3D 12; + phy->lifs_period =3D 40 * phy->symbol_duration; + phy->sifs_period =3D 12 * phy->symbol_duration; =20 hw->flags =3D IEEE802154_HW_TX_OMIT_CKSUM | IEEE802154_HW_AFILT | From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6B45C35295 for ; Mon, 7 Feb 2022 11:55:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387865AbiBGLln (ORCPT ); Mon, 7 Feb 2022 06:41:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382159AbiBGL3R (ORCPT ); Mon, 7 Feb 2022 06:29:17 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3ECD4C02B667; Mon, 7 Feb 2022 03:27:22 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 731C46006F; Mon, 7 Feb 2022 11:27:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F639C340EB; Mon, 7 Feb 2022 11:27:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233227; bh=0G4mg7JrTwEv++ARZxUJpNZ1oLOwrJ8UNREcb0ZZ/f8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vl+ow5r63hLe8mibBlDKEtZ+gAEMCt4rq+cTwmL54S/4HdtU8CixprRmn63SE+1NQ piP/m2yasGdOCydmHBesT8QT7q873Y17W5nORwNN4wNKPd9a/auTWaBvyvkvXAgUbn ZtDYYuKTTvD2LF6sAripFtyeiVG2TasIkU1Ke+ok= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miquel Raynal , Alexander Aring , Stefan Schmidt Subject: [PATCH 5.15 058/110] net: ieee802154: ca8210: Stop leaking skbs Date: Mon, 7 Feb 2022 12:06:31 +0100 Message-Id: <20220207103804.247225937@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Miquel Raynal commit 621b24b09eb61c63f262da0c9c5f0e93348897e5 upstream. Upon error the ieee802154_xmit_complete() helper is not called. Only ieee802154_wake_queue() is called manually. We then leak the skb structure. Free the skb structure upon error before returning. Fixes: ded845a781a5 ("ieee802154: Add CA8210 IEEE 802.15.4 device driver") Signed-off-by: Miquel Raynal Acked-by: Alexander Aring Link: https://lore.kernel.org/r/20220125121426.848337-5-miquel.raynal@bootl= in.com Signed-off-by: Stefan Schmidt Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/net/ieee802154/ca8210.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/net/ieee802154/ca8210.c +++ b/drivers/net/ieee802154/ca8210.c @@ -1771,6 +1771,7 @@ static int ca8210_async_xmit_complete( status ); if (status !=3D MAC_TRANSACTION_OVERFLOW) { + dev_kfree_skb_any(priv->tx_skb); ieee802154_wake_queue(priv->hw); return 0; } From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7FC3C4332F for ; Mon, 7 Feb 2022 11:58:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387908AbiBGLmJ (ORCPT ); Mon, 7 Feb 2022 06:42:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382505AbiBGL3U (ORCPT ); Mon, 7 Feb 2022 06:29:20 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EE4EC02B67B; Mon, 7 Feb 2022 03:27:25 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 6F41AB80EC3; Mon, 7 Feb 2022 11:27:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 923AEC004E1; Mon, 7 Feb 2022 11:27:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233231; bh=56VyBmj+bRsCsk2a9Y/xPAhsRALIjjZvUHbCqINZASk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bcArg6rwo0MAB5WA775Z+fi7A+BZzpIy5w/vLgyqn+6RvhFabP0W9tgb8FMOn95i7 gVu/yhpXVjC52E8QkOOWNtMZmuwjkGKaK48KfiBnHxJ+rWPM8MjDYIGvCGjBclQK1m 1WsInLAxGlCOPfmOTH5UmWNQotX+JcsO80BTNOcc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Phil Sutter , Pablo Neira Ayuso Subject: [PATCH 5.15 059/110] netfilter: nft_reject_bridge: Fix for missing reply from prerouting Date: Mon, 7 Feb 2022 12:06:32 +0100 Message-Id: <20220207103804.278465638@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Phil Sutter commit aeac4554eb549037ff2f719200c0a9c1c25e7eaa upstream. Prior to commit fa538f7cf05aa ("netfilter: nf_reject: add reject skbuff creation helpers"), nft_reject_bridge did not assign to nskb->dev before passing nskb on to br_forward(). The shared skbuff creation helpers introduced in above commit do which seems to confuse br_forward() as reject statements in prerouting hook won't emit a packet anymore. Fix this by simply passing NULL instead of 'dev' to the helpers - they use the pointer for just that assignment, nothing else. Fixes: fa538f7cf05aa ("netfilter: nf_reject: add reject skbuff creation hel= pers") Signed-off-by: Phil Sutter Signed-off-by: Pablo Neira Ayuso Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- net/bridge/netfilter/nft_reject_bridge.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/net/bridge/netfilter/nft_reject_bridge.c +++ b/net/bridge/netfilter/nft_reject_bridge.c @@ -49,7 +49,7 @@ static void nft_reject_br_send_v4_tcp_re { struct sk_buff *nskb; =20 - nskb =3D nf_reject_skb_v4_tcp_reset(net, oldskb, dev, hook); + nskb =3D nf_reject_skb_v4_tcp_reset(net, oldskb, NULL, hook); if (!nskb) return; =20 @@ -65,7 +65,7 @@ static void nft_reject_br_send_v4_unreac { struct sk_buff *nskb; =20 - nskb =3D nf_reject_skb_v4_unreach(net, oldskb, dev, hook, code); + nskb =3D nf_reject_skb_v4_unreach(net, oldskb, NULL, hook, code); if (!nskb) return; =20 @@ -81,7 +81,7 @@ static void nft_reject_br_send_v6_tcp_re { struct sk_buff *nskb; =20 - nskb =3D nf_reject_skb_v6_tcp_reset(net, oldskb, dev, hook); + nskb =3D nf_reject_skb_v6_tcp_reset(net, oldskb, NULL, hook); if (!nskb) return; =20 @@ -98,7 +98,7 @@ static void nft_reject_br_send_v6_unreac { struct sk_buff *nskb; =20 - nskb =3D nf_reject_skb_v6_unreach(net, oldskb, dev, hook, code); + nskb =3D nf_reject_skb_v6_unreach(net, oldskb, NULL, hook, code); if (!nskb) return; =20 From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C71AAC433FE for ; Mon, 7 Feb 2022 11:58:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387915AbiBGLmN (ORCPT ); Mon, 7 Feb 2022 06:42:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1381426AbiBGL3P (ORCPT ); Mon, 7 Feb 2022 06:29:15 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70E1CC02B660; Mon, 7 Feb 2022 03:27:17 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 0357BB811B3; Mon, 7 Feb 2022 11:27:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EF1FDC004E1; Mon, 7 Feb 2022 11:27:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233234; bh=KWI6vSg9iJAy0sZw7ylDuPKoHk9LZwGvR0dTqATAMdo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m+SctpmGjyHAgYwpKIDM9IOb8HMeZD8Hsf9OmOS9+z0v+WHl/AQhMKUrhpJyWEP6p 1dyKPKNNBtcF/tuVM+Jv8WSkbFa4xdpa1iDMpa84DCZqiq0norXy7GB+LKgRIu+9vm U8CCh3nz65A8k0YcV+OsvyKPxAUjRjdPpNoKBQB4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miquel Raynal , Alexander Aring , Stefan Schmidt Subject: [PATCH 5.15 060/110] net: ieee802154: Return meaningful error codes from the netlink helpers Date: Mon, 7 Feb 2022 12:06:33 +0100 Message-Id: <20220207103804.313182681@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Miquel Raynal commit 79c37ca73a6e9a33f7b2b7783ba6af07a448c8a9 upstream. Returning -1 does not indicate anything useful. Use a standard and meaningful error code instead. Fixes: a26c5fd7622d ("nl802154: add support for security layer") Signed-off-by: Miquel Raynal Acked-by: Alexander Aring Link: https://lore.kernel.org/r/20220125121426.848337-6-miquel.raynal@bootl= in.com Signed-off-by: Stefan Schmidt Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- net/ieee802154/nl802154.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/net/ieee802154/nl802154.c +++ b/net/ieee802154/nl802154.c @@ -1441,7 +1441,7 @@ static int nl802154_send_key(struct sk_b =20 hdr =3D nl802154hdr_put(msg, portid, seq, flags, cmd); if (!hdr) - return -1; + return -ENOBUFS; =20 if (nla_put_u32(msg, NL802154_ATTR_IFINDEX, dev->ifindex)) goto nla_put_failure; @@ -1634,7 +1634,7 @@ static int nl802154_send_device(struct s =20 hdr =3D nl802154hdr_put(msg, portid, seq, flags, cmd); if (!hdr) - return -1; + return -ENOBUFS; =20 if (nla_put_u32(msg, NL802154_ATTR_IFINDEX, dev->ifindex)) goto nla_put_failure; @@ -1812,7 +1812,7 @@ static int nl802154_send_devkey(struct s =20 hdr =3D nl802154hdr_put(msg, portid, seq, flags, cmd); if (!hdr) - return -1; + return -ENOBUFS; =20 if (nla_put_u32(msg, NL802154_ATTR_IFINDEX, dev->ifindex)) goto nla_put_failure; @@ -1988,7 +1988,7 @@ static int nl802154_send_seclevel(struct =20 hdr =3D nl802154hdr_put(msg, portid, seq, flags, cmd); if (!hdr) - return -1; + return -ENOBUFS; =20 if (nla_put_u32(msg, NL802154_ATTR_IFINDEX, dev->ifindex)) goto nla_put_failure; From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18061C352A1 for ; Mon, 7 Feb 2022 11:55:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387879AbiBGLmC (ORCPT ); Mon, 7 Feb 2022 06:42:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384584AbiBGL3X (ORCPT ); Mon, 7 Feb 2022 06:29:23 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3A9EC02B5C9; Mon, 7 Feb 2022 03:27:29 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 67150B811BD; Mon, 7 Feb 2022 11:27:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4AAF7C004E1; Mon, 7 Feb 2022 11:27:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233238; bh=1RgZXNPB7G0RNcdoYVgpZJ9eQ2HMk85OO1ApS1Hk6B0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DI6qkkrLw/uzurw565Mj6cMROSLF2gmVZCRVjcUXfttND2UHHxJU86T/7Smr4ooU6 SE71GUBG3k2CMWwIyDe9THzWB+Io6HsIneswGpVt8vtPi8ZARQXkvmrsZLR8KgL/fc D/kJmI2qsjY2M5hwRrgs8JIx4Xo8vLdLkO0z3n5I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Karsten Graul , Wen Gu , "David S. Miller" Subject: [PATCH 5.15 061/110] net/smc: Forward wakeup to smc socket waitqueue after fallback Date: Mon, 7 Feb 2022 12:06:34 +0100 Message-Id: <20220207103804.345433546@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Wen Gu commit 341adeec9adad0874f29a0a1af35638207352a39 upstream. When we replace TCP with SMC and a fallback occurs, there may be some socket waitqueue entries remaining in smc socket->wq, such as eppoll_entries inserted by userspace applications. After the fallback, data flows over TCP/IP and only clcsocket->wq will be woken up. Applications can't be notified by the entries which were inserted in smc socket->wq before fallback. So we need a mechanism to wake up smc socket->wq at the same time if some entries remaining in it. The current workaround is to transfer the entries from smc socket->wq to clcsock->wq during the fallback. But this may cause a crash like this: general protection fault, probably for non-canonical address 0xdead0000000= 00100: 0000 [#1] PREEMPT SMP PTI CPU: 3 PID: 0 Comm: swapper/3 Kdump: loaded Tainted: G E 5.16.0+ #107 RIP: 0010:__wake_up_common+0x65/0x170 Call Trace: __wake_up_common_lock+0x7a/0xc0 sock_def_readable+0x3c/0x70 tcp_data_queue+0x4a7/0xc40 tcp_rcv_established+0x32f/0x660 ? sk_filter_trim_cap+0xcb/0x2e0 tcp_v4_do_rcv+0x10b/0x260 tcp_v4_rcv+0xd2a/0xde0 ip_protocol_deliver_rcu+0x3b/0x1d0 ip_local_deliver_finish+0x54/0x60 ip_local_deliver+0x6a/0x110 ? tcp_v4_early_demux+0xa2/0x140 ? tcp_v4_early_demux+0x10d/0x140 ip_sublist_rcv_finish+0x49/0x60 ip_sublist_rcv+0x19d/0x230 ip_list_rcv+0x13e/0x170 __netif_receive_skb_list_core+0x1c2/0x240 netif_receive_skb_list_internal+0x1e6/0x320 napi_complete_done+0x11d/0x190 mlx5e_napi_poll+0x163/0x6b0 [mlx5_core] __napi_poll+0x3c/0x1b0 net_rx_action+0x27c/0x300 __do_softirq+0x114/0x2d2 irq_exit_rcu+0xb4/0xe0 common_interrupt+0xba/0xe0 The crash is caused by privately transferring waitqueue entries from smc socket->wq to clcsock->wq. The owners of these entries, such as epoll, have no idea that the entries have been transferred to a different socket wait queue and still use original waitqueue spinlock (smc socket->wq.wait.lock) to make the entries operation exclusive, but it doesn't work. The operations to the entries, such as removing from the waitqueue (now is clcsock->wq after fallback), may cause a crash when clcsock waitqueue is being iterated over at the moment. This patch tries to fix this by no longer transferring wait queue entries privately, but introducing own implementations of clcsock's callback functions in fallback situation. The callback functions will forward the wakeup to smc socket->wq if clcsock->wq is actually woken up and smc socket->wq has remaining entries. Fixes: 2153bd1e3d3d ("net/smc: Transfer remaining wait queue entries during= fallback") Suggested-by: Karsten Graul Signed-off-by: Wen Gu Acked-by: Karsten Graul Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- net/smc/af_smc.c | 133 ++++++++++++++++++++++++++++++++++++++++++++++++--= ----- net/smc/smc.h | 20 +++++++- 2 files changed, 137 insertions(+), 16 deletions(-) --- a/net/smc/af_smc.c +++ b/net/smc/af_smc.c @@ -548,17 +548,115 @@ static void smc_stat_fallback(struct smc mutex_unlock(&net->smc.mutex_fback_rsn); } =20 +/* must be called under rcu read lock */ +static void smc_fback_wakeup_waitqueue(struct smc_sock *smc, void *key) +{ + struct socket_wq *wq; + __poll_t flags; + + wq =3D rcu_dereference(smc->sk.sk_wq); + if (!skwq_has_sleeper(wq)) + return; + + /* wake up smc sk->sk_wq */ + if (!key) { + /* sk_state_change */ + wake_up_interruptible_all(&wq->wait); + } else { + flags =3D key_to_poll(key); + if (flags & (EPOLLIN | EPOLLOUT)) + /* sk_data_ready or sk_write_space */ + wake_up_interruptible_sync_poll(&wq->wait, flags); + else if (flags & EPOLLERR) + /* sk_error_report */ + wake_up_interruptible_poll(&wq->wait, flags); + } +} + +static int smc_fback_mark_woken(wait_queue_entry_t *wait, + unsigned int mode, int sync, void *key) +{ + struct smc_mark_woken *mark =3D + container_of(wait, struct smc_mark_woken, wait_entry); + + mark->woken =3D true; + mark->key =3D key; + return 0; +} + +static void smc_fback_forward_wakeup(struct smc_sock *smc, struct sock *cl= csk, + void (*clcsock_callback)(struct sock *sk)) +{ + struct smc_mark_woken mark =3D { .woken =3D false }; + struct socket_wq *wq; + + init_waitqueue_func_entry(&mark.wait_entry, + smc_fback_mark_woken); + rcu_read_lock(); + wq =3D rcu_dereference(clcsk->sk_wq); + if (!wq) + goto out; + add_wait_queue(sk_sleep(clcsk), &mark.wait_entry); + clcsock_callback(clcsk); + remove_wait_queue(sk_sleep(clcsk), &mark.wait_entry); + + if (mark.woken) + smc_fback_wakeup_waitqueue(smc, mark.key); +out: + rcu_read_unlock(); +} + +static void smc_fback_state_change(struct sock *clcsk) +{ + struct smc_sock *smc =3D + smc_clcsock_user_data(clcsk); + + if (!smc) + return; + smc_fback_forward_wakeup(smc, clcsk, smc->clcsk_state_change); +} + +static void smc_fback_data_ready(struct sock *clcsk) +{ + struct smc_sock *smc =3D + smc_clcsock_user_data(clcsk); + + if (!smc) + return; + smc_fback_forward_wakeup(smc, clcsk, smc->clcsk_data_ready); +} + +static void smc_fback_write_space(struct sock *clcsk) +{ + struct smc_sock *smc =3D + smc_clcsock_user_data(clcsk); + + if (!smc) + return; + smc_fback_forward_wakeup(smc, clcsk, smc->clcsk_write_space); +} + +static void smc_fback_error_report(struct sock *clcsk) +{ + struct smc_sock *smc =3D + smc_clcsock_user_data(clcsk); + + if (!smc) + return; + smc_fback_forward_wakeup(smc, clcsk, smc->clcsk_error_report); +} + static int smc_switch_to_fallback(struct smc_sock *smc, int reason_code) { - wait_queue_head_t *smc_wait =3D sk_sleep(&smc->sk); - wait_queue_head_t *clc_wait; - unsigned long flags; + struct sock *clcsk; =20 mutex_lock(&smc->clcsock_release_lock); if (!smc->clcsock) { mutex_unlock(&smc->clcsock_release_lock); return -EBADF; } + clcsk =3D smc->clcsock->sk; + smc->use_fallback =3D true; smc->fallback_rsn =3D reason_code; smc_stat_fallback(smc); @@ -568,16 +666,22 @@ static int smc_switch_to_fallback(struct smc->clcsock->wq.fasync_list =3D smc->sk.sk_socket->wq.fasync_list; =20 - /* There may be some entries remaining in - * smc socket->wq, which should be removed - * to clcsocket->wq during the fallback. + /* There might be some wait entries remaining + * in smc sk->sk_wq and they should be woken up + * as clcsock's wait queue is woken up. */ - clc_wait =3D sk_sleep(smc->clcsock->sk); - spin_lock_irqsave(&smc_wait->lock, flags); - spin_lock_nested(&clc_wait->lock, SINGLE_DEPTH_NESTING); - list_splice_init(&smc_wait->head, &clc_wait->head); - spin_unlock(&clc_wait->lock); - spin_unlock_irqrestore(&smc_wait->lock, flags); + smc->clcsk_state_change =3D clcsk->sk_state_change; + smc->clcsk_data_ready =3D clcsk->sk_data_ready; + smc->clcsk_write_space =3D clcsk->sk_write_space; + smc->clcsk_error_report =3D clcsk->sk_error_report; + + clcsk->sk_state_change =3D smc_fback_state_change; + clcsk->sk_data_ready =3D smc_fback_data_ready; + clcsk->sk_write_space =3D smc_fback_write_space; + clcsk->sk_error_report =3D smc_fback_error_report; + + smc->clcsock->sk->sk_user_data =3D + (void *)((uintptr_t)smc | SK_USER_DATA_NOCOPY); } mutex_unlock(&smc->clcsock_release_lock); return 0; @@ -1909,10 +2013,9 @@ out: =20 static void smc_clcsock_data_ready(struct sock *listen_clcsock) { - struct smc_sock *lsmc; + struct smc_sock *lsmc =3D + smc_clcsock_user_data(listen_clcsock); =20 - lsmc =3D (struct smc_sock *) - ((uintptr_t)listen_clcsock->sk_user_data & ~SK_USER_DATA_NOCOPY); if (!lsmc) return; lsmc->clcsk_data_ready(listen_clcsock); --- a/net/smc/smc.h +++ b/net/smc/smc.h @@ -129,6 +129,12 @@ enum smc_urg_state { SMC_URG_READ =3D 3, /* data was already read */ }; =20 +struct smc_mark_woken { + bool woken; + void *key; + wait_queue_entry_t wait_entry; +}; + struct smc_connection { struct rb_node alert_node; struct smc_link_group *lgr; /* link group of connection */ @@ -217,8 +223,14 @@ struct smc_connection { struct smc_sock { /* smc sock container */ struct sock sk; struct socket *clcsock; /* internal tcp socket */ + void (*clcsk_state_change)(struct sock *sk); + /* original stat_change fct. */ void (*clcsk_data_ready)(struct sock *sk); - /* original data_ready fct. **/ + /* original data_ready fct. */ + void (*clcsk_write_space)(struct sock *sk); + /* original write_space fct. */ + void (*clcsk_error_report)(struct sock *sk); + /* original error_report fct. */ struct smc_connection conn; /* smc connection */ struct smc_sock *listen_smc; /* listen parent */ struct work_struct connect_work; /* handle non-blocking connect*/ @@ -253,6 +265,12 @@ static inline struct smc_sock *smc_sk(co return (struct smc_sock *)sk; } =20 +static inline struct smc_sock *smc_clcsock_user_data(struct sock *clcsk) +{ + return (struct smc_sock *) + ((uintptr_t)clcsk->sk_user_data & ~SK_USER_DATA_NOCOPY); +} + extern struct workqueue_struct *smc_hs_wq; /* wq for handshake work */ extern struct workqueue_struct *smc_close_wq; /* wq for close work */ =20 From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48506C4167B for ; Mon, 7 Feb 2022 11:55:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387894AbiBGLmE (ORCPT ); Mon, 7 Feb 2022 06:42:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384583AbiBGL3X (ORCPT ); Mon, 7 Feb 2022 06:29:23 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35D73C02B5CA; Mon, 7 Feb 2022 03:27:29 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EA7D560A6B; Mon, 7 Feb 2022 11:27:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3BEFC004E1; Mon, 7 Feb 2022 11:27:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233241; bh=WnFNuTNHN+U9z+3wWHwApqEJQhHlO7hieQexRD6JlRk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wJ5l6lmQaAelIsYwLlQXgjDc1hg95m9lAqQAFC+Kp8yGuwV2aBdT+ZkcdXaGfgdHi twN2vuWU6rsGWUi56VJBveduyIxQdN5EuEH57MZqFLh82OqQjx7WPPmYPIcXLAcTx4 LxlAzWgHFKpchxeenljoogrtHDMml6FIgycwUMR4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kernel test robot , Dan Carpenter , Yuji Ishikawa , Nobuhiro Iwamatsu , "David S. Miller" Subject: [PATCH 5.15 062/110] net: stmmac: dwmac-visconti: No change to ETHER_CLOCK_SEL for unexpected speed request. Date: Mon, 7 Feb 2022 12:06:35 +0100 Message-Id: <20220207103804.384237281@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Yuji Ishikawa commit 928d6fe996f69330ded6b887baf4534c5fac7988 upstream. Variable clk_sel_val is not initialized in the default case of the first sw= itch statement. In that case, the function should return immediately without any changes to= the hardware. Reported-by: kernel test robot Reported-by: Dan Carpenter Fixes: b38dd98ff8d0 ("net: stmmac: Add Toshiba Visconti SoCs glue driver") Signed-off-by: Yuji Ishikawa Reviewed-by: Nobuhiro Iwamatsu Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c @@ -49,13 +49,15 @@ struct visconti_eth { void __iomem *reg; u32 phy_intf_sel; struct clk *phy_ref_clk; + struct device *dev; spinlock_t lock; /* lock to protect register update */ }; =20 static void visconti_eth_fix_mac_speed(void *priv, unsigned int speed) { struct visconti_eth *dwmac =3D priv; - unsigned int val, clk_sel_val; + struct net_device *netdev =3D dev_get_drvdata(dwmac->dev); + unsigned int val, clk_sel_val =3D 0; unsigned long flags; =20 spin_lock_irqsave(&dwmac->lock, flags); @@ -85,7 +87,9 @@ static void visconti_eth_fix_mac_speed(v break; default: /* No bit control */ - break; + netdev_err(netdev, "Unsupported speed request (%d)", speed); + spin_unlock_irqrestore(&dwmac->lock, flags); + return; } =20 writel(val, dwmac->reg + MAC_CTRL_REG); @@ -230,6 +234,7 @@ static int visconti_eth_dwmac_probe(stru =20 spin_lock_init(&dwmac->lock); dwmac->reg =3D stmmac_res.addr; + dwmac->dev =3D &pdev->dev; plat_dat->bsp_priv =3D dwmac; plat_dat->fix_mac_speed =3D visconti_eth_fix_mac_speed; =20 From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03A24C35280 for ; Mon, 7 Feb 2022 11:55:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387872AbiBGLly (ORCPT ); Mon, 7 Feb 2022 06:41:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1383682AbiBGL3V (ORCPT ); Mon, 7 Feb 2022 06:29:21 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8591C02B67D; Mon, 7 Feb 2022 03:27:25 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0F27060918; Mon, 7 Feb 2022 11:27:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9EECC004E1; Mon, 7 Feb 2022 11:27:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233244; bh=PTUQAjh21a/J/n3M9BufajGrHXdy9xnbWOMHv55ppr0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h/VCAHoKVmOW0ZBjIabsdgqBFSCKKbkIB8rE2K9bRyJ6FomXl/W2NqPJEySDziOVb Dp9eQUmiRiu4LnR2Fajcexs4q5EXZhRHJQMILZTHd0JuesE90DttcgZln9Iat2w+2q dlfw4vGlpDotdCNYQt6GpIL3RTlAJYcjTYa/feH4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jisheng Zhang , "David S. Miller" Subject: [PATCH 5.15 063/110] net: stmmac: properly handle with runtime pm in stmmac_dvr_remove() Date: Mon, 7 Feb 2022 12:06:36 +0100 Message-Id: <20220207103804.414970991@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Jisheng Zhang commit 6449520391dfc3d2cef134f11a91251a054ff7d0 upstream. There are two issues with runtime pm handling in stmmac_dvr_remove(): 1. the mac is runtime suspended before stopping dma and rx/tx. We need to ensure the device is properly resumed back. 2. the stmmaceth clk enable/disable isn't balanced in both exit and error handling code path. Take the exit code path for example, when we unbind the driver or rmmod the driver module, the mac is runtime suspended as said above, so the stmmaceth clk is disabled, but stmmac_dvr_remove() stmmac_remove_config_dt() clk_disable_unprepare() CCF will complain this time. The error handling code path suffers from the similar situtaion. Here are kernel warnings in error handling code path on Allwinner D1 platform: [ 1.604695] ------------[ cut here ]------------ [ 1.609328] bus-emac already disabled [ 1.613015] WARNING: CPU: 0 PID: 38 at drivers/clk/clk.c:952 clk_core_di= sable+0xcc/0xec [ 1.621039] CPU: 0 PID: 38 Comm: kworker/u2:1 Not tainted 5.14.0-rc4#1 [ 1.627653] Hardware name: Allwinner D1 NeZha (DT) [ 1.632443] Workqueue: events_unbound deferred_probe_work_func [ 1.638286] epc : clk_core_disable+0xcc/0xec [ 1.642561] ra : clk_core_disable+0xcc/0xec [ 1.646835] epc : ffffffff8023c2ec ra : ffffffff8023c2ec sp : ffffffd004= 11bb10 [ 1.654054] gp : ffffffff80ec9988 tp : ffffffe00143a800 t0 : ffffffff80= ed6a6f [ 1.661272] t1 : ffffffff80ed6a60 t2 : 0000000000000000 s0 : ffffffe001= 509e00 [ 1.668489] s1 : 0000000000000001 a0 : 0000000000000019 a1 : ffffffff80= e80bd8 [ 1.675707] a2 : 00000000ffffefff a3 : 00000000000000f4 a4 : 0000000000= 000002 [ 1.682924] a5 : 0000000000000001 a6 : 0000000000000030 a7 : 0000000002= 8f5c29 [ 1.690141] s2 : 0000000000000800 s3 : ffffffe001375000 s4 : ffffffe01f= df7a80 [ 1.697358] s5 : ffffffe001375010 s6 : ffffffff8001fc10 s7 : ffffffffff= ffffff [ 1.704577] s8 : 0000000000000001 s9 : ffffffff80ecb248 s10: ffffffe001= b80000 [ 1.711794] s11: ffffffe001b80760 t3 : 0000000000000062 t4 : ffffffffff= ffffff [ 1.719012] t5 : ffffffff80e0f6d8 t6 : ffffffd00411b8f0 [ 1.724321] status: 8000000201800100 badaddr: 0000000000000000 cause: 00= 00000000000003 [ 1.732233] [] clk_core_disable+0xcc/0xec [ 1.737810] [] clk_disable+0x38/0x78 [ 1.742956] [] worker_thread+0x1a8/0x4d8 [ 1.748451] [] stmmac_remove_config_dt+0x1c/0x4c [ 1.754646] [] sun8i_dwmac_probe+0x378/0x82c [ 1.760484] [] worker_thread+0x1a8/0x4d8 [ 1.765975] [] platform_probe+0x64/0xf0 [ 1.771382] [] really_probe.part.0+0x8c/0x30c [ 1.777305] [] __driver_probe_device+0xa0/0x148 [ 1.783402] [] driver_probe_device+0x38/0x138 [ 1.789324] [] __device_attach_driver+0xd0/0x170 [ 1.795508] [] __driver_attach_async_helper+0xbc/0xc0 [ 1.802125] [] bus_for_each_drv+0x68/0xb4 [ 1.807701] [] __device_attach+0xd8/0x184 [ 1.813277] [] bus_probe_device+0x98/0xbc [ 1.818852] [] deferred_probe_work_func+0x90/0xd4 [ 1.825122] [] process_one_work+0x1e4/0x390 [ 1.830872] [] worker_thread+0x31c/0x4d8 [ 1.836362] [] kthreadd+0x94/0x188 [ 1.841335] [] kthreadd+0x94/0x188 [ 1.846304] [] process_one_work+0x38c/0x390 [ 1.852054] [] kthread+0x124/0x160 [ 1.857021] [] set_kthread_struct+0x5c/0x60 [ 1.862770] [] ret_from_syscall_rejected+0x8/0xc [ 1.868956] ---[ end trace 8d5c6046255f84a0 ]--- [ 1.873675] ------------[ cut here ]------------ [ 1.878366] bus-emac already unprepared [ 1.882378] WARNING: CPU: 0 PID: 38 at drivers/clk/clk.c:810 clk_core_un= prepare+0xe4/0x168 [ 1.890673] CPU: 0 PID: 38 Comm: kworker/u2:1 Tainted: G W 5.14.0= -rc4 #1 [ 1.898674] Hardware name: Allwinner D1 NeZha (DT) [ 1.903464] Workqueue: events_unbound deferred_probe_work_func [ 1.909305] epc : clk_core_unprepare+0xe4/0x168 [ 1.913840] ra : clk_core_unprepare+0xe4/0x168 [ 1.918375] epc : ffffffff8023d6cc ra : ffffffff8023d6cc sp : ffffffd004= 11bb10 [ 1.925593] gp : ffffffff80ec9988 tp : ffffffe00143a800 t0 : 0000000000= 000002 [ 1.932811] t1 : ffffffe01f743be0 t2 : 0000000000000040 s0 : ffffffe001= 509e00 [ 1.940029] s1 : 0000000000000001 a0 : 000000000000001b a1 : ffffffe001= 43a800 [ 1.947246] a2 : 0000000000000000 a3 : 00000000000000f4 a4 : 0000000000= 000001 [ 1.954463] a5 : 0000000000000000 a6 : 0000000005fce2a5 a7 : 0000000000= 000001 [ 1.961680] s2 : 0000000000000800 s3 : ffffffff80afeb90 s4 : ffffffe01f= df7a80 [ 1.968898] s5 : ffffffe001375010 s6 : ffffffff8001fc10 s7 : ffffffffff= ffffff [ 1.976115] s8 : 0000000000000001 s9 : ffffffff80ecb248 s10: ffffffe001= b80000 [ 1.983333] s11: ffffffe001b80760 t3 : ffffffff80b39120 t4 : 0000000000= 000001 [ 1.990550] t5 : 0000000000000000 t6 : ffffffe001600002 [ 1.995859] status: 8000000201800120 badaddr: 0000000000000000 cause: 00= 00000000000003 [ 2.003771] [] clk_core_unprepare+0xe4/0x168 [ 2.009609] [] clk_unprepare+0x24/0x3c [ 2.014929] [] stmmac_remove_config_dt+0x24/0x4c [ 2.021125] [] sun8i_dwmac_probe+0x378/0x82c [ 2.026965] [] worker_thread+0x1a8/0x4d8 [ 2.032463] [] platform_probe+0x64/0xf0 [ 2.037871] [] really_probe.part.0+0x8c/0x30c [ 2.043795] [] __driver_probe_device+0xa0/0x148 [ 2.049892] [] driver_probe_device+0x38/0x138 [ 2.055815] [] __device_attach_driver+0xd0/0x170 [ 2.061999] [] __driver_attach_async_helper+0xbc/0xc0 [ 2.068616] [] bus_for_each_drv+0x68/0xb4 [ 2.074193] [] __device_attach+0xd8/0x184 [ 2.079769] [] bus_probe_device+0x98/0xbc [ 2.085345] [] deferred_probe_work_func+0x90/0xd4 [ 2.091616] [] process_one_work+0x1e4/0x390 [ 2.097367] [] worker_thread+0x31c/0x4d8 [ 2.102858] [] kthreadd+0x94/0x188 [ 2.107830] [] kthreadd+0x94/0x188 [ 2.112800] [] process_one_work+0x38c/0x390 [ 2.118551] [] kthread+0x124/0x160 [ 2.123520] [] set_kthread_struct+0x5c/0x60 [ 2.129268] [] ret_from_syscall_rejected+0x8/0xc [ 2.135455] ---[ end trace 8d5c6046255f84a1 ]--- Fixes: 5ec55823438e ("net: stmmac: add clocks management for gmac driver") Signed-off-by: Jisheng Zhang Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -7120,6 +7120,10 @@ int stmmac_dvr_remove(struct device *dev =20 netdev_info(priv->dev, "%s: removing driver", __func__); =20 + pm_runtime_get_sync(dev); + pm_runtime_disable(dev); + pm_runtime_put_noidle(dev); + stmmac_stop_all_dma(priv); stmmac_mac_set(priv, priv->ioaddr, false); netif_carrier_off(ndev); @@ -7138,8 +7142,6 @@ int stmmac_dvr_remove(struct device *dev if (priv->plat->stmmac_rst) reset_control_assert(priv->plat->stmmac_rst); reset_control_assert(priv->plat->stmmac_ahb_rst); - pm_runtime_put(dev); - pm_runtime_disable(dev); if (priv->hw->pcs !=3D STMMAC_PCS_TBI && priv->hw->pcs !=3D STMMAC_PCS_RTBI) stmmac_mdio_unregister(ndev); From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E728C47087 for ; Mon, 7 Feb 2022 11:55:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387887AbiBGLmD (ORCPT ); Mon, 7 Feb 2022 06:42:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384594AbiBGL3X (ORCPT ); Mon, 7 Feb 2022 06:29:23 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86168C02B5D1; Mon, 7 Feb 2022 03:27:32 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2E522B80EBD; Mon, 7 Feb 2022 11:27:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47739C004E1; Mon, 7 Feb 2022 11:27:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233247; bh=a/ZBpKbDDQqi+MpGt1DElsti8XZTAvY6yZ+reuerCY8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p5o0Zh5Mf7NzRn4EdtNdw7rNkieDEJ8Y4Tgtt/87MbaOjnKiNDOdzHkQOjxmlTvZR bp980SrQoklv1Tfqo9lhSh02VnXi6e5tmmoxkoAidKZvow0zG5DiG7pdbqMTOXR31l 6cr8EPKtk85Cg2FyCHdSIcp36HXOM950Zr7C/ieM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lior Nahmanson , Raed Salem , Antoine Tenart , Jakub Kicinski Subject: [PATCH 5.15 064/110] net: macsec: Fix offload support for NETDEV_UNREGISTER event Date: Mon, 7 Feb 2022 12:06:37 +0100 Message-Id: <20220207103804.446898871@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Lior Nahmanson commit 9cef24c8b76c1f6effe499d2f131807c90f7ce9a upstream. Current macsec netdev notify handler handles NETDEV_UNREGISTER event by releasing relevant SW resources only, this causes resources leak in case of macsec HW offload, as the underlay driver was not notified to clean it's macsec offload resources. Fix by calling the underlay driver to clean it's relevant resources by moving offload handling from macsec_dellink() to macsec_common_dellink() when handling NETDEV_UNREGISTER event. Fixes: 3cf3227a21d1 ("net: macsec: hardware offloading infrastructure") Signed-off-by: Lior Nahmanson Reviewed-by: Raed Salem Signed-off-by: Raed Salem Reviewed-by: Antoine Tenart Link: https://lore.kernel.org/r/1643542141-28956-1-git-send-email-raeds@nvi= dia.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/net/macsec.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) --- a/drivers/net/macsec.c +++ b/drivers/net/macsec.c @@ -3870,6 +3870,18 @@ static void macsec_common_dellink(struct struct macsec_dev *macsec =3D macsec_priv(dev); struct net_device *real_dev =3D macsec->real_dev; =20 + /* If h/w offloading is available, propagate to the device */ + if (macsec_is_offloaded(macsec)) { + const struct macsec_ops *ops; + struct macsec_context ctx; + + ops =3D macsec_get_ops(netdev_priv(dev), &ctx); + if (ops) { + ctx.secy =3D &macsec->secy; + macsec_offload(ops->mdo_del_secy, &ctx); + } + } + unregister_netdevice_queue(dev, head); list_del_rcu(&macsec->secys); macsec_del_dev(macsec); @@ -3884,18 +3896,6 @@ static void macsec_dellink(struct net_de struct net_device *real_dev =3D macsec->real_dev; struct macsec_rxh_data *rxd =3D macsec_data_rtnl(real_dev); =20 - /* If h/w offloading is available, propagate to the device */ - if (macsec_is_offloaded(macsec)) { - const struct macsec_ops *ops; - struct macsec_context ctx; - - ops =3D macsec_get_ops(netdev_priv(dev), &ctx); - if (ops) { - ctx.secy =3D &macsec->secy; - macsec_offload(ops->mdo_del_secy, &ctx); - } - } - macsec_common_dellink(dev, head); =20 if (list_empty(&rxd->secys)) { From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1F8FC433EF for ; Mon, 7 Feb 2022 11:58:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387901AbiBGLmH (ORCPT ); Mon, 7 Feb 2022 06:42:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384605AbiBGL3Z (ORCPT ); Mon, 7 Feb 2022 06:29:25 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3BAFC02B5DA; Mon, 7 Feb 2022 03:27:35 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 07BF36091A; Mon, 7 Feb 2022 11:27:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E7BBC004E1; Mon, 7 Feb 2022 11:27:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233251; bh=kXZdNLArO7qlWpDU7iG2egpXkmF2NNZxXC7x7oXDF0Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ye+Jee+wXq6znG777QtIBOfMGqbpmpOJYqUSRNtwdLD07MyE8hq7qkybrKnZCtYsW qXFFzkvh9+9Q49GxB8oZxHipg6uI4Eq5TVUwxwWVG3md+evntVqTfOoKakbbOQkBIH cmIGkJvAJzT22njaCGkZoahhpReEt1rQwAPGzXe4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lior Nahmanson , Raed Salem , Jakub Kicinski Subject: [PATCH 5.15 065/110] net: macsec: Verify that send_sci is on when setting Tx sci explicitly Date: Mon, 7 Feb 2022 12:06:38 +0100 Message-Id: <20220207103804.478400147@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Lior Nahmanson commit d0cfa548dbde354de986911d3913897b5448faad upstream. When setting Tx sci explicit, the Rx side is expected to use this sci and not recalculate it from the packet.However, in case of Tx sci is explicit and send_sci is off, the receiver is wrongly recalculate the sci from the source MAC address which most likely be different than the explicit sci. Fix by preventing such configuration when macsec newlink is established and return EINVAL error code on such cases. Fixes: c09440f7dcb3 ("macsec: introduce IEEE 802.1AE driver") Signed-off-by: Lior Nahmanson Reviewed-by: Raed Salem Signed-off-by: Raed Salem Link: https://lore.kernel.org/r/1643542672-29403-1-git-send-email-raeds@nvi= dia.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/net/macsec.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- a/drivers/net/macsec.c +++ b/drivers/net/macsec.c @@ -4018,6 +4018,15 @@ static int macsec_newlink(struct net *ne !macsec_check_offload(macsec->offload, macsec)) return -EOPNOTSUPP; =20 + /* send_sci must be set to true when transmit sci explicitly is set */ + if ((data && data[IFLA_MACSEC_SCI]) && + (data && data[IFLA_MACSEC_INC_SCI])) { + u8 send_sci =3D !!nla_get_u8(data[IFLA_MACSEC_INC_SCI]); + + if (!send_sci) + return -EINVAL; + } + if (data && data[IFLA_MACSEC_ICV_LEN]) icv_len =3D nla_get_u8(data[IFLA_MACSEC_ICV_LEN]); mtu =3D real_dev->mtu - icv_len - macsec_extra_len(true); From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A585C41535 for ; Mon, 7 Feb 2022 11:48:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387929AbiBGLmS (ORCPT ); Mon, 7 Feb 2022 06:42:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384616AbiBGL31 (ORCPT ); Mon, 7 Feb 2022 06:29:27 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7DBCC02B5DC; Mon, 7 Feb 2022 03:27:37 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 095BCB811AF; Mon, 7 Feb 2022 11:27:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0DD8AC340F0; Mon, 7 Feb 2022 11:27:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233254; bh=EtbOZiAqtWbT4t6/B/vsUfgMMXkYyFMWs8SFTUx3QU0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y27jjh47+CUty3MmNRBpQYy+RFfSBWzegOX3K4GVYcsgzCtgNjnuZGe/J75zqcYau WHnHaTRGX5uA+fT2gHQX22udortkTOae5d3QMg6HVR/PRk7hdmZRg1aP4yTa3f22WA 4IQch0bNJuL7/snPAx44rhM49IAGSFZIFqHLODhM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Camel Guo , Jakub Kicinski Subject: [PATCH 5.15 066/110] net: stmmac: dump gmac4 DMA registers correctly Date: Mon, 7 Feb 2022 12:06:39 +0100 Message-Id: <20220207103804.510645202@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Camel Guo commit 7af037c39b600bac2c716dd1228e8ddbe149573f upstream. Unlike gmac100, gmac1000, gmac4 has 27 DMA registers and they are located at DMA_CHAN_BASE_ADDR (0x1100). In order for ethtool to dump gmac4 DMA registers correctly, this commit checks if a net_device has gmac4 and uses different logic to dump its DMA registers. This fixes the following KASAN warning, which can normally be triggered by a command similar like "ethtool -d eth0": BUG: KASAN: vmalloc-out-of-bounds in dwmac4_dump_dma_regs+0x6d4/0xb30 Write of size 4 at addr ffffffc010177100 by task ethtool/1839 kasan_report+0x200/0x21c __asan_report_store4_noabort+0x34/0x60 dwmac4_dump_dma_regs+0x6d4/0xb30 stmmac_ethtool_gregs+0x110/0x204 ethtool_get_regs+0x200/0x4b0 dev_ethtool+0x1dac/0x3800 dev_ioctl+0x7c0/0xb50 sock_ioctl+0x298/0x6c4 ... Fixes: fbf68229ffe7 ("net: stmmac: unify registers dumps methods") Signed-off-by: Camel Guo Link: https://lore.kernel.org/r/20220131083841.3346801-1-camel.guo@axis.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h | 1 + drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 19 ++++++++++++++= +++-- 2 files changed, 18 insertions(+), 2 deletions(-) --- a/drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h @@ -150,6 +150,7 @@ =20 #define NUM_DWMAC100_DMA_REGS 9 #define NUM_DWMAC1000_DMA_REGS 23 +#define NUM_DWMAC4_DMA_REGS 27 =20 void dwmac_enable_dma_transmission(void __iomem *ioaddr); void dwmac_enable_dma_irq(void __iomem *ioaddr, u32 chan, bool rx, bool tx= ); --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c @@ -21,10 +21,18 @@ #include "dwxgmac2.h" =20 #define REG_SPACE_SIZE 0x1060 +#define GMAC4_REG_SPACE_SIZE 0x116C #define MAC100_ETHTOOL_NAME "st_mac100" #define GMAC_ETHTOOL_NAME "st_gmac" #define XGMAC_ETHTOOL_NAME "st_xgmac" =20 +/* Same as DMA_CHAN_BASE_ADDR defined in dwmac4_dma.h + * + * It is here because dwmac_dma.h and dwmac4_dam.h can not be included at = the + * same time due to the conflicting macro names. + */ +#define GMAC4_DMA_CHAN_BASE_ADDR 0x00001100 + #define ETHTOOL_DMA_OFFSET 55 =20 struct stmmac_stats { @@ -435,6 +443,8 @@ static int stmmac_ethtool_get_regs_len(s =20 if (priv->plat->has_xgmac) return XGMAC_REGSIZE * 4; + else if (priv->plat->has_gmac4) + return GMAC4_REG_SPACE_SIZE; return REG_SPACE_SIZE; } =20 @@ -447,8 +457,13 @@ static void stmmac_ethtool_gregs(struct stmmac_dump_mac_regs(priv, priv->hw, reg_space); stmmac_dump_dma_regs(priv, priv->ioaddr, reg_space); =20 - if (!priv->plat->has_xgmac) { - /* Copy DMA registers to where ethtool expects them */ + /* Copy DMA registers to where ethtool expects them */ + if (priv->plat->has_gmac4) { + /* GMAC4 dumps its DMA registers at its DMA_CHAN_BASE_ADDR */ + memcpy(®_space[ETHTOOL_DMA_OFFSET], + ®_space[GMAC4_DMA_CHAN_BASE_ADDR / 4], + NUM_DWMAC4_DMA_REGS * 4); + } else if (!priv->plat->has_xgmac) { memcpy(®_space[ETHTOOL_DMA_OFFSET], ®_space[DMA_BUS_MODE / 4], NUM_DWMAC1000_DMA_REGS * 4); From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D714AC43217 for ; Mon, 7 Feb 2022 11:58:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387922AbiBGLmP (ORCPT ); Mon, 7 Feb 2022 06:42:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384615AbiBGL31 (ORCPT ); Mon, 7 Feb 2022 06:29:27 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD43BC02B5DD; Mon, 7 Feb 2022 03:27:38 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A0DFC60915; Mon, 7 Feb 2022 11:27:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6902DC004E1; Mon, 7 Feb 2022 11:27:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233258; bh=l41qFpCCnF7zcx7W10sjE/r96IdLrzfLg4iNeaeKeis=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D92+a2DAGjT8kRqS6/Vbt1VZyUwl3vbp9PhMdw6M2aGvlkBMDXqzuaWxmf8P3MwOT nCPndXAqGTRxEraoUAsH/QeK29i0KYcfhGdUsWEZ18XtOc9pDIz0FPPvwHHWcMd4No 1+ppNO1IJ9ugakGBEGWGOSgDVIp4smd4mIZt424E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yannick Vignon , "Russell King (Oracle)" , Jakub Kicinski Subject: [PATCH 5.15 067/110] net: stmmac: ensure PTP time register reads are consistent Date: Mon, 7 Feb 2022 12:06:40 +0100 Message-Id: <20220207103804.548852976@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Yannick Vignon commit 80d4609008e6d696a279e39ae7458c916fcd44c1 upstream. Even if protected from preemption and interrupts, a small time window remains when the 2 register reads could return inconsistent values, each time the "seconds" register changes. This could lead to an about 1-second error in the reported time. Add logic to ensure the "seconds" and "nanoseconds" values are consistent. Fixes: 92ba6888510c ("stmmac: add the support for PTP hw clock driver") Signed-off-by: Yannick Vignon Reviewed-by: Russell King (Oracle) Link: https://lore.kernel.org/r/20220203160025.750632-1-yannick.vignon@oss.= nxp.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c | 17 +++++++++++--= ---- 1 file changed, 11 insertions(+), 6 deletions(-) --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c @@ -145,15 +145,20 @@ static int adjust_systime(void __iomem * =20 static void get_systime(void __iomem *ioaddr, u64 *systime) { - u64 ns; + u64 ns, sec0, sec1; =20 - /* Get the TSSS value */ - ns =3D readl(ioaddr + PTP_STNSR); - /* Get the TSS and convert sec time value to nanosecond */ - ns +=3D readl(ioaddr + PTP_STSR) * 1000000000ULL; + /* Get the TSS value */ + sec1 =3D readl_relaxed(ioaddr + PTP_STSR); + do { + sec0 =3D sec1; + /* Get the TSSS value */ + ns =3D readl_relaxed(ioaddr + PTP_STNSR); + /* Get the TSS value */ + sec1 =3D readl_relaxed(ioaddr + PTP_STSR); + } while (sec0 !=3D sec1); =20 if (systime) - *systime =3D ns; + *systime =3D ns + (sec1 * 1000000000ULL); } =20 static void get_ptptime(void __iomem *ptpaddr, u64 *ptp_time) From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 082ECC43219 for ; Mon, 7 Feb 2022 11:58:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387996AbiBGLmc (ORCPT ); Mon, 7 Feb 2022 06:42:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384635AbiBGL3a (ORCPT ); Mon, 7 Feb 2022 06:29:30 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3586CC02B5E8; Mon, 7 Feb 2022 03:27:47 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C9ED9B811A6; Mon, 7 Feb 2022 11:27:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 15284C004E1; Mon, 7 Feb 2022 11:27:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233264; bh=G53Ov27bx25K4bYLcs+JBgsqz22eleL4UIUrJ3J1pmU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gbZY4oNOQnU/lNERKTOyZazLtMML9qlLGYS4FsB4liIPLvvFiRhASabY2s5NDMc6F C6vaStQpXGDD6xtSMudmyKM+vYB2SMGPo25qLe3N39KVOwd6le0xUYlKeDUYjCzvaY H5fU8lV3poNovXUdxBiW86ZUk3lH2v6owomuhNBE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Anitha Chrisanthus , Kees Cook Subject: [PATCH 5.15 068/110] drm/kmb: Fix for build errors with Warray-bounds Date: Mon, 7 Feb 2022 12:06:41 +0100 Message-Id: <20220207103804.581728460@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Anitha Chrisanthus commit 43f2517955875be5d96b641fba33d73097fe3cd9 upstream. This fixes the following build error drivers/gpu/drm/kmb/kmb_plane.c: In function 'kmb_plane_atomic_disable': drivers/gpu/drm/kmb/kmb_plane.c:165:34: error: array subscript 3 is above a= rray bounds of 'struct layer_status[2]' [-Werror=3Darray-bounds] 165 | kmb->plane_status[plane_id].ctrl =3D LCD_CTRL_GL2_ENABLE; | ~~~~~~~~~~~~~~~~~^~~~~~~~~~ In file included from drivers/gpu/drm/kmb/kmb_plane.c:17: drivers/gpu/drm/kmb/kmb_drv.h:61:41: note: while referencing 'plane_statu= s' 61 | struct layer_status plane_status[KMB_MAX_PLANES]; | ^~~~~~~~~~~~ drivers/gpu/drm/kmb/kmb_plane.c:162:34: error: array subscript 2 is above= array bounds of 'struct layer_status[2]' [-Werror=3Darray-bounds] 162 | kmb->plane_status[plane_id].ctrl =3D LCD_CTRL_GL1_ENABLE; | ~~~~~~~~~~~~~~~~~^~~~~~~~~~ In file included from drivers/gpu/drm/kmb/kmb_plane.c:17: drivers/gpu/drm/kmb/kmb_drv.h:61:41: note: while referencing 'plane_statu= s' 61 | struct layer_status plane_status[KMB_MAX_PLANES]; | ^~~~~~~~~~~~ Fixes: 7f7b96a8a0a1 ("drm/kmb: Add support for KeemBay Display") Signed-off-by: Anitha Chrisanthus Reviewed-by: Kees Cook Link: https://patchwork.freedesktop.org/patch/msgid/20220127194227.2213608-= 1-anitha.chrisanthus@intel.com Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/gpu/drm/kmb/kmb_plane.c | 6 ------ 1 file changed, 6 deletions(-) --- a/drivers/gpu/drm/kmb/kmb_plane.c +++ b/drivers/gpu/drm/kmb/kmb_plane.c @@ -158,12 +158,6 @@ static void kmb_plane_atomic_disable(str case LAYER_1: kmb->plane_status[plane_id].ctrl =3D LCD_CTRL_VL2_ENABLE; break; - case LAYER_2: - kmb->plane_status[plane_id].ctrl =3D LCD_CTRL_GL1_ENABLE; - break; - case LAYER_3: - kmb->plane_status[plane_id].ctrl =3D LCD_CTRL_GL2_ENABLE; - break; } =20 kmb->plane_status[plane_id].disable =3D true; From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87308C35274 for ; Mon, 7 Feb 2022 11:48:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387983AbiBGLm3 (ORCPT ); Mon, 7 Feb 2022 06:42:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384646AbiBGL3a (ORCPT ); Mon, 7 Feb 2022 06:29:30 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2286C02B5ED; Mon, 7 Feb 2022 03:27:48 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7796D60A71; Mon, 7 Feb 2022 11:27:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 431F1C004E1; Mon, 7 Feb 2022 11:27:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233267; bh=VQ0um3hPcWFFTWCtrxqzMA54VF4LBJGzFd1GZ0+xhEQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VxVrbIZYvR9+gABOA9Uxgp+f6mq5VlNl4fUF59VvC1WUC7bjRCQ7xE/luiZp4/Iyo aOKnsfALkocaxtVG/OgIzQeTDmrhp3xAmZmJm+v/sZ7FI7BQ78r3tWy19fV0Io2DDY 47mEf/CKpFMV5scFFPvMz0ecnSFcSlBs/j/xt4u0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , Tvrtko Ursulin Subject: [PATCH 5.15 069/110] drm/i915/overlay: Prevent divide by zero bugs in scaling Date: Mon, 7 Feb 2022 12:06:42 +0100 Message-Id: <20220207103804.624178325@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Carpenter commit 90a3d22ff02b196d5884e111f39271a1d4ee8e3e upstream. Smatch detected a divide by zero bug in check_overlay_scaling(). drivers/gpu/drm/i915/display/intel_overlay.c:976 check_overlay_scaling() error: potential divide by zero bug '/ rec->dst_height'. drivers/gpu/drm/i915/display/intel_overlay.c:980 check_overlay_scaling() error: potential divide by zero bug '/ rec->dst_width'. Prevent this by ensuring that the dst height and width are non-zero. Fixes: 02e792fbaadb ("drm/i915: implement drmmode overlay support v4") Signed-off-by: Dan Carpenter Signed-off-by: Ville Syrj=C3=A4l=C3=A4 Link: https://patchwork.freedesktop.org/patch/msgid/20220124122409.GA31673@= kili (cherry picked from commit cf5b64f7f10b28bebb9b7c9d25e7aee5cbe43918) Signed-off-by: Tvrtko Ursulin Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/gpu/drm/i915/display/intel_overlay.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/gpu/drm/i915/display/intel_overlay.c +++ b/drivers/gpu/drm/i915/display/intel_overlay.c @@ -959,6 +959,9 @@ static int check_overlay_dst(struct inte const struct intel_crtc_state *pipe_config =3D overlay->crtc->config; =20 + if (rec->dst_height =3D=3D 0 || rec->dst_width =3D=3D 0) + return -EINVAL; + if (rec->dst_x < pipe_config->pipe_src_w && rec->dst_x + rec->dst_width <=3D pipe_config->pipe_src_w && rec->dst_y < pipe_config->pipe_src_h && From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 17C48C4167D for ; Mon, 7 Feb 2022 11:58:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388026AbiBGLmi (ORCPT ); Mon, 7 Feb 2022 06:42:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384663AbiBGL3d (ORCPT ); Mon, 7 Feb 2022 06:29:33 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA8D6C03E90F; Mon, 7 Feb 2022 03:27:52 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 81642B80EC3; Mon, 7 Feb 2022 11:27:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9BB45C340EB; Mon, 7 Feb 2022 11:27:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233271; bh=+vD/we64CXzKQ+evO7omnlTqMOtfkb0divxIeNZ98KU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PtJaqYaDgUUNE1IvjAghhoKgpjJHk25WI8HVYBSfZ+jzERWg8GQA/52kp7wj5uczN OuZbt27vS1AbYAPo7cH6W8lh7uHt5F8FgisTKcqXe7IEoG81+6C5m+HK/LHS+IWByM uunsZgCqezy20yYBmVc3sRBK36QQ2vu8Wnkt4N/s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alex Deucher , Mario Limonciello Subject: [PATCH 5.15 070/110] drm/amd: avoid suspend on dGPUs w/ s2idle support when runtime PM enabled Date: Mon, 7 Feb 2022 12:06:43 +0100 Message-Id: <20220207103804.655136591@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Mario Limonciello commit e55a3aea418269266d84f426b3bd70794d3389c8 upstream. dGPUs connected to Intel systems configured for suspend to idle will not have the power rails cut at suspend and resetting the GPU may lead to problematic behaviors. Fixes: e25443d2765f4 ("drm/amdgpu: add a dev_pm_ops prepare callback (v2)") Link: https://gitlab.freedesktop.org/drm/amd/-/issues/1879 Reviewed-by: Alex Deucher Signed-off-by: Mario Limonciello Signed-off-by: Alex Deucher Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -1504,8 +1504,7 @@ static int amdgpu_pmops_prepare(struct d * DPM_FLAG_SMART_SUSPEND works properly */ if (amdgpu_device_supports_boco(drm_dev)) - return pm_runtime_suspended(dev) && - pm_suspend_via_firmware(); + return pm_runtime_suspended(dev); =20 return 0; } From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 590CFC35274 for ; Mon, 7 Feb 2022 11:49:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380986AbiBGLjy (ORCPT ); Mon, 7 Feb 2022 06:39:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384673AbiBGL3e (ORCPT ); Mon, 7 Feb 2022 06:29:34 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71D75C0258CE; Mon, 7 Feb 2022 03:27:55 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0EC1360918; Mon, 7 Feb 2022 11:27:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF956C004E1; Mon, 7 Feb 2022 11:27:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233274; bh=oockd+H0nbljZXJvxJaW8xs5secCp/bASldZOrm0rlE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qwKJh+ehzJqVFKdoXKsa26ymzoXB6/YTVsXUkttJBaWaKob4lRTu85cYSHULxLDqK vXdCPOcg4jLVcaPCXf1uHFMe4Ye9MKXAzsOLiKfGH+sAf99+TeLKDxfkrXrSqr5q9Y 9hjrsVHmlk0sodqDuWoV9s1h9DqcnbYpwN4Yja+8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaoqian Lin , Mark Brown Subject: [PATCH 5.15 071/110] ASoC: fsl: Add missing error handling in pcm030_fabric_probe Date: Mon, 7 Feb 2022 12:06:44 +0100 Message-Id: <20220207103804.687368485@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Miaoqian Lin commit fb25621da5702c104ce0a48de5b174ced09e5b4e upstream. Add the missing platform_device_put() and platform_device_del() before return from pcm030_fabric_probe in the error handling case. Fixes: c912fa913446 ("ASoC: fsl: register the wm9712-codec") Signed-off-by: Miaoqian Lin Link: https://lore.kernel.org/r/20220127131336.30214-1-linmq006@gmail.com Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/soc/fsl/pcm030-audio-fabric.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) --- a/sound/soc/fsl/pcm030-audio-fabric.c +++ b/sound/soc/fsl/pcm030-audio-fabric.c @@ -93,16 +93,21 @@ static int pcm030_fabric_probe(struct pl dev_err(&op->dev, "platform_device_alloc() failed\n"); =20 ret =3D platform_device_add(pdata->codec_device); - if (ret) + if (ret) { dev_err(&op->dev, "platform_device_add() failed: %d\n", ret); + platform_device_put(pdata->codec_device); + } =20 ret =3D snd_soc_register_card(card); - if (ret) + if (ret) { dev_err(&op->dev, "snd_soc_register_card() failed: %d\n", ret); + platform_device_del(pdata->codec_device); + platform_device_put(pdata->codec_device); + } =20 platform_set_drvdata(op, pdata); - return ret; + } =20 static int pcm030_fabric_remove(struct platform_device *op) From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E788C433F5 for ; Mon, 7 Feb 2022 11:55:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387179AbiBGLkL (ORCPT ); Mon, 7 Feb 2022 06:40:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384685AbiBGL3g (ORCPT ); Mon, 7 Feb 2022 06:29:36 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 786D4C03E91F; Mon, 7 Feb 2022 03:27:58 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 175E26006F; Mon, 7 Feb 2022 11:27:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E932EC004E1; Mon, 7 Feb 2022 11:27:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233277; bh=fQ6HmfmTWZIJTOD7EvLAW2lH/Y8C1gMM3DzkQZuDHbA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V+MMqK6l1q3eHhvBp5d6HPVwfiy/lunOFQVRDRWd7DdL4kqMs4SfejNCtG/OuWFzw YBR7DeuqCKv1c1TrgtFsTB4gNfItUArpP2NgswMeCqQCya1gjVjfsGD7++gwn+JRV4 UlkZNGDYzamMbkzRej/0l3Q2H+gvInXkeDwWNLgg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Devarsh Thakkar , Robert Hancock , Mark Brown Subject: [PATCH 5.15 072/110] ASoC: xilinx: xlnx_formatter_pcm: Make buffer bytes multiple of period bytes Date: Mon, 7 Feb 2022 12:06:45 +0100 Message-Id: <20220207103804.726347778@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Robert Hancock commit e958b5884725dac86d36c1e7afe5a55f31feb0b2 upstream. This patch is based on one in the Xilinx kernel tree, "ASoc: xlnx: Make buffer bytes multiple of period bytes" by Devarsh Thakkar. The same issue exists in the mainline version of the driver. The original patch description is as follows: "The Xilinx Audio Formatter IP has a constraint on period bytes to be multiple of 64. This leads to driver changing the period size to suitable frames such that period bytes are multiple of 64. Now since period bytes and period size are updated but not the buffer bytes, this may make the buffer bytes unaligned and not multiple of period bytes. When this happens we hear popping noise as while DMA is being done the buffer bytes are not enough to complete DMA access for last period of frame within the application buffer boundary. To avoid this, align buffer bytes too as multiple of 64, and set another constraint to always enforce number of periods as integer. Now since, there is already a rule in alsa core to enforce Buffer size =3D Number of Periods * Period Size this automatically aligns buffer bytes as multiple of period bytes." Fixes: 6f6c3c36f091 ("ASoC: xlnx: add pcm formatter platform driver") Cc: Devarsh Thakkar Signed-off-by: Robert Hancock Link: https://lore.kernel.org/r/20220107214711.1100162-2-robert.hancock@cal= ian.com Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/soc/xilinx/xlnx_formatter_pcm.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) --- a/sound/soc/xilinx/xlnx_formatter_pcm.c +++ b/sound/soc/xilinx/xlnx_formatter_pcm.c @@ -37,6 +37,7 @@ #define XLNX_AUD_XFER_COUNT 0x28 #define XLNX_AUD_CH_STS_START 0x2C #define XLNX_BYTES_PER_CH 0x44 +#define XLNX_AUD_ALIGN_BYTES 64 =20 #define AUD_STS_IOC_IRQ_MASK BIT(31) #define AUD_STS_CH_STS_MASK BIT(29) @@ -368,12 +369,32 @@ static int xlnx_formatter_pcm_open(struc snd_soc_set_runtime_hwparams(substream, &xlnx_pcm_hardware); runtime->private_data =3D stream_data; =20 - /* Resize the period size divisible by 64 */ + /* Resize the period bytes as divisible by 64 */ err =3D snd_pcm_hw_constraint_step(runtime, 0, - SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 64); + SNDRV_PCM_HW_PARAM_PERIOD_BYTES, + XLNX_AUD_ALIGN_BYTES); if (err) { dev_err(component->dev, - "unable to set constraint on period bytes\n"); + "Unable to set constraint on period bytes\n"); + return err; + } + + /* Resize the buffer bytes as divisible by 64 */ + err =3D snd_pcm_hw_constraint_step(runtime, 0, + SNDRV_PCM_HW_PARAM_BUFFER_BYTES, + XLNX_AUD_ALIGN_BYTES); + if (err) { + dev_err(component->dev, + "Unable to set constraint on buffer bytes\n"); + return err; + } + + /* Set periods as integer multiple */ + err =3D snd_pcm_hw_constraint_integer(runtime, + SNDRV_PCM_HW_PARAM_PERIODS); + if (err < 0) { + dev_err(component->dev, + "Unable to set constraint on periods to be integer\n"); return err; } =20 From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F611C47080 for ; Mon, 7 Feb 2022 11:55:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387204AbiBGLkW (ORCPT ); Mon, 7 Feb 2022 06:40:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384704AbiBGL3g (ORCPT ); Mon, 7 Feb 2022 06:29:36 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 486CFC0401D1; Mon, 7 Feb 2022 03:28:03 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 0458AB80EBD; Mon, 7 Feb 2022 11:28:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0B371C340F0; Mon, 7 Feb 2022 11:27:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233280; bh=biUjx9epFYxUc5njJ7zZT0O1LrXh9iSxhzE0Ljx4fBI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OYs9Jo9EtA7FesHozSOyGRkhE7fydY4vcQmF00FNJ9DKbqF2ET3hEfcbkVOx6Yk5w xhRfZtgPQddCRWQytlagEid3kFoPLZCEI9sko4TrMyEvFNsbmogUgTgfScgP20fAwB M0/r8xR2xTHY9mF0cfayyRoFXpeu9/UeT5V3BpHw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Robert Hancock , Mark Brown Subject: [PATCH 5.15 073/110] ASoC: simple-card: fix probe failure on platform component Date: Mon, 7 Feb 2022 12:06:46 +0100 Message-Id: <20220207103804.763779936@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Robert Hancock commit a64067f4cecaaa4deed8e33d3266bc0bcc189142 upstream. A previous change to simple-card resulted in asoc_simple_parse_dai attempting to retrieve the dai_name for platform components, which are unlikely to have a valid DAI name. This caused simple-card to fail to probe when using the xlnx_formatter_pcm as the platform component, since it does not register any DAI components. Since the dai_name is not used for platform components, just skip trying to retrieve it for those. Fixes: f107294c6422 ("ASoC: simple-card: support snd_soc_dai_link_component= style for cpu") Signed-off-by: Robert Hancock Link: https://lore.kernel.org/r/20220107214711.1100162-6-robert.hancock@cal= ian.com Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/soc/generic/simple-card.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -28,6 +28,30 @@ static const struct snd_soc_ops simple_o .hw_params =3D asoc_simple_hw_params, }; =20 +static int asoc_simple_parse_platform(struct device_node *node, + struct snd_soc_dai_link_component *dlc) +{ + struct of_phandle_args args; + int ret; + + if (!node) + return 0; + + /* + * Get node via "sound-dai =3D <&phandle port>" + * it will be used as xxx_of_node on soc_bind_dai_link() + */ + ret =3D of_parse_phandle_with_args(node, DAI, CELL, 0, &args); + if (ret) + return ret; + + /* dai_name is not required and may not exist for plat component */ + + dlc->of_node =3D args.np; + + return 0; +} + static int asoc_simple_parse_dai(struct device_node *node, struct snd_soc_dai_link_component *dlc, int *is_single_link) @@ -289,7 +313,7 @@ static int simple_dai_link_of(struct aso if (ret < 0) goto dai_link_of_err; =20 - ret =3D asoc_simple_parse_dai(plat, platforms, NULL); + ret =3D asoc_simple_parse_platform(plat, platforms); if (ret < 0) goto dai_link_of_err; =20 From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F7E5C4332F for ; Mon, 7 Feb 2022 12:03:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1390882AbiBGL6G (ORCPT ); Mon, 7 Feb 2022 06:58:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384709AbiBGL3i (ORCPT ); Mon, 7 Feb 2022 06:29:38 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB891C0401CA; Mon, 7 Feb 2022 03:28:04 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7784460AB2; Mon, 7 Feb 2022 11:28:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5220DC004E1; Mon, 7 Feb 2022 11:28:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233283; bh=u3/akX/dz9ZO7Yp9P/0+QWrmMr/uEK5Ppvyr2pAXRic=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cRFmOPzv10hMTRT6BL48zRmuMEEDXH4g3h5ozIn8i5dK2B5rdCUw1+t3fdGt+aPVb oYuMDz6FCYXcLgduts/z8TuPUtzFYy1BF24mrgzKW4zPEG/zduEbFspwG3d1Ln0/qR UQSvvnU8aRBEc6mREIa5BEmbzhmm0mTtOLp5Dino= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiasheng Jiang , Mark Brown Subject: [PATCH 5.15 074/110] ASoC: cpcap: Check for NULL pointer after calling of_get_child_by_name Date: Mon, 7 Feb 2022 12:06:47 +0100 Message-Id: <20220207103804.801499999@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Jiasheng Jiang commit f7a6021aaf02088870559f82fc13c58cda7fea1a upstream. If the device does not exist, of_get_child_by_name() will return NULL pointer. And devm_snd_soc_register_component() does not check it. Also, I have noticed that cpcap_codec_driver has not been used yet. Therefore, it should be better to check it in order to avoid the future dereference of the NULL pointer. Fixes: f6cdf2d3445d ("ASoC: cpcap: new codec") Signed-off-by: Jiasheng Jiang Link: https://lore.kernel.org/r/20220111025048.524134-1-jiasheng@iscas.ac.cn Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/soc/codecs/cpcap.c | 2 ++ 1 file changed, 2 insertions(+) --- a/sound/soc/codecs/cpcap.c +++ b/sound/soc/codecs/cpcap.c @@ -1667,6 +1667,8 @@ static int cpcap_codec_probe(struct plat { struct device_node *codec_node =3D of_get_child_by_name(pdev->dev.parent->of_node, "audio-codec"); + if (!codec_node) + return -ENODEV; =20 pdev->dev.of_node =3D codec_node; =20 From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3635C43217 for ; Mon, 7 Feb 2022 12:03:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1390780AbiBGL56 (ORCPT ); Mon, 7 Feb 2022 06:57:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384711AbiBGL3j (ORCPT ); Mon, 7 Feb 2022 06:29:39 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B46F4C0401C6; Mon, 7 Feb 2022 03:28:07 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8FF366091A; Mon, 7 Feb 2022 11:28:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5EAD4C340F0; Mon, 7 Feb 2022 11:28:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233287; bh=07DXET1mUt27c2qdzB5vxavcElMoUr/eGhq3NzQRh/A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A1jAPGWHt+KcZKzX5uwMzPn2N0SERWpjCZgK0c6PLjyGEpFJVX6Ydt/4jfKq0jges 8g4sY8qN1d5VnopwJ7dVZSg6rxk/UyO6DZWyr3met0Uku4oZThfk2a2E5urPRV/wK2 AsGHls+sEe22ha297QRYDnrB4ytt46Lk4JBfMkdw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Mark Brown Subject: [PATCH 5.15 075/110] ASoC: max9759: fix underflow in speaker_gain_control_put() Date: Mon, 7 Feb 2022 12:06:48 +0100 Message-Id: <20220207103804.925662667@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Dan Carpenter commit 4c907bcd9dcd233da6707059d777ab389dcbd964 upstream. Check for negative values of "priv->gain" to prevent an out of bounds access. The concern is that these might come from the user via: -> snd_ctl_elem_write_user() -> snd_ctl_elem_write() -> kctl->put() Fixes: fa8d915172b8 ("ASoC: max9759: Add Amplifier Driver") Signed-off-by: Dan Carpenter Link: https://lore.kernel.org/r/20220119123101.GA9509@kili Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/soc/codecs/max9759.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/sound/soc/codecs/max9759.c +++ b/sound/soc/codecs/max9759.c @@ -64,7 +64,8 @@ static int speaker_gain_control_put(stru struct snd_soc_component *c =3D snd_soc_kcontrol_component(kcontrol); struct max9759 *priv =3D snd_soc_component_get_drvdata(c); =20 - if (ucontrol->value.integer.value[0] > 3) + if (ucontrol->value.integer.value[0] < 0 || + ucontrol->value.integer.value[0] > 3) return -EINVAL; =20 priv->gain =3D ucontrol->value.integer.value[0]; From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B6EFC3527E for ; Mon, 7 Feb 2022 12:03:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1390773AbiBGL5z (ORCPT ); Mon, 7 Feb 2022 06:57:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384715AbiBGL3l (ORCPT ); Mon, 7 Feb 2022 06:29:41 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC0E9C043188; Mon, 7 Feb 2022 03:28:12 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 93E12B81158; Mon, 7 Feb 2022 11:28:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0604C004E1; Mon, 7 Feb 2022 11:28:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233290; bh=mghb54hZFOF3Tf8Tw34fghEoY09mRRxhydg5x0NVEVE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U7YauR0KscXThr/XaJxanyUFWy8fjk6Gt/x+EkqeFjUYwhfJzCS924XyDaDvKSt98 uRIJPAkR1pZMXZAIVdr7y1kiMqMeFKKQgWiw9vgUCG6afTYA+bamNO27Nv65sAq7ru peYhva8Me740YloGLJARO4vYRaMCnGhULi4mSxYc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Srinivas Kandagatla , Mark Brown Subject: [PATCH 5.15 076/110] ASoC: codecs: wcd938x: fix incorrect used of portid Date: Mon, 7 Feb 2022 12:06:49 +0100 Message-Id: <20220207103804.956829119@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Srinivas Kandagatla commit c5c1546a654f613e291a7c5d6f3660fc1eb6d0c7 upstream. Mixer controls have the channel id in mixer->reg, which is not same as port id. port id should be derived from chan_info array. So fix this. Without this, its possible that we could corrupt struct wcd938x_sdw_priv by accessing port_map array out of range with channel id instead of port id. Fixes: e8ba1e05bdc0 ("ASoC: codecs: wcd938x: add basic controls") Signed-off-by: Srinivas Kandagatla Link: https://lore.kernel.org/r/20220126113549.8853-2-srinivas.kandagatla@l= inaro.org Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/soc/codecs/wcd938x.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) --- a/sound/soc/codecs/wcd938x.c +++ b/sound/soc/codecs/wcd938x.c @@ -1432,14 +1432,10 @@ static int wcd938x_sdw_connect_port(stru return 0; } =20 -static int wcd938x_connect_port(struct wcd938x_sdw_priv *wcd, u8 ch_id, u8= enable) +static int wcd938x_connect_port(struct wcd938x_sdw_priv *wcd, u8 port_num,= u8 ch_id, u8 enable) { - u8 port_num; - - port_num =3D wcd->ch_info[ch_id].port_num; - return wcd938x_sdw_connect_port(&wcd->ch_info[ch_id], - &wcd->port_config[port_num], + &wcd->port_config[port_num - 1], enable); } =20 @@ -2593,6 +2589,7 @@ static int wcd938x_set_compander(struct struct wcd938x_priv *wcd938x =3D snd_soc_component_get_drvdata(component); struct wcd938x_sdw_priv *wcd; int value =3D ucontrol->value.integer.value[0]; + int portidx; struct soc_mixer_control *mc; bool hphr; =20 @@ -2606,10 +2603,12 @@ static int wcd938x_set_compander(struct else wcd938x->comp1_enable =3D value; =20 + portidx =3D wcd->ch_info[mc->reg].port_num; + if (value) - wcd938x_connect_port(wcd, mc->reg, true); + wcd938x_connect_port(wcd, portidx, mc->reg, true); else - wcd938x_connect_port(wcd, mc->reg, false); + wcd938x_connect_port(wcd, portidx, mc->reg, false); =20 return 0; } @@ -2882,9 +2881,11 @@ static int wcd938x_get_swr_port(struct s struct wcd938x_sdw_priv *wcd; struct soc_mixer_control *mixer =3D (struct soc_mixer_control *)kcontrol-= >private_value; int dai_id =3D mixer->shift; - int portidx =3D mixer->reg; + int portidx, ch_idx =3D mixer->reg; + =20 wcd =3D wcd938x->sdw_priv[dai_id]; + portidx =3D wcd->ch_info[ch_idx].port_num; =20 ucontrol->value.integer.value[0] =3D wcd->port_enable[portidx]; =20 @@ -2899,12 +2900,14 @@ static int wcd938x_set_swr_port(struct s struct wcd938x_sdw_priv *wcd; struct soc_mixer_control *mixer =3D (struct soc_mixer_control *)kcontrol->private_value; - int portidx =3D mixer->reg; + int ch_idx =3D mixer->reg; + int portidx; int dai_id =3D mixer->shift; bool enable; =20 wcd =3D wcd938x->sdw_priv[dai_id]; =20 + portidx =3D wcd->ch_info[ch_idx].port_num; if (ucontrol->value.integer.value[0]) enable =3D true; else @@ -2912,7 +2915,7 @@ static int wcd938x_set_swr_port(struct s =20 wcd->port_enable[portidx] =3D enable; =20 - wcd938x_connect_port(wcd, portidx, enable); + wcd938x_connect_port(wcd, portidx, ch_idx, enable); =20 return 0; =20 From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78650C3527C for ; Mon, 7 Feb 2022 12:03:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1390766AbiBGL5v (ORCPT ); Mon, 7 Feb 2022 06:57:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384717AbiBGL3m (ORCPT ); Mon, 7 Feb 2022 06:29:42 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E73AC043189; Mon, 7 Feb 2022 03:28:16 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D5900B811AF; Mon, 7 Feb 2022 11:28:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EAC81C004E1; Mon, 7 Feb 2022 11:28:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233293; bh=QSzRICIWp+0GChseBdZWcjIxGZHnKp6X93Ah6uWn+to=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BF+yxwpHCg6gHgJJG2EB5psc3KwzTfZ/sTe8yQpMUOfxFyx0lTFCBniJrK4Nmrvrz U5vxl5yJI6CjZlV9x1iWSUEGXDrg736avj34uC7mBqYsOlFmPjnIuxipcYCw1XyoqQ +ImCHisApsQ+zyhY+HpZXw6+VYIGeZNd2GCa8WdU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Srinivas Kandagatla , Mark Brown Subject: [PATCH 5.15 077/110] ASoC: codecs: lpass-rx-macro: fix sidetone register offsets Date: Mon, 7 Feb 2022 12:06:50 +0100 Message-Id: <20220207103804.987633377@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Srinivas Kandagatla commit fca041a3ab70a099a6d5519ecb689b6279bd04f3 upstream. For some reason we ended up with incorrect register offfset calcuations for sidetone. regmap clearly throw errors when accessing these incorrect registers as these do not belong to any read/write ranges. so fix them to point to correct register offsets. Fixes: f3ce6f3c9a99 ("ASoC: codecs: lpass-rx-macro: add iir widgets") Signed-off-by: Srinivas Kandagatla Link: https://lore.kernel.org/r/20220126113549.8853-3-srinivas.kandagatla@l= inaro.org Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/soc/codecs/lpass-rx-macro.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/sound/soc/codecs/lpass-rx-macro.c +++ b/sound/soc/codecs/lpass-rx-macro.c @@ -2688,8 +2688,8 @@ static uint32_t get_iir_band_coeff(struc int reg, b2_reg; =20 /* Address does not automatically update if reading */ - reg =3D CDC_RX_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx; - b2_reg =3D CDC_RX_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx; + reg =3D CDC_RX_SIDETONE_IIR0_IIR_COEF_B1_CTL + 0x80 * iir_idx; + b2_reg =3D CDC_RX_SIDETONE_IIR0_IIR_COEF_B2_CTL + 0x80 * iir_idx; =20 snd_soc_component_write(component, reg, ((band_idx * BAND_MAX + coeff_idx) * @@ -2718,7 +2718,7 @@ static uint32_t get_iir_band_coeff(struc static void set_iir_band_coeff(struct snd_soc_component *component, int iir_idx, int band_idx, uint32_t value) { - int reg =3D CDC_RX_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx; + int reg =3D CDC_RX_SIDETONE_IIR0_IIR_COEF_B2_CTL + 0x80 * iir_idx; =20 snd_soc_component_write(component, reg, (value & 0xFF)); snd_soc_component_write(component, reg, (value >> 8) & 0xFF); @@ -2739,7 +2739,7 @@ static int rx_macro_put_iir_band_audio_m int iir_idx =3D ctl->iir_idx; int band_idx =3D ctl->band_idx; u32 coeff[BAND_MAX]; - int reg =3D CDC_RX_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx; + int reg =3D CDC_RX_SIDETONE_IIR0_IIR_COEF_B1_CTL + 0x80 * iir_idx; =20 memcpy(&coeff[0], ucontrol->value.bytes.data, params->max); =20 From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5FA94C35272 for ; Mon, 7 Feb 2022 12:00:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389658AbiBGLuh (ORCPT ); Mon, 7 Feb 2022 06:50:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384770AbiBGLaA (ORCPT ); Mon, 7 Feb 2022 06:30:00 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDCD1C0401E6; Mon, 7 Feb 2022 03:28:20 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8845860918; Mon, 7 Feb 2022 11:28:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5EF31C004E1; Mon, 7 Feb 2022 11:28:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233300; bh=esiT/hIJxVX2S5Y8Ay8ItBQhf+iGcOTS78pGTHXvBrc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=moOvvyJSUSZuouXvMw/OP9rpeI+UbSyY8skQ9+J6hnfAS61KaM7on2TbLbx62iX0Q vIL+sM8lySsPDy1znr/Ho5+qJTonSf1PLUukASvXEhlZGmKVx16j72ZQmJfqVpfuyH a6RIOe5Zs0oB69OhtT8TzKVnFhZUQpfEnFzvW0cc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Srinivas Kandagatla , Mark Brown Subject: [PATCH 5.15 078/110] ASoC: codecs: wcd938x: fix return value of mixer put function Date: Mon, 7 Feb 2022 12:06:51 +0100 Message-Id: <20220207103805.020663399@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Srinivas Kandagatla commit bd2347fd67d8da0fa76296507cc556da0a233bcb upstream. wcd938x_ear_pa_put_gain, wcd938x_set_swr_port and wcd938x_set_compander currently returns zero eventhough it changes the value. Fix this, so that change notifications are sent correctly. Fixes: e8ba1e05bdc01 ("ASoC: codecs: wcd938x: add basic controls") Signed-off-by: Srinivas Kandagatla Link: https://lore.kernel.org/r/20220126113549.8853-4-srinivas.kandagatla@l= inaro.org Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- sound/soc/codecs/wcd938x.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/sound/soc/codecs/wcd938x.c +++ b/sound/soc/codecs/wcd938x.c @@ -2559,7 +2559,7 @@ static int wcd938x_ear_pa_put_gain(struc WCD938X_EAR_GAIN_MASK, ucontrol->value.integer.value[0]); =20 - return 0; + return 1; } =20 static int wcd938x_get_compander(struct snd_kcontrol *kcontrol, @@ -2610,7 +2610,7 @@ static int wcd938x_set_compander(struct else wcd938x_connect_port(wcd, portidx, mc->reg, false); =20 - return 0; + return 1; } =20 static int wcd938x_ldoh_get(struct snd_kcontrol *kcontrol, @@ -2917,7 +2917,7 @@ static int wcd938x_set_swr_port(struct s =20 wcd938x_connect_port(wcd, portidx, ch_idx, enable); =20 - return 0; + return 1; =20 } =20 From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 186DEC41535 for ; Mon, 7 Feb 2022 12:00:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389553AbiBGLuL (ORCPT ); Mon, 7 Feb 2022 06:50:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352776AbiBGLaE (ORCPT ); Mon, 7 Feb 2022 06:30:04 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CDA7C03FEE6; Mon, 7 Feb 2022 03:28:25 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 28947B80EBD; Mon, 7 Feb 2022 11:28:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2BA84C004E1; Mon, 7 Feb 2022 11:28:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233302; bh=8QV6oXiFaB4PUA8JqIhf7y6Mx274xZaFC/RUXpTItBc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Fo+LSCeT74grMC0GPXfs24sY/lLKCF4+EdDKEnhrTaVCMV17FzInldyrTujroZmUa WvDHbjWcTpDXc5JqR+RC1O7/WDXrQtShucoa+B2JtIoCbtpzrD9FpZzyd5dlkCMXRS 8o2Iq7OVMbOop7632/NXWW1K9eO+Dq3EkjVdUjUo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, SASANO Takayoshi , Andre Przywara , Jernej Skrabec , Samuel Holland , Linus Walleij Subject: [PATCH 5.15 079/110] pinctrl: sunxi: Fix H616 I2S3 pin data Date: Mon, 7 Feb 2022 12:06:52 +0100 Message-Id: <20220207103805.059120061@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Andre Przywara commit 1fd6bb5b47a65eacb063b37e6fa6df2b8fa92959 upstream. Two bugs have sneaked in the H616 pinctrl data: - PH9 uses the mux value of 0x3 twice (one should be 0x5 instead) - PH8 and PH9 use the "i2s3" function name twice in each pin For the double pin name we use the same trick we pulled for i2s0: append the pin function to the group name to designate the special function. Fixes: 25adc29407fb ("pinctrl: sunxi: Add support for the Allwinner H616 pi= n controller") Reported-by: SASANO Takayoshi Signed-off-by: Andre Przywara Reviewed-by: Jernej Skrabec Reviewed-by: Samuel Holland Link: https://lore.kernel.org/r/20220105172952.23347-1-andre.przywara@arm.c= om Signed-off-by: Linus Walleij Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/pinctrl/sunxi/pinctrl-sun50i-h616.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/drivers/pinctrl/sunxi/pinctrl-sun50i-h616.c +++ b/drivers/pinctrl/sunxi/pinctrl-sun50i-h616.c @@ -363,16 +363,16 @@ static const struct sunxi_desc_pin h616_ SUNXI_FUNCTION(0x0, "gpio_in"), SUNXI_FUNCTION(0x1, "gpio_out"), SUNXI_FUNCTION(0x2, "uart2"), /* CTS */ - SUNXI_FUNCTION(0x3, "i2s3"), /* DO0 */ + SUNXI_FUNCTION(0x3, "i2s3_dout0"), /* DO0 */ SUNXI_FUNCTION(0x4, "spi1"), /* MISO */ - SUNXI_FUNCTION(0x5, "i2s3"), /* DI1 */ + SUNXI_FUNCTION(0x5, "i2s3_din1"), /* DI1 */ SUNXI_FUNCTION_IRQ_BANK(0x6, 6, 8)), /* PH_EINT8 */ SUNXI_PIN(SUNXI_PINCTRL_PIN(H, 9), SUNXI_FUNCTION(0x0, "gpio_in"), SUNXI_FUNCTION(0x1, "gpio_out"), - SUNXI_FUNCTION(0x3, "i2s3"), /* DI0 */ + SUNXI_FUNCTION(0x3, "i2s3_din0"), /* DI0 */ SUNXI_FUNCTION(0x4, "spi1"), /* CS1 */ - SUNXI_FUNCTION(0x3, "i2s3"), /* DO1 */ + SUNXI_FUNCTION(0x5, "i2s3_dout1"), /* DO1 */ SUNXI_FUNCTION_IRQ_BANK(0x6, 6, 9)), /* PH_EINT9 */ SUNXI_PIN(SUNXI_PINCTRL_PIN(H, 10), SUNXI_FUNCTION(0x0, "gpio_in"), From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27F78C3526C for ; Mon, 7 Feb 2022 12:00:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389583AbiBGLuQ (ORCPT ); Mon, 7 Feb 2022 06:50:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349352AbiBGLaH (ORCPT ); Mon, 7 Feb 2022 06:30:07 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E449DC03FEF7; Mon, 7 Feb 2022 03:28:28 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 1480DB81158; Mon, 7 Feb 2022 11:28:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1CD12C004E1; Mon, 7 Feb 2022 11:28:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233305; bh=ugirauE7wsGqXb36nXK6gxIvb+7wGHj2bprs0GCSXLQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ukQjQDUzpmEzWMeJlrrIqbjlTC6ATB6Cwqxwi/SMpr+vpy/3+12IWgeF/YaRzTwsQ +/r+Rovx2E0W0Xu3zW7H8UMnuOFy1YrIq6yS097ljNVD2p3RPjsLFjLkDkFthNwLlx WjTodUWADorpwONLWywqZ0Ca3WYui7DsUJjYpx1s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kane Chen , Andy Shevchenko , Mika Westerberg , Grace Kao Subject: [PATCH 5.15 080/110] pinctrl: intel: Fix a glitch when updating IRQ flags on a preconfigured line Date: Mon, 7 Feb 2022 12:06:53 +0100 Message-Id: <20220207103805.092155522@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Andy Shevchenko commit e12963c453263d5321a2c610e98cbc731233b685 upstream. The commit af7e3eeb84e2 ("pinctrl: intel: Disable input and output buffer when switching to GPIO") hadn't taken into account an update of the IRQ flags scenario. When updating the IRQ flags on the preconfigured line the ->irq_set_type() is called again. In such case the sequential Rx buffer configuration changes may trigger a falling or rising edge interrupt that may lead, on some platforms, to an undesired event. This may happen because each of intel_gpio_set_gpio_mode() and __intel_gpio_set_direction() updates the pad configuration with a different value of the GPIORXDIS bit. Notable, that the intel_gpio_set_gpio_mode() is called only for the pads that are configured as an input. Due to this fact, integrate the logic of __intel_gpio_set_direction() call into the intel_gpio_set_gpio_mode() so that the Rx buffer won't be disabled and immediately re-enabled. Fixes: af7e3eeb84e2 ("pinctrl: intel: Disable input and output buffer when = switching to GPIO") Reported-by: Kane Chen Signed-off-by: Andy Shevchenko Acked-by: Mika Westerberg Tested-by: Grace Kao Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/pinctrl/intel/pinctrl-intel.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) --- a/drivers/pinctrl/intel/pinctrl-intel.c +++ b/drivers/pinctrl/intel/pinctrl-intel.c @@ -451,8 +451,8 @@ static void intel_gpio_set_gpio_mode(voi value &=3D ~PADCFG0_PMODE_MASK; value |=3D PADCFG0_PMODE_GPIO; =20 - /* Disable input and output buffers */ - value |=3D PADCFG0_GPIORXDIS; + /* Disable TX buffer and enable RX (this will be input) */ + value &=3D ~PADCFG0_GPIORXDIS; value |=3D PADCFG0_GPIOTXDIS; =20 /* Disable SCI/SMI/NMI generation */ @@ -497,9 +497,6 @@ static int intel_gpio_request_enable(str =20 intel_gpio_set_gpio_mode(padcfg0); =20 - /* Disable TX buffer and enable RX (this will be input) */ - __intel_gpio_set_direction(padcfg0, true); - raw_spin_unlock_irqrestore(&pctrl->lock, flags); =20 return 0; @@ -1115,9 +1112,6 @@ static int intel_gpio_irq_type(struct ir =20 intel_gpio_set_gpio_mode(reg); =20 - /* Disable TX buffer and enable RX (this will be input) */ - __intel_gpio_set_direction(reg, true); - value =3D readl(reg); =20 value &=3D ~(PADCFG0_RXEVCFG_MASK | PADCFG0_RXINV); From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 381A3C35271 for ; Mon, 7 Feb 2022 12:00:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389631AbiBGLuW (ORCPT ); Mon, 7 Feb 2022 06:50:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359604AbiBGLaJ (ORCPT ); Mon, 7 Feb 2022 06:30:09 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68CB4C03E94C; Mon, 7 Feb 2022 03:28:31 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 270C0B811B3; Mon, 7 Feb 2022 11:28:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E9DDC004E1; Mon, 7 Feb 2022 11:28:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233309; bh=HlwO99kzVVDq/w0vcBsb1+gvp57k51VTn37EzEf+CmY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pogn1h+/KMb8Y7sG1eU4Z3tPqmZDBcQ6cl46Mte8qcQR2IMpgZsCNsgf0iTRactKr /HUX+GP+cPglgKXFE1PtJxuY2C6DUCrDuL9YU6ltCp298yeWLgwAgHSAEMJZImlzRh 7eQW3BFS/9KAagZaSrieHSpeI16v0Mb7Pmf8psLA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?=C5=81ukasz=20Bartosik?= , Andy Shevchenko Subject: [PATCH 5.15 081/110] pinctrl: intel: fix unexpected interrupt Date: Mon, 7 Feb 2022 12:06:54 +0100 Message-Id: <20220207103805.134119606@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: =C5=81ukasz Bartosik commit e986f0e602f19ecb7880b04dd1db415ed9bca3f6 upstream. ASUS Chromebook C223 with Celeron N3350 crashes sometimes during cold booot. Inspection of the kernel log showed that it gets into an inifite loop logging the following message: ->handle_irq(): 000000009cdb51e8, handle_bad_irq+0x0/0x251 ->irq_data.chip(): 000000005ec212a7, 0xffffa043009d8e7 ->action(): 00000 IRQ_NOPROBE set unexpected IRQ trap at vector 7c The issue happens during cold boot but only if cold boot happens at most several dozen seconds after Chromebook is powered off. For longer intervals between power off and power on (cold boot) the issue does not reproduce. The unexpected interrupt is sourced from INT3452 GPIO pin which is used for SD card detect. Investigation relevealed that when the interval between power off and power on (cold boot) is less than several dozen seconds then values of INT3452 GPIO interrupt enable and interrupt pending registers survive power off and power on sequence and interrupt for SD card detect pin is enabled and pending during probe of SD controller which causes the unexpected IRQ message. "Intel Pentium and Celeron Processor N- and J- Series" volume 3 doc mentions that GPIO interrupt enable and status registers default value is 0x0. The fix clears INT3452 GPIO interrupt enabled and interrupt pending registers in its probe function. Fixes: 7981c0015af2 ("pinctrl: intel: Add Intel Sunrisepoint pin controller= and GPIO support") Signed-off-by: =C5=81ukasz Bartosik Signed-off-by: Andy Shevchenko Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/pinctrl/intel/pinctrl-intel.c | 54 +++++++++++++++++++++--------= ----- 1 file changed, 34 insertions(+), 20 deletions(-) --- a/drivers/pinctrl/intel/pinctrl-intel.c +++ b/drivers/pinctrl/intel/pinctrl-intel.c @@ -1210,6 +1210,39 @@ static irqreturn_t intel_gpio_irq(int ir return IRQ_RETVAL(ret); } =20 +static void intel_gpio_irq_init(struct intel_pinctrl *pctrl) +{ + int i; + + for (i =3D 0; i < pctrl->ncommunities; i++) { + const struct intel_community *community; + void __iomem *base; + unsigned int gpp; + + community =3D &pctrl->communities[i]; + base =3D community->regs; + + for (gpp =3D 0; gpp < community->ngpps; gpp++) { + /* Mask and clear all interrupts */ + writel(0, base + community->ie_offset + gpp * 4); + writel(0xffff, base + community->is_offset + gpp * 4); + } + } +} + +static int intel_gpio_irq_init_hw(struct gpio_chip *gc) +{ + struct intel_pinctrl *pctrl =3D gpiochip_get_data(gc); + + /* + * Make sure the interrupt lines are in a proper state before + * further configuration. + */ + intel_gpio_irq_init(pctrl); + + return 0; +} + static int intel_gpio_add_community_ranges(struct intel_pinctrl *pctrl, const struct intel_community *community) { @@ -1314,6 +1347,7 @@ static int intel_gpio_probe(struct intel girq->num_parents =3D 0; girq->default_type =3D IRQ_TYPE_NONE; girq->handler =3D handle_bad_irq; + girq->init_hw =3D intel_gpio_irq_init_hw; =20 ret =3D devm_gpiochip_add_data(pctrl->dev, &pctrl->chip, pctrl); if (ret) { @@ -1689,26 +1723,6 @@ int intel_pinctrl_suspend_noirq(struct d } EXPORT_SYMBOL_GPL(intel_pinctrl_suspend_noirq); =20 -static void intel_gpio_irq_init(struct intel_pinctrl *pctrl) -{ - size_t i; - - for (i =3D 0; i < pctrl->ncommunities; i++) { - const struct intel_community *community; - void __iomem *base; - unsigned int gpp; - - community =3D &pctrl->communities[i]; - base =3D community->regs; - - for (gpp =3D 0; gpp < community->ngpps; gpp++) { - /* Mask and clear all interrupts */ - writel(0, base + community->ie_offset + gpp * 4); - writel(0xffff, base + community->is_offset + gpp * 4); - } - } -} - static bool intel_gpio_update_reg(void __iomem *reg, u32 mask, u32 value) { u32 curr, updated; From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A0A5C46467 for ; Mon, 7 Feb 2022 12:00:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389640AbiBGLu0 (ORCPT ); Mon, 7 Feb 2022 06:50:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380273AbiBGLaJ (ORCPT ); Mon, 7 Feb 2022 06:30:09 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 027B4C03E957; Mon, 7 Feb 2022 03:28:32 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8A8026077B; Mon, 7 Feb 2022 11:28:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 733BFC004E1; Mon, 7 Feb 2022 11:28:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233312; bh=gL+AJW7aUmc5Iap6xJjIKV40t3Yz1xThdKwzbu6TnWs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1UKjbuA/p1pvwGSX/KqxDV5muIvTmKvkobZST/EIcHRsbNC429gBU0DyzChmZ+ta7 vdHKivlhguH48t5cL7/ln7TASFa+qpGbV7zfEXe1v95fZ/cRaqusQz3Aq+5LUW7WWu wbxJXeSnkz0d+BIfFDqLd2zJbAaJYOzG1woLVltc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Florian Fainelli , Linus Walleij Subject: [PATCH 5.15 082/110] pinctrl: bcm2835: Fix a few error paths Date: Mon, 7 Feb 2022 12:06:55 +0100 Message-Id: <20220207103805.173542541@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Florian Fainelli commit 5297c693d8c8e08fa742e3112cf70723f7a04da2 upstream. After commit 266423e60ea1 ("pinctrl: bcm2835: Change init order for gpio hogs") a few error paths would not unwind properly the registration of gpio ranges. Correct that by assigning a single error label and goto it whenever we encounter a fatal error. Fixes: 266423e60ea1 ("pinctrl: bcm2835: Change init order for gpio hogs") Signed-off-by: Florian Fainelli Link: https://lore.kernel.org/r/20220127215033.267227-1-f.fainelli@gmail.com Signed-off-by: Linus Walleij Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/pinctrl/bcm/pinctrl-bcm2835.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) --- a/drivers/pinctrl/bcm/pinctrl-bcm2835.c +++ b/drivers/pinctrl/bcm/pinctrl-bcm2835.c @@ -1263,16 +1263,18 @@ static int bcm2835_pinctrl_probe(struct sizeof(*girq->parents), GFP_KERNEL); if (!girq->parents) { - pinctrl_remove_gpio_range(pc->pctl_dev, &pc->gpio_range); - return -ENOMEM; + err =3D -ENOMEM; + goto out_remove; } =20 if (is_7211) { pc->wake_irq =3D devm_kcalloc(dev, BCM2835_NUM_IRQS, sizeof(*pc->wake_irq), GFP_KERNEL); - if (!pc->wake_irq) - return -ENOMEM; + if (!pc->wake_irq) { + err =3D -ENOMEM; + goto out_remove; + } } =20 /* @@ -1300,8 +1302,10 @@ static int bcm2835_pinctrl_probe(struct =20 len =3D strlen(dev_name(pc->dev)) + 16; name =3D devm_kzalloc(pc->dev, len, GFP_KERNEL); - if (!name) - return -ENOMEM; + if (!name) { + err =3D -ENOMEM; + goto out_remove; + } =20 snprintf(name, len, "%s:bank%d", dev_name(pc->dev), i); =20 @@ -1320,11 +1324,14 @@ static int bcm2835_pinctrl_probe(struct err =3D gpiochip_add_data(&pc->gpio_chip, pc); if (err) { dev_err(dev, "could not add GPIO chip\n"); - pinctrl_remove_gpio_range(pc->pctl_dev, &pc->gpio_range); - return err; + goto out_remove; } =20 return 0; + +out_remove: + pinctrl_remove_gpio_range(pc->pctl_dev, &pc->gpio_range); + return err; } =20 static struct platform_driver bcm2835_pinctrl_driver =3D { From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9CE32C47084 for ; Mon, 7 Feb 2022 12:03:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391127AbiBGL6Y (ORCPT ); Mon, 7 Feb 2022 06:58:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385470AbiBGLby (ORCPT ); Mon, 7 Feb 2022 06:31:54 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93729C03E944; Mon, 7 Feb 2022 03:30:26 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 475E0B811BE; Mon, 7 Feb 2022 11:30:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50C22C004E1; Mon, 7 Feb 2022 11:30:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233424; bh=dDv+O0Tzmkl7n2hL6tah/Kh7Z2X5dd7k5qI4BVpOqWQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NzR4wutdE+XwIjzcLIwdTFghUFpoyYBENoFRRMl2reMmNDnhEQhzh0YctLMDNHNHz T5Tt7KaHmq9TAuqITNyy9tzmGVnyzNt3RI3n3Q9W9h8w12sjSPCTbiexbSBrk1rQok cnhAui0z7iOq4X/1iN+i/7YjGBCjM/S7ULd8zMjg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guangwu Zhang , Saurav Kashyap , John Meneghini , "Martin K. Petersen" Subject: [PATCH 5.15 083/110] scsi: bnx2fc: Make bnx2fc_recv_frame() mp safe Date: Mon, 7 Feb 2022 12:06:56 +0100 Message-Id: <20220207103805.208752206@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: John Meneghini commit 936bd03405fc83ba039d42bc93ffd4b88418f1d3 upstream. Running tests with a debug kernel shows that bnx2fc_recv_frame() is modifying the per_cpu lport stats counters in a non-mpsafe way. Just boot a debug kernel and run the bnx2fc driver with the hardware enabled. [ 1391.699147] BUG: using smp_processor_id() in preemptible [00000000] code= : bnx2fc_ [ 1391.699160] caller is bnx2fc_recv_frame+0xbf9/0x1760 [bnx2fc] [ 1391.699174] CPU: 2 PID: 4355 Comm: bnx2fc_l2_threa Kdump: loaded Tainted= : G B [ 1391.699180] Hardware name: HP ProLiant DL120 G7, BIOS J01 07/01/2013 [ 1391.699183] Call Trace: [ 1391.699188] dump_stack_lvl+0x57/0x7d [ 1391.699198] check_preemption_disabled+0xc8/0xd0 [ 1391.699205] bnx2fc_recv_frame+0xbf9/0x1760 [bnx2fc] [ 1391.699215] ? do_raw_spin_trylock+0xb5/0x180 [ 1391.699221] ? bnx2fc_npiv_create_vports.isra.0+0x4e0/0x4e0 [bnx2fc] [ 1391.699229] ? bnx2fc_l2_rcv_thread+0xb7/0x3a0 [bnx2fc] [ 1391.699240] bnx2fc_l2_rcv_thread+0x1af/0x3a0 [bnx2fc] [ 1391.699250] ? bnx2fc_ulp_init+0xc0/0xc0 [bnx2fc] [ 1391.699258] kthread+0x364/0x420 [ 1391.699263] ? _raw_spin_unlock_irq+0x24/0x50 [ 1391.699268] ? set_kthread_struct+0x100/0x100 [ 1391.699273] ret_from_fork+0x22/0x30 Restore the old get_cpu/put_cpu code with some modifications to reduce the size of the critical section. Link: https://lore.kernel.org/r/20220124145110.442335-1-jmeneghi@redhat.com Fixes: d576a5e80cd0 ("bnx2fc: Improve stats update mechanism") Tested-by: Guangwu Zhang Acked-by: Saurav Kashyap Signed-off-by: John Meneghini Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) --- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c +++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c @@ -508,7 +508,8 @@ static int bnx2fc_l2_rcv_thread(void *ar =20 static void bnx2fc_recv_frame(struct sk_buff *skb) { - u32 fr_len; + u64 crc_err; + u32 fr_len, fr_crc; struct fc_lport *lport; struct fcoe_rcv_info *fr; struct fc_stats *stats; @@ -542,6 +543,11 @@ static void bnx2fc_recv_frame(struct sk_ skb_pull(skb, sizeof(struct fcoe_hdr)); fr_len =3D skb->len - sizeof(struct fcoe_crc_eof); =20 + stats =3D per_cpu_ptr(lport->stats, get_cpu()); + stats->RxFrames++; + stats->RxWords +=3D fr_len / FCOE_WORD_TO_BYTE; + put_cpu(); + fp =3D (struct fc_frame *)skb; fc_frame_init(fp); fr_dev(fp) =3D lport; @@ -624,16 +630,15 @@ static void bnx2fc_recv_frame(struct sk_ return; } =20 - stats =3D per_cpu_ptr(lport->stats, smp_processor_id()); - stats->RxFrames++; - stats->RxWords +=3D fr_len / FCOE_WORD_TO_BYTE; + fr_crc =3D le32_to_cpu(fr_crc(fp)); =20 - if (le32_to_cpu(fr_crc(fp)) !=3D - ~crc32(~0, skb->data, fr_len)) { - if (stats->InvalidCRCCount < 5) + if (unlikely(fr_crc !=3D ~crc32(~0, skb->data, fr_len))) { + stats =3D per_cpu_ptr(lport->stats, get_cpu()); + crc_err =3D (stats->InvalidCRCCount++); + put_cpu(); + if (crc_err < 5) printk(KERN_WARNING PFX "dropping frame with " "CRC error\n"); - stats->InvalidCRCCount++; kfree_skb(skb); return; } From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90FADC433EF for ; Mon, 7 Feb 2022 12:00:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235224AbiBGLzr (ORCPT ); Mon, 7 Feb 2022 06:55:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385015AbiBGLa5 (ORCPT ); Mon, 7 Feb 2022 06:30:57 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02F3CC03BFFA; Mon, 7 Feb 2022 03:28:59 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B324BB811B2; Mon, 7 Feb 2022 11:28:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DDFCCC36AE2; Mon, 7 Feb 2022 11:28:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233337; bh=TdKdDS8mr/Iv2O+Ke94fu/1lpmuGq84s4HlElW3efN8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=usBKefgxZ2ogVmb+oI3SvYIPNcjjjp4m2nUrNiK/oRIyhkKYhTRQGgnzBv/wH0dF3 vx8WRasRZJX8wbOJNBCpfptWtx7CXyZcXS5AVNWGyvo5Hpqa9+FO4CzETWzYIoknXS moWe/DdpVhmUbov5ugS2ErrQPbd2P1Nstw3+uD0o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dai Ngo , Chuck Lever , Bruce Fields Subject: [PATCH 5.15 084/110] nfsd: nfsd4_setclientid_confirm mistakenly expires confirmed client. Date: Mon, 7 Feb 2022 12:06:57 +0100 Message-Id: <20220207103805.253054671@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Dai Ngo commit ab451ea952fe9d7afefae55ddb28943a148247fe upstream. >From RFC 7530 Section 16.34.5: o The server has not recorded an unconfirmed { v, x, c, *, * } and has recorded a confirmed { v, x, c, *, s }. If the principals of the record and of SETCLIENTID_CONFIRM do not match, the server returns NFS4ERR_CLID_INUSE without removing any relevant leased client state, and without changing recorded callback and callback_ident values for client { x }. The current code intends to do what the spec describes above but it forgot to set 'old' to NULL resulting to the confirmed client to be expired. Fixes: 2b63482185e6 ("nfsd: fix clid_inuse on mount with security change") Signed-off-by: Dai Ngo Signed-off-by: Chuck Lever Reviewed-by: Bruce Fields Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- fs/nfsd/nfs4state.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -4112,8 +4112,10 @@ nfsd4_setclientid_confirm(struct svc_rqs status =3D nfserr_clid_inuse; if (client_has_state(old) && !same_creds(&unconf->cl_cred, - &old->cl_cred)) + &old->cl_cred)) { + old =3D NULL; goto out; + } status =3D mark_client_expired_locked(old); if (status) { old =3D NULL; From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C8D6BC4707A for ; Mon, 7 Feb 2022 12:03:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382097AbiBGL4z (ORCPT ); Mon, 7 Feb 2022 06:56:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385190AbiBGLbS (ORCPT ); Mon, 7 Feb 2022 06:31:18 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E0C8C03FEE0; Mon, 7 Feb 2022 03:29:33 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 82D126077B; Mon, 7 Feb 2022 11:29:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66D58C004E1; Mon, 7 Feb 2022 11:29:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233373; bh=GS6MBhstiZFiTAX47S9HOYPrRvE1rIgmTK6Ds/8qu4Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vz2MI98HlH63Wyrq7duaOcQ/cViXIuzS6ixFxzTiLFsYy6OWrUdS59Onaq/QQU5d8 EyOHX+pjoSS9Mjk5favPOtchc0b87Jt7GuU5TqBoiA0lMvV9sivU9qW5eTldrKIAvc +zkcd8nzcZ3I0QMzWdS1eA5o5LAetDnPdWfo9IcY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Haiyue Wang , "David S. Miller" Subject: [PATCH 5.15 085/110] gve: fix the wrong AdminQ buffer queue index check Date: Mon, 7 Feb 2022 12:06:58 +0100 Message-Id: <20220207103805.285730669@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Haiyue Wang commit 1f84a9450d75e08af70d9e2f2d5e1c0ac0c881d2 upstream. The 'tail' and 'head' are 'unsigned int' type free-running count, when 'head' is overflow, the 'int i (=3D tail) < u32 head' will be false: Only '- loop 0: idx =3D 63' result is shown, so it needs to use 'int' type to compare, it can handle the overflow correctly. typedef uint32_t u32; int main() { u32 tail, head; int stail, shead; int i, loop; tail =3D 0xffffffff; head =3D 0x00000000; for (i =3D tail, loop =3D 0; i < head; i++) { unsigned int idx =3D i & 63; printf("+ loop %d: idx =3D %u\n", loop++, idx); } stail =3D tail; shead =3D head; for (i =3D stail, loop =3D 0; i < shead; i++) { unsigned int idx =3D i & 63; printf("- loop %d: idx =3D %u\n", loop++, idx); } return 0; } Fixes: 5cdad90de62c ("gve: Batch AQ commands for creating and destroying qu= eues.") Signed-off-by: Haiyue Wang Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/net/ethernet/google/gve/gve_adminq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/net/ethernet/google/gve/gve_adminq.c +++ b/drivers/net/ethernet/google/gve/gve_adminq.c @@ -281,7 +281,7 @@ static int gve_adminq_parse_err(struct g */ static int gve_adminq_kick_and_wait(struct gve_priv *priv) { - u32 tail, head; + int tail, head; int i; =20 tail =3D ioread32be(&priv->reg_bar0->adminq_event_counter); From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E234C3527B for ; Mon, 7 Feb 2022 12:03:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1390737AbiBGL5j (ORCPT ); Mon, 7 Feb 2022 06:57:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385260AbiBGLb1 (ORCPT ); Mon, 7 Feb 2022 06:31:27 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65167C043188; Mon, 7 Feb 2022 03:30:04 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 249E1B8111C; Mon, 7 Feb 2022 11:30:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63342C004E1; Mon, 7 Feb 2022 11:30:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233401; bh=FaEL32L8jTCbwx8zIa5szTEouuCoK0lO5+KhZu49YAU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eGCaFEE1G06lONpwzqXvhSJgLx0fu01TramK9skQMrk0LDYLhW8L1cnaVGjeCiBt7 jL+0ksWb9hAtgC6G2sr8fWcbPLjYCkPpYINmJuQYVFsQJoqbDVugviLAZaEA0mA3WH TvOhHrgZ3G1LSSvUAA0/MAH8sSn6COkn1jYiJeDk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+5ad567a418794b9b5983@syzkaller.appspotmail.com, Hou Tao , Andrii Nakryiko Subject: [PATCH 5.15 086/110] bpf: Use VM_MAP instead of VM_ALLOC for ringbuf Date: Mon, 7 Feb 2022 12:06:59 +0100 Message-Id: <20220207103805.316988910@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Hou Tao commit b293dcc473d22a62dc6d78de2b15e4f49515db56 upstream. After commit 2fd3fb0be1d1 ("kasan, vmalloc: unpoison VM_ALLOC pages after mapping"), non-VM_ALLOC mappings will be marked as accessible in __get_vm_area_node() when KASAN is enabled. But now the flag for ringbuf area is VM_ALLOC, so KASAN will complain out-of-bound access after vmap() returns. Because the ringbuf area is created by mapping allocated pages, so use VM_MAP instead. After the change, info in /proc/vmallocinfo also changes from [start]-[end] 24576 ringbuf_map_alloc+0x171/0x290 vmalloc user to [start]-[end] 24576 ringbuf_map_alloc+0x171/0x290 vmap user Fixes: 457f44363a88 ("bpf: Implement BPF ring buffer and verifier support f= or it") Reported-by: syzbot+5ad567a418794b9b5983@syzkaller.appspotmail.com Signed-off-by: Hou Tao Signed-off-by: Andrii Nakryiko Link: https://lore.kernel.org/bpf/20220202060158.6260-1-houtao1@huawei.com Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- kernel/bpf/ringbuf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/kernel/bpf/ringbuf.c +++ b/kernel/bpf/ringbuf.c @@ -104,7 +104,7 @@ static struct bpf_ringbuf *bpf_ringbuf_a } =20 rb =3D vmap(pages, nr_meta_pages + 2 * nr_data_pages, - VM_ALLOC | VM_USERMAP, PAGE_KERNEL); + VM_MAP | VM_USERMAP, PAGE_KERNEL); if (rb) { kmemleak_not_leak(pages); rb->pages =3D pages; From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85E85C35278 for ; Mon, 7 Feb 2022 12:03:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1390730AbiBGL5f (ORCPT ); Mon, 7 Feb 2022 06:57:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385269AbiBGLb1 (ORCPT ); Mon, 7 Feb 2022 06:31:27 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07D35C0401C7; Mon, 7 Feb 2022 03:30:06 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 98E1960B65; Mon, 7 Feb 2022 11:30:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 75386C3411F; Mon, 7 Feb 2022 11:30:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233405; bh=+nRe8g/tE2F5FU0y+dnQVbMd4p5XFCbxsci5pHSsjd4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WmxPtNh7GwONMW8yA6DhoSFOeieeaHw6jebG3Gz7TzzGVBa0vQZrTONV5RFL5LUxr AP2D101cCwP07sL787mqsEqxg0fOgMaen95zcBJKuSjpN+8/8ArUlyKc1qJKFKorbO 20wfF4+fNtJeEXgjWyzf/b1HlNqq1zCI64tdQ7U4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Muhammad Usama Anjum , Shuah Khan Subject: [PATCH 5.15 087/110] selftests/exec: Remove pipe from TEST_GEN_FILES Date: Mon, 7 Feb 2022 12:07:00 +0100 Message-Id: <20220207103805.348313211@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Muhammad Usama Anjum commit 908a26e139e8cf21093acc56d8e90ddad2ad1eff upstream. pipe named FIFO special file is being created in execveat.c to perform some tests. Makefile doesn't need to do anything with the pipe. When it isn't found, Makefile generates the following build error: make: *** No rule to make target '../tools/testing/selftests/exec/pipe', needed by 'all'. Stop. pipe is created and removed during test run-time. Amended change log to add pipe remove info: Shuah Khan Fixes: 61016db15b8e ("selftests/exec: Verify execve of non-regular files fa= il") Signed-off-by: Muhammad Usama Anjum Reviewed-by: Shuah Khan Signed-off-by: Shuah Khan Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- tools/testing/selftests/exec/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/tools/testing/selftests/exec/Makefile +++ b/tools/testing/selftests/exec/Makefile @@ -5,7 +5,7 @@ CFLAGS +=3D -D_GNU_SOURCE =20 TEST_PROGS :=3D binfmt_script non-regular TEST_GEN_PROGS :=3D execveat load_address_4096 load_address_2097152 load_a= ddress_16777216 -TEST_GEN_FILES :=3D execveat.symlink execveat.denatured script subdir pipe +TEST_GEN_FILES :=3D execveat.symlink execveat.denatured script subdir # Makefile is a run-time dependency, since it's accessed by the execveat t= est TEST_FILES :=3D Makefile =20 From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE79EC433EF for ; Mon, 7 Feb 2022 12:03:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1390791AbiBGL6C (ORCPT ); Mon, 7 Feb 2022 06:58:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385300AbiBGLb3 (ORCPT ); Mon, 7 Feb 2022 06:31:29 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CD6AC0401DD; Mon, 7 Feb 2022 03:30:09 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 169576077B; Mon, 7 Feb 2022 11:30:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1DB1C004E1; Mon, 7 Feb 2022 11:30:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233408; bh=72vwZ6kvzEMAGleLWY/VTPiDOeZhPnE8/1zmPpNqG64=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jmqHiAFBumnDyvarzDaoS4gMORpMuXZAR3VqBHL4aatF+Jk4P+oEuyAr22MaHUrg0 4gEwOnmr4kddNwB7Afrj47RF9qCzOXsGfm0L4T55Vpvw6zyg3eh9MnfN7x+0/rch7+ 7cqeE2do1m8bVQq8mkq0+wzI3CzsWjVnFVnZZaW8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Muhammad Usama Anjum , =?UTF-8?q?Andr=C3=A9=20Almeida?= , Shuah Khan Subject: [PATCH 5.15 088/110] selftests: futex: Use variable MAKE instead of make Date: Mon, 7 Feb 2022 12:07:01 +0100 Message-Id: <20220207103805.386499266@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Muhammad Usama Anjum commit b9199181a9ef8252e47e207be8c23e1f50662620 upstream. Recursive make commands should always use the variable MAKE, not the explicit command name =E2=80=98make=E2=80=99. This has benefits and removes= the following warning when multiple jobs are used for the build: make[2]: warning: jobserver unavailable: using -j1. Add '+' to parent make= rule. Fixes: a8ba798bc8ec ("selftests: enable O and KBUILD_OUTPUT") Signed-off-by: Muhammad Usama Anjum Reviewed-by: Andr=C3=A9 Almeida Signed-off-by: Shuah Khan Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- tools/testing/selftests/futex/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/tools/testing/selftests/futex/Makefile +++ b/tools/testing/selftests/futex/Makefile @@ -11,7 +11,7 @@ all: @for DIR in $(SUBDIRS); do \ BUILD_TARGET=3D$(OUTPUT)/$$DIR; \ mkdir $$BUILD_TARGET -p; \ - make OUTPUT=3D$$BUILD_TARGET -C $$DIR $@;\ + $(MAKE) OUTPUT=3D$$BUILD_TARGET -C $$DIR $@;\ if [ -e $$DIR/$(TEST_PROGS) ]; then \ rsync -a $$DIR/$(TEST_PROGS) $$BUILD_TARGET/; \ fi \ @@ -32,6 +32,6 @@ override define CLEAN @for DIR in $(SUBDIRS); do \ BUILD_TARGET=3D$(OUTPUT)/$$DIR; \ mkdir $$BUILD_TARGET -p; \ - make OUTPUT=3D$$BUILD_TARGET -C $$DIR $@;\ + $(MAKE) OUTPUT=3D$$BUILD_TARGET -C $$DIR $@;\ done endef From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C203C47081 for ; Mon, 7 Feb 2022 12:03:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391106AbiBGL6U (ORCPT ); Mon, 7 Feb 2022 06:58:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385372AbiBGLbj (ORCPT ); Mon, 7 Feb 2022 06:31:39 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FA95C03FEE4; Mon, 7 Feb 2022 03:30:14 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 27B58B80EBD; Mon, 7 Feb 2022 11:30:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20A0BC004E1; Mon, 7 Feb 2022 11:30:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233411; bh=rG2zIR8em5dhqg9au0dA4l5hkYO7yd8NVH3Wp/6VZIs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SFppwJmxWItrmpyQ0yZNqiEJLC7nN/SNr0E+HEuzg0rDSouPXvFuPCXMG6ssvAPg/ RL9+IBt1Yf4TZVwFoBncU471mxP45CbFO8Wzf2PqJcX/CbJK1kCXbaBC8Gbm42P+uW kF1sVjG+VCKSEuc6Q3xkzXmxdVouFixlq5q11Zbg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nathan Chancellor , Daniel Borkmann Subject: [PATCH 5.15 089/110] tools/resolve_btfids: Do not print any commands when building silently Date: Mon, 7 Feb 2022 12:07:02 +0100 Message-Id: <20220207103805.420581720@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Nathan Chancellor commit 7f3bdbc3f13146eb9d07de81ea71f551587a384b upstream. When building with 'make -s', there is some output from resolve_btfids: $ make -sj"$(nproc)" oldconfig prepare MKDIR .../tools/bpf/resolve_btfids/libbpf/ MKDIR .../tools/bpf/resolve_btfids//libsubcmd LINK resolve_btfids Silent mode means that no information should be emitted about what is currently being done. Use the $(silent) variable from Makefile.include to avoid defining the msg macro so that there is no information printed. Fixes: fbbb68de80a4 ("bpf: Add resolve_btfids tool to resolve BTF IDs in EL= F object") Signed-off-by: Nathan Chancellor Signed-off-by: Daniel Borkmann Link: https://lore.kernel.org/bpf/20220201212503.731732-1-nathan@kernel.org Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- tools/bpf/resolve_btfids/Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/tools/bpf/resolve_btfids/Makefile +++ b/tools/bpf/resolve_btfids/Makefile @@ -9,7 +9,11 @@ ifeq ($(V),1) msg =3D else Q =3D @ - msg =3D @printf ' %-8s %s%s\n' "$(1)" "$(notdir $(2))" "$(if $(3), $(3)= )"; + ifeq ($(silent),1) + msg =3D + else + msg =3D @printf ' %-8s %s%s\n' "$(1)" "$(notdir $(2))" "$(if $(3), $(= 3))"; + endif MAKEFLAGS=3D--no-print-directory endif =20 From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37D0CC4321E for ; Mon, 7 Feb 2022 12:03:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391055AbiBGL6Q (ORCPT ); Mon, 7 Feb 2022 06:58:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385407AbiBGLbt (ORCPT ); Mon, 7 Feb 2022 06:31:49 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F5DDC02B662; Mon, 7 Feb 2022 03:30:15 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 73B8260AB0; Mon, 7 Feb 2022 11:30:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B18CC004E1; Mon, 7 Feb 2022 11:30:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233414; bh=i2PB0zojxD9sz4cxUGlG2ch2e9HLN9jntYt4Vcfu+iA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nIwY/NpH15AB/fa+yCdKHsDf1lY7JWeoIDEFkYBLxafQP0sXz0f2u225NXTYuOVM5 sVKgX0PcKJCcpHYIOmfvGKIQIIBYrUHB5PgUVlxlLzuOJOxFF+KvAInkuUahhULiOH gyJzpvmQ43Lrxki4w7axv9WpNYOybj4PH+UVSx58= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kai-Heng Feng , Dima Ruinskiy , Sasha Neftin , Nechama Kraus , Tony Nguyen Subject: [PATCH 5.15 090/110] e1000e: Separate ADP board type from TGP Date: Mon, 7 Feb 2022 12:07:03 +0100 Message-Id: <20220207103805.451603316@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Sasha Neftin commit 68defd528f94ed1cf11f49a75cc1875dccd781fa upstream. We have the same LAN controller on different PCH's. Separate ADP board type from a TGP which will allow for specific fixes to be applied for ADP platforms. Suggested-by: Kai-Heng Feng Suggested-by: Dima Ruinskiy Signed-off-by: Sasha Neftin Tested-by: Nechama Kraus Signed-off-by: Tony Nguyen Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/net/ethernet/intel/e1000e/e1000.h | 4 ++- drivers/net/ethernet/intel/e1000e/ich8lan.c | 20 ++++++++++++++++ drivers/net/ethernet/intel/e1000e/netdev.c | 33 ++++++++++++++---------= ----- 3 files changed, 40 insertions(+), 17 deletions(-) --- a/drivers/net/ethernet/intel/e1000e/e1000.h +++ b/drivers/net/ethernet/intel/e1000e/e1000.h @@ -114,7 +114,8 @@ enum e1000_boards { board_pch_lpt, board_pch_spt, board_pch_cnp, - board_pch_tgp + board_pch_tgp, + board_pch_adp }; =20 struct e1000_ps_page { @@ -501,6 +502,7 @@ extern const struct e1000_info e1000_pch extern const struct e1000_info e1000_pch_spt_info; extern const struct e1000_info e1000_pch_cnp_info; extern const struct e1000_info e1000_pch_tgp_info; +extern const struct e1000_info e1000_pch_adp_info; extern const struct e1000_info e1000_es2_info; =20 void e1000e_ptp_init(struct e1000_adapter *adapter); --- a/drivers/net/ethernet/intel/e1000e/ich8lan.c +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c @@ -6021,3 +6021,23 @@ const struct e1000_info e1000_pch_tgp_in .phy_ops =3D &ich8_phy_ops, .nvm_ops =3D &spt_nvm_ops, }; + +const struct e1000_info e1000_pch_adp_info =3D { + .mac =3D e1000_pch_adp, + .flags =3D FLAG_IS_ICH + | FLAG_HAS_WOL + | FLAG_HAS_HW_TIMESTAMP + | FLAG_HAS_CTRLEXT_ON_LOAD + | FLAG_HAS_AMT + | FLAG_HAS_FLASH + | FLAG_HAS_JUMBO_FRAMES + | FLAG_APME_IN_WUC, + .flags2 =3D FLAG2_HAS_PHY_STATS + | FLAG2_HAS_EEE, + .pba =3D 26, + .max_hw_frame_size =3D 9022, + .get_variants =3D e1000_get_variants_ich8lan, + .mac_ops =3D &ich8_mac_ops, + .phy_ops =3D &ich8_phy_ops, + .nvm_ops =3D &spt_nvm_ops, +}; --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -52,6 +52,7 @@ static const struct e1000_info *e1000_in [board_pch_spt] =3D &e1000_pch_spt_info, [board_pch_cnp] =3D &e1000_pch_cnp_info, [board_pch_tgp] =3D &e1000_pch_tgp_info, + [board_pch_adp] =3D &e1000_pch_adp_info, }; =20 struct e1000_reg_info { @@ -7905,22 +7906,22 @@ static const struct pci_device_id e1000_ { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_TGP_I219_V14), board_pch_tgp }, { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_TGP_I219_LM15), board_pch_tgp }, { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_TGP_I219_V15), board_pch_tgp }, - { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_RPL_I219_LM23), board_pch_tgp }, - { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_RPL_I219_V23), board_pch_tgp }, - { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_ADP_I219_LM16), board_pch_tgp }, - { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_ADP_I219_V16), board_pch_tgp }, - { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_ADP_I219_LM17), board_pch_tgp }, - { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_ADP_I219_V17), board_pch_tgp }, - { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_RPL_I219_LM22), board_pch_tgp }, - { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_RPL_I219_V22), board_pch_tgp }, - { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_MTP_I219_LM18), board_pch_tgp }, - { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_MTP_I219_V18), board_pch_tgp }, - { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_MTP_I219_LM19), board_pch_tgp }, - { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_MTP_I219_V19), board_pch_tgp }, - { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_LNP_I219_LM20), board_pch_tgp }, - { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_LNP_I219_V20), board_pch_tgp }, - { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_LNP_I219_LM21), board_pch_tgp }, - { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_LNP_I219_V21), board_pch_tgp }, + { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_RPL_I219_LM23), board_pch_adp }, + { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_RPL_I219_V23), board_pch_adp }, + { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_ADP_I219_LM16), board_pch_adp }, + { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_ADP_I219_V16), board_pch_adp }, + { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_ADP_I219_LM17), board_pch_adp }, + { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_ADP_I219_V17), board_pch_adp }, + { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_RPL_I219_LM22), board_pch_adp }, + { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_RPL_I219_V22), board_pch_adp }, + { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_MTP_I219_LM18), board_pch_adp }, + { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_MTP_I219_V18), board_pch_adp }, + { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_MTP_I219_LM19), board_pch_adp }, + { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_MTP_I219_V19), board_pch_adp }, + { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_LNP_I219_LM20), board_pch_adp }, + { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_LNP_I219_V20), board_pch_adp }, + { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_LNP_I219_LM21), board_pch_adp }, + { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_LNP_I219_V21), board_pch_adp }, =20 { 0, 0, 0, 0, 0, 0, 0 } /* terminate list */ }; From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 67EA6C47082 for ; Mon, 7 Feb 2022 12:03:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391113AbiBGL6V (ORCPT ); Mon, 7 Feb 2022 06:58:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385425AbiBGLbu (ORCPT ); Mon, 7 Feb 2022 06:31:50 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C53EC03FEEE; Mon, 7 Feb 2022 03:30:20 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 00C14B811B2; Mon, 7 Feb 2022 11:30:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44884C004E1; Mon, 7 Feb 2022 11:30:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233417; bh=DFsm60ujwlq6xrmRluf3V0gZYV+0uKA4KIhEf3z/2VY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fmIeJk6CfoGr0ULvTUvQGKis4dB5JsC8aQeVFX8HRa6hOa5lfQRjKpZdEuEcgjjt1 zwZsZV66GMHZz+mjjNF88RVYMptQfPfpuC0aas/gUUQ54sdC0I713DlO5A2jexCTUS aAQ6m8cSTN/OOUlnVTZgcJkOACwVzNoyAXgkZouM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Riwen Lu , Eric Wong , =?UTF-8?q?Mateusz=20Jo=C5=84czyk?= , Alexandre Belloni Subject: [PATCH 5.15 091/110] rtc: cmos: Evaluate century appropriate Date: Mon, 7 Feb 2022 12:07:04 +0100 Message-Id: <20220207103805.483671403@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Riwen Lu commit ff164ae39b82ee483b24579c8e22a13a8ce5bd04 upstream. There's limiting the year to 2069. When setting the rtc year to 2070, reading it returns 1970. Evaluate century starting from 19 to count the correct year. $ sudo date -s 20700106 Mon 06 Jan 2070 12:00:00 AM CST $ sudo hwclock -w $ sudo hwclock -r 1970-01-06 12:00:49.604968+08:00 Fixes: 2a4daadd4d3e5071 ("rtc: cmos: ignore bogus century byte") Signed-off-by: Riwen Lu Acked-by: Eric Wong Reviewed-by: Mateusz Jo=C5=84czyk Signed-off-by: Alexandre Belloni Link: https://lore.kernel.org/r/20220106084609.1223688-1-luriwen@kylinos.cn Signed-off-by: Mateusz Jo=C5=84czyk # preparation for s= table Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/rtc/rtc-mc146818-lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/rtc/rtc-mc146818-lib.c +++ b/drivers/rtc/rtc-mc146818-lib.c @@ -104,7 +104,7 @@ again: time->tm_year +=3D real_year - 72; #endif =20 - if (century > 20) + if (century > 19) time->tm_year +=3D (century - 19) * 100; =20 /* From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8152BC4167E for ; Mon, 7 Feb 2022 12:03:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391120AbiBGL6X (ORCPT ); Mon, 7 Feb 2022 06:58:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385459AbiBGLby (ORCPT ); Mon, 7 Feb 2022 06:31:54 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 459F0C03FEF8; Mon, 7 Feb 2022 03:30:23 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 0D20AB80EC3; Mon, 7 Feb 2022 11:30:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 306ADC004E1; Mon, 7 Feb 2022 11:30:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233420; bh=/FgX0PQoDe/ke1Z7gTQfTglAyxymyTnBOSUKW6/1TSw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JxwqyzhmQRY/qPzR1H/LrXyJQknHAy/weqv6iNIBkY5wL5/sXAsy1+iwjzmUbs0kX o8uMvDAlwXe1JS5ChLcUo6XoXCraJDWENTKSRZNVLHzQlb0XHgtTD0GK/azBk7CcM+ nxwalfUAwXN7Glz+YimLSso9Pjs/MSGW9hOPsov0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicolas Saenz Julienne , Mark Rutland , Marc Zyngier , Alexandru Elisei , Catalin Marinas , Frederic Weisbecker , James Morse , Paolo Bonzini , "Paul E. McKenney" , Suzuki K Poulose , Will Deacon , Sasha Levin Subject: [PATCH 5.15 092/110] kvm/arm64: rework guest entry logic Date: Mon, 7 Feb 2022 12:07:05 +0100 Message-Id: <20220207103805.516218203@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Mark Rutland [ Upstream commit 8cfe148a7136bc60452a5c6b7ac2d9d15c36909b ] In kvm_arch_vcpu_ioctl_run() we enter an RCU extended quiescent state (EQS) by calling guest_enter_irqoff(), and unmasked IRQs prior to exiting the EQS by calling guest_exit(). As the IRQ entry code will not wake RCU in this case, we may run the core IRQ code and IRQ handler without RCU watching, leading to various potential problems. Additionally, we do not inform lockdep or tracing that interrupts will be enabled during guest execution, which caan lead to misleading traces and warnings that interrupts have been enabled for overly-long periods. This patch fixes these issues by using the new timing and context entry/exit helpers to ensure that interrupts are handled during guest vtime but with RCU watching, with a sequence: guest_timing_enter_irqoff(); guest_state_enter_irqoff(); < run the vcpu > guest_state_exit_irqoff(); < take any pending IRQs > guest_timing_exit_irqoff(); Since instrumentation may make use of RCU, we must also ensure that no instrumented code is run during the EQS. I've split out the critical section into a new kvm_arm_enter_exit_vcpu() helper which is marked noinstr. Fixes: 1b3d546daf85ed2b ("arm/arm64: KVM: Properly account for guest CPU ti= me") Reported-by: Nicolas Saenz Julienne Signed-off-by: Mark Rutland Reviewed-by: Marc Zyngier Reviewed-by: Nicolas Saenz Julienne Cc: Alexandru Elisei Cc: Catalin Marinas Cc: Frederic Weisbecker Cc: James Morse Cc: Paolo Bonzini Cc: Paul E. McKenney Cc: Suzuki K Poulose Cc: Will Deacon Message-Id: <20220201132926.3301912-3-mark.rutland@arm.com> Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- arch/arm64/kvm/arm.c | 51 ++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 9b328bb05596a..f9c7e4e61b296 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -755,6 +755,24 @@ static bool kvm_vcpu_exit_request(struct kvm_vcpu *vcp= u, int *ret) xfer_to_guest_mode_work_pending(); } =20 +/* + * Actually run the vCPU, entering an RCU extended quiescent state (EQS) w= hile + * the vCPU is running. + * + * This must be noinstr as instrumentation may make use of RCU, and this i= s not + * safe during the EQS. + */ +static int noinstr kvm_arm_vcpu_enter_exit(struct kvm_vcpu *vcpu) +{ + int ret; + + guest_state_enter_irqoff(); + ret =3D kvm_call_hyp_ret(__kvm_vcpu_run, vcpu); + guest_state_exit_irqoff(); + + return ret; +} + /** * kvm_arch_vcpu_ioctl_run - the main VCPU run function to execute guest c= ode * @vcpu: The VCPU pointer @@ -845,9 +863,9 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu) * Enter the guest */ trace_kvm_entry(*vcpu_pc(vcpu)); - guest_enter_irqoff(); + guest_timing_enter_irqoff(); =20 - ret =3D kvm_call_hyp_ret(__kvm_vcpu_run, vcpu); + ret =3D kvm_arm_vcpu_enter_exit(vcpu); =20 vcpu->mode =3D OUTSIDE_GUEST_MODE; vcpu->stat.exits++; @@ -882,26 +900,23 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu) kvm_arch_vcpu_ctxsync_fp(vcpu); =20 /* - * We may have taken a host interrupt in HYP mode (ie - * while executing the guest). This interrupt is still - * pending, as we haven't serviced it yet! + * We must ensure that any pending interrupts are taken before + * we exit guest timing so that timer ticks are accounted as + * guest time. Transiently unmask interrupts so that any + * pending interrupts are taken. * - * We're now back in SVC mode, with interrupts - * disabled. Enabling the interrupts now will have - * the effect of taking the interrupt again, in SVC - * mode this time. + * Per ARM DDI 0487G.b section D1.13.4, an ISB (or other + * context synchronization event) is necessary to ensure that + * pending interrupts are taken. */ local_irq_enable(); + isb(); + local_irq_disable(); + + guest_timing_exit_irqoff(); + + local_irq_enable(); =20 - /* - * We do local_irq_enable() before calling guest_exit() so - * that if a timer interrupt hits while running the guest we - * account that tick as being spent in the guest. We enable - * preemption after calling guest_exit() so that if we get - * preempted we make sure ticks after that is not counted as - * guest time. - */ - guest_exit(); trace_kvm_exit(ret, kvm_vcpu_trap_get_class(vcpu), *vcpu_pc(vcpu)); =20 /* Exit types that need handling before we can be preempted */ --=20 2.34.1 From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E163AC4321E for ; Mon, 7 Feb 2022 12:03:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343921AbiBGLzx (ORCPT ); Mon, 7 Feb 2022 06:55:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385022AbiBGLa5 (ORCPT ); Mon, 7 Feb 2022 06:30:57 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B84F8C03BFFF; Mon, 7 Feb 2022 03:29:01 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5297D60B5C; Mon, 7 Feb 2022 11:29:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F849C004E1; Mon, 7 Feb 2022 11:28:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233340; bh=ztI+U6AJfXgJOfHa3JGdlrmkcr9HcxcswIQ5WY5SUUg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2jpesOpgkmwLZgETVuLO6y5dub6AaoumPwmN168Pl7HtTgKR5fPusfve/Wi3wdOMw C1KSk79jPEKbyS4DEEk0L2GFTY5FjxIcbt0Y2DlnlqnM1GFxSliXUC5CStkcI/5DMy e92sR7WQ/3p04lQy84P82+mX2Ees12p9CmBojddw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dmitry Vyukov , Marco Elver , "Peter Zijlstra (Intel)" , Sasha Levin Subject: [PATCH 5.15 093/110] perf: Copy perf_event_attr::sig_data on modification Date: Mon, 7 Feb 2022 12:07:06 +0100 Message-Id: <20220207103805.549583830@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Marco Elver [ Upstream commit 3c25fc97f5590060464cabfa25710970ecddbc96 ] The intent has always been that perf_event_attr::sig_data should also be modifiable along with PERF_EVENT_IOC_MODIFY_ATTRIBUTES, because it is observable by user space if SIGTRAP on events is requested. Currently only PERF_TYPE_BREAKPOINT is modifiable, and explicitly copies relevant breakpoint-related attributes in hw_breakpoint_copy_attr(). This misses copying perf_event_attr::sig_data. Since sig_data is not specific to PERF_TYPE_BREAKPOINT, introduce a helper to copy generic event-type-independent attributes on modification. Fixes: 97ba62b27867 ("perf: Add support for SIGTRAP on perf events") Reported-by: Dmitry Vyukov Signed-off-by: Marco Elver Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Dmitry Vyukov Link: https://lore.kernel.org/r/20220131103407.1971678-1-elver@google.com Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- kernel/events/core.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/kernel/events/core.c b/kernel/events/core.c index c7581e3fb8ab1..69c70767b5dff 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -3234,6 +3234,15 @@ static int perf_event_modify_breakpoint(struct perf_= event *bp, return err; } =20 +/* + * Copy event-type-independent attributes that may be modified. + */ +static void perf_event_modify_copy_attr(struct perf_event_attr *to, + const struct perf_event_attr *from) +{ + to->sig_data =3D from->sig_data; +} + static int perf_event_modify_attr(struct perf_event *event, struct perf_event_attr *attr) { @@ -3256,10 +3265,17 @@ static int perf_event_modify_attr(struct perf_event= *event, WARN_ON_ONCE(event->ctx->parent_ctx); =20 mutex_lock(&event->child_mutex); + /* + * Event-type-independent attributes must be copied before event-type + * modification, which will validate that final attributes match the + * source attributes after all relevant attributes have been copied. + */ + perf_event_modify_copy_attr(&event->attr, attr); err =3D func(event, attr); if (err) goto out; list_for_each_entry(child, &event->child_list, child_list) { + perf_event_modify_copy_attr(&child->attr, attr); err =3D func(child, attr); if (err) goto out; --=20 2.34.1 From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0CD5AC43219 for ; Mon, 7 Feb 2022 12:03:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380160AbiBGL4B (ORCPT ); Mon, 7 Feb 2022 06:56:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385052AbiBGLbC (ORCPT ); Mon, 7 Feb 2022 06:31:02 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E73C2C03649B; Mon, 7 Feb 2022 03:29:06 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 403A1B80EBD; Mon, 7 Feb 2022 11:29:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3BDA7C004E1; Mon, 7 Feb 2022 11:29:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233344; bh=fPYdKdWpnGHTHXZCbhnIuCJs8ENy0yQAD1fLx+dFIIs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ciMsHFjBm6mBx0qLwnUcEiytLfs3SN2Hf5IEVcUF4rSQusurkwpk9251zTqQtKcQg XDTYbyJxlml9tMAtAgnGyCG0EEGAsiv1f1jW6A23TC1Sn8NLUrD5/qttbJQ5pklRAp LoPUOpeHf1oDIHiikqEI33A297wSfSXv2v/tju8g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andi Kleen , Ian Rogers , Alexander Shishkin , Alexandre Torgue , Asaf Yaffe , Caleb Biggers , Ingo Molnar , James Clark , Jiri Olsa , John Garry , Kan Liang , Kshipra Bopardikar , Mark Rutland , Maxime Coquelin , Namhyung Kim , Perry Taylor , Peter Zijlstra , Stephane Eranian , Vineet Singh , Zhengjun Xing , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.15 094/110] perf stat: Fix display of grouped aliased events Date: Mon, 7 Feb 2022 12:07:07 +0100 Message-Id: <20220207103805.580324499@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Ian Rogers [ Upstream commit b2b1aa73ade982c175ac926a1fd34e76ad628b94 ] An event may have a number of uncore aliases that when added to the evlist are consecutive. If there are multiple uncore events in a group then parse_events__set_leader_for_uncore_aliase will reorder the evlist so that events on the same PMU are adjacent. The collect_all_aliases function assumes that aliases are in blocks so that only the first counter is printed and all others are marked merged. The reordering for groups breaks the assumption and so all counts are printed. This change removes the assumption from collect_all_aliases that the events are in blocks and instead processes the entire evlist. Before: ``` $ perf stat -e '{UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE,UNC_CHA_TOR_INS= ERTS.IA_MISS_DRD_REMOTE},duration_time' -a -A -- sleep 1 Performance counter stats for 'system wide': CPU0 256,866 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 494,413 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 967 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,738 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 285,161 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 429,920 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 955 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,443 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 310,753 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 416,657 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,231 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,573 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 416,067 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 405,966 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,481 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,447 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 312,911 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 408,154 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,086 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,380 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 333,994 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 370,349 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,287 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,335 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 188,107 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 302,423 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 701 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,070 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 307,221 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 383,642 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,036 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,158 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 318,479 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 821,545 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,028 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 2,550 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 227,618 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 372,272 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 903 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,456 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 376,783 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 419,827 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,406 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,453 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 286,583 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 429,956 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 999 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,436 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 313,867 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 370,159 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,114 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,291 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 342,083 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 409,111 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,399 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,684 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 365,828 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 376,037 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,378 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,411 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 382,456 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 621,743 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,232 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,955 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 342,316 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 385,067 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,176 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,268 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 373,588 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 386,163 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,394 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,464 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 381,206 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 546,891 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,266 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,712 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 221,176 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 392,069 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 831 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,456 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 355,401 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 705,595 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,235 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 2,216 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 371,436 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 428,103 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,306 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,442 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 384,352 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 504,200 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,468 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,860 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 228,856 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 287,976 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 832 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,060 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 215,121 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 334,162 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 681 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,026 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 296,179 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 436,083 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,084 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,525 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 262,296 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 416,573 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 986 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,533 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 285,852 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 359,842 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,073 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,326 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 303,379 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 367,222 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,008 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,156 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 273,487 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 425,449 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 932 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,367 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 297,596 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 414,793 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,140 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,601 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 342,365 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 360,422 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,291 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,342 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 327,196 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 580,858 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,122 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 2,014 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 296,564 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 452,817 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,087 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,694 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 375,002 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 389,393 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,478 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 1,540 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 365,213 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 594,685 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 1,401 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 2,222 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 1,000,749,060 ns duration_time 1.000749060 seconds time elapsed ``` After: ``` Performance counter stats for 'system wide': CPU0 20,547,434 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU36 45,202,862 UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMO= TE CPU0 82,001 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU36 159,688 UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE CPU0 1,000,464,828 ns duration_time 1.000464828 seconds time elapsed ``` Fixes: 3cdc5c2cb924acb4 ("perf parse-events: Handle uncore event aliases in= small groups properly") Reviewed-by: Andi Kleen Signed-off-by: Ian Rogers Cc: Alexander Shishkin Cc: Alexandre Torgue Cc: Asaf Yaffe Cc: Caleb Biggers Cc: Ingo Molnar Cc: James Clark Cc: Jiri Olsa Cc: John Garry Cc: Kan Liang Cc: Kshipra Bopardikar Cc: Mark Rutland Cc: Maxime Coquelin Cc: Namhyung Kim Cc: Perry Taylor Cc: Peter Zijlstra Cc: Stephane Eranian Cc: Vineet Singh Cc: Zhengjun Xing Link: https://lore.kernel.org/r/20220205010941.1065469-1-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing --- tools/perf/util/stat-display.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index 588601000f3f9..db00ca6a67deb 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -584,15 +584,16 @@ static void collect_all_aliases(struct perf_stat_conf= ig *config, struct evsel *c =20 alias =3D list_prepare_entry(counter, &(evlist->core.entries), core.node); list_for_each_entry_continue (alias, &evlist->core.entries, core.node) { - if (strcmp(evsel__name(alias), evsel__name(counter)) || - alias->scale !=3D counter->scale || - alias->cgrp !=3D counter->cgrp || - strcmp(alias->unit, counter->unit) || - evsel__is_clock(alias) !=3D evsel__is_clock(counter) || - !strcmp(alias->pmu_name, counter->pmu_name)) - break; - alias->merged_stat =3D true; - cb(config, alias, data, false); + /* Merge events with the same name, etc. but on different PMUs. */ + if (!strcmp(evsel__name(alias), evsel__name(counter)) && + alias->scale =3D=3D counter->scale && + alias->cgrp =3D=3D counter->cgrp && + !strcmp(alias->unit, counter->unit) && + evsel__is_clock(alias) =3D=3D evsel__is_clock(counter) && + strcmp(alias->pmu_name, counter->pmu_name)) { + alias->merged_stat =3D true; + cb(config, alias, data, false); + } } } =20 --=20 2.34.1 From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1580C4167B for ; Mon, 7 Feb 2022 12:03:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355836AbiBGLzz (ORCPT ); Mon, 7 Feb 2022 06:55:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385061AbiBGLbD (ORCPT ); Mon, 7 Feb 2022 06:31:03 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9ED8C0354AB; Mon, 7 Feb 2022 03:29:09 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 686D1B811A6; Mon, 7 Feb 2022 11:29:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86BADC004E1; Mon, 7 Feb 2022 11:29:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233347; bh=f1ORtPDAHpcxACauP0gFG5EboxWBRvFWuxzNa3VLo2w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G4riBLUO5ZxbwBMIaeO+6onlM2ZWK1ZtMZSE+yYOnwuIW63PStueCngwRIhM8qikb q5+tCI/iQtAR/1IlPgaalQFNrByvdukSrZi6HMOBYemCWfdvE63IGVMoEFwU8hvUMm IqtuwJU3mUCAcOD5i7HewESv5HOL9KWrYga96Jz4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tristan Hume , "Peter Zijlstra (Intel)" , Adrian Hunter , stable@kernel.org Subject: [PATCH 5.15 095/110] perf/x86/intel/pt: Fix crash with stop filters in single-range mode Date: Mon, 7 Feb 2022 12:07:08 +0100 Message-Id: <20220207103805.612059303@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Tristan Hume commit 1d9093457b243061a9bba23543c38726e864a643 upstream. Add a check for !buf->single before calling pt_buffer_region_size in a place where a missing check can cause a kernel crash. Fixes a bug introduced by commit 670638477aed ("perf/x86/intel/pt: Opportunistically use single range output mode"), which added a support for PT single-range output mode. Since that commit if a PT stop filter range is hit while tracing, the kernel will crash because of a null pointer dereference in pt_handle_status due to calling pt_buffer_region_size without a ToPA configured. The commit which introduced single-range mode guarded almost all uses of the ToPA buffer variables with checks of the buf->single variable, but missed the case where tracing was stopped by the PT hardware, which happens when execution hits a configured stop filter. Tested that hitting a stop filter while PT recording successfully records a trace with this patch but crashes without this patch. Fixes: 670638477aed ("perf/x86/intel/pt: Opportunistically use single range= output mode") Signed-off-by: Tristan Hume Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Adrian Hunter Cc: stable@kernel.org Link: https://lkml.kernel.org/r/20220127220806.73664-1-tristan@thume.ca Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- arch/x86/events/intel/pt.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/arch/x86/events/intel/pt.c +++ b/arch/x86/events/intel/pt.c @@ -897,8 +897,9 @@ static void pt_handle_status(struct pt * * means we are already losing data; need to let the decoder * know. */ - if (!intel_pt_validate_hw_cap(PT_CAP_topa_multiple_entries) || - buf->output_off =3D=3D pt_buffer_region_size(buf)) { + if (!buf->single && + (!intel_pt_validate_hw_cap(PT_CAP_topa_multiple_entries) || + buf->output_off =3D=3D pt_buffer_region_size(buf))) { perf_aux_output_flag(&pt->handle, PERF_AUX_FLAG_TRUNCATED); advance++; From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 565C9C41535 for ; Mon, 7 Feb 2022 12:03:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380451AbiBGL4b (ORCPT ); Mon, 7 Feb 2022 06:56:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385075AbiBGLbE (ORCPT ); Mon, 7 Feb 2022 06:31:04 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93C94C03544C; Mon, 7 Feb 2022 03:29:11 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0A1E260AB0; Mon, 7 Feb 2022 11:29:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2330C004E1; Mon, 7 Feb 2022 11:29:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233350; bh=dlSCWan0FfA5znaLczSL60Lqi/QBNHiAtI0rESPoMpM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kEUz8gV7yqHCtFKUzno+n+JILWViIKEHt95jTv2kOlKHVm+TDnk8HuObPGi7k1APK O43Hp0Fa3Tp5s81cy+/BV3U2oVfCnEQ02TcohMk5g0Qjk1NjrQ+Y56ZTyyv1ctpTn7 QsKt80dKRQk81qJ4UPll8qd5o9p5yLwMBuFOfKvY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kyle Huey , Andrew Cooper , "Peter Zijlstra (Intel)" , stable@kernel.org Subject: [PATCH 5.15 096/110] x86/perf: Default set FREEZE_ON_SMI for all Date: Mon, 7 Feb 2022 12:07:09 +0100 Message-Id: <20220207103805.641038111@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Peter Zijlstra commit a01994f5e5c79d3a35e5e8cf4252c7f2147323c3 upstream. Kyle reported that rr[0] has started to malfunction on Comet Lake and later CPUs due to EFI starting to make use of CPL3 [1] and the PMU event filtering not distinguishing between regular CPL3 and SMM CPL3. Since this is a privilege violation, default disable SMM visibility where possible. Administrators wanting to observe SMM cycles can easily change this using the sysfs attribute while regular users don't have access to this file. [0] https://rr-project.org/ [1] See the Intel white paper "Trustworthy SMM on the Intel vPro Platform" at https://bugzilla.kernel.org/attachment.cgi?id=3D300300, particularly the end of page 5. Reported-by: Kyle Huey Suggested-by: Andrew Cooper Signed-off-by: Peter Zijlstra (Intel) Cc: stable@kernel.org Link: https://lkml.kernel.org/r/YfKChjX61OW4CkYm@hirez.programming.kicks-as= s.net Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- arch/x86/events/intel/core.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -4654,6 +4654,19 @@ static __initconst const struct x86_pmu .lbr_read =3D intel_pmu_lbr_read_64, .lbr_save =3D intel_pmu_lbr_save, .lbr_restore =3D intel_pmu_lbr_restore, + + /* + * SMM has access to all 4 rings and while traditionally SMM code only + * ran in CPL0, 2021-era firmware is starting to make use of CPL3 in SMM. + * + * Since the EVENTSEL.{USR,OS} CPL filtering makes no distinction + * between SMM or not, this results in what should be pure userspace + * counters including SMM data. + * + * This is a clear privilege issue, therefore globally disable + * counting SMM by default. + */ + .attr_freeze_on_smi =3D 1, }; =20 static __init void intel_clovertown_quirk(void) From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29320C4167E for ; Mon, 7 Feb 2022 12:03:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380226AbiBGL4L (ORCPT ); Mon, 7 Feb 2022 06:56:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385093AbiBGLbG (ORCPT ); Mon, 7 Feb 2022 06:31:06 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 115B5C035416; Mon, 7 Feb 2022 03:29:15 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id AE08AB80EC3; Mon, 7 Feb 2022 11:29:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE59FC004E1; Mon, 7 Feb 2022 11:29:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233353; bh=s67VpVP7MXMILns6SrqsrSdBqMFhRM8QKqe4wHf8zNk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LdPrV0ZlJD6K99cybysk7Sz5t9V8ruUXz4DgCm0KqYa4QlE9OSF+t1ZuE2JQonJs5 pkzjH9vI8n7nEaz4TftS4uEvbwfZ3kp6Fulcbsd4A6qPXpdgjJ0hKpDPE9Fh2RByvS ruSeqthObn/k6RWu/vbAmKTfUlDsiIGxu6CWeLAc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sergey Shtylyov , Borislav Petkov , Dinh Nguyen Subject: [PATCH 5.15 097/110] EDAC/altera: Fix deferred probing Date: Mon, 7 Feb 2022 12:07:10 +0100 Message-Id: <20220207103805.674588034@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Sergey Shtylyov commit 279eb8575fdaa92c314a54c0d583c65e26229107 upstream. The driver overrides the error codes returned by platform_get_irq() to -ENODEV for some strange reason, so if it returns -EPROBE_DEFER, the driver will fail the probe permanently instead of the deferred probing. Switch to propagating the proper error codes to platform driver code upwards. [ bp: Massage commit message. ] Fixes: 71bcada88b0f ("edac: altera: Add Altera SDRAM EDAC support") Signed-off-by: Sergey Shtylyov Signed-off-by: Borislav Petkov Acked-by: Dinh Nguyen Cc: Link: https://lore.kernel.org/r/20220124185503.6720-2-s.shtylyov@omp.ru Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/edac/altera_edac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/edac/altera_edac.c +++ b/drivers/edac/altera_edac.c @@ -350,7 +350,7 @@ static int altr_sdram_probe(struct platf if (irq < 0) { edac_printk(KERN_ERR, EDAC_MC, "No irq %d in DT\n", irq); - return -ENODEV; + return irq; } =20 /* Arria10 has a 2nd IRQ */ From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F595C4167D for ; Mon, 7 Feb 2022 12:03:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380349AbiBGL4T (ORCPT ); Mon, 7 Feb 2022 06:56:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385092AbiBGLbG (ORCPT ); Mon, 7 Feb 2022 06:31:06 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7241C033241; Mon, 7 Feb 2022 03:29:17 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6437F6077B; Mon, 7 Feb 2022 11:29:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B3EEC004E1; Mon, 7 Feb 2022 11:29:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233356; bh=3+OdnXHnwYipTw8qEI909/tZBBwnRXIhertLR4aPfWo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aq23/UZvX6IbQeIztvpZyWcN6Xs/+naP+96Yi6YBtWfKS7rVajvzjRhH+vVE/HSmx 9HR7z6q8Udx/0pp9qIkFkAgIxms/DnqXzJavOEESEX6V1LWlFpmEJLTf94Tf15Jt5c 0PcUtuY61e5iKF/0s/I1QWwJjtk+CVSRf0L/+9jU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sergey Shtylyov , Borislav Petkov Subject: [PATCH 5.15 098/110] EDAC/xgene: Fix deferred probing Date: Mon, 7 Feb 2022 12:07:11 +0100 Message-Id: <20220207103805.711854566@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Sergey Shtylyov commit dfd0dfb9a7cc04acf93435b440dd34c2ca7b4424 upstream. The driver overrides error codes returned by platform_get_irq_optional() to -EINVAL for some strange reason, so if it returns -EPROBE_DEFER, the driver will fail the probe permanently instead of the deferred probing. Switch to propagating the proper error codes to platform driver code upwards. [ bp: Massage commit message. ] Fixes: 0d4429301c4a ("EDAC: Add APM X-Gene SoC EDAC driver") Signed-off-by: Sergey Shtylyov Signed-off-by: Borislav Petkov Cc: Link: https://lore.kernel.org/r/20220124185503.6720-3-s.shtylyov@omp.ru Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/edac/xgene_edac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/edac/xgene_edac.c +++ b/drivers/edac/xgene_edac.c @@ -1919,7 +1919,7 @@ static int xgene_edac_probe(struct platf irq =3D platform_get_irq_optional(pdev, i); if (irq < 0) { dev_err(&pdev->dev, "No IRQ resource\n"); - rc =3D -EINVAL; + rc =3D irq; goto out_err; } rc =3D devm_request_irq(&pdev->dev, irq, From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E3CEC35271 for ; Mon, 7 Feb 2022 12:03:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381995AbiBGL4l (ORCPT ); Mon, 7 Feb 2022 06:56:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385107AbiBGLbK (ORCPT ); Mon, 7 Feb 2022 06:31:10 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 141B4C033247; Mon, 7 Feb 2022 03:29:20 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5D1DE60A67; Mon, 7 Feb 2022 11:29:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4254CC004E1; Mon, 7 Feb 2022 11:29:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233359; bh=96amUmCpTDzItVXSdoi5GA0nI3qQJEkMsW3DEz5lelk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FdGi85eKiTBKSaV2gXu0xo0ckHPybXaPZue3DFINuX2Xcv4sXSEdZuxflK6DuE0AL MbV0y+ifI7Un63W6XckTGF6tJcmDMI0U3xHbBRKS3uiGqH0t8lnc9uudtdPE7v8rM/ d3O+ZP2YfbhO93svBSXkrB0MhaNvS08b8uCkVhA0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xin Yin , Theodore Tso , stable@kernel.org Subject: [PATCH 5.15 099/110] ext4: prevent used blocks from being allocated during fast commit replay Date: Mon, 7 Feb 2022 12:07:12 +0100 Message-Id: <20220207103805.744397195@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Xin Yin commit 599ea31d13617c5484c40cdf50d88301dc351cfc upstream. During fast commit replay procedure, we clear inode blocks bitmap in ext4_ext_clear_bb(), this may cause ext4_mb_new_blocks_simple() allocate blocks still in use. Make ext4_fc_record_regions() also record physical disk regions used by inodes during replay procedure. Then ext4_mb_new_blocks_simple() can excludes these blocks in use. Signed-off-by: Xin Yin Link: https://lore.kernel.org/r/20220110035141.1980-2-yinxin.x@bytedance.com Signed-off-by: Theodore Ts'o Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- fs/ext4/ext4.h | 3 +++ fs/ext4/extents.c | 4 ++++ fs/ext4/fast_commit.c | 20 +++++++++++++++----- 3 files changed, 22 insertions(+), 5 deletions(-) --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -2935,6 +2935,9 @@ void ext4_fc_replay_cleanup(struct super int ext4_fc_commit(journal_t *journal, tid_t commit_tid); int __init ext4_fc_init_dentry_cache(void); void ext4_fc_destroy_dentry_cache(void); +int ext4_fc_record_regions(struct super_block *sb, int ino, + ext4_lblk_t lblk, ext4_fsblk_t pblk, + int len, int replay); =20 /* mballoc.c */ extern const struct seq_operations ext4_mb_seq_groups_ops; --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -6096,11 +6096,15 @@ int ext4_ext_clear_bb(struct inode *inod =20 ext4_mb_mark_bb(inode->i_sb, path[j].p_block, 1, 0); + ext4_fc_record_regions(inode->i_sb, inode->i_ino, + 0, path[j].p_block, 1, 1); } ext4_ext_drop_refs(path); kfree(path); } ext4_mb_mark_bb(inode->i_sb, map.m_pblk, map.m_len, 0); + ext4_fc_record_regions(inode->i_sb, inode->i_ino, + map.m_lblk, map.m_pblk, map.m_len, 1); } cur =3D cur + map.m_len; } --- a/fs/ext4/fast_commit.c +++ b/fs/ext4/fast_commit.c @@ -1603,16 +1603,23 @@ out: } =20 /* - * Record physical disk regions which are in use as per fast commit area. = Our - * simple replay phase allocator excludes these regions from allocation. + * Record physical disk regions which are in use as per fast commit area, + * and used by inodes during replay phase. Our simple replay phase + * allocator excludes these regions from allocation. */ -static int ext4_fc_record_regions(struct super_block *sb, int ino, - ext4_lblk_t lblk, ext4_fsblk_t pblk, int len) +int ext4_fc_record_regions(struct super_block *sb, int ino, + ext4_lblk_t lblk, ext4_fsblk_t pblk, int len, int replay) { struct ext4_fc_replay_state *state; struct ext4_fc_alloc_region *region; =20 state =3D &EXT4_SB(sb)->s_fc_replay_state; + /* + * during replay phase, the fc_regions_valid may not same as + * fc_regions_used, update it when do new additions. + */ + if (replay && state->fc_regions_used !=3D state->fc_regions_valid) + state->fc_regions_used =3D state->fc_regions_valid; if (state->fc_regions_used =3D=3D state->fc_regions_size) { state->fc_regions_size +=3D EXT4_FC_REPLAY_REALLOC_INCREMENT; @@ -1630,6 +1637,9 @@ static int ext4_fc_record_regions(struct region->pblk =3D pblk; region->len =3D len; =20 + if (replay) + state->fc_regions_valid++; + return 0; } =20 @@ -1973,7 +1983,7 @@ static int ext4_fc_replay_scan(journal_t ret =3D ext4_fc_record_regions(sb, le32_to_cpu(ext.fc_ino), le32_to_cpu(ex->ee_block), ext4_ext_pblock(ex), - ext4_ext_get_actual_len(ex)); + ext4_ext_get_actual_len(ex), 0); if (ret < 0) break; ret =3D JBD2_FC_REPLAY_CONTINUE; From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A78F0C46467 for ; Mon, 7 Feb 2022 12:03:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382015AbiBGL4p (ORCPT ); Mon, 7 Feb 2022 06:56:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385124AbiBGLbN (ORCPT ); Mon, 7 Feb 2022 06:31:13 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DE53C033258; Mon, 7 Feb 2022 03:29:23 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B2C8B60A69; Mon, 7 Feb 2022 11:29:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78F75C004E1; Mon, 7 Feb 2022 11:29:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233363; bh=R4imgKnV8m32j4qt81S3AnOiSUStzzwNsdj4QWnDjis=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w8GLwpo2RxJ7/bQyUhPOqOoWcoo2Y/jOwQY7GDCuhTGhvH6ebw29q4N+81HgD9aFs rOXYsiqy+GP5CZd0UkagMXa2mgI3l1ELvwVzJ2nfWBEGBsBE1Fw+WNaFcOD9vsCpbv AyERg/JsYoFIe28q22Wx9LbQP0UB/t1fDASC/BTI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xin Yin , Harshad Shirwadkar , Theodore Tso , stable@kernel.org Subject: [PATCH 5.15 100/110] ext4: modify the logic of ext4_mb_new_blocks_simple Date: Mon, 7 Feb 2022 12:07:13 +0100 Message-Id: <20220207103805.775103847@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Xin Yin commit 31a074a0c62dc0d2bfb9b543142db4fe27f9e5eb upstream. For now in ext4_mb_new_blocks_simple, if we found a block which should be excluded then will switch to next group, this may probably cause 'group' run out of range. Change to check next block in the same group when get a block should be excluded. Also change the search range to EXT4_CLUSTERS_PER_GROUP and add error checking. Signed-off-by: Xin Yin Reviewed-by: Harshad Shirwadkar Link: https://lore.kernel.org/r/20220110035141.1980-3-yinxin.x@bytedance.com Signed-off-by: Theodore Ts'o Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- fs/ext4/mballoc.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -5753,7 +5753,8 @@ static ext4_fsblk_t ext4_mb_new_blocks_s struct super_block *sb =3D ar->inode->i_sb; ext4_group_t group; ext4_grpblk_t blkoff; - int i =3D sb->s_blocksize; + ext4_grpblk_t max =3D EXT4_CLUSTERS_PER_GROUP(sb); + ext4_grpblk_t i =3D 0; ext4_fsblk_t goal, block; struct ext4_super_block *es =3D EXT4_SB(sb)->s_es; =20 @@ -5775,19 +5776,26 @@ static ext4_fsblk_t ext4_mb_new_blocks_s ext4_get_group_no_and_offset(sb, max(ext4_group_first_block_no(sb, group), goal), NULL, &blkoff); - i =3D mb_find_next_zero_bit(bitmap_bh->b_data, sb->s_blocksize, + while (1) { + i =3D mb_find_next_zero_bit(bitmap_bh->b_data, max, blkoff); + if (i >=3D max) + break; + if (ext4_fc_replay_check_excluded(sb, + ext4_group_first_block_no(sb, group) + i)) { + blkoff =3D i + 1; + } else + break; + } brelse(bitmap_bh); - if (i >=3D sb->s_blocksize) - continue; - if (ext4_fc_replay_check_excluded(sb, - ext4_group_first_block_no(sb, group) + i)) - continue; - break; + if (i < max) + break; } =20 - if (group >=3D ext4_get_groups_count(sb) && i >=3D sb->s_blocksize) + if (group >=3D ext4_get_groups_count(sb) || i >=3D max) { + *errp =3D -ENOSPC; return 0; + } =20 block =3D ext4_group_first_block_no(sb, group) + i; ext4_mb_mark_bb(sb, block, 1, 1); From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B932DC35272 for ; Mon, 7 Feb 2022 12:03:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382071AbiBGL4v (ORCPT ); Mon, 7 Feb 2022 06:56:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385168AbiBGLbR (ORCPT ); Mon, 7 Feb 2022 06:31:17 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F27AC0302D0; Mon, 7 Feb 2022 03:29:28 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B4DEFB80EBD; Mon, 7 Feb 2022 11:29:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9CF1C004E1; Mon, 7 Feb 2022 11:29:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233366; bh=CfF5WdTDKr8HJN9/b0LVxkEDlz1x+4lkrQSzwtW1+XQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Pe/fKzpH4R9gRFrlIt5iCWLSc8lYa6xlmR8KGwcEaGC8LrbkQLJpx1/tZTsrJTIBC e0ckHU73IAG6RccQi5cJZQ3Ygrway+mskupOw24pELlrARclchW/lRAB/dzgrbNTSm 1VIPIwbf94uxwQ06Tx641nQmh3zLbRVr8NlrlVTw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Whitney , Ritesh Harjani , Jan Kara , Theodore Tso , stable@kernel.org Subject: [PATCH 5.15 101/110] ext4: fix error handling in ext4_restore_inline_data() Date: Mon, 7 Feb 2022 12:07:14 +0100 Message-Id: <20220207103805.814201997@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Ritesh Harjani commit 897026aaa73eb2517dfea8d147f20ddb0b813044 upstream. While running "./check -I 200 generic/475" it sometimes gives below kernel BUG(). Ideally we should not call ext4_write_inline_data() if ext4_create_inline_data() has failed. [73131.453234] kernel BUG at fs/ext4/inline.c:223! 212 static void ext4_write_inline_data(struct inode *inode, struct ext4_il= oc *iloc, 213 void *buffer, loff_t pos, unsigned = int len) 214 { <...> 223 BUG_ON(!EXT4_I(inode)->i_inline_off); 224 BUG_ON(pos + len > EXT4_I(inode)->i_inline_size); This patch handles the error and prints out a emergency msg saying potential data loss for the given inode (since we couldn't restore the original inline_data due to some previous error). [ 9571.070313] EXT4-fs (dm-0): error restoring inline_data for inode -- pot= ential data loss! (inode 1703982, error -30) Reported-by: Eric Whitney Signed-off-by: Ritesh Harjani Reviewed-by: Jan Kara Link: https://lore.kernel.org/r/9f4cd7dfd54fa58ff27270881823d94ddf78dd07.16= 42416995.git.riteshh@linux.ibm.com Signed-off-by: Theodore Ts'o Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- fs/ext4/inline.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) --- a/fs/ext4/inline.c +++ b/fs/ext4/inline.c @@ -1133,7 +1133,15 @@ static void ext4_restore_inline_data(han struct ext4_iloc *iloc, void *buf, int inline_size) { - ext4_create_inline_data(handle, inode, inline_size); + int ret; + + ret =3D ext4_create_inline_data(handle, inode, inline_size); + if (ret) { + ext4_msg(inode->i_sb, KERN_EMERG, + "error restoring inline_data for inode -- potential data loss! (inode %= lu, error %d)", + inode->i_ino, ret); + return; + } ext4_write_inline_data(inode, iloc, buf, 0, inline_size); ext4_set_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA); } From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5895AC3527A for ; Mon, 7 Feb 2022 12:03:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1390751AbiBGL5r (ORCPT ); Mon, 7 Feb 2022 06:57:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385175AbiBGLbR (ORCPT ); Mon, 7 Feb 2022 06:31:17 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C331BC03E97A; Mon, 7 Feb 2022 03:29:30 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5DC3D6077B; Mon, 7 Feb 2022 11:29:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 24076C004E1; Mon, 7 Feb 2022 11:29:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233369; bh=6vj50r1AvP3r9OAXzpvy1MjM6N02vm1PiN84suqqwYY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oH28ytEGmaJrIPdqGp08btMiWbK1iEIokFHwQD0pM7112YWsPSGZV17UHpWcSIs0R U8OSUNaVhSyNMDAZDlzCyuNEq3oOuKLYVg7LMsC095QAObmnWEOnAFXg3HBys5WJKS Xpl9m3gjtLMacjVe+VWO2N9NUBr4N8IxxZsXuLQ4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, luo penghao , Lukas Czerner , Ritesh Harjani , Jan Kara , Theodore Tso , stable@kernel.org Subject: [PATCH 5.15 102/110] ext4: fix error handling in ext4_fc_record_modified_inode() Date: Mon, 7 Feb 2022 12:07:15 +0100 Message-Id: <20220207103805.845715864@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Ritesh Harjani commit cdce59a1549190b66f8e3fe465c2b2f714b98a94 upstream. Current code does not fully takes care of krealloc() error case, which could lead to silent memory corruption or a kernel bug. This patch fixes that. Also it cleans up some duplicated error handling logic from various functions in fast_commit.c file. Reported-by: luo penghao Suggested-by: Lukas Czerner Signed-off-by: Ritesh Harjani Reviewed-by: Jan Kara Link: https://lore.kernel.org/r/62e8b6a1cce9359682051deb736a3c0953c9d1e9.16= 42416995.git.riteshh@linux.ibm.com Signed-off-by: Theodore Ts'o Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- fs/ext4/fast_commit.c | 64 ++++++++++++++++++++++-----------------------= ----- 1 file changed, 29 insertions(+), 35 deletions(-) --- a/fs/ext4/fast_commit.c +++ b/fs/ext4/fast_commit.c @@ -1433,14 +1433,15 @@ static int ext4_fc_record_modified_inode if (state->fc_modified_inodes[i] =3D=3D ino) return 0; if (state->fc_modified_inodes_used =3D=3D state->fc_modified_inodes_size)= { - state->fc_modified_inodes_size +=3D - EXT4_FC_REPLAY_REALLOC_INCREMENT; state->fc_modified_inodes =3D krealloc( - state->fc_modified_inodes, sizeof(int) * - state->fc_modified_inodes_size, - GFP_KERNEL); + state->fc_modified_inodes, + sizeof(int) * (state->fc_modified_inodes_size + + EXT4_FC_REPLAY_REALLOC_INCREMENT), + GFP_KERNEL); if (!state->fc_modified_inodes) return -ENOMEM; + state->fc_modified_inodes_size +=3D + EXT4_FC_REPLAY_REALLOC_INCREMENT; } state->fc_modified_inodes[state->fc_modified_inodes_used++] =3D ino; return 0; @@ -1472,7 +1473,9 @@ static int ext4_fc_replay_inode(struct s } inode =3D NULL; =20 - ext4_fc_record_modified_inode(sb, ino); + ret =3D ext4_fc_record_modified_inode(sb, ino); + if (ret) + goto out; =20 raw_fc_inode =3D (struct ext4_inode *) (val + offsetof(struct ext4_fc_inode, fc_raw_inode)); @@ -1671,6 +1674,8 @@ static int ext4_fc_replay_add_range(stru } =20 ret =3D ext4_fc_record_modified_inode(sb, inode->i_ino); + if (ret) + goto out; =20 start =3D le32_to_cpu(ex->ee_block); start_pblk =3D ext4_ext_pblock(ex); @@ -1688,18 +1693,14 @@ static int ext4_fc_replay_add_range(stru map.m_pblk =3D 0; ret =3D ext4_map_blocks(NULL, inode, &map, 0); =20 - if (ret < 0) { - iput(inode); - return 0; - } + if (ret < 0) + goto out; =20 if (ret =3D=3D 0) { /* Range is not mapped */ path =3D ext4_find_extent(inode, cur, NULL, 0); - if (IS_ERR(path)) { - iput(inode); - return 0; - } + if (IS_ERR(path)) + goto out; memset(&newex, 0, sizeof(newex)); newex.ee_block =3D cpu_to_le32(cur); ext4_ext_store_pblock( @@ -1713,10 +1714,8 @@ static int ext4_fc_replay_add_range(stru up_write((&EXT4_I(inode)->i_data_sem)); ext4_ext_drop_refs(path); kfree(path); - if (ret) { - iput(inode); - return 0; - } + if (ret) + goto out; goto next; } =20 @@ -1729,10 +1728,8 @@ static int ext4_fc_replay_add_range(stru ret =3D ext4_ext_replay_update_ex(inode, cur, map.m_len, ext4_ext_is_unwritten(ex), start_pblk + cur - start); - if (ret) { - iput(inode); - return 0; - } + if (ret) + goto out; /* * Mark the old blocks as free since they aren't used * anymore. We maintain an array of all the modified @@ -1752,10 +1749,8 @@ static int ext4_fc_replay_add_range(stru ext4_ext_is_unwritten(ex), map.m_pblk); ret =3D ext4_ext_replay_update_ex(inode, cur, map.m_len, ext4_ext_is_unwritten(ex), map.m_pblk); - if (ret) { - iput(inode); - return 0; - } + if (ret) + goto out; /* * We may have split the extent tree while toggling the state. * Try to shrink the extent tree now. @@ -1767,6 +1762,7 @@ next: } ext4_ext_replay_shrink_inode(inode, i_size_read(inode) >> sb->s_blocksize_bits); +out: iput(inode); return 0; } @@ -1796,6 +1792,8 @@ ext4_fc_replay_del_range(struct super_bl } =20 ret =3D ext4_fc_record_modified_inode(sb, inode->i_ino); + if (ret) + goto out; =20 jbd_debug(1, "DEL_RANGE, inode %ld, lblk %d, len %d\n", inode->i_ino, le32_to_cpu(lrange.fc_lblk), @@ -1805,10 +1803,8 @@ ext4_fc_replay_del_range(struct super_bl map.m_len =3D remaining; =20 ret =3D ext4_map_blocks(NULL, inode, &map, 0); - if (ret < 0) { - iput(inode); - return 0; - } + if (ret < 0) + goto out; if (ret > 0) { remaining -=3D ret; cur +=3D ret; @@ -1823,15 +1819,13 @@ ext4_fc_replay_del_range(struct super_bl ret =3D ext4_ext_remove_space(inode, lrange.fc_lblk, lrange.fc_lblk + lrange.fc_len - 1); up_write(&EXT4_I(inode)->i_data_sem); - if (ret) { - iput(inode); - return 0; - } + if (ret) + goto out; ext4_ext_replay_shrink_inode(inode, i_size_read(inode) >> sb->s_blocksize_bits); ext4_mark_inode_dirty(NULL, inode); +out: iput(inode); - return 0; } =20 From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07356C47080 for ; Mon, 7 Feb 2022 12:03:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1390744AbiBGL5n (ORCPT ); Mon, 7 Feb 2022 06:57:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385201AbiBGLbT (ORCPT ); Mon, 7 Feb 2022 06:31:19 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76763C0302EA; Mon, 7 Feb 2022 03:29:38 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 6DDEBB80EC3; Mon, 7 Feb 2022 11:29:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 92901C004E1; Mon, 7 Feb 2022 11:29:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233376; bh=fvqCg9Xu5uhA5L3q+FEDsw1sBGuqJaYbDtNqhJQvLfI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JCxn0wU7G01L/P5qbqjZ3CHOwVt9T+C0+Nd6uN1NL5Wg1+JaksQFrT4q2cxf9HO6d hVTV6GPhNuSsHJ9Hs1NVQrBkuJiRYQJRk+fAfx/5PFetsX5PaQcqQj1jIWXSs0ypEK FQ+If6JKNbgJ81xGdG3WKmZ9guMU+FSEE42jV/Hc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kernel test robot , stable@kernel.org, Xin Yin , Ritesh Harjani , Theodore Tso Subject: [PATCH 5.15 103/110] ext4: fix incorrect type issue during replay_del_range Date: Mon, 7 Feb 2022 12:07:16 +0100 Message-Id: <20220207103805.877048294@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Xin Yin commit 8fca8a2b0a822f7936130af7299d2fd7f0a66714 upstream. should not use fast commit log data directly, add le32_to_cpu(). Reported-by: kernel test robot Fixes: 0b5b5a62b945 ("ext4: use ext4_ext_remove_space() for fast commit rep= lay delete range") Cc: stable@kernel.org Signed-off-by: Xin Yin Reviewed-by: Ritesh Harjani Link: https://lore.kernel.org/r/20220126063146.2302-1-yinxin.x@bytedance.com Signed-off-by: Theodore Ts'o Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- fs/ext4/fast_commit.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/fs/ext4/fast_commit.c +++ b/fs/ext4/fast_commit.c @@ -1816,8 +1816,9 @@ ext4_fc_replay_del_range(struct super_bl } =20 down_write(&EXT4_I(inode)->i_data_sem); - ret =3D ext4_ext_remove_space(inode, lrange.fc_lblk, - lrange.fc_lblk + lrange.fc_len - 1); + ret =3D ext4_ext_remove_space(inode, le32_to_cpu(lrange.fc_lblk), + le32_to_cpu(lrange.fc_lblk) + + le32_to_cpu(lrange.fc_len) - 1); up_write(&EXT4_I(inode)->i_data_sem); if (ret) goto out; From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF103C35274 for ; Mon, 7 Feb 2022 12:03:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1390637AbiBGL5D (ORCPT ); Mon, 7 Feb 2022 06:57:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385212AbiBGLbU (ORCPT ); Mon, 7 Feb 2022 06:31:20 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC3EFC0302F1; Mon, 7 Feb 2022 03:29:41 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A864FB80EC3; Mon, 7 Feb 2022 11:29:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CCE33C004E1; Mon, 7 Feb 2022 11:29:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233379; bh=q0nvyZV4sYkd7gzOHWgjUx1R62mGh98lgexTYH8IfgA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gxiZBjjCS+7ieVCtRWkxkCzovZEjPAHdmtqMzPRL/pjfzt2b8sztytYfl+ZYjH2G/ IbZHpMXESASuwslCBoGJTkKlU+VDbcDXIU1T3unEni0NEs9g3dzk69pxZ0mWirlJHk icyj3aAt1Z0vyYJfwf0GoUolnBD1j9uTgyXec/g0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= , Andrew Lunn , Florian Fainelli , Jakub Kicinski Subject: [PATCH 5.15 104/110] net: dsa: mt7530: make NET_DSA_MT7530 select MEDIATEK_GE_PHY Date: Mon, 7 Feb 2022 12:07:17 +0100 Message-Id: <20220207103805.908177058@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ar=C4=B1n=C3=A7 =C3=9CNAL commit 4223f86512877b04c932e7203648b37eec931731 upstream. Make MediaTek MT753x DSA driver enable MediaTek Gigabit PHYs driver to properly control MT7530 and MT7531 switch PHYs. A noticeable change is that the behaviour of switchport interfaces going up-down-up-down is no longer there. Fixes: b8f126a8d543 ("net-next: dsa: add dsa support for Mediatek MT7530 sw= itch") Signed-off-by: Ar=C4=B1n=C3=A7 =C3=9CNAL Reviewed-by: Andrew Lunn Reviewed-by: Florian Fainelli Link: https://lore.kernel.org/r/20220129062703.595-1-arinc.unal@arinc9.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/net/dsa/Kconfig | 1 + 1 file changed, 1 insertion(+) --- a/drivers/net/dsa/Kconfig +++ b/drivers/net/dsa/Kconfig @@ -36,6 +36,7 @@ config NET_DSA_LANTIQ_GSWIP config NET_DSA_MT7530 tristate "MediaTek MT753x and MT7621 Ethernet switch support" select NET_DSA_TAG_MTK + select MEDIATEK_GE_PHY help This enables support for the MediaTek MT7530, MT7531, and MT7621 Ethernet switch chips. From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4920C35275 for ; Mon, 7 Feb 2022 12:03:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1390663AbiBGL5M (ORCPT ); Mon, 7 Feb 2022 06:57:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385224AbiBGLbY (ORCPT ); Mon, 7 Feb 2022 06:31:24 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73786C02C461; Mon, 7 Feb 2022 03:29:43 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 119A260A69; Mon, 7 Feb 2022 11:29:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E2CFBC004E1; Mon, 7 Feb 2022 11:29:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233382; bh=qVNKeck0zmBC2NlbwYsQU2xFOx29BT7tvNk9RAbYvl8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lyIW1SVLv4iMkO1aBzTC7qAJ2XPhBJzLtEGc0ei0+2eJPAsrlOSsFwUBrhNsmgExi dOqsLV2z5XYofUAZncWAT0wZhAha8ERoF2IoiGtMJly534aJ9P/wFAizYqLayXn/Oo YKrYG9JBOlIDpVon49sM5NQOEWOIWz0y2yio6lxM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Waiman Long , Phil Auld , Tejun Heo Subject: [PATCH 5.15 105/110] cgroup/cpuset: Fix "suspicious RCU usage" lockdep warning Date: Mon, 7 Feb 2022 12:07:18 +0100 Message-Id: <20220207103805.944986607@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Waiman Long commit 2bdfd2825c9662463371e6691b1a794e97fa36b4 upstream. It was found that a "suspicious RCU usage" lockdep warning was issued with the rcu_read_lock() call in update_sibling_cpumasks(). It is because the update_cpumasks_hier() function may sleep. So we have to release the RCU lock, call update_cpumasks_hier() and reacquire it afterward. Also add a percpu_rwsem_assert_held() in update_sibling_cpumasks() instead of stating that in the comment. Fixes: 4716909cc5c5 ("cpuset: Track cpusets that use parent's effective_cpu= s") Signed-off-by: Waiman Long Tested-by: Phil Auld Reviewed-by: Phil Auld Signed-off-by: Tejun Heo Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- kernel/cgroup/cpuset.c | 10 ++++++++++ 1 file changed, 10 insertions(+) --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -1512,10 +1512,15 @@ static void update_sibling_cpumasks(stru struct cpuset *sibling; struct cgroup_subsys_state *pos_css; =20 + percpu_rwsem_assert_held(&cpuset_rwsem); + /* * Check all its siblings and call update_cpumasks_hier() * if their use_parent_ecpus flag is set in order for them * to use the right effective_cpus value. + * + * The update_cpumasks_hier() function may sleep. So we have to + * release the RCU read lock before calling it. */ rcu_read_lock(); cpuset_for_each_child(sibling, pos_css, parent) { @@ -1523,8 +1528,13 @@ static void update_sibling_cpumasks(stru continue; if (!sibling->use_parent_ecpus) continue; + if (!css_tryget_online(&sibling->css)) + continue; =20 + rcu_read_unlock(); update_cpumasks_hier(sibling, tmp); + rcu_read_lock(); + css_put(&sibling->css); } rcu_read_unlock(); } From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11B62C4707E for ; Mon, 7 Feb 2022 12:03:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1390644AbiBGL5J (ORCPT ); Mon, 7 Feb 2022 06:57:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385234AbiBGLb0 (ORCPT ); Mon, 7 Feb 2022 06:31:26 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8297C02B750; Mon, 7 Feb 2022 03:29:46 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 768E960A67; Mon, 7 Feb 2022 11:29:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3809CC004E1; Mon, 7 Feb 2022 11:29:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233385; bh=OtP5r+gyCFy9t1qM39CdxkthGbobIllUleGvZdo9M9s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hZ5F2WKF/P2sC563mjfEDcQa/whNZgOR+dvNvmGELRP1vEKFJHrTzU4BYLRRuIqQU YSL3aPDCQX5Dvycw+fzkIlMYfeXbOTRF/CqCExyv9xgW242CScEuHIP/8eQ0/56XI9 UHWD7nbbJ4K33Lm2ztNzuhMe1LUJZfKImAtds0o8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dmitry Osipenko , Mark Brown , Takashi Iwai , Arnaldo Carvalho de Melo Subject: [PATCH 5.15 106/110] tools include UAPI: Sync sound/asound.h copy with the kernel sources Date: Mon, 7 Feb 2022 12:07:19 +0100 Message-Id: <20220207103805.980470477@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Arnaldo Carvalho de Melo commit 4f2492731ada9d702ffdfaa6ec1ff64820a1664c upstream. Picking the changes from: 06feec6005c9d950 ("ASoC: hdmi-codec: Fix OOB memory accesses") Which entails no changes in the tooling side as it doesn't introduce new SNDRV_PCM_IOCTL_ ioctls. To silence this perf tools build warning: Warning: Kernel ABI header at 'tools/include/uapi/sound/asound.h' differs= from latest version at 'include/uapi/sound/asound.h' diff -u tools/include/uapi/sound/asound.h include/uapi/sound/asound.h Cc: Dmitry Osipenko Cc: Mark Brown Cc: Takashi Iwai Link: https://lore.kernel.org/lkml/Yf+6OT+2eMrYDEeX@kernel.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- tools/include/uapi/sound/asound.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/tools/include/uapi/sound/asound.h +++ b/tools/include/uapi/sound/asound.h @@ -56,8 +56,10 @@ * = * *************************************************************************= ***/ =20 +#define AES_IEC958_STATUS_SIZE 24 + struct snd_aes_iec958 { - unsigned char status[24]; /* AES/IEC958 channel status bits */ + unsigned char status[AES_IEC958_STATUS_SIZE]; /* AES/IEC958 channel statu= s bits */ unsigned char subcode[147]; /* AES/IEC958 subcode bits */ unsigned char pad; /* nothing */ unsigned char dig_subframe[4]; /* AES/IEC958 subframe bits */ From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F0A17C4707F for ; Mon, 7 Feb 2022 12:03:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1390716AbiBGL5a (ORCPT ); Mon, 7 Feb 2022 06:57:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385249AbiBGLb0 (ORCPT ); Mon, 7 Feb 2022 06:31:26 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89438C02B647; Mon, 7 Feb 2022 03:29:51 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 5398EB8111C; Mon, 7 Feb 2022 11:29:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91106C004E1; Mon, 7 Feb 2022 11:29:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233389; bh=Bhdf+S29ZevkiMeS0rzmUpQEcBMlLRTwt6TQNWmKMNc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vyUSsswwmfKojG0ORAIc8rB/6ufEi4M0wZKlcAxWgx57EAqX8VEqfIGBf0rQt4W3b ME5oIIfh98/SGLryW5sib4mZHQFgdApDM+sTyIG3UcxnAePSn1ZBLfnQ7wqkTePso6 Re1sm56fR9kAkr6PesyTKCKIz2o8oP42hAvMNoRc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Abaci Robot , Yang Li , Bartosz Golaszewski Subject: [PATCH 5.15 107/110] gpio: idt3243x: Fix an ignored error return from platform_get_irq() Date: Mon, 7 Feb 2022 12:07:20 +0100 Message-Id: <20220207103806.015849410@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Yang Li commit 7c1cf55577782725ea2bc24687767c8fe8e57486 upstream. The return from the call to platform_get_irq() is int, it can be a negative error code, however this is being assigned to an unsigned int variable 'parent_irq', so making 'parent_irq' an int. Eliminate the following coccicheck warning: ./drivers/gpio/gpio-idt3243x.c:167:6-16: WARNING: Unsigned expression compared with zero: parent_irq < 0 Reported-by: Abaci Robot Fixes: 30fee1d7462a ("gpio: idt3243x: Fix IRQ check in idt_gpio_probe") Signed-off-by: Yang Li Signed-off-by: Bartosz Golaszewski Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/gpio/gpio-idt3243x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/gpio/gpio-idt3243x.c +++ b/drivers/gpio/gpio-idt3243x.c @@ -132,7 +132,7 @@ static int idt_gpio_probe(struct platfor struct device *dev =3D &pdev->dev; struct gpio_irq_chip *girq; struct idt_gpio_ctrl *ctrl; - unsigned int parent_irq; + int parent_irq; int ngpios; int ret; =20 From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8FE2C35276 for ; Mon, 7 Feb 2022 12:03:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1390687AbiBGL50 (ORCPT ); Mon, 7 Feb 2022 06:57:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385251AbiBGLb0 (ORCPT ); Mon, 7 Feb 2022 06:31:26 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83201C02B649; Mon, 7 Feb 2022 03:29:53 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1F22260A67; Mon, 7 Feb 2022 11:29:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CBD6BC004E1; Mon, 7 Feb 2022 11:29:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233392; bh=/caNl0v9RwhFS+XEpOgKYAUioaM4gZ0FnbqNGD2i7JI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pPbmIcCckoN5STM/q3ddYOROfNOZ+9d9id1UgT6OJpxgItbmHInde+q2uaIJPDdGy MLENk41JJy/ME0ghQU8qxrxe3B8jgExgRfO2C3H2fl3cOaAHnKU5Ue/vdJNmNYisTb We1u/mMJ+GD96We+qi1ku3jLEOmwvthrvXF3q4P4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Abaci Robot , Yang Li , Bartosz Golaszewski Subject: [PATCH 5.15 108/110] gpio: mpc8xxx: Fix an ignored error return from platform_get_irq() Date: Mon, 7 Feb 2022 12:07:21 +0100 Message-Id: <20220207103806.050063963@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Yang Li commit 9f51ce0b9e73f83bab2442b36d5e247a81bd3401 upstream. The return from the call to platform_get_irq() is int, it can be a negative error code, however this is being assigned to an unsigned int variable 'irqn', so making 'irqn' an int. Eliminate the following coccicheck warning: ./drivers/gpio/gpio-mpc8xxx.c:391:5-21: WARNING: Unsigned expression compared with zero: mpc8xxx_gc -> irqn < 0 Reported-by: Abaci Robot Fixes: 0b39536cc699 ("gpio: mpc8xxx: Fix IRQ check in mpc8xxx_probe") Signed-off-by: Yang Li Signed-off-by: Bartosz Golaszewski Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- drivers/gpio/gpio-mpc8xxx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/gpio/gpio-mpc8xxx.c +++ b/drivers/gpio/gpio-mpc8xxx.c @@ -47,7 +47,7 @@ struct mpc8xxx_gpio_chip { unsigned offset, int value); =20 struct irq_domain *irq; - unsigned int irqn; + int irqn; }; =20 /* From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6AE90C433FE for ; Mon, 7 Feb 2022 12:03:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1390723AbiBGL5c (ORCPT ); Mon, 7 Feb 2022 06:57:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385250AbiBGLb0 (ORCPT ); Mon, 7 Feb 2022 06:31:26 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52437C02B64B; Mon, 7 Feb 2022 03:29:58 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 12A10B80EBD; Mon, 7 Feb 2022 11:29:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 409CEC004E1; Mon, 7 Feb 2022 11:29:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233395; bh=IzGcumH0UBveEX4Z1EvcBvjQJNsagxoSQnbTgSwJPG0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rbpg17KapGLYWkKQFTYu6f/JtNd+drIdpiOyg5x7TWqKn9XMKKcCybyl7lLYI0PgX 4BWuAvUrS2C7DrZcPy9mTsvwkExPF3TJjP/kO3rHyX5PnxdjGtxgumJZHLWoMsPw6r cH4S6o1GXdoI7cvc6WqhcRz6sJsBeZjtkZ9Xqu8E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Florian Westphal , Stefano Brivio , Pablo Neira Ayuso Subject: [PATCH 5.15 109/110] selftests: nft_concat_range: add test for reload with no element add/del Date: Mon, 7 Feb 2022 12:07:22 +0100 Message-Id: <20220207103806.081081409@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Florian Westphal commit eda0cf1202acf1ef47f93d8f92d4839213431424 upstream. Add a specific test for the reload issue fixed with commit 23c54263efd7cb ("netfilter: nft_set_pipapo: allocate pcpu scratch ma= ps on clone"). Add to set, then flush set content + restore without other add/remove in the transaction. On kernels before the fix, this test case fails: net,mac with reload [FAIL] Signed-off-by: Florian Westphal Reviewed-by: Stefano Brivio Signed-off-by: Pablo Neira Ayuso Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- tools/testing/selftests/netfilter/nft_concat_range.sh | 72 +++++++++++++= ++++- 1 file changed, 71 insertions(+), 1 deletion(-) --- a/tools/testing/selftests/netfilter/nft_concat_range.sh +++ b/tools/testing/selftests/netfilter/nft_concat_range.sh @@ -27,7 +27,7 @@ TYPES=3D"net_port port_net net6_port port_ net_port_mac_proto_net" =20 # Reported bugs, also described by TYPE_ variables below -BUGS=3D"flush_remove_add" +BUGS=3D"flush_remove_add reload" =20 # List of possible paths to pktgen script from kernel tree for performance= tests PKTGEN_SCRIPT_PATHS=3D" @@ -337,6 +337,23 @@ TYPE_flush_remove_add=3D" display Add two elements, flush, re-add " =20 +TYPE_reload=3D" +display net,mac with reload +type_spec ipv4_addr . ether_addr +chain_spec ip daddr . ether saddr +dst addr4 +src mac +start 1 +count 1 +src_delta 2000 +tools sendip nc bash +proto udp + +race_repeat 0 + +perf_duration 0 +" + # Set template for all tests, types and rules are filled in depending on t= est set_template=3D' flush ruleset @@ -1455,6 +1472,59 @@ test_bug_flush_remove_add() { nft flush ruleset } =20 +# - add ranged element, check that packets match it +# - reload the set, check packets still match +test_bug_reload() { + setup veth send_"${proto}" set || return ${KSELFTEST_SKIP} + rstart=3D${start} + + range_size=3D1 + for i in $(seq "${start}" $((start + count))); do + end=3D$((start + range_size)) + + # Avoid negative or zero-sized port ranges + if [ $((end / 65534)) -gt $((start / 65534)) ]; then + start=3D${end} + end=3D$((end + 1)) + fi + srcstart=3D$((start + src_delta)) + srcend=3D$((end + src_delta)) + + add "$(format)" || return 1 + range_size=3D$((range_size + 1)) + start=3D$((end + range_size)) + done + + # check kernel does allocate pcpu sctrach map + # for reload with no elemet add/delete + ( echo flush set inet filter test ; + nft list set inet filter test ) | nft -f - + + start=3D${rstart} + range_size=3D1 + + for i in $(seq "${start}" $((start + count))); do + end=3D$((start + range_size)) + + # Avoid negative or zero-sized port ranges + if [ $((end / 65534)) -gt $((start / 65534)) ]; then + start=3D${end} + end=3D$((end + 1)) + fi + srcstart=3D$((start + src_delta)) + srcend=3D$((end + src_delta)) + + for j in $(seq ${start} $((range_size / 2 + 1)) ${end}); do + send_match "${j}" $((j + src_delta)) || return 1 + done + + range_size=3D$((range_size + 1)) + start=3D$((end + range_size)) + done + + nft flush ruleset +} + test_reported_issues() { eval test_bug_"${subtest}" } From nobody Mon Jun 29 16:42:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C027AC433F5 for ; Mon, 7 Feb 2022 12:03:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1390670AbiBGL5Q (ORCPT ); Mon, 7 Feb 2022 06:57:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385255AbiBGLb1 (ORCPT ); Mon, 7 Feb 2022 06:31:27 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D35DC03E910; Mon, 7 Feb 2022 03:30:01 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2806DB80EBD; Mon, 7 Feb 2022 11:30:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6529AC004E1; Mon, 7 Feb 2022 11:29:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233399; bh=2io9CEw91StQj81t+X7quJ24LQ0pDfkOTHb8NuMuRsA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bYz8Z368S6x/yQ7j6PYuEtgLKmmtdTi+6L0E9cwIfzgMNlU1wNL0lSGKSFUlxmTKF wZe0Ia63S0v5IFdf0/MNetqUwNXRlytVjgnKLkEDfjMxOBtbs5xwd9uvYwzvPQsG0n wIR0Liwl+L7mfdv7LNI1hQ8TJiuxHHsQ1yScnJME= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Florian Westphal , Pablo Neira Ayuso Subject: [PATCH 5.15 110/110] selftests: netfilter: check stateless nat udp checksum fixup Date: Mon, 7 Feb 2022 12:07:23 +0100 Message-Id: <20220207103806.116943414@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Florian Westphal commit aad51ca71ad83273e8826d6cfdcf53c98748d1fa upstream. Add a test that sends large udp packet (which is fragmented) via a stateless nft nat rule, i.e. 'ip saddr set 10.2.3.4' and check that the datagram is received by peer. On kernels without commit 4e1860a38637 ("netfilter: nft_payload: do not update layer 4 checksu= m when mangling fragments")', this will fail with: cmp: EOF on /tmp/tmp.V1q0iXJyQF which is empty -rw------- 1 root root 4096 Jan 24 22:03 /tmp/tmp.Aaqnq4rBKS -rw------- 1 root root 0 Jan 24 22:03 /tmp/tmp.V1q0iXJyQF ERROR: in and output file mismatch when checking udp with stateless nat FAIL: nftables v1.0.0 (Fearless Fosdick #2) On patched kernels, this will show: PASS: IP statless for ns2-PFp89amx Signed-off-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso Signed-off-by: Greg Kroah-Hartman Reported-by: Linux Kernel Functional Testing --- tools/testing/selftests/netfilter/nft_nat.sh | 152 ++++++++++++++++++++++= +++++ 1 file changed, 152 insertions(+) --- a/tools/testing/selftests/netfilter/nft_nat.sh +++ b/tools/testing/selftests/netfilter/nft_nat.sh @@ -885,6 +885,144 @@ EOF ip netns exec "$ns0" nft delete table $family nat } =20 +test_stateless_nat_ip() +{ + local lret=3D0 + + ip netns exec "$ns0" sysctl net.ipv4.conf.veth0.forwarding=3D1 > /dev/null + ip netns exec "$ns0" sysctl net.ipv4.conf.veth1.forwarding=3D1 > /dev/null + + ip netns exec "$ns2" ping -q -c 1 10.0.1.99 > /dev/null # ping ns2->ns1 + if [ $? -ne 0 ] ; then + echo "ERROR: cannot ping $ns1 from $ns2 before loading stateless rules" + return 1 + fi + +ip netns exec "$ns0" nft -f /dev/stdin < /dev/null # ping ns2->ns1 + if [ $? -ne 0 ] ; then + echo "ERROR: cannot ping $ns1 from $ns2 with stateless rules" + lret=3D1 + fi + + # ns1 should have seen packets from .2.2, due to stateless rewrite. + expect=3D"packets 1 bytes 84" + cnt=3D$(ip netns exec "$ns1" nft list counter inet filter ns0insl | grep = -q "$expect") + if [ $? -ne 0 ]; then + bad_counter "$ns1" ns0insl "$expect" "test_stateless 1" + lret=3D1 + fi + + for dir in "in" "out" ; do + cnt=3D$(ip netns exec "$ns2" nft list counter inet filter ns1${dir} | gr= ep -q "$expect") + if [ $? -ne 0 ]; then + bad_counter "$ns2" ns1$dir "$expect" "test_stateless 2" + lret=3D1 + fi + done + + # ns1 should not have seen packets from ns2, due to masquerade + expect=3D"packets 0 bytes 0" + for dir in "in" "out" ; do + cnt=3D$(ip netns exec "$ns1" nft list counter inet filter ns2${dir} | gr= ep -q "$expect") + if [ $? -ne 0 ]; then + bad_counter "$ns1" ns0$dir "$expect" "test_stateless 3" + lret=3D1 + fi + + cnt=3D$(ip netns exec "$ns0" nft list counter inet filter ns1${dir} | gr= ep -q "$expect") + if [ $? -ne 0 ]; then + bad_counter "$ns0" ns1$dir "$expect" "test_stateless 4" + lret=3D1 + fi + done + + reset_counters + + socat -h > /dev/null 2>&1 + if [ $? -ne 0 ];then + echo "SKIP: Could not run stateless nat frag test without socat tool" + if [ $lret -eq 0 ]; then + return $ksft_skip + fi + + ip netns exec "$ns0" nft delete table ip stateless + return $lret + fi + + local tmpfile=3D$(mktemp) + dd if=3D/dev/urandom of=3D$tmpfile bs=3D4096 count=3D1 2>/dev/null + + local outfile=3D$(mktemp) + ip netns exec "$ns1" timeout 3 socat -u UDP4-RECV:4233 OPEN:$outfile < /d= ev/null & + sc_r=3D$! + + sleep 1 + # re-do with large ping -> ip fragmentation + ip netns exec "$ns2" timeout 3 socat - UDP4-SENDTO:"10.0.1.99:4233" < "$t= mpfile" > /dev/null + if [ $? -ne 0 ] ; then + echo "ERROR: failed to test udp $ns1 to $ns2 with stateless ip nat" 1>&2 + lret=3D1 + fi + + wait + + cmp "$tmpfile" "$outfile" + if [ $? -ne 0 ]; then + ls -l "$tmpfile" "$outfile" + echo "ERROR: in and output file mismatch when checking udp with stateles= s nat" 1>&2 + lret=3D1 + fi + + rm -f "$tmpfile" "$outfile" + + # ns1 should have seen packets from 2.2, due to stateless rewrite. + expect=3D"packets 3 bytes 4164" + cnt=3D$(ip netns exec "$ns1" nft list counter inet filter ns0insl | grep = -q "$expect") + if [ $? -ne 0 ]; then + bad_counter "$ns1" ns0insl "$expect" "test_stateless 5" + lret=3D1 + fi + + ip netns exec "$ns0" nft delete table ip stateless + if [ $? -ne 0 ]; then + echo "ERROR: Could not delete table ip stateless" 1>&2 + lret=3D1 + fi + + test $lret -eq 0 && echo "PASS: IP statless for $ns2" + + return $lret +} + # ip netns exec "$ns0" ping -c 1 -q 10.0.$i.99 for i in 0 1 2; do ip netns exec ns$i-$sfx nft -f /dev/stdin <