--- /dev/null
+From 1f245e6caab49fa19003309ef6337742627bcab8 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 11 Dec 2023 21:43:52 +0000
+Subject: afs: Fix refcount underflow from error handling race
+
+From: David Howells <dhowells@redhat.com>
+
+[ Upstream commit 52bf9f6c09fca8c74388cd41cc24e5d1bff812a9 ]
+
+If an AFS cell that has an unreachable (eg. ENETUNREACH) server listed (VL
+server or fileserver), an asynchronous probe to one of its addresses may
+fail immediately because sendmsg() returns an error. When this happens, a
+refcount underflow can happen if certain events hit a very small window.
+
+The way this occurs is:
+
+ (1) There are two levels of "call" object, the afs_call and the
+ rxrpc_call. Each of them can be transitioned to a "completed" state
+ in the event of success or failure.
+
+ (2) Asynchronous afs_calls are self-referential whilst they are active to
+ prevent them from evaporating when they're not being processed. This
+ reference is disposed of when the afs_call is completed.
+
+ Note that an afs_call may only be completed once; once completed
+ completing it again will do nothing.
+
+ (3) When a call transmission is made, the app-side rxrpc code queues a Tx
+ buffer for the rxrpc I/O thread to transmit. The I/O thread invokes
+ sendmsg() to transmit it - and in the case of failure, it transitions
+ the rxrpc_call to the completed state.
+
+ (4) When an rxrpc_call is completed, the app layer is notified. In this
+ case, the app is kafs and it schedules a work item to process events
+ pertaining to an afs_call.
+
+ (5) When the afs_call event processor is run, it goes down through the
+ RPC-specific handler to afs_extract_data() to retrieve data from rxrpc
+ - and, in this case, it picks up the error from the rxrpc_call and
+ returns it.
+
+ The error is then propagated to the afs_call and that is completed
+ too. At this point the self-reference is released.
+
+ (6) If the rxrpc I/O thread manages to complete the rxrpc_call within the
+ window between rxrpc_send_data() queuing the request packet and
+ checking for call completion on the way out, then
+ rxrpc_kernel_send_data() will return the error from sendmsg() to the
+ app.
+
+ (7) Then afs_make_call() will see an error and will jump to the error
+ handling path which will attempt to clean up the afs_call.
+
+ (8) The problem comes when the error handling path in afs_make_call()
+ tries to unconditionally drop an async afs_call's self-reference.
+ This self-reference, however, may already have been dropped by
+ afs_extract_data() completing the afs_call
+
+ (9) The refcount underflows when we return to afs_do_probe_vlserver() and
+ that tries to drop its reference on the afs_call.
+
+Fix this by making afs_make_call() attempt to complete the afs_call rather
+than unconditionally putting it. That way, if afs_extract_data() manages
+to complete the call first, afs_make_call() won't do anything.
+
+The bug can be forced by making do_udp_sendmsg() return -ENETUNREACH and
+sticking an msleep() in rxrpc_send_data() after the 'success:' label to
+widen the race window.
+
+The error message looks something like:
+
+ refcount_t: underflow; use-after-free.
+ WARNING: CPU: 3 PID: 720 at lib/refcount.c:28 refcount_warn_saturate+0xba/0x110
+ ...
+ RIP: 0010:refcount_warn_saturate+0xba/0x110
+ ...
+ afs_put_call+0x1dc/0x1f0 [kafs]
+ afs_fs_get_capabilities+0x8b/0xe0 [kafs]
+ afs_fs_probe_fileserver+0x188/0x1e0 [kafs]
+ afs_lookup_server+0x3bf/0x3f0 [kafs]
+ afs_alloc_server_list+0x130/0x2e0 [kafs]
+ afs_create_volume+0x162/0x400 [kafs]
+ afs_get_tree+0x266/0x410 [kafs]
+ vfs_get_tree+0x25/0xc0
+ fc_mount+0xe/0x40
+ afs_d_automount+0x1b3/0x390 [kafs]
+ __traverse_mounts+0x8f/0x210
+ step_into+0x340/0x760
+ path_openat+0x13a/0x1260
+ do_filp_open+0xaf/0x160
+ do_sys_openat2+0xaf/0x170
+
+or something like:
+
+ refcount_t: underflow; use-after-free.
+ ...
+ RIP: 0010:refcount_warn_saturate+0x99/0xda
+ ...
+ afs_put_call+0x4a/0x175
+ afs_send_vl_probes+0x108/0x172
+ afs_select_vlserver+0xd6/0x311
+ afs_do_cell_detect_alias+0x5e/0x1e9
+ afs_cell_detect_alias+0x44/0x92
+ afs_validate_fc+0x9d/0x134
+ afs_get_tree+0x20/0x2e6
+ vfs_get_tree+0x1d/0xc9
+ fc_mount+0xe/0x33
+ afs_d_automount+0x48/0x9d
+ __traverse_mounts+0xe0/0x166
+ step_into+0x140/0x274
+ open_last_lookups+0x1c1/0x1df
+ path_openat+0x138/0x1c3
+ do_filp_open+0x55/0xb4
+ do_sys_openat2+0x6c/0xb6
+
+Fixes: 34fa47612bfe ("afs: Fix race in async call refcounting")
+Reported-by: Bill MacAllister <bill@ca-zephyr.org>
+Closes: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1052304
+Suggested-by: Jeffrey E Altman <jaltman@auristor.com>
+Signed-off-by: David Howells <dhowells@redhat.com>
+Reviewed-by: Jeffrey Altman <jaltman@auristor.com>
+cc: Marc Dionne <marc.dionne@auristor.com>
+cc: linux-afs@lists.infradead.org
+Link: https://lore.kernel.org/r/2633992.1702073229@warthog.procyon.org.uk/ # v1
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/afs/rxrpc.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/fs/afs/rxrpc.c b/fs/afs/rxrpc.c
+index 535d28b44bca3..1820b53657a6c 100644
+--- a/fs/afs/rxrpc.c
++++ b/fs/afs/rxrpc.c
+@@ -491,7 +491,7 @@ void afs_make_call(struct afs_addr_cursor *ac, struct afs_call *call, gfp_t gfp)
+ if (call->async) {
+ if (cancel_work_sync(&call->async_work))
+ afs_put_call(call);
+- afs_put_call(call);
++ afs_set_call_complete(call, ret, 0);
+ }
+
+ ac->error = ret;
+--
+2.43.0
+
--- /dev/null
+From 766105a772d0d020d63321fe804b9fbee73ade5c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 12 Dec 2023 15:31:48 +0200
+Subject: HID: lenovo: Restrict detection of patched firmware only to USB
+ cptkbd
+
+From: Mikhail Khvainitski <me@khvoinitsky.org>
+
+[ Upstream commit 43527a0094c10dfbf0d5a2e7979395a38de3ff65 ]
+
+Commit 46a0a2c96f0f ("HID: lenovo: Detect quirk-free fw on cptkbd and
+stop applying workaround") introduced a regression for ThinkPad
+TrackPoint Keyboard II which has similar quirks to cptkbd (so it uses
+the same workarounds) but slightly different so that there are
+false-positives during detecting well-behaving firmware. This commit
+restricts detecting well-behaving firmware to the only model which
+known to have one and have stable enough quirks to not cause
+false-positives.
+
+Fixes: 46a0a2c96f0f ("HID: lenovo: Detect quirk-free fw on cptkbd and stop applying workaround")
+Link: https://lore.kernel.org/linux-input/ZXRiiPsBKNasioqH@jekhomev/
+Link: https://bbs.archlinux.org/viewtopic.php?pid=2135468#p2135468
+Signed-off-by: Mikhail Khvainitski <me@khvoinitsky.org>
+Tested-by: Yauhen Kharuzhy <jekhor@gmail.com>
+Signed-off-by: Jiri Kosina <jkosina@suse.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/hid/hid-lenovo.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/hid/hid-lenovo.c b/drivers/hid/hid-lenovo.c
+index 71f7b0d539df5..249af8d26fe78 100644
+--- a/drivers/hid/hid-lenovo.c
++++ b/drivers/hid/hid-lenovo.c
+@@ -489,7 +489,8 @@ static int lenovo_event_cptkbd(struct hid_device *hdev,
+ * so set middlebutton_state to 3
+ * to never apply workaround anymore
+ */
+- if (cptkbd_data->middlebutton_state == 1 &&
++ if (hdev->product == USB_DEVICE_ID_LENOVO_CUSBKBD &&
++ cptkbd_data->middlebutton_state == 1 &&
+ usage->type == EV_REL &&
+ (usage->code == REL_X || usage->code == REL_Y)) {
+ cptkbd_data->middlebutton_state = 3;
+--
+2.43.0
+
--- /dev/null
+From 0218f1372ad4887ffc6df3e68d92b55b9d12a11c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 17 Apr 2023 12:55:51 -0400
+Subject: IMA: use vfs_getattr_nosec to get the i_version
+
+From: Jeff Layton <jlayton@kernel.org>
+
+[ Upstream commit db1d1e8b9867aae5c3e61ad7859abfcc4a6fd6c7 ]
+
+IMA currently accesses the i_version out of the inode directly when it
+does a measurement. This is fine for most simple filesystems, but can be
+problematic with more complex setups (e.g. overlayfs).
+
+Make IMA instead call vfs_getattr_nosec to get this info. This allows
+the filesystem to determine whether and how to report the i_version, and
+should allow IMA to work properly with a broader class of filesystems in
+the future.
+
+Reported-and-Tested-by: Stefan Berger <stefanb@linux.ibm.com>
+Reviewed-by: Christian Brauner <brauner@kernel.org>
+Signed-off-by: Jeff Layton <jlayton@kernel.org>
+Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ security/integrity/ima/ima_api.c | 9 ++++++---
+ security/integrity/ima/ima_main.c | 12 ++++++++----
+ 2 files changed, 14 insertions(+), 7 deletions(-)
+
+diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
+index 70efd4aa1bd11..cf24e441a9fa7 100644
+--- a/security/integrity/ima/ima_api.c
++++ b/security/integrity/ima/ima_api.c
+@@ -13,7 +13,6 @@
+ #include <linux/fs.h>
+ #include <linux/xattr.h>
+ #include <linux/evm.h>
+-#include <linux/iversion.h>
+
+ #include "ima.h"
+
+@@ -214,10 +213,11 @@ int ima_collect_measurement(struct integrity_iint_cache *iint,
+ struct inode *inode = file_inode(file);
+ struct inode *real_inode = d_real_inode(file_dentry(file));
+ const char *filename = file->f_path.dentry->d_name.name;
++ struct kstat stat;
+ int result = 0;
+ int length;
+ void *tmpbuf;
+- u64 i_version;
++ u64 i_version = 0;
+ struct {
+ struct ima_digest_data hdr;
+ char digest[IMA_MAX_DIGEST_SIZE];
+@@ -239,7 +239,10 @@ int ima_collect_measurement(struct integrity_iint_cache *iint,
+ * which do not support i_version, support is limited to an initial
+ * measurement/appraisal/audit.
+ */
+- i_version = inode_query_iversion(inode);
++ result = vfs_getattr_nosec(&file->f_path, &stat, STATX_CHANGE_COOKIE,
++ AT_STATX_SYNC_AS_STAT);
++ if (!result && (stat.result_mask & STATX_CHANGE_COOKIE))
++ i_version = stat.change_cookie;
+ hash.hdr.algo = algo;
+
+ /* Initialize hash digest to 0's in case of failure */
+diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
+index 8e0fe0ce61646..b2e83245d17aa 100644
+--- a/security/integrity/ima/ima_main.c
++++ b/security/integrity/ima/ima_main.c
+@@ -24,7 +24,6 @@
+ #include <linux/slab.h>
+ #include <linux/xattr.h>
+ #include <linux/ima.h>
+-#include <linux/iversion.h>
+ #include <linux/fs.h>
+ #include <linux/iversion.h>
+
+@@ -159,11 +158,16 @@ static void ima_check_last_writer(struct integrity_iint_cache *iint,
+
+ mutex_lock(&iint->mutex);
+ if (atomic_read(&inode->i_writecount) == 1) {
++ struct kstat stat;
++
+ update = test_and_clear_bit(IMA_UPDATE_XATTR,
+ &iint->atomic_flags);
+- if (!IS_I_VERSION(inode) ||
+- !inode_eq_iversion(inode, iint->version) ||
+- (iint->flags & IMA_NEW_FILE)) {
++ if ((iint->flags & IMA_NEW_FILE) ||
++ vfs_getattr_nosec(&file->f_path, &stat,
++ STATX_CHANGE_COOKIE,
++ AT_STATX_SYNC_AS_STAT) ||
++ !(stat.result_mask & STATX_CHANGE_COOKIE) ||
++ stat.change_cookie != iint->version) {
+ iint->flags &= ~(IMA_DONE_MASK | IMA_NEW_FILE);
+ iint->measured_pcrs = 0;
+ if (update)
+--
+2.43.0
+
--- /dev/null
+From 28e8a9b60bf2f7a4888fbe70a344153a2f35a87c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 17 May 2022 14:05:39 -0400
+Subject: net: usb: r8152: Add in new Devices that are supported for
+ Mac-Passthru
+
+From: David Ober <dober6023@gmail.com>
+
+[ Upstream commit f01cdcf891a569dee187a5de0c25cd5766151524 ]
+
+Lenovo Thunderbolt 4 Dock, and other Lenovo USB Docks are using the
+original Realtek USB ethernet Vendor and Product IDs
+If the Network device is Realtek verify that it is on a Lenovo USB hub
+before enabling the passthru feature
+
+This also adds in the device IDs for the Lenovo USB Dongle and one other
+USB-C dock
+
+V2 fix formating of code
+V3 remove Generic define for Device ID 0x8153 and change it to use value
+V4 rearrange defines and case statement to put them in better order
+v5 create helper function to do the testing work as suggested
+
+Signed-off-by: David Ober <dober6023@gmail.com>
+Link: https://lore.kernel.org/r/20220517180539.25839-1-dober6023@gmail.com
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/usb/r8152.c | 33 ++++++++++++++++++++++++++-------
+ 1 file changed, 26 insertions(+), 7 deletions(-)
+
+diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
+index ce47a111fe62b..bcfd51373b53c 100644
+--- a/drivers/net/usb/r8152.c
++++ b/drivers/net/usb/r8152.c
+@@ -697,7 +697,9 @@ enum rtl8152_flags {
+ #define VENDOR_ID_TPLINK 0x2357
+
+ #define DEVICE_ID_THINKPAD_THUNDERBOLT3_DOCK_GEN2 0x3082
++#define DEVICE_ID_THINKPAD_USB_C_DONGLE 0x720c
+ #define DEVICE_ID_THINKPAD_USB_C_DOCK_GEN2 0xa387
++#define DEVICE_ID_THINKPAD_USB_C_DOCK_GEN3 0x3062
+
+ #define MCU_TYPE_PLA 0x0100
+ #define MCU_TYPE_USB 0x0000
+@@ -6694,6 +6696,29 @@ static u8 rtl_get_version(struct usb_interface *intf)
+ return version;
+ }
+
++static bool rtl8152_supports_lenovo_macpassthru(struct usb_device *udev)
++{
++ int parent_vendor_id = le16_to_cpu(udev->parent->descriptor.idVendor);
++ int product_id = le16_to_cpu(udev->descriptor.idProduct);
++ int vendor_id = le16_to_cpu(udev->descriptor.idVendor);
++
++ if (vendor_id == VENDOR_ID_LENOVO) {
++ switch (product_id) {
++ case DEVICE_ID_THINKPAD_THUNDERBOLT3_DOCK_GEN2:
++ case DEVICE_ID_THINKPAD_USB_C_DOCK_GEN2:
++ case DEVICE_ID_THINKPAD_USB_C_DOCK_GEN3:
++ case DEVICE_ID_THINKPAD_USB_C_DONGLE:
++ return 1;
++ }
++ } else if (vendor_id == VENDOR_ID_REALTEK && parent_vendor_id == VENDOR_ID_LENOVO) {
++ switch (product_id) {
++ case 0x8153:
++ return 1;
++ }
++ }
++ return 0;
++}
++
+ static int rtl8152_probe(struct usb_interface *intf,
+ const struct usb_device_id *id)
+ {
+@@ -6771,13 +6796,7 @@ static int rtl8152_probe(struct usb_interface *intf,
+ netdev->hw_features &= ~NETIF_F_RXCSUM;
+ }
+
+- if (le16_to_cpu(udev->descriptor.idVendor) == VENDOR_ID_LENOVO) {
+- switch (le16_to_cpu(udev->descriptor.idProduct)) {
+- case DEVICE_ID_THINKPAD_THUNDERBOLT3_DOCK_GEN2:
+- case DEVICE_ID_THINKPAD_USB_C_DOCK_GEN2:
+- tp->lenovo_macpassthru = 1;
+- }
+- }
++ tp->lenovo_macpassthru = rtl8152_supports_lenovo_macpassthru(udev);
+
+ if (le16_to_cpu(udev->descriptor.bcdDevice) == 0x3011 && udev->serial &&
+ (!strcmp(udev->serial, "000001000000") ||
+--
+2.43.0
+
--- /dev/null
+From 9ed7204d762ad7944b30c58959ef736222828ec6 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 4 Dec 2023 12:29:54 +0100
+Subject: netfilter: nf_tables: fix 'exist' matching on bigendian arches
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Florian Westphal <fw@strlen.de>
+
+[ Upstream commit 63331e37fb227e796894b31d713697612c8dee7f ]
+
+Maze reports "tcp option fastopen exists" fails to match on
+OpenWrt 22.03.5, r20134-5f15225c1e (5.10.176) router.
+
+"tcp option fastopen exists" translates to:
+inet
+ [ exthdr load tcpopt 1b @ 34 + 0 present => reg 1 ]
+ [ cmp eq reg 1 0x00000001 ]
+
+.. but existing nft userspace generates a 1-byte compare.
+
+On LSB (x86), "*reg32 = 1" is identical to nft_reg_store8(reg32, 1), but
+not on MSB, which will place the 1 last. IOW, on bigendian aches the cmp8
+is awalys false.
+
+Make sure we store this in a consistent fashion, so existing userspace
+will also work on MSB (bigendian).
+
+Regardless of this patch we can also change nft userspace to generate
+'reg32 == 0' and 'reg32 != 0' instead of u8 == 0 // u8 == 1 when
+adding 'option x missing/exists' expressions as well.
+
+Fixes: 3c1fece8819e ("netfilter: nft_exthdr: Allow checking TCP option presence, too")
+Fixes: b9f9a485fb0e ("netfilter: nft_exthdr: add boolean DCCP option matching")
+Fixes: 055c4b34b94f ("netfilter: nft_fib: Support existence check")
+Reported-by: Maciej Żenczykowski <zenczykowski@gmail.com>
+Closes: https://lore.kernel.org/netfilter-devel/CAHo-OozyEqHUjL2-ntATzeZOiuftLWZ_HU6TOM_js4qLfDEAJg@mail.gmail.com/
+Signed-off-by: Florian Westphal <fw@strlen.de>
+Acked-by: Phil Sutter <phil@nwl.cc>
+Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/netfilter/nft_exthdr.c | 2 +-
+ net/netfilter/nft_fib.c | 8 ++++++--
+ 2 files changed, 7 insertions(+), 3 deletions(-)
+
+diff --git a/net/netfilter/nft_exthdr.c b/net/netfilter/nft_exthdr.c
+index cb69a299f10c5..c9f89f035ccff 100644
+--- a/net/netfilter/nft_exthdr.c
++++ b/net/netfilter/nft_exthdr.c
+@@ -214,7 +214,7 @@ static void nft_exthdr_tcp_eval(const struct nft_expr *expr,
+
+ offset = i + priv->offset;
+ if (priv->flags & NFT_EXTHDR_F_PRESENT) {
+- *dest = 1;
++ nft_reg_store8(dest, 1);
+ } else {
+ if (priv->len % NFT_REG32_SIZE)
+ dest[priv->len / NFT_REG32_SIZE] = 0;
+diff --git a/net/netfilter/nft_fib.c b/net/netfilter/nft_fib.c
+index b10ce732b337c..1fd4b2054e8f7 100644
+--- a/net/netfilter/nft_fib.c
++++ b/net/netfilter/nft_fib.c
+@@ -140,11 +140,15 @@ void nft_fib_store_result(void *reg, const struct nft_fib *priv,
+ switch (priv->result) {
+ case NFT_FIB_RESULT_OIF:
+ index = dev ? dev->ifindex : 0;
+- *dreg = (priv->flags & NFTA_FIB_F_PRESENT) ? !!index : index;
++ if (priv->flags & NFTA_FIB_F_PRESENT)
++ nft_reg_store8(dreg, !!index);
++ else
++ *dreg = index;
++
+ break;
+ case NFT_FIB_RESULT_OIFNAME:
+ if (priv->flags & NFTA_FIB_F_PRESENT)
+- *dreg = !!dev;
++ nft_reg_store8(dreg, !!dev);
+ else
+ strncpy(reg, dev ? dev->name : "", IFNAMSIZ);
+ break;
+--
+2.43.0
+
--- /dev/null
+From 6a36f9afdd16e89f3f673ad693020351b96b6bc3 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 24 Aug 2022 21:14:36 +0200
+Subject: r8152: add PID for the Lenovo OneLink+ Dock
+
+From: Jean-Francois Le Fillatre <jflf_kernel@gmx.com>
+
+[ Upstream commit 76d7df9406a1d2faec6eaaa1d835a1dbc1d49cec ]
+
+The Lenovo OneLink+ Dock contains an RTL8153 controller that behaves as
+a broken CDC device by default. Add the custom Lenovo PID to the r8152
+driver to support it properly.
+
+Also, systems compatible with this dock provide a BIOS option to enable
+MAC address passthrough (as per Lenovo document "ThinkPad Docking
+Solutions 2017"). Add the custom PID to the MAC passthrough list too.
+
+Tested on a ThinkPad 13 1st gen with the expected results:
+
+passthrough disabled: Invalid header when reading pass-thru MAC addr
+passthrough enabled: Using pass-thru MAC addr XX:XX:XX:XX:XX:XX
+
+Signed-off-by: Jean-Francois Le Fillatre <jflf_kernel@gmx.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/usb/r8152.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
+index bcfd51373b53c..02bafe49c6c1a 100644
+--- a/drivers/net/usb/r8152.c
++++ b/drivers/net/usb/r8152.c
+@@ -696,6 +696,7 @@ enum rtl8152_flags {
+ #define VENDOR_ID_NVIDIA 0x0955
+ #define VENDOR_ID_TPLINK 0x2357
+
++#define DEVICE_ID_THINKPAD_ONELINK_PLUS_DOCK 0x3054
+ #define DEVICE_ID_THINKPAD_THUNDERBOLT3_DOCK_GEN2 0x3082
+ #define DEVICE_ID_THINKPAD_USB_C_DONGLE 0x720c
+ #define DEVICE_ID_THINKPAD_USB_C_DOCK_GEN2 0xa387
+@@ -6704,6 +6705,7 @@ static bool rtl8152_supports_lenovo_macpassthru(struct usb_device *udev)
+
+ if (vendor_id == VENDOR_ID_LENOVO) {
+ switch (product_id) {
++ case DEVICE_ID_THINKPAD_ONELINK_PLUS_DOCK:
+ case DEVICE_ID_THINKPAD_THUNDERBOLT3_DOCK_GEN2:
+ case DEVICE_ID_THINKPAD_USB_C_DOCK_GEN2:
+ case DEVICE_ID_THINKPAD_USB_C_DOCK_GEN3:
+@@ -6923,6 +6925,7 @@ static const struct usb_device_id rtl8152_table[] = {
+ REALTEK_USB_DEVICE(VENDOR_ID_MICROSOFT, 0x0927),
+ REALTEK_USB_DEVICE(VENDOR_ID_SAMSUNG, 0xa101),
+ REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x304f),
++ REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3054),
+ REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3062),
+ REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3069),
+ REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3082),
+--
+2.43.0
+
--- /dev/null
+From e6b84ca7d14f7686afaebd9ce187f221559be94a Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 6 Jan 2023 17:07:38 +0100
+Subject: r8152: add USB device driver for config selection
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Bjørn Mork <bjorn@mork.no>
+
+[ Upstream commit ec51fbd1b8a2bca2948dede99c14ec63dc57ff6b ]
+
+Subclassing the generic USB device driver to override the
+default configuration selection regardless of matching interface
+drivers.
+
+The r815x family devices expose a vendor specific function which
+the r8152 interface driver wants to handle. This is the preferred
+device mode. Additionally one or more USB class functions are
+usually supported for hosts lacking a vendor specific driver. The
+choice is USB configuration based, with one alternate function per
+configuration.
+
+Example device with both NCM and ECM alternate cfgs:
+
+T: Bus=02 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 4 Spd=5000 MxCh= 0
+D: Ver= 3.20 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 9 #Cfgs= 3
+P: Vendor=0bda ProdID=8156 Rev=31.00
+S: Manufacturer=Realtek
+S: Product=USB 10/100/1G/2.5G LAN
+S: SerialNumber=001000001
+C:* #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr=256mA
+I:* If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=00 Driver=r8152
+E: Ad=81(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
+E: Ad=02(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
+E: Ad=83(I) Atr=03(Int.) MxPS= 2 Ivl=128ms
+C: #Ifs= 2 Cfg#= 2 Atr=a0 MxPwr=256mA
+I: If#= 0 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=0d Prot=00 Driver=
+E: Ad=83(I) Atr=03(Int.) MxPS= 16 Ivl=128ms
+I: If#= 1 Alt= 0 #EPs= 0 Cls=0a(data ) Sub=00 Prot=01 Driver=
+I: If#= 1 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=01 Driver=
+E: Ad=81(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
+E: Ad=02(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
+C: #Ifs= 2 Cfg#= 3 Atr=a0 MxPwr=256mA
+I: If#= 0 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=06 Prot=00 Driver=
+E: Ad=83(I) Atr=03(Int.) MxPS= 16 Ivl=128ms
+I: If#= 1 Alt= 0 #EPs= 0 Cls=0a(data ) Sub=00 Prot=00 Driver=
+I: If#= 1 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=
+E: Ad=81(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
+E: Ad=02(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
+
+A problem with this is that Linux will prefer class functions over
+vendor specific functions. Using the above example, Linux defaults
+to cfg #2, running the device in a sub-optimal NCM mode.
+
+Previously we've attempted to work around the problem by
+blacklisting the devices in the ECM class driver "cdc_ether", and
+matching on the ECM class function in the vendor specific interface
+driver. The latter has been used to switch back to the vendor
+specific configuration when the driver is probed for a class
+function.
+
+This workaround has several issues;
+- class driver blacklists is additional maintanence cruft in an
+ unrelated driver
+- class driver blacklists prevents users from optionally running
+ the devices in class mode
+- each device needs double match entries in the vendor driver
+- the initial probing as a class function slows down device
+ discovery
+
+Now these issues have become even worse with the introduction of
+firmware supporting both NCM and ECM, where NCM ends up as the
+default mode in Linux. To use the same workaround, we now have
+to blacklist the devices in to two different class drivers and
+add yet another match entry to the vendor specific driver.
+
+This patch implements an alternative workaround strategy -
+independent of the interface drivers. It avoids adding a
+blacklist to the cdc_ncm driver and will let us remove the
+existing blacklist from the cdc_ether driver.
+
+As an additional bonus, removing the blacklists allow users to
+select one of the other device modes if wanted.
+
+Signed-off-by: Bjørn Mork <bjorn@mork.no>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/usb/r8152.c | 107 +++++++++++++++++++++++++++++-----------
+ 1 file changed, 78 insertions(+), 29 deletions(-)
+
+diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
+index 02bafe49c6c1a..5f212b8752f4d 100644
+--- a/drivers/net/usb/r8152.c
++++ b/drivers/net/usb/r8152.c
+@@ -6733,6 +6733,9 @@ static int rtl8152_probe(struct usb_interface *intf,
+ if (version == RTL_VER_UNKNOWN)
+ return -ENODEV;
+
++ if (intf->cur_altsetting->desc.bInterfaceClass != USB_CLASS_VENDOR_SPEC)
++ return -ENODEV;
++
+ if (!rtl_vendor_mode(intf))
+ return -ENODEV;
+
+@@ -6904,39 +6907,31 @@ static void rtl8152_disconnect(struct usb_interface *intf)
+ }
+ }
+
+-#define REALTEK_USB_DEVICE(vend, prod) { \
+- USB_DEVICE_INTERFACE_CLASS(vend, prod, USB_CLASS_VENDOR_SPEC), \
+-}, \
+-{ \
+- USB_DEVICE_AND_INTERFACE_INFO(vend, prod, USB_CLASS_COMM, \
+- USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), \
+-}
+-
+ /* table of devices that work with this driver */
+ static const struct usb_device_id rtl8152_table[] = {
+ /* Realtek */
+- REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8050),
+- REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8152),
+- REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8153),
++ { USB_DEVICE(VENDOR_ID_REALTEK, 0x8050) },
++ { USB_DEVICE(VENDOR_ID_REALTEK, 0x8152) },
++ { USB_DEVICE(VENDOR_ID_REALTEK, 0x8153) },
+
+ /* Microsoft */
+- REALTEK_USB_DEVICE(VENDOR_ID_MICROSOFT, 0x07ab),
+- REALTEK_USB_DEVICE(VENDOR_ID_MICROSOFT, 0x07c6),
+- REALTEK_USB_DEVICE(VENDOR_ID_MICROSOFT, 0x0927),
+- REALTEK_USB_DEVICE(VENDOR_ID_SAMSUNG, 0xa101),
+- REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x304f),
+- REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3054),
+- REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3062),
+- REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3069),
+- REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3082),
+- REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x7205),
+- REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x720c),
+- REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x7214),
+- REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x721e),
+- REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0xa387),
+- REALTEK_USB_DEVICE(VENDOR_ID_LINKSYS, 0x0041),
+- REALTEK_USB_DEVICE(VENDOR_ID_NVIDIA, 0x09ff),
+- REALTEK_USB_DEVICE(VENDOR_ID_TPLINK, 0x0601),
++ { USB_DEVICE(VENDOR_ID_MICROSOFT, 0x07ab) },
++ { USB_DEVICE(VENDOR_ID_MICROSOFT, 0x07c6) },
++ { USB_DEVICE(VENDOR_ID_MICROSOFT, 0x0927) },
++ { USB_DEVICE(VENDOR_ID_SAMSUNG, 0xa101) },
++ { USB_DEVICE(VENDOR_ID_LENOVO, 0x304f) },
++ { USB_DEVICE(VENDOR_ID_LENOVO, 0x3054) },
++ { USB_DEVICE(VENDOR_ID_LENOVO, 0x3062) },
++ { USB_DEVICE(VENDOR_ID_LENOVO, 0x3069) },
++ { USB_DEVICE(VENDOR_ID_LENOVO, 0x3082) },
++ { USB_DEVICE(VENDOR_ID_LENOVO, 0x7205) },
++ { USB_DEVICE(VENDOR_ID_LENOVO, 0x720c) },
++ { USB_DEVICE(VENDOR_ID_LENOVO, 0x7214) },
++ { USB_DEVICE(VENDOR_ID_LENOVO, 0x721e) },
++ { USB_DEVICE(VENDOR_ID_LENOVO, 0xa387) },
++ { USB_DEVICE(VENDOR_ID_LINKSYS, 0x0041) },
++ { USB_DEVICE(VENDOR_ID_NVIDIA, 0x09ff) },
++ { USB_DEVICE(VENDOR_ID_TPLINK, 0x0601) },
+ {}
+ };
+
+@@ -6956,7 +6951,61 @@ static struct usb_driver rtl8152_driver = {
+ .disable_hub_initiated_lpm = 1,
+ };
+
+-module_usb_driver(rtl8152_driver);
++static int rtl8152_cfgselector_probe(struct usb_device *udev)
++{
++ struct usb_host_config *c;
++ int i, num_configs;
++
++ /* The vendor mode is not always config #1, so to find it out. */
++ c = udev->config;
++ num_configs = udev->descriptor.bNumConfigurations;
++ for (i = 0; i < num_configs; (i++, c++)) {
++ struct usb_interface_descriptor *desc = NULL;
++
++ if (!c->desc.bNumInterfaces)
++ continue;
++ desc = &c->intf_cache[0]->altsetting->desc;
++ if (desc->bInterfaceClass == USB_CLASS_VENDOR_SPEC)
++ break;
++ }
++
++ if (i == num_configs)
++ return -ENODEV;
++
++ if (usb_set_configuration(udev, c->desc.bConfigurationValue)) {
++ dev_err(&udev->dev, "Failed to set configuration %d\n",
++ c->desc.bConfigurationValue);
++ return -ENODEV;
++ }
++
++ return 0;
++}
++
++static struct usb_device_driver rtl8152_cfgselector_driver = {
++ .name = MODULENAME "-cfgselector",
++ .probe = rtl8152_cfgselector_probe,
++ .id_table = rtl8152_table,
++ .generic_subclass = 1,
++};
++
++static int __init rtl8152_driver_init(void)
++{
++ int ret;
++
++ ret = usb_register_device_driver(&rtl8152_cfgselector_driver, THIS_MODULE);
++ if (ret)
++ return ret;
++ return usb_register(&rtl8152_driver);
++}
++
++static void __exit rtl8152_driver_exit(void)
++{
++ usb_deregister(&rtl8152_driver);
++ usb_deregister_device_driver(&rtl8152_cfgselector_driver);
++}
++
++module_init(rtl8152_driver_init);
++module_exit(rtl8152_driver_exit);
+
+ MODULE_AUTHOR(DRIVER_AUTHOR);
+ MODULE_DESCRIPTION(DRIVER_DESC);
+--
+2.43.0
+
--- /dev/null
+From 0299d1b30eda034d7d78e10303a8556c8d4e297c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 2 Dec 2023 17:17:12 -0800
+Subject: r8152: add vendor/device ID pair for ASUS USB-C2500
+
+From: Kelly Kane <kelly@hawknetworks.com>
+
+[ Upstream commit 7037d95a047cd89b1f680eed253c6ab586bef1ed ]
+
+The ASUS USB-C2500 is an RTL8156 based 2.5G Ethernet controller.
+
+Add the vendor and product ID values to the driver. This makes Ethernet
+work with the adapter.
+
+Signed-off-by: Kelly Kane <kelly@hawknetworks.com>
+Link: https://lore.kernel.org/r/20231203011712.6314-1-kelly@hawknetworks.com
+Signed-off-by: Paolo Abeni <pabeni@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/usb/r8152.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
+index 2ed73ae2bea3d..f0b781341e185 100644
+--- a/drivers/net/usb/r8152.c
++++ b/drivers/net/usb/r8152.c
+@@ -696,6 +696,7 @@ enum rtl8152_flags {
+ #define VENDOR_ID_NVIDIA 0x0955
+ #define VENDOR_ID_TPLINK 0x2357
+ #define VENDOR_ID_DLINK 0x2001
++#define VENDOR_ID_ASUS 0x0b05
+
+ #define DEVICE_ID_THINKPAD_ONELINK_PLUS_DOCK 0x3054
+ #define DEVICE_ID_THINKPAD_THUNDERBOLT3_DOCK_GEN2 0x3082
+@@ -6934,6 +6935,7 @@ static const struct usb_device_id rtl8152_table[] = {
+ { USB_DEVICE(VENDOR_ID_NVIDIA, 0x09ff) },
+ { USB_DEVICE(VENDOR_ID_TPLINK, 0x0601) },
+ { USB_DEVICE(VENDOR_ID_DLINK, 0xb301) },
++ { USB_DEVICE(VENDOR_ID_ASUS, 0x1976) },
+ {}
+ };
+
+--
+2.43.0
+
--- /dev/null
+From 6b532e620ea785015abf89d2f0249d3d36cb0c5c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 26 Aug 2023 01:05:50 +0200
+Subject: r8152: add vendor/device ID pair for D-Link DUB-E250
+
+From: Antonio Napolitano <anton@polit.no>
+
+[ Upstream commit 72f93a3136ee18fd59fa6579f84c07e93424681e ]
+
+The D-Link DUB-E250 is an RTL8156 based 2.5G Ethernet controller.
+
+Add the vendor and product ID values to the driver. This makes Ethernet
+work with the adapter.
+
+Signed-off-by: Antonio Napolitano <anton@polit.no>
+Link: https://lore.kernel.org/r/CV200KJEEUPC.WPKAHXCQJ05I@mercurius
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/usb/r8152.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
+index 5f212b8752f4d..2ed73ae2bea3d 100644
+--- a/drivers/net/usb/r8152.c
++++ b/drivers/net/usb/r8152.c
+@@ -695,6 +695,7 @@ enum rtl8152_flags {
+ #define VENDOR_ID_LINKSYS 0x13b1
+ #define VENDOR_ID_NVIDIA 0x0955
+ #define VENDOR_ID_TPLINK 0x2357
++#define VENDOR_ID_DLINK 0x2001
+
+ #define DEVICE_ID_THINKPAD_ONELINK_PLUS_DOCK 0x3054
+ #define DEVICE_ID_THINKPAD_THUNDERBOLT3_DOCK_GEN2 0x3082
+@@ -6932,6 +6933,7 @@ static const struct usb_device_id rtl8152_table[] = {
+ { USB_DEVICE(VENDOR_ID_LINKSYS, 0x0041) },
+ { USB_DEVICE(VENDOR_ID_NVIDIA, 0x09ff) },
+ { USB_DEVICE(VENDOR_ID_TPLINK, 0x0601) },
++ { USB_DEVICE(VENDOR_ID_DLINK, 0xb301) },
+ {}
+ };
+
+--
+2.43.0
+
--- /dev/null
+From c103c1d2c27716211bcd4d8cb5b9443dcb093490 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 23 Apr 2021 17:44:55 +0800
+Subject: r8152: redefine REALTEK_USB_DEVICE macro
+
+From: Hayes Wang <hayeswang@realtek.com>
+
+[ Upstream commit 55319eeb5bbcd3c73366de92ff224bd62325a68d ]
+
+Redefine REALTEK_USB_DEVICE macro with USB_DEVICE_INTERFACE_CLASS and
+USB_DEVICE_AND_INTERFACE_INFO to simply the code.
+
+Although checkpatch.pl shows the following error, it is more readable.
+
+ ERROR: Macros with complex values should be enclosed in parentheses
+
+Signed-off-by: Hayes Wang <hayeswang@realtek.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/usb/r8152.c | 60 +++++++++++++++++++----------------------
+ 1 file changed, 27 insertions(+), 33 deletions(-)
+
+diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
+index 170b6ec2dbb3c..7e9335d6e5562 100644
+--- a/drivers/net/usb/r8152.c
++++ b/drivers/net/usb/r8152.c
+@@ -6883,44 +6883,38 @@ static void rtl8152_disconnect(struct usb_interface *intf)
+ }
+ }
+
+-#define REALTEK_USB_DEVICE(vend, prod) \
+- .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \
+- USB_DEVICE_ID_MATCH_INT_CLASS, \
+- .idVendor = (vend), \
+- .idProduct = (prod), \
+- .bInterfaceClass = USB_CLASS_VENDOR_SPEC \
++#define REALTEK_USB_DEVICE(vend, prod) { \
++ USB_DEVICE_INTERFACE_CLASS(vend, prod, USB_CLASS_VENDOR_SPEC), \
+ }, \
+ { \
+- .match_flags = USB_DEVICE_ID_MATCH_INT_INFO | \
+- USB_DEVICE_ID_MATCH_DEVICE, \
+- .idVendor = (vend), \
+- .idProduct = (prod), \
+- .bInterfaceClass = USB_CLASS_COMM, \
+- .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET, \
+- .bInterfaceProtocol = USB_CDC_PROTO_NONE
++ USB_DEVICE_AND_INTERFACE_INFO(vend, prod, USB_CLASS_COMM, \
++ USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), \
++}
+
+ /* table of devices that work with this driver */
+ static const struct usb_device_id rtl8152_table[] = {
+- {REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8050)},
+- {REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8152)},
+- {REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8153)},
+- {REALTEK_USB_DEVICE(VENDOR_ID_MICROSOFT, 0x07ab)},
+- {REALTEK_USB_DEVICE(VENDOR_ID_MICROSOFT, 0x07c6)},
+- {REALTEK_USB_DEVICE(VENDOR_ID_MICROSOFT, 0x0927)},
+- {REALTEK_USB_DEVICE(VENDOR_ID_SAMSUNG, 0xa101)},
+- {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x304f)},
+- {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3054)},
+- {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3062)},
+- {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3069)},
+- {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3082)},
+- {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x7205)},
+- {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x720c)},
+- {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x7214)},
+- {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x721e)},
+- {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0xa387)},
+- {REALTEK_USB_DEVICE(VENDOR_ID_LINKSYS, 0x0041)},
+- {REALTEK_USB_DEVICE(VENDOR_ID_NVIDIA, 0x09ff)},
+- {REALTEK_USB_DEVICE(VENDOR_ID_TPLINK, 0x0601)},
++ /* Realtek */
++ REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8050),
++ REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8152),
++ REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8153),
++
++ /* Microsoft */
++ REALTEK_USB_DEVICE(VENDOR_ID_MICROSOFT, 0x07ab),
++ REALTEK_USB_DEVICE(VENDOR_ID_MICROSOFT, 0x07c6),
++ REALTEK_USB_DEVICE(VENDOR_ID_MICROSOFT, 0x0927),
++ REALTEK_USB_DEVICE(VENDOR_ID_SAMSUNG, 0xa101),
++ REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x304f),
++ REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3062),
++ REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3069),
++ REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3082),
++ REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x7205),
++ REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x720c),
++ REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x7214),
++ REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x721e),
++ REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0xa387),
++ REALTEK_USB_DEVICE(VENDOR_ID_LINKSYS, 0x0041),
++ REALTEK_USB_DEVICE(VENDOR_ID_NVIDIA, 0x09ff),
++ REALTEK_USB_DEVICE(VENDOR_ID_TPLINK, 0x0601),
+ {}
+ };
+
+--
+2.43.0
+
--- /dev/null
+From 303ec1d99145849a40bd6ce0e3379c5080f4ca3f Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 24 Apr 2021 14:09:03 +0800
+Subject: r8152: remove some bit operations
+
+From: Hayes Wang <hayeswang@realtek.com>
+
+[ Upstream commit 9c68011bd7e477ee8d03824c8cb40eab9c64027d ]
+
+Remove DELL_TB_RX_AGG_BUG and LENOVO_MACPASSTHRU flags of rtl8152_flags.
+They are only set when initializing and wouldn't be change. It is enough
+to record them with variables.
+
+Signed-off-by: Hayes Wang <hayeswang@realtek.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/usb/r8152.c | 14 +++++++-------
+ 1 file changed, 7 insertions(+), 7 deletions(-)
+
+diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
+index 7e9335d6e5562..ce47a111fe62b 100644
+--- a/drivers/net/usb/r8152.c
++++ b/drivers/net/usb/r8152.c
+@@ -685,8 +685,6 @@ enum rtl8152_flags {
+ PHY_RESET,
+ SCHEDULE_TASKLET,
+ GREEN_ETHERNET,
+- DELL_TB_RX_AGG_BUG,
+- LENOVO_MACPASSTHRU,
+ };
+
+ /* Define these values to match your device */
+@@ -860,6 +858,8 @@ struct r8152 {
+ u32 rx_copybreak;
+ u32 rx_pending;
+
++ u32 lenovo_macpassthru:1;
++ u32 dell_tb_rx_agg_bug:1;
+ u16 ocp_base;
+ u16 speed;
+ u16 eee_adv;
+@@ -1432,7 +1432,7 @@ static int vendor_mac_passthru_addr_read(struct r8152 *tp, struct sockaddr *sa)
+ acpi_object_type mac_obj_type;
+ int mac_strlen;
+
+- if (test_bit(LENOVO_MACPASSTHRU, &tp->flags)) {
++ if (tp->lenovo_macpassthru) {
+ mac_obj_name = "\\MACA";
+ mac_obj_type = ACPI_TYPE_STRING;
+ mac_strlen = 0x16;
+@@ -2123,7 +2123,7 @@ static int r8152_tx_agg_fill(struct r8152 *tp, struct tx_agg *agg)
+
+ remain = agg_buf_sz - (int)(tx_agg_align(tx_data) - agg->head);
+
+- if (test_bit(DELL_TB_RX_AGG_BUG, &tp->flags))
++ if (tp->dell_tb_rx_agg_bug)
+ break;
+ }
+
+@@ -5473,7 +5473,7 @@ static void r8153_init(struct r8152 *tp)
+ /* rx aggregation */
+ ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_USB_CTRL);
+ ocp_data &= ~(RX_AGG_DISABLE | RX_ZERO_EN);
+- if (test_bit(DELL_TB_RX_AGG_BUG, &tp->flags))
++ if (tp->dell_tb_rx_agg_bug)
+ ocp_data |= RX_AGG_DISABLE;
+
+ ocp_write_word(tp, MCU_TYPE_USB, USB_USB_CTRL, ocp_data);
+@@ -6775,7 +6775,7 @@ static int rtl8152_probe(struct usb_interface *intf,
+ switch (le16_to_cpu(udev->descriptor.idProduct)) {
+ case DEVICE_ID_THINKPAD_THUNDERBOLT3_DOCK_GEN2:
+ case DEVICE_ID_THINKPAD_USB_C_DOCK_GEN2:
+- set_bit(LENOVO_MACPASSTHRU, &tp->flags);
++ tp->lenovo_macpassthru = 1;
+ }
+ }
+
+@@ -6783,7 +6783,7 @@ static int rtl8152_probe(struct usb_interface *intf,
+ (!strcmp(udev->serial, "000001000000") ||
+ !strcmp(udev->serial, "000002000000"))) {
+ dev_info(&udev->dev, "Dell TB16 Dock, disable RX aggregation");
+- set_bit(DELL_TB_RX_AGG_BUG, &tp->flags);
++ tp->dell_tb_rx_agg_bug = 1;
+ }
+
+ netdev->ethtool_ops = &ops;
+--
+2.43.0
+
--- /dev/null
+From 999a10cbab78406a4fa45870dde04d0e7b7c66c5 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 16 Apr 2021 16:04:37 +0800
+Subject: r8152: search the configuration of vendor mode
+
+From: Hayes Wang <hayeswang@realtek.com>
+
+[ Upstream commit c2198943e33b100ed21dfb636c8fa6baef841e9d ]
+
+The vendor mode is not always at config #1, so it is necessary to
+set the correct configuration number.
+
+Signed-off-by: Hayes Wang <hayeswang@realtek.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/usb/r8152.c | 39 +++++++++++++++++++++++++++++++++++----
+ 1 file changed, 35 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
+index 0d6f10c9bb139..170b6ec2dbb3c 100644
+--- a/drivers/net/usb/r8152.c
++++ b/drivers/net/usb/r8152.c
+@@ -28,7 +28,7 @@
+ #include <crypto/hash.h>
+
+ /* Information for net-next */
+-#define NETNEXT_VERSION "11"
++#define NETNEXT_VERSION "12"
+
+ /* Information for net */
+ #define NET_VERSION "11"
+@@ -5580,6 +5580,39 @@ static void r8153b_init(struct r8152 *tp)
+ tp->coalesce = 15000; /* 15 us */
+ }
+
++static bool rtl_vendor_mode(struct usb_interface *intf)
++{
++ struct usb_host_interface *alt = intf->cur_altsetting;
++ struct usb_device *udev;
++ struct usb_host_config *c;
++ int i, num_configs;
++
++ if (alt->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC)
++ return true;
++
++ /* The vendor mode is not always config #1, so to find it out. */
++ udev = interface_to_usbdev(intf);
++ c = udev->config;
++ num_configs = udev->descriptor.bNumConfigurations;
++ for (i = 0; i < num_configs; (i++, c++)) {
++ struct usb_interface_descriptor *desc = NULL;
++
++ if (c->desc.bNumInterfaces > 0)
++ desc = &c->intf_cache[0]->altsetting->desc;
++ else
++ continue;
++
++ if (desc->bInterfaceClass == USB_CLASS_VENDOR_SPEC) {
++ usb_driver_set_configuration(udev, c->desc.bConfigurationValue);
++ break;
++ }
++ }
++
++ WARN_ON_ONCE(i == num_configs);
++
++ return false;
++}
++
+ static int rtl8152_pre_reset(struct usb_interface *intf)
+ {
+ struct r8152 *tp = usb_get_intfdata(intf);
+@@ -6673,10 +6706,8 @@ static int rtl8152_probe(struct usb_interface *intf,
+ if (version == RTL_VER_UNKNOWN)
+ return -ENODEV;
+
+- if (udev->actconfig->desc.bConfigurationValue != 1) {
+- usb_driver_set_configuration(udev, 1);
++ if (!rtl_vendor_mode(intf))
+ return -ENODEV;
+- }
+
+ if (intf->cur_altsetting->desc.bNumEndpoints < 3)
+ return -ENODEV;
+--
+2.43.0
+
--- /dev/null
+r8152-search-the-configuration-of-vendor-mode.patch
+r8152-redefine-realtek_usb_device-macro.patch
+r8152-remove-some-bit-operations.patch
+net-usb-r8152-add-in-new-devices-that-are-supported-.patch
+r8152-add-pid-for-the-lenovo-onelink-dock.patch
+r8152-add-usb-device-driver-for-config-selection.patch
+r8152-add-vendor-device-id-pair-for-d-link-dub-e250.patch
+r8152-add-vendor-device-id-pair-for-asus-usb-c2500.patch
+vfs-plumb-i_version-handling-into-struct-kstat.patch
+ima-use-vfs_getattr_nosec-to-get-the-i_version.patch
+netfilter-nf_tables-fix-exist-matching-on-bigendian-.patch
+afs-fix-refcount-underflow-from-error-handling-race.patch
+hid-lenovo-restrict-detection-of-patched-firmware-on.patch
--- /dev/null
+From c271cde72b2e037c3e9955790d124d763030abe3 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sun, 4 Dec 2016 09:29:46 -0500
+Subject: vfs: plumb i_version handling into struct kstat
+
+From: Jeff Layton <jlayton@redhat.com>
+
+[ Upstream commit a1175d6b1bdaf4f74eda47ab18eb44194f9cb796 ]
+
+The NFS server has a lot of special handling for different types of
+change attribute access, depending on the underlying filesystem. In
+most cases, it's doing a getattr anyway and then fetching that value
+after the fact.
+
+Rather that do that, add a new STATX_CHANGE_COOKIE flag that is a
+kernel-only symbol (for now). If requested and getattr can implement it,
+it can fill out this field. For IS_I_VERSION inodes, add a generic
+implementation in vfs_getattr_nosec. Take care to mask
+STATX_CHANGE_COOKIE off in requests from userland and in the result
+mask.
+
+Since not all filesystems can give the same guarantees of monotonicity,
+claim a STATX_ATTR_CHANGE_MONOTONIC flag that filesystems can set to
+indicate that they offer an i_version value that can never go backward.
+
+Eventually if we decide to make the i_version available to userland, we
+can just designate a field for it in struct statx, and move the
+STATX_CHANGE_COOKIE definition to the uapi header.
+
+Reviewed-by: NeilBrown <neilb@suse.de>
+Reviewed-by: Jan Kara <jack@suse.cz>
+Signed-off-by: Jeff Layton <jlayton@kernel.org>
+Stable-dep-of: db1d1e8b9867 ("IMA: use vfs_getattr_nosec to get the i_version")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/stat.c | 17 +++++++++++++++--
+ include/linux/stat.h | 9 +++++++++
+ 2 files changed, 24 insertions(+), 2 deletions(-)
+
+diff --git a/fs/stat.c b/fs/stat.c
+index 04550c0ba5407..3ac06528ad4cf 100644
+--- a/fs/stat.c
++++ b/fs/stat.c
+@@ -17,6 +17,7 @@
+ #include <linux/syscalls.h>
+ #include <linux/pagemap.h>
+ #include <linux/compat.h>
++#include <linux/iversion.h>
+
+ #include <linux/uaccess.h>
+ #include <asm/unistd.h>
+@@ -91,6 +92,11 @@ int vfs_getattr_nosec(const struct path *path, struct kstat *stat,
+ stat->attributes_mask |= (STATX_ATTR_AUTOMOUNT |
+ STATX_ATTR_DAX);
+
++ if ((request_mask & STATX_CHANGE_COOKIE) && IS_I_VERSION(inode)) {
++ stat->result_mask |= STATX_CHANGE_COOKIE;
++ stat->change_cookie = inode_query_iversion(inode);
++ }
++
+ if (inode->i_op->getattr)
+ return inode->i_op->getattr(path, stat, request_mask,
+ query_flags);
+@@ -545,9 +551,11 @@ cp_statx(const struct kstat *stat, struct statx __user *buffer)
+
+ memset(&tmp, 0, sizeof(tmp));
+
+- tmp.stx_mask = stat->result_mask;
++ /* STATX_CHANGE_COOKIE is kernel-only for now */
++ tmp.stx_mask = stat->result_mask & ~STATX_CHANGE_COOKIE;
+ tmp.stx_blksize = stat->blksize;
+- tmp.stx_attributes = stat->attributes;
++ /* STATX_ATTR_CHANGE_MONOTONIC is kernel-only for now */
++ tmp.stx_attributes = stat->attributes & ~STATX_ATTR_CHANGE_MONOTONIC;
+ tmp.stx_nlink = stat->nlink;
+ tmp.stx_uid = from_kuid_munged(current_user_ns(), stat->uid);
+ tmp.stx_gid = from_kgid_munged(current_user_ns(), stat->gid);
+@@ -584,6 +592,11 @@ int do_statx(int dfd, const char __user *filename, unsigned flags,
+ if ((flags & AT_STATX_SYNC_TYPE) == AT_STATX_SYNC_TYPE)
+ return -EINVAL;
+
++ /* STATX_CHANGE_COOKIE is kernel-only for now. Ignore requests
++ * from userland.
++ */
++ mask &= ~STATX_CHANGE_COOKIE;
++
+ error = vfs_statx(dfd, filename, flags, &stat, mask);
+ if (error)
+ return error;
+diff --git a/include/linux/stat.h b/include/linux/stat.h
+index fff27e6038141..cd64f44642b1a 100644
+--- a/include/linux/stat.h
++++ b/include/linux/stat.h
+@@ -46,6 +46,15 @@ struct kstat {
+ struct timespec64 btime; /* File creation time */
+ u64 blocks;
+ u64 mnt_id;
++ u64 change_cookie;
+ };
+
++/* These definitions are internal to the kernel for now. Mainly used by nfsd. */
++
++/* mask values */
++#define STATX_CHANGE_COOKIE 0x40000000U /* Want/got stx_change_attr */
++
++/* file attribute values */
++#define STATX_ATTR_CHANGE_MONOTONIC 0x8000000000000000ULL /* version monotonically increases */
++
+ #endif
+--
+2.43.0
+