From nobody Tue Jun 23 18:14:07 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 A5A85C433F5 for ; Mon, 28 Feb 2022 17:36:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238292AbiB1Rgl (ORCPT ); Mon, 28 Feb 2022 12:36:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238525AbiB1Rde (ORCPT ); Mon, 28 Feb 2022 12:33:34 -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 DED2C90FF8; Mon, 28 Feb 2022 09:30:10 -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 F21C3B815B8; Mon, 28 Feb 2022 17:30:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E4B3C340E7; Mon, 28 Feb 2022 17:30:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069407; bh=KkzO5SfNgv6pefqurUmAIt4FKijkSthd8pPmqIR/5/M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n6Y6cTnqE4qkNvQkRmzk6AztpWZ7BML3toqaRHz7Ys3eUKw5BlPcaUfqZVPd0qHo5 VvUn7f6yH2CsP/R4ZRX3g8kDIssSS5WPlNhW4+6gn9DsSUu5hKgLww7Fr2yW54erU1 SKE60jHFWWWUsktmUdCVdC+Eqz9V4gXwbsKwxtds= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhao Gongyi , Zhang Qiao , Waiman Long , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Tejun Heo Subject: [PATCH 5.4 01/53] cgroup/cpuset: Fix a race between cpuset_attach() and cpu hotplug Date: Mon, 28 Feb 2022 18:23:59 +0100 Message-Id: <20220228172248.327750002@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: Zhang Qiao commit 05c7b7a92cc87ff8d7fde189d0fade250697573c upstream. As previously discussed(https://lkml.org/lkml/2022/1/20/51), cpuset_attach() is affected with similar cpu hotplug race, as follow scenario: cpuset_attach() cpu hotplug --------------------------- ---------------------- down_write(cpuset_rwsem) guarantee_online_cpus() // (load cpus_attach) sched_cpu_deactivate set_cpu_active() // will change cpu_active_mask set_cpus_allowed_ptr(cpus_attach) __set_cpus_allowed_ptr_locked() // (if the intersection of cpus_attach and cpu_active_mask is empty, will return -EINVAL) up_write(cpuset_rwsem) To avoid races such as described above, protect cpuset_attach() call with cpu_hotplug_lock. Fixes: be367d099270 ("cgroups: let ss->can_attach and ss->attach do whole t= hreadgroups at a time") Cc: stable@vger.kernel.org # v2.6.32+ Reported-by: Zhao Gongyi Signed-off-by: Zhang Qiao Acked-by: Waiman Long Reviewed-by: Michal Koutn=C3=BD Signed-off-by: Tejun Heo Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- kernel/cgroup/cpuset.c | 2 ++ 1 file changed, 2 insertions(+) --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -2204,6 +2204,7 @@ static void cpuset_attach(struct cgroup_ cgroup_taskset_first(tset, &css); cs =3D css_cs(css); =20 + cpus_read_lock(); percpu_down_write(&cpuset_rwsem); =20 /* prepare for attach */ @@ -2259,6 +2260,7 @@ static void cpuset_attach(struct cgroup_ wake_up(&cpuset_attach_wq); =20 percpu_up_write(&cpuset_rwsem); + cpus_read_unlock(); } =20 /* The various types of files and directories in a cpuset file system */ From nobody Tue Jun 23 18:14:07 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 3B443C433F5 for ; Mon, 28 Feb 2022 17:36:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238260AbiB1Rgr (ORCPT ); Mon, 28 Feb 2022 12:36:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238746AbiB1Rdt (ORCPT ); Mon, 28 Feb 2022 12:33:49 -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 4BFF791ACE; Mon, 28 Feb 2022 09:30: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 6ACA061358; Mon, 28 Feb 2022 17:30:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 762B0C340E7; Mon, 28 Feb 2022 17:30:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069437; bh=ey1A6y5rc1rRDoDJyi4At2XilDpp2JjtriUZZziNA9g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IMqfWipm8auMuQ4k1JNd/myqe/ec2K/5JGWTb42kEUCNOLtRTjwK8SbmZq15MRGAx SnG2TkmR728CSju0EIAcRJpEX+8uULNcKrhbg7OWnwDlIE8WdryRMPaEiYizMUu1R2 n/eyYO8kyTkz1wxQe6EDUAl0aK4VYCmZDA51dhdE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Siarhei Volkau , Paul Cercueil , Stephen Boyd Subject: [PATCH 5.4 02/53] clk: jz4725b: fix mmc0 clock gating Date: Mon, 28 Feb 2022 18:24:00 +0100 Message-Id: <20220228172248.425951543@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: Siarhei Volkau commit 2f0754f27a230fee6e6d753f07585cee03bedfe3 upstream. The mmc0 clock gate bit was mistakenly assigned to "i2s" clock. You can find that the same bit is assigned to "mmc0" too. It leads to mmc0 hang for a long time after any sound activity also it prevented PM_SLEEP to work properly. I guess it was introduced by copy-paste from jz4740 driver where it is really controls I2S clock gate. Fixes: 226dfa4726eb ("clk: Add Ingenic jz4725b CGU driver") Signed-off-by: Siarhei Volkau Tested-by: Siarhei Volkau Reviewed-by: Paul Cercueil Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20220205171849.687805-2-lis8215@gmail.com Signed-off-by: Stephen Boyd Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- drivers/clk/ingenic/jz4725b-cgu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/drivers/clk/ingenic/jz4725b-cgu.c +++ b/drivers/clk/ingenic/jz4725b-cgu.c @@ -135,11 +135,10 @@ static const struct ingenic_cgu_clk_info }, =20 [JZ4725B_CLK_I2S] =3D { - "i2s", CGU_CLK_MUX | CGU_CLK_DIV | CGU_CLK_GATE, + "i2s", CGU_CLK_MUX | CGU_CLK_DIV, .parents =3D { JZ4725B_CLK_EXT, JZ4725B_CLK_PLL_HALF, -1, -1 }, .mux =3D { CGU_REG_CPCCR, 31, 1 }, .div =3D { CGU_REG_I2SCDR, 0, 1, 9, -1, -1, -1 }, - .gate =3D { CGU_REG_CLKGR, 6 }, }, =20 [JZ4725B_CLK_SPI] =3D { From nobody Tue Jun 23 18:14:07 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 E5376C433F5 for ; Mon, 28 Feb 2022 17:36:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235424AbiB1Rh2 (ORCPT ); Mon, 28 Feb 2022 12:37:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238157AbiB1Reh (ORCPT ); Mon, 28 Feb 2022 12:34:37 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28D1C7D029; Mon, 28 Feb 2022 09:31: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 dfw.source.kernel.org (Postfix) with ESMTPS id 3F2D661419; Mon, 28 Feb 2022 17:30:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 53387C340E7; Mon, 28 Feb 2022 17:30:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069456; bh=Rd8jvTNrPWtN6dd5Od5wtu8Di/L6XL1V6MGeJMtvvLA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MXE+/VOB+5Ire5M1YjlbO35I1GjRaTZfgwGXlHom8xBnYWtt/H09mj1Wbukn3n5Ve vOuAXdETsG/jPxN/B8VTMuVXs++KaQZKctLUGuju5nAOJxrMZTCFXRsWIh9PmXZ8dn AzJhhZIDlo0xVMvk2nTKsg4V6SWmBTzvqpvfwpHU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+1e3ea63db39f2b4440e0@syzkaller.appspotmail.com, Stefano Garzarella , Jason Wang , "David S. Miller" , syzbot+3140b17cb44a7b174008@syzkaller.appspotmail.com Subject: [PATCH 5.4 03/53] vhost/vsock: dont check owner in vhost_vsock_stop() while releasing Date: Mon, 28 Feb 2022 18:24:01 +0100 Message-Id: <20220228172248.525743374@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: Stefano Garzarella commit a58da53ffd70294ebea8ecd0eb45fd0d74add9f9 upstream. vhost_vsock_stop() calls vhost_dev_check_owner() to check the device ownership. It expects current->mm to be valid. vhost_vsock_stop() is also called by vhost_vsock_dev_release() when the user has not done close(), so when we are in do_exit(). In this case current->mm is invalid and we're releasing the device, so we should clean it anyway. Let's check the owner only when vhost_vsock_stop() is called by an ioctl. When invoked from release we can not fail so we don't check return code of vhost_vsock_stop(). We need to stop vsock even if it's not the owner. Fixes: 433fc58e6bf2 ("VSOCK: Introduce vhost_vsock.ko") Cc: stable@vger.kernel.org Reported-by: syzbot+1e3ea63db39f2b4440e0@syzkaller.appspotmail.com Reported-and-tested-by: syzbot+3140b17cb44a7b174008@syzkaller.appspotmail.c= om Signed-off-by: Stefano Garzarella Acked-by: Jason Wang Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- drivers/vhost/vsock.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) --- a/drivers/vhost/vsock.c +++ b/drivers/vhost/vsock.c @@ -570,16 +570,18 @@ err: return ret; } =20 -static int vhost_vsock_stop(struct vhost_vsock *vsock) +static int vhost_vsock_stop(struct vhost_vsock *vsock, bool check_owner) { size_t i; - int ret; + int ret =3D 0; =20 mutex_lock(&vsock->dev.mutex); =20 - ret =3D vhost_dev_check_owner(&vsock->dev); - if (ret) - goto err; + if (check_owner) { + ret =3D vhost_dev_check_owner(&vsock->dev); + if (ret) + goto err; + } =20 for (i =3D 0; i < ARRAY_SIZE(vsock->vqs); i++) { struct vhost_virtqueue *vq =3D &vsock->vqs[i]; @@ -694,7 +696,12 @@ static int vhost_vsock_dev_release(struc * inefficient. Room for improvement here. */ vsock_for_each_connected_socket(vhost_vsock_reset_orphans); =20 - vhost_vsock_stop(vsock); + /* Don't check the owner, because we are in the release path, so we + * need to stop the vsock device in any case. + * vhost_vsock_stop() can not fail in this case, so we don't need to + * check the return code. + */ + vhost_vsock_stop(vsock, false); vhost_vsock_flush(vsock); vhost_dev_stop(&vsock->dev); =20 @@ -792,7 +799,7 @@ static long vhost_vsock_dev_ioctl(struct if (start) return vhost_vsock_start(vsock); else - return vhost_vsock_stop(vsock); + return vhost_vsock_stop(vsock, true); case VHOST_GET_FEATURES: features =3D VHOST_VSOCK_FEATURES; if (copy_to_user(argp, &features, sizeof(features))) From nobody Tue Jun 23 18:14:07 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 8C578C433EF for ; Mon, 28 Feb 2022 17:36:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237874AbiB1RhW (ORCPT ); Mon, 28 Feb 2022 12:37:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238037AbiB1Ree (ORCPT ); Mon, 28 Feb 2022 12:34: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 14F46939C9; Mon, 28 Feb 2022 09:31: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 dfw.source.kernel.org (Postfix) with ESMTPS id EA4A16135F; Mon, 28 Feb 2022 17:30:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0ABB9C340E7; Mon, 28 Feb 2022 17:30:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069459; bh=0kLHFsDZCk0ZTM/V8Kf2IsrIaPAGMGwqKe7xccMH9p4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NEcHk9/y29H0u8CWs78PUuj+AEHCBQGXxuejwvowf1Xs+hAsLmGp4jPa2emjMWYaP pR4HJQtTGtYo603W1moeFwhWQqZHi6wXkyhTYwY4/cQsjcyVwyhKVjK6Gy04vljmq1 NiqdD7dATuINwhPdJpU0Uxdj8efShGwca0GJxnkw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Helge Deller Subject: [PATCH 5.4 04/53] parisc/unaligned: Fix fldd and fstd unaligned handlers on 32-bit kernel Date: Mon, 28 Feb 2022 18:24:02 +0100 Message-Id: <20220228172248.619102510@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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 dd2288f4a020d693360e3e8d72f8b9d9c25f5ef6 upstream. Usually the kernel provides fixup routines to emulate the fldd and fstd floating-point instructions if they load or store 8-byte from/to a not natuarally aligned memory location. On a 32-bit kernel I noticed that those unaligned handlers didn't worked and instead the application got a SEGV. While checking the code I found two problems: First, the OPCODE_FLDD_L and OPCODE_FSTD_L cases were ifdef'ed out by the CONFIG_PA20 option, and as such those weren't built on a pure 32-bit kernel. This is now fixed by moving the CONFIG_PA20 #ifdef to prevent the compilati= on of OPCODE_LDD_L and OPCODE_FSTD_L only, and handling the fldd and fstd instructions. The second problem are two bugs in the 32-bit inline assembly code, where t= he wrong registers where used. The calculation of the natural alignment used %2 (vall) instead of %3 (ior), and the first word was stored back to address %1 (valh) instead of %3 (ior). Signed-off-by: Helge Deller Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- arch/parisc/kernel/unaligned.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/arch/parisc/kernel/unaligned.c +++ b/arch/parisc/kernel/unaligned.c @@ -397,7 +397,7 @@ static int emulate_std(struct pt_regs *r __asm__ __volatile__ ( " mtsp %4, %%sr1\n" " zdep %2, 29, 2, %%r19\n" -" dep %%r0, 31, 2, %2\n" +" dep %%r0, 31, 2, %3\n" " mtsar %%r19\n" " zvdepi -2, 32, %%r19\n" "1: ldw 0(%%sr1,%3),%%r20\n" @@ -409,7 +409,7 @@ static int emulate_std(struct pt_regs *r " andcm %%r21, %%r19, %%r21\n" " or %1, %%r20, %1\n" " or %2, %%r21, %2\n" -"3: stw %1,0(%%sr1,%1)\n" +"3: stw %1,0(%%sr1,%3)\n" "4: stw %%r1,4(%%sr1,%3)\n" "5: stw %2,8(%%sr1,%3)\n" " copy %%r0, %0\n" @@ -596,7 +596,6 @@ void handle_unaligned(struct pt_regs *re ret =3D ERR_NOTHANDLED; /* "undefined", but lets kill them. */ break; } -#ifdef CONFIG_PA20 switch (regs->iir & OPCODE2_MASK) { case OPCODE_FLDD_L: @@ -607,14 +606,15 @@ void handle_unaligned(struct pt_regs *re flop=3D1; ret =3D emulate_std(regs, R2(regs->iir),1); break; +#ifdef CONFIG_PA20 case OPCODE_LDD_L: ret =3D emulate_ldd(regs, R2(regs->iir),0); break; case OPCODE_STD_L: ret =3D emulate_std(regs, R2(regs->iir),0); break; - } #endif + } switch (regs->iir & OPCODE3_MASK) { case OPCODE_FLDW_L: From nobody Tue Jun 23 18:14:07 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 77DD3C433F5 for ; Mon, 28 Feb 2022 17:36:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234181AbiB1Rhe (ORCPT ); Mon, 28 Feb 2022 12:37:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238080AbiB1Rey (ORCPT ); Mon, 28 Feb 2022 12:34:54 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 561187E084; Mon, 28 Feb 2022 09:31: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 497EDB815AB; Mon, 28 Feb 2022 17:31:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A0B2BC340E7; Mon, 28 Feb 2022 17:31:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069462; bh=InIoslegLjVX1Yt8uC/7lVQLPHklSm5DBQNu2ZKpfd0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ln7aUeRHpzN031nnkYcn+TXdzMBQ4wotRMExwqWdIdztYOq2vQP9t1c5R6tfln/55 fAHLgzLehDXEFHCQMoPfgIapIWC0+qX3sNDiFD5J6DaWTWGQp5c0hqCuRGfbV8xnBp XdZ/jAzxIDq41CAkATuh7dudWhMx0NTeAwSlwMx8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Helge Deller Subject: [PATCH 5.4 05/53] parisc/unaligned: Fix ldw() and stw() unalignment handlers Date: Mon, 28 Feb 2022 18:24:03 +0100 Message-Id: <20220228172248.682710207@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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 a97279836867b1cb50a3d4f0b1bf60e0abe6d46c upstream. Fix 3 bugs: a) emulate_stw() doesn't return the error code value, so faulting instructions are not reported and aborted. b) Tell emulate_ldw() to handle fldw_l as floating point instruction c) Tell emulate_ldw() to handle ldw_m as integer instruction Signed-off-by: Helge Deller Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- arch/parisc/kernel/unaligned.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/arch/parisc/kernel/unaligned.c +++ b/arch/parisc/kernel/unaligned.c @@ -340,7 +340,7 @@ static int emulate_stw(struct pt_regs *r : "r" (val), "r" (regs->ior), "r" (regs->isr) : "r19", "r20", "r21", "r22", "r1", FIXUP_BRANCH_CLOBBER ); =20 - return 0; + return ret; } static int emulate_std(struct pt_regs *regs, int frreg, int flop) { @@ -619,10 +619,10 @@ void handle_unaligned(struct pt_regs *re { case OPCODE_FLDW_L: flop=3D1; - ret =3D emulate_ldw(regs, R2(regs->iir),0); + ret =3D emulate_ldw(regs, R2(regs->iir), 1); break; case OPCODE_LDW_M: - ret =3D emulate_ldw(regs, R2(regs->iir),1); + ret =3D emulate_ldw(regs, R2(regs->iir), 0); break; =20 case OPCODE_FSTW_L: From nobody Tue Jun 23 18:14:07 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 BEBCFC433FE for ; Mon, 28 Feb 2022 17:37:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238421AbiB1Rhw (ORCPT ); Mon, 28 Feb 2022 12:37:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238203AbiB1RfR (ORCPT ); Mon, 28 Feb 2022 12:35:17 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D4C488793; Mon, 28 Feb 2022 09:31: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 EF84DB815B4; Mon, 28 Feb 2022 17:31:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 567FAC340F0; Mon, 28 Feb 2022 17:31:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069464; bh=YZuggJDY3P6J7A+3vXvf6+XrhLmtPaUAkcNgWg3zZdI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1mQhl8nLOqU1haIwBzjLloEdTqrDClpLNt9R4vr37ffKmGC8b/jhm1ib0m+wsir10 KLHEtVtCN2N7CeFjsvveJYH1lsxKftzsoaPSmWVnwJFoa5x5ENtGC1w/Dw7tv7y/k0 JQ3lvSqcI+5EjezKYMENtOqwTS2wFeMVr8Oqn8D4= 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.4 06/53] drm/amdgpu: disable MMHUB PG for Picasso Date: Mon, 28 Feb 2022 18:24:04 +0100 Message-Id: <20220228172248.781814311@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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 f626dd0ff05043e5a7154770cc7cda66acee33a3 upstream. MMHUB PG needs to be disabled for Picasso for stability reasons. Signed-off-by: Evan Quan Reviewed-by: Alex Deucher Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- drivers/gpu/drm/amd/amdgpu/soc15.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/drivers/gpu/drm/amd/amdgpu/soc15.c +++ b/drivers/gpu/drm/amd/amdgpu/soc15.c @@ -1143,8 +1143,11 @@ static int soc15_common_early_init(void AMD_CG_SUPPORT_SDMA_MGCG | AMD_CG_SUPPORT_SDMA_LS; =20 + /* + * MMHUB PG needs to be disabled for Picasso for + * stability reasons. + */ adev->pg_flags =3D AMD_PG_SUPPORT_SDMA | - AMD_PG_SUPPORT_MMHUB | AMD_PG_SUPPORT_VCN; } else { adev->cg_flags =3D AMD_CG_SUPPORT_GFX_MGCG | From nobody Tue Jun 23 18:14:07 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 C3FD2C433F5 for ; Mon, 28 Feb 2022 17:36:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231309AbiB1Rha (ORCPT ); Mon, 28 Feb 2022 12:37:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237524AbiB1Reo (ORCPT ); Mon, 28 Feb 2022 12:34:44 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15C39939A8; Mon, 28 Feb 2022 09:31: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 AAB3CB815AE; Mon, 28 Feb 2022 17:31:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E319C340E7; Mon, 28 Feb 2022 17:31:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069467; bh=NVZ/13wV06YZ+xr1T2jgfLSQQ++PaVN1I5onuZqPhSI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MMWs2yZg0W2t5l2TX+HZqmu6dIKAMXZvIAr1lu8NeQFxaD+EYU7xlErVQ3Yr8ceKk xMriP8FcXHeBcpvhwhR73jHcrinMWhflBkmpWbZGwRL9/pNEgFR62cg4bhziUaWCR2 lZjSKXkdzS+3WjwdYwjT4ccT17ySbBfVc3mYjcQQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oliver Neukum , Grant Grundler , "David S. Miller" Subject: [PATCH 5.4 07/53] sr9700: sanity check for packet length Date: Mon, 28 Feb 2022 18:24:05 +0100 Message-Id: <20220228172248.850170902@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: Oliver Neukum commit e9da0b56fe27206b49f39805f7dcda8a89379062 upstream. A malicious device can leak heap data to user space providing bogus frame lengths. Introduce a sanity check. Signed-off-by: Oliver Neukum Reviewed-by: Grant Grundler Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- drivers/net/usb/sr9700.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/net/usb/sr9700.c +++ b/drivers/net/usb/sr9700.c @@ -410,7 +410,7 @@ static int sr9700_rx_fixup(struct usbnet /* ignore the CRC length */ len =3D (skb->data[1] | (skb->data[2] << 8)) - 4; =20 - if (len > ETH_FRAME_LEN) + if (len > ETH_FRAME_LEN || len > skb->len) return 0; =20 /* the last packet of current skb */ From nobody Tue Jun 23 18:14:07 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 E7D95C433EF for ; Mon, 28 Feb 2022 17:37:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233173AbiB1Rhj (ORCPT ); Mon, 28 Feb 2022 12:37:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232930AbiB1Rex (ORCPT ); Mon, 28 Feb 2022 12:34:53 -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 04A0F7DE3E; Mon, 28 Feb 2022 09:31: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 89590B815A6; Mon, 28 Feb 2022 17:31:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4F43C340E7; Mon, 28 Feb 2022 17:31:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069470; bh=hlaVVHROS+1+1hqghdgDQ6aqQYuXHJ1E37LvManwwR8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fHWh6dg6Qu6o2FfaoTOdarJ6bBie16xcWg3UpESXTNODOysJOYfh2A3q2w++oFhWM xSiYQvbIIEHOYQUE2B2rLkKDmgpBKGdqxpJLzLg/OBDiYQ9BZ3O1ZklYjp4204Cd9A tCXyxoXVCcj8yU0qHs/54reO4iOxjMyp3Wd6o1jo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oliver Neukum , Ross Maynard , "David S. Miller" Subject: [PATCH 5.4 08/53] USB: zaurus: support another broken Zaurus Date: Mon, 28 Feb 2022 18:24:06 +0100 Message-Id: <20220228172248.917252022@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: Oliver Neukum commit 6605cc67ca18b9d583eb96e18a20f5f4e726103c upstream. This SL-6000 says Direct Line, not Ethernet v2: added Reporter and Link Signed-off-by: Oliver Neukum Reported-by: Ross Maynard Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D215361 Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- drivers/net/usb/cdc_ether.c | 12 ++++++++++++ drivers/net/usb/zaurus.c | 12 ++++++++++++ 2 files changed, 24 insertions(+) --- a/drivers/net/usb/cdc_ether.c +++ b/drivers/net/usb/cdc_ether.c @@ -571,6 +571,11 @@ static const struct usb_device_id produc .bInterfaceSubClass =3D USB_CDC_SUBCLASS_ETHERNET, \ .bInterfaceProtocol =3D USB_CDC_PROTO_NONE =20 +#define ZAURUS_FAKE_INTERFACE \ + .bInterfaceClass =3D USB_CLASS_COMM, \ + .bInterfaceSubClass =3D USB_CDC_SUBCLASS_MDLM, \ + .bInterfaceProtocol =3D USB_CDC_PROTO_NONE + /* SA-1100 based Sharp Zaurus ("collie"), or compatible; * wire-incompatible with true CDC Ethernet implementations. * (And, it seems, needlessly so...) @@ -626,6 +631,13 @@ static const struct usb_device_id produc .driver_info =3D 0, }, { .match_flags =3D USB_DEVICE_ID_MATCH_INT_INFO + | USB_DEVICE_ID_MATCH_DEVICE, + .idVendor =3D 0x04DD, + .idProduct =3D 0x9032, /* SL-6000 */ + ZAURUS_FAKE_INTERFACE, + .driver_info =3D 0, +}, { + .match_flags =3D USB_DEVICE_ID_MATCH_INT_INFO | USB_DEVICE_ID_MATCH_DEVICE, .idVendor =3D 0x04DD, /* reported with some C860 units */ --- a/drivers/net/usb/zaurus.c +++ b/drivers/net/usb/zaurus.c @@ -256,6 +256,11 @@ static const struct usb_device_id produc .bInterfaceSubClass =3D USB_CDC_SUBCLASS_ETHERNET, \ .bInterfaceProtocol =3D USB_CDC_PROTO_NONE =20 +#define ZAURUS_FAKE_INTERFACE \ + .bInterfaceClass =3D USB_CLASS_COMM, \ + .bInterfaceSubClass =3D USB_CDC_SUBCLASS_MDLM, \ + .bInterfaceProtocol =3D USB_CDC_PROTO_NONE + /* SA-1100 based Sharp Zaurus ("collie"), or compatible. */ { .match_flags =3D USB_DEVICE_ID_MATCH_INT_INFO @@ -315,6 +320,13 @@ static const struct usb_device_id produc .driver_info =3D ZAURUS_PXA_INFO, }, { .match_flags =3D USB_DEVICE_ID_MATCH_INT_INFO + | USB_DEVICE_ID_MATCH_DEVICE, + .idVendor =3D 0x04DD, + .idProduct =3D 0x9032, /* SL-6000 */ + ZAURUS_FAKE_INTERFACE, + .driver_info =3D (unsigned long)&bogus_mdlm_info, +}, { + .match_flags =3D USB_DEVICE_ID_MATCH_INT_INFO | USB_DEVICE_ID_MATCH_DEVICE, .idVendor =3D 0x04DD, /* reported with some C860 units */ From nobody Tue Jun 23 18:14:07 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 A8B3DC4332F for ; Mon, 28 Feb 2022 17:37:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238325AbiB1Rht (ORCPT ); Mon, 28 Feb 2022 12:37:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238196AbiB1RfR (ORCPT ); Mon, 28 Feb 2022 12:35: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 1CD3686E36; Mon, 28 Feb 2022 09:31: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 dfw.source.kernel.org (Postfix) with ESMTPS id 852A461359; Mon, 28 Feb 2022 17:31:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9CC3FC340F5; Mon, 28 Feb 2022 17:31:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069473; bh=E7Nksd3jl9+VASg76mwSXa4BXe5fGV8PjlgQ+VkJpGo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SIEkD6EvBRB07jo2sfwwz/lp8TkOu78jNnqf8xBrXjOz7+6KxumbaR1JF8hnpgZdJ JsEdwxULajLlXFQvdLAXalEzMRt3Fp22Y3/HLIuwMIiZTAsl+C9ua9KIv273TrdLaP eTI4tKYfGh+7PwPG6fVtPmn5Go7ERMUcXaqaPHg4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pablo Neira Ayuso , Nick Gregory Subject: [PATCH 5.4 09/53] netfilter: nf_tables_offload: incorrect flow offload action array size Date: Mon, 28 Feb 2022 18:24:07 +0100 Message-Id: <20220228172248.987579826@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: Pablo Neira Ayuso commit b1a5983f56e371046dcf164f90bfaf704d2b89f6 upstream. immediate verdict expression needs to allocate one slot in the flow offload action array, however, immediate data expression does not need to do so. fwd and dup expression need to allocate one slot, this is missing. Add a new offload_action interface to report if this expression needs to allocate one slot in the flow offload action array. Fixes: be2861dc36d7 ("netfilter: nft_{fwd,dup}_netdev: add offload support") Reported-and-tested-by: Nick Gregory Signed-off-by: Pablo Neira Ayuso Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- include/net/netfilter/nf_tables.h | 2 +- include/net/netfilter/nf_tables_offload.h | 2 -- net/netfilter/nf_tables_offload.c | 3 ++- net/netfilter/nft_dup_netdev.c | 6 ++++++ net/netfilter/nft_fwd_netdev.c | 6 ++++++ net/netfilter/nft_immediate.c | 12 +++++++++++- 6 files changed, 26 insertions(+), 5 deletions(-) --- a/include/net/netfilter/nf_tables.h +++ b/include/net/netfilter/nf_tables.h @@ -805,7 +805,7 @@ struct nft_expr_ops { int (*offload)(struct nft_offload_ctx *ctx, struct nft_flow_rule *flow, const struct nft_expr *expr); - u32 offload_flags; + bool (*offload_action)(const struct nft_expr *expr); const struct nft_expr_type *type; void *data; }; --- a/include/net/netfilter/nf_tables_offload.h +++ b/include/net/netfilter/nf_tables_offload.h @@ -60,8 +60,6 @@ struct nft_flow_rule { struct flow_rule *rule; }; =20 -#define NFT_OFFLOAD_F_ACTION (1 << 0) - void nft_flow_rule_set_addr_type(struct nft_flow_rule *flow, enum flow_dissector_key_id addr_type); =20 --- a/net/netfilter/nf_tables_offload.c +++ b/net/netfilter/nf_tables_offload.c @@ -55,7 +55,8 @@ struct nft_flow_rule *nft_flow_rule_crea =20 expr =3D nft_expr_first(rule); while (nft_expr_more(rule, expr)) { - if (expr->ops->offload_flags & NFT_OFFLOAD_F_ACTION) + if (expr->ops->offload_action && + expr->ops->offload_action(expr)) num_actions++; =20 expr =3D nft_expr_next(expr); --- a/net/netfilter/nft_dup_netdev.c +++ b/net/netfilter/nft_dup_netdev.c @@ -67,6 +67,11 @@ static int nft_dup_netdev_offload(struct return nft_fwd_dup_netdev_offload(ctx, flow, FLOW_ACTION_MIRRED, oif); } =20 +static bool nft_dup_netdev_offload_action(const struct nft_expr *expr) +{ + return true; +} + static struct nft_expr_type nft_dup_netdev_type; static const struct nft_expr_ops nft_dup_netdev_ops =3D { .type =3D &nft_dup_netdev_type, @@ -75,6 +80,7 @@ static const struct nft_expr_ops nft_dup .init =3D nft_dup_netdev_init, .dump =3D nft_dup_netdev_dump, .offload =3D nft_dup_netdev_offload, + .offload_action =3D nft_dup_netdev_offload_action, }; =20 static struct nft_expr_type nft_dup_netdev_type __read_mostly =3D { --- a/net/netfilter/nft_fwd_netdev.c +++ b/net/netfilter/nft_fwd_netdev.c @@ -77,6 +77,11 @@ static int nft_fwd_netdev_offload(struct return nft_fwd_dup_netdev_offload(ctx, flow, FLOW_ACTION_REDIRECT, oif); } =20 +static bool nft_fwd_netdev_offload_action(const struct nft_expr *expr) +{ + return true; +} + struct nft_fwd_neigh { enum nft_registers sreg_dev:8; enum nft_registers sreg_addr:8; @@ -219,6 +224,7 @@ static const struct nft_expr_ops nft_fwd .dump =3D nft_fwd_netdev_dump, .validate =3D nft_fwd_validate, .offload =3D nft_fwd_netdev_offload, + .offload_action =3D nft_fwd_netdev_offload_action, }; =20 static const struct nft_expr_ops * --- a/net/netfilter/nft_immediate.c +++ b/net/netfilter/nft_immediate.c @@ -163,6 +163,16 @@ static int nft_immediate_offload(struct return 0; } =20 +static bool nft_immediate_offload_action(const struct nft_expr *expr) +{ + const struct nft_immediate_expr *priv =3D nft_expr_priv(expr); + + if (priv->dreg =3D=3D NFT_REG_VERDICT) + return true; + + return false; +} + static const struct nft_expr_ops nft_imm_ops =3D { .type =3D &nft_imm_type, .size =3D NFT_EXPR_SIZE(sizeof(struct nft_immediate_expr)), @@ -173,7 +183,7 @@ static const struct nft_expr_ops nft_imm .dump =3D nft_immediate_dump, .validate =3D nft_immediate_validate, .offload =3D nft_immediate_offload, - .offload_flags =3D NFT_OFFLOAD_F_ACTION, + .offload_action =3D nft_immediate_offload_action, }; =20 struct nft_expr_type nft_imm_type __read_mostly =3D { From nobody Tue Jun 23 18:14:07 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 EBFEDC433EF for ; Mon, 28 Feb 2022 17:34:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238081AbiB1Rfa (ORCPT ); Mon, 28 Feb 2022 12:35:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238544AbiB1Rdf (ORCPT ); Mon, 28 Feb 2022 12:33:35 -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 C0DCA532DD; Mon, 28 Feb 2022 09:30: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 1312A6140B; Mon, 28 Feb 2022 17:30:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 18116C340E7; Mon, 28 Feb 2022 17:30:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069410; bh=49R9t0N1JPLnjLMJR67fXWWq82987iXgrJZe1ehXUGc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ujboSzYVpaFHtu5ul9bhC7E20x5gkvIdt/9laBqo8VpK8U8AHP1D5b/dq9jk28t91 d3nv+cTUFI1FfgQEUVqdYLrPoLSLeQlmeNvkxIKpEChXphmMgl4J3kroQR8nE3s2hU et5fTddtQW1B3EJ1e4wQ/X1DkqbGyrnBGOvdOOy0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Brian Geffon , Willis Kung , Dave Hansen Subject: [PATCH 5.4 10/53] x86/fpu: Correct pkru/xstate inconsistency Date: Mon, 28 Feb 2022 18:24:08 +0100 Message-Id: <20220228172249.060996561@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: Brian Geffon When eagerly switching PKRU in switch_fpu_finish() it checks that current is not a kernel thread as kernel threads will never use PKRU. It's possible that this_cpu_read_stable() on current_task (ie. get_current()) is returning an old cached value. To resolve this reference next_p directly rather than relying on current. As written it's possible when switching from a kernel thread to a userspace thread to observe a cached PF_KTHREAD flag and never restore the PKRU. And as a result this issue only occurs when switching from a kernel thread to a userspace thread, switching from a non kernel thread works perfectly fine because all that is considered in that situation are the flags from some other non kernel task and the next fpu is passed in to switch_fpu_finish(). This behavior only exists between 5.2 and 5.13 when it was fixed by a rewrite decoupling PKRU from xstate, in: commit 954436989cc5 ("x86/fpu: Remove PKRU handling from switch_fpu_finis= h()") Unfortunately backporting the fix from 5.13 is probably not realistic as it's part of a 60+ patch series which rewrites most of the PKRU handling. Fixes: 0cecca9d03c9 ("x86/fpu: Eager switch PKRU state") Signed-off-by: Brian Geffon Signed-off-by: Willis Kung Tested-by: Willis Kung Cc: # v5.4.x Cc: # v5.10.x Acked-by: Dave Hansen Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- arch/x86/include/asm/fpu/internal.h | 13 ++++++++----- arch/x86/kernel/process_32.c | 6 ++---- arch/x86/kernel/process_64.c | 6 ++---- 3 files changed, 12 insertions(+), 13 deletions(-) --- a/arch/x86/include/asm/fpu/internal.h +++ b/arch/x86/include/asm/fpu/internal.h @@ -560,9 +560,11 @@ static inline void __fpregs_load_activat * The FPU context is only stored/restored for a user task and * PF_KTHREAD is used to distinguish between kernel and user threads. */ -static inline void switch_fpu_prepare(struct fpu *old_fpu, int cpu) +static inline void switch_fpu_prepare(struct task_struct *prev, int cpu) { - if (static_cpu_has(X86_FEATURE_FPU) && !(current->flags & PF_KTHREAD)) { + struct fpu *old_fpu =3D &prev->thread.fpu; + + if (static_cpu_has(X86_FEATURE_FPU) && !(prev->flags & PF_KTHREAD)) { if (!copy_fpregs_to_fpstate(old_fpu)) old_fpu->last_cpu =3D -1; else @@ -581,10 +583,11 @@ static inline void switch_fpu_prepare(st * Load PKRU from the FPU context if available. Delay loading of the * complete FPU state until the return to userland. */ -static inline void switch_fpu_finish(struct fpu *new_fpu) +static inline void switch_fpu_finish(struct task_struct *next) { u32 pkru_val =3D init_pkru_value; struct pkru_state *pk; + struct fpu *next_fpu =3D &next->thread.fpu; =20 if (!static_cpu_has(X86_FEATURE_FPU)) return; @@ -598,7 +601,7 @@ static inline void switch_fpu_finish(str * PKRU state is switched eagerly because it needs to be valid before we * return to userland e.g. for a copy_to_user() operation. */ - if (!(current->flags & PF_KTHREAD)) { + if (!(next->flags & PF_KTHREAD)) { /* * If the PKRU bit in xsave.header.xfeatures is not set, * then the PKRU component was in init state, which means @@ -607,7 +610,7 @@ static inline void switch_fpu_finish(str * in memory is not valid. This means pkru_val has to be * set to 0 and not to init_pkru_value. */ - pk =3D get_xsave_addr(&new_fpu->state.xsave, XFEATURE_PKRU); + pk =3D get_xsave_addr(&next_fpu->state.xsave, XFEATURE_PKRU); pkru_val =3D pk ? pk->pkru : 0; } __write_pkru(pkru_val); --- a/arch/x86/kernel/process_32.c +++ b/arch/x86/kernel/process_32.c @@ -229,14 +229,12 @@ __switch_to(struct task_struct *prev_p, { struct thread_struct *prev =3D &prev_p->thread, *next =3D &next_p->thread; - struct fpu *prev_fpu =3D &prev->fpu; - struct fpu *next_fpu =3D &next->fpu; int cpu =3D smp_processor_id(); =20 /* never put a printk in __switch_to... printk() calls wake_up*() indirec= tly */ =20 if (!test_thread_flag(TIF_NEED_FPU_LOAD)) - switch_fpu_prepare(prev_fpu, cpu); + switch_fpu_prepare(prev_p, cpu); =20 /* * Save away %gs. No need to save %fs, as it was saved on the @@ -292,7 +290,7 @@ __switch_to(struct task_struct *prev_p, =20 this_cpu_write(current_task, next_p); =20 - switch_fpu_finish(next_fpu); + switch_fpu_finish(next_p); =20 /* Load the Intel cache allocation PQR MSR. */ resctrl_sched_in(); --- a/arch/x86/kernel/process_64.c +++ b/arch/x86/kernel/process_64.c @@ -505,15 +505,13 @@ __switch_to(struct task_struct *prev_p, { struct thread_struct *prev =3D &prev_p->thread; struct thread_struct *next =3D &next_p->thread; - struct fpu *prev_fpu =3D &prev->fpu; - struct fpu *next_fpu =3D &next->fpu; int cpu =3D smp_processor_id(); =20 WARN_ON_ONCE(IS_ENABLED(CONFIG_DEBUG_ENTRY) && this_cpu_read(irq_count) !=3D -1); =20 if (!test_thread_flag(TIF_NEED_FPU_LOAD)) - switch_fpu_prepare(prev_fpu, cpu); + switch_fpu_prepare(prev_p, cpu); =20 /* We must save %fs and %gs before load_TLS() because * %fs and %gs may be cleared by load_TLS(). @@ -565,7 +563,7 @@ __switch_to(struct task_struct *prev_p, this_cpu_write(current_task, next_p); this_cpu_write(cpu_current_top_of_stack, task_top_of_stack(next_p)); =20 - switch_fpu_finish(next_fpu); + switch_fpu_finish(next_p); =20 /* Reload sp0. */ update_task_stack(next_p); From nobody Tue Jun 23 18:14:07 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 C913DC433EF for ; Mon, 28 Feb 2022 17:36:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238172AbiB1Rgn (ORCPT ); Mon, 28 Feb 2022 12:36:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238571AbiB1Rdi (ORCPT ); Mon, 28 Feb 2022 12:33:38 -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 DA5419134B; Mon, 28 Feb 2022 09:30: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 7978CB815A6; Mon, 28 Feb 2022 17:30:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D641DC340E7; Mon, 28 Feb 2022 17:30:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069413; bh=qrgm1kzt2di1ONuE+6wLgytVgwd7igoW8PBsESMIvNk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CJyBm8lJ8wBMksBhTSMVdN0/x8lOhdIq9JFfWQWAeZQ87ByjQD33YAqvuKK3pEaGN oCgiclX5hNEGMC4dbCYgwBAcUoWd5gkYBWnITU9QAm9drdFJBsnMIShzLd0OFPjC1+ EwdXNHojKMU/BvmW8DVSnzPdIJVEK3YxgvtXp+ys= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sumit Garg , Jens Wiklander Subject: [PATCH 5.4 11/53] tee: export teedev_open() and teedev_close_context() Date: Mon, 28 Feb 2022 18:24:09 +0100 Message-Id: <20220228172249.155940685@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: Jens Wiklander commit 1e2c3ef0496e72ba9001da5fd1b7ed56ccb30597 upstream. Exports the two functions teedev_open() and teedev_close_context() in order to make it easier to create a driver internal struct tee_context. Reviewed-by: Sumit Garg Signed-off-by: Jens Wiklander Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- drivers/tee/tee_core.c | 6 ++++-- include/linux/tee_drv.h | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) --- a/drivers/tee/tee_core.c +++ b/drivers/tee/tee_core.c @@ -28,7 +28,7 @@ static DEFINE_SPINLOCK(driver_lock); static struct class *tee_class; static dev_t tee_devt; =20 -static struct tee_context *teedev_open(struct tee_device *teedev) +struct tee_context *teedev_open(struct tee_device *teedev) { int rc; struct tee_context *ctx; @@ -56,6 +56,7 @@ err: return ERR_PTR(rc); =20 } +EXPORT_SYMBOL_GPL(teedev_open); =20 void teedev_ctx_get(struct tee_context *ctx) { @@ -82,13 +83,14 @@ void teedev_ctx_put(struct tee_context * kref_put(&ctx->refcount, teedev_ctx_release); } =20 -static void teedev_close_context(struct tee_context *ctx) +void teedev_close_context(struct tee_context *ctx) { struct tee_device *teedev =3D ctx->teedev; =20 teedev_ctx_put(ctx); tee_device_put(teedev); } +EXPORT_SYMBOL_GPL(teedev_close_context); =20 static int tee_open(struct inode *inode, struct file *filp) { --- a/include/linux/tee_drv.h +++ b/include/linux/tee_drv.h @@ -579,4 +579,18 @@ struct tee_client_driver { #define to_tee_client_driver(d) \ container_of(d, struct tee_client_driver, driver) =20 +/** + * teedev_open() - Open a struct tee_device + * @teedev: Device to open + * + * @return a pointer to struct tee_context on success or an ERR_PTR on fai= lure. + */ +struct tee_context *teedev_open(struct tee_device *teedev); + +/** + * teedev_close_context() - closes a struct tee_context + * @ctx: The struct tee_context to close + */ +void teedev_close_context(struct tee_context *ctx); + #endif /*__TEE_DRV_H*/ From nobody Tue Jun 23 18:14:07 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 3E9BAC433EF for ; Mon, 28 Feb 2022 17:35:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238195AbiB1Rfk (ORCPT ); Mon, 28 Feb 2022 12:35:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238580AbiB1Rdj (ORCPT ); Mon, 28 Feb 2022 12:33: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 9B8FB91362; Mon, 28 Feb 2022 09:30: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 31F5EB815AB; Mon, 28 Feb 2022 17:30:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8CF38C340E7; Mon, 28 Feb 2022 17:30:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069415; bh=yeJfOGJrMUlxZx29TMGSAZrifFNOcX1OnMrinSFVYxk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G8xdBoqR7ogPx+aBMR4WiuMJC2FpB4zCyKxeVQeKe5kzTaivyGGdYNysqsSnWzd3c kW+C60yVS1n2cpe7OW5l8Q8ivZzyRJRujs0Nt7Izh+BNsLOiA5WwsmtiIMXYgj04dj YaAVAIQxRc1YLkZlZNksHmJ9l5hA6ZKAKrATLO3o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lars Persson , Sumit Garg , Jens Wiklander Subject: [PATCH 5.4 12/53] optee: use driver internal tee_context for some rpc Date: Mon, 28 Feb 2022 18:24:10 +0100 Message-Id: <20220228172249.224833311@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: Jens Wiklander commit aceeafefff736057e8f93f19bbfbef26abd94604 upstream. Adds a driver private tee_context by moving the tee_context in struct optee_notif to struct optee. This tee_context was previously used when doing internal calls to secure world to deliver notification. The new driver internal tee_context is now also when allocating driver private shared memory. This decouples the shared memory object from its original tee_context. This is needed when the life time of such a memory allocation outlives the client tee_context. This patch fixes the problem described below: The addition of a shutdown hook by commit f25889f93184 ("optee: fix tee out of memory failure seen during kexec reboot") introduced a kernel shutdown regression that can be triggered after running the OP-TEE xtest suites. Once the shutdown hook is called it is not possible to communicate any more with the supplicant process because the system is not scheduling task any longer. Thus if the optee driver shutdown path receives a supplicant RPC request from the OP-TEE we will deadlock the kernel's shutdown. Fixes: f25889f93184 ("optee: fix tee out of memory failure seen during kexe= c reboot") Fixes: 217e0250cccb ("tee: use reference counting for tee_context") Reported-by: Lars Persson Cc: stable@vger.kernel.org Reviewed-by: Sumit Garg Signed-off-by: Jens Wiklander [JW: backport to 5.4-stable + update commit message] Signed-off-by: Jens Wiklander Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- drivers/tee/optee/core.c | 8 ++++++++ drivers/tee/optee/optee_private.h | 2 ++ drivers/tee/optee/rpc.c | 8 +++++--- 3 files changed, 15 insertions(+), 3 deletions(-) --- a/drivers/tee/optee/core.c +++ b/drivers/tee/optee/core.c @@ -552,6 +552,7 @@ static struct optee *optee_probe(struct struct optee *optee =3D NULL; void *memremaped_shm =3D NULL; struct tee_device *teedev; + struct tee_context *ctx; u32 sec_caps; int rc; =20 @@ -631,6 +632,12 @@ static struct optee *optee_probe(struct optee_supp_init(&optee->supp); optee->memremaped_shm =3D memremaped_shm; optee->pool =3D pool; + ctx =3D teedev_open(optee->teedev); + if (IS_ERR(ctx)) { + rc =3D PTR_ERR(ctx); + goto err; + } + optee->ctx =3D ctx; =20 /* * Ensure that there are no pre-existing shm objects before enabling @@ -667,6 +674,7 @@ err: =20 static void optee_remove(struct optee *optee) { + teedev_close_context(optee->ctx); /* * Ask OP-TEE to free all cached shared memory objects to decrease * reference counters and also avoid wild pointers in secure world --- a/drivers/tee/optee/optee_private.h +++ b/drivers/tee/optee/optee_private.h @@ -69,6 +69,7 @@ struct optee_supp { * struct optee - main service struct * @supp_teedev: supplicant device * @teedev: client device + * @ctx: driver internal TEE context * @invoke_fn: function to issue smc or hvc * @call_queue: queue of threads waiting to call @invoke_fn * @wait_queue: queue of threads from secure world waiting for a @@ -83,6 +84,7 @@ struct optee { struct tee_device *supp_teedev; struct tee_device *teedev; optee_invoke_fn *invoke_fn; + struct tee_context *ctx; struct optee_call_queue call_queue; struct optee_wait_queue wait_queue; struct optee_supp supp; --- a/drivers/tee/optee/rpc.c +++ b/drivers/tee/optee/rpc.c @@ -191,6 +191,7 @@ static struct tee_shm *cmd_alloc_suppl(s } =20 static void handle_rpc_func_cmd_shm_alloc(struct tee_context *ctx, + struct optee *optee, struct optee_msg_arg *arg, struct optee_call_ctx *call_ctx) { @@ -220,7 +221,8 @@ static void handle_rpc_func_cmd_shm_allo shm =3D cmd_alloc_suppl(ctx, sz); break; case OPTEE_MSG_RPC_SHM_TYPE_KERNEL: - shm =3D tee_shm_alloc(ctx, sz, TEE_SHM_MAPPED | TEE_SHM_PRIV); + shm =3D tee_shm_alloc(optee->ctx, sz, + TEE_SHM_MAPPED | TEE_SHM_PRIV); break; default: arg->ret =3D TEEC_ERROR_BAD_PARAMETERS; @@ -377,7 +379,7 @@ static void handle_rpc_func_cmd(struct t break; case OPTEE_MSG_RPC_CMD_SHM_ALLOC: free_pages_list(call_ctx); - handle_rpc_func_cmd_shm_alloc(ctx, arg, call_ctx); + handle_rpc_func_cmd_shm_alloc(ctx, optee, arg, call_ctx); break; case OPTEE_MSG_RPC_CMD_SHM_FREE: handle_rpc_func_cmd_shm_free(ctx, arg); @@ -405,7 +407,7 @@ void optee_handle_rpc(struct tee_context =20 switch (OPTEE_SMC_RETURN_GET_RPC_FUNC(param->a0)) { case OPTEE_SMC_RPC_FUNC_ALLOC: - shm =3D tee_shm_alloc(ctx, param->a1, + shm =3D tee_shm_alloc(optee->ctx, param->a1, TEE_SHM_MAPPED | TEE_SHM_PRIV); if (!IS_ERR(shm) && !tee_shm_get_pa(shm, 0, &pa)) { reg_pair_from_64(¶m->a1, ¶m->a2, pa); From nobody Tue Jun 23 18:14:07 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 B12B3C433F5 for ; Mon, 28 Feb 2022 17:34:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238033AbiB1Rff (ORCPT ); Mon, 28 Feb 2022 12:35:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238584AbiB1Rdj (ORCPT ); Mon, 28 Feb 2022 12:33:39 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4944591371; Mon, 28 Feb 2022 09:30: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 dfw.source.kernel.org (Postfix) with ESMTPS id 2A45D61467; Mon, 28 Feb 2022 17:30:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35A7AC340E7; Mon, 28 Feb 2022 17:30:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069418; bh=Qx3WmNxbLHcmR/rJ6GxsuLHqpy+dv54vnH8mcMpNWYU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oy/PeUgKYE9OwRBCHbmhL9CoDxpC90m2lOCNxBTBQCJ89U76aIBmjUrvNO8BbSNND EBIDgzXxs+5OsbVQ32eU3aFQNmohgVtmue2PaM54PT1U0QiTRDnkueirxVP8uJtW9B pZdKkAyrx70HYGIQubsAuEU7PecJlDtU1FNLSxVI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alessandro B Maurici , Heiner Kallweit , Andrew Lunn , Jakub Kicinski , dann frazier Subject: [PATCH 5.4 13/53] lan743x: fix deadlock in lan743x_phy_link_status_change() Date: Mon, 28 Feb 2022 18:24:11 +0100 Message-Id: <20220228172249.292224321@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: Heiner Kallweit commit ddb826c2c92d461f290a7bab89e7c28696191875 upstream. Usage of phy_ethtool_get_link_ksettings() in the link status change handler isn't needed, and in combination with the referenced change it results in a deadlock. Simply remove the call and replace it with direct access to phydev->speed. The duplex argument of lan743x_phy_update_flowcontrol() isn't used and can be removed. Fixes: c10a485c3de5 ("phy: phy_ethtool_ksettings_get: Lock the phy for cons= istency") Reported-by: Alessandro B Maurici Tested-by: Alessandro B Maurici Signed-off-by: Heiner Kallweit Reviewed-by: Andrew Lunn Link: https://lore.kernel.org/r/40e27f76-0ba3-dcef-ee32-a78b9df38b0f@gmail.= com Signed-off-by: Jakub Kicinski [dannf: adjust context] Signed-off-by: dann frazier Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- --- drivers/net/ethernet/microchip/lan743x_main.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) --- a/drivers/net/ethernet/microchip/lan743x_main.c +++ b/drivers/net/ethernet/microchip/lan743x_main.c @@ -916,8 +916,7 @@ static int lan743x_phy_reset(struct lan7 } =20 static void lan743x_phy_update_flowcontrol(struct lan743x_adapter *adapter, - u8 duplex, u16 local_adv, - u16 remote_adv) + u16 local_adv, u16 remote_adv) { struct lan743x_phy *phy =3D &adapter->phy; u8 cap; @@ -944,22 +943,17 @@ static void lan743x_phy_link_status_chan =20 phy_print_status(phydev); if (phydev->state =3D=3D PHY_RUNNING) { - struct ethtool_link_ksettings ksettings; int remote_advertisement =3D 0; int local_advertisement =3D 0; =20 - memset(&ksettings, 0, sizeof(ksettings)); - phy_ethtool_get_link_ksettings(netdev, &ksettings); local_advertisement =3D linkmode_adv_to_mii_adv_t(phydev->advertising); remote_advertisement =3D linkmode_adv_to_mii_adv_t(phydev->lp_advertising); =20 - lan743x_phy_update_flowcontrol(adapter, - ksettings.base.duplex, - local_advertisement, + lan743x_phy_update_flowcontrol(adapter, local_advertisement, remote_advertisement); - lan743x_ptp_update_latency(adapter, ksettings.base.speed); + lan743x_ptp_update_latency(adapter, phydev->speed); } } From nobody Tue Jun 23 18:14:07 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 366D2C433F5 for ; Mon, 28 Feb 2022 17:35:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232630AbiB1Rfp (ORCPT ); Mon, 28 Feb 2022 12:35:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238633AbiB1Rdl (ORCPT ); Mon, 28 Feb 2022 12:33:41 -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 7163891AFB; Mon, 28 Feb 2022 09:30: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 D5E4D61358; Mon, 28 Feb 2022 17:30:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE641C340E7; Mon, 28 Feb 2022 17:30:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069421; bh=6dmsWtF2WF6CEy7yiT59gPr76gbVM+Z8NfW08yZAGbI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TPS5+MjFtP6BJa2n2T2YJIAV/jEpuGOaqu4vHHfZyaiMjlXcdPwKY4icmenU5vjRD rqfqGhWAbBhMPHG5fH+skplrCgoM/au4c/uueXOuBENGqAWYIHwJhpyR84eLD8qVgN v0dBgX+PspDC6xeJH28WfPw7MalxdMgCukSH2dWA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jakub Kicinski , Xin Long Subject: [PATCH 5.4 14/53] ping: remove pr_err from ping_lookup Date: Mon, 28 Feb 2022 18:24:12 +0100 Message-Id: <20220228172249.363203863@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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 Long commit cd33bdcbead882c2e58fdb4a54a7bd75b610a452 upstream. As Jakub noticed, prints should be avoided on the datapath. Also, as packets would never come to the else branch in ping_lookup(), remove pr_err() from ping_lookup(). Fixes: 35a79e64de29 ("ping: fix the dif and sdif check in ping_lookup") Reported-by: Jakub Kicinski Signed-off-by: Xin Long Link: https://lore.kernel.org/r/1ef3f2fcd31bd681a193b1fcf235eee1603819bd.16= 45674068.git.lucien.xin@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- net/ipv4/ping.c | 1 - 1 file changed, 1 deletion(-) --- a/net/ipv4/ping.c +++ b/net/ipv4/ping.c @@ -187,7 +187,6 @@ static struct sock *ping_lookup(struct n (int)ident, &ipv6_hdr(skb)->daddr, dif); #endif } else { - pr_err("ping: protocol(%x) is not supported\n", ntohs(skb->protocol)); return NULL; } From nobody Tue Jun 23 18:14:07 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 65B67C433FE for ; Mon, 28 Feb 2022 17:35:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237455AbiB1RgC (ORCPT ); Mon, 28 Feb 2022 12:36:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238634AbiB1Rdl (ORCPT ); Mon, 28 Feb 2022 12:33:41 -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 AEFBF91AF7; Mon, 28 Feb 2022 09:30:24 -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 8D5F6612FA; Mon, 28 Feb 2022 17:30:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A292C340F5; Mon, 28 Feb 2022 17:30:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069424; bh=P9+8LyoE7wfKYtVa8BQKxcGYP08SrbQhU1GkxwKfPiQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YRiy8wbSNxOjtjV39dOCkaiy+GL0vCh/c22KoSnjQuLbQ0CnZIUbSPCT1NyJNm/CD 1FrqISLSXx0bvlTRgaZFnEm75LNBQs7MuibTs7x4psEls2aH+Gd4WJUSWDvycwSRf0 5GZOlZCILCQ3S+DHY55tMo+99E1LGPU5ZTynNhoI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexey Bayduraev , Jiri Olsa , Adrian Hunter , Alexander Antonov , Alexander Shishkin , Alexei Budankov , Andi Kleen , Ingo Molnar , Namhyung Kim , Peter Zijlstra , Arnaldo Carvalho de Melo Subject: [PATCH 5.4 15/53] perf data: Fix double free in perf_session__delete() Date: Mon, 28 Feb 2022 18:24:13 +0100 Message-Id: <20220228172249.441146466@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: Alexey Bayduraev commit 69560e366fc4d5fca7bebb0e44edbfafc8bcaf05 upstream. When perf_data__create_dir() fails, it calls close_dir(), but perf_session__delete() also calls close_dir() and since dir.version and dir.nr were initialized by perf_data__create_dir(), a double free occurs. This patch moves the initialization of dir.version and dir.nr after successful initialization of dir.files, that prevents double freeing. This behavior is already implemented in perf_data__open_dir(). Fixes: 145520631130bd64 ("perf data: Add perf_data__(create_dir|close_dir) = functions") Signed-off-by: Alexey Bayduraev Acked-by: Jiri Olsa Cc: Adrian Hunter Cc: Alexander Antonov Cc: Alexander Shishkin Cc: Alexei Budankov Cc: Andi Kleen Cc: Ingo Molnar Cc: Namhyung Kim Cc: Peter Zijlstra Link: https://lore.kernel.org/r/20220218152341.5197-2-alexey.v.bayduraev@li= nux.intel.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- tools/perf/util/data.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) --- a/tools/perf/util/data.c +++ b/tools/perf/util/data.c @@ -44,10 +44,6 @@ int perf_data__create_dir(struct perf_da if (!files) return -ENOMEM; =20 - data->dir.version =3D PERF_DIR_VERSION; - data->dir.files =3D files; - data->dir.nr =3D nr; - for (i =3D 0; i < nr; i++) { struct perf_data_file *file =3D &files[i]; =20 @@ -62,6 +58,9 @@ int perf_data__create_dir(struct perf_da file->fd =3D ret; } =20 + data->dir.version =3D PERF_DIR_VERSION; + data->dir.files =3D files; + data->dir.nr =3D nr; return 0; =20 out_err: From nobody Tue Jun 23 18:14:07 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 B026AC433FE for ; Mon, 28 Feb 2022 17:35:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238178AbiB1RgG (ORCPT ); Mon, 28 Feb 2022 12:36:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238660AbiB1Rdn (ORCPT ); Mon, 28 Feb 2022 12:33:43 -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 7C33292851; Mon, 28 Feb 2022 09:30: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 EFD36B815B8; Mon, 28 Feb 2022 17:30:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B24AC340E7; Mon, 28 Feb 2022 17:30:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069426; bh=ACLnAZQIR5psZ8uhJCL76WGjXIdm6NzshqJBZPCBeCU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BUA5lYkLWFOE6AtZc7OXFmSDOig08O9wBLKP/0O0tQyZ8jBws5/A9/Pwc//yPts72 cpzw+hssUqv9vVv0w5lhtrCUrujbnueoHSog1mzVaR0gwCxoU3YbbX2EqwGBiWEFKf SdG5M6jqYM6VFWmRwCNW7CtnQB3fxGOZrTspKir4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Felix Maurer , Daniel Borkmann , Yonghong Song , John Fastabend Subject: [PATCH 5.4 16/53] bpf: Do not try bpf_msg_push_data with len 0 Date: Mon, 28 Feb 2022 18:24:14 +0100 Message-Id: <20220228172249.525088925@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: Felix Maurer commit 4a11678f683814df82fca9018d964771e02d7e6d upstream. If bpf_msg_push_data() is called with len 0 (as it happens during selftests/bpf/test_sockmap), we do not need to do anything and can return early. Calling bpf_msg_push_data() with len 0 previously lead to a wrong ENOMEM error: we later called get_order(copy + len); if len was 0, copy + len was also often 0 and get_order() returned some undefined value (at the moment 52). alloc_pages() caught that and failed, but then bpf_msg_push_dat= a() returned ENOMEM. This was wrong because we are most probably not out of memory and actually do not need any additional memory. Fixes: 6fff607e2f14b ("bpf: sk_msg program helper bpf_msg_push_data") Signed-off-by: Felix Maurer Signed-off-by: Daniel Borkmann Acked-by: Yonghong Song Acked-by: John Fastabend Link: https://lore.kernel.org/bpf/df69012695c7094ccb1943ca02b4920db3537466.= 1644421921.git.fmaurer@redhat.com Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- net/core/filter.c | 3 +++ 1 file changed, 3 insertions(+) --- a/net/core/filter.c +++ b/net/core/filter.c @@ -2516,6 +2516,9 @@ BPF_CALL_4(bpf_msg_pop_data, struct sk_m if (unlikely(flags)) return -EINVAL; =20 + if (unlikely(len =3D=3D 0)) + return 0; + /* First find the starting scatterlist element */ i =3D msg->sg.start; do { From nobody Tue Jun 23 18:14:07 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 A78B1C433F5 for ; Mon, 28 Feb 2022 17:35:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238213AbiB1RgL (ORCPT ); Mon, 28 Feb 2022 12:36:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238736AbiB1Rds (ORCPT ); Mon, 28 Feb 2022 12:33:48 -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 EE8F492D14; Mon, 28 Feb 2022 09:30: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 02D42B815A6; Mon, 28 Feb 2022 17:30:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 54B97C340E7; Mon, 28 Feb 2022 17:30:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069429; bh=RMBC6hs6l1n266HoDM4V7/z0N4puqLKn/zyTHSm1gxU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l72Mw3/GNXXb7lkqdcwoqilDptdH3bDhD0B21IepQvGggcl3p++bGZi09pTFhgsGK HiN/3G3cft3ZKBdVqEebBYH7RbQTuCd0R1f9S+Ge29c0dHTkvRGzpYryp/aeVCH7YR +kBzzfTHggpzndJLJ7Uxfq1a6AjsXhEuNCyJwlSg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , Jakub Kicinski Subject: [PATCH 5.4 17/53] net: __pskb_pull_tail() & pskb_carve_frag_list() drop_monitor friends Date: Mon, 28 Feb 2022 18:24:15 +0100 Message-Id: <20220228172249.581172789@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: Eric Dumazet commit ef527f968ae05c6717c39f49c8709a7e2c19183a upstream. Whenever one of these functions pull all data from an skb in a frag_list, use consume_skb() instead of kfree_skb() to avoid polluting drop monitoring. Fixes: 6fa01ccd8830 ("skbuff: Add pskb_extract() helper function") Signed-off-by: Eric Dumazet Link: https://lore.kernel.org/r/20220220154052.1308469-1-eric.dumazet@gmail= .com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- net/core/skbuff.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -2139,7 +2139,7 @@ void *__pskb_pull_tail(struct sk_buff *s /* Free pulled out fragments. */ while ((list =3D skb_shinfo(skb)->frag_list) !=3D insp) { skb_shinfo(skb)->frag_list =3D list->next; - kfree_skb(list); + consume_skb(list); } /* And insert new clone at head. */ if (clone) { @@ -5846,7 +5846,7 @@ static int pskb_carve_frag_list(struct s /* Free pulled out fragments. */ while ((list =3D shinfo->frag_list) !=3D insp) { shinfo->frag_list =3D list->next; - kfree_skb(list); + consume_skb(list); } /* And insert new clone at head. */ if (clone) { From nobody Tue Jun 23 18:14:07 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 BA8B0C433F5 for ; Mon, 28 Feb 2022 17:36:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238250AbiB1Rgv (ORCPT ); Mon, 28 Feb 2022 12:36:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238737AbiB1Rds (ORCPT ); Mon, 28 Feb 2022 12:33:48 -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 7939492D24; Mon, 28 Feb 2022 09:30: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 0859F61359; Mon, 28 Feb 2022 17:30:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 104C7C340E7; Mon, 28 Feb 2022 17:30:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069432; bh=60HXZVWxDSLdoAjPwuYTkh8TQJyS7vj0cIEYlcOXRx0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lxJ19rSzOu6yhNNdhJz7RCYpH8dYW3buTAgj/bkFs6Obz5pMfRJBL3IM3g7NcfJTl ox28gDsbbZObrvzGgsq3nuVnMqOEsO2khTGOL4sLI7krTRYfiVkvNl8A/DnwNhTGd8 Ea8yflsszKqqBjgjvROzYbZWTzQXPduX1uPCU2+M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , "David S. Miller" Subject: [PATCH 5.4 18/53] tipc: Fix end of loop tests for list_for_each_entry() Date: Mon, 28 Feb 2022 18:24:16 +0100 Message-Id: <20220228172249.637915224@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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 a1f8fec4dac8bc7b172b2bdbd881e015261a6322 upstream. These tests are supposed to check if the loop exited via a break or not. However the tests are wrong because if we did not exit via a break then "p" is not a valid pointer. In that case, it's the equivalent of "if (*(u32 *)sr =3D=3D *last_key) {". That's going to work most of the tim= e, but there is a potential for those to be equal. Fixes: 1593123a6a49 ("tipc: add name table dump to new netlink api") Fixes: 1a1a143daf84 ("tipc: add publication dump to new netlink api") Signed-off-by: Dan Carpenter Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- net/tipc/name_table.c | 2 +- net/tipc/socket.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) --- a/net/tipc/name_table.c +++ b/net/tipc/name_table.c @@ -812,7 +812,7 @@ static int __tipc_nl_add_nametable_publ( list_for_each_entry(p, &sr->all_publ, all_publ) if (p->key =3D=3D *last_key) break; - if (p->key !=3D *last_key) + if (list_entry_is_head(p, &sr->all_publ, all_publ)) return -EPIPE; } else { p =3D list_first_entry(&sr->all_publ, --- a/net/tipc/socket.c +++ b/net/tipc/socket.c @@ -3590,7 +3590,7 @@ static int __tipc_nl_list_sk_publ(struct if (p->key =3D=3D *last_publ) break; } - if (p->key !=3D *last_publ) { + if (list_entry_is_head(p, &tsk->publications, binding_sock)) { /* We never set seq or call nl_dump_check_consistent() * this means that setting prev_seq here will cause the * consistence check to fail in the netlink callback From nobody Tue Jun 23 18:14:07 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 4503FC433F5 for ; Mon, 28 Feb 2022 17:36:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238341AbiB1Rg7 (ORCPT ); Mon, 28 Feb 2022 12:36:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238830AbiB1Rdz (ORCPT ); Mon, 28 Feb 2022 12:33:55 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD27677A93; Mon, 28 Feb 2022 09:30: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 5E84DB815AB; Mon, 28 Feb 2022 17:30:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B61EFC340F4; Mon, 28 Feb 2022 17:30:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069435; bh=SvDQLbu5beE3Sm6Z67NDVZ7DhnI92oBSclkppH4UUcM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XJSqc94YLfeE1u02Zg50p9SWGd25Vq+3XyQqqJbOwQrB/0+D6Dgn2BbEXI6/lOMpa zZjJMXsOhzarB+nRrgBN73gsyWASbVlmt1MacCUJGJf80O9pu5aYqHZK+lUjhkZauX avvp0TP2V4f+EcJkoxR8v21r+uQ0XC1ku1XIes9c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tao Liu , Willem de Bruijn , "David S. Miller" Subject: [PATCH 5.4 19/53] gso: do not skip outer ip header in case of ipip and net_failover Date: Mon, 28 Feb 2022 18:24:17 +0100 Message-Id: <20220228172249.730686703@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: Tao Liu commit cc20cced0598d9a5ff91ae4ab147b3b5e99ee819 upstream. We encounter a tcp drop issue in our cloud environment. Packet GROed in host forwards to a VM virtio_net nic with net_failover enabled. VM acts as a IPVS LB with ipip encapsulation. The full path like: host gro -> vm virtio_net rx -> net_failover rx -> ipvs fullnat -> ipip encap -> net_failover tx -> virtio_net tx When net_failover transmits a ipip pkt (gso_type =3D 0x0103, which means SKB_GSO_TCPV4, SKB_GSO_DODGY and SKB_GSO_IPXIP4), there is no gso did because it supports TSO and GSO_IPXIP4. But network_header points to inner ip header. Call Trace: tcp4_gso_segment ------> return NULL inet_gso_segment ------> inner iph, network_header points to ipip_gso_segment inet_gso_segment ------> outer iph skb_mac_gso_segment Afterwards virtio_net transmits the pkt, only inner ip header is modified. And the outer one just keeps unchanged. The pkt will be dropped in remote host. Call Trace: inet_gso_segment ------> inner iph, outer iph is skipped skb_mac_gso_segment __skb_gso_segment validate_xmit_skb validate_xmit_skb_list sch_direct_xmit __qdisc_run __dev_queue_xmit ------> virtio_net dev_hard_start_xmit __dev_queue_xmit ------> net_failover ip_finish_output2 ip_output iptunnel_xmit ip_tunnel_xmit ipip_tunnel_xmit ------> ipip dev_hard_start_xmit __dev_queue_xmit ip_finish_output2 ip_output ip_forward ip_rcv __netif_receive_skb_one_core netif_receive_skb_internal napi_gro_receive receive_buf virtnet_poll net_rx_action The root cause of this issue is specific with the rare combination of SKB_GSO_DODGY and a tunnel device that adds an SKB_GSO_ tunnel option. SKB_GSO_DODGY is set from external virtio_net. We need to reset network header when callbacks.gso_segment() returns NULL. This patch also includes ipv6_gso_segment(), considering SIT, etc. Fixes: cb32f511a70b ("ipip: add GSO/TSO support") Signed-off-by: Tao Liu Reviewed-by: Willem de Bruijn Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- net/ipv4/af_inet.c | 5 ++++- net/ipv6/ip6_offload.c | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -1344,8 +1344,11 @@ struct sk_buff *inet_gso_segment(struct } =20 ops =3D rcu_dereference(inet_offloads[proto]); - if (likely(ops && ops->callbacks.gso_segment)) + if (likely(ops && ops->callbacks.gso_segment)) { segs =3D ops->callbacks.gso_segment(skb, features); + if (!segs) + skb->network_header =3D skb_mac_header(skb) + nhoff - skb->head; + } =20 if (IS_ERR_OR_NULL(segs)) goto out; --- a/net/ipv6/ip6_offload.c +++ b/net/ipv6/ip6_offload.c @@ -111,6 +111,8 @@ static struct sk_buff *ipv6_gso_segment( if (likely(ops && ops->callbacks.gso_segment)) { skb_reset_transport_header(skb); segs =3D ops->callbacks.gso_segment(skb, features); + if (!segs) + skb->network_header =3D skb_mac_header(skb) + nhoff - skb->head; } =20 if (IS_ERR_OR_NULL(segs)) From nobody Tue Jun 23 18:14:07 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 86F35C4332F for ; Mon, 28 Feb 2022 17:36:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238139AbiB1Rgz (ORCPT ); Mon, 28 Feb 2022 12:36:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238765AbiB1Rdu (ORCPT ); Mon, 28 Feb 2022 12:33:50 -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 D01179318C; Mon, 28 Feb 2022 09:30: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 dfw.source.kernel.org (Postfix) with ESMTPS id 2021F6143A; Mon, 28 Feb 2022 17:30:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A3D0C340E7; Mon, 28 Feb 2022 17:30:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069440; bh=ROkih2dOv8Nkwrhl3q24xQr0HNt/vhhvIrdDm3BjikQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QHsd7fZv7oVQYpk5utp4iWtQ/VtQvndl+HXV+YTi8IMjc2tUQahwS3xaa2SqssMA9 lhng6Q9Zu0AUN1JKHVF5ae5Nsys72LM5N+I+imEMQtdiKxa+ZtJxi5sQ7AiiKFd3PQ 72pgrQKBUYe22VDjboztcU3DSZkf5DXCVfRjpxzU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paul Blakey , Jakub Kicinski Subject: [PATCH 5.4 20/53] openvswitch: Fix setting ipv6 fields causing hw csum failure Date: Mon, 28 Feb 2022 18:24:18 +0100 Message-Id: <20220228172249.788638885@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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 Blakey commit d9b5ae5c1b241b91480aa30408be12fe91af834a upstream. Ipv6 ttl, label and tos fields are modified without first pulling/pushing the ipv6 header, which would have updated the hw csum (if available). This might cause csum validation when sending the packet to the stack, as can be seen in the trace below. Fix this by updating skb->csum if available. Trace resulted by ipv6 ttl dec and then sending packet to conntrack [actions: set(ipv6(hlimit=3D63)),ct(zone=3D99)]: [295241.900063] s_pf0vf2: hw csum failure [295241.923191] Call Trace: [295241.925728] [295241.927836] dump_stack+0x5c/0x80 [295241.931240] __skb_checksum_complete+0xac/0xc0 [295241.935778] nf_conntrack_tcp_packet+0x398/0xba0 [nf_conntrack] [295241.953030] nf_conntrack_in+0x498/0x5e0 [nf_conntrack] [295241.958344] __ovs_ct_lookup+0xac/0x860 [openvswitch] [295241.968532] ovs_ct_execute+0x4a7/0x7c0 [openvswitch] [295241.979167] do_execute_actions+0x54a/0xaa0 [openvswitch] [295242.001482] ovs_execute_actions+0x48/0x100 [openvswitch] [295242.006966] ovs_dp_process_packet+0x96/0x1d0 [openvswitch] [295242.012626] ovs_vport_receive+0x6c/0xc0 [openvswitch] [295242.028763] netdev_frame_hook+0xc0/0x180 [openvswitch] [295242.034074] __netif_receive_skb_core+0x2ca/0xcb0 [295242.047498] netif_receive_skb_internal+0x3e/0xc0 [295242.052291] napi_gro_receive+0xba/0xe0 [295242.056231] mlx5e_handle_rx_cqe_mpwrq_rep+0x12b/0x250 [mlx5_core] [295242.062513] mlx5e_poll_rx_cq+0xa0f/0xa30 [mlx5_core] [295242.067669] mlx5e_napi_poll+0xe1/0x6b0 [mlx5_core] [295242.077958] net_rx_action+0x149/0x3b0 [295242.086762] __do_softirq+0xd7/0x2d6 [295242.090427] irq_exit+0xf7/0x100 [295242.093748] do_IRQ+0x7f/0xd0 [295242.096806] common_interrupt+0xf/0xf [295242.100559] [295242.102750] RIP: 0033:0x7f9022e88cbd [295242.125246] RSP: 002b:00007f9022282b20 EFLAGS: 00000246 ORIG_RAX: fffff= fffffffffda [295242.132900] RAX: 0000000000000005 RBX: 0000000000000010 RCX: 0000000000= 000000 [295242.140120] RDX: 00007f9022282ba8 RSI: 00007f9022282a30 RDI: 00007f9014= 005c30 [295242.147337] RBP: 00007f9014014d60 R08: 0000000000000020 R09: 00007f9025= 4a8340 [295242.154557] R10: 00007f9022282a28 R11: 0000000000000246 R12: 0000000000= 000000 [295242.161775] R13: 00007f902308c000 R14: 000000000000002b R15: 00007f9022= b71f40 Fixes: 3fdbd1ce11e5 ("openvswitch: add ipv6 'set' action") Signed-off-by: Paul Blakey Link: https://lore.kernel.org/r/20220223163416.24096-1-paulb@nvidia.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- include/net/checksum.h | 5 +++++ net/openvswitch/actions.c | 46 ++++++++++++++++++++++++++++++++++++++---= ----- 2 files changed, 43 insertions(+), 8 deletions(-) --- a/include/net/checksum.h +++ b/include/net/checksum.h @@ -139,6 +139,11 @@ static inline void csum_replace2(__sum16 *sum =3D ~csum16_add(csum16_sub(~(*sum), old), new); } =20 +static inline void csum_replace(__wsum *csum, __wsum old, __wsum new) +{ + *csum =3D csum_add(csum_sub(*csum, old), new); +} + struct sk_buff; void inet_proto_csum_replace4(__sum16 *sum, struct sk_buff *skb, __be32 from, __be32 to, bool pseudohdr); --- a/net/openvswitch/actions.c +++ b/net/openvswitch/actions.c @@ -427,12 +427,43 @@ static void set_ipv6_addr(struct sk_buff memcpy(addr, new_addr, sizeof(__be32[4])); } =20 -static void set_ipv6_fl(struct ipv6hdr *nh, u32 fl, u32 mask) +static void set_ipv6_dsfield(struct sk_buff *skb, struct ipv6hdr *nh, u8 i= pv6_tclass, u8 mask) { + u8 old_ipv6_tclass =3D ipv6_get_dsfield(nh); + + ipv6_tclass =3D OVS_MASKED(old_ipv6_tclass, ipv6_tclass, mask); + + if (skb->ip_summed =3D=3D CHECKSUM_COMPLETE) + csum_replace(&skb->csum, (__force __wsum)(old_ipv6_tclass << 12), + (__force __wsum)(ipv6_tclass << 12)); + + ipv6_change_dsfield(nh, ~mask, ipv6_tclass); +} + +static void set_ipv6_fl(struct sk_buff *skb, struct ipv6hdr *nh, u32 fl, u= 32 mask) +{ + u32 ofl; + + ofl =3D nh->flow_lbl[0] << 16 | nh->flow_lbl[1] << 8 | nh->flow_lbl[2]; + fl =3D OVS_MASKED(ofl, fl, mask); + /* Bits 21-24 are always unmasked, so this retains their values. */ - OVS_SET_MASKED(nh->flow_lbl[0], (u8)(fl >> 16), (u8)(mask >> 16)); - OVS_SET_MASKED(nh->flow_lbl[1], (u8)(fl >> 8), (u8)(mask >> 8)); - OVS_SET_MASKED(nh->flow_lbl[2], (u8)fl, (u8)mask); + nh->flow_lbl[0] =3D (u8)(fl >> 16); + nh->flow_lbl[1] =3D (u8)(fl >> 8); + nh->flow_lbl[2] =3D (u8)fl; + + if (skb->ip_summed =3D=3D CHECKSUM_COMPLETE) + csum_replace(&skb->csum, (__force __wsum)htonl(ofl), (__force __wsum)hto= nl(fl)); +} + +static void set_ipv6_ttl(struct sk_buff *skb, struct ipv6hdr *nh, u8 new_t= tl, u8 mask) +{ + new_ttl =3D OVS_MASKED(nh->hop_limit, new_ttl, mask); + + if (skb->ip_summed =3D=3D CHECKSUM_COMPLETE) + csum_replace(&skb->csum, (__force __wsum)(nh->hop_limit << 8), + (__force __wsum)(new_ttl << 8)); + nh->hop_limit =3D new_ttl; } =20 static void set_ip_ttl(struct sk_buff *skb, struct iphdr *nh, u8 new_ttl, @@ -550,18 +581,17 @@ static int set_ipv6(struct sk_buff *skb, } } if (mask->ipv6_tclass) { - ipv6_change_dsfield(nh, ~mask->ipv6_tclass, key->ipv6_tclass); + set_ipv6_dsfield(skb, nh, key->ipv6_tclass, mask->ipv6_tclass); flow_key->ip.tos =3D ipv6_get_dsfield(nh); } if (mask->ipv6_label) { - set_ipv6_fl(nh, ntohl(key->ipv6_label), + set_ipv6_fl(skb, nh, ntohl(key->ipv6_label), ntohl(mask->ipv6_label)); flow_key->ipv6.label =3D *(__be32 *)nh & htonl(IPV6_FLOWINFO_FLOWLABEL); } if (mask->ipv6_hlimit) { - OVS_SET_MASKED(nh->hop_limit, key->ipv6_hlimit, - mask->ipv6_hlimit); + set_ipv6_ttl(skb, nh, key->ipv6_hlimit, mask->ipv6_hlimit); flow_key->ip.ttl =3D nh->hop_limit; } return 0; From nobody Tue Jun 23 18:14:07 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 41C02C433F5 for ; Mon, 28 Feb 2022 17:36:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236156AbiB1RhJ (ORCPT ); Mon, 28 Feb 2022 12:37:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238870AbiB1Rd6 (ORCPT ); Mon, 28 Feb 2022 12:33:58 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA2C393992; Mon, 28 Feb 2022 09:30: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 CF96E6140B; Mon, 28 Feb 2022 17:30:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E592CC340F1; Mon, 28 Feb 2022 17:30:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069443; bh=0Ur9b9NVUv1Ys4I0wG9XQmOVmgDkBGlKP/zekti89a8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RtbzzRTNEFqpRBGZ/64H6+NfCY+T3Y6U5BEBDQKDzFa2ZJSQ0quABRQGmFV+4TYAL CJrHf0eoZXLIuIQQxcvamXuaVD8q1QaKZW2hIrKbJgW97D3A4XBdmJQp/ezfV8xS65 UzFkHpIKp4HIjGiGf/5i1E8u1SFhXWeFOMQdbRJg= 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?= , Matthias Reichl , Maxime Ripard Subject: [PATCH 5.4 21/53] drm/edid: Always set RGB444 Date: Mon, 28 Feb 2022 18:24:19 +0100 Message-Id: <20220228172249.865887796@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: Maxime Ripard commit ecbd4912a693b862e25cba0a6990a8c95b00721e upstream. In order to fill the drm_display_info structure each time an EDID is read, the code currently will call drm_add_display_info with the parsed EDID. drm_add_display_info will then call drm_reset_display_info to reset all the fields to 0, and then set them to the proper value depending on the EDID. In the color_formats case, we will thus report that we don't support any color format, and then fill it back with RGB444 plus the additional formats described in the EDID Feature Support byte. However, since that byte only contains format-related bits since the 1.4 specification, this doesn't happen if the EDID is following an earlier specification. In turn, it means that for one of these EDID, we end up with color_formats set to 0. The EDID 1.3 specification never really specifies what it means by RGB exactly, but since both HDMI and DVI will use RGB444, it's fairly safe to assume it's supposed to be RGB444. Let's move the addition of RGB444 to color_formats earlier in drm_add_display_info() so that it's always set for a digital display. Fixes: da05a5a71ad8 ("drm: parse color format support for digital displays") Cc: Ville Syrj=C3=A4l=C3=A4 Reported-by: Matthias Reichl Signed-off-by: Maxime Ripard Reviewed-by: Ville Syrj=C3=A4l=C3=A4 Link: https://patchwork.freedesktop.org/patch/msgid/20220203115416.1137308-= 1-maxime@cerno.tech Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- drivers/gpu/drm/drm_edid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -4659,6 +4659,7 @@ u32 drm_add_display_info(struct drm_conn if (!(edid->input & DRM_EDID_INPUT_DIGITAL)) return quirks; =20 + info->color_formats |=3D DRM_COLOR_FORMAT_RGB444; drm_parse_cea_ext(connector, edid); =20 /* @@ -4707,7 +4708,6 @@ u32 drm_add_display_info(struct drm_conn DRM_DEBUG("%s: Assigning EDID-1.4 digital sink color depth as %d bpc.\n", connector->name, info->bpc); =20 - info->color_formats |=3D DRM_COLOR_FORMAT_RGB444; if (edid->features & DRM_EDID_FEATURE_RGB_YCRCB444) info->color_formats |=3D DRM_COLOR_FORMAT_YCRCB444; if (edid->features & DRM_EDID_FEATURE_RGB_YCRCB422) From nobody Tue Jun 23 18:14:07 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 1872EC433F5 for ; Mon, 28 Feb 2022 17:36:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237763AbiB1RhN (ORCPT ); Mon, 28 Feb 2022 12:37:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237542AbiB1ReE (ORCPT ); Mon, 28 Feb 2022 12:34:04 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4366A939BA; Mon, 28 Feb 2022 09:30:57 -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 46921B815AC; Mon, 28 Feb 2022 17:30:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B9DEC340E7; Mon, 28 Feb 2022 17:30:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069446; bh=kyKWOYt+j8NdpzKA9EZ5lJe6018rgYKEaDnb7/Q3m2Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LwEKSpik9A3sl4hCUOVAVkQ0O7tS/rM6ahtM+3SZS52PJA3vhm2GaIiOSGQk1Yr1D dK0Tq7H5NkICFvMY62Wp5FZxsGAAWltBz8tV5HvtHXwemJDC058AAcUahu500a/se2 LBDCWGRwHj1Am00eArzb0nJwxOLc2/mPLQqFKCC4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gal Pressman , Tariq Toukan , Saeed Mahameed Subject: [PATCH 5.4 22/53] net/mlx5e: Fix wrong return value on ioctl EEPROM query failure Date: Mon, 28 Feb 2022 18:24:20 +0100 Message-Id: <20220228172249.931709849@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: Gal Pressman commit 0b89429722353d112f8b8b29ca397e95fa994d27 upstream. The ioctl EEPROM query wrongly returns success on read failures, fix that by returning the appropriate error code. Fixes: bb64143eee8c ("net/mlx5e: Add ethtool support for dump module EEPROM= ") Signed-off-by: Gal Pressman Reviewed-by: Tariq Toukan Signed-off-by: Saeed Mahameed Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c @@ -1683,7 +1683,7 @@ static int mlx5e_get_module_eeprom(struc if (size_read < 0) { netdev_err(priv->netdev, "%s: mlx5_query_eeprom failed:0x%x\n", __func__, size_read); - return 0; + return size_read; } =20 i +=3D size_read; From nobody Tue Jun 23 18:14:07 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 494C2C433FE for ; Mon, 28 Feb 2022 17:36:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234025AbiB1RhR (ORCPT ); Mon, 28 Feb 2022 12:37:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238838AbiB1Rdz (ORCPT ); Mon, 28 Feb 2022 12:33:55 -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 67A6877AAE; Mon, 28 Feb 2022 09:30: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 43A1C61359; Mon, 28 Feb 2022 17:30:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 538A4C340E7; Mon, 28 Feb 2022 17:30:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069448; bh=YKvPEg0zzOIBH0zwPdQEyNkdhgSjYM/EH+4eaRDEvs0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v6vgdM10tLlQrJ1JDLC4lo0j953pQpoAXg13eGOzTCAsiklm2xE9AA6ktcPMFS2Xe NRSWPMFkWWpNmWSBs8SW+yVQVpksGlQ2S5BFMFpHHMgVZhtwZW652kgIXMrOWqiB6D myXn5nfqo7FoUQagUQJb9i6aOXKoHMxF/McXOP4E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiaoke Wang , "David S. Miller" Subject: [PATCH 5.4 23/53] net: ll_temac: check the return value of devm_kmalloc() Date: Mon, 28 Feb 2022 18:24:21 +0100 Message-Id: <20220228172249.990160395@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: Xiaoke Wang commit b352c3465bb808ab700d03f5bac2f7a6f37c5350 upstream. devm_kmalloc() returns a pointer to allocated memory on success, NULL on failure. While lp->indirect_lock is allocated by devm_kmalloc() without proper check. It is better to check the value of it to prevent potential wrong memory access. Fixes: f14f5c11f051 ("net: ll_temac: Support indirect_mutex share within TE= MAC IP") Signed-off-by: Xiaoke Wang Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- drivers/net/ethernet/xilinx/ll_temac_main.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/net/ethernet/xilinx/ll_temac_main.c +++ b/drivers/net/ethernet/xilinx/ll_temac_main.c @@ -1345,6 +1345,8 @@ static int temac_probe(struct platform_d lp->indirect_lock =3D devm_kmalloc(&pdev->dev, sizeof(*lp->indirect_lock), GFP_KERNEL); + if (!lp->indirect_lock) + return -ENOMEM; spin_lock_init(lp->indirect_lock); } From nobody Tue Jun 23 18:14:07 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 2E32CC4332F for ; Mon, 28 Feb 2022 17:36:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236998AbiB1RhT (ORCPT ); Mon, 28 Feb 2022 12:37:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237192AbiB1ReH (ORCPT ); Mon, 28 Feb 2022 12:34:07 -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 84E4B939C1; Mon, 28 Feb 2022 09:30:57 -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 B66DAB815AE; Mon, 28 Feb 2022 17:30:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0933FC340F0; Mon, 28 Feb 2022 17:30:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069451; bh=2A8txO/37jTjRq7tu0H8N9qZCzHLsUbc41RmaV/i3Jo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bv5d2boPZriZEeeI/jPo1CdNqTRkbH30SFaQgEBynkr6stW2Hc/89rWxYvXbwcpjE NjHn7XWR772UBi+guH8yLOkps4mHiAE9ej2Tl9ubZ3b9hXitWtVeMrzV59pJyKqvrE LCN0f00WKtV6CQPQ0qIRvwsJ814VYGTtyMZix1sk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masahiro Yamada , Nick Desaulniers , Andrew Morton , Christophe Leroy , "David S. Miller" Subject: [PATCH 5.4 24/53] net: Force inlining of checksum functions in net/checksum.h Date: Mon, 28 Feb 2022 18:24:22 +0100 Message-Id: <20220228172250.060108334@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: Christophe Leroy commit 5486f5bf790b5c664913076c3194b8f916a5c7ad upstream. All functions defined as static inline in net/checksum.h are meant to be inlined for performance reason. But since commit ac7c3e4ff401 ("compiler: enable CONFIG_OPTIMIZE_INLINING forcibly") the compiler is allowed to uninline functions when it wants. Fair enough in the general case, but for tiny performance critical checksum helpers that's counter-productive. The problem mainly arises when selecting CONFIG_CC_OPTIMISE_FOR_SIZE, Those helpers being 'static inline' in header files you suddenly find them duplicated many times in the resulting vmlinux. Here is a typical exemple when building powerpc pmac32_defconfig with CONFIG_CC_OPTIMISE_FOR_SIZE. csum_sub() appears 4 times: c04a23cc : c04a23cc: 7c 84 20 f8 not r4,r4 c04a23d0: 7c 63 20 14 addc r3,r3,r4 c04a23d4: 7c 63 01 94 addze r3,r3 c04a23d8: 4e 80 00 20 blr ... c04a2ce8: 4b ff f6 e5 bl c04a23cc ... c04a2d2c: 4b ff f6 a1 bl c04a23cc ... c04a2d54: 4b ff f6 79 bl c04a23cc ... c04a754c : c04a754c: 7c 84 20 f8 not r4,r4 c04a7550: 7c 63 20 14 addc r3,r3,r4 c04a7554: 7c 63 01 94 addze r3,r3 c04a7558: 4e 80 00 20 blr ... c04ac930: 4b ff ac 1d bl c04a754c ... c04ad264: 4b ff a2 e9 bl c04a754c ... c04e3b08 : c04e3b08: 7c 84 20 f8 not r4,r4 c04e3b0c: 7c 63 20 14 addc r3,r3,r4 c04e3b10: 7c 63 01 94 addze r3,r3 c04e3b14: 4e 80 00 20 blr ... c04e5788: 4b ff e3 81 bl c04e3b08 ... c04e65c8: 4b ff d5 41 bl c04e3b08 ... c0512d34 : c0512d34: 7c 84 20 f8 not r4,r4 c0512d38: 7c 63 20 14 addc r3,r3,r4 c0512d3c: 7c 63 01 94 addze r3,r3 c0512d40: 4e 80 00 20 blr ... c0512dfc: 4b ff ff 39 bl c0512d34 ... c05138bc: 4b ff f4 79 bl c0512d34 ... Restore the expected behaviour by using __always_inline for all functions defined in net/checksum.h vmlinux size is even reduced by 256 bytes with this patch: text data bss dec hex filename 6980022 2515362 194384 9689768 93daa8 vmlinux.before 6979862 2515266 194384 9689512 93d9a8 vmlinux.now Fixes: ac7c3e4ff401 ("compiler: enable CONFIG_OPTIMIZE_INLINING forcibly") Cc: Masahiro Yamada Cc: Nick Desaulniers Cc: Andrew Morton Signed-off-by: Christophe Leroy Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- include/net/checksum.h | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) --- a/include/net/checksum.h +++ b/include/net/checksum.h @@ -22,7 +22,7 @@ #include =20 #ifndef _HAVE_ARCH_COPY_AND_CSUM_FROM_USER -static inline +static __always_inline __wsum csum_and_copy_from_user (const void __user *src, void *dst, int len, __wsum sum, int *err_ptr) { @@ -37,7 +37,7 @@ __wsum csum_and_copy_from_user (const vo #endif =20 #ifndef HAVE_CSUM_COPY_USER -static __inline__ __wsum csum_and_copy_to_user +static __always_inline __wsum csum_and_copy_to_user (const void *src, void __user *dst, int len, __wsum sum, int *err_ptr) { sum =3D csum_partial(src, len, sum); @@ -54,7 +54,7 @@ static __inline__ __wsum csum_and_copy_t #endif =20 #ifndef HAVE_ARCH_CSUM_ADD -static inline __wsum csum_add(__wsum csum, __wsum addend) +static __always_inline __wsum csum_add(__wsum csum, __wsum addend) { u32 res =3D (__force u32)csum; res +=3D (__force u32)addend; @@ -62,12 +62,12 @@ static inline __wsum csum_add(__wsum csu } #endif =20 -static inline __wsum csum_sub(__wsum csum, __wsum addend) +static __always_inline __wsum csum_sub(__wsum csum, __wsum addend) { return csum_add(csum, ~addend); } =20 -static inline __sum16 csum16_add(__sum16 csum, __be16 addend) +static __always_inline __sum16 csum16_add(__sum16 csum, __be16 addend) { u16 res =3D (__force u16)csum; =20 @@ -75,12 +75,12 @@ static inline __sum16 csum16_add(__sum16 return (__force __sum16)(res + (res < (__force u16)addend)); } =20 -static inline __sum16 csum16_sub(__sum16 csum, __be16 addend) +static __always_inline __sum16 csum16_sub(__sum16 csum, __be16 addend) { return csum16_add(csum, ~addend); } =20 -static inline __wsum +static __always_inline __wsum csum_block_add(__wsum csum, __wsum csum2, int offset) { u32 sum =3D (__force u32)csum2; @@ -92,36 +92,37 @@ csum_block_add(__wsum csum, __wsum csum2 return csum_add(csum, (__force __wsum)sum); } =20 -static inline __wsum +static __always_inline __wsum csum_block_add_ext(__wsum csum, __wsum csum2, int offset, int len) { return csum_block_add(csum, csum2, offset); } =20 -static inline __wsum +static __always_inline __wsum csum_block_sub(__wsum csum, __wsum csum2, int offset) { return csum_block_add(csum, ~csum2, offset); } =20 -static inline __wsum csum_unfold(__sum16 n) +static __always_inline __wsum csum_unfold(__sum16 n) { return (__force __wsum)n; } =20 -static inline __wsum csum_partial_ext(const void *buff, int len, __wsum su= m) +static __always_inline +__wsum csum_partial_ext(const void *buff, int len, __wsum sum) { return csum_partial(buff, len, sum); } =20 #define CSUM_MANGLED_0 ((__force __sum16)0xffff) =20 -static inline void csum_replace_by_diff(__sum16 *sum, __wsum diff) +static __always_inline void csum_replace_by_diff(__sum16 *sum, __wsum diff) { *sum =3D csum_fold(csum_add(diff, ~csum_unfold(*sum))); } =20 -static inline void csum_replace4(__sum16 *sum, __be32 from, __be32 to) +static __always_inline void csum_replace4(__sum16 *sum, __be32 from, __be3= 2 to) { __wsum tmp =3D csum_sub(~csum_unfold(*sum), (__force __wsum)from); =20 @@ -134,7 +135,7 @@ static inline void csum_replace4(__sum16 * m : old value of a 16bit field * m' : new value of a 16bit field */ -static inline void csum_replace2(__sum16 *sum, __be16 old, __be16 new) +static __always_inline void csum_replace2(__sum16 *sum, __be16 old, __be16= new) { *sum =3D ~csum16_add(csum16_sub(~(*sum), old), new); } @@ -153,16 +154,16 @@ void inet_proto_csum_replace16(__sum16 * void inet_proto_csum_replace_by_diff(__sum16 *sum, struct sk_buff *skb, __wsum diff, bool pseudohdr); =20 -static inline void inet_proto_csum_replace2(__sum16 *sum, struct sk_buff *= skb, - __be16 from, __be16 to, - bool pseudohdr) +static __always_inline +void inet_proto_csum_replace2(__sum16 *sum, struct sk_buff *skb, + __be16 from, __be16 to, bool pseudohdr) { inet_proto_csum_replace4(sum, skb, (__force __be32)from, (__force __be32)to, pseudohdr); } =20 -static inline __wsum remcsum_adjust(void *ptr, __wsum csum, - int start, int offset) +static __always_inline __wsum remcsum_adjust(void *ptr, __wsum csum, + int start, int offset) { __sum16 *psum =3D (__sum16 *)(ptr + offset); __wsum delta; @@ -178,7 +179,7 @@ static inline __wsum remcsum_adjust(void return delta; } =20 -static inline void remcsum_unadjust(__sum16 *psum, __wsum delta) +static __always_inline void remcsum_unadjust(__sum16 *psum, __wsum delta) { *psum =3D csum_fold(csum_sub(delta, (__force __wsum)*psum)); } From nobody Tue Jun 23 18:14:07 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 7140AC433F5 for ; Mon, 28 Feb 2022 17:36:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238258AbiB1RhY (ORCPT ); Mon, 28 Feb 2022 12:37:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237773AbiB1Reg (ORCPT ); Mon, 28 Feb 2022 12:34:36 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE9969399C; Mon, 28 Feb 2022 09:31: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 9B2AF61365; Mon, 28 Feb 2022 17:30:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2960C36AE7; Mon, 28 Feb 2022 17:30:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069454; bh=MLtCPOzQia29se3vECjDQjwtcWHGH9cE0eyTMbvnry8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XrSdotJG68OBZMJvaGpl1JZ4SgF3ZQkSRbVVfS9Jb5xZsh9ncMgk8MLBKjPDO6q0/ wwC8wRuNrgukEHKo2KEm+BV8ze1Jw9LXJxCPO9aN5lRI5e6QfACVC3HTueWjm7AJqB CXJme86T+JLVZYuGS7DzE29upaZbMpZw5Yl2aNFs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe JAILLET , Simon Horman , Jakub Kicinski Subject: [PATCH 5.4 25/53] nfp: flower: Fix a potential leak in nfp_tunnel_add_shared_mac() Date: Mon, 28 Feb 2022 18:24:23 +0100 Message-Id: <20220228172250.117600264@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: Christophe JAILLET commit 3a14d0888eb4b0045884126acc69abfb7b87814d upstream. ida_simple_get() returns an id between min (0) and max (NFP_MAX_MAC_INDEX) inclusive. So NFP_MAX_MAC_INDEX (0xff) is a valid id. In order for the error handling path to work correctly, the 'invalid' value for 'ida_idx' should not be in the 0..NFP_MAX_MAC_INDEX range, inclusive. So set it to -1. Fixes: 20cce8865098 ("nfp: flower: enable MAC address sharing for offloadab= le devs") Signed-off-by: Christophe JAILLET Signed-off-by: Simon Horman Link: https://lore.kernel.org/r/20220218131535.100258-1-simon.horman@corigi= ne.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c +++ b/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c @@ -588,8 +588,8 @@ nfp_tunnel_add_shared_mac(struct nfp_app int port, bool mod) { struct nfp_flower_priv *priv =3D app->priv; - int ida_idx =3D NFP_MAX_MAC_INDEX, err; struct nfp_tun_offloaded_mac *entry; + int ida_idx =3D -1, err; u16 nfp_mac_idx =3D 0; =20 entry =3D nfp_tunnel_lookup_offloaded_macs(app, netdev->dev_addr); @@ -663,7 +663,7 @@ err_remove_hash: err_free_entry: kfree(entry); err_free_ida: - if (ida_idx !=3D NFP_MAX_MAC_INDEX) + if (ida_idx !=3D -1) ida_simple_remove(&priv->tun.mac_off_ids, ida_idx); =20 return err; From nobody Tue Jun 23 18:14:07 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 45703C433EF for ; Mon, 28 Feb 2022 17:41:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234234AbiB1Rmb (ORCPT ); Mon, 28 Feb 2022 12:42:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238407AbiB1Rhv (ORCPT ); Mon, 28 Feb 2022 12:37:51 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D503A13F16; Mon, 28 Feb 2022 09:32: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 4631261358; Mon, 28 Feb 2022 17:32:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B616C340E7; Mon, 28 Feb 2022 17:32:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069552; bh=0t215VCzkJe0beIi2ijWkcI79VmhD3hbKqHuLFKXKd0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wdOkIMKx4A5v3aZbmDe6ZvqZdPm7tIpzccm7YvuOe+c7sW5X2xLyAnRzQGVGJnqmN U8hN/ObWohNdpZkFKS9MfhyfIZPByriglLsikHd5AWBc8D9fY6FlLFfxWrwYbR8RBH MYQZpGlPIzcfU7E/dkq2QW3T6ZAv+30k2lRSIplo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Fernando Fernandez Mancera , Florian Westphal , Pablo Neira Ayuso Subject: [PATCH 5.4 26/53] netfilter: nf_tables: fix memory leak during stateful obj update Date: Mon, 28 Feb 2022 18:24:24 +0100 Message-Id: <20220228172250.179632246@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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 dad3bdeef45f81a6e90204bcc85360bb76eccec7 upstream. stateful objects can be updated from the control plane. The transaction logic allocates a temporary object for this purpose. The ->init function was called for this object, so plain kfree() leaks resources. We must call ->destroy function of the object. nft_obj_destroy does this, but it also decrements the module refcount, but the update path doesn't increment it. To avoid special-casing the update object release, do module_get for the update case too and release it via nft_obj_destroy(). Fixes: d62d0ba97b58 ("netfilter: nf_tables: Introduce stateful object updat= e operation") Cc: Fernando Fernandez Mancera Signed-off-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- net/netfilter/nf_tables_api.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -5184,12 +5184,15 @@ static int nf_tables_updobj(const struct { struct nft_object *newobj; struct nft_trans *trans; - int err; + int err =3D -ENOMEM; + + if (!try_module_get(type->owner)) + return -ENOENT; =20 trans =3D nft_trans_alloc(ctx, NFT_MSG_NEWOBJ, sizeof(struct nft_trans_obj)); if (!trans) - return -ENOMEM; + goto err_trans; =20 newobj =3D nft_obj_init(ctx, type, attr); if (IS_ERR(newobj)) { @@ -5206,6 +5209,8 @@ static int nf_tables_updobj(const struct =20 err_free_trans: kfree(trans); +err_trans: + module_put(type->owner); return err; } =20 @@ -6544,7 +6549,7 @@ static void nft_obj_commit_update(struct if (obj->ops->update) obj->ops->update(obj, newobj); =20 - kfree(newobj); + nft_obj_destroy(&trans->ctx, newobj); } =20 static void nft_commit_release(struct nft_trans *trans) @@ -7109,7 +7114,7 @@ static int __nf_tables_abort(struct net break; case NFT_MSG_NEWOBJ: if (nft_trans_obj_update(trans)) { - kfree(nft_trans_obj_newobj(trans)); + nft_obj_destroy(&trans->ctx, nft_trans_obj_newobj(trans)); nft_trans_destroy(trans); } else { trans->ctx.table->use--; From nobody Tue Jun 23 18:14:07 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 E9DB7C433FE for ; Mon, 28 Feb 2022 17:39:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238526AbiB1Rh6 (ORCPT ); Mon, 28 Feb 2022 12:37:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238207AbiB1RfS (ORCPT ); Mon, 28 Feb 2022 12:35:18 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7679688798; Mon, 28 Feb 2022 09:31: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 dfw.source.kernel.org (Postfix) with ESMTPS id 18D7361357; Mon, 28 Feb 2022 17:31:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 22CB0C340E7; Mon, 28 Feb 2022 17:31:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069478; bh=epMXXlbGNSFUVnUKm1TddebGD0G60b9EZdMjrNxAv0g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=buag19bilsKR2bMb+hwsM4X7vlJ1XfBkgJJWd6Uj9ntGc39++DL/ZbfCgtpsYUyKG LM09qR31Vi2v//61xrcW3hx/EvDe8jnBQr6LAURw+ijWEJw0W+BY20oynoBlOVfUgm BGGjn11e2hOIaHJRNLE+o24qt5tNKmwuQMDvFrrY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maor Gottlieb , Mark Bloch , Saeed Mahameed Subject: [PATCH 5.4 27/53] net/mlx5: Fix possible deadlock on rule deletion Date: Mon, 28 Feb 2022 18:24:25 +0100 Message-Id: <20220228172250.254197486@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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 b645e57debca846f51b3209907546ea857ddd3f5 upstream. Add missing call to up_write_ref_node() which releases the semaphore in case the FTE doesn't have destinations, such in drop rule case. Fixes: 465e7baab6d9 ("net/mlx5: Fix deletion of duplicate rules") Signed-off-by: Maor Gottlieb Reviewed-by: Mark Bloch Signed-off-by: Saeed Mahameed Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c @@ -1947,6 +1947,8 @@ void mlx5_del_flow_rules(struct mlx5_flo fte->node.del_hw_func =3D NULL; up_write_ref_node(&fte->node, false); tree_put_node(&fte->node, false); + } else { + up_write_ref_node(&fte->node, false); } kfree(handle); } From nobody Tue Jun 23 18:14:07 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 EAAB8C4332F for ; Mon, 28 Feb 2022 17:38:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234061AbiB1Ri4 (ORCPT ); Mon, 28 Feb 2022 12:38:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238315AbiB1Rgs (ORCPT ); Mon, 28 Feb 2022 12:36:48 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACF7997BBF; Mon, 28 Feb 2022 09:31: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 8895761359; Mon, 28 Feb 2022 17:31:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9CBDFC340E7; Mon, 28 Feb 2022 17:31:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069509; bh=s0zOtC35QEyG/6RmIPaCTT90hzhX03S1G3ch4pgXpg0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=17dX1JtpAuqna+2XOkUrQFpJ489z2VtdrivMSraLVU1grPEeuQYsUDhEHilrTN0De D1NMwYeWWsDWqgxJ5tf+TD8I51EJlZZGsk5yPao/iipLlvOCpajEJFS1+lCRmsp3zn 82dStSsh0A9elUeBLY4PYVztsE0OLgA/0uB1HsDI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ariel Levkovich , Maor Dickman , Saeed Mahameed Subject: [PATCH 5.4 28/53] net/mlx5: Fix wrong limitation of metadata match on ecpf Date: Mon, 28 Feb 2022 18:24:26 +0100 Message-Id: <20220228172250.336083429@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: Ariel Levkovich commit 07666c75ad17d7389b18ac0235c8cf41e1504ea8 upstream. Match metadata support check returns false for ecpf device. However, this support does exist for ecpf and therefore this limitation should be removed to allow feature such as stacked devices and internal port offloaded to be supported. Fixes: 92ab1eb392c6 ("net/mlx5: E-Switch, Enable vport metadata matching if= firmware supports it") Signed-off-by: Ariel Levkovich Reviewed-by: Maor Dickman Signed-off-by: Saeed Mahameed Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 4 ---- 1 file changed, 4 deletions(-) --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c @@ -1977,10 +1977,6 @@ esw_check_vport_match_metadata_supported if (!MLX5_CAP_ESW_FLOWTABLE(esw->dev, flow_source)) return false; =20 - if (mlx5_core_is_ecpf_esw_manager(esw->dev) || - mlx5_ecpf_vport_exists(esw->dev)) - return false; - return true; } From nobody Tue Jun 23 18:14:07 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 447A4C433F5 for ; Mon, 28 Feb 2022 17:41:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234906AbiB1Rlx (ORCPT ); Mon, 28 Feb 2022 12:41:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238404AbiB1Rhv (ORCPT ); Mon, 28 Feb 2022 12:37:51 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3DDDDECA; Mon, 28 Feb 2022 09:32: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 522676140B; Mon, 28 Feb 2022 17:32:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 343A7C340E7; Mon, 28 Feb 2022 17:32:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069533; bh=kUMCLelcyBnmGSrfhG9kHSouDJ5eCfOYfQauTCi5Qkk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VRWo9zWDBYLBhWRwi6ZeuTtA72DqwzBkbcMQZUtyV8nd+V1DsY6Pa3SPy3fMvYmAT i+BBwbDfIYg5v2bSPQKE467tctDLkU2Cs5lTO5gde/qGhbx/3TxyAX777Ha6kPBmq2 4nStUwCtwry9zXAXKzKyJ6/5tfuLsWAXji9nMZlY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhou Qingyang , Mark Brown , Sasha Levin Subject: [PATCH 5.4 29/53] spi: spi-zynq-qspi: Fix a NULL pointer dereference in zynq_qspi_exec_mem_op() Date: Mon, 28 Feb 2022 18:24:27 +0100 Message-Id: <20220228172250.404297965@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: Zhou Qingyang [ Upstream commit ab3824427b848da10e9fe2727f035bbeecae6ff4 ] In zynq_qspi_exec_mem_op(), kzalloc() is directly used in memset(), which could lead to a NULL pointer dereference on failure of kzalloc(). Fix this bug by adding a check of tmpbuf. This bug was found by a static analyzer. The analysis employs differential checking to identify inconsistent security operations (e.g., checks or kfrees) between two code paths and confirms that the inconsistent operations are not recovered in the current function or the callers, so they constitute bugs. Note that, as a bug found by static analysis, it can be a false positive or hard to trigger. Multiple researchers have cross-reviewed the bug. Builds with CONFIG_SPI_ZYNQ_QSPI=3Dm show no new warnings, and our static analyzer no longer warns about this code. Fixes: 67dca5e580f1 ("spi: spi-mem: Add support for Zynq QSPI controller") Signed-off-by: Zhou Qingyang Link: https://lore.kernel.org/r/20211130172253.203700-1-zhou1615@umn.edu Signed-off-by: Mark Brown Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- drivers/spi/spi-zynq-qspi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/spi/spi-zynq-qspi.c b/drivers/spi/spi-zynq-qspi.c index 1ced6eb8b3303..b3588240eb39b 100644 --- a/drivers/spi/spi-zynq-qspi.c +++ b/drivers/spi/spi-zynq-qspi.c @@ -558,6 +558,9 @@ static int zynq_qspi_exec_mem_op(struct spi_mem *mem, =20 if (op->dummy.nbytes) { tmpbuf =3D kzalloc(op->dummy.nbytes, GFP_KERNEL); + if (!tmpbuf) + return -ENOMEM; + memset(tmpbuf, 0xff, op->dummy.nbytes); reinit_completion(&xqspi->data_completion); xqspi->txbuf =3D tmpbuf; --=20 2.34.1 From nobody Tue Jun 23 18:14:07 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 90D72C433F5 for ; Mon, 28 Feb 2022 17:41:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235260AbiB1RmB (ORCPT ); Mon, 28 Feb 2022 12:42:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238377AbiB1Rhn (ORCPT ); Mon, 28 Feb 2022 12:37:43 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4001DFB6; Mon, 28 Feb 2022 09:32: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 1513861459; Mon, 28 Feb 2022 17:32:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A21BC340E7; Mon, 28 Feb 2022 17:32:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069536; bh=93VhQEaHboX50eHHlwuPWGL8BptRVPbGklzyVUlkH8Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zVEhAjn3gyAzr9lJ+8wSKcbaG/f/ocv8Nzq7hgFhNLhcj+I+qHBrESCkJ9yl4bS7y f45bQwMPTi/jXQhDaNxzwGCb2z+LU570GyZDt4lusTOWu9zUMTLDQOEK5d5/oy69Fp AO6Y03939TQ106SdG5IXxoonNLysMbBV2zk/F1cg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, ChenXiaoSong , Laibin Qiu , Christoph Hellwig , Sasha Levin Subject: [PATCH 5.4 30/53] configfs: fix a race in configfs_{,un}register_subsystem() Date: Mon, 28 Feb 2022 18:24:28 +0100 Message-Id: <20220228172250.470518132@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: ChenXiaoSong [ Upstream commit 84ec758fb2daa236026506868c8796b0500c047d ] When configfs_register_subsystem() or configfs_unregister_subsystem() is executing link_group() or unlink_group(), it is possible that two processes add or delete list concurrently. Some unfortunate interleavings of them can cause kernel panic. One of cases is: A --> B --> C --> D A <-- B <-- C <-- D delete list_head *B | delete list_head *C Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --------------------------------|----------------------------------- configfs_unregister_subsystem | configfs_unregister_subsystem unlink_group | unlink_group unlink_obj | unlink_obj list_del_init | list_del_init __list_del_entry | __list_del_entry __list_del | __list_del // next =3D=3D C | next->prev =3D prev | | next->prev =3D prev prev->next =3D next | | // prev =3D=3D B | prev->next =3D next Fix this by adding mutex when calling link_group() or unlink_group(), but parent configfs_subsystem is NULL when config_item is root. So I create a mutex configfs_subsystem_mutex. Fixes: 7063fbf22611 ("[PATCH] configfs: User-driven configuration filesyste= m") Signed-off-by: ChenXiaoSong Signed-off-by: Laibin Qiu Signed-off-by: Christoph Hellwig Signed-off-by: Sasha Levin --- fs/configfs/dir.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c index 2992cebb78661..d73d88d9c2598 100644 --- a/fs/configfs/dir.c +++ b/fs/configfs/dir.c @@ -36,6 +36,14 @@ */ DEFINE_SPINLOCK(configfs_dirent_lock); =20 +/* + * All of link_obj/unlink_obj/link_group/unlink_group require that + * subsys->su_mutex is held. + * But parent configfs_subsystem is NULL when config_item is root. + * Use this mutex when config_item is root. + */ +static DEFINE_MUTEX(configfs_subsystem_mutex); + static void configfs_d_iput(struct dentry * dentry, struct inode * inode) { @@ -1884,7 +1892,9 @@ int configfs_register_subsystem(struct configfs_subsy= stem *subsys) group->cg_item.ci_name =3D group->cg_item.ci_namebuf; =20 sd =3D root->d_fsdata; + mutex_lock(&configfs_subsystem_mutex); link_group(to_config_group(sd->s_element), group); + mutex_unlock(&configfs_subsystem_mutex); =20 inode_lock_nested(d_inode(root), I_MUTEX_PARENT); =20 @@ -1909,7 +1919,9 @@ int configfs_register_subsystem(struct configfs_subsy= stem *subsys) inode_unlock(d_inode(root)); =20 if (err) { + mutex_lock(&configfs_subsystem_mutex); unlink_group(group); + mutex_unlock(&configfs_subsystem_mutex); configfs_release_fs(); } put_fragment(frag); @@ -1956,7 +1968,9 @@ void configfs_unregister_subsystem(struct configfs_su= bsystem *subsys) =20 dput(dentry); =20 + mutex_lock(&configfs_subsystem_mutex); unlink_group(group); + mutex_unlock(&configfs_subsystem_mutex); configfs_release_fs(); } =20 --=20 2.34.1 From nobody Tue Jun 23 18:14:07 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 D642CC433F5 for ; Mon, 28 Feb 2022 17:38:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237801AbiB1Rj3 (ORCPT ); Mon, 28 Feb 2022 12:39:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238331AbiB1RhZ (ORCPT ); Mon, 28 Feb 2022 12:37:25 -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 48D956369; Mon, 28 Feb 2022 09:32: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 77418B815AE; Mon, 28 Feb 2022 17:32:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D7179C340E7; Mon, 28 Feb 2022 17:32:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069539; bh=9Q2zckVU2MjYx6EoLKZDAOT6Znqr42HIt8j8+BfBou4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g17zj+6ClA/PVEKXfQaQISI7Lou15MCQT8IFwJ2xvnnM9bqyo5vjWJpTc2qRUybcy r7GW9zHYxj4kWAFrBeaoePTjqBItQR8LJXZTL1sf/mkCrn5eIKNmVLtOC5WaLg3e6Y lWvCxJlo6mTK918r9/Gn57LUmDAts+XAvQ29dCv8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+831661966588c802aae9@syzkaller.appspotmail.com, Bart Van Assche , Leon Romanovsky , Jason Gunthorpe , Sasha Levin Subject: [PATCH 5.4 31/53] RDMA/ib_srp: Fix a deadlock Date: Mon, 28 Feb 2022 18:24:29 +0100 Message-Id: <20220228172250.528772715@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: Bart Van Assche [ Upstream commit 081bdc9fe05bb23248f5effb6f811da3da4b8252 ] Remove the flush_workqueue(system_long_wq) call since flushing system_long_wq is deadlock-prone and since that call is redundant with a preceding cancel_work_sync() Link: https://lore.kernel.org/r/20220215210511.28303-3-bvanassche@acm.org Fixes: ef6c49d87c34 ("IB/srp: Eliminate state SRP_TARGET_DEAD") Reported-by: syzbot+831661966588c802aae9@syzkaller.appspotmail.com Signed-off-by: Bart Van Assche Reviewed-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- drivers/infiniband/ulp/srp/ib_srp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/s= rp/ib_srp.c index 8708ed5477e99..dac806b715afa 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -4222,9 +4222,11 @@ static void srp_remove_one(struct ib_device *device,= void *client_data) spin_unlock(&host->target_lock); =20 /* - * Wait for tl_err and target port removal tasks. + * srp_queue_remove_work() queues a call to + * srp_remove_target(). The latter function cancels + * target->tl_err_work so waiting for the remove works to + * finish is sufficient. */ - flush_workqueue(system_long_wq); flush_workqueue(srp_remove_wq); =20 kfree(host); --=20 2.34.1 From nobody Tue Jun 23 18:14:07 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 39607C433F5 for ; Mon, 28 Feb 2022 17:38:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238216AbiB1Rjc (ORCPT ); Mon, 28 Feb 2022 12:39:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238394AbiB1Rhv (ORCPT ); Mon, 28 Feb 2022 12:37:51 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AA99E014; Mon, 28 Feb 2022 09:32: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 7295161357; Mon, 28 Feb 2022 17:32:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8D5F1C340E7; Mon, 28 Feb 2022 17:32:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069541; bh=HNlEnn31gDfp78Stg/+wfklDNtibWpDYzDPpIk7TOvg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VgD0YcyFbFhJmEUoUVMRTJp8WwdUOEVaxw493/ersiOVqEZkudqmeXEzT+z56sU8X kKiQzwJerhIYoUYrzp6pIMXjRLl2+TY3dmrZ5FOZg/ZI3XqZMTBhKYMxvZ6MgLt9kJ WZr47ivlBx/ZOPrwo0+CZpd3RcaY2sbhfnoSXezI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Bristot de Oliveira , Tom Zanussi , "Steven Rostedt (Google)" Subject: [PATCH 5.4 32/53] tracing: Have traceon and traceoff trigger honor the instance Date: Mon, 28 Feb 2022 18:24:30 +0100 Message-Id: <20220228172250.593515553@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: Steven Rostedt (Google) commit 302e9edd54985f584cfc180098f3554774126969 upstream. If a trigger is set on an event to disable or enable tracing within an instance, then tracing should be disabled or enabled in the instance and not at the top level, which is confusing to users. Link: https://lkml.kernel.org/r/20220223223837.14f94ec3@rorschach.local.home Cc: stable@vger.kernel.org Fixes: ae63b31e4d0e2 ("tracing: Separate out trace events from global varia= bles") Tested-by: Daniel Bristot de Oliveira Reviewed-by: Tom Zanussi Signed-off-by: Steven Rostedt (Google) Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- kernel/trace/trace_events_trigger.c | 52 +++++++++++++++++++++++++++++++= ----- 1 file changed, 46 insertions(+), 6 deletions(-) --- a/kernel/trace/trace_events_trigger.c +++ b/kernel/trace/trace_events_trigger.c @@ -940,6 +940,16 @@ static void traceon_trigger(struct event_trigger_data *data, void *rec, struct ring_buffer_event *event) { + struct trace_event_file *file =3D data->private_data; + + if (file) { + if (tracer_tracing_is_on(file->tr)) + return; + + tracer_tracing_on(file->tr); + return; + } + if (tracing_is_on()) return; =20 @@ -950,8 +960,15 @@ static void traceon_count_trigger(struct event_trigger_data *data, void *rec, struct ring_buffer_event *event) { - if (tracing_is_on()) - return; + struct trace_event_file *file =3D data->private_data; + + if (file) { + if (tracer_tracing_is_on(file->tr)) + return; + } else { + if (tracing_is_on()) + return; + } =20 if (!data->count) return; @@ -959,13 +976,26 @@ traceon_count_trigger(struct event_trigg if (data->count !=3D -1) (data->count)--; =20 - tracing_on(); + if (file) + tracer_tracing_on(file->tr); + else + tracing_on(); } =20 static void traceoff_trigger(struct event_trigger_data *data, void *rec, struct ring_buffer_event *event) { + struct trace_event_file *file =3D data->private_data; + + if (file) { + if (!tracer_tracing_is_on(file->tr)) + return; + + tracer_tracing_off(file->tr); + return; + } + if (!tracing_is_on()) return; =20 @@ -976,8 +1006,15 @@ static void traceoff_count_trigger(struct event_trigger_data *data, void *rec, struct ring_buffer_event *event) { - if (!tracing_is_on()) - return; + struct trace_event_file *file =3D data->private_data; + + if (file) { + if (!tracer_tracing_is_on(file->tr)) + return; + } else { + if (!tracing_is_on()) + return; + } =20 if (!data->count) return; @@ -985,7 +1022,10 @@ traceoff_count_trigger(struct event_trig if (data->count !=3D -1) (data->count)--; =20 - tracing_off(); + if (file) + tracer_tracing_off(file->tr); + else + tracing_off(); } =20 static int From nobody Tue Jun 23 18:14:07 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 3274FC433EF for ; Mon, 28 Feb 2022 17:41:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238452AbiB1RmF (ORCPT ); Mon, 28 Feb 2022 12:42:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238305AbiB1Rh0 (ORCPT ); Mon, 28 Feb 2022 12:37:26 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D2801FA78; Mon, 28 Feb 2022 09:32: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 30E70609EE; Mon, 28 Feb 2022 17:32:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 471E4C340E7; Mon, 28 Feb 2022 17:32:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069544; bh=m3D1UtU+qGhEenIw23BRw2gMcv27uFHzZlSA1vb5nuI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pLdgsf1X9hXOopK6lNVWvaWqAckKn+JLF4jOkEcPfMVICvdQNwA0dRWaFCc1WDwax IdPFB/3epfN4/tv6XUkkxgLUj+B0lxMsGxZXeaXf/c2o3mKeqfzIcFKNn8arFiJ/Hu 099P0pTclThqJNRcSMiAKA4Psi/NkqGjhXZAg3Nc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe JAILLET , Stable@vger.kernel.org, Jonathan Cameron Subject: [PATCH 5.4 33/53] iio: adc: men_z188_adc: Fix a resource leak in an error handling path Date: Mon, 28 Feb 2022 18:24:31 +0100 Message-Id: <20220228172250.668376063@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: Christophe JAILLET commit e0a2e37f303828d030a83f33ffe14b36cb88d563 upstream. If iio_device_register() fails, a previous ioremap() is left unbalanced. Update the error handling path and add the missing iounmap() call, as already done in the remove function. Fixes: 74aeac4da66f ("iio: adc: Add MEN 16z188 ADC driver") Signed-off-by: Christophe JAILLET Link: https://lore.kernel.org/r/320fc777863880247c2aff4a9d1a54ba69abf080.16= 43445149.git.christophe.jaillet@wanadoo.fr Cc: Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- drivers/iio/adc/men_z188_adc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) --- a/drivers/iio/adc/men_z188_adc.c +++ b/drivers/iio/adc/men_z188_adc.c @@ -103,6 +103,7 @@ static int men_z188_probe(struct mcb_dev struct z188_adc *adc; struct iio_dev *indio_dev; struct resource *mem; + int ret; =20 indio_dev =3D devm_iio_device_alloc(&dev->dev, sizeof(struct z188_adc)); if (!indio_dev) @@ -129,8 +130,14 @@ static int men_z188_probe(struct mcb_dev adc->mem =3D mem; mcb_set_drvdata(dev, indio_dev); =20 - return iio_device_register(indio_dev); + ret =3D iio_device_register(indio_dev); + if (ret) + goto err_unmap; =20 + return 0; + +err_unmap: + iounmap(adc->base); err: mcb_release_mem(mem); return -ENXIO; From nobody Tue Jun 23 18:14:07 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 1729FC433EF for ; Mon, 28 Feb 2022 17:41:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236158AbiB1Rm1 (ORCPT ); Mon, 28 Feb 2022 12:42:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238234AbiB1Rhk (ORCPT ); Mon, 28 Feb 2022 12:37:40 -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 CC2FD25C58; Mon, 28 Feb 2022 09:32: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 DD20661365; Mon, 28 Feb 2022 17:32:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F0DBCC340E7; Mon, 28 Feb 2022 17:32:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069547; bh=YapyDaCD7iBiLBcrtI8n+txzlNjyNo+E6ZIxHkcKEO8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s8jcS2mzloaOUU9WiZ9GttLmmlP/yACDHmvHZAI9K5CESntp6kWKEGfH90msz0G/B lQgSmSbu/UAl7zKH/B90AXzNLOkUykpFp+TI4eOTXmkL2cDJ7h4KEl9KsseqznEkyy KJg6zjXEub09Y7l0NijhYmiAmLxYVqitDtos97EY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Cosmin Tanislav , Stable@vger.kernel.org, Jonathan Cameron Subject: [PATCH 5.4 34/53] iio: adc: ad7124: fix mask used for setting AIN_BUFP & AIN_BUFM bits Date: Mon, 28 Feb 2022 18:24:32 +0100 Message-Id: <20220228172250.747090700@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: Cosmin Tanislav commit 0e33d15f1dce9e3a80a970ea7f0b27837168aeca upstream. According to page 90 of the datasheet [1], AIN_BUFP is bit 6 and AIN_BUFM is bit 5 of the CONFIG_0 -> CONFIG_7 registers. Fix the mask used for setting these bits. [1]: https://www.analog.com/media/en/technical-documentation/data-sheets/ad= 7124-8.pdf Fixes: 0eaecea6e487 ("iio: adc: ad7124: Add buffered input support") Signed-off-by: Cosmin Tanislav Link: https://lore.kernel.org/r/20220112200036.694490-1-cosmin.tanislav@ana= log.com Cc: Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- drivers/iio/adc/ad7124.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/iio/adc/ad7124.c +++ b/drivers/iio/adc/ad7124.c @@ -63,7 +63,7 @@ #define AD7124_CONFIG_REF_SEL(x) FIELD_PREP(AD7124_CONFIG_REF_SEL_MSK, x) #define AD7124_CONFIG_PGA_MSK GENMASK(2, 0) #define AD7124_CONFIG_PGA(x) FIELD_PREP(AD7124_CONFIG_PGA_MSK, x) -#define AD7124_CONFIG_IN_BUFF_MSK GENMASK(7, 6) +#define AD7124_CONFIG_IN_BUFF_MSK GENMASK(6, 5) #define AD7124_CONFIG_IN_BUFF(x) FIELD_PREP(AD7124_CONFIG_IN_BUFF_MSK, x) =20 /* AD7124_FILTER_X */ From nobody Tue Jun 23 18:14:07 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 CF9DCC433F5 for ; Mon, 28 Feb 2022 17:41:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238435AbiB1Rlo (ORCPT ); Mon, 28 Feb 2022 12:41:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238403AbiB1Rhv (ORCPT ); Mon, 28 Feb 2022 12:37:51 -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 7A97DE011; Mon, 28 Feb 2022 09:32: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 dfw.source.kernel.org (Postfix) with ESMTPS id 9225E61419; Mon, 28 Feb 2022 17:32:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A4FEDC340F0; Mon, 28 Feb 2022 17:32:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069550; bh=rXJKHRfMx4tgPKyBz9VayILD7iO+VQgXHo/d+r7XewU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v/AlDIwKH33UEGb1KG3l8ipbRGRLDx+f5SCJv1qNhAw5vtiwRWVoj90gTdno1yLQv roza4AikF7lxwG/7uKiQeAkiFYjUzGFvccqlqjIgJ7gb6VxJbT/hbcfy1swnM87Nqg nJFtFv/AlmEwA/iI3qLJgU0gmerigjfDlZu5c3Tc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaoqian Lin , Andy Shevchenko , Stable@vger.kernel.org, Jonathan Cameron Subject: [PATCH 5.4 35/53] iio: Fix error handling for PM Date: Mon, 28 Feb 2022 18:24:33 +0100 Message-Id: <20220228172250.812558422@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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 632fe0bb8c5b9c06ec961f575ee42a6fff5eceeb upstream. The pm_runtime_enable will increase power disable depth. If the probe fails, we should use pm_runtime_disable() to balance pm_runtime_enable(). In the PM Runtime docs: Drivers in ->remove() callback should undo the runtime PM changes done in ->probe(). Usually this means calling pm_runtime_disable(), pm_runtime_dont_use_autosuspend() etc. We should do this in error handling. Fix this problem for the following drivers: bmc150, bmg160, kmx61, kxcj-1013, mma9551, mma9553. Fixes: 7d0ead5c3f00 ("iio: Reconcile operation order between iio_register/u= nregister and pm functions") Signed-off-by: Miaoqian Lin Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20220106112309.16879-1-linmq006@gmail.com Cc: Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- drivers/iio/accel/bmc150-accel-core.c | 5 ++++- drivers/iio/accel/kxcjk-1013.c | 5 ++++- drivers/iio/accel/mma9551.c | 5 ++++- drivers/iio/accel/mma9553.c | 5 ++++- drivers/iio/gyro/bmg160_core.c | 5 ++++- drivers/iio/imu/kmx61.c | 5 ++++- drivers/iio/magnetometer/bmc150_magn.c | 5 +++-- 7 files changed, 27 insertions(+), 8 deletions(-) --- a/drivers/iio/accel/bmc150-accel-core.c +++ b/drivers/iio/accel/bmc150-accel-core.c @@ -1649,11 +1649,14 @@ int bmc150_accel_core_probe(struct devic ret =3D iio_device_register(indio_dev); if (ret < 0) { dev_err(dev, "Unable to register iio device\n"); - goto err_trigger_unregister; + goto err_pm_cleanup; } =20 return 0; =20 +err_pm_cleanup: + pm_runtime_dont_use_autosuspend(dev); + pm_runtime_disable(dev); err_trigger_unregister: bmc150_accel_unregister_triggers(data, BMC150_ACCEL_TRIGGERS - 1); err_buffer_cleanup: --- a/drivers/iio/accel/kxcjk-1013.c +++ b/drivers/iio/accel/kxcjk-1013.c @@ -1409,11 +1409,14 @@ static int kxcjk1013_probe(struct i2c_cl ret =3D iio_device_register(indio_dev); if (ret < 0) { dev_err(&client->dev, "unable to register iio device\n"); - goto err_buffer_cleanup; + goto err_pm_cleanup; } =20 return 0; =20 +err_pm_cleanup: + pm_runtime_dont_use_autosuspend(&client->dev); + pm_runtime_disable(&client->dev); err_buffer_cleanup: iio_triggered_buffer_cleanup(indio_dev); err_trigger_unregister: --- a/drivers/iio/accel/mma9551.c +++ b/drivers/iio/accel/mma9551.c @@ -496,11 +496,14 @@ static int mma9551_probe(struct i2c_clie ret =3D iio_device_register(indio_dev); if (ret < 0) { dev_err(&client->dev, "unable to register iio device\n"); - goto out_poweroff; + goto err_pm_cleanup; } =20 return 0; =20 +err_pm_cleanup: + pm_runtime_dont_use_autosuspend(&client->dev); + pm_runtime_disable(&client->dev); out_poweroff: mma9551_set_device_state(client, false); =20 --- a/drivers/iio/accel/mma9553.c +++ b/drivers/iio/accel/mma9553.c @@ -1135,12 +1135,15 @@ static int mma9553_probe(struct i2c_clie ret =3D iio_device_register(indio_dev); if (ret < 0) { dev_err(&client->dev, "unable to register iio device\n"); - goto out_poweroff; + goto err_pm_cleanup; } =20 dev_dbg(&indio_dev->dev, "Registered device %s\n", name); return 0; =20 +err_pm_cleanup: + pm_runtime_dont_use_autosuspend(&client->dev); + pm_runtime_disable(&client->dev); out_poweroff: mma9551_set_device_state(client, false); return ret; --- a/drivers/iio/gyro/bmg160_core.c +++ b/drivers/iio/gyro/bmg160_core.c @@ -1173,11 +1173,14 @@ int bmg160_core_probe(struct device *dev ret =3D iio_device_register(indio_dev); if (ret < 0) { dev_err(dev, "unable to register iio device\n"); - goto err_buffer_cleanup; + goto err_pm_cleanup; } =20 return 0; =20 +err_pm_cleanup: + pm_runtime_dont_use_autosuspend(dev); + pm_runtime_disable(dev); err_buffer_cleanup: iio_triggered_buffer_cleanup(indio_dev); err_trigger_unregister: --- a/drivers/iio/imu/kmx61.c +++ b/drivers/iio/imu/kmx61.c @@ -1393,7 +1393,7 @@ static int kmx61_probe(struct i2c_client ret =3D iio_device_register(data->acc_indio_dev); if (ret < 0) { dev_err(&client->dev, "Failed to register acc iio device\n"); - goto err_buffer_cleanup_mag; + goto err_pm_cleanup; } =20 ret =3D iio_device_register(data->mag_indio_dev); @@ -1406,6 +1406,9 @@ static int kmx61_probe(struct i2c_client =20 err_iio_unregister_acc: iio_device_unregister(data->acc_indio_dev); +err_pm_cleanup: + pm_runtime_dont_use_autosuspend(&client->dev); + pm_runtime_disable(&client->dev); err_buffer_cleanup_mag: if (client->irq > 0) iio_triggered_buffer_cleanup(data->mag_indio_dev); --- a/drivers/iio/magnetometer/bmc150_magn.c +++ b/drivers/iio/magnetometer/bmc150_magn.c @@ -944,13 +944,14 @@ int bmc150_magn_probe(struct device *dev ret =3D iio_device_register(indio_dev); if (ret < 0) { dev_err(dev, "unable to register iio device\n"); - goto err_disable_runtime_pm; + goto err_pm_cleanup; } =20 dev_dbg(dev, "Registered device %s\n", name); return 0; =20 -err_disable_runtime_pm: +err_pm_cleanup: + pm_runtime_dont_use_autosuspend(dev); pm_runtime_disable(dev); err_buffer_cleanup: iio_triggered_buffer_cleanup(indio_dev); From nobody Tue Jun 23 18:14:07 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 03A83C43217 for ; Mon, 28 Feb 2022 17:37:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238625AbiB1RiD (ORCPT ); Mon, 28 Feb 2022 12:38:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238121AbiB1Rf1 (ORCPT ); Mon, 28 Feb 2022 12:35:27 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22AE27D02F; Mon, 28 Feb 2022 09:31: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 E023261365; Mon, 28 Feb 2022 17:31:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 01903C340E7; Mon, 28 Feb 2022 17:31:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069481; bh=3eRJEy+ZjS94CDexDLediyf+S+DU9xrQ07WNDcrwUXM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kxu9hgaH5nVNXrkFznqD6GcBafQMI6y6+8ZmLQmMptCY+HqNlc396ELDtRpTrFgsL +7IDflxpNu77JNJF1Gzaj3BFvXibp20Bg6sktsqzNLOow0uaVnR4UZRvEiKNuFAQLT vWYFPZtaM5YnSAYrd21TUMfI0NxOJihhOd2vS6K4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sergey Shtylyov , Damien Le Moal Subject: [PATCH 5.4 36/53] ata: pata_hpt37x: disable primary channel on HPT371 Date: Mon, 28 Feb 2022 18:24:34 +0100 Message-Id: <20220228172250.877933175@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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 8d093e02e898b24c58788b0289e3202317a96d2a upstream. The HPT371 chip physically has only one channel, the secondary one, however the primary channel registers do exist! Thus we have to manually disable the non-existing channel if the BIOS hasn't done this already. Similarly to the pata_hpt3x2n driver, always disable the primary channel. Fixes: 669a5db411d8 ("[libata] Add a bunch of PATA drivers.") Cc: stable@vger.kernel.org Signed-off-by: Sergey Shtylyov Signed-off-by: Damien Le Moal Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- drivers/ata/pata_hpt37x.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) --- a/drivers/ata/pata_hpt37x.c +++ b/drivers/ata/pata_hpt37x.c @@ -918,6 +918,20 @@ static int hpt37x_init_one(struct pci_de pci_write_config_byte(dev, 0x5a, irqmask); =20 /* + * HPT371 chips physically have only one channel, the secondary one, + * but the primary channel registers do exist! Go figure... + * So, we manually disable the non-existing channel here + * (if the BIOS hasn't done this already). + */ + if (dev->device =3D=3D PCI_DEVICE_ID_TTI_HPT371) { + u8 mcr1; + + pci_read_config_byte(dev, 0x50, &mcr1); + mcr1 &=3D ~0x04; + pci_write_config_byte(dev, 0x50, mcr1); + } + + /* * default to pci clock. make sure MA15/16 are set to output * to prevent drives having problems with 40-pin cables. Needed * for some drives such as IBM-DTLA which will not enter ready From nobody Tue Jun 23 18:14:07 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 1576FC433EF for ; Mon, 28 Feb 2022 17:39:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238583AbiB1RiB (ORCPT ); Mon, 28 Feb 2022 12:38:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238216AbiB1Rf2 (ORCPT ); Mon, 28 Feb 2022 12:35:28 -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 AE58B954BE; Mon, 28 Feb 2022 09:31: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 C759461464; Mon, 28 Feb 2022 17:31:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D90A9C340E7; Mon, 28 Feb 2022 17:31:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069484; bh=heffnUpLO99jdcWfJkamhIedC6tI/ruh+8NmK74Kg00=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oAPcTKTn39fTZU6OR+Ji5umKZglW7TOT/9L5oTh6vHKq2E9DpKvkXhmplScm9ZE9o 1DHyiEGkDC5Yr1SKta12lljpQE2c7J63cVMo6smGT9+1kwLXsUMOqwn6uv1E07cFr2 aVwXijhGuIl4AZ3y+tMAEv1c0nFeTQuIDMPfgpko= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dmytro Bagrii , Johan Hovold Subject: [PATCH 5.4 37/53] Revert "USB: serial: ch341: add new Product ID for CH341A" Date: Mon, 28 Feb 2022 18:24:35 +0100 Message-Id: <20220228172250.965056875@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: Dmytro Bagrii commit 198a7ebd5fa17b4d0be8cb70240ee1be885175c0 upstream. This reverts commit 46ee4abb10a07bd8f8ce910ee6b4ae6a947d7f63. CH341 has Product ID 0x5512 in EPP/MEM mode which is used for I2C/SPI/GPIO interfaces. In asynchronous serial interface mode CH341 has PID 0x5523 which is already in the table. Mode is selected by corresponding jumper setting. Signed-off-by: Dmytro Bagrii Link: https://lore.kernel.org/r/20220210164137.4376-1-dimich.dmb@gmail.com Link: https://lore.kernel.org/r/YJ0OCS/sh+1ifD/q@hovoldconsulting.com Cc: stable@vger.kernel.org Signed-off-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- drivers/usb/serial/ch341.c | 1 - 1 file changed, 1 deletion(-) --- a/drivers/usb/serial/ch341.c +++ b/drivers/usb/serial/ch341.c @@ -80,7 +80,6 @@ #define CH341_LCR_CS5 0x00 =20 static const struct usb_device_id id_table[] =3D { - { USB_DEVICE(0x1a86, 0x5512) }, { USB_DEVICE(0x1a86, 0x5523) }, { USB_DEVICE(0x1a86, 0x7522) }, { USB_DEVICE(0x1a86, 0x7523) }, From nobody Tue Jun 23 18:14:07 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 2348CC4167B for ; Mon, 28 Feb 2022 17:37:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238656AbiB1RiG (ORCPT ); Mon, 28 Feb 2022 12:38:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238238AbiB1Rfn (ORCPT ); Mon, 28 Feb 2022 12:35:43 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B949A95A1E; Mon, 28 Feb 2022 09:31: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 37DACB815B8; Mon, 28 Feb 2022 17:31:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8FE02C340F1; Mon, 28 Feb 2022 17:31:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069486; bh=p8i4Tq1JhKBA4elh4tr7Rvc8i93blPcxJzdKjp36pJI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QD1VEN0iKUqLavvXScMRd/Zk2Zk1yhbBFEQOvi+95Is/LtJz9eUJLjqI4vjQTjJwJ Z/RPE+mKOb3fDXDySPyXAJPWi+dt1BwMgtpr1SadVAfyIjoF3SwwKBBwEfnc9j/Cnj wVhKfJNd5vIGUXqgtmvZwEBulk4ZCbDTpYMpoId0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable , Daehwan Jung Subject: [PATCH 5.4 38/53] usb: gadget: rndis: add spinlock for rndis response list Date: Mon, 28 Feb 2022 18:24:36 +0100 Message-Id: <20220228172251.050260261@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: Daehwan Jung commit aaaba1c86d04dac8e49bf508b492f81506257da3 upstream. There's no lock for rndis response list. It could cause list corruption if there're two different list_add at the same time like below. It's better to add in rndis_add_response / rndis_free_response / rndis_get_next_response to prevent any race condition on response list. [ 361.894299] [1: irq/191-dwc3:16979] list_add corruption. next->prev should be prev (ffffff80651764d0), but was ffffff883dc36f80. (next=3Dffffff80651764d0). [ 361.904380] [1: irq/191-dwc3:16979] Call trace: [ 361.904391] [1: irq/191-dwc3:16979] __list_add_valid+0x74/0x90 [ 361.904401] [1: irq/191-dwc3:16979] rndis_msg_parser+0x168/0x8c0 [ 361.904409] [1: irq/191-dwc3:16979] rndis_command_complete+0x24/0x84 [ 361.904417] [1: irq/191-dwc3:16979] usb_gadget_giveback_request+0x20/= 0xe4 [ 361.904426] [1: irq/191-dwc3:16979] dwc3_gadget_giveback+0x44/0x60 [ 361.904434] [1: irq/191-dwc3:16979] dwc3_ep0_complete_data+0x1e8/0x3a0 [ 361.904442] [1: irq/191-dwc3:16979] dwc3_ep0_interrupt+0x29c/0x3dc [ 361.904450] [1: irq/191-dwc3:16979] dwc3_process_event_entry+0x78/0x6= cc [ 361.904457] [1: irq/191-dwc3:16979] dwc3_process_event_buf+0xa0/0x1ec [ 361.904465] [1: irq/191-dwc3:16979] dwc3_thread_interrupt+0x34/0x5c Fixes: f6281af9d62e ("usb: gadget: rndis: use list_for_each_entry_safe") Cc: stable Signed-off-by: Daehwan Jung Link: https://lore.kernel.org/r/1645507768-77687-1-git-send-email-dh10.jung= @samsung.com Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- drivers/usb/gadget/function/rndis.c | 8 ++++++++ drivers/usb/gadget/function/rndis.h | 1 + 2 files changed, 9 insertions(+) --- a/drivers/usb/gadget/function/rndis.c +++ b/drivers/usb/gadget/function/rndis.c @@ -922,6 +922,7 @@ struct rndis_params *rndis_register(void params->resp_avail =3D resp_avail; params->v =3D v; INIT_LIST_HEAD(¶ms->resp_queue); + spin_lock_init(¶ms->resp_lock); pr_debug("%s: configNr =3D %d\n", __func__, i); =20 return params; @@ -1015,12 +1016,14 @@ void rndis_free_response(struct rndis_pa { rndis_resp_t *r, *n; =20 + spin_lock(¶ms->resp_lock); list_for_each_entry_safe(r, n, ¶ms->resp_queue, list) { if (r->buf =3D=3D buf) { list_del(&r->list); kfree(r); } } + spin_unlock(¶ms->resp_lock); } EXPORT_SYMBOL_GPL(rndis_free_response); =20 @@ -1030,14 +1033,17 @@ u8 *rndis_get_next_response(struct rndis =20 if (!length) return NULL; =20 + spin_lock(¶ms->resp_lock); list_for_each_entry_safe(r, n, ¶ms->resp_queue, list) { if (!r->send) { r->send =3D 1; *length =3D r->length; + spin_unlock(¶ms->resp_lock); return r->buf; } } =20 + spin_unlock(¶ms->resp_lock); return NULL; } EXPORT_SYMBOL_GPL(rndis_get_next_response); @@ -1054,7 +1060,9 @@ static rndis_resp_t *rndis_add_response( r->length =3D length; r->send =3D 0; =20 + spin_lock(¶ms->resp_lock); list_add_tail(&r->list, ¶ms->resp_queue); + spin_unlock(¶ms->resp_lock); return r; } =20 --- a/drivers/usb/gadget/function/rndis.h +++ b/drivers/usb/gadget/function/rndis.h @@ -174,6 +174,7 @@ typedef struct rndis_params { void (*resp_avail)(void *v); void *v; struct list_head resp_queue; + spinlock_t resp_lock; } rndis_params; =20 /* RNDIS Message parser and other useless functions */ From nobody Tue Jun 23 18:14:07 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 331A5C4321E for ; Mon, 28 Feb 2022 17:37:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238764AbiB1RiT (ORCPT ); Mon, 28 Feb 2022 12:38:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238152AbiB1Rf7 (ORCPT ); Mon, 28 Feb 2022 12:35:59 -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 918BA88B29; Mon, 28 Feb 2022 09:31: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 2BA8A61359; Mon, 28 Feb 2022 17:31:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 440D6C340F0; Mon, 28 Feb 2022 17:31:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069489; bh=LC9GLPRNXxE7G7VL7b6l3jW0/NAL6RtstC9Wj+2iMi4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zDn/X3EoCdkUqCv9NApiu6Jb+SqfSwgNHuIvjEKC+W31Q+7EPnb2Dh/nhw6WVIUGB 4pk090DZT5ogw1U7X8wzV26soNz6IzIDL2szOocswqZ9B5jicld65bnNEv/qhj6/7r wlpgKFz3l/JZLkeb2HkROksx7HQo0JXyoLuluUmI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Szymon Heidrich , stable Subject: [PATCH 5.4 39/53] USB: gadget: validate endpoint index for xilinx udc Date: Mon, 28 Feb 2022 18:24:37 +0100 Message-Id: <20220228172251.128596176@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: Szymon Heidrich commit 7f14c7227f342d9932f9b918893c8814f86d2a0d upstream. Assure that host may not manipulate the index to point past endpoint array. Signed-off-by: Szymon Heidrich Cc: stable Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- drivers/usb/gadget/udc/udc-xilinx.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/drivers/usb/gadget/udc/udc-xilinx.c +++ b/drivers/usb/gadget/udc/udc-xilinx.c @@ -1613,6 +1613,8 @@ static void xudc_getstatus(struct xusb_u break; case USB_RECIP_ENDPOINT: epnum =3D udc->setup.wIndex & USB_ENDPOINT_NUMBER_MASK; + if (epnum >=3D XUSB_MAX_ENDPOINTS) + goto stall; target_ep =3D &udc->ep[epnum]; epcfgreg =3D udc->read_fn(udc->addr + target_ep->offset); halt =3D epcfgreg & XUSB_EP_CFG_STALL_MASK; @@ -1680,6 +1682,10 @@ static void xudc_set_clear_feature(struc case USB_RECIP_ENDPOINT: if (!udc->setup.wValue) { endpoint =3D udc->setup.wIndex & USB_ENDPOINT_NUMBER_MASK; + if (endpoint >=3D XUSB_MAX_ENDPOINTS) { + xudc_ep0_stall(udc); + return; + } target_ep =3D &udc->ep[endpoint]; outinbit =3D udc->setup.wIndex & USB_ENDPOINT_DIR_MASK; outinbit =3D outinbit >> 7; From nobody Tue Jun 23 18:14:07 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 BA6E1C433F5 for ; Mon, 28 Feb 2022 17:37:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238804AbiB1RiX (ORCPT ); Mon, 28 Feb 2022 12:38:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234072AbiB1RgE (ORCPT ); Mon, 28 Feb 2022 12:36:04 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7822595484; Mon, 28 Feb 2022 09:31: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 ams.source.kernel.org (Postfix) with ESMTPS id 984DEB815BA; Mon, 28 Feb 2022 17:31:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F1BCAC340F0; Mon, 28 Feb 2022 17:31:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069492; bh=5OcLa9xhiQm5sSpWziM/BAipFWqf/w/nCCjsk6ZkN4A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E7PXelrMot0ccOIhlx9wMAAR2eC3uE7ODQCEBZwNWr0rQJ+LiTV4ihZbzO7lNkf3P UEawjRm7xeEEvWzPf1e8EEuLcjStNnIx5sUTpjMbmQfdhuRDfv/+eKUpOSMTf2neJY u8y/u/psYejY/P1Vz7bq9qBLyQM2ZqJuyjHN7vqg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Al Viro , "Steven Rostedt (Google)" Subject: [PATCH 5.4 40/53] tracefs: Set the group ownership in apply_options() not parse_options() Date: Mon, 28 Feb 2022 18:24:38 +0100 Message-Id: <20220228172251.204987715@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: Steven Rostedt (Google) commit 851e99ebeec3f4a672bb5010cf1ece095acee447 upstream. Al Viro brought it to my attention that the dentries may not be filled when the parse_options() is called, causing the call to set_gid() to possibly crash. It should only be called if parse_options() succeeds totally anyway. He suggested the logical place to do the update is in apply_options(). Link: https://lore.kernel.org/all/20220225165219.737025658@goodmis.org/ Link: https://lkml.kernel.org/r/20220225153426.1c4cab6b@gandalf.local.home Cc: stable@vger.kernel.org Acked-by: Al Viro Reported-by: Al Viro Fixes: 48b27b6b5191 ("tracefs: Set all files to the same group ownership as= the mount option") Signed-off-by: Steven Rostedt (Google) Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- fs/tracefs/inode.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -262,7 +262,6 @@ static int tracefs_parse_options(char *d if (!gid_valid(gid)) return -EINVAL; opts->gid =3D gid; - set_gid(tracefs_mount->mnt_root, gid); break; case Opt_mode: if (match_octal(&args[0], &option)) @@ -289,7 +288,9 @@ static int tracefs_apply_options(struct inode->i_mode |=3D opts->mode; =20 inode->i_uid =3D opts->uid; - inode->i_gid =3D opts->gid; + + /* Set all the group ids to the mount option */ + set_gid(sb->s_root, opts->gid); =20 return 0; } From nobody Tue Jun 23 18:14:07 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 87B1FC4332F for ; Mon, 28 Feb 2022 17:39:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238688AbiB1RiN (ORCPT ); Mon, 28 Feb 2022 12:38:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238161AbiB1RgC (ORCPT ); Mon, 28 Feb 2022 12:36:02 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3BE788B31; Mon, 28 Feb 2022 09:31: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 A4F3A612FA; Mon, 28 Feb 2022 17:31:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE381C340F0; Mon, 28 Feb 2022 17:31:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069495; bh=DzwcJXbODgTKFsEgFpXDiJ68s9xoeQXLilc34DuJJns=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R1G3gMM28yS5QCX8dKME1mV+e0v1AscktHqxpueIZxafCaGsLuaYRO5ZJic6TokEk W2jDyW9Cr6/Q2Lpd4tNLyI0kOJVCZg08lDaJ6BaK5WxzjqKF4vttw2gHT2c0Zbse7p VWjUN/DGJXGr+CYYEB+DBz7YthgWo5QegBSOUN8A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Slark Xiao , Johan Hovold Subject: [PATCH 5.4 41/53] USB: serial: option: add support for DW5829e Date: Mon, 28 Feb 2022 18:24:39 +0100 Message-Id: <20220228172251.276023966@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: Slark Xiao commit 6ecb3f0b18b320320460a42e40d6fb603f6ded96 upstream. Dell DW5829e same as DW5821e except CAT level. DW5821e supports CAT16 but DW5829e supports CAT9. There are 2 types product of DW5829e: normal and eSIM. So we will add 2 PID for DW5829e. And for each PID, it support MBIM or RMNET. Let's see test evidence as below: DW5829e MBIM mode: T: Bus=3D04 Lev=3D01 Prnt=3D01 Port=3D01 Cnt=3D01 Dev#=3D 4 Spd=3D5000 Mx= Ch=3D 0 D: Ver=3D 3.10 Cls=3Def(misc ) Sub=3D02 Prot=3D01 MxPS=3D 9 #Cfgs=3D 2 P: Vendor=3D413c ProdID=3D81e6 Rev=3D03.18 S: Manufacturer=3DDell Inc. S: Product=3DDW5829e Snapdragon X20 LTE S: SerialNumber=3D0123456789ABCDEF C: #Ifs=3D 7 Cfg#=3D 2 Atr=3Da0 MxPwr=3D896mA I: If#=3D0x0 Alt=3D 0 #EPs=3D 1 Cls=3D02(commc) Sub=3D0e Prot=3D00 Driver= =3Dcdc_mbim I: If#=3D0x1 Alt=3D 1 #EPs=3D 2 Cls=3D0a(data ) Sub=3D00 Prot=3D02 Driver= =3Dcdc_mbim I: If#=3D0x2 Alt=3D 0 #EPs=3D 3 Cls=3Dff(vend.) Sub=3D00 Prot=3D00 Driver= =3Doption I: If#=3D0x3 Alt=3D 0 #EPs=3D 3 Cls=3Dff(vend.) Sub=3D00 Prot=3D00 Driver= =3Doption I: If#=3D0x4 Alt=3D 0 #EPs=3D 3 Cls=3Dff(vend.) Sub=3D00 Prot=3D00 Driver= =3Doption I: If#=3D0x5 Alt=3D 0 #EPs=3D 2 Cls=3Dff(vend.) Sub=3Dff Prot=3Dff Driver= =3Doption I: If#=3D0x6 Alt=3D 0 #EPs=3D 1 Cls=3Dff(vend.) Sub=3Dff Prot=3Dff Driver= =3D(none) DW5829e RMNET mode: T: Bus=3D04 Lev=3D01 Prnt=3D01 Port=3D01 Cnt=3D01 Dev#=3D 5 Spd=3D5000 Mx= Ch=3D 0 D: Ver=3D 3.10 Cls=3Def(misc ) Sub=3D02 Prot=3D01 MxPS=3D 9 #Cfgs=3D 1 P: Vendor=3D413c ProdID=3D81e6 Rev=3D03.18 S: Manufacturer=3DDell Inc. S: Product=3DDW5829e Snapdragon X20 LTE S: SerialNumber=3D0123456789ABCDEF C: #Ifs=3D 6 Cfg#=3D 1 Atr=3Da0 MxPwr=3D896mA I: If#=3D0x0 Alt=3D 0 #EPs=3D 3 Cls=3Dff(vend.) Sub=3Dff Prot=3Dff Driver= =3Dqmi_wwan I: If#=3D0x1 Alt=3D 0 #EPs=3D 1 Cls=3D03(HID ) Sub=3D00 Prot=3D00 Driver= =3Dusbhid I: If#=3D0x2 Alt=3D 0 #EPs=3D 3 Cls=3Dff(vend.) Sub=3D00 Prot=3D00 Driver= =3Doption I: If#=3D0x3 Alt=3D 0 #EPs=3D 3 Cls=3Dff(vend.) Sub=3D00 Prot=3D00 Driver= =3Doption I: If#=3D0x4 Alt=3D 0 #EPs=3D 3 Cls=3Dff(vend.) Sub=3D00 Prot=3D00 Driver= =3Doption I: If#=3D0x5 Alt=3D 0 #EPs=3D 2 Cls=3Dff(vend.) Sub=3Dff Prot=3Dff Driver= =3Doption DW5829e-eSIM MBIM mode: T: Bus=3D04 Lev=3D01 Prnt=3D01 Port=3D01 Cnt=3D01 Dev#=3D 6 Spd=3D5000 Mx= Ch=3D 0 D: Ver=3D 3.10 Cls=3Def(misc ) Sub=3D02 Prot=3D01 MxPS=3D 9 #Cfgs=3D 2 P: Vendor=3D413c ProdID=3D81e4 Rev=3D03.18 S: Manufacturer=3DDell Inc. S: Product=3DDW5829e-eSIM Snapdragon X20 LTE S: SerialNumber=3D0123456789ABCDEF C: #Ifs=3D 7 Cfg#=3D 2 Atr=3Da0 MxPwr=3D896mA I: If#=3D0x0 Alt=3D 0 #EPs=3D 1 Cls=3D02(commc) Sub=3D0e Prot=3D00 Driver= =3Dcdc_mbim I: If#=3D0x1 Alt=3D 1 #EPs=3D 2 Cls=3D0a(data ) Sub=3D00 Prot=3D02 Driver= =3Dcdc_mbim I: If#=3D0x2 Alt=3D 0 #EPs=3D 3 Cls=3Dff(vend.) Sub=3D00 Prot=3D00 Driver= =3Doption I: If#=3D0x3 Alt=3D 0 #EPs=3D 3 Cls=3Dff(vend.) Sub=3D00 Prot=3D00 Driver= =3Doption I: If#=3D0x4 Alt=3D 0 #EPs=3D 3 Cls=3Dff(vend.) Sub=3D00 Prot=3D00 Driver= =3Doption I: If#=3D0x5 Alt=3D 0 #EPs=3D 2 Cls=3Dff(vend.) Sub=3Dff Prot=3Dff Driver= =3Doption I: If#=3D0x6 Alt=3D 0 #EPs=3D 1 Cls=3Dff(vend.) Sub=3Dff Prot=3Dff Driver= =3D(none) DW5829e-eSIM RMNET mode: T: Bus=3D04 Lev=3D01 Prnt=3D01 Port=3D01 Cnt=3D01 Dev#=3D 7 Spd=3D5000 Mx= Ch=3D 0 D: Ver=3D 3.10 Cls=3Def(misc ) Sub=3D02 Prot=3D01 MxPS=3D 9 #Cfgs=3D 1 P: Vendor=3D413c ProdID=3D81e4 Rev=3D03.18 S: Manufacturer=3DDell Inc. S: Product=3DDW5829e-eSIM Snapdragon X20 LTE S: SerialNumber=3D0123456789ABCDEF C: #Ifs=3D 6 Cfg#=3D 1 Atr=3Da0 MxPwr=3D896mA I: If#=3D0x0 Alt=3D 0 #EPs=3D 3 Cls=3Dff(vend.) Sub=3Dff Prot=3Dff Driver= =3Dqmi_wwan I: If#=3D0x1 Alt=3D 0 #EPs=3D 1 Cls=3D03(HID ) Sub=3D00 Prot=3D00 Driver= =3Dusbhid I: If#=3D0x2 Alt=3D 0 #EPs=3D 3 Cls=3Dff(vend.) Sub=3D00 Prot=3D00 Driver= =3Doption I: If#=3D0x3 Alt=3D 0 #EPs=3D 3 Cls=3Dff(vend.) Sub=3D00 Prot=3D00 Driver= =3Doption I: If#=3D0x4 Alt=3D 0 #EPs=3D 3 Cls=3Dff(vend.) Sub=3D00 Prot=3D00 Driver= =3Doption I: If#=3D0x5 Alt=3D 0 #EPs=3D 2 Cls=3Dff(vend.) Sub=3Dff Prot=3Dff Driver= =3Doption BTW, the interface 0x6 of MBIM mode is GNSS port, which not same as NMEA port. So it's banned from serial option driver. The remaining interfaces 0x2-0x5 are: MODEM, MODEM, NMEA, DIAG. Signed-off-by: Slark Xiao Link: https://lore.kernel.org/r/20220214021401.6264-1-slark_xiao@163.com [ johan: drop unnecessary reservation of interface 1 ] Cc: stable@vger.kernel.org Signed-off-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- drivers/usb/serial/option.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c @@ -198,6 +198,8 @@ static void option_instat_callback(struc =20 #define DELL_PRODUCT_5821E 0x81d7 #define DELL_PRODUCT_5821E_ESIM 0x81e0 +#define DELL_PRODUCT_5829E_ESIM 0x81e4 +#define DELL_PRODUCT_5829E 0x81e6 =20 #define KYOCERA_VENDOR_ID 0x0c88 #define KYOCERA_PRODUCT_KPC650 0x17da @@ -1063,6 +1065,10 @@ static const struct usb_device_id option .driver_info =3D RSVD(0) | RSVD(1) | RSVD(6) }, { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5821E_ESIM), .driver_info =3D RSVD(0) | RSVD(1) | RSVD(6) }, + { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5829E), + .driver_info =3D RSVD(0) | RSVD(6) }, + { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5829E_ESIM), + .driver_info =3D RSVD(0) | RSVD(6) }, { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) }, /* ADU-E100= , ADU-310 */ { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) }, { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_620UW) }, From nobody Tue Jun 23 18:14:07 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 BFA6BC433FE for ; Mon, 28 Feb 2022 17:37:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237036AbiB1Ri2 (ORCPT ); Mon, 28 Feb 2022 12:38:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238269AbiB1RgY (ORCPT ); Mon, 28 Feb 2022 12:36:24 -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 3719985665; Mon, 28 Feb 2022 09:31: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 5CA66B815B0; Mon, 28 Feb 2022 17:31:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8AD72C340E7; Mon, 28 Feb 2022 17:31:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069498; bh=TG+mq0mWCM/MrB0JN5FlEuzzUbsrlAfNgtd+H9v3LVM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r35sbDTruOY5y7E3poy9ti3hmsWpnrcVJmiRoZKtf1SL5iPBw44ug1nXqN3pggicR D0NoO6gUOCR6hDeclXnHuz9anO5Idy2GwiEZeJc6WQ4DvCc+7nctOja5kQBtioGVNU 6u1ah2swPRyjpstOuFYhFM60HtAwG+wk1qgXbYSo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniele Palmas , Johan Hovold Subject: [PATCH 5.4 42/53] USB: serial: option: add Telit LE910R1 compositions Date: Mon, 28 Feb 2022 18:24:40 +0100 Message-Id: <20220228172251.347271288@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: Daniele Palmas commit cfc4442c642d568014474b6718ccf65dc7ca6099 upstream. Add support for the following Telit LE910R1 compositions: 0x701a: rndis, tty, tty, tty 0x701b: ecm, tty, tty, tty 0x9201: tty Signed-off-by: Daniele Palmas Link: https://lore.kernel.org/r/20220218134552.4051-1-dnlplm@gmail.com Cc: stable@vger.kernel.org Signed-off-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- drivers/usb/serial/option.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c @@ -1279,10 +1279,16 @@ static const struct usb_device_id option .driver_info =3D NCTRL(2) }, { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x7011, 0xff), /* Telit LE9= 10-S1 (ECM) */ .driver_info =3D NCTRL(2) }, + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x701a, 0xff), /* Telit LE9= 10R1 (RNDIS) */ + .driver_info =3D NCTRL(2) }, + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x701b, 0xff), /* Telit LE9= 10R1 (ECM) */ + .driver_info =3D NCTRL(2) }, { USB_DEVICE(TELIT_VENDOR_ID, 0x9010), /* Telit SBL FN980 flashing dev= ice */ .driver_info =3D NCTRL(0) | ZLP }, { USB_DEVICE(TELIT_VENDOR_ID, 0x9200), /* Telit LE910S1 flashing devic= e */ .driver_info =3D NCTRL(0) | ZLP }, + { USB_DEVICE(TELIT_VENDOR_ID, 0x9201), /* Telit LE910R1 flashing devic= e */ + .driver_info =3D NCTRL(0) | ZLP }, { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF622, 0xff, 0= xff, 0xff) }, /* ZTE WCDMA products */ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0002, 0xff, 0xff, 0xff), .driver_info =3D RSVD(1) }, From nobody Tue Jun 23 18:14:07 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 1A3DCC433EF for ; Mon, 28 Feb 2022 17:38:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238168AbiB1Rih (ORCPT ); Mon, 28 Feb 2022 12:38:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238280AbiB1Rg0 (ORCPT ); Mon, 28 Feb 2022 12:36: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 8FFA29681E; Mon, 28 Feb 2022 09:31: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 ams.source.kernel.org (Postfix) with ESMTPS id 1AAACB815AB; Mon, 28 Feb 2022 17:31:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6EA00C340F3; Mon, 28 Feb 2022 17:31:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069500; bh=0uozSdYEpm4wPeKQjXI6P7p2CNOcuYuCBw5SCjpmGnI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rg072FYeCZojlFw5guDixWR1d7DexwJ53guKPe24FNLXUQLq3LzQNlrtD/bnt2pAE asZk374rCqfi6xwxnDiqrxi+aMW3qKBqyb0f+yEhSC7UReJ6TLQj5cpxkRwIP+6t2Z iMRH2M7PJ3ELvFfOhiHvCnkNP8t48qaGlmddnE0Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hans de Goede Subject: [PATCH 5.4 43/53] usb: dwc3: pci: Fix Bay Trail phy GPIO mappings Date: Mon, 28 Feb 2022 18:24:41 +0100 Message-Id: <20220228172251.430271739@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: Hans de Goede commit 62e3f0afe246720f7646eb1b034a6897dac34405 upstream. When the Bay Trail phy GPIO mappings where added cs and reset were swapped, this did not cause any issues sofar, because sofar they were always driven high/low at the same time. Note the new mapping has been verified both in /sys/kernel/debug/gpio output on Android factory images on multiple devices, as well as in the schematics for some devices. Fixes: 5741022cbdf3 ("usb: dwc3: pci: Add GPIO lookup table on platforms wi= thout ACPI GPIO resources") Cc: stable Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20220213130524.18748-3-hdegoede@redhat.com Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- drivers/usb/dwc3/dwc3-pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/usb/dwc3/dwc3-pci.c +++ b/drivers/usb/dwc3/dwc3-pci.c @@ -81,8 +81,8 @@ static const struct acpi_gpio_mapping ac static struct gpiod_lookup_table platform_bytcr_gpios =3D { .dev_id =3D "0000:00:16.0", .table =3D { - GPIO_LOOKUP("INT33FC:00", 54, "reset", GPIO_ACTIVE_HIGH), - GPIO_LOOKUP("INT33FC:02", 14, "cs", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("INT33FC:00", 54, "cs", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("INT33FC:02", 14, "reset", GPIO_ACTIVE_HIGH), {} }, }; From nobody Tue Jun 23 18:14:07 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 8FD0CC433EF for ; Mon, 28 Feb 2022 17:38:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236557AbiB1Rit (ORCPT ); Mon, 28 Feb 2022 12:38:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238140AbiB1Rg0 (ORCPT ); Mon, 28 Feb 2022 12:36: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 1704F88B14; Mon, 28 Feb 2022 09:31: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 1EEAE6135F; Mon, 28 Feb 2022 17:31:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 270B4C340E7; Mon, 28 Feb 2022 17:31:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069503; bh=3B6U30DnZLogicG+t+CFTLySNfmtFdpaMTdhUnrn9t0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e/PI8FiRc1M0Yt0lISyxJToTZDYMWpbjIP+YDFmatYp9jzBQjnIj7kSHsJwzIDxfc 3y7zpF+CfF6XG3XzJ1t57129G003yoSwR3jd60533fiZN5zZEVPn980RYesL7pbB7i 7JGaIyTvgrxIfma7GvztmHa5AjQjiZY52XvQhCgs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable , Marek Szyprowski , Sebastian Andrzej Siewior Subject: [PATCH 5.4 44/53] usb: dwc3: gadget: Let the interrupt handler disable bottom halves. Date: Mon, 28 Feb 2022 18:24:42 +0100 Message-Id: <20220228172251.492857297@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: Sebastian Andrzej Siewior commit 84918a89d6efaff075de570b55642b6f4ceeac6d upstream. The interrupt service routine registered for the gadget is a primary handler which mask the interrupt source and a threaded handler which handles the source of the interrupt. Since the threaded handler is voluntary threaded, the IRQ-core does not disable bottom halves before invoke the handler like it does for the forced-threaded handler. Due to changes in networking it became visible that a network gadget's completions handler may schedule a softirq which remains unprocessed. The gadget's completion handler is usually invoked either in hard-IRQ or soft-IRQ context. In this context it is enough to just raise the softirq because the softirq itself will be handled once that context is left. In the case of the voluntary threaded handler, there is nothing that will process pending softirqs. Which means it remain queued until another random interrupt (on this CPU) fires and handles it on its exit path or another thread locks and unlocks a lock with the bh suffix. Worst case is that the CPU goes idle and the NOHZ complains about unhandled softirqs. Disable bottom halves before acquiring the lock (and disabling interrupts) and enable them after dropping the lock. This ensures that any pending softirqs will handled right away. Link: https://lkml.kernel.org/r/c2a64979-73d1-2c22-e048-c275c9f81558@samsun= g.com Fixes: e5f68b4a3e7b0 ("Revert "usb: dwc3: gadget: remove unnecessary _irqsa= ve()"") Cc: stable Reported-by: Marek Szyprowski Tested-by: Marek Szyprowski Signed-off-by: Sebastian Andrzej Siewior Link: https://lore.kernel.org/r/Yg/YPejVQH3KkRVd@linutronix.de Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- drivers/usb/dwc3/gadget.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -3529,9 +3529,11 @@ static irqreturn_t dwc3_thread_interrupt unsigned long flags; irqreturn_t ret =3D IRQ_NONE; =20 + local_bh_disable(); spin_lock_irqsave(&dwc->lock, flags); ret =3D dwc3_process_event_buf(evt); spin_unlock_irqrestore(&dwc->lock, flags); + local_bh_enable(); =20 return ret; } From nobody Tue Jun 23 18:14:07 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 0F5C2C433EF for ; Mon, 28 Feb 2022 17:38:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238399AbiB1Ril (ORCPT ); Mon, 28 Feb 2022 12:38:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237476AbiB1Rg3 (ORCPT ); Mon, 28 Feb 2022 12:36: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 EE72396839; Mon, 28 Feb 2022 09:31: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 CFB8A61357; Mon, 28 Feb 2022 17:31:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E2B9FC340E7; Mon, 28 Feb 2022 17:31:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069506; bh=6ttKOQ9m0Pb17Q3CVH254bmmxO+Df4LgDPnSSCUWaO4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZawDyaUPVnpspj3LqL03JjJsG3kNBz81Mvd8OtPKsa/nvz3foB308TnUZu+2btlzM SYJYmwUy3jTf+WsJB8yVd1p+fja8nKCGzPAq6Or99FbfiniwA8r/KZ8o9jWwCN9ImZ ef4kzRtothYLf2Mk3tUKdFnXCfn1ldp0pVwyx8B8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Puma Hsu , Mathias Nyman Subject: [PATCH 5.4 45/53] xhci: re-initialize the HC during resume if HCE was set Date: Mon, 28 Feb 2022 18:24:43 +0100 Message-Id: <20220228172251.553098751@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: Puma Hsu commit 8b328f8002bcf29ef517ee4bf234e09aabec4d2e upstream. When HCE(Host Controller Error) is set, it means an internal error condition has been detected. Software needs to re-initialize the HC, so add this check in xhci resume. Cc: stable@vger.kernel.org Signed-off-by: Puma Hsu Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20220215123320.1253947-2-mathias.nyman@linu= x.intel.com Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- drivers/usb/host/xhci.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -1091,6 +1091,7 @@ int xhci_resume(struct xhci_hcd *xhci, b int retval =3D 0; bool comp_timer_running =3D false; bool pending_portevent =3D false; + bool reinit_xhc =3D false; =20 if (!hcd->state) return 0; @@ -1107,10 +1108,11 @@ int xhci_resume(struct xhci_hcd *xhci, b set_bit(HCD_FLAG_HW_ACCESSIBLE, &xhci->shared_hcd->flags); =20 spin_lock_irq(&xhci->lock); - if ((xhci->quirks & XHCI_RESET_ON_RESUME) || xhci->broken_suspend) - hibernated =3D true; =20 - if (!hibernated) { + if (hibernated || xhci->quirks & XHCI_RESET_ON_RESUME || xhci->broken_sus= pend) + reinit_xhc =3D true; + + if (!reinit_xhc) { /* * Some controllers might lose power during suspend, so wait * for controller not ready bit to clear, just as in xHC init. @@ -1143,12 +1145,17 @@ int xhci_resume(struct xhci_hcd *xhci, b spin_unlock_irq(&xhci->lock); return -ETIMEDOUT; } - temp =3D readl(&xhci->op_regs->status); } =20 - /* If restore operation fails, re-initialize the HC during resume */ - if ((temp & STS_SRE) || hibernated) { + temp =3D readl(&xhci->op_regs->status); + + /* re-initialize the HC on Restore Error, or Host Controller Error */ + if (temp & (STS_SRE | STS_HCE)) { + reinit_xhc =3D true; + xhci_warn(xhci, "xHC error in resume, USBSTS 0x%x, Reinit\n", temp); + } =20 + if (reinit_xhc) { if ((xhci->quirks & XHCI_COMP_MODE_QUIRK) && !(xhci_all_ports_seen_u0(xhci))) { del_timer_sync(&xhci->comp_mode_recovery_timer); From nobody Tue Jun 23 18:14:07 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 321F3C4332F for ; Mon, 28 Feb 2022 17:38:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237773AbiB1RjD (ORCPT ); Mon, 28 Feb 2022 12:39:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238273AbiB1Rgv (ORCPT ); Mon, 28 Feb 2022 12:36:51 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 071D488792; Mon, 28 Feb 2022 09:31: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 E3342B815A6; Mon, 28 Feb 2022 17:31:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 527E2C340E7; Mon, 28 Feb 2022 17:31:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069511; bh=/IPjo5Im5eTlmflgA6jvO3M2vFnLOiss2A90CD++VY8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bq+3kQpO4S5b/FUiYEB44i2VNzEh69+P8syu2k1RM0U1ne9p0TQ94S6iUwuoqEEJa 4+N8rIMHaexHh06lntda2UrpIRzTOcsWwSfler1C2bThCkOsqCthYdmrWxA/RGdUHh 4NMX+mT1hGDbMxhoAla2WWw+1xrQGTMd3NIdPVpc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hongyu Xie , Mathias Nyman Subject: [PATCH 5.4 46/53] xhci: Prevent futile URB re-submissions due to incorrect return value. Date: Mon, 28 Feb 2022 18:24:44 +0100 Message-Id: <20220228172251.616249061@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: Hongyu Xie commit 243a1dd7ba48c120986dd9e66fee74bcb7751034 upstream. The -ENODEV return value from xhci_check_args() is incorrectly changed to -EINVAL in a couple places before propagated further. xhci_check_args() returns 4 types of value, -ENODEV, -EINVAL, 1 and 0. xhci_urb_enqueue and xhci_check_streams_endpoint return -EINVAL if the return value of xhci_check_args <=3D 0. This causes problems for example r8152_submit_rx, calling usb_submit_urb in drivers/net/usb/r8152.c. r8152_submit_rx will never get -ENODEV after submiting an urb when xHC is halted because xhci_urb_enqueue returns -EINVAL in the very beginning. [commit message and header edit -Mathias] Fixes: 203a86613fb3 ("xhci: Avoid NULL pointer deref when host dies.") Cc: stable@vger.kernel.org Signed-off-by: Hongyu Xie Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20220215123320.1253947-3-mathias.nyman@linu= x.intel.com Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- drivers/usb/host/xhci.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -1487,9 +1487,12 @@ static int xhci_urb_enqueue(struct usb_h struct urb_priv *urb_priv; int num_tds; =20 - if (!urb || xhci_check_args(hcd, urb->dev, urb->ep, - true, true, __func__) <=3D 0) + if (!urb) return -EINVAL; + ret =3D xhci_check_args(hcd, urb->dev, urb->ep, + true, true, __func__); + if (ret <=3D 0) + return ret ? ret : -EINVAL; =20 slot_id =3D urb->dev->slot_id; ep_index =3D xhci_get_endpoint_index(&urb->ep->desc); @@ -3289,7 +3292,7 @@ static int xhci_check_streams_endpoint(s return -EINVAL; ret =3D xhci_check_args(xhci_to_hcd(xhci), udev, ep, 1, true, __func__); if (ret <=3D 0) - return -EINVAL; + return ret ? ret : -EINVAL; if (usb_ss_max_streams(&ep->ss_ep_comp) =3D=3D 0) { xhci_warn(xhci, "WARN: SuperSpeed Endpoint Companion" " descriptor for ep 0x%x does not support streams\n", From nobody Tue Jun 23 18:14:07 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 361C8C433FE for ; Mon, 28 Feb 2022 17:38:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237973AbiB1RjK (ORCPT ); Mon, 28 Feb 2022 12:39:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238227AbiB1Rgw (ORCPT ); Mon, 28 Feb 2022 12:36: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 F2C87985B4; Mon, 28 Feb 2022 09:31: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 EAB1061365; Mon, 28 Feb 2022 17:31:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C2B3C340F0; Mon, 28 Feb 2022 17:31:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069514; bh=vEPAZ3lTc+fwgGKdNcNvLHd+Ln7uEJIIVY59/b1a6eI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sFxfHYtP1FaBxzz0FWPSLrv/YILh+AJlA4frdq02CfVh3sbT/mq8Z4eQ4BXvF34ZS +R16UOZ4TblkUWhhZHYIn0aCnLnRZXOJlUZ0210L7W6HIemPnk0IPtuRKvzpKQVuAu 1dbakx0ExormJbBC/doCWYAdqLugIKV6SuYLLPwg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Starke Subject: [PATCH 5.4 47/53] tty: n_gsm: fix encoding of control signal octet bit DV Date: Mon, 28 Feb 2022 18:24:45 +0100 Message-Id: <20220228172251.681315920@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: daniel.starke@siemens.com commit 737b0ef3be6b319d6c1fd64193d1603311969326 upstream. n_gsm is based on the 3GPP 07.010 and its newer version is the 3GPP 27.010. See https://portal.3gpp.org/desktopmodules/Specifications/SpecificationDeta= ils.aspx?specificationId=3D1516 The changes from 07.010 to 27.010 are non-functional. Therefore, I refer to the newer 27.010 here. Chapter 5.4.6.3.7 describes the encoding of the control signal octet used by the MSC (modem status command). The same encoding is also used in convergence layer type 2 as described in chapter 5.5.2. Table 7 and 24 both require the DV (data valid) bit to be set 1 for outgoing control signal octets sent by the DTE (data terminal equipment), i.e. for the initiator side. Currently, the DV bit is only set if CD (carrier detect) is on, regardless of the side. This patch fixes this behavior by setting the DV bit on the initiator side unconditionally. Fixes: e1eaea46bb40 ("tty: n_gsm line discipline") Cc: stable@vger.kernel.org Signed-off-by: Daniel Starke Link: https://lore.kernel.org/r/20220218073123.2121-1-daniel.starke@siemens= .com Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- drivers/tty/n_gsm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -428,7 +428,7 @@ static u8 gsm_encode_modem(const struct modembits |=3D MDM_RTR; if (dlci->modem_tx & TIOCM_RI) modembits |=3D MDM_IC; - if (dlci->modem_tx & TIOCM_CD) + if (dlci->modem_tx & TIOCM_CD || dlci->gsm->initiator) modembits |=3D MDM_DV; return modembits; } From nobody Tue Jun 23 18:14:07 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 1DC9EC433FE for ; Mon, 28 Feb 2022 17:38:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236349AbiB1RjZ (ORCPT ); Mon, 28 Feb 2022 12:39:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238316AbiB1RhO (ORCPT ); Mon, 28 Feb 2022 12:37:14 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25F4D8A6CE; Mon, 28 Feb 2022 09:32:10 -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 70C26B815AC; Mon, 28 Feb 2022 17:31:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B601DC340E7; Mon, 28 Feb 2022 17:31:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069517; bh=DOUNBwYA9JP+Lq4UjXFlsFmonEHF0xINmyozSDtOuas=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yfi03rQYY0Sr8BYFX2AS5gYwvr8QnRkJTiHigYO0TlfTp5DFqg23QZw/rn773DquS +xYctaiizD+DB4FIBQqbeM6zHwMpWdvk9nc7nB+26+OU5xHDre1UQY1mNe9N+TbKVf BkQMEu7oUoM8WDuHQCJnCvLx31ZK4icLeKKvO7k8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Starke Subject: [PATCH 5.4 48/53] tty: n_gsm: fix proper link termination after failed open Date: Mon, 28 Feb 2022 18:24:46 +0100 Message-Id: <20220228172251.762472170@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: daniel.starke@siemens.com commit e3b7468f082d106459e86e8dc6fb9bdd65553433 upstream. Trying to open a DLCI by sending a SABM frame may fail with a timeout. The link is closed on the initiator side without informing the responder about this event. The responder assumes the link is open after sending a UA frame to answer the SABM frame. The link gets stuck in a half open state. This patch fixes this by initiating the proper link termination procedure after link setup timeout instead of silently closing it down. Fixes: e1eaea46bb40 ("tty: n_gsm line discipline") Cc: stable@vger.kernel.org Signed-off-by: Daniel Starke Link: https://lore.kernel.org/r/20220218073123.2121-3-daniel.starke@siemens= .com Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- drivers/tty/n_gsm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -1490,7 +1490,7 @@ static void gsm_dlci_t1(struct timer_lis dlci->mode =3D DLCI_MODE_ADM; gsm_dlci_open(dlci); } else { - gsm_dlci_close(dlci); + gsm_dlci_begin_close(dlci); /* prevent half open link */ } =20 break; From nobody Tue Jun 23 18:14:07 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 0FDE9C433F5 for ; Mon, 28 Feb 2022 17:38:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238063AbiB1RjO (ORCPT ); Mon, 28 Feb 2022 12:39:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238291AbiB1RhK (ORCPT ); Mon, 28 Feb 2022 12:37:10 -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 5772689CD9; Mon, 28 Feb 2022 09:32: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 6604D61357; Mon, 28 Feb 2022 17:32:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F897C340E7; Mon, 28 Feb 2022 17:31:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069519; bh=y1SU/BTsz0Cz1b5TkDBk+IMdQX/XvpIL1a+b4XrJ5wg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SxHgYrObN4hJziQMHXTc395KP6rbVqTI7SNFW0N+fXqHZ4Z7+32nxdbY1rdPA5GPg Z6vS6T8l1xlKTuZA/u8zhiW5WBygf+/cy6sy3nDveVba/pmoFFWpnIPAUEYZ2gnaH2 kTf1UjvPY9HqNz4zXJUV8SxYrV2Ds7Xf/GXLQvq4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Starke Subject: [PATCH 5.4 49/53] tty: n_gsm: fix NULL pointer access due to DLCI release Date: Mon, 28 Feb 2022 18:24:47 +0100 Message-Id: <20220228172251.843432793@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: daniel.starke@siemens.com commit 96b169f05cdcc844b400695184d77e42071d14f2 upstream. The here fixed commit made the tty hangup asynchronous to avoid a circular locking warning. I could not reproduce this warning. Furthermore, due to the asynchronous hangup the function call now gets queued up while the underlying tty is being freed. Depending on the timing this results in a NULL pointer access in the global work queue scheduler. To be precise in process_one_work(). Therefore, the previous commit made the issue worse which it tried to fix. This patch fixes this by falling back to the old behavior which uses a blocking tty hangup call before freeing up the associated tty. Fixes: 7030082a7415 ("tty: n_gsm: avoid recursive locking with async port h= angup") Cc: stable@vger.kernel.org Signed-off-by: Daniel Starke Link: https://lore.kernel.org/r/20220218073123.2121-4-daniel.starke@siemens= .com Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- drivers/tty/n_gsm.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -1722,7 +1722,12 @@ static void gsm_dlci_release(struct gsm_ gsm_destroy_network(dlci); mutex_unlock(&dlci->mutex); =20 - tty_hangup(tty); + /* We cannot use tty_hangup() because in tty_kref_put() the tty + * driver assumes that the hangup queue is free and reuses it to + * queue release_one_tty() -> NULL pointer panic in + * process_one_work(). + */ + tty_vhangup(tty); =20 tty_port_tty_set(&dlci->port, NULL); tty_kref_put(tty); From nobody Tue Jun 23 18:14:07 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 9A20BC433F5 for ; Mon, 28 Feb 2022 17:41:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238445AbiB1RmD (ORCPT ); Mon, 28 Feb 2022 12:42:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238334AbiB1Rh0 (ORCPT ); Mon, 28 Feb 2022 12:37:26 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 561033BFB5; Mon, 28 Feb 2022 09:32:24 -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 EBD3DB815BD; Mon, 28 Feb 2022 17:32:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35967C340F1; Mon, 28 Feb 2022 17:32:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069522; bh=lOKstslbYrY+nxQARpLVOyEJ89Vqe2153PAdOHBhjNs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cJ6D3YChNfw9YsdogXnZRwoT2y3U+8pK9a9nV5dD7nnWP0i6X1hoZs7p18C0LuC1h +mq4BTzgnqcTyvcf4qt5rtAGkg40DlPhjX+mD21RLLWT9jUSXYsoCr490cvddmCAHu IoBvEoP4ifVNT3hFbopAh5WLyJ+pc3oawEm9bSqw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marc Zyngier , Thierry Reding , Linus Walleij , Bartosz Golaszewski Subject: [PATCH 5.4 50/53] gpio: tegra186: Fix chip_data type confusion Date: Mon, 28 Feb 2022 18:24:48 +0100 Message-Id: <20220228172251.915821058@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: Marc Zyngier commit d1e972ace42390de739cde87d96043dcbe502286 upstream. The tegra186 GPIO driver makes the assumption that the pointer returned by irq_data_get_irq_chip_data() is a pointer to a tegra_gpio structure. Unfortunately, it is actually a pointer to the inner gpio_chip structure, as mandated by the gpiolib infrastructure. Nice try. The saving grace is that the gpio_chip is the first member of tegra_gpio, so the bug has gone undetected since... forever. Fix it by performing a container_of() on the pointer. This results in no additional code, and makes it possible to understand how the whole thing works. Fixes: 5b2b135a87fc ("gpio: Add Tegra186 support") Signed-off-by: Marc Zyngier Cc: Thierry Reding Cc: Linus Walleij Cc: Bartosz Golaszewski Link: https://lore.kernel.org/r/20220211093904.1112679-1-maz@kernel.org Signed-off-by: Linus Walleij Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- drivers/gpio/gpio-tegra186.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) --- a/drivers/gpio/gpio-tegra186.c +++ b/drivers/gpio/gpio-tegra186.c @@ -234,9 +234,12 @@ static int tegra186_gpio_of_xlate(struct return offset + pin; } =20 +#define to_tegra_gpio(x) container_of((x), struct tegra_gpio, gpio) + static void tegra186_irq_ack(struct irq_data *data) { - struct tegra_gpio *gpio =3D irq_data_get_irq_chip_data(data); + struct gpio_chip *gc =3D irq_data_get_irq_chip_data(data); + struct tegra_gpio *gpio =3D to_tegra_gpio(gc); void __iomem *base; =20 base =3D tegra186_gpio_get_base(gpio, data->hwirq); @@ -248,7 +251,8 @@ static void tegra186_irq_ack(struct irq_ =20 static void tegra186_irq_mask(struct irq_data *data) { - struct tegra_gpio *gpio =3D irq_data_get_irq_chip_data(data); + struct gpio_chip *gc =3D irq_data_get_irq_chip_data(data); + struct tegra_gpio *gpio =3D to_tegra_gpio(gc); void __iomem *base; u32 value; =20 @@ -263,7 +267,8 @@ static void tegra186_irq_mask(struct irq =20 static void tegra186_irq_unmask(struct irq_data *data) { - struct tegra_gpio *gpio =3D irq_data_get_irq_chip_data(data); + struct gpio_chip *gc =3D irq_data_get_irq_chip_data(data); + struct tegra_gpio *gpio =3D to_tegra_gpio(gc); void __iomem *base; u32 value; =20 @@ -278,7 +283,8 @@ static void tegra186_irq_unmask(struct i =20 static int tegra186_irq_set_type(struct irq_data *data, unsigned int type) { - struct tegra_gpio *gpio =3D irq_data_get_irq_chip_data(data); + struct gpio_chip *gc =3D irq_data_get_irq_chip_data(data); + struct tegra_gpio *gpio =3D to_tegra_gpio(gc); void __iomem *base; u32 value; From nobody Tue Jun 23 18:14:07 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 5D351C433EF for ; Mon, 28 Feb 2022 17:38:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238030AbiB1RjU (ORCPT ); Mon, 28 Feb 2022 12:39:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238308AbiB1RhO (ORCPT ); Mon, 28 Feb 2022 12:37:14 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FCEF89CF8; Mon, 28 Feb 2022 09:32: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 E547A61358; Mon, 28 Feb 2022 17:32:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 04297C340E7; Mon, 28 Feb 2022 17:32:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069525; bh=OdVa2ugLA2SYLg1Q1Zk4v0F51Z57H51iaDsKFNlaeLQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iZXFMlQH+HaXBCOyuCa+3zewQVBQzEoJPUuplD7R9BSicI2sc2aqy0kob8e2SQiYA sj77w/65Ws78Im1gK2Y3K8z5QPYaqS384Ld3j4RDOTAVbpmiQuyqtNuKQXrofzw4+O hUMqHlrgUDBkr0rTxvWQOdvRcG6caF/M/2k7zvqg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Ben Skeggs , Lyude Paul , Karol Herbst Subject: [PATCH 5.4 51/53] Revert "drm/nouveau/pmu/gm200-: avoid touching PMU outside of DEVINIT/PREOS/ACR" Date: Mon, 28 Feb 2022 18:24:49 +0100 Message-Id: <20220228172252.022032029@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: Karol Herbst This reverts commit c9ec3d85c0eef7c71cdc68db758e0f0e378132c0. This commit causes a regression if 4cdd2450bf739bada353e82d27b00db9af8c3001 is not applied as well. This was fixed for 5.16, 5.15 and 5.10. On older stable branches backporting this commit is complicated as relevant code changed quite a bit. Furthermore most of the affected hardware barely works on those and users would want to use the newer kernels anyway. Cc: stable@vger.kernel.org # 5.4 4.19 and 4.14 Cc: Ben Skeggs Cc: Lyude Paul Link: https://gitlab.freedesktop.org/drm/nouveau/-/issues/149 Signed-off-by: Karol Herbst Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- drivers/gpu/drm/nouveau/nvkm/subdev/pmu/base.c | 37 ++++++++++----------= ----- 1 file changed, 16 insertions(+), 21 deletions(-) --- a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/base.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/base.c @@ -88,13 +88,20 @@ nvkm_pmu_fini(struct nvkm_subdev *subdev return 0; } =20 -static void +static int nvkm_pmu_reset(struct nvkm_pmu *pmu) { struct nvkm_device *device =3D pmu->subdev.device; =20 if (!pmu->func->enabled(pmu)) - return; + return 0; + + /* Inhibit interrupts, and wait for idle. */ + nvkm_wr32(device, 0x10a014, 0x0000ffff); + nvkm_msec(device, 2000, + if (!nvkm_rd32(device, 0x10a04c)) + break; + ); =20 /* Reset. */ if (pmu->func->reset) @@ -105,37 +112,25 @@ nvkm_pmu_reset(struct nvkm_pmu *pmu) if (!(nvkm_rd32(device, 0x10a10c) & 0x00000006)) break; ); + + return 0; } =20 static int nvkm_pmu_preinit(struct nvkm_subdev *subdev) { struct nvkm_pmu *pmu =3D nvkm_pmu(subdev); - nvkm_pmu_reset(pmu); - return 0; + return nvkm_pmu_reset(pmu); } =20 static int nvkm_pmu_init(struct nvkm_subdev *subdev) { struct nvkm_pmu *pmu =3D nvkm_pmu(subdev); - struct nvkm_device *device =3D pmu->subdev.device; - - if (!pmu->func->init) - return 0; - - if (pmu->func->enabled(pmu)) { - /* Inhibit interrupts, and wait for idle. */ - nvkm_wr32(device, 0x10a014, 0x0000ffff); - nvkm_msec(device, 2000, - if (!nvkm_rd32(device, 0x10a04c)) - break; - ); - - nvkm_pmu_reset(pmu); - } - - return pmu->func->init(pmu); + int ret =3D nvkm_pmu_reset(pmu); + if (ret =3D=3D 0 && pmu->func->init) + ret =3D pmu->func->init(pmu); + return ret; } =20 static int From nobody Tue Jun 23 18:14:07 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 B9789C433F5 for ; Mon, 28 Feb 2022 17:41:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238469AbiB1RmM (ORCPT ); Mon, 28 Feb 2022 12:42:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238349AbiB1RhO (ORCPT ); Mon, 28 Feb 2022 12:37:14 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE91F8AE54; Mon, 28 Feb 2022 09:32: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 sin.source.kernel.org (Postfix) with ESMTPS id ACE7BCE17BE; Mon, 28 Feb 2022 17:32:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 999E5C340E7; Mon, 28 Feb 2022 17:32:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069527; bh=c3+ZF2Am26AFS69yXSGDqrLPBKoFtoySafESdM+LLg8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QQ+yX7qc0mQ8juWZ4/SDktg1aK5hlsTj2sYwla1cG709SMaXC3UeKvoknPMw85NKO 6K6niKh/RCf1QKn4Tumx9BrT1g1f1tKO7EH92+d6Zl0NjuxQG/ab8DfP9tE/eD+SqF LxPR1XWezv7jrcJswDxm4KeAt4KoCLjW+mgKy2dI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaohe Lin , Mike Rapoport Subject: [PATCH 5.4 52/53] memblock: use kfree() to release kmalloced memblock regions Date: Mon, 28 Feb 2022 18:24:50 +0100 Message-Id: <20220228172252.234235570@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: Miaohe Lin commit c94afc46cae7ad41b2ad6a99368147879f4b0e56 upstream. memblock.{reserved,memory}.regions may be allocated using kmalloc() in memblock_double_array(). Use kfree() to release these kmalloced regions indicated by memblock_{reserved,memory}_in_slab. Signed-off-by: Miaohe Lin Fixes: 3010f876500f ("mm: discard memblock data later") Signed-off-by: Mike Rapoport Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- mm/memblock.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) --- a/mm/memblock.c +++ b/mm/memblock.c @@ -348,14 +348,20 @@ void __init memblock_discard(void) addr =3D __pa(memblock.reserved.regions); size =3D PAGE_ALIGN(sizeof(struct memblock_region) * memblock.reserved.max); - __memblock_free_late(addr, size); + if (memblock_reserved_in_slab) + kfree(memblock.reserved.regions); + else + __memblock_free_late(addr, size); } =20 if (memblock.memory.regions !=3D memblock_memory_init_regions) { addr =3D __pa(memblock.memory.regions); size =3D PAGE_ALIGN(sizeof(struct memblock_region) * memblock.memory.max); - __memblock_free_late(addr, size); + if (memblock_memory_in_slab) + kfree(memblock.memory.regions); + else + __memblock_free_late(addr, size); } } #endif From nobody Tue Jun 23 18:14:07 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 CC534C433F5 for ; Mon, 28 Feb 2022 17:41:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238465AbiB1RmI (ORCPT ); Mon, 28 Feb 2022 12:42:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238350AbiB1RhO (ORCPT ); Mon, 28 Feb 2022 12:37:14 -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 890FC8A6FB; Mon, 28 Feb 2022 09:32: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 63AF4609EE; Mon, 28 Feb 2022 17:32:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A94BC340E7; Mon, 28 Feb 2022 17:32:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069530; bh=enr+3JE+jfp/tXmWjfUXVHUy5lAWuiRIWpJLIBM2HW0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J7PGMgeWay6LT8pOCFZPON6DBehY/4+B5RcgJZXDIo2hcYNDbt4y18bSgSwr6l4Lb 0fUBbajxcQwgPynsWC3HR8s5FLsE1fTizdOq9k7qEBai5bINCxwXSiaqdVBhdtQrnu tfDeo7nPo4Zui4qlG8lA4hAYVzRxpyoj5VzE47yg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kernel test robot , Carel Si , Jann Horn , Miklos Szeredi , Linus Torvalds , Baokun Li Subject: [PATCH 5.4 53/53] fget: clarify and improve __fget_files() implementation Date: Mon, 28 Feb 2022 18:24:51 +0100 Message-Id: <20220228172252.371692386@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@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: Linus Torvalds commit e386dfc56f837da66d00a078e5314bc8382fab83 upstream. Commit 054aa8d439b9 ("fget: check that the fd still exists after getting a ref to it") fixed a race with getting a reference to a file just as it was being closed. It was a fairly minimal patch, and I didn't think re-checking the file pointer lookup would be a measurable overhead, since it was all right there and cached. But I was wrong, as pointed out by the kernel test robot. The 'poll2' case of the will-it-scale.per_thread_ops benchmark regressed quite noticeably. Admittedly it seems to be a very artificial test: doing "poll()" system calls on regular files in a very tight loop in multiple threads. That means that basically all the time is spent just looking up file descriptors without ever doing anything useful with them (not that doing 'poll()' on a regular file is useful to begin with). And as a result it shows the extra "re-check fd" cost as a sore thumb. Happily, the regression is fixable by just writing the code to loook up the fd to be better and clearer. There's still a cost to verify the file pointer, but now it's basically in the noise even for that benchmark that does nothing else - and the code is more understandable and has better comments too. [ Side note: this patch is also a classic case of one that looks very messy with the default greedy Myers diff - it's much more legible with either the patience of histogram diff algorithm ] Link: https://lore.kernel.org/lkml/20211210053743.GA36420@xsang-OptiPlex-90= 20/ Link: https://lore.kernel.org/lkml/20211213083154.GA20853@linux.intel.com/ Reported-by: kernel test robot Tested-by: Carel Si Cc: Jann Horn Cc: Miklos Szeredi Signed-off-by: Linus Torvalds Signed-off-by: Baokun Li Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Slade Watkins Tested-by: Sudip Mukherjee --- fs/file.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++---------= ----- 1 file changed, 57 insertions(+), 16 deletions(-) --- a/fs/file.c +++ b/fs/file.c @@ -706,28 +706,69 @@ void do_close_on_exec(struct files_struc spin_unlock(&files->file_lock); } =20 -static struct file *__fget(unsigned int fd, fmode_t mask, unsigned int ref= s) +static inline struct file *__fget_files_rcu(struct files_struct *files, + unsigned int fd, fmode_t mask, unsigned int refs) { - struct files_struct *files =3D current->files; - struct file *file; + for (;;) { + struct file *file; + struct fdtable *fdt =3D rcu_dereference_raw(files->fdt); + struct file __rcu **fdentry; =20 - rcu_read_lock(); -loop: - file =3D fcheck_files(files, fd); - if (file) { - /* File object ref couldn't be taken. - * dup2() atomicity guarantee is the reason - * we loop to catch the new file (or NULL pointer) + if (unlikely(fd >=3D fdt->max_fds)) + return NULL; + + fdentry =3D fdt->fd + array_index_nospec(fd, fdt->max_fds); + file =3D rcu_dereference_raw(*fdentry); + if (unlikely(!file)) + return NULL; + + if (unlikely(file->f_mode & mask)) + return NULL; + + /* + * Ok, we have a file pointer. However, because we do + * this all locklessly under RCU, we may be racing with + * that file being closed. + * + * Such a race can take two forms: + * + * (a) the file ref already went down to zero, + * and get_file_rcu_many() fails. Just try + * again: */ - if (file->f_mode & mask) - file =3D NULL; - else if (!get_file_rcu_many(file, refs)) - goto loop; - else if (__fcheck_files(files, fd) !=3D file) { + if (unlikely(!get_file_rcu_many(file, refs))) + continue; + + /* + * (b) the file table entry has changed under us. + * Note that we don't need to re-check the 'fdt->fd' + * pointer having changed, because it always goes + * hand-in-hand with 'fdt'. + * + * If so, we need to put our refs and try again. + */ + if (unlikely(rcu_dereference_raw(files->fdt) !=3D fdt) || + unlikely(rcu_dereference_raw(*fdentry) !=3D file)) { fput_many(file, refs); - goto loop; + continue; } + + /* + * Ok, we have a ref to the file, and checked that it + * still exists. + */ + return file; } +} + + +static struct file *__fget(unsigned int fd, fmode_t mask, unsigned int ref= s) +{ + struct files_struct *files =3D current->files; + struct file *file; + + rcu_read_lock(); + file =3D __fget_files_rcu(files, fd, mask, refs); rcu_read_unlock(); =20 return file;