Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1037055pxm; Wed, 23 Feb 2022 16:31:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJz27SEWwmlTI6kGNTPUkaWIMRLCmLuB4GIA66O12FoJ2GLKkYSGXw3w0lKBmxalMq6pBkRc X-Received: by 2002:a17:90a:404f:b0:1bc:2a81:d7ca with SMTP id k15-20020a17090a404f00b001bc2a81d7camr118494pjg.211.1645662677173; Wed, 23 Feb 2022 16:31:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645662677; cv=none; d=google.com; s=arc-20160816; b=FGF2JqLrtU3Ib2wqdh1O8JNEwAcu91phMOXMjItKOhC5FrFIlIjKGu2/9QcdDD1P6L T5DNQjMhnCGbKTCPxPlJlJ2aGa5GkoufMKZSVxMwuIbOapcc3BLK4MzhhxwpoVg2QbNh bapOav4fBUPF2kFNoDHzLFLV51kjj+9VqCrvkhqW9LMHsqx7I6D4lC47J3rg+qFC7WTo /sDBXDWC4Uq0FyuDvSBDLl7sYtxE7INh6TZwsKvGW9d/x8igX1oO7Rm1ZVuu9i+7Pqsr u/xxGixC+FXwrw/tkXPFSe4XJMg5+By7GeZabut9VPt3EZsEHGJ98iRZ69hbES2Vt/+e ekHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=GibhDTYAryb7Hpuwr56XwbKKlqG8iiUhOGqmRs36ioM=; b=yOWJyn94jE0oUj5V6/jN9fhXaj79OqChJ9bUVdcftavGMcdOtOxkFfHE7b0s1lIIXp rQ1vz0wNpy97f59eF4vi+ez+BsVjc6B2rrEYKJ6Tnd2E3zMjfhJAus0txzo/asbSMDmU y7svNLI3P6EoRIsaChppOY4f8zL+a+xjnjlzmmSf/WK4N/DaqlAI9yyO0yCP/m7BxIO6 s/XeNcxhNxc9QtZEC9tBSGTP5nk746zSLbWu9NLnhrVGF01NO7mYuXrMMFXc0hhky7Ei 3Qi0pvWt+yVynvkqdCcSUlQWOFLm/ny4BUUSX0xE/U1rj1fydXEa6nfErUg8YRSmHy0I byyw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id f32si944036pjk.141.2022.02.23.16.31.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 16:31:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7D12C70F71; Wed, 23 Feb 2022 16:31:11 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244597AbiBWUBO (ORCPT + 99 others); Wed, 23 Feb 2022 15:01:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244590AbiBWUBN (ORCPT ); Wed, 23 Feb 2022 15:01:13 -0500 Received: from smtp.smtpout.orange.fr (smtp08.smtpout.orange.fr [80.12.242.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 913D735DCB for ; Wed, 23 Feb 2022 12:00:44 -0800 (PST) Received: from [192.168.1.18] ([90.126.236.122]) by smtp.orange.fr with ESMTPA id MxoSnoXxX41cbMxoSnhzlJ; Wed, 23 Feb 2022 21:00:42 +0100 X-ME-Helo: [192.168.1.18] X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Wed, 23 Feb 2022 21:00:42 +0100 X-ME-IP: 90.126.236.122 Message-ID: <7ce2df48-b876-0c30-d003-32275c5a9f65@wanadoo.fr> Date: Wed, 23 Feb 2022 21:00:36 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [RFC PATCH 07/13] udp_tunnel: remove the usage of the list iterator after the loop Content-Language: fr To: Jakob Koschel , Linus Torvalds , linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, Greg Kroah-Hartman , Thomas Gleixner , Arnd Bergman , Andy Shevchenko , Andrew Morton , Kees Cook , Mike Rapoport , "Gustavo A. R. Silva" , Brian Johannesmeyer , Cristiano Giuffrida , "Bos, H.J." , Dan Carpenter References: <20220217184829.1991035-1-jakobkoschel@gmail.com> <20220217184829.1991035-8-jakobkoschel@gmail.com> From: Christophe JAILLET In-Reply-To: <20220217184829.1991035-8-jakobkoschel@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 17/02/2022 à 19:48, Jakob Koschel a écrit : > The usage of node->dev after the loop body is a legitimate type > confusion if the break was not hit. It will compare an undefined > memory location with dev that could potentially be equal. The value > of node->dev in this case could either be a random struct member of the > head element or an out-of-bounds value. > > Therefore it is more safe to use the found variable. With the > introduction of speculative safe list iterator this check could be > replaced with if (!node). > > Signed-off-by: Jakob Koschel > --- > net/ipv4/udp_tunnel_nic.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/net/ipv4/udp_tunnel_nic.c b/net/ipv4/udp_tunnel_nic.c > index b91003538d87..c47f9fb36d29 100644 > --- a/net/ipv4/udp_tunnel_nic.c > +++ b/net/ipv4/udp_tunnel_nic.c > @@ -842,11 +842,14 @@ udp_tunnel_nic_unregister(struct net_device *dev, struct udp_tunnel_nic *utn) > */ > if (info->shared) { > struct udp_tunnel_nic_shared_node *node, *first; > + bool found = false; > > list_for_each_entry(node, &info->shared->devices, list) > - if (node->dev == dev) > + if (node->dev == dev) { > + found = true; > break; > - if (node->dev != dev) > + } > + if (!found) > return; > > list_del(&node->list); Hi, just in case, see Dan Carpeter's patch for the same issue with another fix at: https://lore.kernel.org/kernel-janitors/20220222134251.GA2271@kili/ CJ