From patchwork Thu Oct 13 17:52:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2231 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp412456wrs; Thu, 13 Oct 2022 11:10:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4hXz2QEINk5csKrwzEw6z6YcYoBuSFR8vrK+gVNcNJgNC5Ds4xazdhFPkF6OOihBy7uJe8 X-Received: by 2002:a62:1a97:0:b0:562:5587:12d6 with SMTP id a145-20020a621a97000000b00562558712d6mr917511pfa.37.1665684643592; Thu, 13 Oct 2022 11:10:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684643; cv=none; d=google.com; s=arc-20160816; b=zM9CBkZNEi4n/4X0HYV6t9Gj/PDIEjIPqC7P/muDu5grOOMUwfEq3QoFJjgEeNxhmT ID09/F87upJecd2ufVRHvhCm6GACoQXjg5ayacDcdW18sjPnVseGuObs8WYPe88Rf92q aolhBDPE9gbSZjf6K4PMbEOUxY7TygqAXC3pXEH5RGFFfQY67otFMVL+WWytDNmLmd6G ZbxOtz8/eh75VAjcfj3WKziTUtXfV0BY83R1E4tt8tWE10knPam4Qo3dhknIiUaaNAdw Dz5RryypkrTk+PNcrcUoWJ2Kjc6D5DgQ1ya7AmC2CHjAps6f2jd12wl5AbRmgOkXYO6u PWkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=R5Ts1gYK+bv7sl4la9+VHGihDX7toXEO/CyqXOirrDE=; b=MkuXsRZvdahXhpcSmZhe0KCcFVj0CN7WjpOgYPHxqr00Z1HmWMAeSo1t8MzS4dExuu pKbfZZdxQG6Jk4hv4Iy0ZoULBSdKf9wcSw9D0JAIw5liBR57fTEv8Q3PAskHZ9I4j7Y0 PDXnwQYIepRjdOVxgY0SzOQQpMm8YrhPJ/2C1A/vJbqL+kXjmXJh2PQU0owmcZSmVHXa TN2nnstTjNIPgyewQo+Ahxbp/kD4uKcMGyBDf+QKa7T9k/lcm8Ov/L0hvzJp7AyPJXfN 2AkJGLKvC27y4uwYWb70vGMQ+udrJhMCyQSR2joM9dN2fQilw9tk1Sh3UHhhJFe2kRBb 85yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FV1OdCaJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y192-20020a638ac9000000b0043ca0a1f7dasi24464pgd.674.2022.10.13.11.10.31; Thu, 13 Oct 2022 11:10:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FV1OdCaJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230395AbiJMSKW (ORCPT + 99 others); Thu, 13 Oct 2022 14:10:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231376AbiJMSJr (ORCPT ); Thu, 13 Oct 2022 14:09:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D34CB169CC5; Thu, 13 Oct 2022 11:07:13 -0700 (PDT) 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 3D8E061A36; Thu, 13 Oct 2022 18:01:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46503C433C1; Thu, 13 Oct 2022 18:01:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665684084; bh=7lrOG+XELFk1IIcIKmG8btdaYc1FlQlU2Ev0FtNv+Y0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FV1OdCaJHWxchlec9bXrwfbcjaOK8uA4fSUmJCJPoCB/ghSDsUwu8L76EL1S81ppy ifag9ImHq3rGBoSbnAWrzCuxxDjVLiRiAW9TsVIJzYNRxDRnP+otvgkvTfmNlqEMW8 CDeOH19VCEXi8eEq5wK/DskryfFECndEeuLnwdEQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ryusuke Konishi , syzbot+b8c672b0e22615c80fe0@syzkaller.appspotmail.com, Khalid Masum , Andrew Morton Subject: [PATCH 6.0 02/34] nilfs2: fix use-after-free bug of struct nilfs_root Date: Thu, 13 Oct 2022 19:52:40 +0200 Message-Id: <20221013175146.577263099@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175146.507746257@linuxfoundation.org> References: <20221013175146.507746257@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746596941085759655?= X-GMAIL-MSGID: =?utf-8?q?1746596941085759655?= From: Ryusuke Konishi commit d325dc6eb763c10f591c239550b8c7e5466a5d09 upstream. If the beginning of the inode bitmap area is corrupted on disk, an inode with the same inode number as the root inode can be allocated and fail soon after. In this case, the subsequent call to nilfs_clear_inode() on that bogus root inode will wrongly decrement the reference counter of struct nilfs_root, and this will erroneously free struct nilfs_root, causing kernel oopses. This fixes the problem by changing nilfs_new_inode() to skip reserved inode numbers while repairing the inode bitmap. Link: https://lkml.kernel.org/r/20221003150519.39789-1-konishi.ryusuke@gmail.com Signed-off-by: Ryusuke Konishi Reported-by: syzbot+b8c672b0e22615c80fe0@syzkaller.appspotmail.com Reported-by: Khalid Masum Tested-by: Ryusuke Konishi Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- fs/nilfs2/inode.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) --- a/fs/nilfs2/inode.c +++ b/fs/nilfs2/inode.c @@ -328,6 +328,7 @@ struct inode *nilfs_new_inode(struct ino struct inode *inode; struct nilfs_inode_info *ii; struct nilfs_root *root; + struct buffer_head *bh; int err = -ENOMEM; ino_t ino; @@ -343,11 +344,25 @@ struct inode *nilfs_new_inode(struct ino ii->i_state = BIT(NILFS_I_NEW); ii->i_root = root; - err = nilfs_ifile_create_inode(root->ifile, &ino, &ii->i_bh); + err = nilfs_ifile_create_inode(root->ifile, &ino, &bh); if (unlikely(err)) goto failed_ifile_create_inode; /* reference count of i_bh inherits from nilfs_mdt_read_block() */ + if (unlikely(ino < NILFS_USER_INO)) { + nilfs_warn(sb, + "inode bitmap is inconsistent for reserved inodes"); + do { + brelse(bh); + err = nilfs_ifile_create_inode(root->ifile, &ino, &bh); + if (unlikely(err)) + goto failed_ifile_create_inode; + } while (ino < NILFS_USER_INO); + + nilfs_info(sb, "repaired inode bitmap for reserved inodes"); + } + ii->i_bh = bh; + atomic64_inc(&root->inodes_count); inode_init_owner(&init_user_ns, inode, dir, mode); inode->i_ino = ino; From patchwork Thu Oct 13 17:52:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2295 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp427996wrs; Thu, 13 Oct 2022 11:50:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7nB6kGF9E5ig6geom1y50w/F68PmGcz4gd+pzkR8MJqa0R2mCVEXRvzLhS1/L7cBPPeJEE X-Received: by 2002:a17:90b:388e:b0:20d:4a1f:d5a2 with SMTP id mu14-20020a17090b388e00b0020d4a1fd5a2mr1242939pjb.135.1665687045086; Thu, 13 Oct 2022 11:50:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665687045; cv=none; d=google.com; s=arc-20160816; b=oZE0g4uXWI8nM+cNINw2SHgupOzchSqeZGug/0Qhu6A7kzJFfZoD/IM0OkaxaNRc/J uOGEY87XjmpB0JURq7u2/FKxgT8ur2h7Xx5P8RPqExjuqJe3ihKX8QS9T/LqVuVLEOq0 ih47Q03VSWLb+1K8Yuw6oqy0x868dhg5X0pRP/1YJye8dz/zv0j0SCT55bfKAKuoSP1j eElYNPUfNZ6GwUUSC1EOiZf58ssDJbVk2A9gIX+feVAYNPlHTHtbvlGOAxB90r2nYOWz BBwEG87b7NKzUUa0Jqmal9PJHjTy1toTpfu7auubFPlfC9GtvJD0UUQYjrFo8meEDWO0 /zGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2b2/wfbgbXHKU9tF9t50KaWRwLvzMNyAJEdOZl2R4UA=; b=Qtn3UV2JGDsZVbfhnywLDUgHRzJPctdrqaaVQ7J2AVEVx7bsvOjgyQjrvLWOBA/LRV jop5SWqs1yp9fkXUykL5fL1hOhLTzIvuT/ehN9TYGa6MtaoJ4kRJrt6sjGTrmC8lDXrg OGRbqUB14H9FnXINqhY88BkXYoxv+w8b0XdY9vv9WZORrmYkuD+qpuBnHYkn03EJsmix WPmtAYsDxDKw1ifKy1jjgSh/uCFjwB/ahzdrYp8WNHFHWRbvyFwFvScdYWZQviWAOLnY jCqzThNzHfieIvj9cTWZsNwmnjufqFzCgVQdxYexgteCRACbu3jdjKplLX3Sgmu4UIv6 4CPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BfzZ9Y7j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f15-20020a056a0022cf00b00562e267252csi146036pfj.145.2022.10.13.11.50.31; Thu, 13 Oct 2022 11:50:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BfzZ9Y7j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231638AbiJMSYQ (ORCPT + 99 others); Thu, 13 Oct 2022 14:24:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232055AbiJMSXr (ORCPT ); Thu, 13 Oct 2022 14:23:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4316D107; Thu, 13 Oct 2022 11:19:18 -0700 (PDT) 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 68EC16192D; Thu, 13 Oct 2022 18:01:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 798E8C433D6; Thu, 13 Oct 2022 18:01:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665684115; bh=4/0gbWRoGgXhcpCItadg29FCqoOIDIWdJPHkOeinRzA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BfzZ9Y7jzNPqMpAHfKvFgn9H61SKQFTBYrXzkcbpncoU2rzRBL0wUmO/h5U6kkdAv sFdmPcyyujO8qh/VS1q2hu+C7E1WDrfCmYvfpgmc8/6r0F0D/K/piUtjPy62VNKf35 WVId0l0OSHYT1a/9hWWpFbS8x15ySZqaGeFhR7+c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ryusuke Konishi , syzbot+7381dc4ad60658ca4c05@syzkaller.appspotmail.com, Andrew Morton Subject: [PATCH 6.0 03/34] nilfs2: fix leak of nilfs_root in case of writer thread creation failure Date: Thu, 13 Oct 2022 19:52:41 +0200 Message-Id: <20221013175146.607406794@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175146.507746257@linuxfoundation.org> References: <20221013175146.507746257@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746599458757288606?= X-GMAIL-MSGID: =?utf-8?q?1746599458757288606?= From: Ryusuke Konishi commit d0d51a97063db4704a5ef6bc978dddab1636a306 upstream. If nilfs_attach_log_writer() failed to create a log writer thread, it frees a data structure of the log writer without any cleanup. After commit e912a5b66837 ("nilfs2: use root object to get ifile"), this causes a leak of struct nilfs_root, which started to leak an ifile metadata inode and a kobject on that struct. In addition, if the kernel is booted with panic_on_warn, the above ifile metadata inode leak will cause the following panic when the nilfs2 kernel module is removed: kmem_cache_destroy nilfs2_inode_cache: Slab cache still has objects when called from nilfs_destroy_cachep+0x16/0x3a [nilfs2] WARNING: CPU: 8 PID: 1464 at mm/slab_common.c:494 kmem_cache_destroy+0x138/0x140 ... RIP: 0010:kmem_cache_destroy+0x138/0x140 Code: 00 20 00 00 e8 a9 55 d8 ff e9 76 ff ff ff 48 8b 53 60 48 c7 c6 20 70 65 86 48 c7 c7 d8 69 9c 86 48 8b 4c 24 28 e8 ef 71 c7 00 <0f> 0b e9 53 ff ff ff c3 48 81 ff ff 0f 00 00 77 03 31 c0 c3 53 48 ... Call Trace: ? nilfs_palloc_freev.cold.24+0x58/0x58 [nilfs2] nilfs_destroy_cachep+0x16/0x3a [nilfs2] exit_nilfs_fs+0xa/0x1b [nilfs2] __x64_sys_delete_module+0x1d9/0x3a0 ? __sanitizer_cov_trace_pc+0x1a/0x50 ? syscall_trace_enter.isra.19+0x119/0x190 do_syscall_64+0x34/0x80 entry_SYSCALL_64_after_hwframe+0x63/0xcd ... Kernel panic - not syncing: panic_on_warn set ... This patch fixes these issues by calling nilfs_detach_log_writer() cleanup function if spawning the log writer thread fails. Link: https://lkml.kernel.org/r/20221007085226.57667-1-konishi.ryusuke@gmail.com Fixes: e912a5b66837 ("nilfs2: use root object to get ifile") Signed-off-by: Ryusuke Konishi Reported-by: syzbot+7381dc4ad60658ca4c05@syzkaller.appspotmail.com Tested-by: Ryusuke Konishi Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- fs/nilfs2/segment.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) --- a/fs/nilfs2/segment.c +++ b/fs/nilfs2/segment.c @@ -2786,10 +2786,9 @@ int nilfs_attach_log_writer(struct super inode_attach_wb(nilfs->ns_bdev->bd_inode, NULL); err = nilfs_segctor_start_thread(nilfs->ns_writer); - if (err) { - kfree(nilfs->ns_writer); - nilfs->ns_writer = NULL; - } + if (unlikely(err)) + nilfs_detach_log_writer(sb); + return err; } From patchwork Thu Oct 13 17:52:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2235 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp412682wrs; Thu, 13 Oct 2022 11:11:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5bDf/aWTKlgWnyseLbTM1GPGyfoRh2ynK64RZEA/jXOeKbfPpFlFU3QLbrJ/5Sotgg/Rj2 X-Received: by 2002:a17:90b:4b02:b0:20d:3937:7ad with SMTP id lx2-20020a17090b4b0200b0020d393707admr12543098pjb.145.1665684680829; Thu, 13 Oct 2022 11:11:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684680; cv=none; d=google.com; s=arc-20160816; b=jipzUQpHcSP0IBDe/b0v5DadGGLfFl3XwrwcB2G+lulDKnwR7k14G9guQj9NbKYOjx 86ZjxiUZD98EAYvQocYEVy5iC8g6kDLwO+VEIoGeNel4x00uHJdy0ch258I0R45VQJTU MXx50+Ow6Sanp4QjsElnudF50oFYMw2bBx0T+ayaWNkr9Iq3VuKx5N/gnGx+pFufSGdZ zIdW+wb2Pu9xlkaseIB8/ruxug6Nlgl4jPiUJVkilxajgY8FOL8mUbOHnR1fb0AhuXko aiP4CIGWBsmc0BcsQ7P9LzTWVHRM3K68XopvbpEe/7axF/BGqyBrWSlO8eYLf5WmgVE0 Qs/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=aNgRi6K6QlKRGK4Ipwa6FfNJWusnQAp2ZBui43ru6fM=; b=LXgcKfbbLeyKwXUkBQQUiaPhooxrsfbCxg39Cc5UvDpUhA3D/EmMH3WUll562Ae0or RnlgZmSgiooqgEM2oL1Tp3B9VUv6rhzgH024Xfw52YhXiEWVr3qWHqsr1WVjF42oIF/Z 2Y2oZggWpn1d86/JQfDbZ+RgWukH9pnfTNtrmZoS2nX8FZNeMCSIl6DMVQWfpULGMnV9 5aHTqqdO+8CH2JvmQhzsD6/c6VEmx0sr5JZ+3dnidm6CPFYJzqlxjt8BVkkdDjh3IQXJ X0Wq0x4DwS4P0hlXmRJf9vlMyoyzAHxlV6WK35bfoqjYFDnOFt/DvQPO6rbI/bk5j6lm SROg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=olOTxqoR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v8-20020a056a00148800b0056391cc1e6asi12245190pfu.354.2022.10.13.11.11.08; Thu, 13 Oct 2022 11:11:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=olOTxqoR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231469AbiJMSKz (ORCPT + 99 others); Thu, 13 Oct 2022 14:10:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231476AbiJMSKM (ORCPT ); Thu, 13 Oct 2022 14:10:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECBAC9DDBC; Thu, 13 Oct 2022 11:07:39 -0700 (PDT) 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 3B22661A33; Thu, 13 Oct 2022 18:01:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44103C433D6; Thu, 13 Oct 2022 18:01:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665684118; bh=T5hUlJubGs9iN1Cr22GehC2ffTzgTKc0wkupXsH0j3A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=olOTxqoRN6lLR20A+z7lFF36e9GdfYYhtgF1xCiJfSPZffOBI6mwZyErODhUbIizR JqfYOstJ1r9au824fbwDqrLvCkoQr7ehC8SEAOd/zYBedhfQrmJQ3OMsVH5P9IwAtF 5c6QuO4s1dT0578S4GWMjeb/qySdFnIyM19Icme4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ryusuke Konishi , syzbot+fbb3e0b24e8dae5a16ee@syzkaller.appspotmail.com, Andrew Morton Subject: [PATCH 6.0 04/34] nilfs2: replace WARN_ONs by nilfs_error for checkpoint acquisition failure Date: Thu, 13 Oct 2022 19:52:42 +0200 Message-Id: <20221013175146.634269087@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175146.507746257@linuxfoundation.org> References: <20221013175146.507746257@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746596980059397307?= X-GMAIL-MSGID: =?utf-8?q?1746596980059397307?= From: Ryusuke Konishi commit 723ac751208f6d6540191689cfbf6c77135a7a1b upstream. If creation or finalization of a checkpoint fails due to anomalies in the checkpoint metadata on disk, a kernel warning is generated. This patch replaces the WARN_ONs by nilfs_error, so that a kernel, booted with panic_on_warn, does not panic. A nilfs_error is appropriate here to handle the abnormal filesystem condition. This also replaces the detected error codes with an I/O error so that neither of the internal error codes is returned to callers. Link: https://lkml.kernel.org/r/20220929123330.19658-1-konishi.ryusuke@gmail.com Signed-off-by: Ryusuke Konishi Reported-by: syzbot+fbb3e0b24e8dae5a16ee@syzkaller.appspotmail.com Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- fs/nilfs2/segment.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) --- a/fs/nilfs2/segment.c +++ b/fs/nilfs2/segment.c @@ -875,9 +875,11 @@ static int nilfs_segctor_create_checkpoi nilfs_mdt_mark_dirty(nilfs->ns_cpfile); nilfs_cpfile_put_checkpoint( nilfs->ns_cpfile, nilfs->ns_cno, bh_cp); - } else - WARN_ON(err == -EINVAL || err == -ENOENT); - + } else if (err == -EINVAL || err == -ENOENT) { + nilfs_error(sci->sc_super, + "checkpoint creation failed due to metadata corruption."); + err = -EIO; + } return err; } @@ -891,7 +893,11 @@ static int nilfs_segctor_fill_in_checkpo err = nilfs_cpfile_get_checkpoint(nilfs->ns_cpfile, nilfs->ns_cno, 0, &raw_cp, &bh_cp); if (unlikely(err)) { - WARN_ON(err == -EINVAL || err == -ENOENT); + if (err == -EINVAL || err == -ENOENT) { + nilfs_error(sci->sc_super, + "checkpoint finalization failed due to metadata corruption."); + err = -EIO; + } goto failed_ibh; } raw_cp->cp_snapshot_list.ssl_next = 0; From patchwork Thu Oct 13 17:52:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2253 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp414363wrs; Thu, 13 Oct 2022 11:15:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4g1xo3WevxvtlGHUjhbHKeW/HFrANhqok4PMuuzpaEmN8UkilvG32HD4b3mbq0VH5r0wGM X-Received: by 2002:a05:6a00:851:b0:563:6c6a:2b7b with SMTP id q17-20020a056a00085100b005636c6a2b7bmr936602pfk.45.1665684911378; Thu, 13 Oct 2022 11:15:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684911; cv=none; d=google.com; s=arc-20160816; b=Sj32VfFBgQFEVovX2hMws6dKeUJzEeWRE/ZWlarbPGNrwkvONDC+KW1oUr26ckxkXj DfavTFunSLmBoWPFBundOL/p0YCOzeC0mVXrXMbSiUD/GUyLnrw9HcF7/msvaUa99NrI 0V+I2bWqFdTOG81w7mxLOe2/vPcZHmWEf6WoCUQyvK3BLKbZjp3CPZRiCR1W/Z1JoT/a ooT2QSfZkRuR4IL0D6U9nzfC0FcEW5CGoWOufew+ibZboJg8SCiTn2ByMdeoweeUSEC+ j0Dt4p4VA7RxGlfJO3t8FFE2tRXuAWoW27ETawrURB9EczjCHZJC3lrF7R0ko/hxSsz5 SJQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XxjXhrWHKuPUbWIkGQrYEY47pB2FGtQhMwG/QEXYx5U=; b=ck7yyq/H4tWZ9FaD9u6eyCLOIckRiS4ZNcMBKT4S7vlnagSPByghcIK8f/dXpz3vO1 W0eV/H+7lttlWXerZ7HbrNA747/vJwHNaCh46hk27Lsq+g5KwC2a6vPPrrUIGTpAKQLq YPaL7HTZT0ZoxdAHOHlb1aKsSwKCGbslME8WJ5WFA4BcZkOd0braUnndTsqliS8SzaFl CcUjFPAmq12Z6AgfCrOjpoWC5n5G2iepeB3no2Wx7SF25Wrz7DjqYMCBgaUSAz3VT+9f IKjJUIHyoZ/ps1ffoxJCfLRV0/D02lRYSHPIBzxdWQEnkjZ92+aTeX1ihzXIUdKstMLX hCXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=esBj9o9Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a11-20020a056a000c8b00b0053e1d872a91si102261pfv.83.2022.10.13.11.14.58; Thu, 13 Oct 2022 11:15:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=esBj9o9Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231828AbiJMSMu (ORCPT + 99 others); Thu, 13 Oct 2022 14:12:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231744AbiJMSMZ (ORCPT ); Thu, 13 Oct 2022 14:12:25 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63DEE16339A; Thu, 13 Oct 2022 11:09:02 -0700 (PDT) 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 B3202B820BD; Thu, 13 Oct 2022 18:02:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1154CC433C1; Thu, 13 Oct 2022 18:02:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665684121; bh=7CXu2ISfdtjdID+KmuZSU74Aw/Of9Rg1gzLUSEkIXD4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=esBj9o9QwKUYW3HxyTi29nz33ostwSdLa3vB14kPwL69+zk/aetx9Rbu8YDaVheZg 97V5emVVYhyb3u9AujXle0uovdOPVgm7+BcT2gxhu9d+rfxqMrWsSZX2PYfB8UhHDR DelxzRcHCvnK95Xf6VZkF5uuWE2TdB4muIQkeZ64= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rishabh Bhatnagar , Christoph Hellwig Subject: [PATCH 6.0 05/34] nvme-pci: set min_align_mask before calculating max_hw_sectors Date: Thu, 13 Oct 2022 19:52:43 +0200 Message-Id: <20221013175146.661543716@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175146.507746257@linuxfoundation.org> References: <20221013175146.507746257@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746597221843106065?= X-GMAIL-MSGID: =?utf-8?q?1746597221843106065?= From: Rishabh Bhatnagar commit 61ce339f19fabbc3e51237148a7ef6f2270e44fa upstream. If swiotlb is force enabled dma_max_mapping_size ends up calling swiotlb_max_mapping_size which takes into account the min align mask for the device. Set the min align mask for nvme driver before calling dma_max_mapping_size while calculating max hw sectors. Signed-off-by: Rishabh Bhatnagar Signed-off-by: Christoph Hellwig Signed-off-by: Greg Kroah-Hartman --- drivers/nvme/host/pci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -2834,6 +2834,8 @@ static void nvme_reset_work(struct work_ nvme_start_admin_queue(&dev->ctrl); } + dma_set_min_align_mask(dev->dev, NVME_CTRL_PAGE_SIZE - 1); + /* * Limit the max command size to prevent iod->sg allocations going * over a single page. @@ -2846,7 +2848,6 @@ static void nvme_reset_work(struct work_ * Don't limit the IOMMU merged segment size. */ dma_set_max_seg_size(dev->dev, 0xffffffff); - dma_set_min_align_mask(dev->dev, NVME_CTRL_PAGE_SIZE - 1); mutex_unlock(&dev->shutdown_lock); From patchwork Thu Oct 13 17:52:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2254 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp414364wrs; Thu, 13 Oct 2022 11:15:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6Qa4nbHKXByFW71L3/fy/KpNt3FniR9NGTQrrXCUl1DDHeNI4jQyJLp9B1a+7TmzlRvgBD X-Received: by 2002:a17:90b:4c12:b0:20d:7124:7c10 with SMTP id na18-20020a17090b4c1200b0020d71247c10mr12370158pjb.204.1665684911444; Thu, 13 Oct 2022 11:15:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684911; cv=none; d=google.com; s=arc-20160816; b=czJK4dqU9VhFHEOCFhCQ/NKdOe79C5sdI7HAyJfH+wGbPqYxtGoNdp8RaizouwXA7n UPtildkD2Ta/dq4RsBNm8PxgzKYiEU47+H7RnDyv51eYClnbiNgASZq7L492kJxMxZHH vXT6GY8jc3Ez24adD1f8Ry1wiwgUDtEfsce4k6lE7ID2dTpWYFmKBgMEI4r+Drr5yTOj J5f3AX62IanMJVjsUjT7ZHIRCr9xXocneZnIkR8DA4mSuQFGnwGoKLPGciA3PVBhi4dF 4j1/YfQXEHYSKbCfAw/jGFmTAwih5Rc41bldwuRM2cqdzMKEBwIs7zp4fRsefhrUwN3N VpIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ol34b5SBarGALYSkdk6GSfd+/906Crz5crtsmaAOmiA=; b=p9tLvotRh+u/SpnBTSCprQjDgHJoQGANq+LOjpKteuE4xad6KkJ2cIMO3GYEDd8ipv 3d3+Jk/kAWTL4BjwuNMnwl/ZxcDrIX4IAG23u9ubTYmg4ThLmSALNo632by8B5v3AVOU XBv23BTAlR+E+rtIfjhoGNMB6KPUx7olNTAQo7aMKvSxNRo+JjluznMHdo9n1XjEB64N +mRDnzXLmvtgYkj7aej8IKUmAfIc2qhVAn/lfhNt2bNppwvahDVpjSOF937PIpRHc/yC vmmqVVhVIJBtCoGQxm7MdRM1ruGvFI4W3EQ33bGeHGVGI+XbDdp+IDjHd80sN3v5DgZS 7J6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Dgs3Ynii; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b5-20020a170902e94500b0017c9ffbab0fsi435384pll.152.2022.10.13.11.14.58; Thu, 13 Oct 2022 11:15:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Dgs3Ynii; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231434AbiJMSN0 (ORCPT + 99 others); Thu, 13 Oct 2022 14:13:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231789AbiJMSMe (ORCPT ); Thu, 13 Oct 2022 14:12:34 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3827D175784; Thu, 13 Oct 2022 11:09:04 -0700 (PDT) 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 631D7B820C1; Thu, 13 Oct 2022 18:02:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87564C4314B; Thu, 13 Oct 2022 18:02:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665684125; bh=Sp7xcLmkYsm+Np+1uTluGtZlEhRASHATTWD+iC/6Kg4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dgs3YniivfqcskZLkD8wOxc+U7ymu3j4bCExsREVSm9xhycB+aWZhzKkYg21fF5YP 6joIl0b6uXNfhDJf8RcUBh2WsnLOgniOviDIenix54WWRDhD4PaCDd11AlyOT5ZxHr RLT17kf+/vRar5uNeqb7zbgEmN6GqLKi0YhvuNFI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guozihua , Zhongguohua , Al Viro , Theodore Tso , Andrew Lutomirski , "Jason A. Donenfeld" Subject: [PATCH 6.0 06/34] random: restore O_NONBLOCK support Date: Thu, 13 Oct 2022 19:52:44 +0200 Message-Id: <20221013175146.686620479@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175146.507746257@linuxfoundation.org> References: <20221013175146.507746257@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746597221485496773?= X-GMAIL-MSGID: =?utf-8?q?1746597221485496773?= From: Jason A. Donenfeld commit cd4f24ae9404fd31fc461066e57889be3b68641b upstream. Prior to 5.6, when /dev/random was opened with O_NONBLOCK, it would return -EAGAIN if there was no entropy. When the pools were unified in 5.6, this was lost. The post 5.6 behavior of blocking until the pool is initialized, and ignoring O_NONBLOCK in the process, went unnoticed, with no reports about the regression received for two and a half years. However, eventually this indeed did break somebody's userspace. So we restore the old behavior, by returning -EAGAIN if the pool is not initialized. Unlike the old /dev/random, this can only occur during early boot, after which it never blocks again. In order to make this O_NONBLOCK behavior consistent with other expectations, also respect users reading with preadv2(RWF_NOWAIT) and similar. Fixes: 30c08efec888 ("random: make /dev/random be almost like /dev/urandom") Reported-by: Guozihua Reported-by: Zhongguohua Cc: Al Viro Cc: Theodore Ts'o Cc: Andrew Lutomirski Cc: stable@vger.kernel.org Signed-off-by: Jason A. Donenfeld Signed-off-by: Greg Kroah-Hartman --- drivers/char/mem.c | 4 ++-- drivers/char/random.c | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) --- a/drivers/char/mem.c +++ b/drivers/char/mem.c @@ -712,8 +712,8 @@ static const struct memdev { #endif [5] = { "zero", 0666, &zero_fops, FMODE_NOWAIT }, [7] = { "full", 0666, &full_fops, 0 }, - [8] = { "random", 0666, &random_fops, 0 }, - [9] = { "urandom", 0666, &urandom_fops, 0 }, + [8] = { "random", 0666, &random_fops, FMODE_NOWAIT }, + [9] = { "urandom", 0666, &urandom_fops, FMODE_NOWAIT }, #ifdef CONFIG_PRINTK [11] = { "kmsg", 0644, &kmsg_fops, 0 }, #endif --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -1347,6 +1347,11 @@ static ssize_t random_read_iter(struct k { int ret; + if (!crng_ready() && + ((kiocb->ki_flags & (IOCB_NOWAIT | IOCB_NOIO)) || + (kiocb->ki_filp->f_flags & O_NONBLOCK))) + return -EAGAIN; + ret = wait_for_random_bytes(); if (ret != 0) return ret; From patchwork Thu Oct 13 17:52:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2257 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp414430wrs; Thu, 13 Oct 2022 11:15:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5P36k8YUxQ088zXdbf1D775uKvkIuUArepYIPJOzwpjo2gFnCxRbtNq/0G/TfAPsQtKetO X-Received: by 2002:a05:6a00:1781:b0:561:7f7f:dc38 with SMTP id s1-20020a056a00178100b005617f7fdc38mr811214pfg.42.1665684921001; Thu, 13 Oct 2022 11:15:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684920; cv=none; d=google.com; s=arc-20160816; b=ypYtUGgUU7ka8D/WpYxjMw+wE0P3zZfV/w6dfaIgxWgMaFfyOJ67u0yWa5T4hEGqXY uosIp6eHRPnskCI1RtVXqQVn5+PBRvCU2F+wiJxcyvCVTcsx/1oFcc6N33G72oyjZSP8 Wy0zc92q8NNCF/qvrI/bywzsdQCacj2LjB/aXZpQKYa3wLOrNaKEn0CTdmE8Q5SKGU5b A+eAEI+yQb/U5JbyM0V9y8JnNenBJbzg6aFJJtGWoEoj6mjXHBAm2AGOlIEG8CHp2C+d PhHeLBuULjoxMMFRlUG+54XrDlnw8H3DlpDYM2hWX+HT9AjhskPGhbSYkVmvSWuS91KG N8jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=aRdm5lrx2cPZwmBFDsXqsMOlmsY/kjFELh6ty8wttFc=; b=DzS/3VdOOjSR/Y4+/oOUZF0EakcJdvCIIahgHIRPTtQcZJzvGREkq1cGxV4R2z1xA5 Z32ChF4IO0WTrHZyUvFGTKfedKXm1Qyl546YmPJpMB3Hx3Y47Br+p8K0F3QaD7OWiguv 1GN8e+00yB5xOJqpQ3am6cSOZ8W6EqRf2QMhupLJrybZsT8+QnDV52ciBt3G6KbLa9+J 4sBaKkj8V3+O+/eAmXuYtF+/oyN2GWFVqTIsqv9+HVA5fb7FXg43zpMzHV64MHnGrK6O uacc8GxvUo1zil3w1qKn3KtSm4SXcL7MU018oeXTDv9oiFzWOwUb0/bLbOAK5edljSO2 sf3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SE0BHqNM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f186-20020a6251c3000000b00541c0da3083si10958pfb.302.2022.10.13.11.15.07; Thu, 13 Oct 2022 11:15:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SE0BHqNM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231932AbiJMSNs (ORCPT + 99 others); Thu, 13 Oct 2022 14:13:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231314AbiJMSMe (ORCPT ); Thu, 13 Oct 2022 14:12:34 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1BF617C577; Thu, 13 Oct 2022 11:09:13 -0700 (PDT) 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 4315BB820C5; Thu, 13 Oct 2022 18:02:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A6ACC433C1; Thu, 13 Oct 2022 18:02:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665684128; bh=251S8n2kh1CgLL9KLnRdiuwkTapMfX2u91F2Tly2WEY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SE0BHqNMaWNFoloIfuu6AmPQGaX23dSCOUkXs6fgqVPMx9Kd0hrwzCmZssnZ6HimI advVzyO1awBzzUXGTMdaKaPAY/fK+8TfOJHGRJvuZsIlwP06vSCXYpnRTKdLgHDI+E rd04AU/3RktzGRq/xptRfuzejWnCCr7wLO0x8HFM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Jason A. Donenfeld" Subject: [PATCH 6.0 07/34] random: clamp credited irq bits to maximum mixed Date: Thu, 13 Oct 2022 19:52:45 +0200 Message-Id: <20221013175146.713159261@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175146.507746257@linuxfoundation.org> References: <20221013175146.507746257@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746597232018476546?= X-GMAIL-MSGID: =?utf-8?q?1746597232018476546?= From: Jason A. Donenfeld commit e78a802a7b4febf53f2a92842f494b01062d85a8 upstream. Since the most that's mixed into the pool is sizeof(long)*2, don't credit more than that many bytes of entropy. Fixes: e3e33fc2ea7f ("random: do not use input pool from hard IRQs") Cc: stable@vger.kernel.org Signed-off-by: Jason A. Donenfeld Signed-off-by: Greg Kroah-Hartman --- drivers/char/random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -1006,7 +1006,7 @@ static void mix_interrupt_randomness(str local_irq_enable(); mix_pool_bytes(pool, sizeof(pool)); - credit_init_bits(max(1u, (count & U16_MAX) / 64)); + credit_init_bits(clamp_t(unsigned int, (count & U16_MAX) / 64, 1, sizeof(pool) * 8)); memzero_explicit(pool, sizeof(pool)); } From patchwork Thu Oct 13 17:52:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2237 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp412769wrs; Thu, 13 Oct 2022 11:11:34 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6Jt37r10iME5iNbF0P+SrhFubyy/cbhMe/kqjy66IR4o8obrk1R+IJdgOPv+qfVVTnw4oY X-Received: by 2002:a63:1353:0:b0:457:3e87:7883 with SMTP id 19-20020a631353000000b004573e877883mr988512pgt.172.1665684694205; Thu, 13 Oct 2022 11:11:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684694; cv=none; d=google.com; s=arc-20160816; b=M63qhCasW6cegDam5wfzQtrGpiRqljjbkrFPWLcHYTAq+3FAUUpODA5Yzs51kb/Xm8 lgXV6gShqzPF+8oCANaGjx58MXkVc0Cp8MOiAlkp+qSEBpzsXZkWK4sOSuzJdHXLPOl2 BJYOZpAMCr7WuE1ze4i/FGjS+Mnjm18BqG4+24iLE64oFI4fsj1R040wXUvUMv8BVgtQ y7seevLau7R9NoGyMyV/xVEfTLCEkst95ldR+9JldwWwM/MO8Vo9nYGbMEf3eNty6C7N LAsH6o1bjLyYrWQ6IMTqXrhYiuXETWwk6wDFFX2TiBMLJMjuQSTQO1cO0S7PI3Usjcbj lFQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KiZccsTHkuUele1UNuG6Ntr4PJ8NIyKDPrGMtz7je7o=; b=kctuFUZHmSenugwejU4NbZh7BEKjTPHX+2KQr22ojUyjqc49HVoFDP8D4Y+hLoo5NW ITCw8yQT4A0dRFumYe+4bLVg6mUVlHhsngEwV46egNZC0PtD9/hyG3cPtOzfA1+WTtwu MQSEz4fZmT8geIcq5crFutKvFHsAtbLyrcZZ8Lx/stapXGIAk8T5rEmERPIY3GOU0w6N pYaYal+XKUc4xtFm0oifIgHLfLqHS9p/anP4h75BwqO+XDKd+TUQW+n7n1zl0lQUqqYD e7CCstrER84l9PS+9qrJMuXwEHqQQ43A9/hLaFekOGrKpqIIBo6BKMD4fWtTgKRbagHQ bI5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=q76DxKbr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w2-20020a1709029a8200b001729146e418si381000plp.388.2022.10.13.11.11.21; Thu, 13 Oct 2022 11:11:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=q76DxKbr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231644AbiJMSLE (ORCPT + 99 others); Thu, 13 Oct 2022 14:11:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231488AbiJMSKR (ORCPT ); Thu, 13 Oct 2022 14:10:17 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B633B17579F; Thu, 13 Oct 2022 11:07:40 -0700 (PDT) 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 ACE6C61929; Thu, 13 Oct 2022 18:02:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7AC39C433C1; Thu, 13 Oct 2022 18:02:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665684131; bh=YzomB7J4BsTWMhyhV0465aLsGEaRBA/Q+cVNwoCa4xM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q76DxKbrMFhtVtaWgGjyMr8/5fFvzgqpcIJ5Rfxx5NA/bk8kv4lqY5MtTs6geDMnR KWbJeXP3ZLLhyi4nbJGP023dufWBwWYW7Yub0Fti6SrpalEp0fgdm/L7Bnp+UuCGDH tVTwulPcRH36ArUhoWEAREy3YknenC+jk7CpxEL8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai , Hans de Goede Subject: [PATCH 6.0 08/34] ALSA: hda: Fix position reporting on Poulsbo Date: Thu, 13 Oct 2022 19:52:46 +0200 Message-Id: <20221013175146.737744465@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175146.507746257@linuxfoundation.org> References: <20221013175146.507746257@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746596993931564558?= X-GMAIL-MSGID: =?utf-8?q?1746596993931564558?= From: Takashi Iwai commit 56e696c0f0c71b77fff921fc94b58a02f0445b2c upstream. Hans reported that his Sony VAIO VPX11S1E showed the broken sound behavior at the start of the stream for a couple of seconds, and it turned out that the position_fix=1 option fixes the issue. It implies that the position reporting is inaccurate, and very likely hitting on all Poulsbo devices. The patch applies the workaround for Poulsbo generically to switch to LPIB mode instead of the default position buffer. Reported-and-tested-by: Hans de Goede Cc: Link: https://lore.kernel.org/r/3e8697e1-87c6-7a7b-d2e8-b21f1d2f181b@redhat.com Link: https://lore.kernel.org/r/20221001142124.7241-1-tiwai@suse.de Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/pci/hda/hda_intel.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -2554,7 +2554,8 @@ static const struct pci_device_id azx_id .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_PCH_NOPM }, /* Poulsbo */ { PCI_DEVICE(0x8086, 0x811b), - .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_PCH_BASE }, + .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_PCH_BASE | + AZX_DCAPS_POSFIX_LPIB }, /* Oaktrail */ { PCI_DEVICE(0x8086, 0x080a), .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_PCH_BASE }, From patchwork Thu Oct 13 17:52:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2255 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp414376wrs; Thu, 13 Oct 2022 11:15:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7CiEZbToUDdOAWFPO2I+2c7YaatNvBPOqqWWN6nuKR2Jco/xcjXxWfux8tCAnf/hT86xQB X-Received: by 2002:a63:1608:0:b0:45a:355a:9420 with SMTP id w8-20020a631608000000b0045a355a9420mr1020230pgl.354.1665684914169; Thu, 13 Oct 2022 11:15:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684914; cv=none; d=google.com; s=arc-20160816; b=oJqSshL/nH+hCOqS/Pdj0MfJ4IJP/r0e0PEpuD7kcPOj3Stdyycf9G1Yz5DVmtDuae 2M/LdOV1WWjIH4SX9ki/8KAUQ9Cg/mpiOCcepNE2a8xib63PfBDS7pDLgz7CJi8v9csN MSL8hElSdsiJ4vlvbnzIcC2/nZsfGb7c48GhwVf03CBewSKkLWNu7Hzj1siPWDaapG8A KFYxLNLc85IH3AkAx2Vjh1ui62naJaTtRdK1o8qUjFF6Q85GpgLfQ2sup7FBPd/eOAue cUGmsq1S6nMMaHz1c1JvdCwSznV5hQcOmFE3svDoI/67H4I432iNnT9PmfNgqr2T+EPg 7WsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=olGdC3J/FFdYZF+PSU4MDPtfkadJl4lMC/Hxac7cIgc=; b=fcobFDXS1f6uynJYnAIQwodfMyn+GKx3HGdC60jvKzgSTOzD5ELXgxkTkq73BBCCI/ JqAZwyqYm3YvJ6G+Es4ZaXuVFcFa1Equde6j9Orfqy9D3BXKz5eSoTjU3bzlOe1rmjm/ ERov++UZpQR+LEGnjQd5/5iTaKDcF2AEZ/aPMlEmooMD1dGiISmQwQv47pq0CVY7EuMH l/DQNGSiE2pNm62QxK3hvHdPp3yrPJWZ2JJQ7pnsmgoHzz49NNetFYuQ3EdUN3PUQL/4 RuLBMg91madL6YXm9C9Zj5RNiElJAna47K+uB+GoeIE232HJ7IuL7EdDhaRbOfDmmozX B0zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vAJPOnsv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 18-20020a630d52000000b0046af0960898si45170pgn.625.2022.10.13.11.15.01; Thu, 13 Oct 2022 11:15:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vAJPOnsv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231621AbiJMSNa (ORCPT + 99 others); Thu, 13 Oct 2022 14:13:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231794AbiJMSMf (ORCPT ); Thu, 13 Oct 2022 14:12:35 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53435163388; Thu, 13 Oct 2022 11:09:16 -0700 (PDT) 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 55A10B820BF; Thu, 13 Oct 2022 18:02:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BEF53C433D7; Thu, 13 Oct 2022 18:02:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665684134; bh=Tpy11LMGiLfANUN3J/Jhm3VW7QyD+W+Gr7dQ2ylbtK8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vAJPOnsvjxQq8WCOTQSC+OueilSVA+dxfayz2TCwjIhhp9h7DW4PPQOKF0BVeHZIA jgsQICjAjuHOdclTJPQwy7SgeAnGZhOlb5Bd1gPnRmeBZW1mZ+2wJIzTJyk6bBgjKQ qtO7ypZzfPSc4idjBPXcRYD+oQeugvGM1FkYL76o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai Subject: [PATCH 6.0 09/34] ALSA: hda/realtek: Add quirk for HP Zbook Firefly 14 G9 model Date: Thu, 13 Oct 2022 19:52:47 +0200 Message-Id: <20221013175146.764976386@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175146.507746257@linuxfoundation.org> References: <20221013175146.507746257@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746597224037538642?= X-GMAIL-MSGID: =?utf-8?q?1746597224037538642?= From: Takashi Iwai commit 225f6e1bc151978041595c7d2acaded3aac41f54 upstream. HP Zbook Firefly 14 G9 model (103c:8abb) requires yet another binding with CS35L41 codec, but with a slightly different configuration. It's over spi1 instead of spi0. Create a new fixup entry for that. Cc: Link: https://lore.kernel.org/r/20220929061455.13355-1-tiwai@suse.de Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/pci/hda/patch_realtek.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -6741,6 +6741,11 @@ static void cs35l41_fixup_spi_two(struct cs35l41_generic_fixup(codec, action, "spi0", "CSC3551", 2); } +static void cs35l41_fixup_spi1_two(struct hda_codec *codec, const struct hda_fixup *fix, int action) +{ + cs35l41_generic_fixup(codec, action, "spi1", "CSC3551", 2); +} + static void cs35l41_fixup_spi_four(struct hda_codec *codec, const struct hda_fixup *fix, int action) { cs35l41_generic_fixup(codec, action, "spi0", "CSC3551", 4); @@ -7132,6 +7137,8 @@ enum { ALC287_FIXUP_CS35L41_I2C_2_HP_GPIO_LED, ALC245_FIXUP_CS35L41_SPI_2, ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED, + ALC245_FIXUP_CS35L41_SPI1_2, + ALC245_FIXUP_CS35L41_SPI1_2_HP_GPIO_LED, ALC245_FIXUP_CS35L41_SPI_4, ALC245_FIXUP_CS35L41_SPI_4_HP_GPIO_LED, ALC285_FIXUP_HP_SPEAKERS_MICMUTE_LED, @@ -8979,6 +8986,16 @@ static const struct hda_fixup alc269_fix .chained = true, .chain_id = ALC285_FIXUP_HP_GPIO_LED, }, + [ALC245_FIXUP_CS35L41_SPI1_2] = { + .type = HDA_FIXUP_FUNC, + .v.func = cs35l41_fixup_spi1_two, + }, + [ALC245_FIXUP_CS35L41_SPI1_2_HP_GPIO_LED] = { + .type = HDA_FIXUP_FUNC, + .v.func = cs35l41_fixup_spi1_two, + .chained = true, + .chain_id = ALC285_FIXUP_HP_GPIO_LED, + }, [ALC245_FIXUP_CS35L41_SPI_4] = { .type = HDA_FIXUP_FUNC, .v.func = cs35l41_fixup_spi_four, @@ -9341,6 +9358,7 @@ static const struct snd_pci_quirk alc269 SND_PCI_QUIRK(0x103c, 0x8aa3, "HP ProBook 450 G9 (MB 8AA1)", ALC236_FIXUP_HP_GPIO_LED), SND_PCI_QUIRK(0x103c, 0x8aa8, "HP EliteBook 640 G9 (MB 8AA6)", ALC236_FIXUP_HP_GPIO_LED), SND_PCI_QUIRK(0x103c, 0x8aab, "HP EliteBook 650 G9 (MB 8AA9)", ALC236_FIXUP_HP_GPIO_LED), + SND_PCI_QUIRK(0x103c, 0x8abb, "HP ZBook Firefly 14 G9", ALC245_FIXUP_CS35L41_SPI1_2_HP_GPIO_LED), SND_PCI_QUIRK(0x103c, 0x8ad1, "HP EliteBook 840 14 inch G9 Notebook PC", ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED), SND_PCI_QUIRK(0x103c, 0x8ad2, "HP EliteBook 860 16 inch G9 Notebook PC", ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED), SND_PCI_QUIRK(0x1043, 0x103e, "ASUS X540SA", ALC256_FIXUP_ASUS_MIC), From patchwork Thu Oct 13 17:52:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2217 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp411095wrs; Thu, 13 Oct 2022 11:07:58 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6kbsCcjH/nRy54oKrp4yTmE1DaNPlaXj2nl9eqO2V8CXihRDfUz/GIURIrQN1FjQBjRFE3 X-Received: by 2002:a17:90b:390b:b0:20d:2c45:84e3 with SMTP id ob11-20020a17090b390b00b0020d2c4584e3mr1084684pjb.161.1665684478482; Thu, 13 Oct 2022 11:07:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684478; cv=none; d=google.com; s=arc-20160816; b=ngeqkCIptsrBlVx0V8PeqfYrWexRMDlxB8/moSbfG37GCxAXTezOOLj5j1f3VSsMdC F56P9H/uMIBJ8D8NUtoFCYhvh9VCIiQxN3RLLs3Y0ad1cizJnD3zfxOmooeHpw5MXl6J ATF0qMIqT0BSDUQjT380lMTE4i782V3/bjimFvlFLO/orCzccbU+2xbHecofVnZTSf0y z3ftNCakmuPSCfgg6PadlXU+H54WIJCCThz1BWsbDWymykE2aDojuJZ2BNENhQ48NhV9 CQPqTAtZ/BatAAlC/eTTarx/oD4l2Avc24Om4LN56OXHyx22pQ3TxecDcEMxy/1OCdtC 3yyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=z/hiobo4Tfv9x8gfSNE0FJT2rhT1ElDpRkjn0AubFJw=; b=kuKeB3oxkr8LIMjdLhkoUAtnCCq9mrT6GzdSI409WXsZ+wJHJSIcxN0vGGvcVj1dGT KROn9OtTJe8IYgUNwJzLzaqc5bZtOFS3V4x55AOYVmKciV/66yjndfbBzHw2E0q5kAE/ TrbqY6M7oxAvNgoBXT1PyM1czVSsRC5XBms9hSxWDRsUUez/2NSugYbNggbLu9cpUlT1 HbtLmhP/8cHGnLL3WqkEt7W+AQbGOtJvxCRxDb1ta2hw1/hz15/41eJplCz9goYn8YXn BjHEWqjQDRWpqmAn29DkYOxaHcnzh2Sia/11/2d2ylXDF73dQuxMnkNiMi6TOaIoD+xx FI8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DSFy6ETh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nl5-20020a17090b384500b00205dfd2c794si6154992pjb.167.2022.10.13.11.07.45; Thu, 13 Oct 2022 11:07:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DSFy6ETh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231587AbiJMSHc (ORCPT + 99 others); Thu, 13 Oct 2022 14:07:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231289AbiJMSFo (ORCPT ); Thu, 13 Oct 2022 14:05:44 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 790C2A1A8; Thu, 13 Oct 2022 11:04:41 -0700 (PDT) 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 0FFFB61986; Thu, 13 Oct 2022 18:00:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6FAA7C43142; Thu, 13 Oct 2022 18:00:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665684052; bh=R56tc7ab5Ae7BCl75vsYTgnxuRRQc6ZCGNdTc3leahg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DSFy6EThkuQcemc6QUcfiEdRBFm9Io31tLS7zZ1hmulAOqGkiFhffUHuvhtofIDLN BOHjLmnlVMEV0k5HJsJ3jZAgHJ6DA3d4YHSR5rPr2yGVUSfuj1ZLu5EJhcaC8qPFm5 XESj73HZg/4haWA717Wv9twlRDwfUO3RGVT2sL2c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Aditya Garg , Samuel Jiang , Orlando Chamberlain , Mimi Zohar Subject: [PATCH 6.0 10/34] efi: Correct Macmini DMI match in uefi cert quirk Date: Thu, 13 Oct 2022 19:52:48 +0200 Message-Id: <20221013175146.789102926@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175146.507746257@linuxfoundation.org> References: <20221013175146.507746257@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746596767836690474?= X-GMAIL-MSGID: =?utf-8?q?1746596767836690474?= From: Orlando Chamberlain commit bab715bdaa9ebf28d99a6d1efb2704a30125e96d upstream. It turns out Apple doesn't capitalise the "mini" in "Macmini" in DMI, which is inconsistent with other model line names. Correct the capitalisation of Macmini in the quirk for skipping loading platform certs on T2 Macs. Currently users get: ------------[ cut here ]------------ [Firmware Bug]: Page fault caused by firmware at PA: 0xffffa30640054000 WARNING: CPU: 1 PID: 8 at arch/x86/platform/efi/quirks.c:735 efi_crash_gracefully_on_page_fault+0x55/0xe0 Modules linked in: CPU: 1 PID: 8 Comm: kworker/u12:0 Not tainted 5.18.14-arch1-2-t2 #1 4535eb3fc40fd08edab32a509fbf4c9bc52d111e Hardware name: Apple Inc. Macmini8,1/Mac-7BA5B2DFE22DDD8C, BIOS 1731.120.10.0.0 (iBridge: 19.16.15071.0.0,0) 04/24/2022 Workqueue: efi_rts_wq efi_call_rts ... ---[ end trace 0000000000000000 ]--- efi: Froze efi_rts_wq and disabled EFI Runtime Services integrity: Couldn't get size: 0x8000000000000015 integrity: MODSIGN: Couldn't get UEFI db list efi: EFI Runtime Services are disabled! integrity: Couldn't get size: 0x8000000000000015 integrity: Couldn't get UEFI dbx list Fixes: 155ca952c7ca ("efi: Do not import certificates from UEFI Secure Boot for T2 Macs") Cc: stable@vger.kernel.org Cc: Aditya Garg Tested-by: Samuel Jiang Signed-off-by: Orlando Chamberlain Signed-off-by: Mimi Zohar Signed-off-by: Greg Kroah-Hartman --- security/integrity/platform_certs/load_uefi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/security/integrity/platform_certs/load_uefi.c +++ b/security/integrity/platform_certs/load_uefi.c @@ -31,7 +31,7 @@ static const struct dmi_system_id uefi_s { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "MacBookAir8,1") }, { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "MacBookAir8,2") }, { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "MacBookAir9,1") }, - { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "MacMini8,1") }, + { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "Macmini8,1") }, { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "MacPro7,1") }, { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "iMac20,1") }, { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "iMac20,2") }, From patchwork Thu Oct 13 17:52:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2218 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp411136wrs; Thu, 13 Oct 2022 11:08:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4eEqMytKU1n7rD2EkTPxO/slQZaHpYDajutSEs/IGlmZNesW5+7kxLacdD+K1goyQPJXzU X-Received: by 2002:a17:903:41ce:b0:182:a32f:4dde with SMTP id u14-20020a17090341ce00b00182a32f4ddemr869567ple.47.1665684485138; Thu, 13 Oct 2022 11:08:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684485; cv=none; d=google.com; s=arc-20160816; b=JhsRWuLJki0YofM54EkpwjohEBp5yn8Hz5AwbZ/Oj9rjWYtvZ7aU7HpFf701DQdloC 6ysv9D4DYIxxnh5HposLdmxNTqVUcko5ksNmKpFiDDb4rEmgdQaZ5Emnlps/Iyhl0nKE 4lu5UYU889ijkxUSv9VTPFj/m2rZfLeaTrvWz/LiqMCrAhDlPkysd/mnmlgQ0c1FWqPW lH+ulGUIZAHWu4uhNpVxCfRq376CxlnkiS5lG5eRhqeRKoQVmBEaISZO3ufI8V2dWqiS NIiA6amQGgIhYfX01EbGYnfrIZHRYgzQNGR9enGdw4DCJZRy51HxqEYHarMGLY1MkND1 QF1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9BRdOo3tflaEUqfzOc+KZ4fGO1eeqF/53JBmlA1Yy6k=; b=Fkl/Cpmx1pE/AhfZAhpJ4/myuo92gHJ03OyUE2pAw9wfBzR8FouiLn/HqMl+BckVV/ 8S3zXNiGgqFum4vHGbyrB8ZwGgkc1fvUyp3WYpHWv7nCETGYpzq0gVorXqnJYbI/aHKV GjtEOf5hKTgTzlUmhFeGvhpZROxibhekVFX+hbz3e8tVNnctuQ3tIazD8PYUZIIOVqgT BERkWH9t5HX1tGtYiVCF2Yes1fK2yt6hhDVwI0R923SR/R2uCet2x+VUSPp52ZcU+eY6 CLF9V5htEofpAbVDbddywM3dslYLUuXvovaJOdV2ipX1cyp81LgmwIOO56oqptD/dl9N NA8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Euxm4PuA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u207-20020a6279d8000000b00560bdd654ffsi20639810pfc.314.2022.10.13.11.07.52; Thu, 13 Oct 2022 11:08:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Euxm4PuA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231596AbiJMSHh (ORCPT + 99 others); Thu, 13 Oct 2022 14:07:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231345AbiJMSFx (ORCPT ); Thu, 13 Oct 2022 14:05:53 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3701B3C17C; Thu, 13 Oct 2022 11:04:56 -0700 (PDT) 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 D400361995; Thu, 13 Oct 2022 18:00:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4ACDDC433B5; Thu, 13 Oct 2022 18:00:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665684055; bh=9vKia5o5B4xGTx3eWxIf6VhmDOv6agctG3itO2HEjxM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Euxm4PuAH2v5SDgDBgVvMJmPGvUaVxG5z3WLW0v2+fNG/g8S55XvxT0cjrfWytXmu fc46i4oGNkMQPjyUzDi/jAODovZ9LveSLXLPrQtpE2pYftnEateGkT69oaLTl7m3h3 1kQ6B4QikVDVRU5kzLQkN/LlyqfE9xh7p5OdRAIA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Himanshu Madhani , Arun Easi , Nilesh Javali , "Martin K. Petersen" Subject: [PATCH 6.0 11/34] scsi: qla2xxx: Revert "scsi: qla2xxx: Fix response queue handler reading stale packets" Date: Thu, 13 Oct 2022 19:52:49 +0200 Message-Id: <20221013175146.815599374@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175146.507746257@linuxfoundation.org> References: <20221013175146.507746257@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746596774869308005?= X-GMAIL-MSGID: =?utf-8?q?1746596774869308005?= From: Arun Easi commit 6dc45a7322cb9db48a5b6696597a00ef7c778ef9 upstream. Reverting this commit so that a fixed up patch, without adding new module parameters, can be submitted. Link: https://lore.kernel.org/stable/166039743723771@kroah.com/ This reverts commit b1f707146923335849fb70237eec27d4d1ae7d62. Link: https://lore.kernel.org/r/20220826102559.17474-2-njavali@marvell.com Cc: stable@vger.kernel.org Reviewed-by: Himanshu Madhani Signed-off-by: Arun Easi Signed-off-by: Nilesh Javali Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/qla2xxx/qla_gbl.h | 2 -- drivers/scsi/qla2xxx/qla_isr.c | 25 ++----------------------- drivers/scsi/qla2xxx/qla_os.c | 10 ---------- 3 files changed, 2 insertions(+), 35 deletions(-) --- a/drivers/scsi/qla2xxx/qla_gbl.h +++ b/drivers/scsi/qla2xxx/qla_gbl.h @@ -193,8 +193,6 @@ extern int ql2xsecenable; extern int ql2xenforce_iocb_limit; extern int ql2xabts_wait_nvme; extern u32 ql2xnvme_queues; -extern int ql2xrspq_follow_inptr; -extern int ql2xrspq_follow_inptr_legacy; extern int qla2x00_loop_reset(scsi_qla_host_t *); extern void qla2x00_abort_all_cmds(scsi_qla_host_t *, int); --- a/drivers/scsi/qla2xxx/qla_isr.c +++ b/drivers/scsi/qla2xxx/qla_isr.c @@ -3763,8 +3763,7 @@ void qla24xx_process_response_queue(stru struct qla_hw_data *ha = vha->hw; struct purex_entry_24xx *purex_entry; struct purex_item *pure_item; - u16 rsp_in = 0, cur_ring_index; - int follow_inptr, is_shadow_hba; + u16 cur_ring_index; if (!ha->flags.fw_started) return; @@ -3774,25 +3773,7 @@ void qla24xx_process_response_queue(stru qla_cpu_update(rsp->qpair, smp_processor_id()); } -#define __update_rsp_in(_update, _is_shadow_hba, _rsp, _rsp_in) \ - do { \ - if (_update) { \ - _rsp_in = _is_shadow_hba ? *(_rsp)->in_ptr : \ - rd_reg_dword_relaxed((_rsp)->rsp_q_in); \ - } \ - } while (0) - - is_shadow_hba = IS_SHADOW_REG_CAPABLE(ha); - follow_inptr = is_shadow_hba ? ql2xrspq_follow_inptr : - ql2xrspq_follow_inptr_legacy; - - __update_rsp_in(follow_inptr, is_shadow_hba, rsp, rsp_in); - - while ((likely(follow_inptr && - rsp->ring_index != rsp_in && - rsp->ring_ptr->signature != RESPONSE_PROCESSED)) || - (!follow_inptr && - rsp->ring_ptr->signature != RESPONSE_PROCESSED)) { + while (rsp->ring_ptr->signature != RESPONSE_PROCESSED) { pkt = (struct sts_entry_24xx *)rsp->ring_ptr; cur_ring_index = rsp->ring_index; @@ -3906,8 +3887,6 @@ process_err: } pure_item = qla27xx_copy_fpin_pkt(vha, (void **)&pkt, &rsp); - __update_rsp_in(follow_inptr, is_shadow_hba, - rsp, rsp_in); if (!pure_item) break; qla24xx_queue_purex_item(vha, pure_item, --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -338,16 +338,6 @@ module_param(ql2xdelay_before_pci_error_ MODULE_PARM_DESC(ql2xdelay_before_pci_error_handling, "Number of seconds delayed before qla begin PCI error self-handling (default: 5).\n"); -int ql2xrspq_follow_inptr = 1; -module_param(ql2xrspq_follow_inptr, int, 0644); -MODULE_PARM_DESC(ql2xrspq_follow_inptr, - "Follow RSP IN pointer for RSP updates for HBAs 27xx and newer (default: 1)."); - -int ql2xrspq_follow_inptr_legacy = 1; -module_param(ql2xrspq_follow_inptr_legacy, int, 0644); -MODULE_PARM_DESC(ql2xrspq_follow_inptr_legacy, - "Follow RSP IN pointer for RSP updates for HBAs older than 27XX. (default: 1)."); - static void qla2x00_clear_drv_active(struct qla_hw_data *); static void qla2x00_free_device(scsi_qla_host_t *); static int qla2xxx_map_queues(struct Scsi_Host *shost); From patchwork Thu Oct 13 17:52:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2345 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp435337wrs; Thu, 13 Oct 2022 12:07:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5bZji5uTsviTe+qzePbaHR7OIzPoxC9cHSmquielkN4R85AozIbCJzGP4zHVvmjeZfO3e6 X-Received: by 2002:a17:907:320c:b0:77b:6f08:9870 with SMTP id xg12-20020a170907320c00b0077b6f089870mr890580ejb.249.1665688041885; Thu, 13 Oct 2022 12:07:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665688041; cv=none; d=google.com; s=arc-20160816; b=QacgwU8i+q+gfhPsf0s+0K9L1y/5R0Dz6RKOK6WFzoLWcpEhn8N65vvEbF6jf6dgr0 pKVntFzD2EOz/x3MUZLLqwSv7UAeaGQFoi6zb6yEW8fPdlhFqGxrADu2N7UPrEV/bLYH XYqlGlz5NFhmqGO4TK3n9A7b+yuWHp2z1iq1FZSH+3VkQ0IvuJzZnOl1UVeY+zvAxHjs 1Gm4f5rkQx65cvdMUtQ6d/mWpQoYmV0SJt+5ny125nK6IiolzAsQIJUD7nU0h/d/7py4 a73XvWQ5vn7wHtOiBzpuXpwe5iJmqQIg2JXutgd3ZPhODTUNdy2mJJuR3W2JVVuSqAwX dunA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hjDvueq1Vyq5AD0u3nIzLOc+/iWa22QCSxD/Stt9iTM=; b=KqmiMnQ9Y36uTkTGd3tzMvmZF4j6mM7tsf31IoLrzhUuk0oHfU8UEO7yXRM7/PSPRu 3zJjDWsoJHuV/VQgCEYBsCie9t6m9APsXHdB7PLajIy82TlXxeX2963ShGodrckyVWlz 7snR7QNzRlP1E4RIX3Fvc5z0cIq5EuXVBfCWVencId0ToMK0od4gKGnB4Zb7MPpKxnRg FtYqpJ4PksZp2anm4RXzWX/v6XczxNgC9j9v/cBD2VxF4ukuyXPQkeJSRA9LUZv3/3n2 2ipz1rcChA1pKDMJnLNWMel0H1bDxdokDBqyjV2yooK5mzn7TwuvlCYqHBLjh3xiXY/z cpMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MjEktAbf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nd33-20020a17090762a100b0077ac5f39842si493141ejc.96.2022.10.13.12.06.55; Thu, 13 Oct 2022 12:07:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MjEktAbf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229777AbiJMTGG (ORCPT + 99 others); Thu, 13 Oct 2022 15:06:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229749AbiJMTGA (ORCPT ); Thu, 13 Oct 2022 15:06:00 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 430D763D7; Thu, 13 Oct 2022 12:05:59 -0700 (PDT) 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 A7330B8207B; Thu, 13 Oct 2022 18:00:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 180E2C433D6; Thu, 13 Oct 2022 18:00:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665684058; bh=bOidcKm6QKaIaWqZXsQBrCRpaMrW7PXqT/0Sgh+sGxk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MjEktAbfju8ST3GDa4mG/2vBcepggl7VLHD5fOZZbaHtCGGAeDKsES7EW1bV1Q6I/ h87Lfj8yHlAXREhXk2dv1gUsxcyvmwYJMVuRKBz2isxYUVpEy3Jl2MJhucb70IaNZh 9lgjkIixO6vorY7gAzCqGy2vtihc4b9HXOTJCmIQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Himanshu Madhani , Arun Easi , Nilesh Javali , "Martin K. Petersen" Subject: [PATCH 6.0 12/34] scsi: qla2xxx: Fix response queue handler reading stale packets Date: Thu, 13 Oct 2022 19:52:50 +0200 Message-Id: <20221013175146.840895989@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175146.507746257@linuxfoundation.org> References: <20221013175146.507746257@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746600503862746698?= X-GMAIL-MSGID: =?utf-8?q?1746600503862746698?= From: Arun Easi commit e4f8a29deb3ba30e414dfb6b09e3ae3bf6dbe74a upstream. On some platforms, the current logic of relying on finding new packet solely based on signature pattern can lead to driver reading stale packets. Though this is a bug in those platforms, reduce such exposures by limiting reading packets until the IN pointer. Link: https://lore.kernel.org/r/20220826102559.17474-3-njavali@marvell.com Cc: stable@vger.kernel.org Reviewed-by: Himanshu Madhani Signed-off-by: Arun Easi Signed-off-by: Nilesh Javali Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/qla2xxx/qla_isr.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) --- a/drivers/scsi/qla2xxx/qla_isr.c +++ b/drivers/scsi/qla2xxx/qla_isr.c @@ -3763,7 +3763,8 @@ void qla24xx_process_response_queue(stru struct qla_hw_data *ha = vha->hw; struct purex_entry_24xx *purex_entry; struct purex_item *pure_item; - u16 cur_ring_index; + u16 rsp_in = 0, cur_ring_index; + int is_shadow_hba; if (!ha->flags.fw_started) return; @@ -3773,7 +3774,18 @@ void qla24xx_process_response_queue(stru qla_cpu_update(rsp->qpair, smp_processor_id()); } - while (rsp->ring_ptr->signature != RESPONSE_PROCESSED) { +#define __update_rsp_in(_is_shadow_hba, _rsp, _rsp_in) \ + do { \ + _rsp_in = _is_shadow_hba ? *(_rsp)->in_ptr : \ + rd_reg_dword_relaxed((_rsp)->rsp_q_in); \ + } while (0) + + is_shadow_hba = IS_SHADOW_REG_CAPABLE(ha); + + __update_rsp_in(is_shadow_hba, rsp, rsp_in); + + while (rsp->ring_index != rsp_in && + rsp->ring_ptr->signature != RESPONSE_PROCESSED) { pkt = (struct sts_entry_24xx *)rsp->ring_ptr; cur_ring_index = rsp->ring_index; @@ -3887,6 +3899,7 @@ process_err: } pure_item = qla27xx_copy_fpin_pkt(vha, (void **)&pkt, &rsp); + __update_rsp_in(is_shadow_hba, rsp, rsp_in); if (!pure_item) break; qla24xx_queue_purex_item(vha, pure_item, From patchwork Thu Oct 13 17:52:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2223 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp411482wrs; Thu, 13 Oct 2022 11:08:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6OBDxX+r7EYzFTSiM6uURbNFCHTI1PYR5kd5rtHo02IZIcrUvXm6d50aBi7Bbtc/dg+BKw X-Received: by 2002:a63:1750:0:b0:43a:9392:2676 with SMTP id 16-20020a631750000000b0043a93922676mr945662pgx.463.1665684518951; Thu, 13 Oct 2022 11:08:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684518; cv=none; d=google.com; s=arc-20160816; b=cbavVUhoSQN+xfpK3s7fAEYZoeav4Fzdd6pu3LBaw1TxyiKoD9eyxMvLqWQRtRNxOQ QICDg58dtYYal4jY9isxX/bAsMwCe2AF+6ITwJLzWb2FZLrYRzUdhdJbgDW25W0c2MlK IihLZBlvjnARkX8u9CYfawjt5C/CHb+p5j2pS4tt6oa7wkAsmkmeAgx7KSEi8zw+vV6m iU0tyEd6hbQbc1V/ROoJ/wYxygOAwhO/bGQQg/wvkygh4Bt6tlb2aU8A+RFCc3CAg2Ek RYdoRnFgwHJM0Gp3gWqHaoOyXR/RHsCfX1pnMNGZIy7t4bInNj4EE73nJCiS0E2ZGQcO aWng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2ap7yEYFJsrTDHxyBv9P9V1MpiYyLB8JdXjSedlR6vs=; b=G85oBT5mjDMc6XozDLQ0AEeXPgjtmlI0enWZGqyLw112gHPrt70vH/v71/MCBVYM0h 1zP6PdfI/GzfItwdAK7IS/Pwzai39Zdx9GUog334+DLF/4qFrSor/jXjp3rKdWqLLE/D PGV0PErs8hGXC+jxeBQ8SpxZrdPBe6QIsA1xlOW3egWRdO8QOGnYmBGxqlSa8BXEskvS m3vcZ/yJU9zgw/ATa49GQxjmwnpglvohtF6z/RzbY544lyI/gA3C4zpaIu3MaEHCXsBM +Ap2AdEhOGI1OcTXXjOD8sR1XggaQ44Q/RXSRiXsa4N4CwTQBP7daaOyFg1+WhLjBVTU FDug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sCrZPGQ2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fw4-20020a17090b128400b0020ad5d0a3cfsi250976pjb.22.2022.10.13.11.08.26; Thu, 13 Oct 2022 11:08:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sCrZPGQ2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230483AbiJMSIK (ORCPT + 99 others); Thu, 13 Oct 2022 14:08:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231555AbiJMSHM (ORCPT ); Thu, 13 Oct 2022 14:07:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6404DD03A8; Thu, 13 Oct 2022 11:05:22 -0700 (PDT) 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 D5F0B619B3; Thu, 13 Oct 2022 18:01:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E2838C433D6; Thu, 13 Oct 2022 18:01:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665684061; bh=u3wOX1M1rrknB6ZGLhBuFpeKJ4/JbNruxTQnEpNP1yA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sCrZPGQ2ld41hFQer0IQUKNgxk7IY+nHQyWYlVlWzkfhCr8nDUtTQSCBL+x6Zs1n4 7O68Sge8PnTD2T5CybXWClI7bMdacg0dMy7T4n4WjIPeX3+2RvB0Oh4E3WuKBmm9F9 ca/yv0yK2ye9YN7QlB7oyA9PxDEoiVRN7oMnJssA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable@kernel.org, "James E.J. Bottomley" , "Martin K. Petersen" , Dan Carpenter , hdthky , Linus Torvalds Subject: [PATCH 6.0 13/34] scsi: stex: Properly zero out the passthrough command structure Date: Thu, 13 Oct 2022 19:52:51 +0200 Message-Id: <20221013175146.865642668@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175146.507746257@linuxfoundation.org> References: <20221013175146.507746257@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746596810407549333?= X-GMAIL-MSGID: =?utf-8?q?1746596810407549333?= From: Linus Torvalds commit 6022f210461fef67e6e676fd8544ca02d1bcfa7a upstream. The passthrough structure is declared off of the stack, so it needs to be set to zero before copied back to userspace to prevent any unintentional data leakage. Switch things to be statically allocated which will fill the unused fields with 0 automatically. Link: https://lore.kernel.org/r/YxrjN3OOw2HHl9tx@kroah.com Cc: stable@kernel.org Cc: "James E.J. Bottomley" Cc: "Martin K. Petersen" Cc: Dan Carpenter Reported-by: hdthky Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/stex.c | 17 +++++++++-------- include/scsi/scsi_cmnd.h | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) --- a/drivers/scsi/stex.c +++ b/drivers/scsi/stex.c @@ -665,16 +665,17 @@ static int stex_queuecommand_lck(struct return 0; case PASSTHRU_CMD: if (cmd->cmnd[1] == PASSTHRU_GET_DRVVER) { - struct st_drvver ver; + const struct st_drvver ver = { + .major = ST_VER_MAJOR, + .minor = ST_VER_MINOR, + .oem = ST_OEM, + .build = ST_BUILD_VER, + .signature[0] = PASSTHRU_SIGNATURE, + .console_id = host->max_id - 1, + .host_no = hba->host->host_no, + }; size_t cp_len = sizeof(ver); - ver.major = ST_VER_MAJOR; - ver.minor = ST_VER_MINOR; - ver.oem = ST_OEM; - ver.build = ST_BUILD_VER; - ver.signature[0] = PASSTHRU_SIGNATURE; - ver.console_id = host->max_id - 1; - ver.host_no = hba->host->host_no; cp_len = scsi_sg_copy_from_buffer(cmd, &ver, cp_len); if (sizeof(ver) == cp_len) cmd->result = DID_OK << 16; --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h @@ -201,7 +201,7 @@ static inline unsigned int scsi_get_resi for_each_sg(scsi_sglist(cmd), sg, nseg, __i) static inline int scsi_sg_copy_from_buffer(struct scsi_cmnd *cmd, - void *buf, int buflen) + const void *buf, int buflen) { return sg_copy_from_buffer(scsi_sglist(cmd), scsi_sg_count(cmd), buf, buflen); From patchwork Thu Oct 13 17:52:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2224 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp411776wrs; Thu, 13 Oct 2022 11:09:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4MgWbY3awoxLQGfZmZ5grZK43LnFBu3IG4ZQdGzXiz0S1SEpmnPhRcw9Chw626v20+mZhg X-Received: by 2002:a17:902:e54e:b0:178:5371:5199 with SMTP id n14-20020a170902e54e00b0017853715199mr972413plf.59.1665684551484; Thu, 13 Oct 2022 11:09:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684551; cv=none; d=google.com; s=arc-20160816; b=V0YyFM2yYDluJ6frkguAj+zXV0nCGQ92FcBmevaErLzXv+OSKqnNUNk+qaj/mu5P0z it6ryNL4ne1/JiDOFkr0h+kbauWh9lCWqLxzXSYoH5dNI8mgmlMPE0ib5um4acVU+STM BYaODNtCzGVXhMvIzDYYMPjJzVQwNmOaYhK9pynJtBqW4MLUIwZ1UrAE6CcID2ImGgDL a8ql730NKSAi6WXLaLAxMf1HRdEN761UfIcpv1e7DQqhnS0Rz3ova8kHoExm5Qs0fa/N ZFzWTf88Mj8hnmQaCmBMfpEF+xzq7ESWVBtR2CWtnT82EMobRn6HqCShSfmWFbJVoz3R mg0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=n94YcU9eJvk4YYatYbbgQVbMk25EJupsfQK6OtcSIF8=; b=k53pb5UuHa6E+Vkv74utqx1/9hb5eLtGqmyvsA89RADAkq0ZXiLnCvwiVpt3mTyonS GviSVzUv683MGQigO2dEityk3PjMuPiMBh4dwk/iDS5tOZxQ8RHIcgV7n+cmWTkp48KS 0JFhc2AwsobjyJBttH9wCs6ynP1c/r12WwWpO66xZH+smkY5jNkJhljWwp3dRNowiQGc Vw4B2DcsxcyeO0486LOO5CPQOXVsSncAFI11A3lLqg8QnOZAUYzWGKRhf/XOdXiv0TjF el4xH0bEnWTFO7fqpw6ut67oAjQQamRatluOHZj0/YGSWTlYVOcpAxwD726LjUeEt+kb Lw5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0Dhm3jIG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s15-20020a63214f000000b0045fd7ef7478si71pgm.851.2022.10.13.11.08.59; Thu, 13 Oct 2022 11:09:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0Dhm3jIG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231676AbiJMSIY (ORCPT + 99 others); Thu, 13 Oct 2022 14:08:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231458AbiJMSHn (ORCPT ); Thu, 13 Oct 2022 14:07:43 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0954160EFB; Thu, 13 Oct 2022 11:05:33 -0700 (PDT) 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 156D3619C6; Thu, 13 Oct 2022 18:01:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 208B8C433C1; Thu, 13 Oct 2022 18:01:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665684064; bh=xm4dJk+a4xXbTCFuEdRLmVRDxS983Q+yBTlQeFFvqXU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0Dhm3jIGZFO2heety8nCOH0YaArjcpWPSHRGoou3/3X5zvWtePHvflW0iknGhlhGr nQI3Y3Hjnvo/yp30BNv45XJsPN6fMDunP+x2vKqP0NSEhvfIAYtPqd0IMd6QwhnMG/ G9q65xyQ6SsVhsuFeJnv0UzEC441oz3/dXNMktfc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Frank Wunderlich , Johan Hovold Subject: [PATCH 6.0 14/34] USB: serial: qcserial: add new usb-id for Dell branded EM7455 Date: Thu, 13 Oct 2022 19:52:52 +0200 Message-Id: <20221013175146.891278087@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175146.507746257@linuxfoundation.org> References: <20221013175146.507746257@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746596844188745176?= X-GMAIL-MSGID: =?utf-8?q?1746596844188745176?= From: Frank Wunderlich commit eee48781ea199e32c1d0c4732641c494833788ca upstream. Add support for Dell 5811e (EM7455) with USB-id 0x413c:0x81c2. Signed-off-by: Frank Wunderlich Cc: stable@vger.kernel.org Signed-off-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/qcserial.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/usb/serial/qcserial.c +++ b/drivers/usb/serial/qcserial.c @@ -177,6 +177,7 @@ static const struct usb_device_id id_tab {DEVICE_SWI(0x413c, 0x81b3)}, /* Dell Wireless 5809e Gobi(TM) 4G LTE Mobile Broadband Card (rev3) */ {DEVICE_SWI(0x413c, 0x81b5)}, /* Dell Wireless 5811e QDL */ {DEVICE_SWI(0x413c, 0x81b6)}, /* Dell Wireless 5811e QDL */ + {DEVICE_SWI(0x413c, 0x81c2)}, /* Dell Wireless 5811e */ {DEVICE_SWI(0x413c, 0x81cb)}, /* Dell Wireless 5816e QDL */ {DEVICE_SWI(0x413c, 0x81cc)}, /* Dell Wireless 5816e */ {DEVICE_SWI(0x413c, 0x81cf)}, /* Dell Wireless 5819 */ From patchwork Thu Oct 13 17:52:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2302 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp428604wrs; Thu, 13 Oct 2022 11:52:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4CQh5XaJTnwXCRp8SNnJeGaWYZrZ5xhZWPsvOqxrrnJzBJ6u5ML8vpR5uQUvmmxNz58jsL X-Received: by 2002:a17:90a:ac11:b0:20b:10d2:e837 with SMTP id o17-20020a17090aac1100b0020b10d2e837mr1287767pjq.165.1665687145519; Thu, 13 Oct 2022 11:52:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665687145; cv=none; d=google.com; s=arc-20160816; b=VMHx172Oh1R+2uyGO9iON4rj0d1hg7whs5t0mnjPTwChDZwcb1YewRm00wCNR9aja6 WVURBUqleTWTyTRYEauId8b8r75ecdo9jXm4YjDIR4sM3qimIk37FQVMQZ+Fin/o2JEZ DWW0sxaaMcab0tbjKC0aj4tUHVa4WtC72MYsy6UcXPgHmoDcCE/pyYEIFoT8htXSd5/S QDhOsnbhc53LPzytQIcAPsR0wpr1Uy47H709KCRzXZ+YOHX+nCO2B7yduZLl8p0Rxa9V 4A29xynZb38VbTmmF6hIgIF/lsGOnVNKwD6FvzKQfIh/8EzU0PB1mjH+6Eum96QqcN4x XUWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=n6xVL3UlxLU6iy5NOymQXgLssD5FLiavWN35R9FmrRU=; b=Czl387IAYsbWWUF01Fqz1BhwleBpqaFIMG1Kch2HC1dQTy7z8AOX/XJsfHGWkx5KUP 10+MSe44aUlPXJVHuQdSHYdih1O55AqkW1hW/9gav4u32ffNDgT7ppEwmA9c/7SvZ+Vi fTYqvUgZMeyO73pPWsIkKbXD1pDaj1GL/522LUWoGfsUtzoFsv1UTAppI5x9kT9ktfbc OuU70Ws1Ku5y2eRc+kWPIQX1nwNGXbgS2Ak8OrGwuX1eMLp4e5AMxeSyd2MQaOxOLVaG wZgJ/l7+Dh7vzQOwgZLnVF+5AVl974cL6dyso0QLYbAPaK3Ysz0G5caHmpYap9g8lAKI bWKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pg2lnftp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y13-20020a056a00190d00b00562cafb2856si237749pfi.78.2022.10.13.11.52.13; Thu, 13 Oct 2022 11:52:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pg2lnftp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231979AbiJMSjs (ORCPT + 99 others); Thu, 13 Oct 2022 14:39:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232013AbiJMSje (ORCPT ); Thu, 13 Oct 2022 14:39:34 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFA61E52ED; Thu, 13 Oct 2022 11:37:17 -0700 (PDT) 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 B2A68B82088; Thu, 13 Oct 2022 18:01:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20486C433B5; Thu, 13 Oct 2022 18:01:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665684068; bh=LZaqBYHcuIQk2aCRBz6Wyb3wafhltmWSwGIA3LWDVLs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pg2lnftp3t0pKetKpRqvheCsL29mWACkln/gfDvF2gdL59dNOoirVBqUlpfRl7UtC sWJlT1QE8Caf1EdKOIs1GUwRTp/AVw2IMEXJ8DPpyTVN79y7KsKbbkgKQCvaUhqSzq d1hIcqB5AaGRbUsllkdYpaDXUAYI2CFF1vzaafm8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ferry Toth , Andy Shevchenko Subject: [PATCH 6.0 15/34] Revert "USB: fixup for merge issue with "usb: dwc3: Dont switch OTG -> peripheral if extcon is present"" Date: Thu, 13 Oct 2022 19:52:53 +0200 Message-Id: <20221013175146.916141650@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175146.507746257@linuxfoundation.org> References: <20221013175146.507746257@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746599564389395130?= X-GMAIL-MSGID: =?utf-8?q?1746599564389395130?= From: Andy Shevchenko commit 2adc960ce79d3231b02f820daeee434542fe2911 upstream. This reverts commit 8bd6b8c4b1009d7d2662138d6bdc6fe58a9274c5. Prerequisite revert for the reverting of the original commit 0f0101719138. Fixes: 8bd6b8c4b100 ("USB: fixup for merge issue with "usb: dwc3: Don't switch OTG -> peripheral if extcon is present"") Fixes: 0f0101719138 ("usb: dwc3: Don't switch OTG -> peripheral if extcon is present") Reported-by: Ferry Toth Cc: stable@vger.kernel.org Signed-off-by: Andy Shevchenko Tested-by: Ferry Toth # for Merrifield Link: https://lore.kernel.org/r/20220927155332.10762-2-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc3/core.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1684,8 +1684,13 @@ static struct extcon_dev *dwc3_get_extco * This device property is for kernel internal use only and * is expected to be set by the glue code. */ - if (device_property_read_string(dev, "linux,extcon-name", &name) == 0) - return extcon_get_extcon_dev(name); + if (device_property_read_string(dev, "linux,extcon-name", &name) == 0) { + edev = extcon_get_extcon_dev(name); + if (!edev) + return ERR_PTR(-EPROBE_DEFER); + + return edev; + } /* * Try to get an extcon device from the USB PHY controller's "port" From patchwork Thu Oct 13 17:52:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2271 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp415206wrs; Thu, 13 Oct 2022 11:17:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6sr/dFZ7GJI0GF8M1Un3/8FncEMBPT7uvsUOibCnEj459wJIpH9Xw3p+/O6xAZkrO/pcNE X-Received: by 2002:a63:454d:0:b0:43c:e834:ec0 with SMTP id u13-20020a63454d000000b0043ce8340ec0mr1054263pgk.270.1665685022386; Thu, 13 Oct 2022 11:17:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665685022; cv=none; d=google.com; s=arc-20160816; b=mmPaEHOj6WONQuyKW2s/SFsWI7E5ePar5KuvshXi4w+p7aTvw0DdoOZBVaaUWC9mVV 3xx/qjyIMm8ckC3IE8LqaCHomP/m3ehfoNxQzIpnyaYMYJsI4pc+7rnf5fAnxBwdy64+ I7FVt51nQBv5yFfhJUtuCStySN3PvJ/eF9p9H6lG4p2a06RfSmY0YLiERPP5LPXkiV6s 0772ZEowEUwNfpat53MkWNBREb0fjlP7Ah+VVEK8FfoIura2+MWWvku7d3GwHb6xU7EK nF4wSFOaBu+CIxLWkD2p3lSku2LZw3hovYOwqellXRKg327fJy3KH2xT0VikBFHUysGN VKZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=znolENb3OtJtDAeY815NZh8WFppW/rGTYOWAnDN9JDk=; b=uhK2Sit7fxhxslu36QsbUqvpU1VUxs+XOMYCmQBoi1p9MBR9gbzebKNubxnlxdVgIy J+Ta+rw2LHF5pW4PC7u1jOv7vOHuaDacootWYiSKG3806PeDQthppy9IEQJHS+lIml7q 8RfROjKmQLYJeSletzmIpSoO/tAg6PhkmPLTc3fm+SWpBo1l5XTPM2DItWf7CNPZHgxd yaBVg+j+SyXbSzHlU7i4SYncEQKS/r2OHv22xhUI4fhb0nOCtAo8GixXSeEN8wSgYQlB OW94g5LNxlLooWH8/7pb5cxS4QHL00Rc4SoeBm0aqPC0TS6Ue20M4TJLN1jdXu0lxo25 U+kA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=O9gJDOBD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id il7-20020a17090b164700b001fb35ed6fdesi308614pjb.53.2022.10.13.11.16.49; Thu, 13 Oct 2022 11:17:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=O9gJDOBD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231235AbiJMSQ0 (ORCPT + 99 others); Thu, 13 Oct 2022 14:16:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232065AbiJMSOD (ORCPT ); Thu, 13 Oct 2022 14:14:03 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88448C696D; Thu, 13 Oct 2022 11:10:22 -0700 (PDT) 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 79FA5B8208A; Thu, 13 Oct 2022 18:01:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9EF4C43140; Thu, 13 Oct 2022 18:01:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665684071; bh=zRDyqTsvfv0HYuMdDsaBuYunJJDtyf5HIeyATqjvbEk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O9gJDOBD4FHzP9GWlfszoUveJmA2x9/JHGe3KQZpFBobpbEomu1PFkrfVyXmr913b feXcDZ1ChxEas1YjWxIHpuHIT4YjDqyPJ8FaH7LwGXENfvje7+okvt88ytWzkvRmMN fgwKmiiG3lXNBIE8zHyKdJCG4ZElE26XU+uM4haU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ferry Toth , Andy Shevchenko , Sven Peter Subject: [PATCH 6.0 16/34] Revert "usb: dwc3: Dont switch OTG -> peripheral if extcon is present" Date: Thu, 13 Oct 2022 19:52:54 +0200 Message-Id: <20221013175146.942398236@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175146.507746257@linuxfoundation.org> References: <20221013175146.507746257@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746597338370411690?= X-GMAIL-MSGID: =?utf-8?q?1746597338370411690?= From: Andy Shevchenko commit 7a84e7353e23202d4f82b05093af4db2b26e6768 upstream. This reverts commit 0f01017191384e3962fa31520a9fd9846c3d352f. As pointed out by Ferry this breaks Dual Role support on Intel Merrifield platforms. Fixes: 0f0101719138 ("usb: dwc3: Don't switch OTG -> peripheral if extcon is present") Reported-by: Ferry Toth Cc: stable@vger.kernel.org Signed-off-by: Andy Shevchenko Tested-by: Ferry Toth # for Merrifield Reviewed-by: Sven Peter Link: https://lore.kernel.org/r/20220927155332.10762-3-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc3/core.c | 55 ------------------------------------------------ drivers/usb/dwc3/drd.c | 50 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 54 deletions(-) --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -86,7 +85,7 @@ static int dwc3_get_dr_mode(struct dwc3 * mode. If the controller supports DRD but the dr_mode is not * specified or set to OTG, then set the mode to peripheral. */ - if (mode == USB_DR_MODE_OTG && !dwc->edev && + if (mode == USB_DR_MODE_OTG && (!IS_ENABLED(CONFIG_USB_ROLE_SWITCH) || !device_property_read_bool(dwc->dev, "usb-role-switch")) && !DWC3_VER_IS_PRIOR(DWC3, 330A)) @@ -1668,51 +1667,6 @@ static void dwc3_check_params(struct dwc } } -static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc) -{ - struct device *dev = dwc->dev; - struct device_node *np_phy; - struct extcon_dev *edev = NULL; - const char *name; - - if (device_property_read_bool(dev, "extcon")) - return extcon_get_edev_by_phandle(dev, 0); - - /* - * Device tree platforms should get extcon via phandle. - * On ACPI platforms, we get the name from a device property. - * This device property is for kernel internal use only and - * is expected to be set by the glue code. - */ - if (device_property_read_string(dev, "linux,extcon-name", &name) == 0) { - edev = extcon_get_extcon_dev(name); - if (!edev) - return ERR_PTR(-EPROBE_DEFER); - - return edev; - } - - /* - * Try to get an extcon device from the USB PHY controller's "port" - * node. Check if it has the "port" node first, to avoid printing the - * error message from underlying code, as it's a valid case: extcon - * device (and "port" node) may be missing in case of "usb-role-switch" - * or OTG mode. - */ - np_phy = of_parse_phandle(dev->of_node, "phys", 0); - if (of_graph_is_present(np_phy)) { - struct device_node *np_conn; - - np_conn = of_graph_get_remote_node(np_phy, -1, -1); - if (np_conn) - edev = extcon_find_edev_by_node(np_conn); - of_node_put(np_conn); - } - of_node_put(np_phy); - - return edev; -} - static int dwc3_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -1849,13 +1803,6 @@ static int dwc3_probe(struct platform_de goto err2; } - dwc->edev = dwc3_get_extcon(dwc); - if (IS_ERR(dwc->edev)) { - ret = PTR_ERR(dwc->edev); - dev_err_probe(dwc->dev, ret, "failed to get extcon\n"); - goto err3; - } - ret = dwc3_get_dr_mode(dwc); if (ret) goto err3; --- a/drivers/usb/dwc3/drd.c +++ b/drivers/usb/dwc3/drd.c @@ -8,6 +8,7 @@ */ #include +#include #include #include #include @@ -438,6 +439,51 @@ static int dwc3_drd_notifier(struct noti return NOTIFY_DONE; } +static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc) +{ + struct device *dev = dwc->dev; + struct device_node *np_phy; + struct extcon_dev *edev = NULL; + const char *name; + + if (device_property_read_bool(dev, "extcon")) + return extcon_get_edev_by_phandle(dev, 0); + + /* + * Device tree platforms should get extcon via phandle. + * On ACPI platforms, we get the name from a device property. + * This device property is for kernel internal use only and + * is expected to be set by the glue code. + */ + if (device_property_read_string(dev, "linux,extcon-name", &name) == 0) { + edev = extcon_get_extcon_dev(name); + if (!edev) + return ERR_PTR(-EPROBE_DEFER); + + return edev; + } + + /* + * Try to get an extcon device from the USB PHY controller's "port" + * node. Check if it has the "port" node first, to avoid printing the + * error message from underlying code, as it's a valid case: extcon + * device (and "port" node) may be missing in case of "usb-role-switch" + * or OTG mode. + */ + np_phy = of_parse_phandle(dev->of_node, "phys", 0); + if (of_graph_is_present(np_phy)) { + struct device_node *np_conn; + + np_conn = of_graph_get_remote_node(np_phy, -1, -1); + if (np_conn) + edev = extcon_find_edev_by_node(np_conn); + of_node_put(np_conn); + } + of_node_put(np_phy); + + return edev; +} + #if IS_ENABLED(CONFIG_USB_ROLE_SWITCH) #define ROLE_SWITCH 1 static int dwc3_usb_role_switch_set(struct usb_role_switch *sw, @@ -542,6 +588,10 @@ int dwc3_drd_init(struct dwc3 *dwc) device_property_read_bool(dwc->dev, "usb-role-switch")) return dwc3_setup_role_switch(dwc); + dwc->edev = dwc3_get_extcon(dwc); + if (IS_ERR(dwc->edev)) + return PTR_ERR(dwc->edev); + if (dwc->edev) { dwc->edev_nb.notifier_call = dwc3_drd_notifier; ret = extcon_register_notifier(dwc->edev, EXTCON_USB_HOST, From patchwork Thu Oct 13 17:52:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2227 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp412035wrs; Thu, 13 Oct 2022 11:09:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6cBf3epBtlMvui3qljjavk4xHxgnVgmfRwO4P0cLavwgC6AxQ1ElPJr4I4J3FOwheeenO/ X-Received: by 2002:a17:902:690a:b0:17a:32d:7acc with SMTP id j10-20020a170902690a00b0017a032d7accmr949207plk.18.1665684586255; Thu, 13 Oct 2022 11:09:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684586; cv=none; d=google.com; s=arc-20160816; b=aNKpzMMZWaNZEhV/c14HKHmHPvjnZVrCgSMQuzsbS6SxXqviNsnPjgvqFHQ8kBHN7i 8IYu4DjgcAHtbwaXmJXnsRQYPxQ93BZ8wxy/PpBEMKeo1MZOSgEhM++AujwreNbSY+r5 B4CjjYCvWDh+odC1RS+33/Fw+nZTRGuMaECiGJalzDoWLbcJ1Uba7UY7Hm0ITRNfCP11 t7hsQefmTsTzo+0chuvBX/+YImshaRtPmUg75CdQAgbsMzMT949Mz4IBHN4ampWox8kI 1YvjlYu8aD4ScW99Nry+WRAb0etk1LtoeHsx4WLKeEZWe+LChvjYcCoE4F8r7oGZCvQ2 yGiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=OIJqYRlCxH5KpA/gF76wHhzR/XXka/tEsB+5X3n3h/U=; b=R/bxsB6ejR2eO3te9kHblSNFnhAQ79RWiryItD/02SGehJTrd8Y0ralldHl6iLHdmu IoPS+tiLZERlj33zApX1931JgqT/E/eMrJt1CJUc2qMH21Y5hJk3ebhrpBF6BkOLLPRu 4STg0F9f7Vqil2RRJ1qXZdcME8GM88H3GnLgzbS4aP8BR1ROyd0fR0F+jeZPDkrgHfuS IdqNTLoX4fNN0HeYmF8QRff4JECXRmXRC4/MvRmz1/jtGKGnWX0+IwRrpNTg7O1dJW/S 8YSlt+axr20yM3JyhghdC2JyPhuojmzPBQmfNNPFfyGm65cvp5yWi/VPCYHVCBkH0pu6 FtAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OFkiqKKe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l8-20020a170903120800b001727a15dbf8si448041plh.345.2022.10.13.11.09.33; Thu, 13 Oct 2022 11:09:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OFkiqKKe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231194AbiJMSJW (ORCPT + 99 others); Thu, 13 Oct 2022 14:09:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231757AbiJMSIn (ORCPT ); Thu, 13 Oct 2022 14:08:43 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 217403470D; Thu, 13 Oct 2022 11:06:20 -0700 (PDT) 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 55848619F7; Thu, 13 Oct 2022 18:01:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 32B0AC433D6; Thu, 13 Oct 2022 18:01:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665684074; bh=5fGeL9rrSeEnEiyxIZ1qrK6yt0BsEelbTs8rHswWTrY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OFkiqKKeB4JRTYj5cAUN2BuyrjxrFoQ/j0M8uzxK+gUE2tODiuEJWkIyMobdZilkp kRiyqMApMGAI9CQIvD/VkR5AsP1HERl8PWLowln9evEVC6vCOXbZyT77/RVEZPvdos JBvKu/2nSziX24ZNewvuUjAjeT4XkRDeN5Yv9yxk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nathan Lynch , Laurent Dufour , Michael Ellerman Subject: [PATCH 6.0 17/34] Revert "powerpc/rtas: Implement reentrant rtas call" Date: Thu, 13 Oct 2022 19:52:55 +0200 Message-Id: <20221013175146.967941800@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175146.507746257@linuxfoundation.org> References: <20221013175146.507746257@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746596880596324916?= X-GMAIL-MSGID: =?utf-8?q?1746596880596324916?= From: Nathan Lynch commit f88aabad33ea22be2ce1c60d8901942e4e2a9edb upstream. At the time this was submitted by Leonardo, I confirmed -- or thought I had confirmed -- with PowerVM partition firmware development that the following RTAS functions: - ibm,get-xive - ibm,int-off - ibm,int-on - ibm,set-xive were safe to call on multiple CPUs simultaneously, not only with respect to themselves as indicated by PAPR, but with arbitrary other RTAS calls: https://lore.kernel.org/linuxppc-dev/875zcy2v8o.fsf@linux.ibm.com/ Recent discussion with firmware development makes it clear that this is not true, and that the code in commit b664db8e3f97 ("powerpc/rtas: Implement reentrant rtas call") is unsafe, likely explaining several strange bugs we've seen in internal testing involving DLPAR and LPM. These scenarios use ibm,configure-connector, whose internal state can be corrupted by the concurrent use of the "reentrant" functions, leading to symptoms like endless busy statuses from RTAS. Fixes: b664db8e3f97 ("powerpc/rtas: Implement reentrant rtas call") Cc: stable@vger.kernel.org # v5.8+ Signed-off-by: Nathan Lynch Reviewed-by: Laurent Dufour Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20220907220111.223267-1-nathanl@linux.ibm.com Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/include/asm/paca.h | 1 arch/powerpc/include/asm/rtas.h | 1 arch/powerpc/kernel/paca.c | 32 --------------------- arch/powerpc/kernel/rtas.c | 54 ------------------------------------ arch/powerpc/sysdev/xics/ics-rtas.c | 22 +++++++------- 5 files changed, 11 insertions(+), 99 deletions(-) --- a/arch/powerpc/include/asm/paca.h +++ b/arch/powerpc/include/asm/paca.h @@ -263,7 +263,6 @@ struct paca_struct { u64 l1d_flush_size; #endif #ifdef CONFIG_PPC_PSERIES - struct rtas_args *rtas_args_reentrant; u8 *mce_data_buf; /* buffer to hold per cpu rtas errlog */ #endif /* CONFIG_PPC_PSERIES */ --- a/arch/powerpc/include/asm/rtas.h +++ b/arch/powerpc/include/asm/rtas.h @@ -240,7 +240,6 @@ extern struct rtas_t rtas; extern int rtas_token(const char *service); extern int rtas_service_present(const char *service); extern int rtas_call(int token, int, int, int *, ...); -int rtas_call_reentrant(int token, int nargs, int nret, int *outputs, ...); void rtas_call_unlocked(struct rtas_args *args, int token, int nargs, int nret, ...); extern void __noreturn rtas_restart(char *cmd); --- a/arch/powerpc/kernel/paca.c +++ b/arch/powerpc/kernel/paca.c @@ -16,7 +16,6 @@ #include #include #include -#include #include "setup.h" @@ -170,30 +169,6 @@ static struct slb_shadow * __init new_sl } #endif /* CONFIG_PPC_64S_HASH_MMU */ -#ifdef CONFIG_PPC_PSERIES -/** - * new_rtas_args() - Allocates rtas args - * @cpu: CPU number - * @limit: Memory limit for this allocation - * - * Allocates a struct rtas_args and return it's pointer, - * if not in Hypervisor mode - * - * Return: Pointer to allocated rtas_args - * NULL if CPU in Hypervisor Mode - */ -static struct rtas_args * __init new_rtas_args(int cpu, unsigned long limit) -{ - limit = min_t(unsigned long, limit, RTAS_INSTANTIATE_MAX); - - if (early_cpu_has_feature(CPU_FTR_HVMODE)) - return NULL; - - return alloc_paca_data(sizeof(struct rtas_args), L1_CACHE_BYTES, - limit, cpu); -} -#endif /* CONFIG_PPC_PSERIES */ - /* The Paca is an array with one entry per processor. Each contains an * lppaca, which contains the information shared between the * hypervisor and Linux. @@ -232,10 +207,6 @@ void __init initialise_paca(struct paca_ /* For now -- if we have threads this will be adjusted later */ new_paca->tcd_ptr = &new_paca->tcd; #endif - -#ifdef CONFIG_PPC_PSERIES - new_paca->rtas_args_reentrant = NULL; -#endif } /* Put the paca pointer into r13 and SPRG_PACA */ @@ -308,9 +279,6 @@ void __init allocate_paca(int cpu) #ifdef CONFIG_PPC_64S_HASH_MMU paca->slb_shadow_ptr = new_slb_shadow(cpu, limit); #endif -#ifdef CONFIG_PPC_PSERIES - paca->rtas_args_reentrant = new_rtas_args(cpu, limit); -#endif paca_struct_size += sizeof(struct paca_struct); } --- a/arch/powerpc/kernel/rtas.c +++ b/arch/powerpc/kernel/rtas.c @@ -43,7 +43,6 @@ #include #include #include -#include /* This is here deliberately so it's only used in this file */ void enter_rtas(unsigned long); @@ -932,59 +931,6 @@ void rtas_activate_firmware(void) pr_err("ibm,activate-firmware failed (%i)\n", fwrc); } -#ifdef CONFIG_PPC_PSERIES -/** - * rtas_call_reentrant() - Used for reentrant rtas calls - * @token: Token for desired reentrant RTAS call - * @nargs: Number of Input Parameters - * @nret: Number of Output Parameters - * @outputs: Array of outputs - * @...: Inputs for desired RTAS call - * - * According to LoPAR documentation, only "ibm,int-on", "ibm,int-off", - * "ibm,get-xive" and "ibm,set-xive" are currently reentrant. - * Reentrant calls need their own rtas_args buffer, so not using rtas.args, but - * PACA one instead. - * - * Return: -1 on error, - * First output value of RTAS call if (nret > 0), - * 0 otherwise, - */ -int rtas_call_reentrant(int token, int nargs, int nret, int *outputs, ...) -{ - va_list list; - struct rtas_args *args; - unsigned long flags; - int i, ret = 0; - - if (!rtas.entry || token == RTAS_UNKNOWN_SERVICE) - return -1; - - local_irq_save(flags); - preempt_disable(); - - /* We use the per-cpu (PACA) rtas args buffer */ - args = local_paca->rtas_args_reentrant; - - va_start(list, outputs); - va_rtas_call_unlocked(args, token, nargs, nret, list); - va_end(list); - - if (nret > 1 && outputs) - for (i = 0; i < nret - 1; ++i) - outputs[i] = be32_to_cpu(args->rets[i + 1]); - - if (nret > 0) - ret = be32_to_cpu(args->rets[0]); - - local_irq_restore(flags); - preempt_enable(); - - return ret; -} - -#endif /* CONFIG_PPC_PSERIES */ - /** * get_pseries_errorlog() - Find a specific pseries error log in an RTAS * extended event log. --- a/arch/powerpc/sysdev/xics/ics-rtas.c +++ b/arch/powerpc/sysdev/xics/ics-rtas.c @@ -36,8 +36,8 @@ static void ics_rtas_unmask_irq(struct i server = xics_get_irq_server(d->irq, irq_data_get_affinity_mask(d), 0); - call_status = rtas_call_reentrant(ibm_set_xive, 3, 1, NULL, hw_irq, - server, DEFAULT_PRIORITY); + call_status = rtas_call(ibm_set_xive, 3, 1, NULL, hw_irq, server, + DEFAULT_PRIORITY); if (call_status != 0) { printk(KERN_ERR "%s: ibm_set_xive irq %u server %x returned %d\n", @@ -46,7 +46,7 @@ static void ics_rtas_unmask_irq(struct i } /* Now unmask the interrupt (often a no-op) */ - call_status = rtas_call_reentrant(ibm_int_on, 1, 1, NULL, hw_irq); + call_status = rtas_call(ibm_int_on, 1, 1, NULL, hw_irq); if (call_status != 0) { printk(KERN_ERR "%s: ibm_int_on irq=%u returned %d\n", __func__, hw_irq, call_status); @@ -68,7 +68,7 @@ static void ics_rtas_mask_real_irq(unsig if (hw_irq == XICS_IPI) return; - call_status = rtas_call_reentrant(ibm_int_off, 1, 1, NULL, hw_irq); + call_status = rtas_call(ibm_int_off, 1, 1, NULL, hw_irq); if (call_status != 0) { printk(KERN_ERR "%s: ibm_int_off irq=%u returned %d\n", __func__, hw_irq, call_status); @@ -76,8 +76,8 @@ static void ics_rtas_mask_real_irq(unsig } /* Have to set XIVE to 0xff to be able to remove a slot */ - call_status = rtas_call_reentrant(ibm_set_xive, 3, 1, NULL, hw_irq, - xics_default_server, 0xff); + call_status = rtas_call(ibm_set_xive, 3, 1, NULL, hw_irq, + xics_default_server, 0xff); if (call_status != 0) { printk(KERN_ERR "%s: ibm_set_xive(0xff) irq=%u returned %d\n", __func__, hw_irq, call_status); @@ -108,7 +108,7 @@ static int ics_rtas_set_affinity(struct if (hw_irq == XICS_IPI || hw_irq == XICS_IRQ_SPURIOUS) return -1; - status = rtas_call_reentrant(ibm_get_xive, 1, 3, xics_status, hw_irq); + status = rtas_call(ibm_get_xive, 1, 3, xics_status, hw_irq); if (status) { printk(KERN_ERR "%s: ibm,get-xive irq=%u returns %d\n", @@ -126,8 +126,8 @@ static int ics_rtas_set_affinity(struct pr_debug("%s: irq %d [hw 0x%x] server: 0x%x\n", __func__, d->irq, hw_irq, irq_server); - status = rtas_call_reentrant(ibm_set_xive, 3, 1, NULL, - hw_irq, irq_server, xics_status[1]); + status = rtas_call(ibm_set_xive, 3, 1, NULL, + hw_irq, irq_server, xics_status[1]); if (status) { printk(KERN_ERR "%s: ibm,set-xive irq=%u returns %d\n", @@ -158,7 +158,7 @@ static int ics_rtas_check(struct ics *ic return -EINVAL; /* Check if RTAS knows about this interrupt */ - rc = rtas_call_reentrant(ibm_get_xive, 1, 3, status, hw_irq); + rc = rtas_call(ibm_get_xive, 1, 3, status, hw_irq); if (rc) return -ENXIO; @@ -174,7 +174,7 @@ static long ics_rtas_get_server(struct i { int rc, status[2]; - rc = rtas_call_reentrant(ibm_get_xive, 1, 3, status, vec); + rc = rtas_call(ibm_get_xive, 1, 3, status, vec); if (rc) return -1; return status[0]; From patchwork Thu Oct 13 17:52:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2229 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp412220wrs; Thu, 13 Oct 2022 11:10:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6mC+0+a7w86yCKjYapQUheg9uLXPInnDBoYiKtqv3Vp5mjKYQulMoI7hM38VcVRLjLCATG X-Received: by 2002:a17:90b:3e82:b0:20d:2fa1:d08d with SMTP id rj2-20020a17090b3e8200b0020d2fa1d08dmr12915179pjb.162.1665684608440; Thu, 13 Oct 2022 11:10:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684608; cv=none; d=google.com; s=arc-20160816; b=Cu79FphKEisXkurlNBA6Hc1Ocv8qdJ+QiLXsP/RUh5eJe8TQe5vbS1AV/v72d0Kz+T A9oWjbinE7Yyfax7gIaHM/ensl42ZQzY3vClcywAdAyAKX7h41TCmm/YzT4BApMtFTGy uiD4b0y7trS8QBLTToeiM7x8KCw/Rx8R4C8LuGxLWY1RHL2vZK2BcdT4FZR3PK30FYr9 6IOe1nxQek4L7O4OurhtGf5S2Bl4uIg0rgo2rAwCDCI86BEujC6ODArS1Y2MMph3tDK2 qmyfowDOp/B/NhmI6FuGjt3JANbHRCP1NckON/BSl1sZvbTLHiVI5i7+pUxaQp0b4I9o 5Ipw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4GVxEZ9y2rt0iK4DrnBH0LFAiNDjocNAdwdPVGD2JpY=; b=ivb2KIDAKWQa84vXC1IfSwp2a8VsjYKpcfIdDHxtuesps4vCbKuqS1Ywl+3SrvLfza O3ak90zLAT3H2qTBq7VukCNOXagDmU7OYGihLR3teyGJOM+GSQ9rOxJAhAT68SmrSJq9 ZXHYqGn4JrLbqP5zvqD+j54u0bxeu0KFXva2sV7U5RFmJiLfd9bKjl4u7mT59TzzWDjh ItgX0Qx1KWNGwu0v1Zd1qgpMFRZ/4kz1ZlMiK9zovf0+WcDhXwg0dfuw2msdAy5jrVWw UzFjncMpA8a/M5JgzNxbP3mPUAbbj/JOg6JZ4JYn5WZTtKRE1V5L+mkL5C6VleIEawm/ joKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=opAKSoT+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l62-20020a638841000000b0044c7a49bef7si77387pgd.259.2022.10.13.11.09.55; Thu, 13 Oct 2022 11:10:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=opAKSoT+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231320AbiJMSJp (ORCPT + 99 others); Thu, 13 Oct 2022 14:09:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231868AbiJMSI5 (ORCPT ); Thu, 13 Oct 2022 14:08:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EFC914FD34; Thu, 13 Oct 2022 11:06:39 -0700 (PDT) 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 3C54C61A0D; Thu, 13 Oct 2022 18:01:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA8FCC4314E; Thu, 13 Oct 2022 18:01:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665684078; bh=4rWjydFXyLLDqW4rzOLOSOJ8MSOKHrz5swor8EvZv0k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=opAKSoT+UWpUDUlN3cQrkbLRdPJgg9jef+Ve4MW5Xy0NyJenCpg23YnXXPqhuw6ol TndVd7kw7GETWK+yflZEVp7Md9ELpDlTk8rA25sG6QLeFr1g1EXIKt6RS43TOkbMzc t5ktAJuAJXeKovoFe2MTEmcZLJ7JcM5fIEmU73ks= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Herbert Xu , Giovanni Cabiddu Subject: [PATCH 6.0 18/34] Revert "crypto: qat - reduce size of mapped region" Date: Thu, 13 Oct 2022 19:52:56 +0200 Message-Id: <20221013175146.994722955@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175146.507746257@linuxfoundation.org> References: <20221013175146.507746257@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746596903801740942?= X-GMAIL-MSGID: =?utf-8?q?1746596903801740942?= From: Giovanni Cabiddu commit 9c5f21b198d259bfe1191b1fedf08e2eab15b33b upstream. This reverts commit e48767c17718067ba21fb2ef461779ec2506f845. In an attempt to resolve a set of warnings reported by the static analyzer Smatch, the reverted commit improperly reduced the sizes of the DMA mappings used for the input and output parameters for both RSA and DH creating a mismatch (map size=8 bytes, unmap size=64 bytes). This issue is reported when CONFIG_DMA_API_DEBUG is selected, when the crypto self test is run. The function dma_unmap_single() reports a warning similar to the one below, saying that the `device driver frees DMA memory with different size`. DMA-API: 4xxx 0000:06:00.0: device driver frees DMA memory with different size [device address=0x0000000123206c80] [map size=8 bytes] [unmap size=64 bytes] WARNING: CPU: 0 PID: 0 at kernel/dma/debug.c:973 check_unmap+0x3d0/0x8c0\ ... Call Trace: debug_dma_unmap_page+0x5c/0x60 qat_dh_cb+0xd7/0x110 [intel_qat] qat_alg_asym_callback+0x1a/0x30 [intel_qat] adf_response_handler+0xbd/0x1a0 [intel_qat] tasklet_action_common.constprop.0+0xcd/0xe0 __do_softirq+0xf8/0x30c __irq_exit_rcu+0xbf/0x140 common_interrupt+0xb9/0xd0 The original commit was correct. Cc: Reported-by: Herbert Xu Signed-off-by: Giovanni Cabiddu Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/qat/qat_common/qat_asym_algs.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) --- a/drivers/crypto/qat/qat_common/qat_asym_algs.c +++ b/drivers/crypto/qat/qat_common/qat_asym_algs.c @@ -333,13 +333,13 @@ static int qat_dh_compute_value(struct k qat_req->out.dh.out_tab[1] = 0; /* Mapping in.in.b or in.in_g2.xa is the same */ qat_req->phy_in = dma_map_single(dev, &qat_req->in.dh.in.b, - sizeof(qat_req->in.dh.in.b), + sizeof(struct qat_dh_input_params), DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev, qat_req->phy_in))) goto unmap_dst; qat_req->phy_out = dma_map_single(dev, &qat_req->out.dh.r, - sizeof(qat_req->out.dh.r), + sizeof(struct qat_dh_output_params), DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev, qat_req->phy_out))) goto unmap_in_params; @@ -730,13 +730,13 @@ static int qat_rsa_enc(struct akcipher_r qat_req->in.rsa.in_tab[3] = 0; qat_req->out.rsa.out_tab[1] = 0; qat_req->phy_in = dma_map_single(dev, &qat_req->in.rsa.enc.m, - sizeof(qat_req->in.rsa.enc.m), + sizeof(struct qat_rsa_input_params), DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev, qat_req->phy_in))) goto unmap_dst; qat_req->phy_out = dma_map_single(dev, &qat_req->out.rsa.enc.c, - sizeof(qat_req->out.rsa.enc.c), + sizeof(struct qat_rsa_output_params), DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev, qat_req->phy_out))) goto unmap_in_params; @@ -876,13 +876,13 @@ static int qat_rsa_dec(struct akcipher_r qat_req->in.rsa.in_tab[3] = 0; qat_req->out.rsa.out_tab[1] = 0; qat_req->phy_in = dma_map_single(dev, &qat_req->in.rsa.dec.c, - sizeof(qat_req->in.rsa.dec.c), + sizeof(struct qat_rsa_input_params), DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev, qat_req->phy_in))) goto unmap_dst; qat_req->phy_out = dma_map_single(dev, &qat_req->out.rsa.dec.m, - sizeof(qat_req->out.rsa.dec.m), + sizeof(struct qat_rsa_output_params), DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev, qat_req->phy_out))) goto unmap_in_params; From patchwork Thu Oct 13 17:52:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2230 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp412275wrs; Thu, 13 Oct 2022 11:10:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7a6LPlnbuOwxPbXNhCV9bxXwh5ViX+btIUItbTXxU2qFnYIAt6WkwlHQTWYRgWI9f0pLaJ X-Received: by 2002:a17:902:ef89:b0:17f:8097:83bb with SMTP id iz9-20020a170902ef8900b0017f809783bbmr909089plb.20.1665684615610; Thu, 13 Oct 2022 11:10:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684615; cv=none; d=google.com; s=arc-20160816; b=X/VnME0ta/6g53hYYmSn16TyKYPyvvU+W64pMwS09zVZQqm6YIfWCuIqcheHegmWip aJouqZdbe/AGhT3ZUtXb49vPnL/JVOr6fuUvN69gKIXP7fm80AJ2HZJ3XZqVC1djk8hI Chs6YqDZvUc9OlZg8MDQWW10pXCfshpL755vI/Lc2QvTAX+C59KrtQecmLMEOPy0zhz6 RRkM/fh9WZ+7jMY7fVn//R+JQHxx020IHimzGCkQ9iVA1DA2loxjkFLJ4+OjXwmVnjBu +cbuyaVU4nxC9XNiCQyQZ0+CgWUkeFW0NS4PyJI2B3+9V+N5pNQJWdCFpHnr8AgqfeDU rVnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=DmLpAb6c0BytwCX8H3bwk2/pfC4s0U+fzQfV7wsYv9I=; b=KWNTQEax5PHoPRNkj8Mi8VYJCV+F/34Whnsym+rIQR5uNNWIeE2XEcTGgfQvoEJNbg qO0qWARVVpbOdmNdQqkOKYCUNXE+bowxU4XSB7492z+3EXIvA3pcJf+o7dA92rQXWU42 sdGNZeFPj9/SeNHxHwoe1XLgBvwmx+sKyQOR+vEwc/Pt53O2D6mZy6SRP+I3nz95kp8Z w10apHIXkz64FhDOb6NyXe7/fEkzcUUMc8tbOW+3Yxy+D6lQ7QmvQOzODiMkgJGpRYIk WkOv9LeYbZRfxDwgp9qxvDygxFMmpBgrWQFcYlMxDGZ8k67bwktg4Q8LyNKgd0yxhvO5 H5fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Qa1TQI3/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o5-20020a1709026b0500b00184c33ddeb8si446056plk.23.2022.10.13.11.10.02; Thu, 13 Oct 2022 11:10:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Qa1TQI3/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231402AbiJMSJx (ORCPT + 99 others); Thu, 13 Oct 2022 14:09:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231873AbiJMSI5 (ORCPT ); Thu, 13 Oct 2022 14:08:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DE041633AD; Thu, 13 Oct 2022 11:06:53 -0700 (PDT) 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 E493B6190D; Thu, 13 Oct 2022 18:01:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B6F7C433D6; Thu, 13 Oct 2022 18:01:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665684081; bh=0AtYCypjBm2AxQIyd9GfbErbZ6yuOnswlF1Z4Pi9P8M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qa1TQI3/FjCsTAyBQLaEBV5/j3r70zKPl4I/jqVzpGwO6uCzs+zVeT11iflJyk7qR +ngk+lziJeljf00aevZdchT6Anqt3+2xEHejuF8ucZcZAMQ+dIU+qx1660g5444HyH 3n7LqP0x6sc64YHrv+WHjJQmR3EH/eiWQoAxlkds= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sebastian Andrzej Siewior , "Jason A. Donenfeld" Subject: [PATCH 6.0 19/34] random: avoid reading two cache lines on irq randomness Date: Thu, 13 Oct 2022 19:52:57 +0200 Message-Id: <20221013175147.018941454@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175146.507746257@linuxfoundation.org> References: <20221013175146.507746257@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746596911446184441?= X-GMAIL-MSGID: =?utf-8?q?1746596911446184441?= From: Jason A. Donenfeld commit 9ee0507e896b45af6d65408c77815800bce30008 upstream. In order to avoid reading and dirtying two cache lines on every IRQ, move the work_struct to the bottom of the fast_pool struct. add_ interrupt_randomness() always touches .pool and .count, which are currently split, because .mix pushes everything down. Instead, move .mix to the bottom, so that .pool and .count are always in the first cache line, since .mix is only accessed when the pool is full. Fixes: 58340f8e952b ("random: defer fast pool mixing to worker") Reviewed-by: Sebastian Andrzej Siewior Signed-off-by: Jason A. Donenfeld Signed-off-by: Greg Kroah-Hartman --- drivers/char/random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -920,10 +920,10 @@ EXPORT_SYMBOL_GPL(unregister_random_vmfo #endif struct fast_pool { - struct work_struct mix; unsigned long pool[4]; unsigned long last; unsigned int count; + struct work_struct mix; }; static DEFINE_PER_CPU(struct fast_pool, irq_randomness) = { From patchwork Thu Oct 13 17:52:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2265 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp414783wrs; Thu, 13 Oct 2022 11:16:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5+zmY1voSHMDjl7ulMHT6DNRghO4UMKO0aPIjPy5yeUSLA/CzGiKw9JoNsr1/yxesP2LVt X-Received: by 2002:a17:902:e849:b0:17f:f3c4:a2c4 with SMTP id t9-20020a170902e84900b0017ff3c4a2c4mr914719plg.125.1665684975212; Thu, 13 Oct 2022 11:16:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684975; cv=none; d=google.com; s=arc-20160816; b=qbq+85B4zoQ/EerdcrPg7JkIcswnvesXUjMR+tFGYfJD/3GHZMU1xg5xKiqTPcqnKb Zvk9P4rBujdfz5k3yRUbik9CJObx4L/g573p/dQO3b4VYNePchLIMrB1fxJDOQw79x0L rp9OfwrY9CmgTuSyc+E2eIaP23NGEwpt2FhV8a813SG8Mqy+lVuoIhsj663Jd7oBda3t q9O/hqjQ+As7XdLmODTTgeFJIy13tp7XwujvFnv+0ml8Dc6ouI9TN52ykbMi0ecbzv8B VSiu+gR94rl5zGqlCK/tmKkHsRU6bI9ty36XqJ8LUrjMgZjWpmxOYavSYVT508vpTi8F dpLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6xUYP0N+KL+/7fLdmtilqmBfURf1xBMC9zAqWemjNHY=; b=K0UiQ9W9s+sWIRtxnXWqWGcmKQGqL7Q4fRhJtV9aUIRczYoheSVezdBGHDG/y+LBwy aWf0iEUriEU2VKYoDpohyabXMU1cIT9PysCQRMulRMg6Qq+2TlPArbie2RhwN7N/OjPd WGB0HxCvebRCXBLn1bVxNLh7oYABwEvOy4EqGVac/SVvDiq6OQl8O7QDdXO0hS+18Ker e0fu4aUbxK4g9Pg41Gp/tnWWaEBwGpXq1kukXSXtwNwPzdQDYmL+U40XSLFm0+3hxSCG ZbPhTpZMCrJz6KYIKdgjoZSMCk1Rm+J+lsWv6hcwjwxmQpuhsrPoc5KaUFMyVVWN9mPt Kutw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=W2oc5Owk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k14-20020a170902ce0e00b00176c9015627si477189plg.94.2022.10.13.11.16.03; Thu, 13 Oct 2022 11:16:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=W2oc5Owk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231725AbiJMSPa (ORCPT + 99 others); Thu, 13 Oct 2022 14:15:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231622AbiJMSMr (ORCPT ); Thu, 13 Oct 2022 14:12:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66CCA2DCA; Thu, 13 Oct 2022 11:09:23 -0700 (PDT) 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 A269F61A3F; Thu, 13 Oct 2022 18:01:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF02BC433B5; Thu, 13 Oct 2022 18:01:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665684087; bh=Qgu883AQmFoIRpgdwPNsgCs+MfY/HWZXNTNzgBkZpX8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W2oc5OwkxgIXDer7JS6JyRj3kaUPrQ4LbqvAckThNUDeHaZsj4DKWLQieyuTtEC88 2ebsCHVhHnfEDa2N3wMp/hKpjBjVLBucUViGExuSOUcYrdNLzYKS8zRArcQiggoYMd NDM6eFFx9HWOhd6NQai8t0djNXChDB6jiaenbhRg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sherry Yang , Paul Webb , Phillip Goerl , Jack Vogel , Nicky Veitch , Colm Harrington , Ramanan Govindarajan , Sebastian Andrzej Siewior , Dominik Brodowski , Tejun Heo , Sultan Alsawaf , "Jason A. Donenfeld" Subject: [PATCH 6.0 20/34] random: use expired timer rather than wq for mixing fast pool Date: Thu, 13 Oct 2022 19:52:58 +0200 Message-Id: <20221013175147.042953145@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175146.507746257@linuxfoundation.org> References: <20221013175146.507746257@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746597288728247651?= X-GMAIL-MSGID: =?utf-8?q?1746597288728247651?= From: Jason A. Donenfeld commit 748bc4dd9e663f23448d8ad7e58c011a67ea1eca upstream. Previously, the fast pool was dumped into the main pool periodically in the fast pool's hard IRQ handler. This worked fine and there weren't problems with it, until RT came around. Since RT converts spinlocks into sleeping locks, problems cropped up. Rather than switching to raw spinlocks, the RT developers preferred we make the transformation from originally doing: do_some_stuff() spin_lock() do_some_other_stuff() spin_unlock() to doing: do_some_stuff() queue_work_on(some_other_stuff_worker) This is an ordinary pattern done all over the kernel. However, Sherry noticed a 10% performance regression in qperf TCP over a 40gbps InfiniBand card. Quoting her message: > MT27500 Family [ConnectX-3] cards: > Infiniband device 'mlx4_0' port 1 status: > default gid: fe80:0000:0000:0000:0010:e000:0178:9eb1 > base lid: 0x6 > sm lid: 0x1 > state: 4: ACTIVE > phys state: 5: LinkUp > rate: 40 Gb/sec (4X QDR) > link_layer: InfiniBand > > Cards are configured with IP addresses on private subnet for IPoIB > performance testing. > Regression identified in this bug is in TCP latency in this stack as reported > by qperf tcp_lat metric: > > We have one system listen as a qperf server: > [root@yourQperfServer ~]# qperf > > Have the other system connect to qperf server as a client (in this > case, it’s X7 server with Mellanox card): > [root@yourQperfClient ~]# numactl -m0 -N0 qperf 20.20.20.101 -v -uu -ub --time 60 --wait_server 20 -oo msg_size:4K:1024K:*2 tcp_lat Rather than incur the scheduling latency from queue_work_on, we can instead switch to running on the next timer tick, on the same core. This also batches things a bit more -- once per jiffy -- which is okay now that mix_interrupt_randomness() can credit multiple bits at once. Reported-by: Sherry Yang Tested-by: Paul Webb Cc: Sherry Yang Cc: Phillip Goerl Cc: Jack Vogel Cc: Nicky Veitch Cc: Colm Harrington Cc: Ramanan Govindarajan Cc: Sebastian Andrzej Siewior Cc: Dominik Brodowski Cc: Tejun Heo Cc: Sultan Alsawaf Cc: stable@vger.kernel.org Fixes: 58340f8e952b ("random: defer fast pool mixing to worker") Signed-off-by: Jason A. Donenfeld Signed-off-by: Greg Kroah-Hartman --- drivers/char/random.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -923,17 +923,20 @@ struct fast_pool { unsigned long pool[4]; unsigned long last; unsigned int count; - struct work_struct mix; + struct timer_list mix; }; +static void mix_interrupt_randomness(struct timer_list *work); + static DEFINE_PER_CPU(struct fast_pool, irq_randomness) = { #ifdef CONFIG_64BIT #define FASTMIX_PERM SIPHASH_PERMUTATION - .pool = { SIPHASH_CONST_0, SIPHASH_CONST_1, SIPHASH_CONST_2, SIPHASH_CONST_3 } + .pool = { SIPHASH_CONST_0, SIPHASH_CONST_1, SIPHASH_CONST_2, SIPHASH_CONST_3 }, #else #define FASTMIX_PERM HSIPHASH_PERMUTATION - .pool = { HSIPHASH_CONST_0, HSIPHASH_CONST_1, HSIPHASH_CONST_2, HSIPHASH_CONST_3 } + .pool = { HSIPHASH_CONST_0, HSIPHASH_CONST_1, HSIPHASH_CONST_2, HSIPHASH_CONST_3 }, #endif + .mix = __TIMER_INITIALIZER(mix_interrupt_randomness, 0) }; /* @@ -975,7 +978,7 @@ int __cold random_online_cpu(unsigned in } #endif -static void mix_interrupt_randomness(struct work_struct *work) +static void mix_interrupt_randomness(struct timer_list *work) { struct fast_pool *fast_pool = container_of(work, struct fast_pool, mix); /* @@ -1029,10 +1032,11 @@ void add_interrupt_randomness(int irq) if (new_count < 1024 && !time_is_before_jiffies(fast_pool->last + HZ)) return; - if (unlikely(!fast_pool->mix.func)) - INIT_WORK(&fast_pool->mix, mix_interrupt_randomness); fast_pool->count |= MIX_INFLIGHT; - queue_work_on(raw_smp_processor_id(), system_highpri_wq, &fast_pool->mix); + if (!timer_pending(&fast_pool->mix)) { + fast_pool->mix.expires = jiffies; + add_timer_on(&fast_pool->mix, raw_smp_processor_id()); + } } EXPORT_SYMBOL_GPL(add_interrupt_randomness); From patchwork Thu Oct 13 17:52:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2232 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp412518wrs; Thu, 13 Oct 2022 11:10:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4948dGYdayhVtMdgB3lf0dgmBY3gghRurW8xaYPjrqlVBwj4A1PCtkYcSOEIWN3EUnXgXb X-Received: by 2002:a63:c5d:0:b0:460:17cc:73a6 with SMTP id 29-20020a630c5d000000b0046017cc73a6mr992613pgm.332.1665684652221; Thu, 13 Oct 2022 11:10:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684652; cv=none; d=google.com; s=arc-20160816; b=tWfwm7GUmD7XwofM/okwNaiiATAsGvLYeljxEU/zkGJLDVnySMXd5ekVwC4A4MdseN ZNpPOyeIIY23UC0mGelTrQlkExIV7x38WCW0x3MngV0Cs767pmv4Kf5bQANah3WQTPE7 X+4kcMKauInuwErvPsTQSWzBUL7a0Qc7UvTPIa4BatPDdGAunYj04/GA84EWWdmZ8GX6 gbkSP15SYkE4jEMpWKxQ0kH3p25Oxp5xrRbGY4ERKiKdV4LvEuSUjtSG1rR0QA+z0Ddr WRnPO2UxIpd6cls6m7l8HLhddPVezGMwLtPss+BqFf+9/l+TVfYBpIYD7u3kti8YCc2B /2+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=omKlhbk9CSOQdNNWLr6ptpJ5xIvt1ml7n0StJ8XC+N0=; b=SIQv8pzjMTzskIEhnvV1ZHObAcdofZhRSGvuHRRFO7pt658ynTc+SnOcqmEfzwmKkJ qPwq9m7sD9n4eAA04s/fNO9yAn6XdacwHMpq9soKCDRThcgkqast76luVXW9nrL3qQwd 9Mmw7Y6UH5yRFQk23Ob44uxEINBTDldrBK2jeF70exBItsQ9jRP8inlHrbCFFaWHKV4e qizTZrVneObCF/Zp3cL5OAsoIMLM2PZARsGsEDKcU44mOWsS5s8cN2Jm7pIwcFQaHNV/ lUHFnoQHDJ83K6Gxy9oOORcnWdcyT89TxHxgvxiVWYpSghQQhX6K/XRXT4NCVV+uVCVV Ojxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OfHkS7CK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mq18-20020a17090b381200b0020d8df0ac89si6803414pjb.122.2022.10.13.11.10.39; Thu, 13 Oct 2022 11:10:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OfHkS7CK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231497AbiJMSKe (ORCPT + 99 others); Thu, 13 Oct 2022 14:10:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231401AbiJMSJx (ORCPT ); Thu, 13 Oct 2022 14:09:53 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59EC1169CEE; Thu, 13 Oct 2022 11:07:32 -0700 (PDT) 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 CA8DE61A43; Thu, 13 Oct 2022 18:01:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8987C433C1; Thu, 13 Oct 2022 18:01:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665684090; bh=yO7jB7qJ3SzvXbCw+6Kqc+Vb9MrWMZHZx+fu+glnvtQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OfHkS7CKbQBrvEwGykyecb9oLe7yLh8w26y95OjtWnKjZpvXmBqtYS/OVVGOHhx17 MTLCjfAXzHEDoXJdi6gEvknz2c3MQ3H1+HSaUeSvqR7Udpypp+2Vh3va48ltYN22ip +cjoq0nyl0vp5w4deDEvRFUAjkA9EW9STkabe+3g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Soenke Huster , Kees Cook , Johannes Berg Subject: [PATCH 6.0 21/34] wifi: cfg80211: fix u8 overflow in cfg80211_update_notlisted_nontrans() Date: Thu, 13 Oct 2022 19:52:59 +0200 Message-Id: <20221013175147.067414219@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175146.507746257@linuxfoundation.org> References: <20221013175146.507746257@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746596950197178278?= X-GMAIL-MSGID: =?utf-8?q?1746596950197178278?= From: Johannes Berg commit aebe9f4639b13a1f4e9a6b42cdd2e38c617b442d upstream. In the copy code of the elements, we do the following calculation to reach the end of the MBSSID element: /* copy the IEs after MBSSID */ cpy_len = mbssid[1] + 2; This looks fine, however, cpy_len is a u8, the same as mbssid[1], so the addition of two can overflow. In this case the subsequent memcpy() will overflow the allocated buffer, since it copies 256 bytes too much due to the way the allocation and memcpy() sizes are calculated. Fix this by using size_t for the cpy_len variable. This fixes CVE-2022-41674. Reported-by: Soenke Huster Tested-by: Soenke Huster Fixes: 0b8fb8235be8 ("cfg80211: Parsing of Multiple BSSID information in scanning") Reviewed-by: Kees Cook Signed-off-by: Johannes Berg Signed-off-by: Greg Kroah-Hartman --- net/wireless/scan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/wireless/scan.c +++ b/net/wireless/scan.c @@ -2279,7 +2279,7 @@ cfg80211_update_notlisted_nontrans(struc size_t new_ie_len; struct cfg80211_bss_ies *new_ies; const struct cfg80211_bss_ies *old; - u8 cpy_len; + size_t cpy_len; lockdep_assert_held(&wiphy_to_rdev(wiphy)->bss_lock); From patchwork Thu Oct 13 17:53:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2236 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp412721wrs; Thu, 13 Oct 2022 11:11:27 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7WeXuhE4nECubRjQ8Dpe3dpTpga2DkY5HUif1ws5kJaRzr7AGzAKsJeRP01NdTGzRSMGwZ X-Received: by 2002:a65:48cc:0:b0:45f:795:c374 with SMTP id o12-20020a6548cc000000b0045f0795c374mr963852pgs.107.1665684687178; Thu, 13 Oct 2022 11:11:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684687; cv=none; d=google.com; s=arc-20160816; b=yEZUTdCVFeShWTsrPU13ixa1KLoGzO21n2Rft7d5FjkbQEb/XSEliZP34I1L/8Ghl/ Kp8hx1tyezoUYQn0I13xYwYME9z2IOXevk67Z/Donm3QrjraAzs+cPGtG7+PiWutlgSG A3bnhy9tuX1C3+xMuU2djcCKDIq9m82jwYh/wx5Cf0DhM79A1wd0fhy0sbrL4/RNjntm ZjeVQ1QFNwNbFXL9Nd/7NvgTh0LVFJA//K4Zug4wAxnIQ/ibxMrjJvHXEL/5BeD2PF54 TtmFwrI0hedp/8YRGXhf2f2b5wvw7w9SHhVN68GeZYEr8ufS4eXgUPH7alH4rL3ydFv7 tepg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YJIg0gTZNVbopiUkXpogYfFM7xDZJVVqzq5UKrp2Cko=; b=QmjYOxWEkL1QnUZjBpWsdc/SVcuzM4HCU9o1nalAxi741rxk5w/u6aaFkieOhu+IOo eyjPx5aD4ThCRwtnyVXwSyncpK5cPmDLN9PBYukxM1PxNiBy3ePyoG6b4Q902VaMa6QC fxPYPEqqvt4REOyClU5OvHXaNgxIUsbKWMrT02eBK+f1lNa8ARqZeTv/nHXtIVEGlrkW SbpMHWZ2q9MF4I2Uk2DqscnhXNk8UZ8M9PcDg5FSIs/ls5axIHOaWSr+/LB7dBq2Z0m4 F2ds8N/hrXtdMT6zXJybTET5kqwkqNB37IGGmqSydV0rCOLA6y3xXji9cxw19t7XzchG vuEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HD1CrisC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id na12-20020a17090b4c0c00b001fdd6d07d39si7062117pjb.8.2022.10.13.11.11.13; Thu, 13 Oct 2022 11:11:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HD1CrisC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231362AbiJMSKr (ORCPT + 99 others); Thu, 13 Oct 2022 14:10:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231443AbiJMSKJ (ORCPT ); Thu, 13 Oct 2022 14:10:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F4E4175795; Thu, 13 Oct 2022 11:07:34 -0700 (PDT) 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 B7B5E61A47; Thu, 13 Oct 2022 18:01:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A56BCC433D6; Thu, 13 Oct 2022 18:01:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665684093; bh=ABVtqPRgxmZIFlVSQtFaRqnHz1dauK3i7uCum+wmrFc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HD1CrisClRoFpKLiQMJhtk58tAiwL+ZkZsQsG9RLGZjHYm+uKuT/fJw8kJ6js4kdc EUFnz8pGznCEmlvZUzQ/1pM/UGBkNJg6AxFXW1BE8C3Z8npcPaCIsaWx0WoY1Xor1j Mj0aGm8JCt+BaKazkAOZHxqRnniW0/Fy/TbP9OIw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kees Cook , Johannes Berg Subject: [PATCH 6.0 22/34] wifi: cfg80211/mac80211: reject bad MBSSID elements Date: Thu, 13 Oct 2022 19:53:00 +0200 Message-Id: <20221013175147.094790325@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175146.507746257@linuxfoundation.org> References: <20221013175146.507746257@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746596986199291072?= X-GMAIL-MSGID: =?utf-8?q?1746596986199291072?= From: Johannes Berg commit 8f033d2becc24aa6bfd2a5c104407963560caabc upstream. Per spec, the maximum value for the MaxBSSID ('n') indicator is 8, and the minimum is 1 since a multiple BSSID set with just one BSSID doesn't make sense (the # of BSSIDs is limited by 2^n). Limit this in the parsing in both cfg80211 and mac80211, rejecting any elements with an invalid value. This fixes potentially bad shifts in the processing of these inside the cfg80211_gen_new_bssid() function later. I found this during the investigation of CVE-2022-41674 fixed by the previous patch. Fixes: 0b8fb8235be8 ("cfg80211: Parsing of Multiple BSSID information in scanning") Fixes: 78ac51f81532 ("mac80211: support multi-bssid") Reviewed-by: Kees Cook Signed-off-by: Johannes Berg Signed-off-by: Greg Kroah-Hartman --- net/mac80211/util.c | 2 ++ net/wireless/scan.c | 2 ++ 2 files changed, 4 insertions(+) --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -1442,6 +1442,8 @@ static size_t ieee802_11_find_bssid_prof for_each_element_id(elem, WLAN_EID_MULTIPLE_BSSID, start, len) { if (elem->datalen < 2) continue; + if (elem->data[0] < 1 || elem->data[0] > 8) + continue; for_each_element(sub, elem->data + 1, elem->datalen - 1) { u8 new_bssid[ETH_ALEN]; --- a/net/wireless/scan.c +++ b/net/wireless/scan.c @@ -2143,6 +2143,8 @@ static void cfg80211_parse_mbssid_data(s for_each_element_id(elem, WLAN_EID_MULTIPLE_BSSID, ie, ielen) { if (elem->datalen < 4) continue; + if (elem->data[0] < 1 || (int)elem->data[0] > 8) + continue; for_each_element(sub, elem->data + 1, elem->datalen - 1) { u8 profile_len; From patchwork Thu Oct 13 17:53:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2298 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp428335wrs; Thu, 13 Oct 2022 11:51:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM56rt48iHvzHrXC3DysX14qgMr6Vxmk4OnvJKsRIgfSWM5BxeUrKHjGoMugYHyddKhJBqCG X-Received: by 2002:a17:903:1053:b0:185:37cb:da04 with SMTP id f19-20020a170903105300b0018537cbda04mr1310076plc.108.1665687101582; Thu, 13 Oct 2022 11:51:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665687101; cv=none; d=google.com; s=arc-20160816; b=ySxQymeflTYs4Nx2qSTqsDYxXTHUJudXCr3CZ7a6/8t31P5MRC0Lqwd6M0MHVAvk+V bvgK0LRXMzkduxfeGKlbp9bpV0VvjCSS7S615WnZhVmK46nDynHvhtLKZ5pD1MotV2SH 0wGsZMqt9lw0NOK+beywzUeFY+jvz/cekmw/TpFiEg3g++EZk9YnFcycOJFhsiG2SNoZ 79SzNebn+013z0GBGM0rVtGH/UNe/kFHrTsgUWmCtGtZ3F0f+EpyTm+1DcpF76TeBm9h 1LZoouiwDow/FhCD9JZE72cNQLv45fYg2gT7UZolWYgXLpF7EMsUGcS0T37PzzWZBGxx rhLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6iZ8nODMbAT3X3Z8eeVKhhNUepqQlPk45jLrsRhR0xM=; b=wPSh+nIkYuKG8AdP7rLieSWrYfoRWuq/VV6bbPW+q6Lcs3iO+Zx+IlGPr7LZsPOM6l 1I5lzd6l5g6ixeZP/Mf3u7VjeeI03C7deh24Vhv/DjJLpF8A0PZoL2g/wk6JTTJ8mnsG kMAyVdziKih+7hNxGUBUmUJK+4u/f84j1XN65mj3w95MtokvHEMpveY621oMytcKu73c 9piNVC7o8RPTnf+CzQlwi/rf1Y0LxLSHgMxRKEhsvx1vpfmIq0ymyx62AmCDTJmtaVLp ZD3lZnqT3OwX45kzjb+4eSF64ENTyv1imqCBu4r0FGTwf3ysdykU03WCRX4EIosJJeYj 6siw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Hy2H85DM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h8-20020a170902f54800b0017693dbd8cdsi436349plf.551.2022.10.13.11.51.29; Thu, 13 Oct 2022 11:51:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Hy2H85DM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231961AbiJMSd5 (ORCPT + 99 others); Thu, 13 Oct 2022 14:33:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229649AbiJMSdV (ORCPT ); Thu, 13 Oct 2022 14:33:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CBA517FD5F; Thu, 13 Oct 2022 11:29:21 -0700 (PDT) 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 A026761A51; Thu, 13 Oct 2022 18:01:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AFEA8C433D7; Thu, 13 Oct 2022 18:01:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665684096; bh=Ajm14oqIOS8bNZ+O27M/3u4Vz08BqrePq7KdTFY7v80=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hy2H85DMOI2HJ2ZZn20GJS61mnFdnhcLrmxKapiO0JL5uVO8wO+v8VfXBBKYmgUh9 HByX3njDxrMwhaCjbGnhbJ+RgOLOOz9KzXw14wI+IBf8fWkASFdoG2KJwi1vR0o+GM WTaHk6mMU3/Ew4ExqI12h3cHrV2VLJIyjAM0bUYc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ilan Peer , Kees Cook , Johannes Berg Subject: [PATCH 6.0 23/34] wifi: mac80211: fix MBSSID parsing use-after-free Date: Thu, 13 Oct 2022 19:53:01 +0200 Message-Id: <20221013175147.118965481@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175146.507746257@linuxfoundation.org> References: <20221013175146.507746257@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746599518251198226?= X-GMAIL-MSGID: =?utf-8?q?1746599518251198226?= From: Johannes Berg commit ff05d4b45dd89b922578dac497dcabf57cf771c6 upstream. When we parse a multi-BSSID element, we might point some element pointers into the allocated nontransmitted_profile. However, we free this before returning, causing UAF when the relevant pointers in the parsed elements are accessed. Fix this by not allocating the scratch buffer separately but as part of the returned structure instead, that way, there are no lifetime issues with it. The scratch buffer introduction as part of the returned data here is taken from MLO feature work done by Ilan. This fixes CVE-2022-42719. Fixes: 5023b14cf4df ("mac80211: support profile split between elements") Co-developed-by: Ilan Peer Signed-off-by: Ilan Peer Reviewed-by: Kees Cook Signed-off-by: Johannes Berg Signed-off-by: Greg Kroah-Hartman --- net/mac80211/ieee80211_i.h | 8 ++++++++ net/mac80211/util.c | 28 ++++++++++++++-------------- 2 files changed, 22 insertions(+), 14 deletions(-) --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -1704,6 +1704,14 @@ struct ieee802_11_elems { /* whether a parse error occurred while retrieving these elements */ bool parse_error; + + /* + * scratch buffer that can be used for various element parsing related + * tasks, e.g., element de-fragmentation etc. + */ + size_t scratch_len; + u8 *scratch_pos; + u8 scratch[]; }; static inline struct ieee80211_local *hw_to_local( --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -1503,24 +1503,26 @@ ieee802_11_parse_elems_full(struct ieee8 const struct element *non_inherit = NULL; u8 *nontransmitted_profile; int nontransmitted_profile_len = 0; + size_t scratch_len = params->len; - elems = kzalloc(sizeof(*elems), GFP_ATOMIC); + elems = kzalloc(sizeof(*elems) + scratch_len, GFP_ATOMIC); if (!elems) return NULL; elems->ie_start = params->start; elems->total_len = params->len; + elems->scratch_len = scratch_len; + elems->scratch_pos = elems->scratch; - nontransmitted_profile = kmalloc(params->len, GFP_ATOMIC); - if (nontransmitted_profile) { - nontransmitted_profile_len = - ieee802_11_find_bssid_profile(params->start, params->len, - elems, params->bss, - nontransmitted_profile); - non_inherit = - cfg80211_find_ext_elem(WLAN_EID_EXT_NON_INHERITANCE, - nontransmitted_profile, - nontransmitted_profile_len); - } + nontransmitted_profile = elems->scratch_pos; + nontransmitted_profile_len = + ieee802_11_find_bssid_profile(params->start, params->len, + elems, params->bss, + nontransmitted_profile); + elems->scratch_pos += nontransmitted_profile_len; + elems->scratch_len -= nontransmitted_profile_len; + non_inherit = cfg80211_find_ext_elem(WLAN_EID_EXT_NON_INHERITANCE, + nontransmitted_profile, + nontransmitted_profile_len); elems->crc = _ieee802_11_parse_elems_full(params, elems, non_inherit); @@ -1554,8 +1556,6 @@ ieee802_11_parse_elems_full(struct ieee8 offsetofend(struct ieee80211_bssid_index, dtim_count)) elems->dtim_count = elems->bssid_index->dtim_count; - kfree(nontransmitted_profile); - return elems; } From patchwork Thu Oct 13 17:53:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2261 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp414584wrs; Thu, 13 Oct 2022 11:15:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6QQrz8SVYzS8vtugikXd7aTqENh/BKUr4yyrq9VSYa0Ae2dulos5z2GMQ4ze9DxB8jP3K5 X-Received: by 2002:a05:6a02:202:b0:42b:d711:f27c with SMTP id bh2-20020a056a02020200b0042bd711f27cmr1017036pgb.246.1665684944836; Thu, 13 Oct 2022 11:15:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684944; cv=none; d=google.com; s=arc-20160816; b=PpFP1TnThtYta+DrBbPhT4lLr63LxwrG3PstEGIDtbdkdxvmVqvYifn2rm0X//M8Sy rpECuZb76wIMqqaGf747PE7lmV5vI3p9W6GcSYInuBJcU78AYv2V7Z3UYh+RdnXZpO9v KpNSkFyNqJnT24OgnrVE8ZxbJqNODBpHawH2le1C0GE9vkDCFuG4Ck5Af4Qzp0DrEsnf jthy2P+41SCVJAOlXpppSe5y2a8dfm9qShXLJlefctQgs7lMAmLm47Ta1lzIRupeEOa4 ltrgSZcCo99DcZjG3PP2wtrco9JWXm1epR+iq95ZdYcf5U7nMqml77QsFvlKImcQnJsH Pr7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+sj+1pjDe2qwAtycRwj/aoNEuIQNSsbr+6RKm1o559g=; b=PwHAZgfeLXs7Vvk/1mYTkGdnyGQ/HjSXxpWK8iZE7/41v9yMLUDmO4h/27NCc3Y0HC ArJ0szsuovkkZVHNI/zH+Ut4k8mYfWPRqVWWtyV+qMNe2AxhRxqF9J6Ya2EUTwCDDFu2 RDWv0EEtjqml9N+23fSd3Hu6VS/QwUnzdIS1kMW5ITejp+YjsGQ6CRk2kPxAEjSmA/DH PA8vo1stRlmdkc1SZIUXDmdPyMe/W3UxGcWzdDV+XmtWElRuVsUDBUGpypH5oZXJGcmi ayKHAgtTkcFoovtNAamCuR/HCvDtv7kYmn+Lhj467ZdczovnWZmnL4qomVW1l2zxid49 ZALg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Zg/0A5eQ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k29-20020a635a5d000000b004597ddac21csi119444pgm.80.2022.10.13.11.15.27; Thu, 13 Oct 2022 11:15:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Zg/0A5eQ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231352AbiJMSPH (ORCPT + 99 others); Thu, 13 Oct 2022 14:15:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231319AbiJMSL4 (ORCPT ); Thu, 13 Oct 2022 14:11:56 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDB1215625A; Thu, 13 Oct 2022 11:08:45 -0700 (PDT) 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 07606B8208B; Thu, 13 Oct 2022 18:01:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68EA4C433C1; Thu, 13 Oct 2022 18:01:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665684098; bh=7ADSkhJgMzgbvEfxkGhKSmMII+dlmQ0WYUlz4phgh+4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zg/0A5eQm5s2wmpJv7V7MapZZbEZxrWWwqZotrz1s+xUlwUcrLeVcXVr2Sqw+5l25 nGbtvcMTiiKAyjrq2gr4kHbPh2ywKtRDfQPNFwVLzKMChyWuITx93xtVAgYl7hsLZw x8osLPwJ0SGtrd+GluwGMuiwDwnImGCqpVePPctU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Soenke Huster , Johannes Berg Subject: [PATCH 6.0 24/34] wifi: cfg80211: ensure length byte is present before access Date: Thu, 13 Oct 2022 19:53:02 +0200 Message-Id: <20221013175147.143750056@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175146.507746257@linuxfoundation.org> References: <20221013175146.507746257@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746597256578098001?= X-GMAIL-MSGID: =?utf-8?q?1746597256578098001?= From: Johannes Berg commit 567e14e39e8f8c6997a1378bc3be615afca86063 upstream. When iterating the elements here, ensure the length byte is present before checking it to see if the entire element will fit into the buffer. Longer term, we should rewrite this code using the type-safe element iteration macros that check all of this. Fixes: 0b8fb8235be8 ("cfg80211: Parsing of Multiple BSSID information in scanning") Reported-by: Soenke Huster Signed-off-by: Johannes Berg Signed-off-by: Greg Kroah-Hartman --- net/wireless/scan.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/net/wireless/scan.c +++ b/net/wireless/scan.c @@ -304,7 +304,8 @@ static size_t cfg80211_gen_new_ie(const tmp_old = cfg80211_find_ie(WLAN_EID_SSID, ie, ielen); tmp_old = (tmp_old) ? tmp_old + tmp_old[1] + 2 : ie; - while (tmp_old + tmp_old[1] + 2 - ie <= ielen) { + while (tmp_old + 2 - ie <= ielen && + tmp_old + tmp_old[1] + 2 - ie <= ielen) { if (tmp_old[0] == 0) { tmp_old++; continue; @@ -364,7 +365,8 @@ static size_t cfg80211_gen_new_ie(const * copied to new ie, skip ssid, capability, bssid-index ie */ tmp_new = sub_copy; - while (tmp_new + tmp_new[1] + 2 - sub_copy <= subie_len) { + while (tmp_new + 2 - sub_copy <= subie_len && + tmp_new + tmp_new[1] + 2 - sub_copy <= subie_len) { if (!(tmp_new[0] == WLAN_EID_NON_TX_BSSID_CAP || tmp_new[0] == WLAN_EID_SSID)) { memcpy(pos, tmp_new, tmp_new[1] + 2); From patchwork Thu Oct 13 17:53:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2263 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp414727wrs; Thu, 13 Oct 2022 11:16:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4ia8cgcPeB5vXhXOiSgPhC0k9iUP2eSTaf7WQqA2/xJTR76nEjiIlT9upyaMAiDtgse0+W X-Received: by 2002:a17:902:ce08:b0:179:ed2b:8cd8 with SMTP id k8-20020a170902ce0800b00179ed2b8cd8mr1223022plg.23.1665684968918; Thu, 13 Oct 2022 11:16:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684968; cv=none; d=google.com; s=arc-20160816; b=VQwJIzkwCf5SMMUyaW30NypR8Dh48hdDOSQxE6HUsvQBoy7nZoPYveP3U/Nfu800Uj C9nidmfPLyEu7YJvBuu+PB5TlAxO6PmzfgDcZd/AuCgY4H/3cxHaVthhcMBMrkOCkDoC G/60LmE166pYUffTRSk0S5DDgYvszYi32T5Nu2ddzg1WCTEo4U5R34IKxD5SyyGMkXoE eYIRQ182IDDOi4V5Ec11JhFHgflZk8T3OCwykxTAbnM3Mkl6MN9rOFuoXo1p5RnTsnAI fwH5FSxRadK+Wo1pA/e8mbFEXdkXQPstSxNj9wQxxxbwotkxi/TlcvyBNiuRw0HfT77g 7ErQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6qtI4ewGAghKNg6M5lurU+D80RYsSRe1CLfXYibzRkM=; b=o/Oij5EErXP3+lq/k9foa3gi0CUoZWY4qDArIwOa1OHnvB1oUVkRV4h0CAmXXf7Z7z 6287QuqHPQRABIxYkvt1Sp+2xkfhJsO+f8+fDCtyZEFTBeDjFB4Vn07trtlpxU7I99+k lvYy5vv2apYPfq9Vte85i+jFOrLB/z4WnfvZ2OQZPZa8e5og2JU8NXAsgwrT0UDfS9gV fjBypy+uPyWdPKLDMrFmUj72iCEf7mty4mZg3v/1eL51+EA47OP2FLT0MYYhudGUhu9J oYnUoUhtYZJ9NBhoe9n6Nx0lQHhcg3SY+ehq6gyuTtpHSl5f4MDh2l0TXwRymEvl5hnT hHRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MD62TgRc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n3-20020a632703000000b0043ac3ec9d9csi28531pgn.758.2022.10.13.11.15.57; Thu, 13 Oct 2022 11:16:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MD62TgRc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231314AbiJMSPM (ORCPT + 99 others); Thu, 13 Oct 2022 14:15:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231151AbiJMSMF (ORCPT ); Thu, 13 Oct 2022 14:12:05 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9259C157F7A; Thu, 13 Oct 2022 11:08:47 -0700 (PDT) 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 C8CFCB820BC; Thu, 13 Oct 2022 18:01:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F80AC433C1; Thu, 13 Oct 2022 18:01:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665684101; bh=GLtAHWxXyJx3NijczFxtqRQxyiQ/itl74fwTwCHfKGk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MD62TgRcTsG6BVNN81KJ/OttPjXBT6Pij9IMBfMCIwRuHtGk9vt6AEhFvgtEcfZND XudcJVj9kRueadf5rXlipGRSafmZy5ky6idmLGDnVVsZiQFXeONBkRWQH24ZW4a+A7 NyKlz8tHZqQEWBMrfZn+f/HB2/RUGM7NpvPSvwo8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?utf-8?q?S=C3=B6nke_Huster?= , Johannes Berg Subject: [PATCH 6.0 25/34] wifi: cfg80211: fix BSS refcounting bugs Date: Thu, 13 Oct 2022 19:53:03 +0200 Message-Id: <20221013175147.168042993@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175146.507746257@linuxfoundation.org> References: <20221013175146.507746257@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746597281983771573?= X-GMAIL-MSGID: =?utf-8?q?1746597281983771573?= From: Johannes Berg commit 0b7808818cb9df6680f98996b8e9a439fa7bcc2f upstream. There are multiple refcounting bugs related to multi-BSSID: - In bss_ref_get(), if the BSS has a hidden_beacon_bss, then the bss pointer is overwritten before checking for the transmitted BSS, which is clearly wrong. Fix this by using the bss_from_pub() macro. - In cfg80211_bss_update() we copy the transmitted_bss pointer from tmp into new, but then if we release new, we'll unref it erroneously. We already set the pointer and ref it, but need to NULL it since it was copied from the tmp data. - In cfg80211_inform_single_bss_data(), if adding to the non- transmitted list fails, we unlink the BSS and yet still we return it, but this results in returning an entry without a reference. We shouldn't return it anyway if it was broken enough to not get added there. This fixes CVE-2022-42720. Reported-by: Sönke Huster Tested-by: Sönke Huster Fixes: a3584f56de1c ("cfg80211: Properly track transmitting and non-transmitting BSS") Signed-off-by: Johannes Berg Signed-off-by: Greg Kroah-Hartman --- net/wireless/scan.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) --- a/net/wireless/scan.c +++ b/net/wireless/scan.c @@ -143,18 +143,12 @@ static inline void bss_ref_get(struct cf lockdep_assert_held(&rdev->bss_lock); bss->refcount++; - if (bss->pub.hidden_beacon_bss) { - bss = container_of(bss->pub.hidden_beacon_bss, - struct cfg80211_internal_bss, - pub); - bss->refcount++; - } - if (bss->pub.transmitted_bss) { - bss = container_of(bss->pub.transmitted_bss, - struct cfg80211_internal_bss, - pub); - bss->refcount++; - } + + if (bss->pub.hidden_beacon_bss) + bss_from_pub(bss->pub.hidden_beacon_bss)->refcount++; + + if (bss->pub.transmitted_bss) + bss_from_pub(bss->pub.transmitted_bss)->refcount++; } static inline void bss_ref_put(struct cfg80211_registered_device *rdev, @@ -1741,6 +1735,8 @@ cfg80211_bss_update(struct cfg80211_regi new->refcount = 1; INIT_LIST_HEAD(&new->hidden_list); INIT_LIST_HEAD(&new->pub.nontrans_list); + /* we'll set this later if it was non-NULL */ + new->pub.transmitted_bss = NULL; if (rcu_access_pointer(tmp->pub.proberesp_ies)) { hidden = rb_find_bss(rdev, tmp, BSS_CMP_HIDE_ZLEN); @@ -2023,10 +2019,15 @@ cfg80211_inform_single_bss_data(struct w spin_lock_bh(&rdev->bss_lock); if (cfg80211_add_nontrans_list(non_tx_data->tx_bss, &res->pub)) { - if (__cfg80211_unlink_bss(rdev, res)) + if (__cfg80211_unlink_bss(rdev, res)) { rdev->bss_generation++; + res = NULL; + } } spin_unlock_bh(&rdev->bss_lock); + + if (!res) + return NULL; } trace_cfg80211_return_bss(&res->pub); From patchwork Thu Oct 13 17:53:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2234 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp412622wrs; Thu, 13 Oct 2022 11:11:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5/MNzIw/vBjyygiUypvGYb2En5kbdNbDd5oruOtSB3h4kF79ZLDuLRRBXdxi1IhnU0EmyC X-Received: by 2002:a17:90b:3d8:b0:20a:8e90:8e8c with SMTP id go24-20020a17090b03d800b0020a8e908e8cmr1114061pjb.138.1665684668689; Thu, 13 Oct 2022 11:11:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684668; cv=none; d=google.com; s=arc-20160816; b=fPtJ27lCIe3TTDioOQZNaLxLkoGeyonIHphjONlGEmYsiYzy6SaHp0bFE2u45zV0Y6 eJELbf/zx00rUAXp08ndj/5/pC5lfXsuynLqjz54nxhai7CUgUwoJkpTNSLCNh1zvXfm R0COYBYz5ex9DQSymUov6hsBlb3v7MGPTFUb1eo8Sybd8rkziDLnN8bzxHfV2jz4ANQV m7+x8JBdXv89lo/Ho3qvoqpj9tjCgHUwG3QWv+a5C6IacZhSBENROWVPdRYbUpkBNXyA C+q/xF0JI6+42ZcvrLeiZ5HwXW+Po0DJ6CXRJ2L/d6BvVfOCXEPxr5/3gURnAGZ8B4IQ S9Cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dv3Kk0DV/VYeKP/SkwjmD9vtZ6ZgGQfYtEu9WsCBeMk=; b=t5ERMTTSBpM0PPK9hqsJE7oYN+Hw9X8woMbto3nFxtijbkj5xHCEus1unm/1mUPMq2 lBgr68LMQT9/QNfmeErnOAwTNESyvYtJP4dXE0gJlaXrosLoimvGL+98+Jwou5eN2N97 i78oiGY1V6ApUvwhN9GFP6UsePMc92FHFRPpXzTdzUVbjsjfhDmPtVJQvlYx7UNvEU4T X/QcfgdKgLUWfcx14/1KF11oGVA7XvpQpkGLKktHFsiOxSajS6tfmBeF80x2nNj6f3YO Xf80KcyZDsEk2uMGrrCkPN/rsHYbUPy/5tGfw7Xdc8ew1A3gxFIetbGbPKx+s4WTwsFh Yl2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aLTonID1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x185-20020a6386c2000000b0043961d07372si37844pgd.585.2022.10.13.11.10.55; Thu, 13 Oct 2022 11:11:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aLTonID1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231209AbiJMSKo (ORCPT + 99 others); Thu, 13 Oct 2022 14:10:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231446AbiJMSKJ (ORCPT ); Thu, 13 Oct 2022 14:10:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E393B15625F; Thu, 13 Oct 2022 11:07:34 -0700 (PDT) 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 EABC86192E; Thu, 13 Oct 2022 18:01:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03451C433D7; Thu, 13 Oct 2022 18:01:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665684104; bh=SsMZnV5IRg+VfGQh81XQuLjXEJU1N9vepNOsf1+r8VU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aLTonID16sFXFtCymOfbq00eVFbCSXG9GqGBc8P0DmoqgYo0qPc8kFVgNUse+LTrb bEEqmEYPzLBDkYL7yGCvQs3GwrkVYETh2AFH2bOZKdFywcfDlDeeIMV80w/ymgHHlb S3uaz0CEhaBKJ26gc6PplqiINoic819laNuMvu/w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?utf-8?q?S=C3=B6nke_Huster?= , Johannes Berg Subject: [PATCH 6.0 26/34] wifi: cfg80211: avoid nontransmitted BSS list corruption Date: Thu, 13 Oct 2022 19:53:04 +0200 Message-Id: <20221013175147.193301522@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175146.507746257@linuxfoundation.org> References: <20221013175146.507746257@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746596967053149954?= X-GMAIL-MSGID: =?utf-8?q?1746596967053149954?= From: Johannes Berg commit bcca852027e5878aec911a347407ecc88d6fff7f upstream. If a non-transmitted BSS shares enough information (both SSID and BSSID!) with another non-transmitted BSS of a different AP, then we can find and update it, and then try to add it to the non-transmitted BSS list. We do a search for it on the transmitted BSS, but if it's not there (but belongs to another transmitted BSS), the list gets corrupted. Since this is an erroneous situation, simply fail the list insertion in this case and free the non-transmitted BSS. This fixes CVE-2022-42721. Reported-by: Sönke Huster Tested-by: Sönke Huster Fixes: 0b8fb8235be8 ("cfg80211: Parsing of Multiple BSSID information in scanning") Signed-off-by: Johannes Berg Signed-off-by: Greg Kroah-Hartman --- net/wireless/scan.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- a/net/wireless/scan.c +++ b/net/wireless/scan.c @@ -423,6 +423,15 @@ cfg80211_add_nontrans_list(struct cfg802 rcu_read_unlock(); + /* + * This is a bit weird - it's not on the list, but already on another + * one! The only way that could happen is if there's some BSSID/SSID + * shared by multiple APs in their multi-BSSID profiles, potentially + * with hidden SSID mixed in ... ignore it. + */ + if (!list_empty(&nontrans_bss->nontrans_list)) + return -EINVAL; + /* add to the list */ list_add_tail(&nontrans_bss->nontrans_list, &trans_bss->nontrans_list); return 0; From patchwork Thu Oct 13 17:53:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2233 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp412563wrs; Thu, 13 Oct 2022 11:11:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5inxWERj9aZJXj5wdP/+oGQ27TKedqkxAiahJv2WzaR9K1b4cURaG5oEhC11JaWbCKmXR6 X-Received: by 2002:a63:1c47:0:b0:44c:2476:12ff with SMTP id c7-20020a631c47000000b0044c247612ffmr1053946pgm.50.1665684659889; Thu, 13 Oct 2022 11:10:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684659; cv=none; d=google.com; s=arc-20160816; b=B6AftvhJlgm4SKCrgB5wl9KoUe7aIiCq0XwUSM7AhzDPgrhcMe+uNfkwI6qE85akyX dGsR1WhErwjBq0qwZV+utjH4UtKJC1yxJgC4O8gEjuCEJzCtEjphY94UCWfNnmYLNJBo ZEIYwmebuwSXE4GgAQI7lqXCAgpfxRmW08eyUWFFvRJ0hKM47EMghggVOZpeJ16yIzEH vdHCHQCWlpwEVPLa2r/3k6v7S7Sj6aWAL5NF6ee//WAYW/mSrFruh09d1sDx599+aaF9 OwlG/G7OOeY/96r4OTQARJ6MbIdFw/ktGaoymOGp0Jl2n0SCDGC1pVDtoqnPSlZpnae/ QQhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7h7yQGiFQYJgDf3aJgGMbshNi+0f74pGBK9Hn7HXU8g=; b=F1EW6W5Jk6WLDQ61CrBEaI6K+jDFtBzecGpg14N85qXMGeOwK5ELKzFpcIh7LNC7Ie j8xCZR5X/Fk0mDFTY8/bC748Trfn37BYHZgdfXQlRmNKCQ/ZP+kXYDuC4ubui5I/nYSr CQ1pLp9i8APjiIqnzgGrLYVGTdGiKc2JGYDe8JzZ038ehqXBDg6kPd3tw5mjkgnx4FkS 4Tz9M1RkSyBOCcn3hTfpViEA6AKyN6HJp6h2nnKZ+d4FCdOIklZHmSPB8rPXK/ZWXpPm slHKFXKpcPSPn6j/lex4VxhVWPlhM0lW8xUsU2jKXzeMF0jmefnGk/4+tquIlATHlViR Ioqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pYxm0nnD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pt6-20020a17090b3d0600b0020a47a4c951si157733pjb.147.2022.10.13.11.10.46; Thu, 13 Oct 2022 11:10:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pYxm0nnD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231130AbiJMSKi (ORCPT + 99 others); Thu, 13 Oct 2022 14:10:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231182AbiJMSKE (ORCPT ); Thu, 13 Oct 2022 14:10:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D608DB854; Thu, 13 Oct 2022 11:07:36 -0700 (PDT) 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 D2BFD6194B; Thu, 13 Oct 2022 18:01:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1C2EC433D7; Thu, 13 Oct 2022 18:01:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665684107; bh=GRz9I5d9zHaKVHe3ziSUKmLW6FeLmSChjvrYLTtRYLA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pYxm0nnDyflsJi6blqVNks5K3D0GVBOobuwViEyYsF05gnbX7yNQIltdhcz24mMma t7gh83ZYKh40AN0b1ExbydJ4uE183m8VsGkfoU7TygWWarAkSl7tgfCBC34tso+Qmh eKH0wSH42MqM4HVgLKs4ZLmnkVXgJRIU9MK12iww= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?utf-8?q?S=C3=B6nke_Huster?= , Johannes Berg Subject: [PATCH 6.0 27/34] wifi: mac80211_hwsim: avoid mac80211 warning on bad rate Date: Thu, 13 Oct 2022 19:53:05 +0200 Message-Id: <20221013175147.217997359@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175146.507746257@linuxfoundation.org> References: <20221013175146.507746257@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746596957829431323?= X-GMAIL-MSGID: =?utf-8?q?1746596957829431323?= From: Johannes Berg commit 1833b6f46d7e2830251a063935ab464256defe22 upstream. If the tool on the other side (e.g. wmediumd) gets confused about the rate, we hit a warning in mac80211. Silence that by effectively duplicating the check here and dropping the frame silently (in mac80211 it's dropped with the warning). Reported-by: Sönke Huster Tested-by: Sönke Huster Signed-off-by: Johannes Berg Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/mac80211_hwsim.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -4526,6 +4526,8 @@ static int hwsim_cloned_frame_received_n rx_status.band = channel->band; rx_status.rate_idx = nla_get_u32(info->attrs[HWSIM_ATTR_RX_RATE]); + if (rx_status.rate_idx >= data2->hw->wiphy->bands[rx_status.band]->n_bitrates) + goto out; rx_status.signal = nla_get_u32(info->attrs[HWSIM_ATTR_SIGNAL]); hdr = (void *)skb->data; From patchwork Thu Oct 13 17:53:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2251 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp413704wrs; Thu, 13 Oct 2022 11:13:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5k15Bgby/xAgNrGoNJnOu6PtyXWEAdW/NpZlFSTY/HYLpzp3G//q3hX8rNxl0pPWlx6HCf X-Received: by 2002:a17:902:ef95:b0:17c:256a:d52c with SMTP id iz21-20020a170902ef9500b0017c256ad52cmr961057plb.94.1665684824802; Thu, 13 Oct 2022 11:13:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684824; cv=none; d=google.com; s=arc-20160816; b=cMEJk5wD1xQYlv+aqxWYCMKqk/MacYMnQz/eLXS/naDTV314nV/ymTvvZtsngDzFL8 lyBsLY+vNMbW42J3gO3S/UKXTuFS/HdbmUo9/LGG9/RMFXjK87HQlzOiDtY6cEyIQuRf l/jjNzxxpmSHJfpwdQ0OuTed2B1SAHDLIUatM6QAamw5RXUyF6iRQZ0LBm8xaSbHWdHB 8JwhFHPJGYDcyG6KiU3ZGN1mSavVo3RW+DT3d4d+ejLgpNNdOA+rM4xGcRvP9lP2FsdS uVjJDsl6eiEBFsdi+BOIR2rICE3bqvdHg6PAtsJjNxUBSC3si5ILbPyf/i72F/z7s8ho AWAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=f2D/UTt52w77b03my98Fi4tNwQOenbRf8t2SEK7pa9g=; b=uKI2fCxagJ2mGCnuWmdhhaXVEqZ2ytKvlxGtLmOmA+RSpLuxW8RN/TeTF8q7UL9BLk 6ILiqVngLlVK9v9wLK+fkXIFBVF3KGbug3k3zsgt5ugiiJCtIG16P9sYK19PyE+7nR7H sGvXCASuAQZjIxPsOy+a1d1JhKHDbdG3OkvwyHmg/xKgyE9L8DO5FD93BH/O2McLPO4G AFJeVqpk7bbtFgf6o7m90jPO9CrRCv+kImV8gDHzf4wQ9ZnIGjTkMEfhq17EIxhSmm/F BhVxxihgaFLYffKlGmZCcxYw5GeB8ta5UTyvHZkiqU9ePayRQK0Oa7svnqCaiUumcXaC oNHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yw6Ix6t0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p1-20020a654bc1000000b0045cc8781244si110505pgr.220.2022.10.13.11.13.32; Thu, 13 Oct 2022 11:13:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yw6Ix6t0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231821AbiJMSND (ORCPT + 99 others); Thu, 13 Oct 2022 14:13:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231740AbiJMSMY (ORCPT ); Thu, 13 Oct 2022 14:12:24 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B38642E60; Thu, 13 Oct 2022 11:09:00 -0700 (PDT) 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 A9242B8208C; Thu, 13 Oct 2022 18:01:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 01C12C433D6; Thu, 13 Oct 2022 18:01:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665684110; bh=lLqCrwDJ8miX6i4LtkwaFt39DqsL2gRwP9cDebLmFlU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yw6Ix6t0vh6X1IVp7uxeeVyxQLgyMFLzBGKmCrqVpfkGlRKOm7ua7Z0P72RaIjrcC Q6Xhak5vtOB1fD6ZBE9l2AgwRxqoIuey/fQPDqpZjNG69io0hX1lN+mAtRHQclhQlk VZyfXi/HvpFtpGUFKZWO1fAm+WxAH0gbjgbQjRRg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?utf-8?q?S=C3=B6nke_Huster?= , Johannes Berg Subject: [PATCH 6.0 28/34] wifi: mac80211: fix crash in beacon protection for P2P-device Date: Thu, 13 Oct 2022 19:53:06 +0200 Message-Id: <20221013175147.242454440@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175146.507746257@linuxfoundation.org> References: <20221013175146.507746257@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746597130754883132?= X-GMAIL-MSGID: =?utf-8?q?1746597130754883132?= From: Johannes Berg commit b2d03cabe2b2e150ff5a381731ea0355459be09f upstream. If beacon protection is active but the beacon cannot be decrypted or is otherwise malformed, we call the cfg80211 API to report this to userspace, but that uses a netdev pointer, which isn't present for P2P-Device. Fix this to call it only conditionally to ensure cfg80211 won't crash in the case of P2P-Device. This fixes CVE-2022-42722. Reported-by: Sönke Huster Fixes: 9eaf183af741 ("mac80211: Report beacon protection failures to user space") Signed-off-by: Johannes Berg Signed-off-by: Greg Kroah-Hartman --- net/mac80211/rx.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -1967,10 +1967,11 @@ ieee80211_rx_h_decrypt(struct ieee80211_ if (mmie_keyidx < NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS || mmie_keyidx >= NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS + - NUM_DEFAULT_BEACON_KEYS) { - cfg80211_rx_unprot_mlme_mgmt(rx->sdata->dev, - skb->data, - skb->len); + NUM_DEFAULT_BEACON_KEYS) { + if (rx->sdata->dev) + cfg80211_rx_unprot_mlme_mgmt(rx->sdata->dev, + skb->data, + skb->len); return RX_DROP_MONITOR; /* unexpected BIP keyidx */ } @@ -2121,7 +2122,8 @@ ieee80211_rx_h_decrypt(struct ieee80211_ /* either the frame has been decrypted or will be dropped */ status->flag |= RX_FLAG_DECRYPTED; - if (unlikely(ieee80211_is_beacon(fc) && result == RX_DROP_UNUSABLE)) + if (unlikely(ieee80211_is_beacon(fc) && result == RX_DROP_UNUSABLE && + rx->sdata->dev)) cfg80211_rx_unprot_mlme_mgmt(rx->sdata->dev, skb->data, skb->len); From patchwork Thu Oct 13 17:53:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2279 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp424235wrs; Thu, 13 Oct 2022 11:40:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4inNd6i0+iyx/CeCCkv6wC7+eCAWNq2kKipNQdtisaxWhux/j8XyTN062RskQ8w2nAP6Nd X-Received: by 2002:a62:2985:0:b0:544:77d4:f43b with SMTP id p127-20020a622985000000b0054477d4f43bmr896012pfp.9.1665686455497; Thu, 13 Oct 2022 11:40:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665686455; cv=none; d=google.com; s=arc-20160816; b=N5bwnngPpZtwHu3F0MFxXFdr5KXNTODi6wPbQ89sqap1h/0LHStWiL72Apeg6tKMzY QkKJV465sd3YF0LjYOMLvbiJLwhsrD+J6irlSTB13OZGhJth0xzIIoKYHmNIo0xsb7Pu KBrbWw1ztA77LfBuOl87kk5f0MfZRLP0nwbASsCAf9c3x5X9n9fTEybM8jgYdnKoCRkO 7L0l3oTogqIpuTcL75SFHCCfJq5aJvb582i4P7cVMcX0bblyPkEZZtCxCa3rgJTxM9Zp xHFHXjBSGs2m7WJ9C3gKh4WT2S8R7KOFALmYd/I2as+1pczWKscmN4YNM4I94fFLoO4c oFEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=tuNFlO5xEwx1qwA17FlNfOiBU373yUDD5hY9sp6BMwM=; b=iOKPvlPId2ra4vqK/npexLXgShFUv1AxBGCKRGupRWpxJC/wB5D7Ae3wAUQEQ1dulA TEEERLOVCtTHwweVQFL9SoU/W+cMSIO96p9PEPrr7vkOmuTLUApcWtswiq7sHBvc0/kH ohTm9GPWVNs34/EKeDv5bMj2am9wUkILvGOE4zil5xyetHUJ+xIfAdvHzsN3qIwG2x2Z qM5o63AOdUY4V64d0bl7eVf9zOkdrKICAM8RtkcEtdF2pd+wjgIgWIO9JUAsrSDrXHxz BurIW+GohEB9hPI6BKOjKoPKbWsgBq0horPBQDAzRv0n3EZq5UiNc/Vg+AagCewrYEDM NJ0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="hJh/MGzy"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o21-20020a170903211500b0016c00834dd5si482555ple.18.2022.10.13.11.40.42; Thu, 13 Oct 2022 11:40:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="hJh/MGzy"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231865AbiJMSQj (ORCPT + 99 others); Thu, 13 Oct 2022 14:16:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232271AbiJMSOe (ORCPT ); Thu, 13 Oct 2022 14:14:34 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DCBF170DF0; Thu, 13 Oct 2022 11:10:58 -0700 (PDT) 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 5383EB820AD; Thu, 13 Oct 2022 18:01:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B547EC433D6; Thu, 13 Oct 2022 18:01:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665684113; bh=YcQbhCSPoD2UnDkliHAi/oE6U9WmvVTA8st+VYyO1o0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hJh/MGzykUe+e46qb8pFPWngN3MsgCCNeynk0EX2OqNcKO23Tgu1p2CVFfPosG+h8 DIYDyyGyab3Dv3EE5M9FlsIeRmOV7kU5r3DJgV4iWO3BiflVcKlbiBiMR47DNmLBh7 x4VKOPEosJ742+eOzkpyjHgja38GrXpml6zmYRCA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?utf-8?q?S=C3=B6nke_Huster?= , Johannes Berg Subject: [PATCH 6.0 29/34] wifi: cfg80211: update hidden BSSes to avoid WARN_ON Date: Thu, 13 Oct 2022 19:53:07 +0200 Message-Id: <20221013175147.267608492@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175146.507746257@linuxfoundation.org> References: <20221013175146.507746257@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746598840579923627?= X-GMAIL-MSGID: =?utf-8?q?1746598840579923627?= From: Johannes Berg commit c90b93b5b782891ebfda49d4e5da36632fefd5d1 upstream. When updating beacon elements in a non-transmitted BSS, also update the hidden sub-entries to the same beacon elements, so that a future update through other paths won't trigger a WARN_ON(). The warning is triggered because the beacon elements in the hidden BSSes that are children of the BSS should always be the same as in the parent. Reported-by: Sönke Huster Tested-by: Sönke Huster Fixes: 0b8fb8235be8 ("cfg80211: Parsing of Multiple BSSID information in scanning") Signed-off-by: Johannes Berg Signed-off-by: Greg Kroah-Hartman --- net/wireless/scan.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) --- a/net/wireless/scan.c +++ b/net/wireless/scan.c @@ -1607,6 +1607,23 @@ struct cfg80211_non_tx_bss { u8 bssid_index; }; +static void cfg80211_update_hidden_bsses(struct cfg80211_internal_bss *known, + const struct cfg80211_bss_ies *new_ies, + const struct cfg80211_bss_ies *old_ies) +{ + struct cfg80211_internal_bss *bss; + + /* Assign beacon IEs to all sub entries */ + list_for_each_entry(bss, &known->hidden_list, hidden_list) { + const struct cfg80211_bss_ies *ies; + + ies = rcu_access_pointer(bss->pub.beacon_ies); + WARN_ON(ies != old_ies); + + rcu_assign_pointer(bss->pub.beacon_ies, new_ies); + } +} + static bool cfg80211_update_known_bss(struct cfg80211_registered_device *rdev, struct cfg80211_internal_bss *known, @@ -1630,7 +1647,6 @@ cfg80211_update_known_bss(struct cfg8021 kfree_rcu((struct cfg80211_bss_ies *)old, rcu_head); } else if (rcu_access_pointer(new->pub.beacon_ies)) { const struct cfg80211_bss_ies *old; - struct cfg80211_internal_bss *bss; if (known->pub.hidden_beacon_bss && !list_empty(&known->hidden_list)) { @@ -1658,16 +1674,7 @@ cfg80211_update_known_bss(struct cfg8021 if (old == rcu_access_pointer(known->pub.ies)) rcu_assign_pointer(known->pub.ies, new->pub.beacon_ies); - /* Assign beacon IEs to all sub entries */ - list_for_each_entry(bss, &known->hidden_list, hidden_list) { - const struct cfg80211_bss_ies *ies; - - ies = rcu_access_pointer(bss->pub.beacon_ies); - WARN_ON(ies != old); - - rcu_assign_pointer(bss->pub.beacon_ies, - new->pub.beacon_ies); - } + cfg80211_update_hidden_bsses(known, new->pub.beacon_ies, old); if (old) kfree_rcu((struct cfg80211_bss_ies *)old, rcu_head); @@ -2360,6 +2367,8 @@ cfg80211_update_notlisted_nontrans(struc } else { old = rcu_access_pointer(nontrans_bss->beacon_ies); rcu_assign_pointer(nontrans_bss->beacon_ies, new_ies); + cfg80211_update_hidden_bsses(bss_from_pub(nontrans_bss), + new_ies, old); rcu_assign_pointer(nontrans_bss->ies, new_ies); if (old) kfree_rcu((struct cfg80211_bss_ies *)old, rcu_head); From patchwork Thu Oct 13 17:53:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2252 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp413734wrs; Thu, 13 Oct 2022 11:13:47 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6KXbQRInXlMXCQZSKt/1pPaibq1vTPjxqwRDniBMA85vmYOhPv8aliNs/EASGsmnriEaIm X-Received: by 2002:a17:902:bcc4:b0:181:899a:ac9c with SMTP id o4-20020a170902bcc400b00181899aac9cmr940012pls.124.1665684827422; Thu, 13 Oct 2022 11:13:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684827; cv=none; d=google.com; s=arc-20160816; b=RuSg+DdVSDXKW68czG1jyfvzcf1IMEIvn7fgo35XKksC+dCDNRecGyiB9uQeVXJOE9 bBMFTs4CA1A4qH8PqnQ4a9bMYGk3uTJui7OOHgoP6z638INkkbfK06MqzI3ePoI6IM1w yW8i3XeRzCQS4SX4c0YNr6msB3+2J8s03haqaTaR466sXNL+XSIa+l4PGTxGE4vXvibW kWqxDlaXacMVhKbF/D7nbCrn7vuELrjqbflY8v0f31l7wFgJne3j/y5QoN6uMpU169au oH9WQRusVTW1hYe4Fkm5vjjApkEWhuVNWhnBSvKgvW/Iwx5uBVmgiGWija2938ukEva/ sAZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qaWh7cQqMCexGiyovsFDcs0CMJdtexthRqEjDGfr+jY=; b=TycBb3skIbTVjpUFfZw/wklBTMYAU91sj+vCoiHm3Z8IF2g+TBYteM7nVnhFkGwwgu qTwu4nMYL72+0DaCKhquH8G2rlQDOv5OE14d+gZ+4D2eetjLWQGcB5eA0r+VMRvct9NF egQQvjg/Wv9v1t3Lb5n6db9U4DIDnhbE5vgLi5BSCqRh50LupCUvGJ5uB+bhEeM19CNP e/J9DqWk6tUi+Zh5eRB/amm53u/wttsss9Lp5ECt+EMz5TJ+RPNhQBhW0qQObxeLjI6a EqX6xzLVwQdzeOCDp12o54GMT5V0oJRK1YaJ8Z+iGhzRlLt5D7STzqh8wD2F3t76A8sI Yi+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Mg6F2PMg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r10-20020a1709028bca00b001789a178e33si326431plo.428.2022.10.13.11.13.34; Thu, 13 Oct 2022 11:13:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Mg6F2PMg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231476AbiJMSNT (ORCPT + 99 others); Thu, 13 Oct 2022 14:13:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231769AbiJMSMa (ORCPT ); Thu, 13 Oct 2022 14:12:30 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CBA3170DCC; Thu, 13 Oct 2022 11:09:19 -0700 (PDT) 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 003F2B820CB; Thu, 13 Oct 2022 18:02:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F70DC433C1; Thu, 13 Oct 2022 18:02:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665684151; bh=cLMk1ar/nQON1mZgjjsdpVy1arXfNUVtd1FNGe7wHxc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mg6F2PMgkRvjBgb7z6ZNUS4aU5aXRC+Rglz7+CORq8TFS29/6dw+IKg7sUwfP2c/Z /Ci0tHCvtu3u/s93mL3YBUkRd/Ww7LeuVCE0NiPH4sD00knBGUQei87+FwVRjCXN52 zxdMspKzaKmt/VlwLVDFYKm7g3B5R3xT0WvFONE0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, butt3rflyh4ck , Jeremy Kerr , "David S. Miller" Subject: [PATCH 6.0 30/34] mctp: prevent double key removal and unref Date: Thu, 13 Oct 2022 19:53:08 +0200 Message-Id: <20221013175147.291795983@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175146.507746257@linuxfoundation.org> References: <20221013175146.507746257@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746597133479519179?= X-GMAIL-MSGID: =?utf-8?q?1746597133479519179?= From: Jeremy Kerr commit 3a732b46736cd8a29092e4b0b1a9ba83e672bf89 upstream. Currently, we have a bug where a simultaneous DROPTAG ioctl and socket close may race, as we attempt to remove a key from lists twice, and perform an unref for each removal operation. This may result in a uaf when we attempt the second unref. This change fixes the race by making __mctp_key_remove tolerant to being called on a key that has already been removed from the socket/net lists, and only performs the unref when we do the actual remove. We also need to hold the list lock on the ioctl cleanup path. This fix is based on a bug report and comprehensive analysis from butt3rflyh4ck , found via syzkaller. Cc: stable@vger.kernel.org Fixes: 63ed1aab3d40 ("mctp: Add SIOCMCTP{ALLOC,DROP}TAG ioctls for tag control") Reported-by: butt3rflyh4ck Signed-off-by: Jeremy Kerr Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/mctp/af_mctp.c | 23 ++++++++++++++++------- net/mctp/route.c | 10 +++++----- 2 files changed, 21 insertions(+), 12 deletions(-) --- a/net/mctp/af_mctp.c +++ b/net/mctp/af_mctp.c @@ -295,11 +295,12 @@ __must_hold(&net->mctp.keys_lock) mctp_dev_release_key(key->dev, key); spin_unlock_irqrestore(&key->lock, flags); - hlist_del(&key->hlist); - hlist_del(&key->sklist); - - /* unref for the lists */ - mctp_key_unref(key); + if (!hlist_unhashed(&key->hlist)) { + hlist_del_init(&key->hlist); + hlist_del_init(&key->sklist); + /* unref for the lists */ + mctp_key_unref(key); + } kfree_skb(skb); } @@ -373,9 +374,17 @@ static int mctp_ioctl_alloctag(struct mc ctl.tag = tag | MCTP_TAG_OWNER | MCTP_TAG_PREALLOC; if (copy_to_user((void __user *)arg, &ctl, sizeof(ctl))) { - spin_lock_irqsave(&key->lock, flags); - __mctp_key_remove(key, net, flags, MCTP_TRACE_KEY_DROPPED); + unsigned long fl2; + /* Unwind our key allocation: the keys list lock needs to be + * taken before the individual key locks, and we need a valid + * flags value (fl2) to pass to __mctp_key_remove, hence the + * second spin_lock_irqsave() rather than a plain spin_lock(). + */ + spin_lock_irqsave(&net->mctp.keys_lock, flags); + spin_lock_irqsave(&key->lock, fl2); + __mctp_key_remove(key, net, fl2, MCTP_TRACE_KEY_DROPPED); mctp_key_unref(key); + spin_unlock_irqrestore(&net->mctp.keys_lock, flags); return -EFAULT; } --- a/net/mctp/route.c +++ b/net/mctp/route.c @@ -228,12 +228,12 @@ __releases(&key->lock) if (!key->manual_alloc) { spin_lock_irqsave(&net->mctp.keys_lock, flags); - hlist_del(&key->hlist); - hlist_del(&key->sklist); + if (!hlist_unhashed(&key->hlist)) { + hlist_del_init(&key->hlist); + hlist_del_init(&key->sklist); + mctp_key_unref(key); + } spin_unlock_irqrestore(&net->mctp.keys_lock, flags); - - /* unref for the lists */ - mctp_key_unref(key); } /* and one for the local reference */ From patchwork Thu Oct 13 17:53:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2300 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp428516wrs; Thu, 13 Oct 2022 11:52:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Fex0vLK+BNhK8ZjwH+pUojVFUIA6kFZotxW9bFWENZcwLIZEcJgAgymlZk29Lkz0bcT6F X-Received: by 2002:a17:90b:4c12:b0:20d:7124:7c10 with SMTP id na18-20020a17090b4c1200b0020d71247c10mr12519677pjb.204.1665687130393; Thu, 13 Oct 2022 11:52:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665687130; cv=none; d=google.com; s=arc-20160816; b=N/rnlsb4OVl9/12Ko36qYZVnmgydqI1/08DnIN76TbY+H9Wuv9w3qyShvmfE3X0cit JdfA7+XR+K4oV3If4QGYOMz+7YlSi/K821we+RzoW/+Za0Hzo64/Zm0GG641wpHsCimR LqA6U+OTmr7EnU/SrfJ/HSEcKihMhuvyq+dVsZMpBZQZES0M+vIL//BeIWBFUtrXabnG MJhrOyHK98o30Yri4+R1P4cSyZVq1l33ltZ4um9q+24faNeFU7BdfxiJaBjgsKl6xC0S 7iUrtu7ybX4gUbJtLStpMyeYKCGzFoIN9KmVElk109/jVM9P5zvp2+Al8CAjqvenAYbw ++IQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=FF+oA7C4BHy0usZcW/zh7Gm6QjQ7dJ+f1p72HLJmg80=; b=LLj1KyEQge+8Lx0xCoGP33Vw281gTa75agbdPBvfGSlsHFXiLqGzEEIIXMGjYzTXAa HrsJg9iF0RtNNalrYJzEeKoEox54LneVOEfl+MTElNp6dageB7pG3S4HPGMNk1v0slpk vg8BHiaVjX1GFgD5x7nJyOOU5wQ5u5kg5fJ0ovyeeJ5r+R4Z7bQce3mj7cdUtg17NBXg fm9QGjzWz9behomF084kHMPR7AJYrzecLGu7Kpyc7OKsWeIrqHr6gIHdGuE46jHjvLc4 9GUe6E0oJWGtNYMUzIFgh3FJgLjCw+6SFwqzHphAXcHBPCjoK3DbEPZG1EA+RyUBpjRe I20Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="dv/K+4u6"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z20-20020aa78894000000b0053e7495a394si172440pfe.141.2022.10.13.11.51.58; Thu, 13 Oct 2022 11:52:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="dv/K+4u6"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232089AbiJMSgT (ORCPT + 99 others); Thu, 13 Oct 2022 14:36:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231933AbiJMSfk (ORCPT ); Thu, 13 Oct 2022 14:35:40 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E3E2192DBE; Thu, 13 Oct 2022 11:32:08 -0700 (PDT) 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 68EFEB820C3; Thu, 13 Oct 2022 18:02:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC8C3C433C1; Thu, 13 Oct 2022 18:02:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665684140; bh=/HRpr7EII9h229SUlP4Dmlr4MvLxTEfPUsGzRLuyqhM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dv/K+4u69K6uSeiOJW3SKD4iaREOURgh+sBSxJZGTE+fxtAWTzKZNHklOJ2imzw46 /nlpYZcwyJvC1nzfWORYUTGrbDZEgp/VGkvXp8OuIAiarWtO+HiWiqn7TxjDObUaMe rjlR2/DMrELP7I+VX/BfljW589PqVyr87chXsD0E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jasper Poppe , Jeremy Palmer , Ruineka , Cleber de Mattos Casali , Kyle Gospodnetich , Pavel Rojtberg , Dmitry Torokhov Subject: [PATCH 6.0 31/34] Input: xpad - add supported devices as contributed on github Date: Thu, 13 Oct 2022 19:53:09 +0200 Message-Id: <20221013175147.316403835@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175146.507746257@linuxfoundation.org> References: <20221013175146.507746257@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746599548378969651?= X-GMAIL-MSGID: =?utf-8?q?1746599548378969651?= From: Pavel Rojtberg commit b382c5e37344883dc97525d05f1f6b788f549985 upstream. This is based on multiple commits at https://github.com/paroj/xpad Cc: stable@vger.kernel.org Signed-off-by: Jasper Poppe Signed-off-by: Jeremy Palmer Signed-off-by: Ruineka Signed-off-by: Cleber de Mattos Casali Signed-off-by: Kyle Gospodnetich Signed-off-by: Pavel Rojtberg Link: https://lore.kernel.org/r/20220818154411.510308-2-rojtberg@gmail.com Signed-off-by: Dmitry Torokhov Signed-off-by: Greg Kroah-Hartman --- drivers/input/joystick/xpad.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) --- a/drivers/input/joystick/xpad.c +++ b/drivers/input/joystick/xpad.c @@ -113,6 +113,8 @@ static const struct xpad_device { u8 xtype; } xpad_device[] = { { 0x0079, 0x18d4, "GPD Win 2 X-Box Controller", 0, XTYPE_XBOX360 }, + { 0x03eb, 0xff01, "Wooting One (Legacy)", 0, XTYPE_XBOX360 }, + { 0x03eb, 0xff02, "Wooting Two (Legacy)", 0, XTYPE_XBOX360 }, { 0x044f, 0x0f00, "Thrustmaster Wheel", 0, XTYPE_XBOX }, { 0x044f, 0x0f03, "Thrustmaster Wheel", 0, XTYPE_XBOX }, { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX }, @@ -244,6 +246,7 @@ static const struct xpad_device { { 0x0f0d, 0x0063, "Hori Real Arcade Pro Hayabusa (USA) Xbox One", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE }, { 0x0f0d, 0x0067, "HORIPAD ONE", 0, XTYPE_XBOXONE }, { 0x0f0d, 0x0078, "Hori Real Arcade Pro V Kai Xbox One", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE }, + { 0x0f0d, 0x00c5, "Hori Fighting Commander ONE", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE }, { 0x0f30, 0x010b, "Philips Recoil", 0, XTYPE_XBOX }, { 0x0f30, 0x0202, "Joytech Advanced Controller", 0, XTYPE_XBOX }, { 0x0f30, 0x8888, "BigBen XBMiniPad Controller", 0, XTYPE_XBOX }, @@ -260,6 +263,7 @@ static const struct xpad_device { { 0x1430, 0x8888, "TX6500+ Dance Pad (first generation)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, { 0x1430, 0xf801, "RedOctane Controller", 0, XTYPE_XBOX360 }, { 0x146b, 0x0601, "BigBen Interactive XBOX 360 Controller", 0, XTYPE_XBOX360 }, + { 0x146b, 0x0604, "Bigben Interactive DAIJA Arcade Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, { 0x1532, 0x0037, "Razer Sabertooth", 0, XTYPE_XBOX360 }, { 0x1532, 0x0a00, "Razer Atrox Arcade Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE }, { 0x1532, 0x0a03, "Razer Wildcat", 0, XTYPE_XBOXONE }, @@ -325,6 +329,7 @@ static const struct xpad_device { { 0x24c6, 0x5502, "Hori Fighting Stick VX Alt", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, { 0x24c6, 0x5503, "Hori Fighting Edge", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, { 0x24c6, 0x5506, "Hori SOULCALIBUR V Stick", 0, XTYPE_XBOX360 }, + { 0x24c6, 0x5510, "Hori Fighting Commander ONE (Xbox 360/PC Mode)", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, { 0x24c6, 0x550d, "Hori GEM Xbox controller", 0, XTYPE_XBOX360 }, { 0x24c6, 0x550e, "Hori Real Arcade Pro V Kai 360", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, { 0x24c6, 0x551a, "PowerA FUSION Pro Controller", 0, XTYPE_XBOXONE }, @@ -334,6 +339,14 @@ static const struct xpad_device { { 0x24c6, 0x5b03, "Thrustmaster Ferrari 458 Racing Wheel", 0, XTYPE_XBOX360 }, { 0x24c6, 0x5d04, "Razer Sabertooth", 0, XTYPE_XBOX360 }, { 0x24c6, 0xfafe, "Rock Candy Gamepad for Xbox 360", 0, XTYPE_XBOX360 }, + { 0x2563, 0x058d, "OneXPlayer Gamepad", 0, XTYPE_XBOX360 }, + { 0x2dc8, 0x2000, "8BitDo Pro 2 Wired Controller fox Xbox", 0, XTYPE_XBOXONE }, + { 0x31e3, 0x1100, "Wooting One", 0, XTYPE_XBOX360 }, + { 0x31e3, 0x1200, "Wooting Two", 0, XTYPE_XBOX360 }, + { 0x31e3, 0x1210, "Wooting Lekker", 0, XTYPE_XBOX360 }, + { 0x31e3, 0x1220, "Wooting Two HE", 0, XTYPE_XBOX360 }, + { 0x31e3, 0x1300, "Wooting 60HE (AVR)", 0, XTYPE_XBOX360 }, + { 0x31e3, 0x1310, "Wooting 60HE (ARM)", 0, XTYPE_XBOX360 }, { 0x3285, 0x0607, "Nacon GC-100", 0, XTYPE_XBOX360 }, { 0x3767, 0x0101, "Fanatec Speedster 3 Forceshock Wheel", 0, XTYPE_XBOX }, { 0xffff, 0xffff, "Chinese-made Xbox Controller", 0, XTYPE_XBOX }, @@ -419,6 +432,7 @@ static const signed short xpad_abs_trigg static const struct usb_device_id xpad_table[] = { { USB_INTERFACE_INFO('X', 'B', 0) }, /* X-Box USB-IF not approved class */ XPAD_XBOX360_VENDOR(0x0079), /* GPD Win 2 Controller */ + XPAD_XBOX360_VENDOR(0x03eb), /* Wooting Keyboards (Legacy) */ XPAD_XBOX360_VENDOR(0x044f), /* Thrustmaster X-Box 360 controllers */ XPAD_XBOX360_VENDOR(0x045e), /* Microsoft X-Box 360 controllers */ XPAD_XBOXONE_VENDOR(0x045e), /* Microsoft X-Box One controllers */ @@ -429,6 +443,7 @@ static const struct usb_device_id xpad_t { USB_DEVICE(0x0738, 0x4540) }, /* Mad Catz Beat Pad */ XPAD_XBOXONE_VENDOR(0x0738), /* Mad Catz FightStick TE 2 */ XPAD_XBOX360_VENDOR(0x07ff), /* Mad Catz GamePad */ + XPAD_XBOX360_VENDOR(0x0c12), /* Zeroplus X-Box 360 controllers */ XPAD_XBOX360_VENDOR(0x0e6f), /* 0x0e6f X-Box 360 controllers */ XPAD_XBOXONE_VENDOR(0x0e6f), /* 0x0e6f X-Box One controllers */ XPAD_XBOX360_VENDOR(0x0f0d), /* Hori Controllers */ @@ -450,8 +465,12 @@ static const struct usb_device_id xpad_t XPAD_XBOXONE_VENDOR(0x20d6), /* PowerA Controllers */ XPAD_XBOX360_VENDOR(0x24c6), /* PowerA Controllers */ XPAD_XBOXONE_VENDOR(0x24c6), /* PowerA Controllers */ + XPAD_XBOX360_VENDOR(0x2563), /* OneXPlayer Gamepad */ + XPAD_XBOX360_VENDOR(0x260d), /* Dareu H101 */ + XPAD_XBOXONE_VENDOR(0x2dc8), /* 8BitDo Pro 2 Wired Controller for Xbox */ XPAD_XBOXONE_VENDOR(0x2e24), /* Hyperkin Duke X-Box One pad */ XPAD_XBOX360_VENDOR(0x2f24), /* GameSir Controllers */ + XPAD_XBOX360_VENDOR(0x31e3), /* Wooting Keyboards */ XPAD_XBOX360_VENDOR(0x3285), /* Nacon GC-100 */ { } }; From patchwork Thu Oct 13 17:53:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2238 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp412858wrs; Thu, 13 Oct 2022 11:11:47 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6tF04pwZnpnTD3Z+faFRw9PE1LtiFmFx09T45YXVFzjemRGd4pX27Atmmy3BJG/kBmIFlT X-Received: by 2002:a17:90b:4d0d:b0:1fb:a86d:e752 with SMTP id mw13-20020a17090b4d0d00b001fba86de752mr1142490pjb.120.1665684707522; Thu, 13 Oct 2022 11:11:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684707; cv=none; d=google.com; s=arc-20160816; b=GbDYlKqVDCnpV5cS4ILpaZqRFczF842IR3VTcKqTlhtsnqCJJZzJBV2TTry6Px/8sl luJE+GuRB6TtyltklwGojz/REB6Qje1T9FdsD1RNZPoNWfcoXl0PhoMzwaOEiLqN6QiT AoLfvVS5O0mAmqSnfyrYI82SYbHF38ub2pfIrLASY0pjLS/n6bL6Zy7S23tXGO929uqR kV3q+4coIqyNDEln71ea4YnMt+fNCmJGqac6FFBnLo5TaU5LbRUOqfzUIOFwE3Fw1kWJ A09QBVUzO52lrO/1Bg7QDinA73fgZ1erB4O7a1MgTc3Hi3dgsGtNP9xUyQ7I30HnT/8m Q54w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=FZ1YaeSNy/pNi3dcImhxesDJb5g81XsNXUAZ07POFWY=; b=lIvb2HjEeYdLuAG+nbkwdQSBAFpeMwTDQ5j7ozcstUA2Z+2744+t7+soYios9NUZWj n20R7G64xMSWU1bHLk0w78OWEpw/vvlHZOx4AIxGkW92puLEuTvYGFq881dVIEcfV15R HJveH08i8PsMg/5nwtxuyq4L2LBjSwkfgpqwv/HZnE4gUKisYx1Ubmnbc3polhpxRVbA 5zhbkrYbGVoIw6yPx6Og598LMNyxNtP4WcM1bQR+YATYqx5MWBzzw6Ra/m0fYvolpUh/ eodltHj2pWtpfjrQ6fXn51p2mNdSZfs/c6T498r6WVq72sThJAVK7o7AbuNJpSW6qK7i 8vqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=K9ObPneC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n1-20020a170902e54100b001786a4a4c98si393440plf.371.2022.10.13.11.11.34; Thu, 13 Oct 2022 11:11:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=K9ObPneC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231206AbiJMSLT (ORCPT + 99 others); Thu, 13 Oct 2022 14:11:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231290AbiJMSKd (ORCPT ); Thu, 13 Oct 2022 14:10:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F830169CF2; Thu, 13 Oct 2022 11:07:49 -0700 (PDT) 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 995EF61A53; Thu, 13 Oct 2022 18:02:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA87CC433C1; Thu, 13 Oct 2022 18:02:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665684143; bh=45B25suZiRTyMNLHbM6xw8qTu27E00Fp19ufaiOX5r0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K9ObPneC3kJY+RKF3jCOVPjZKul9jtb+dHFXU/iOILWryCld8FgVVs2qSRyVxrr7R Ev/2f2JfaOGiKXnT/LqWrU61eDd2D8Ldj7HlCf6ENH653VPYAWNE+3T/cxzQc/lM7p Lv3FJAE5MlV3laVZ4nDnzF0ia/b4xKTbw8JibSiY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Cameron Gutman , Pavel Rojtberg , Dmitry Torokhov Subject: [PATCH 6.0 32/34] Input: xpad - fix wireless 360 controller breaking after suspend Date: Thu, 13 Oct 2022 19:53:10 +0200 Message-Id: <20221013175147.341436627@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175146.507746257@linuxfoundation.org> References: <20221013175146.507746257@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746597008159331834?= X-GMAIL-MSGID: =?utf-8?q?1746597008159331834?= From: Cameron Gutman commit a17b9841152e7f4621619902b347e2cc39c32996 upstream. Suspending and resuming the system can sometimes cause the out URB to get hung after a reset_resume. This causes LED setting and force feedback to break on resume. To avoid this, just drop the reset_resume callback so the USB core rebinds xpad to the wireless pads on resume if a reset happened. A nice side effect of this change is the LED ring on wireless controllers is now set correctly on system resume. Cc: stable@vger.kernel.org Fixes: 4220f7db1e42 ("Input: xpad - workaround dead irq_out after suspend/ resume") Signed-off-by: Cameron Gutman Signed-off-by: Pavel Rojtberg Link: https://lore.kernel.org/r/20220818154411.510308-3-rojtberg@gmail.com Signed-off-by: Dmitry Torokhov Signed-off-by: Greg Kroah-Hartman --- drivers/input/joystick/xpad.c | 1 - 1 file changed, 1 deletion(-) --- a/drivers/input/joystick/xpad.c +++ b/drivers/input/joystick/xpad.c @@ -1991,7 +1991,6 @@ static struct usb_driver xpad_driver = { .disconnect = xpad_disconnect, .suspend = xpad_suspend, .resume = xpad_resume, - .reset_resume = xpad_resume, .id_table = xpad_table, }; From patchwork Thu Oct 13 17:53:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2249 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp413530wrs; Thu, 13 Oct 2022 11:13:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5N7CZzybBM62h0pKrPptMecTxDw8Boax9/kc88a6Uuv3AvRRPSGB/M74Z3vVDHONoTE4wT X-Received: by 2002:a65:56cb:0:b0:460:442e:b293 with SMTP id w11-20020a6556cb000000b00460442eb293mr972919pgs.49.1665684804260; Thu, 13 Oct 2022 11:13:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684804; cv=none; d=google.com; s=arc-20160816; b=ZO2nk60KNX5EvZgSV/0/XG4G6QUkca637G0wSxvkUP5YLMreDNfioxjEwCYLqhCaHg Fur6bSUdaP2L1m13GfwUjCbEHhrBFgI8h1Ulgpre3YOy+NdA2ZcXQqW84o2JEqdxbi8y x5j0wDBEKTsoEr2NXVPpJzX+xxTx00ZeAlVscMGSY/KyUBOlV6+K0hMBrZ7WSHVBUScU WawK60JqJF5VnSrOrdapOAcA0lJuowiZs6BrTfdO6bjMH7j4iwG5Yl8SrG0DraRpa/i+ jzeZsuA2BkpN+8t2a+3ecAtVwHEcMW7bVPUWW527/h4MCfutz8dABoHo8nNoq3EAsFqV QvHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nZhZQXfCKk7bnYk3QDLtn3RiiucS6JTrEp045IGadhE=; b=QBP5F87SYBm/xfjbwjhlSPEMskqgC/mUgKBzQmX4mhvfJYAbG8ytgNjjsrmEbCH6Ti S1hUWdHG1XFZwSJXOFCSjYF8TKZrMK/f5Nwa14lUBywNrWbOnEDVJiYubhu8T8t7QKWJ J2qnco3qDEd0Lkcw9/ZWd7aaSitxr2aSocS3AfMmguUF98L8NwQpEWCstDQNBhFaLnQr NSJKO2NznAAxzc5s0Gk3P3B9IlfedpgK7mdZiEvCgG74PSC80uLK5G6Tu8XeGCp0y4Nw VwPCdhQVA/Apou8bucsSqaZ5ekGFLFSxrEnZrzpvaofMffS75T05P+bZaXy7t0Lip9DF MLRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ymuI6cIf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g1-20020a056a000b8100b00554f1b32131si23082028pfj.362.2022.10.13.11.13.11; Thu, 13 Oct 2022 11:13:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ymuI6cIf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231779AbiJMSM4 (ORCPT + 99 others); Thu, 13 Oct 2022 14:12:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231756AbiJMSM2 (ORCPT ); Thu, 13 Oct 2022 14:12:28 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C21CE170DC0; Thu, 13 Oct 2022 11:09:16 -0700 (PDT) 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 46E47B8206A; Thu, 13 Oct 2022 18:02:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E21DC433D6; Thu, 13 Oct 2022 18:02:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665684146; bh=d76VYFuP2IkY/Fd+zNHwxmqro3iVPoBaVndsGkcmcJw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ymuI6cIfiqQD387ATdl1a0FMMiKoIJLaBxPc7BNta4jz1QxBPZoa5vyz3r1O9gSoM xroVCS9G8hHtcQiKUP4b1+U6t6C1QLtbtHAbvUnTIvpTfGoVSB/5B4FTOfLNpD3ojl pvV5+shEmr70wgZjnM5aDqxZJU1VBwEpvAAG5Jzc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shunsuke Mie , stable Subject: [PATCH 6.0 33/34] misc: pci_endpoint_test: Aggregate params checking for xfer Date: Thu, 13 Oct 2022 19:53:11 +0200 Message-Id: <20221013175147.365846516@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175146.507746257@linuxfoundation.org> References: <20221013175146.507746257@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746597109428209265?= X-GMAIL-MSGID: =?utf-8?q?1746597109428209265?= From: Shunsuke Mie commit 3e42deaac06567c7e86d287c305ccda24db4ae3d upstream. Each transfer test functions have same parameter checking code. This patch unites those to an introduced function. Signed-off-by: Shunsuke Mie Cc: stable Link: https://lore.kernel.org/r/20220907020100.122588-1-mie@igel.co.jp Signed-off-by: Greg Kroah-Hartman --- drivers/misc/pci_endpoint_test.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -332,6 +332,17 @@ static bool pci_endpoint_test_msi_irq(st return false; } +static int pci_endpoint_test_validate_xfer_params(struct device *dev, + struct pci_endpoint_test_xfer_param *param, size_t alignment) +{ + if (param->size > SIZE_MAX - alignment) { + dev_dbg(dev, "Maximum transfer data size exceeded\n"); + return -EINVAL; + } + + return 0; +} + static bool pci_endpoint_test_copy(struct pci_endpoint_test *test, unsigned long arg) { @@ -363,9 +374,11 @@ static bool pci_endpoint_test_copy(struc return false; } + err = pci_endpoint_test_validate_xfer_params(dev, ¶m, alignment); + if (err) + return false; + size = param.size; - if (size > SIZE_MAX - alignment) - goto err; use_dma = !!(param.flags & PCITEST_FLAGS_USE_DMA); if (use_dma) @@ -497,9 +510,11 @@ static bool pci_endpoint_test_write(stru return false; } + err = pci_endpoint_test_validate_xfer_params(dev, ¶m, alignment); + if (err) + return false; + size = param.size; - if (size > SIZE_MAX - alignment) - goto err; use_dma = !!(param.flags & PCITEST_FLAGS_USE_DMA); if (use_dma) @@ -595,9 +610,11 @@ static bool pci_endpoint_test_read(struc return false; } + err = pci_endpoint_test_validate_xfer_params(dev, ¶m, alignment); + if (err) + return false; + size = param.size; - if (size > SIZE_MAX - alignment) - goto err; use_dma = !!(param.flags & PCITEST_FLAGS_USE_DMA); if (use_dma) From patchwork Thu Oct 13 17:53:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2256 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp414379wrs; Thu, 13 Oct 2022 11:15:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7L8e6w3v/a9a0yhAv+SIfgD6Fx1Fhm75IP9hBg7cn0CKtGL8tnG1AoBqqsFY0UYbtV97c9 X-Received: by 2002:a05:6a00:14d4:b0:563:9296:f320 with SMTP id w20-20020a056a0014d400b005639296f320mr806341pfu.27.1665684914403; Thu, 13 Oct 2022 11:15:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684914; cv=none; d=google.com; s=arc-20160816; b=tmkxgOy8l+Nz5OGPW82Y+t7P9JNLZhc/WENrzGuZYEaUWiJ92YDFZKlyR8VSbdJLxc 4lIXNrwIxz2Xa+yHaH8GXVgvheNXtKwn512HC/JSKl6DWf/PUZ8hjpGjneUod6Sxst6S xA0BPQEjDXy/zG+eUvO/hAe+t5AzmNr9XKs8ZaErpKqKCTQZTxtPKavUkTzFr0uyOcck GRWydCK0t3nWZcs/4SkeqsvSHfbMomkpc6olbNOfan4mEkhDpBy8c6n+1m0mS7DOt07N F/xHvbs9375N35cdRwZ7vdx0Fia+nnoIO9V9jUBYJS2UnBR/1N27i7HNTD/4CL98cSpV h7GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ha0SroDg8oCcYjRNVcCRTHCyD5k0ka8z4g6fTvXDinE=; b=FOVH8Fcdx6lAxJGzGXk5V3VPhVqwrzctDBPgghka9Phi8042Eo6dEQiCj2c24NoOXk IpDIH9jbLSFKhsuWOhPNOJaQuifF+xvuaEaVuDfYTAqGAGXqqXvp4jadCV4DfcoE/cAK t0gtkajKWTjT5FSp+Nc+QdNwvOKPFjQDRHU5yfS/Bl0zColGwsDk0/FdwOdBs13tbXIT RovQSBrfvrDigIaonu9BSj2GbcTCVeXXuuVAwUSFuAv+LsKAW+ikaG75acYaytGK2/Em sEY/M8IcJi04xmNRCNIPM7UnFqIHq+9m+PP7v2S3XnIoa/CPHcPV7VgClOHoBv3uAv+z cFLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lDxoXJDB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k6-20020a636f06000000b0045efd23abd4si10350pgc.874.2022.10.13.11.15.01; Thu, 13 Oct 2022 11:15:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lDxoXJDB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231214AbiJMSNe (ORCPT + 99 others); Thu, 13 Oct 2022 14:13:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231792AbiJMSMe (ORCPT ); Thu, 13 Oct 2022 14:12:34 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93418163398; Thu, 13 Oct 2022 11:09:16 -0700 (PDT) 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 09DFEB81CFB; Thu, 13 Oct 2022 18:02:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 598FBC433D7; Thu, 13 Oct 2022 18:02:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665684148; bh=5ZgFuOtpNeu9B5tS5zB18GvxrieiEtS9AebSGSuoKG4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lDxoXJDBDslyMMttwliPFBANmmhG6BNmb6QV4qENI1Kw0trWrP6Qbz8CG3wctJ3O9 J1jnTKLR2ailz1mksL3hX6jpV/KPkvkvvW78nMK3WyzKjDnrCmjShsoWRZBlvzxkDZ 4x4GkHRaosHjCvHsY3m+GW69zARP+nvXvBhvYmXA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable , Shunsuke Mie Subject: [PATCH 6.0 34/34] misc: pci_endpoint_test: Fix pci_endpoint_test_{copy,write,read}() panic Date: Thu, 13 Oct 2022 19:53:12 +0200 Message-Id: <20221013175147.392396734@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175146.507746257@linuxfoundation.org> References: <20221013175146.507746257@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746597224812836860?= X-GMAIL-MSGID: =?utf-8?q?1746597224812836860?= From: Shunsuke Mie commit 8e30538eca016de8e252bef174beadecd64239f0 upstream. The dma_map_single() doesn't permit zero length mapping. It causes a follow panic. A panic was reported on arm64: [ 60.137988] ------------[ cut here ]------------ [ 60.142630] kernel BUG at kernel/dma/swiotlb.c:624! [ 60.147508] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP [ 60.152992] Modules linked in: dw_hdmi_cec crct10dif_ce simple_bridge rcar_fdp1 vsp1 rcar_vin videobuf2_vmalloc rcar_csi2 v4l 2_mem2mem videobuf2_dma_contig videobuf2_memops pci_endpoint_test videobuf2_v4l2 videobuf2_common rcar_fcp v4l2_fwnode v4l2_asyn c videodev mc gpio_bd9571mwv max9611 pwm_rcar ccree at24 authenc libdes phy_rcar_gen3_usb3 usb_dmac display_connector pwm_bl [ 60.186252] CPU: 0 PID: 508 Comm: pcitest Not tainted 6.0.0-rc1rpci-dev+ #237 [ 60.193387] Hardware name: Renesas Salvator-X 2nd version board based on r8a77951 (DT) [ 60.201302] pstate: 00000005 (nzcv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 60.208263] pc : swiotlb_tbl_map_single+0x2c0/0x590 [ 60.213149] lr : swiotlb_map+0x88/0x1f0 [ 60.216982] sp : ffff80000a883bc0 [ 60.220292] x29: ffff80000a883bc0 x28: 0000000000000000 x27: 0000000000000000 [ 60.227430] x26: 0000000000000000 x25: ffff0004c0da20d0 x24: ffff80000a1f77c0 [ 60.234567] x23: 0000000000000002 x22: 0001000040000010 x21: 000000007a000000 [ 60.241703] x20: 0000000000200000 x19: 0000000000000000 x18: 0000000000000000 [ 60.248840] x17: 0000000000000000 x16: 0000000000000000 x15: ffff0006ff7b9180 [ 60.255977] x14: ffff0006ff7b9180 x13: 0000000000000000 x12: 0000000000000000 [ 60.263113] x11: 0000000000000000 x10: 0000000000000000 x9 : 0000000000000000 [ 60.270249] x8 : 0001000000000010 x7 : ffff0004c6754b20 x6 : 0000000000000000 [ 60.277385] x5 : ffff0004c0da2090 x4 : 0000000000000000 x3 : 0000000000000001 [ 60.284521] x2 : 0000000040000000 x1 : 0000000000000000 x0 : 0000000040000010 [ 60.291658] Call trace: [ 60.294100] swiotlb_tbl_map_single+0x2c0/0x590 [ 60.298629] swiotlb_map+0x88/0x1f0 [ 60.302115] dma_map_page_attrs+0x188/0x230 [ 60.306299] pci_endpoint_test_ioctl+0x5e4/0xd90 [pci_endpoint_test] [ 60.312660] __arm64_sys_ioctl+0xa8/0xf0 [ 60.316583] invoke_syscall+0x44/0x108 [ 60.320334] el0_svc_common.constprop.0+0xcc/0xf0 [ 60.325038] do_el0_svc+0x2c/0xb8 [ 60.328351] el0_svc+0x2c/0x88 [ 60.331406] el0t_64_sync_handler+0xb8/0xc0 [ 60.335587] el0t_64_sync+0x18c/0x190 [ 60.339251] Code: 52800013 d2e00414 35fff45c d503201f (d4210000) [ 60.345344] ---[ end trace 0000000000000000 ]--- To fix it, this patch adds a checking the payload length if it is zero. Fixes: 343dc693f7b7 ("misc: pci_endpoint_test: Prevent some integer overflows") Cc: stable Signed-off-by: Shunsuke Mie Link: https://lore.kernel.org/r/20220907020100.122588-2-mie@igel.co.jp Signed-off-by: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- drivers/misc/pci_endpoint_test.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -335,6 +335,11 @@ static bool pci_endpoint_test_msi_irq(st static int pci_endpoint_test_validate_xfer_params(struct device *dev, struct pci_endpoint_test_xfer_param *param, size_t alignment) { + if (!param->size) { + dev_dbg(dev, "Data size is zero\n"); + return -EINVAL; + } + if (param->size > SIZE_MAX - alignment) { dev_dbg(dev, "Maximum transfer data size exceeded\n"); return -EINVAL;