From nobody Mon Apr 20 01:10:16 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D26AC433EF for ; Thu, 23 Jun 2022 18:24:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237180AbiFWSWS (ORCPT ); Thu, 23 Jun 2022 14:22:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237331AbiFWSSN (ORCPT ); Thu, 23 Jun 2022 14:18:13 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93546B628E; Thu, 23 Jun 2022 10:24:38 -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 166D2B82497; Thu, 23 Jun 2022 17:24:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76FE4C341C4; Thu, 23 Jun 2022 17:24:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656005075; bh=GJjPzaE1Xp4leBAxjdOS0+AqdSMbVLMu+pd/8Sgp3ck=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tu+8pbMaDgg++sYzcFDKGXk2ltF/7lgXlG+aqgGX24VIFDaHhUWm6kDDhvAkiBl7n JbtCZ1b9hTfaQTiPv5LPmYO+uC9hAJMkXwnMvyUov12na4q62QqHDqtT+AVg8lad3X ivD9VEpvAm1IiMzcWFNSPWemLY1sUa5DRNtB76M0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christian Borntraeger , Janis Schoetterl-Glausch , Claudio Imbrenda , Heiko Carstens Subject: [PATCH 5.4 01/11] s390/mm: use non-quiescing sske for KVM switch to keyed guest Date: Thu, 23 Jun 2022 18:45:05 +0200 Message-Id: <20220623164321.239935415@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623164321.195163701@linuxfoundation.org> References: <20220623164321.195163701@linuxfoundation.org> User-Agent: quilt/0.66 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Christian Borntraeger commit 3ae11dbcfac906a8c3a480e98660a823130dc16a upstream. The switch to a keyed guest does not require a classic sske as the other guest CPUs are not accessing the key before the switch is complete. By using the NQ SSKE things are faster especially with multiple guests. Signed-off-by: Christian Borntraeger Suggested-by: Janis Schoetterl-Glausch Reviewed-by: Claudio Imbrenda Link: https://lore.kernel.org/r/20220530092706.11637-3-borntraeger@linux.ib= m.com Signed-off-by: Christian Borntraeger Signed-off-by: Heiko Carstens Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Hulk Robot Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- arch/s390/mm/pgtable.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/s390/mm/pgtable.c +++ b/arch/s390/mm/pgtable.c @@ -716,7 +716,7 @@ void ptep_zap_key(struct mm_struct *mm, pgste_val(pgste) |=3D PGSTE_GR_BIT | PGSTE_GC_BIT; ptev =3D pte_val(*ptep); if (!(ptev & _PAGE_INVALID) && (ptev & _PAGE_WRITE)) - page_set_storage_key(ptev & PAGE_MASK, PAGE_DEFAULT_KEY, 1); + page_set_storage_key(ptev & PAGE_MASK, PAGE_DEFAULT_KEY, 0); pgste_set_unlock(ptep, pgste); preempt_enable(); } From nobody Mon Apr 20 01:10:16 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE35FC43334 for ; Thu, 23 Jun 2022 18:23:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237212AbiFWSWU (ORCPT ); Thu, 23 Jun 2022 14:22:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237346AbiFWSSP (ORCPT ); Thu, 23 Jun 2022 14:18:15 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AD7BB6299; Thu, 23 Jun 2022 10:24: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 C2E8661EA7; Thu, 23 Jun 2022 17:24:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 792A2C3411B; Thu, 23 Jun 2022 17:24:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656005079; bh=BbQ41YjqojrH7sMswoZysdjkiwLVg8lKBYqxsZSb4Us=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T9BYwOSYRfBsq7okrLliIClwAxTutkHFGM6hO/zJ7OvxqYScBZxYjxJ6YuoQN27QT 22mXKjKqJmlOo7QZGOrCRoBHAaCUnnkt+APfVC0wfhAGWRczW+Cxkd713lsVlZwvUd gZbAMPGt1Bf9IvcIKtixgxzpSEY3LGoriQkPBc8s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guenter Roeck , Mike Snitzer Subject: [PATCH 5.4 02/11] dm: remove special-casing of bio-based immutable singleton target on NVMe Date: Thu, 23 Jun 2022 18:45:06 +0200 Message-Id: <20220623164321.269097952@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623164321.195163701@linuxfoundation.org> References: <20220623164321.195163701@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Mike Snitzer Commit 9c37de297f6590937f95a28bec1b7ac68a38618f upstream. There is no benefit to DM special-casing NVMe. Remove all code used to establish DM_TYPE_NVME_BIO_BASED. Also, remove 3 'struct mapped_device *md' variables in __map_bio() which masked the same variable that is available within __map_bio()'s scope. Tested-by: Guenter Roeck Signed-off-by: Mike Snitzer Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Hulk Robot Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/md/dm-table.c | 32 +----------------- drivers/md/dm.c | 73 ++++---------------------------------= ----- include/linux/device-mapper.h | 1=20 3 files changed, 9 insertions(+), 97 deletions(-) --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -872,8 +872,7 @@ EXPORT_SYMBOL(dm_consume_args); static bool __table_type_bio_based(enum dm_queue_mode table_type) { return (table_type =3D=3D DM_TYPE_BIO_BASED || - table_type =3D=3D DM_TYPE_DAX_BIO_BASED || - table_type =3D=3D DM_TYPE_NVME_BIO_BASED); + table_type =3D=3D DM_TYPE_DAX_BIO_BASED); } =20 static bool __table_type_request_based(enum dm_queue_mode table_type) @@ -929,8 +928,6 @@ bool dm_table_supports_dax(struct dm_tab return true; } =20 -static bool dm_table_does_not_support_partial_completion(struct dm_table *= t); - static int device_is_rq_stackable(struct dm_target *ti, struct dm_dev *dev, sector_t start, sector_t len, void *data) { @@ -960,7 +957,6 @@ static int dm_table_determine_type(struc goto verify_bio_based; } BUG_ON(t->type =3D=3D DM_TYPE_DAX_BIO_BASED); - BUG_ON(t->type =3D=3D DM_TYPE_NVME_BIO_BASED); goto verify_rq_based; } =20 @@ -999,15 +995,6 @@ verify_bio_based: if (dm_table_supports_dax(t, device_not_dax_capable, &page_size) || (list_empty(devices) && live_md_type =3D=3D DM_TYPE_DAX_BIO_BASED)) { t->type =3D DM_TYPE_DAX_BIO_BASED; - } else { - /* Check if upgrading to NVMe bio-based is valid or required */ - tgt =3D dm_table_get_immutable_target(t); - if (tgt && !tgt->max_io_len && dm_table_does_not_support_partial_comple= tion(t)) { - t->type =3D DM_TYPE_NVME_BIO_BASED; - goto verify_rq_based; /* must be stacked directly on NVMe (blk-mq) */ - } else if (list_empty(devices) && live_md_type =3D=3D DM_TYPE_NVME_BIO_= BASED) { - t->type =3D DM_TYPE_NVME_BIO_BASED; - } } return 0; } @@ -1024,8 +1011,7 @@ verify_rq_based: * (e.g. request completion process for partial completion.) */ if (t->num_targets > 1) { - DMERR("%s DM doesn't support multiple targets", - t->type =3D=3D DM_TYPE_NVME_BIO_BASED ? "nvme bio-based" : "reques= t-based"); + DMERR("request-based DM doesn't support multiple targets"); return -EINVAL; } =20 @@ -1714,20 +1700,6 @@ static int device_is_not_random(struct d return q && !blk_queue_add_random(q); } =20 -static int device_is_partial_completion(struct dm_target *ti, struct dm_de= v *dev, - sector_t start, sector_t len, void *data) -{ - char b[BDEVNAME_SIZE]; - - /* For now, NVMe devices are the only devices of this class */ - return (strncmp(bdevname(dev->bdev, b), "nvme", 4) !=3D 0); -} - -static bool dm_table_does_not_support_partial_completion(struct dm_table *= t) -{ - return !dm_table_any_dev_attr(t, device_is_partial_completion, NULL); -} - static int device_not_write_same_capable(struct dm_target *ti, struct dm_d= ev *dev, sector_t start, sector_t len, void *data) { --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1000,7 +1000,7 @@ static void clone_endio(struct bio *bio) struct mapped_device *md =3D tio->io->md; dm_endio_fn endio =3D tio->ti->type->end_io; =20 - if (unlikely(error =3D=3D BLK_STS_TARGET) && md->type !=3D DM_TYPE_NVME_B= IO_BASED) { + if (unlikely(error =3D=3D BLK_STS_TARGET)) { if (bio_op(bio) =3D=3D REQ_OP_DISCARD && !bio->bi_disk->queue->limits.max_discard_sectors) disable_discard(md); @@ -1325,7 +1325,6 @@ static blk_qc_t __map_bio(struct dm_targ sector =3D clone->bi_iter.bi_sector; =20 if (unlikely(swap_bios_limit(ti, clone))) { - struct mapped_device *md =3D io->md; int latch =3D get_swap_bios(); if (unlikely(latch !=3D md->swap_bios)) __set_swap_bios_limit(md, latch); @@ -1340,24 +1339,17 @@ static blk_qc_t __map_bio(struct dm_targ /* the bio has been remapped so dispatch it */ trace_block_bio_remap(clone->bi_disk->queue, clone, bio_dev(io->orig_bio), sector); - if (md->type =3D=3D DM_TYPE_NVME_BIO_BASED) - ret =3D direct_make_request(clone); - else - ret =3D generic_make_request(clone); + ret =3D generic_make_request(clone); break; case DM_MAPIO_KILL: - if (unlikely(swap_bios_limit(ti, clone))) { - struct mapped_device *md =3D io->md; + if (unlikely(swap_bios_limit(ti, clone))) up(&md->swap_bios_semaphore); - } free_tio(tio); dec_pending(io, BLK_STS_IOERR); break; case DM_MAPIO_REQUEUE: - if (unlikely(swap_bios_limit(ti, clone))) { - struct mapped_device *md =3D io->md; + if (unlikely(swap_bios_limit(ti, clone))) up(&md->swap_bios_semaphore); - } free_tio(tio); dec_pending(io, BLK_STS_DM_REQUEUE); break; @@ -1732,51 +1724,6 @@ static blk_qc_t __split_and_process_bio( return ret; } =20 -/* - * Optimized variant of __split_and_process_bio that leverages the - * fact that targets that use it do _not_ have a need to split bios. - */ -static blk_qc_t __process_bio(struct mapped_device *md, struct dm_table *m= ap, - struct bio *bio, struct dm_target *ti) -{ - struct clone_info ci; - blk_qc_t ret =3D BLK_QC_T_NONE; - int error =3D 0; - - init_clone_info(&ci, md, map, bio); - - if (bio->bi_opf & REQ_PREFLUSH) { - struct bio flush_bio; - - /* - * Use an on-stack bio for this, it's safe since we don't - * need to reference it after submit. It's just used as - * the basis for the clone(s). - */ - bio_init(&flush_bio, NULL, 0); - flush_bio.bi_opf =3D REQ_OP_WRITE | REQ_PREFLUSH | REQ_SYNC; - ci.bio =3D &flush_bio; - ci.sector_count =3D 0; - error =3D __send_empty_flush(&ci); - bio_uninit(ci.bio); - /* dec_pending submits any data associated with flush */ - } else { - struct dm_target_io *tio; - - ci.bio =3D bio; - ci.sector_count =3D bio_sectors(bio); - if (__process_abnormal_io(&ci, ti, &error)) - goto out; - - tio =3D alloc_tio(&ci, ti, 0, GFP_NOIO); - ret =3D __clone_and_map_simple_bio(&ci, tio, NULL); - } -out: - /* drop the extra reference count */ - dec_pending(ci.io, errno_to_blk_status(error)); - return ret; -} - static blk_qc_t dm_process_bio(struct mapped_device *md, struct dm_table *map, struct bio *bio) { @@ -1807,8 +1754,6 @@ static blk_qc_t dm_process_bio(struct ma /* regular IO is split by __split_and_process_bio */ } =20 - if (dm_get_md_type(md) =3D=3D DM_TYPE_NVME_BIO_BASED) - return __process_bio(md, map, bio, ti); return __split_and_process_bio(md, map, bio); } =20 @@ -2200,12 +2145,10 @@ static struct dm_table *__bind(struct ma if (request_based) dm_stop_queue(q); =20 - if (request_based || md->type =3D=3D DM_TYPE_NVME_BIO_BASED) { + if (request_based) { /* - * Leverage the fact that request-based DM targets and - * NVMe bio based targets are immutable singletons - * - used to optimize both dm_request_fn and dm_mq_queue_rq; - * and __process_bio. + * Leverage the fact that request-based DM targets are + * immutable singletons - used to optimize dm_mq_queue_rq. */ md->immutable_target =3D dm_table_get_immutable_target(t); } @@ -2334,7 +2277,6 @@ int dm_setup_md_queue(struct mapped_devi break; case DM_TYPE_BIO_BASED: case DM_TYPE_DAX_BIO_BASED: - case DM_TYPE_NVME_BIO_BASED: dm_init_congested_fn(md); break; case DM_TYPE_NONE: @@ -3070,7 +3012,6 @@ struct dm_md_mempools *dm_alloc_md_mempo switch (type) { case DM_TYPE_BIO_BASED: case DM_TYPE_DAX_BIO_BASED: - case DM_TYPE_NVME_BIO_BASED: pool_size =3D max(dm_get_reserved_bio_based_ios(), min_pool_size); front_pad =3D roundup(per_io_data_size, __alignof__(struct dm_target_io)= ) + offsetof(struct dm_target_io, clone); io_front_pad =3D roundup(front_pad, __alignof__(struct dm_io)) + offset= of(struct dm_io, tio); --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h @@ -28,7 +28,6 @@ enum dm_queue_mode { DM_TYPE_BIO_BASED =3D 1, DM_TYPE_REQUEST_BASED =3D 2, DM_TYPE_DAX_BIO_BASED =3D 3, - DM_TYPE_NVME_BIO_BASED =3D 4, }; =20 typedef enum { STATUSTYPE_INFO, STATUSTYPE_TABLE } status_type_t; From nobody Mon Apr 20 01:10:16 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF671CCA480 for ; Thu, 23 Jun 2022 18:23:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237273AbiFWSW0 (ORCPT ); Thu, 23 Jun 2022 14:22:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237363AbiFWSSS (ORCPT ); Thu, 23 Jun 2022 14:18:18 -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 46677B62B1; Thu, 23 Jun 2022 10:24:43 -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 C9DF961EE3; Thu, 23 Jun 2022 17:24:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B98CC3411B; Thu, 23 Jun 2022 17:24:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656005082; bh=E0lgWaK+wTrtgx+NOHmYoyAHE5JLXtccaud7lMVI+84=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hotup2oBVPwoGjIyBJbLssZ1RnrVcwwrYqnOZ5nM80wBeKxFLxtB4Okcb/L8M44ri qBBp4X/Si0bgJ8uLDVgG5rvc0ggroLm8dZfrSpWFXGO94/XDHYut9z3NUWs7ijtMju sE/cZ0AmYqACtd58b5+JTtSqCgKaly9dk3cc8WgI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marian Postevca Subject: [PATCH 5.4 03/11] usb: gadget: u_ether: fix regression in setting fixed MAC address Date: Thu, 23 Jun 2022 18:45:07 +0200 Message-Id: <20220623164321.298588956@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623164321.195163701@linuxfoundation.org> References: <20220623164321.195163701@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Marian Postevca commit b337af3a4d6147000b7ca6b3438bf5c820849b37 upstream. In systemd systems setting a fixed MAC address through the "dev_addr" module argument fails systematically. When checking the MAC address after the interface is created it always has the same but different MAC address to the one supplied as argument. This is partially caused by systemd which by default will set an internally generated permanent MAC address for interfaces that are marked as having a randomly generated address. Commit 890d5b40908bfd1a ("usb: gadget: u_ether: fix race in setting MAC address in setup phase") didn't take into account the fact that the interface must be marked as having a set MAC address when it's set as module argument. Fixed by marking the interface with NET_ADDR_SET when the "dev_addr" module argument is supplied. Fixes: 890d5b40908bfd1a ("usb: gadget: u_ether: fix race in setting MAC add= ress in setup phase") Cc: stable@vger.kernel.org Signed-off-by: Marian Postevca Link: https://lore.kernel.org/r/20220603153459.32722-1-posteuca@mutex.one Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Hulk Robot Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/usb/gadget/function/u_ether.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) --- a/drivers/usb/gadget/function/u_ether.c +++ b/drivers/usb/gadget/function/u_ether.c @@ -772,9 +772,13 @@ struct eth_dev *gether_setup_name(struct dev->qmult =3D qmult; snprintf(net->name, sizeof(net->name), "%s%%d", netname); =20 - if (get_ether_addr(dev_addr, net->dev_addr)) + if (get_ether_addr(dev_addr, net->dev_addr)) { + net->addr_assign_type =3D NET_ADDR_RANDOM; dev_warn(&g->dev, "using random %s ethernet address\n", "self"); + } else { + net->addr_assign_type =3D NET_ADDR_SET; + } if (get_ether_addr(host_addr, dev->host_mac)) dev_warn(&g->dev, "using random %s ethernet address\n", "host"); @@ -831,6 +835,9 @@ struct net_device *gether_setup_name_def INIT_LIST_HEAD(&dev->tx_reqs); INIT_LIST_HEAD(&dev->rx_reqs); =20 + /* by default we always have a random MAC address */ + net->addr_assign_type =3D NET_ADDR_RANDOM; + skb_queue_head_init(&dev->rx_frames); =20 /* network device setup */ @@ -868,7 +875,6 @@ int gether_register_netdev(struct net_de g =3D dev->gadget; =20 memcpy(net->dev_addr, dev->dev_mac, ETH_ALEN); - net->addr_assign_type =3D NET_ADDR_RANDOM; =20 status =3D register_netdev(net); if (status < 0) { @@ -908,6 +914,7 @@ int gether_set_dev_addr(struct net_devic if (get_ether_addr(dev_addr, new_addr)) return -EINVAL; memcpy(dev->dev_mac, new_addr, ETH_ALEN); + net->addr_assign_type =3D NET_ADDR_SET; return 0; } EXPORT_SYMBOL_GPL(gether_set_dev_addr); From nobody Mon Apr 20 01:10:16 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05341CCA482 for ; Thu, 23 Jun 2022 18:23:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237303AbiFWSW2 (ORCPT ); Thu, 23 Jun 2022 14:22:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237395AbiFWSSW (ORCPT ); Thu, 23 Jun 2022 14:18:22 -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 742306272F; Thu, 23 Jun 2022 10:24: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 2FD1EB824BD; Thu, 23 Jun 2022 17:24:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94217C3411B; Thu, 23 Jun 2022 17:24:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656005085; bh=2EFVg608nzBI+aMFDwHwYRHf9AqWHdPRfIN8mRLZx8c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JRxJRtFwq8xlVVeHSznhY+2mzqdATdBZ20LnnoSVUB+M/3wiqsRNkSgYFZ/ZpVbNS 5Mh41fh5NQ6C2yEsqoVl249Mw2ujsrzbMskN+cdjVgL8hDiXAi2LhWRf8iR5P5MSo0 92xhVbrrNEZhtBRtn29NOhMnIuNBB8nFUge6oKCo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , David Dworken , Willem de Bruijn , "David S. Miller" , Ben Hutchings Subject: [PATCH 5.4 04/11] tcp: add some entropy in __inet_hash_connect() Date: Thu, 23 Jun 2022 18:45:08 +0200 Message-Id: <20220623164321.327144241@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623164321.195163701@linuxfoundation.org> References: <20220623164321.195163701@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Eric Dumazet commit c579bd1b4021c42ae247108f1e6f73dd3f08600c upstream. Even when implementing RFC 6056 3.3.4 (Algorithm 4: Double-Hash Port Selection Algorithm), a patient attacker could still be able to collect enough state from an otherwise idle host. Idea of this patch is to inject some noise, in the cases __inet_hash_connect() found a candidate in the first attempt. This noise should not significantly reduce the collision avoidance, and should be zero if connection table is already well used. Note that this is not implementing RFC 6056 3.3.5 because we think Algorithm 5 could hurt typical workloads. Signed-off-by: Eric Dumazet Cc: David Dworken Cc: Willem de Bruijn Signed-off-by: David S. Miller Cc: Ben Hutchings Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Hulk Robot Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- net/ipv4/inet_hashtables.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/net/ipv4/inet_hashtables.c +++ b/net/ipv4/inet_hashtables.c @@ -782,6 +782,11 @@ next_port: return -EADDRNOTAVAIL; =20 ok: + /* If our first attempt found a candidate, skip next candidate + * in 1/16 of cases to add some noise. + */ + if (!i && !(prandom_u32() % 16)) + i =3D 2; WRITE_ONCE(table_perturb[index], READ_ONCE(table_perturb[index]) + i + 2); =20 /* Head lock still held and bh's disabled */ From nobody Mon Apr 20 01:10:16 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18247CCA47F for ; Thu, 23 Jun 2022 18:23:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237335AbiFWSWa (ORCPT ); Thu, 23 Jun 2022 14:22:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237414AbiFWSS1 (ORCPT ); Thu, 23 Jun 2022 14:18:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA7BECD937; Thu, 23 Jun 2022 10:24:51 -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 511C061F04; Thu, 23 Jun 2022 17:24:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F8FFC341C4; Thu, 23 Jun 2022 17:24:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656005090; bh=SVHnFOSEA0CLpzXjVBGfSS0XlrSkacPH10kMRhOVNY4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wH/BOc229aQQh4S7/6E7eprOrYpmQEWCN8ccyFUfAejeGiq5pT8WhfUQ8fJGO+k3a OEv26zdznd8/NLzqHybUXC4xMt/BD3mWZQ6v9Pg5m9dfaq/XmGfmIMCtSCIQBRIrMt +JwiCAhZ7cIvQIi32T29jYhJDCmlvwgRCVsPmE1U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Jason A. Donenfeld" , Moshe Kol , Yossi Gilad , Amit Klein , Eric Dumazet , Willy Tarreau , Jakub Kicinski , Ben Hutchings Subject: [PATCH 5.4 05/11] tcp: use different parts of the port_offset for index and offset Date: Thu, 23 Jun 2022 18:45:09 +0200 Message-Id: <20220623164321.355832044@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623164321.195163701@linuxfoundation.org> References: <20220623164321.195163701@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Willy Tarreau commit 9e9b70ae923baf2b5e8a0ea4fd0c8451801ac526 upstream. Amit Klein suggests that we use different parts of port_offset for the table's index and the port offset so that there is no direct relation between them. Cc: Jason A. Donenfeld Cc: Moshe Kol Cc: Yossi Gilad Cc: Amit Klein Reviewed-by: Eric Dumazet Signed-off-by: Willy Tarreau Signed-off-by: Jakub Kicinski Cc: Ben Hutchings Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Hulk Robot Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- net/ipv4/inet_hashtables.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/ipv4/inet_hashtables.c +++ b/net/ipv4/inet_hashtables.c @@ -726,7 +726,7 @@ int __inet_hash_connect(struct inet_time net_get_random_once(table_perturb, sizeof(table_perturb)); index =3D hash_32(port_offset, INET_TABLE_PERTURB_SHIFT); =20 - offset =3D READ_ONCE(table_perturb[index]) + port_offset; + offset =3D READ_ONCE(table_perturb[index]) + (port_offset >> 32); offset %=3D remaining; =20 /* In first pass we try ports of @low parity. From nobody Mon Apr 20 01:10:16 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F849CCA47F for ; Thu, 23 Jun 2022 18:23:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234399AbiFWSXz (ORCPT ); Thu, 23 Jun 2022 14:23:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237123AbiFWSVj (ORCPT ); Thu, 23 Jun 2022 14:21:39 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF9B7699BB; Thu, 23 Jun 2022 10:25:15 -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 D447761DC6; Thu, 23 Jun 2022 17:25:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5F40C3411B; Thu, 23 Jun 2022 17:25:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656005114; bh=a2yASAbOJhkKvUDD8zu4yyqktGPtzXvL3oQp01bC5n4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bw+wYo7VWJUx2eLMI71U1ZXImkei3EoOKuYhkPSZNQyqORAjAIAxXKX+q52JrJWSf 7FWYzeM0h/YRyXPepCArizrm+s9Rb7UOyGs0umE7sxF9ppN3toLrHeK6AUAcDjebV5 gMgnDoYKT8+o786f1Zpkj4Z4wA+jiZ1nuS/RhS6I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Moshe Kol , Yossi Gilad , Amit Klein , Eric Dumazet , Willy Tarreau , Jakub Kicinski , Ben Hutchings Subject: [PATCH 5.4 06/11] tcp: add small random increments to the source port Date: Thu, 23 Jun 2022 18:45:10 +0200 Message-Id: <20220623164321.383720086@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623164321.195163701@linuxfoundation.org> References: <20220623164321.195163701@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Willy Tarreau commit ca7af0402550f9a0b3316d5f1c30904e42ed257d upstream. Here we're randomly adding between 0 and 7 random increments to the selected source port in order to add some noise in the source port selection that will make the next port less predictable. With the default port range of 32768-60999 this means a worst case reuse scenario of 14116/8=3D1764 connections between two consecutive uses of the same port, with an average of 14116/4.5=3D3137. This code was stressed at more than 800000 connections per second to a fixed target with all connections closed by the client using RSTs (worst condition) and only 2 connections failed among 13 billion, despite the hash being reseeded every 10 seconds, indicating a perfectly safe situation. Cc: Moshe Kol Cc: Yossi Gilad Cc: Amit Klein Reviewed-by: Eric Dumazet Signed-off-by: Willy Tarreau Signed-off-by: Jakub Kicinski Cc: Ben Hutchings Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Hulk Robot Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- net/ipv4/inet_hashtables.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) --- a/net/ipv4/inet_hashtables.c +++ b/net/ipv4/inet_hashtables.c @@ -782,11 +782,12 @@ next_port: return -EADDRNOTAVAIL; =20 ok: - /* If our first attempt found a candidate, skip next candidate - * in 1/16 of cases to add some noise. + /* Here we want to add a little bit of randomness to the next source + * port that will be chosen. We use a max() with a random here so that + * on low contention the randomness is maximal and on high contention + * it may be inexistent. */ - if (!i && !(prandom_u32() % 16)) - i =3D 2; + i =3D max_t(int, i, (prandom_u32() & 7) * 2); WRITE_ONCE(table_perturb[index], READ_ONCE(table_perturb[index]) + i + 2); =20 /* Head lock still held and bh's disabled */ From nobody Mon Apr 20 01:10:16 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B50ADC43334 for ; Thu, 23 Jun 2022 18:24:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237419AbiFWSWm (ORCPT ); Thu, 23 Jun 2022 14:22:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234933AbiFWSSe (ORCPT ); Thu, 23 Jun 2022 14:18:34 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A0DF68021; Thu, 23 Jun 2022 10:24: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 dfw.source.kernel.org (Postfix) with ESMTPS id 999CA61F06; Thu, 23 Jun 2022 17:24:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 760EDC341C5; Thu, 23 Jun 2022 17:24:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656005096; bh=wp9EquvNPqrrsJ/Y1NFOY6uknM5N6T0rAZv5vmCLvqQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=riS+em0i3Fjo8zyg1AkKiULncZBRZqtFCiL7gktucAlYTRSKTJtsqea1PdfSxUwBt bIp5Lfr61de6wc4YmOROhO9sqs7gNEQdF1ZWS5X0QytwOMZnagaCCtjuU30w5gJaaU dzMoHo4e6TnC90G3DFY+5Zf1SDj7JIv6kPWFplNU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Moshe Kol , Yossi Gilad , Amit Klein , Eric Dumazet , Willy Tarreau , Jakub Kicinski , Ben Hutchings Subject: [PATCH 5.4 07/11] tcp: dynamically allocate the perturb table used by source ports Date: Thu, 23 Jun 2022 18:45:11 +0200 Message-Id: <20220623164321.412902424@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623164321.195163701@linuxfoundation.org> References: <20220623164321.195163701@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Willy Tarreau commit e9261476184be1abd486c9434164b2acbe0ed6c2 upstream. We'll need to further increase the size of this table and it's likely that at some point its size will not be suitable anymore for a static table. Let's allocate it on boot from inet_hashinfo2_init(), which is called from tcp_init(). Cc: Moshe Kol Cc: Yossi Gilad Cc: Amit Klein Reviewed-by: Eric Dumazet Signed-off-by: Willy Tarreau Signed-off-by: Jakub Kicinski Cc: Ben Hutchings Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Hulk Robot Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- net/ipv4/inet_hashtables.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) --- a/net/ipv4/inet_hashtables.c +++ b/net/ipv4/inet_hashtables.c @@ -680,7 +680,8 @@ EXPORT_SYMBOL_GPL(inet_unhash); * privacy, this only consumes 1 KB of kernel memory. */ #define INET_TABLE_PERTURB_SHIFT 8 -static u32 table_perturb[1 << INET_TABLE_PERTURB_SHIFT]; +#define INET_TABLE_PERTURB_SIZE (1 << INET_TABLE_PERTURB_SHIFT) +static u32 *table_perturb; =20 int __inet_hash_connect(struct inet_timewait_death_row *death_row, struct sock *sk, u64 port_offset, @@ -723,7 +724,8 @@ int __inet_hash_connect(struct inet_time if (likely(remaining > 1)) remaining &=3D ~1U; =20 - net_get_random_once(table_perturb, sizeof(table_perturb)); + net_get_random_once(table_perturb, + INET_TABLE_PERTURB_SIZE * sizeof(*table_perturb)); index =3D hash_32(port_offset, INET_TABLE_PERTURB_SHIFT); =20 offset =3D READ_ONCE(table_perturb[index]) + (port_offset >> 32); @@ -861,6 +863,12 @@ void __init inet_hashinfo2_init(struct i low_limit, high_limit); init_hashinfo_lhash2(h); + + /* this one is used for source ports of outgoing connections */ + table_perturb =3D kmalloc_array(INET_TABLE_PERTURB_SIZE, + sizeof(*table_perturb), GFP_KERNEL); + if (!table_perturb) + panic("TCP: failed to alloc table_perturb"); } =20 int inet_hashinfo2_init_mod(struct inet_hashinfo *h) From nobody Mon Apr 20 01:10:16 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CFF05CCA47F for ; Thu, 23 Jun 2022 18:24:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237452AbiFWSWn (ORCPT ); Thu, 23 Jun 2022 14:22:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236829AbiFWSSw (ORCPT ); Thu, 23 Jun 2022 14:18:52 -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 339A4647B7; Thu, 23 Jun 2022 10:25:01 -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 AA73160B79; Thu, 23 Jun 2022 17:25:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89D2CC3411B; Thu, 23 Jun 2022 17:24:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656005099; bh=hqzuFkqJZfZ2xw66ZjW5NeLcs8PlIC6Yzab2noj3OdM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OQfntXg1188KUKr9JXf5EzFxhKy0EAR5xejfPR5Hxo09lr4QimdA5PqW0brDTOPTh Wv3oL29nVIFuS4IwhVTX/ghEzmT7C4KDfEMn/GcSTsvuQrL2/YYPXcMBU/c7jKFtPD lslBexq7buCBjHMCCKGGpKi+fxyfRuQmeC1Y4OLw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Moshe Kol , Yossi Gilad , Amit Klein , Eric Dumazet , Willy Tarreau , Jakub Kicinski , Ben Hutchings Subject: [PATCH 5.4 08/11] tcp: increase source port perturb table to 2^16 Date: Thu, 23 Jun 2022 18:45:12 +0200 Message-Id: <20220623164321.442250829@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623164321.195163701@linuxfoundation.org> References: <20220623164321.195163701@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Willy Tarreau commit 4c2c8f03a5ab7cb04ec64724d7d176d00bcc91e5 upstream. Moshe Kol, Amit Klein, and Yossi Gilad reported being able to accurately identify a client by forcing it to emit only 40 times more connections than there are entries in the table_perturb[] table. The previous two improvements consisting in resalting the secret every 10s and adding randomness to each port selection only slightly improved the situation, and the current value of 2^8 was too small as it's not very difficult to make a client emit 10k connections in less than 10 seconds. Thus we're increasing the perturb table from 2^8 to 2^16 so that the same precision now requires 2.6M connections, which is more difficult in this time frame and harder to hide as a background activity. The impact is that the table now uses 256 kB instead of 1 kB, which could mostly affect devices making frequent outgoing connections. However such components usually target a small set of destinations (load balancers, database clients, perf assessment tools), and in practice only a few entries will be visited, like before. A live test at 1 million connections per second showed no performance difference from the previous value. Reported-by: Moshe Kol Reported-by: Yossi Gilad Reported-by: Amit Klein Reviewed-by: Eric Dumazet Signed-off-by: Willy Tarreau Signed-off-by: Jakub Kicinski Cc: Ben Hutchings Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Hulk Robot Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- net/ipv4/inet_hashtables.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) --- a/net/ipv4/inet_hashtables.c +++ b/net/ipv4/inet_hashtables.c @@ -675,11 +675,12 @@ EXPORT_SYMBOL_GPL(inet_unhash); * Note that we use 32bit integers (vs RFC 'short integers') * because 2^16 is not a multiple of num_ephemeral and this * property might be used by clever attacker. - * RFC claims using TABLE_LENGTH=3D10 buckets gives an improvement, - * we use 256 instead to really give more isolation and - * privacy, this only consumes 1 KB of kernel memory. + * RFC claims using TABLE_LENGTH=3D10 buckets gives an improvement, though + * attacks were since demonstrated, thus we use 65536 instead to really + * give more isolation and privacy, at the expense of 256kB of kernel + * memory. */ -#define INET_TABLE_PERTURB_SHIFT 8 +#define INET_TABLE_PERTURB_SHIFT 16 #define INET_TABLE_PERTURB_SIZE (1 << INET_TABLE_PERTURB_SHIFT) static u32 *table_perturb; From nobody Mon Apr 20 01:10:16 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47497CCA483 for ; Thu, 23 Jun 2022 18:23:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237491AbiFWSWq (ORCPT ); Thu, 23 Jun 2022 14:22:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234131AbiFWSTG (ORCPT ); Thu, 23 Jun 2022 14:19:06 -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 174226801D; Thu, 23 Jun 2022 10:25: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 dfw.source.kernel.org (Postfix) with ESMTPS id 9CCC561F08; Thu, 23 Jun 2022 17:25:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B5C2C341C5; Thu, 23 Jun 2022 17:25:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656005102; bh=pKgidH1iBtYdAQlTT+9cdhSza1ynLiI3QaAdMB6TxqQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lJtkmTiaCg0Mj3ZvVFeqGniUWRYC/FYIgzuF1UWMKmtkS5tNXCsjHmMDHz+e2SJkr j1lBxCRqCQLUrwY6yP87CLHDdXoSUVDMPkfObvCVJez2mT432zht17o1SupTmfdKqL N0g55OTOLAD1c5H7RGI6VR8ZkYRA8NUTzY7X7tWE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Amit Klein , Eric Dumazet , Willy Tarreau , Jakub Kicinski , Ben Hutchings Subject: [PATCH 5.4 09/11] tcp: drop the hash_32() part from the index calculation Date: Thu, 23 Jun 2022 18:45:13 +0200 Message-Id: <20220623164321.470700805@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623164321.195163701@linuxfoundation.org> References: <20220623164321.195163701@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Willy Tarreau commit e8161345ddbb66e449abde10d2fdce93f867eba9 upstream. In commit 190cc82489f4 ("tcp: change source port randomizarion at connect() time"), the table_perturb[] array was introduced and an index was taken from the port_offset via hash_32(). But it turns out that hash_32() performs a multiplication while the input here comes from the output of SipHash in secure_seq, that is well distributed enough to avoid the need for yet another hash. Suggested-by: Amit Klein Reviewed-by: Eric Dumazet Signed-off-by: Willy Tarreau Signed-off-by: Jakub Kicinski Cc: Ben Hutchings Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Hulk Robot Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- net/ipv4/inet_hashtables.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/ipv4/inet_hashtables.c +++ b/net/ipv4/inet_hashtables.c @@ -727,7 +727,7 @@ int __inet_hash_connect(struct inet_time =20 net_get_random_once(table_perturb, INET_TABLE_PERTURB_SIZE * sizeof(*table_perturb)); - index =3D hash_32(port_offset, INET_TABLE_PERTURB_SHIFT); + index =3D port_offset & (INET_TABLE_PERTURB_SIZE - 1); =20 offset =3D READ_ONCE(table_perturb[index]) + (port_offset >> 32); offset %=3D remaining; From nobody Mon Apr 20 01:10:16 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A342CCA487 for ; Thu, 23 Jun 2022 18:23:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237536AbiFWSWu (ORCPT ); Thu, 23 Jun 2022 14:22:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237054AbiFWSUg (ORCPT ); Thu, 23 Jun 2022 14:20:36 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E5CC680A3; Thu, 23 Jun 2022 10:25:09 -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 A793560B79; Thu, 23 Jun 2022 17:25:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 809B9C3411B; Thu, 23 Jun 2022 17:25:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656005108; bh=SRMKkR6B/s1amXppPbKxKENrJIwF9K0pCjkqpT0XZf0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HkuAvrA54Gg29IxW9p3Pxl0sIJM6XvZRExn53K8v9CbsIEIs00k5dk+YAZafVDUcz AUyyN5Mi+M88XdXyjuAQ2X1tNEVthHg3Oe1hjWJPPZRUV7b8zpxNyxVAGq6XOu1SW2 hIJpWkMfQ+klnXuzs3Bi46bkkK8+KPDEJult+49M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ard Biesheuvel , Christoph Hellwig , Robin Murphy , Russell King , Will Deacon , Catalin Marinas Subject: [PATCH 5.4 10/11] arm64: mm: Dont invalidate FROM_DEVICE buffers at start of DMA transfer Date: Thu, 23 Jun 2022 18:45:14 +0200 Message-Id: <20220623164321.498480839@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623164321.195163701@linuxfoundation.org> References: <20220623164321.195163701@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Will Deacon commit c50f11c6196f45c92ca48b16a5071615d4ae0572 upstream. Invalidating the buffer memory in arch_sync_dma_for_device() for FROM_DEVICE transfers When using the streaming DMA API to map a buffer prior to inbound non-coherent DMA (i.e. DMA_FROM_DEVICE), we invalidate any dirty CPU cachelines so that they will not be written back during the transfer and corrupt the buffer contents written by the DMA. This, however, poses two potential problems: (1) If the DMA transfer does not write to every byte in the buffer, then the unwritten bytes will contain stale data once the transfer has completed. (2) If the buffer has a virtual alias in userspace, then stale data may be visible via this alias during the period between performing the cache invalidation and the DMA writes landing in memory. Address both of these issues by cleaning (aka writing-back) the dirty lines in arch_sync_dma_for_device(DMA_FROM_DEVICE) instead of discarding them using invalidation. Cc: Ard Biesheuvel Cc: Christoph Hellwig Cc: Robin Murphy Cc: Russell King Cc: Link: https://lore.kernel.org/r/20220606152150.GA31568@willie-the-truck Signed-off-by: Will Deacon Reviewed-by: Ard Biesheuvel Link: https://lore.kernel.org/r/20220610151228.4562-2-will@kernel.org Signed-off-by: Catalin Marinas Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Hulk Robot Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- arch/arm64/mm/cache.S | 2 -- 1 file changed, 2 deletions(-) --- a/arch/arm64/mm/cache.S +++ b/arch/arm64/mm/cache.S @@ -228,8 +228,6 @@ ENDPIPROC(__dma_flush_area) * - dir - DMA direction */ ENTRY(__dma_map_area) - cmp w2, #DMA_FROM_DEVICE - b.eq __dma_inv_area b __dma_clean_area ENDPIPROC(__dma_map_area) From nobody Mon Apr 20 01:10:16 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC8E6CCA48A for ; Thu, 23 Jun 2022 18:23:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233614AbiFWSXx (ORCPT ); Thu, 23 Jun 2022 14:23:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237081AbiFWSVF (ORCPT ); Thu, 23 Jun 2022 14:21:05 -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 C8ACB68C42; Thu, 23 Jun 2022 10:25:12 -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 C67DD61BFA; Thu, 23 Jun 2022 17:25:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B936AC3411B; Thu, 23 Jun 2022 17:25:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656005111; bh=c5AcL957SsFi4ZAuL0Y2ToBTmHljoGZLqLESIUV+rfM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hKYs+yNiSDnHjxn17/VJcieBx/hsxbbGd0zYmGrDfGlM7N8TBrIwG/qNqoLXBSWdH lLAPV1Mm+xjVOz2W3rN4BEF6ZrQ9cen8pzALvu0nQZbKQFFwp6+HVeXP1+GK39KOnp H85u8Y6X/vEH39Hj5UQo8c8hUMlTLHKq4zeaWr1s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Julian Haller , Guenter Roeck , Sasha Levin Subject: [PATCH 5.4 11/11] Revert "hwmon: Make chip parameter for with_info API mandatory" Date: Thu, 23 Jun 2022 18:45:15 +0200 Message-Id: <20220623164321.527852885@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623164321.195163701@linuxfoundation.org> References: <20220623164321.195163701@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Greg Kroah-Hartman This reverts commit 1ec0bc72f5dab3ab367ae5230cf6f212d805a225 which is commit ddaefa209c4ac791c1262e97c9b2d0440c8ef1d5 upstream. It should not have been applied to the stable trees. Link: https://lore.kernel.org/r/20220622154454.GA1864037@roeck-us.net Reported-by: Julian Haller Reported-by: Guenter Roeck Cc: Sasha Levin Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Hulk Robot Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- Documentation/hwmon/hwmon-kernel-api.rst | 2 +- drivers/hwmon/hwmon.c | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) --- a/Documentation/hwmon/hwmon-kernel-api.rst +++ b/Documentation/hwmon/hwmon-kernel-api.rst @@ -72,7 +72,7 @@ hwmon_device_register_with_info is the m to register a hardware monitoring device. It creates the standard sysfs attributes in the hardware monitoring core, letting the driver focus on re= ading from and writing to the chip instead of having to bother with sysfs attrib= utes. -The parent device parameter as well as the chip parameter must not be NULL= . Its +The parent device parameter cannot be NULL with non-NULL chip info. Its parameters are described in more detail below. =20 devm_hwmon_device_register_with_info is similar to --- a/drivers/hwmon/hwmon.c +++ b/drivers/hwmon/hwmon.c @@ -715,12 +715,11 @@ EXPORT_SYMBOL_GPL(hwmon_device_register_ =20 /** * hwmon_device_register_with_info - register w/ hwmon - * @dev: the parent device (mandatory) - * @name: hwmon name attribute (mandatory) - * @drvdata: driver data to attach to created device (optional) - * @chip: pointer to hwmon chip information (mandatory) + * @dev: the parent device + * @name: hwmon name attribute + * @drvdata: driver data to attach to created device + * @chip: pointer to hwmon chip information * @extra_groups: pointer to list of additional non-standard attribute gro= ups - * (optional) * * hwmon_device_unregister() must be called when the device is no * longer needed. @@ -733,10 +732,13 @@ hwmon_device_register_with_info(struct d const struct hwmon_chip_info *chip, const struct attribute_group **extra_groups) { - if (!dev || !name || !chip) + if (!name) return ERR_PTR(-EINVAL); =20 - if (!chip->ops || !chip->ops->is_visible || !chip->info) + if (chip && (!chip->ops || !chip->ops->is_visible || !chip->info)) + return ERR_PTR(-EINVAL); + + if (chip && !dev) return ERR_PTR(-EINVAL); =20 return __hwmon_device_register(dev, name, drvdata, chip, extra_groups);