From nobody Sun Jun 28 00:10:37 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 DBBD5C433EF for ; Thu, 17 Feb 2022 18:50:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244637AbiBQSuQ (ORCPT ); Thu, 17 Feb 2022 13:50:16 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:44484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244627AbiBQSuI (ORCPT ); Thu, 17 Feb 2022 13:50:08 -0500 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D9385133F; Thu, 17 Feb 2022 10:49:52 -0800 (PST) Received: by mail-ed1-x52e.google.com with SMTP id h18so11316693edb.7; Thu, 17 Feb 2022 10:49:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4cIot06p9bDQauaO1zbhigQdt5owQ2rXgJArey+D59k=; b=UoYO3PHZ4HTMVcUw5lv3zypcgWVf/5pzgSroMo+f3bngjaPxXFwX3HhKvS6xdlOAqz 8gSBrl8c8D3qe/HOPg7i4DPGJFAQANXNLmiOH8o6jRLs/HghTGAURVHt+9fVmJgi+9qW MpNIRELNUgcaWdVylHzZfyTKu43QUEGjKcjTssKoJjQImdM9vSiuZw0gpLZPi/ZaWGS4 ElGOpTM26javGFnnmSuuaID3Dr8g5c2MCbOO+AmvXAmxinBNP0oYxMLkuqXYk5Keqs9/ O1ji42DyTDwWBOfuc0LY8vibfFUuNaIseAOg/RdfgPmZ71kHv+r+quLLVNhxtbYQpBT5 5Xhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4cIot06p9bDQauaO1zbhigQdt5owQ2rXgJArey+D59k=; b=z7YXcB74Pp4AnetnBV3v0f1d8mdurBPS+S0wTBmMoaGnM2b3FxDY2rJUxnI7VSwNUo aY6HzbS4muej3iARPWAUsceFLCMJE+gnta2gaL/AhA6zODQgWsjzDZoe6BAD+JBtaON+ Nx/JaAOZPIQeZWMoMhVrXnmEaKA57jSFDuVmEeddcmeotrk7c+YetrBJxCINvTeiXXtl /8PZzd5xyfqhEXQNH9V8NH2Vy1p17/9uqd5e8z6B0k9pdQjYWbVw9Ud7eImqL3CNB/Ow SNkhGj/M4yM4LiHIeaEiLaqQxCtStePVbc595FNNMXFc3DpYYBMqKUv/yIPHLDPYeZMo +b/w== X-Gm-Message-State: AOAM533j6LQ+aqjN7A2jyThllgbD4FlpboR1cBzDploPIObtNmQjUJu1 Xf1ntk/WPQsFJx8+e+44KUs= X-Google-Smtp-Source: ABdhPJwVQsnOpusaPVplCNMtPOIo1hxXvJsWTnSyJXdpiYr6w0I1libJUg95L+1iei0vO6WtH3kbGg== X-Received: by 2002:a05:6402:3486:b0:409:8ed0:9340 with SMTP id v6-20020a056402348600b004098ed09340mr4114511edc.255.1645123791125; Thu, 17 Feb 2022 10:49:51 -0800 (PST) Received: from localhost.localdomain (dhcp-077-250-038-153.chello.nl. [77.250.38.153]) by smtp.googlemail.com with ESMTPSA id q7sm3493268edv.93.2022.02.17.10.49.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 10:49:50 -0800 (PST) From: Jakob Koschel To: 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." , Jakob Koschel Subject: [RFC PATCH 01/13] list: introduce speculative safe list_for_each_entry() Date: Thu, 17 Feb 2022 19:48:17 +0100 Message-Id: <20220217184829.1991035-2-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220217184829.1991035-1-jakobkoschel@gmail.com> References: <20220217184829.1991035-1-jakobkoschel@gmail.com> 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" list_for_each_entry() selects either the correct value (pos) or a safe value for the additional mispredicted iteration (NULL) for the list iterator. list_for_each_entry() calls select_nospec(), which performs a branch-less select. On x86, this select is performed via a cmov. Otherwise, it's performed via various shift/mask/etc. operations. Kasper Acknowledgements: Jakob Koschel, Brian Johannesmeyer, Kaveh Razavi, Herbert Bos, Cristiano Giuffrida from the VUSec group at VU Amsterdam. Co-developed-by: Brian Johannesmeyer Signed-off-by: Brian Johannesmeyer Signed-off-by: Jakob Koschel --- arch/x86/include/asm/barrier.h | 12 ++++++++++++ include/linux/list.h | 3 ++- include/linux/nospec.h | 16 ++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/barrier.h b/arch/x86/include/asm/barrier.h index 35389b2af88e..722797ad74e2 100644 --- a/arch/x86/include/asm/barrier.h +++ b/arch/x86/include/asm/barrier.h @@ -48,6 +48,18 @@ static inline unsigned long array_index_mask_nospec(unsi= gned long index, /* Override the default implementation from linux/nospec.h. */ #define array_index_mask_nospec array_index_mask_nospec =20 +/* Override the default implementation from linux/nospec.h. */ +#define select_nospec(cond, exptrue, expfalse) \ +({ \ + typeof(exptrue) _out =3D (exptrue); \ + \ + asm volatile("test %1, %1\n\t" \ + "cmove %2, %0" \ + : "+r" (_out) \ + : "r" (cond), "r" (expfalse)); \ + _out; \ +}) + /* Prevent speculative execution past this barrier. */ #define barrier_nospec() alternative("", "lfence", X86_FEATURE_LFENCE_RDTS= C) =20 diff --git a/include/linux/list.h b/include/linux/list.h index dd6c2041d09c..1a1b39fdd122 100644 --- a/include/linux/list.h +++ b/include/linux/list.h @@ -636,7 +636,8 @@ static inline void list_splice_tail_init(struct list_he= ad *list, */ #define list_for_each_entry(pos, head, member) \ for (pos =3D list_first_entry(head, typeof(*pos), member); \ - !list_entry_is_head(pos, head, member); \ + ({ bool _cond =3D !list_entry_is_head(pos, head, member); \ + pos =3D select_nospec(_cond, pos, NULL); _cond; }); \ pos =3D list_next_entry(pos, member)) =20 /** diff --git a/include/linux/nospec.h b/include/linux/nospec.h index c1e79f72cd89..ca8ed81e4f9e 100644 --- a/include/linux/nospec.h +++ b/include/linux/nospec.h @@ -67,4 +67,20 @@ int arch_prctl_spec_ctrl_set(struct task_struct *task, u= nsigned long which, /* Speculation control for seccomp enforced mitigation */ void arch_seccomp_spec_mitigate(struct task_struct *task); =20 +/** + * select_nospec - select a value without using a branch; equivalent to: + * cond ? exptrue : expfalse; + */ +#ifndef select_nospec +#define select_nospec(cond, exptrue, expfalse) \ +({ \ + unsigned long _t =3D (unsigned long) (exptrue); \ + unsigned long _f =3D (unsigned long) (expfalse); \ + unsigned long _c =3D (unsigned long) (cond); \ + OPTIMIZER_HIDE_VAR(_c); \ + unsigned long _m =3D -((_c | -_c) >> (BITS_PER_LONG - 1)); \ + (typeof(exptrue)) ((_t & _m) | (_f & ~_m)); \ +}) +#endif + #endif /* _LINUX_NOSPEC_H */ --=20 2.25.1 From nobody Sun Jun 28 00:10:37 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 95139C433EF for ; Thu, 17 Feb 2022 18:50:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244647AbiBQSuU (ORCPT ); Thu, 17 Feb 2022 13:50:20 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:45016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244625AbiBQSuP (ORCPT ); Thu, 17 Feb 2022 13:50:15 -0500 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E17E522D8; Thu, 17 Feb 2022 10:50:01 -0800 (PST) Received: by mail-ed1-x536.google.com with SMTP id c6so8586271edk.12; Thu, 17 Feb 2022 10:50:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=n/tXywgWcjoxJRzGsDhwx7/PqgtdIxpeFw3OBwiMgEc=; b=jVT3FGeUaE5POK128yREy9rdStZKFkWoseVl4YdjXSw2oknas7UyHZ4Jwvd00EphbP ERTV9ZvJRIhcYqdZ3TVstkPJZG5/vSrK+XpVEMvUwpBwghKQbkUhm+wS1UPA8uuV0AoP k76sGspPlQFHmgoH1ifBieex58D/FIKTgYSsxICgS6gEXznNTQxmJxzXzSX2xibEroTs h/dhmorYNdk4UX6e5hacSnkuJutn1IFVfiNUp392baUowYsXn9kDgM2AkGKffGow3and e0nEp/yJWNy0jJPqeShfbW1b2gM/CgD59Ncu23uR46uibxVF6j5UM+N6S5/NkwghZjC3 3fsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=n/tXywgWcjoxJRzGsDhwx7/PqgtdIxpeFw3OBwiMgEc=; b=4IKNKuJwWvcu9TvfaDqa+nyji3MPQuR/2FeZ/fILkz7rhA25YvxbjBlJjEznntPmR1 xIlWde+nuYN7j9IMufQFHT88wEmWP4jhn04lS9cDLy5KjcfndtlOIonumQRa3UK4CHlN SBUhKRpWU2DSCvAbrBxdFc/ON0F81YwBcX+/PCNtA38tnRg4N7uMpHq1CfpWlpmDWx32 8ohdVqZadyh1ZeHihIvPnTvxRxCGvV9cCwNay82LFyywXquBIveHXnEBc2Yzt8dnuRDU OSJxUVFp7rfi6WhlWLqZOo9SDSw9F8WFmn2XB1rFTq0FooP4Kv2mGN6VuRkuGIlX7dmj mUWg== X-Gm-Message-State: AOAM533d9Ed7HJcN3YgMxDSjeIgMVLHUjmILnMB5o8pQCOmut6meGOw0 nVTh5odLi2IQr8pANSH1sfM= X-Google-Smtp-Source: ABdhPJyQxLL5ymfvMWl7ULAGVOQiuETx992R3qYTUkxbRt2G2dqEkaOz6h5A/3+oGeweBcwqtSfICQ== X-Received: by 2002:a05:6402:3691:b0:410:a178:6be1 with SMTP id ej17-20020a056402369100b00410a1786be1mr4173352edb.287.1645123799786; Thu, 17 Feb 2022 10:49:59 -0800 (PST) Received: from localhost.localdomain (dhcp-077-250-038-153.chello.nl. [77.250.38.153]) by smtp.googlemail.com with ESMTPSA id q7sm3493268edv.93.2022.02.17.10.49.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 10:49:59 -0800 (PST) From: Jakob Koschel To: 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." , Jakob Koschel Subject: [RFC PATCH 02/13] scripts: coccinelle: adapt to find list_for_each_entry nospec issues Date: Thu, 17 Feb 2022 19:48:18 +0100 Message-Id: <20220217184829.1991035-3-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220217184829.1991035-1-jakobkoschel@gmail.com> References: <20220217184829.1991035-1-jakobkoschel@gmail.com> 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" These changes are just temporary to illustrate how I composed the list of code locations mentioned here. While for example the usage of &c->member is currently safe to use, it is an issue if c is set to NULL when the terminating condition is met. Signed-off-by: Jakob Koschel --- .../coccinelle/iterators/use_after_iter.cocci | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/scripts/coccinelle/iterators/use_after_iter.cocci b/scripts/co= ccinelle/iterators/use_after_iter.cocci index 676edd562eef..01563a242f00 100644 --- a/scripts/coccinelle/iterators/use_after_iter.cocci +++ b/scripts/coccinelle/iterators/use_after_iter.cocci @@ -91,43 +91,19 @@ list_for_each_entry(c,...) S | list_for_each_entry_reverse(c,...) S | -list_for_each_entry_continue(c,...) S -| -list_for_each_entry_continue_reverse(c,...) S -| -list_for_each_entry_from(c,...) S -| list_for_each_entry_safe(c,...) S | list_for_each_entry_safe(x,c,...) S | -list_for_each_entry_safe_continue(c,...) S -| -list_for_each_entry_safe_continue(x,c,...) S -| -list_for_each_entry_safe_from(c,...) S -| -list_for_each_entry_safe_from(x,c,...) S -| list_for_each_entry_safe_reverse(c,...) S | list_for_each_entry_safe_reverse(x,c,...) S | hlist_for_each_entry(c,...) S | -hlist_for_each_entry_continue(c,...) S -| -hlist_for_each_entry_from(c,...) S -| hlist_for_each_entry_safe(c,...) S | -list_remove_head(x,c,...) -| -list_entry_is_head(c,...) -| sizeof(<+...c...+>) -| - &c->member | T c; | --=20 2.25.1 From nobody Sun Jun 28 00:10:37 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 ADE4EC43217 for ; Thu, 17 Feb 2022 18:50:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244664AbiBQSu2 (ORCPT ); Thu, 17 Feb 2022 13:50:28 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:45200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244640AbiBQSuR (ORCPT ); Thu, 17 Feb 2022 13:50:17 -0500 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FDA1522EF; Thu, 17 Feb 2022 10:50:02 -0800 (PST) Received: by mail-ej1-x632.google.com with SMTP id vz16so9556606ejb.0; Thu, 17 Feb 2022 10:50:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=unUH0vvyOBECU4IrGGURVauaUXMQWjJ7wkWDp8rOwCg=; b=Fl3qxwWQ5BLecyc2lLwyIjWUBs0RQaVZrk6sfZcHIjbYnBUMpeF0Gsv2igqs1xjD+9 5v1Kdd57Q35HedaFP09/Iom0huFuGfh0uCygJnKVLHh/wtbFHE6Nsa/itVlT5w+v36I2 8y+V8HUoVwJQV8aRG8ne216+yVcyYjqM3PIFBDoeZFAkMw1+S+0ka2O55icCeOCF3Yuy 68LKEqYcjBsZwc2MQpzC6/1bFen/+5+9/QiER2lfM6mEezOTo2t4SYFQuaIaCo7jaugC aCan1E2p2RnHQVIE92rWEdYnl7vYnBzK5wDkbdzhY4pKP8g3kluE8ubdW6sifyYxUzup qzBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=unUH0vvyOBECU4IrGGURVauaUXMQWjJ7wkWDp8rOwCg=; b=yvGPBavcbXt+SGR1HfCz6jubsiRCKXxUTymhu1B2Pc09ZuQ0PoPRAoT44b63N2RMKn JhQF/xNXPBpSHNtv7F0RVbO7YWMMG016Kx6nnK8YPnRSedg2QxtroMpXu5n1SHrm7KgP knny13f4hm+oJtIsHMltFY7FFr3K+2wLA61r929/dT1cuOhY0OHzieWLQqItIsrG73D5 Jq5ZzSUL3v5Z29zUTH/DwkOowxOYdi/1Ltl1Gb95/t/zZXEUEI+/rf1BDE177q0Y5S4J wsNvVVvZR43DjfRoVepzyKmRjlHTEcxU25T1jmNTjZvnSqwMRoUzFx6qZiojfxpiAV2k Sf2A== X-Gm-Message-State: AOAM531Xm+Ize6ZdCWDI/utSl9iwmz/ctbY5BWRDkokUxemKCMetpBtz 8GPV9BUllE+r+0s6NqK4UhA= X-Google-Smtp-Source: ABdhPJyDAa1AKzFWhHhYKIS5pXEt6jcYgUa5Vbkg43ImUDfsxSd5kyjg4MEf2hS5UQ9eOXQTcGseeA== X-Received: by 2002:a17:906:27db:b0:6ce:6f8:d0e3 with SMTP id k27-20020a17090627db00b006ce06f8d0e3mr3515168ejc.455.1645123800878; Thu, 17 Feb 2022 10:50:00 -0800 (PST) Received: from localhost.localdomain (dhcp-077-250-038-153.chello.nl. [77.250.38.153]) by smtp.googlemail.com with ESMTPSA id q7sm3493268edv.93.2022.02.17.10.49.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 10:50:00 -0800 (PST) From: Jakob Koschel To: 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." , Jakob Koschel Subject: [RFC PATCH 03/13] usb: remove the usage of the list iterator after the loop Date: Thu, 17 Feb 2022 19:48:19 +0100 Message-Id: <20220217184829.1991035-4-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220217184829.1991035-1-jakobkoschel@gmail.com> References: <20220217184829.1991035-1-jakobkoschel@gmail.com> 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" It is unsafe to assume that &req->req !=3D _req can only evaluate to false if the break within the list iterator is hit. When the break is not hit, req is set to an address derived from the head element. If _req would match with that value of req it would allow continuing beyond the safety check even if the _req was never found within the list. Signed-off-by: Jakob Koschel --- drivers/usb/gadget/udc/gr_udc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/udc/gr_udc.c b/drivers/usb/gadget/udc/gr_ud= c.c index 4b35739d3695..18ae2c7a1656 100644 --- a/drivers/usb/gadget/udc/gr_udc.c +++ b/drivers/usb/gadget/udc/gr_udc.c @@ -1695,6 +1695,7 @@ static int gr_dequeue(struct usb_ep *_ep, struct usb_= request *_req) struct gr_udc *dev; int ret =3D 0; unsigned long flags; + bool found =3D false; =20 ep =3D container_of(_ep, struct gr_ep, ep); if (!_ep || !_req || (!ep->ep.desc && ep->num !=3D 0)) @@ -1711,10 +1712,12 @@ static int gr_dequeue(struct usb_ep *_ep, struct us= b_request *_req) =20 /* Make sure it's actually queued on this endpoint */ list_for_each_entry(req, &ep->queue, queue) { - if (&req->req =3D=3D _req) + if (&req->req =3D=3D _req) { + found =3D true; break; + } } - if (&req->req !=3D _req) { + if (!found) { ret =3D -EINVAL; goto out; } --=20 2.25.1 From nobody Sun Jun 28 00:10:37 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 A5BD4C433EF for ; Thu, 17 Feb 2022 18:50:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243133AbiBQSud (ORCPT ); Thu, 17 Feb 2022 13:50:33 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:45660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244632AbiBQSu0 (ORCPT ); Thu, 17 Feb 2022 13:50:26 -0500 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E60F527D1; Thu, 17 Feb 2022 10:50:03 -0800 (PST) Received: by mail-ej1-x635.google.com with SMTP id lw4so9368369ejb.12; Thu, 17 Feb 2022 10:50:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=s2EDUr3xcd5mXkWQmbeSTJkbyfBykW87kRKEwtU/qi4=; b=KMhtZy1aw/g9aZk2dKJwQL+5I7qUzM9kmJTJZ67p5IR7ZCAUJ7h2I8tTGd3M/sknjm gi7SEe6J+b6Gn1l6vIe752TXM860itvoV6U2b+XDuotIxetF7l9JyCUyY5N68O2V/HnV LvBh5c1PFXGmkhWk2dHGOLbbFKdG+nlg302kC08igise0K2xFzjQe8pr/8GAgqsC/+tS 1n0KzDTkPdlJbP29JODQLNf75LgvBVLrrUh5KYmL5aUF0XE/eOn+LWW6+fiVLsaU0tzX xWT1Wl7lg1sw0kNz/39GS03sETp0uIcZxWPbHEGEHz0HneUSxEZoKCjwRn4wBcGbhJur w6bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=s2EDUr3xcd5mXkWQmbeSTJkbyfBykW87kRKEwtU/qi4=; b=CJI4MaEmBRDqflv3fxszJVDOfn0cVHQsI82vEpZs8cpkQuIA/Qx1PdlkvpiFVFfQcM Oy+Z6w92ekudbtAWZfoT5OJ2QbJF/zYeTj51v9PNenhET2ZZbPHykXm7r3doWs3U7kAg l4SQmwHh5nr+G032JWTwNdEiiBU3drislln95SGcvbSpc2VB9O7rYS1fLnuqXzYnzz5a CKiVAStFXZU8YnsQtD0r8psevJfnrkPt0NijrY/Fe5y2Y3Wb+sWupNEun6xkX/zNuN6u /6inRy8RMY71uIIlgQMqARiuBcg6kVPF3JUy52fnaUbNBz8lttzR7zD65XPmlJljBWbx DglQ== X-Gm-Message-State: AOAM5323aYi7H4YlhuSy1Sh9ef6Uq1HKkNhDFtnuMk3UKfShucWcAucp ZoEN4AZ0oYo6Fe4O8A/ns9I= X-Google-Smtp-Source: ABdhPJzTxZDIUqCgkh4rMHsmNsIMTp1nMdZ8ITZuVbR0PoJ9bbt1buiZMTtj+pfxqYHdC12tG5hM1A== X-Received: by 2002:a17:907:1256:b0:6b0:5b4c:d855 with SMTP id wc22-20020a170907125600b006b05b4cd855mr3727693ejb.458.1645123801867; Thu, 17 Feb 2022 10:50:01 -0800 (PST) Received: from localhost.localdomain (dhcp-077-250-038-153.chello.nl. [77.250.38.153]) by smtp.googlemail.com with ESMTPSA id q7sm3493268edv.93.2022.02.17.10.50.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 10:50:01 -0800 (PST) From: Jakob Koschel To: 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." , Jakob Koschel Subject: [RFC PATCH 04/13] vfio/mdev: remove the usage of the list iterator after the loop Date: Thu, 17 Feb 2022 19:48:20 +0100 Message-Id: <20220217184829.1991035-5-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220217184829.1991035-1-jakobkoschel@gmail.com> References: <20220217184829.1991035-1-jakobkoschel@gmail.com> 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" It is unsafe to assume that tmp !=3D mdev can only evaluate to false if the break within the list iterator is hit. When the break is not hit, tmp is set to an address derived from the head element. If mdev would match with that value of tmp it would allow continuing beyond the safety check even if mdev was never found within the list Signed-off-by: Jakob Koschel --- drivers/vfio/mdev/mdev_core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c index b314101237fe..e646ba5036f4 100644 --- a/drivers/vfio/mdev/mdev_core.c +++ b/drivers/vfio/mdev/mdev_core.c @@ -339,14 +339,17 @@ int mdev_device_remove(struct mdev_device *mdev) { struct mdev_device *tmp; struct mdev_parent *parent =3D mdev->type->parent; + bool found =3D false; =20 mutex_lock(&mdev_list_lock); list_for_each_entry(tmp, &mdev_list, next) { - if (tmp =3D=3D mdev) + if (tmp =3D=3D mdev) { + found =3D true; break; + } } =20 - if (tmp !=3D mdev) { + if (!found) { mutex_unlock(&mdev_list_lock); return -ENODEV; } --=20 2.25.1 From nobody Sun Jun 28 00:10:37 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 A0802C4332F for ; Thu, 17 Feb 2022 18:50:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244709AbiBQSuk (ORCPT ); Thu, 17 Feb 2022 13:50:40 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:45672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244638AbiBQSu0 (ORCPT ); Thu, 17 Feb 2022 13:50:26 -0500 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83D57527F3; Thu, 17 Feb 2022 10:50:04 -0800 (PST) Received: by mail-ed1-x52c.google.com with SMTP id m3so5339901eda.10; Thu, 17 Feb 2022 10:50:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/mv9B9kxz/tt3t/iKJDekMmwgu1k+2+Z11dWvEyqL7k=; b=av0CaKWg58n1u8l2MX25kTvxriQU1FjdWcRy3ytXNxDPTdn6WlupCBzzE3n7vKJqSt IhsjEAeZPT/42YQY3xgbSqtx4HJNHEQxtDd3esD4RvaqbYZOf7fi1L7DyjBtpz4sW0td sdX0tvcndQudy/z90Ixcr4VVEKOy9cpCSieLUgMZ3xgHQxcc6N0DdT5tyBPowZxvruEo M888EBYjCyS6er67ljHe0C/33gdlHGweJ//8owWNohAwU3EW4FXcdVcnVFlm+8G8tpzm SgyVdyS+gfbPNM00S0W/eT7S2WBdrU3UQPdq1pcOHLI9JEUEwPE4So0jVFe6AzrJkJ8X 0k5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/mv9B9kxz/tt3t/iKJDekMmwgu1k+2+Z11dWvEyqL7k=; b=2cEosemwdVmJCbiummqbMkF9OqYVA2X8QqHcrtzKrv4q+dTXxginKE+e4zkVXUSaYT z0UUQo8v5qC7wRljI+I3H67GfAXt+kV53sxZxpXkyh/skNgyw6dA0+406sxBjaO0bGVO GS4he+oAGU3eL15EUDHGZcOJmfL4m12yaM8CVplE6Tv5CQMAeZ104kVTtjLkjOMNm7ve mA6mPq53LKbsfSZQ2RuqwtB6D1T+P3EB3o6XExZpl38cy6Mn/Z0toQndlIwVmxKM5Z3h uBNncX/deotCJ2EbzA8MNiK2yn0+dCnLXK3ExOa+7G+nxmxSvczbM6Q7ZulqVjyGWWv5 DYAw== X-Gm-Message-State: AOAM53051kUtthWz1Slsd4ufYN4rUSPKGaHx6pWTzFLpAP1olzOZXDcD cVgP08cy7zh/AyqMtP4zh8A= X-Google-Smtp-Source: ABdhPJzemAhA0rQEUpJoQjey9TRCNS6UoffyAf+yvFAIbn8s6zmCTPE3XwgpAURBlOBHcOsTJ5YheA== X-Received: by 2002:aa7:c612:0:b0:40f:2a41:bddb with SMTP id h18-20020aa7c612000000b0040f2a41bddbmr4120824edq.291.1645123803138; Thu, 17 Feb 2022 10:50:03 -0800 (PST) Received: from localhost.localdomain (dhcp-077-250-038-153.chello.nl. [77.250.38.153]) by smtp.googlemail.com with ESMTPSA id q7sm3493268edv.93.2022.02.17.10.50.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 10:50:02 -0800 (PST) From: Jakob Koschel To: 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." , Jakob Koschel Subject: [RFC PATCH 05/13] drivers/perf: remove the usage of the list iterator after the loop Date: Thu, 17 Feb 2022 19:48:21 +0100 Message-Id: <20220217184829.1991035-6-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220217184829.1991035-1-jakobkoschel@gmail.com> References: <20220217184829.1991035-1-jakobkoschel@gmail.com> 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" To introduce a speculative safe list iterator, the iterator variable will be set to NULL when the terminating condition of the loop is hit. The code before assumed rentry would only be NULL if the break is hit, this assumption no longer holds. Once the speculative safe list iterator is merged the condition could be replace with if (!entry) instead. Signed-off-by: Jakob Koschel --- drivers/perf/xgene_pmu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/perf/xgene_pmu.c b/drivers/perf/xgene_pmu.c index 2b6d476bd213..523ff5c53103 100644 --- a/drivers/perf/xgene_pmu.c +++ b/drivers/perf/xgene_pmu.c @@ -1463,6 +1463,7 @@ xgene_pmu_dev_ctx *acpi_get_pmu_hw_inf(struct xgene_p= mu *xgene_pmu, struct resource_entry *rentry; int enable_bit; int rc; + bool found =3D false; =20 ctx =3D devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); if (!ctx) @@ -1478,13 +1479,13 @@ xgene_pmu_dev_ctx *acpi_get_pmu_hw_inf(struct xgene= _pmu *xgene_pmu, list_for_each_entry(rentry, &resource_list, node) { if (resource_type(rentry->res) =3D=3D IORESOURCE_MEM) { res =3D *rentry->res; - rentry =3D NULL; + found =3D true; break; } } acpi_dev_free_resource_list(&resource_list); =20 - if (rentry) { + if (!found) { dev_err(dev, "PMU type %d: No memory resource found\n", type); return NULL; } --=20 2.25.1 From nobody Sun Jun 28 00:10:37 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 B5AF2C433FE for ; Thu, 17 Feb 2022 18:50:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244736AbiBQSun (ORCPT ); Thu, 17 Feb 2022 13:50:43 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:45674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244651AbiBQSu0 (ORCPT ); Thu, 17 Feb 2022 13:50:26 -0500 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75325532D1; Thu, 17 Feb 2022 10:50:05 -0800 (PST) Received: by mail-ed1-x534.google.com with SMTP id c6so8586578edk.12; Thu, 17 Feb 2022 10:50:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aWAz7ch1YbYjOBGYWOA+abErwDCwzis1Yy80ikg8D98=; b=QMuA/YuZ0W74ytmZVJE4le6ip+JLNZSARf4bF7VHrDDsFsPKRVKoky7jQUbsW5VCkI 6mU8g2tqTCApm0uEH+kxh2dUOcqBfaeQTwwcNS9osxdvnKeLqM6OpoS7g0uBmBXF1piB EIuB2gjllDeTUeDrju15WMiEvC5AvaAFl68paZrX8MWLb8yXID5HLhdYlPy8oxs6kVVg LWrS2dEWLdcgMjUKTWeHwoLQlKUlIQGgmXA3QW4twc8qy18z3bMkBT/7ccH0Q19eG+uo 45Irv//5OACfVLFur0CvKTLUgDWFB72TxE28Ple+aC65+LnoEBmaDZRpOLMeckMwiaJ2 cjkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aWAz7ch1YbYjOBGYWOA+abErwDCwzis1Yy80ikg8D98=; b=3fAEcTAnyaavys7W9blaDHZH5P09K/xQa1njN2qfrfqsN+B28vF2xzq5NqHzHmaXgQ IW6aPdiJCLfK2hdN6csn+lC8YVk16LMtHp76bEog5woh4HzDrNC0IOnXxubjM6bFlDrS WCRzANkNILtsWzGX6ugPVksuH7OK1+lVCnXqPuxIbcF7l8BH+xP3jBL34Ai4wSSuT/7s efK8E9aN5dwNO3S7kVSzUpQFxs2E++SHmZu9FgoFtDcwgLC2rgzmABK7xB6vRgS9iuI4 vpaEVkBZx5BsbZ8X3Jq0J7rUoIUx7CiBdCXLmWxLWEYzdqbSiGI09CNik4sPrPFKFBSw kYgA== X-Gm-Message-State: AOAM532Y0+RsEJkPaub7JYjTn/JMU+6wNK4oL+EW7cBFUVbI4y5HYXZw giAXi5AR0weU1fOH1+OtsUw= X-Google-Smtp-Source: ABdhPJxL+kk5YSwPYn5msccPhV06gKGU69gSRSyODQVEtZA0itYwE3YS9fhTydgWYMYHPpG1FMU3TA== X-Received: by 2002:a05:6402:278b:b0:408:e865:45af with SMTP id b11-20020a056402278b00b00408e86545afmr3489783ede.44.1645123804097; Thu, 17 Feb 2022 10:50:04 -0800 (PST) Received: from localhost.localdomain (dhcp-077-250-038-153.chello.nl. [77.250.38.153]) by smtp.googlemail.com with ESMTPSA id q7sm3493268edv.93.2022.02.17.10.50.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 10:50:03 -0800 (PST) From: Jakob Koschel To: 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." , Jakob Koschel Subject: [RFC PATCH 06/13] ARM: mmp: remove the usage of the list iterator after the loop Date: Thu, 17 Feb 2022 19:48:22 +0100 Message-Id: <20220217184829.1991035-7-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220217184829.1991035-1-jakobkoschel@gmail.com> References: <20220217184829.1991035-1-jakobkoschel@gmail.com> 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" To introduce a speculative safe list iterator, the iterator variable will be set to NULL when the terminating condition of the loop is hit. The code before assumed info would be derived from the head if the break did not hit, this assumption no longer holds. Once the speculative safe list iterator is merged the condition could be replace with if (!info) instead. Signed-off-by: Jakob Koschel --- arch/arm/mach-mmp/sram.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-mmp/sram.c b/arch/arm/mach-mmp/sram.c index 6794e2db1ad5..b163d2da53e7 100644 --- a/arch/arm/mach-mmp/sram.c +++ b/arch/arm/mach-mmp/sram.c @@ -39,6 +39,7 @@ static LIST_HEAD(sram_bank_list); struct gen_pool *sram_get_gpool(char *pool_name) { struct sram_bank_info *info =3D NULL; + bool found =3D false; =20 if (!pool_name) return NULL; @@ -46,12 +47,14 @@ struct gen_pool *sram_get_gpool(char *pool_name) mutex_lock(&sram_lock); =20 list_for_each_entry(info, &sram_bank_list, node) - if (!strcmp(pool_name, info->pool_name)) + if (!strcmp(pool_name, info->pool_name)) { + found =3D true; break; + } =20 mutex_unlock(&sram_lock); =20 - if (&info->node =3D=3D &sram_bank_list) + if (!found) return NULL; =20 return info->gpool; --=20 2.25.1 From nobody Sun Jun 28 00:10:37 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 C98F9C433F5 for ; Thu, 17 Feb 2022 18:51:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244766AbiBQSup (ORCPT ); Thu, 17 Feb 2022 13:50:45 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:45684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244654AbiBQSu0 (ORCPT ); Thu, 17 Feb 2022 13:50:26 -0500 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74E77532D9; Thu, 17 Feb 2022 10:50:06 -0800 (PST) Received: by mail-ej1-x62d.google.com with SMTP id qk11so9473224ejb.2; Thu, 17 Feb 2022 10:50:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QtTQzoKh6SHELhVbK7UgiDGo5+sChsVz7qZ/mZQ4wRk=; b=LfG5Bww0Oy3sfjvyo7UZik9CTOze3VJSleCGeTzqBYFQBb7GCb81WoeNFCcwMDHAf2 6KDyRC9FbU54q681hajrooEUs1aUj1/X/WjuVoV3omcO+G34AxBIxo5VUbbH/vgctNu5 1nPnBsA8HLXrB09j1Wal4ffV2IdeaqW/EDGtqMw6CEptfUVX/9wu9p6LShOkI46d0IfV f3qb+rqVCZPlnikjHQsgKr/voCZUNSLcpsDDevv90CtSx//A6/d3IEgX3w+q0SNjp1ng d7OUNelVCif/q3zsuV5zwuSk4/D/XArrjWCtU6hHhewjLLju4BupSa/6nftUykdH73+X JYSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QtTQzoKh6SHELhVbK7UgiDGo5+sChsVz7qZ/mZQ4wRk=; b=wn0sqvOmQxI0h5noPo+XCYO52Gj+7O66j323rHL6/4f68W/mx2ECsONeQmrqgkfHpr YYHTRCYJkYfXopX70g4jKzeW/3Ag6kOgfufGkKgKdtjfP8TOMn92JBpwBOVg5sZtavwk USFwyFisy8Efj/OoErFXyrN/uU/EC8xMuf3bcwHVceQq63vwygpRsvhL2AE7R8uYCva8 9VeFJ0W1f3cD607iOPjvHHVGwhzdFIL9xxPS8FqH8AAcGX0kPdtL4+LWBQOXD+tW3YWU wnClr9WQMBekTCu8lU2RJtIBG0j6x4qufWkPl+818hxJHwwz6iU9Gp+gUlltc41zZ8Vy ZRlw== X-Gm-Message-State: AOAM530xyLyQNaDStFYAEKpaZViBoEdHdmG9A9PVLH52kb5ZnhAvMDCL q6iqQfSzOzpaIyFAgdzpOWk= X-Google-Smtp-Source: ABdhPJwmtpAYY/5eTeVCIMOnvNGpPiD0a5ljZK65FIzDqh88/jSCNF3UR1fL3OrGOhT7yseUT8jxJw== X-Received: by 2002:a17:906:284b:b0:6ae:9d05:e904 with SMTP id s11-20020a170906284b00b006ae9d05e904mr3341561ejc.345.1645123804953; Thu, 17 Feb 2022 10:50:04 -0800 (PST) Received: from localhost.localdomain (dhcp-077-250-038-153.chello.nl. [77.250.38.153]) by smtp.googlemail.com with ESMTPSA id q7sm3493268edv.93.2022.02.17.10.50.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 10:50:04 -0800 (PST) From: Jakob Koschel To: 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." , Jakob Koschel Subject: [RFC PATCH 07/13] udp_tunnel: remove the usage of the list iterator after the loop Date: Thu, 17 Feb 2022 19:48:23 +0100 Message-Id: <20220217184829.1991035-8-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220217184829.1991035-1-jakobkoschel@gmail.com> References: <20220217184829.1991035-1-jakobkoschel@gmail.com> 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" 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, str= uct udp_tunnel_nic *utn) */ if (info->shared) { struct udp_tunnel_nic_shared_node *node, *first; + bool found =3D false; =20 list_for_each_entry(node, &info->shared->devices, list) - if (node->dev =3D=3D dev) + if (node->dev =3D=3D dev) { + found =3D true; break; - if (node->dev !=3D dev) + } + if (!found) return; =20 list_del(&node->list); --=20 2.25.1 From nobody Sun Jun 28 00:10:37 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 C5D28C43219 for ; Thu, 17 Feb 2022 18:50:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244784AbiBQSur (ORCPT ); Thu, 17 Feb 2022 13:50:47 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:45658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244657AbiBQSu0 (ORCPT ); Thu, 17 Feb 2022 13:50:26 -0500 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A714532DC; Thu, 17 Feb 2022 10:50:07 -0800 (PST) Received: by mail-ej1-x634.google.com with SMTP id bg10so9440255ejb.4; Thu, 17 Feb 2022 10:50:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0f0QJvPY6l0YYLP/JaHLlRhitBBVJpxHfsxb6a5gC7w=; b=NOHnBOOXAe/1NOKIQEtHf1BD/jt26baU7KPvJ3ZJu0lACzvjtWpWH0bHsrMSFrMiG4 fbsIYo888fQ1/DhUvWC4j4rq17q3qLHPiZH8GljDv9JANH/ilWYaaKyjm+ySqwluPLHO ycesZ4+dZL1mP39QZkzjg22+FQtYM+/WEG71sWfD3bLEwjDThIvdGADqEnV50FVzYDXB t6pFv+LYM07FfktZxJQIMr0tpsLM5HsZCIBpwyg7u7T5t+qA6zrvHtU4Fa+ur+Anf14n 6NpdYq57CtPS5KKpw5dVGov8WfN+u2ZVvY9VjVWEvIb7fWIOjk3hj0MWQblEhoHzT9yl wNHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0f0QJvPY6l0YYLP/JaHLlRhitBBVJpxHfsxb6a5gC7w=; b=duq8XzKXq1ywrdUaSHoTlph8PgdwqWPkbQ7Wfew+O8zSj4NEajZAQukeC3uPlB7XFV fCW0kNOKdpEe7gQSkO7ZexaYnt9KQnid54I2ni1UtRyT/VN6fEH9cWAkrNuLt3ViKOSf unK73Od5Sb82lo94b0uqEYie8yaBgOjeulqoXle3YtBOArgwf7jas1BUDTze+RhgYzud hrOkTsL8/oZ0WyDtci0ymmVyo9akyCgYFSx85HC+tfpzwW2AAHcNWyoYThn1hQC9iM// QE5fajwovhHg294u9AYmmEdcePXsLs733V43tzPli/m/lIOSqMOq4UkyWM0i9HjnV992 WHGw== X-Gm-Message-State: AOAM531zQCLajO7cAQU1uk/hdOzhH26iwGs9s9V0WjMpqj1sV7VnP+Q/ EkHpYR3UODzsw/ZY1RASYek= X-Google-Smtp-Source: ABdhPJxjICCO3Vhtu+h5/lwmu13mORMlDwV7qSQHPyl3AlJ7a6Vo6Bk6htNd9lAOcvIdXee4sR6crQ== X-Received: by 2002:a17:906:eb4a:b0:6cf:bb0e:69fb with SMTP id mc10-20020a170906eb4a00b006cfbb0e69fbmr3501911ejb.149.1645123805842; Thu, 17 Feb 2022 10:50:05 -0800 (PST) Received: from localhost.localdomain (dhcp-077-250-038-153.chello.nl. [77.250.38.153]) by smtp.googlemail.com with ESMTPSA id q7sm3493268edv.93.2022.02.17.10.50.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 10:50:05 -0800 (PST) From: Jakob Koschel To: 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." , Jakob Koschel Subject: [RFC PATCH 08/13] net: dsa: future proof usage of list iterator after the loop Date: Thu, 17 Feb 2022 19:48:24 +0100 Message-Id: <20220217184829.1991035-9-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220217184829.1991035-1-jakobkoschel@gmail.com> References: <20220217184829.1991035-1-jakobkoschel@gmail.com> 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" With the speculative safe version of the list iterator p will be NULL if the terminating condition was hit and needs to be reset to p derived from the head, before using p->list. Signed-off-by: Jakob Koschel --- drivers/net/dsa/sja1105/sja1105_vl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/dsa/sja1105/sja1105_vl.c b/drivers/net/dsa/sja1105= /sja1105_vl.c index f5dca6a9b0f9..a4f2b95b09c4 100644 --- a/drivers/net/dsa/sja1105/sja1105_vl.c +++ b/drivers/net/dsa/sja1105/sja1105_vl.c @@ -40,6 +40,8 @@ static int sja1105_insert_gate_entry(struct sja1105_gatin= g_config *gating_cfg, if (e->interval < p->interval) break; } + if (!p) + p =3D list_entry(p, &gating_cfg->entries, list); list_add(&e->list, p->list.prev); } =20 --=20 2.25.1 From nobody Sun Jun 28 00:10:37 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 069FEC4321E for ; Thu, 17 Feb 2022 18:50:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244839AbiBQSuw (ORCPT ); Thu, 17 Feb 2022 13:50:52 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:45656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244656AbiBQSu0 (ORCPT ); Thu, 17 Feb 2022 13:50:26 -0500 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 266D1532E3; Thu, 17 Feb 2022 10:50:08 -0800 (PST) Received: by mail-ej1-x632.google.com with SMTP id hw13so9370984ejc.9; Thu, 17 Feb 2022 10:50:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FpBWiiaR04aEkFVsFIobErPGGU69qIWZRAZ0zLpDwAk=; b=c2asecRRx+vL9d/KAaw+7Qk8bKQr682XQKiP5ncBROE8yBceEkrg0vF+KZLEYtf+pX 48yxCW7KEp60jqF3eLYktmaWDbJJWD95L2rkthySbEBpvfi1kfKxXAfK8jqMd8d3Vu12 2B8E4S5QY9CT2EAc0EIXFSqZWiqkeN7ySwzW8EuBtyQh3/xeRTgWs+/etLtCKQWvgZ/+ Hfn4wDSW4QsCU8X2IfzlBqaCUq+B+Y/L4MzXxcQfqhYoQuGk0gxYPnIJOIZ3FNd9KGWE LtEswyev4pT+5dHSMcW3T0dT7zsjsAzP3T4SAfXdnVi2dVVB77Yyn+F8O5dYZgUnqILe IpDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FpBWiiaR04aEkFVsFIobErPGGU69qIWZRAZ0zLpDwAk=; b=tORuIJ3pxf9q14Xj8tVi3bdLhV113jC5rngIKXoQ9JwkptKI9abO+Tsz+0jFmlt7vm j3t09bQu1REak2V1JmW5JfIJfFK2bntaTVBZTeyQiiB5MLwq/inTMtZq4BldbqFmD1rf IgoLJ7JpsYKLvsvAa8up5yCKItgxQgQ4/mxzlozwpF17PnwPEuzC6F1iEsju8vEFqh8j ZwWfdTX7Sp/jW5a5PsSOmg59v82w3t+Huqh6RXec1/dVLZe255WRxml749LckDBuDKZE g+ki82JHm5QjtU7xHYze1lDN3N7fg7Cof3pXl+wrgN5aIYu4Os198rPNgi0XRxIo9ht+ 6gHQ== X-Gm-Message-State: AOAM531pbyKExd0CM07tet4UTGR7qCn5L3efatm3Jz7gsKCCl4/gafKo oBGzKPjhujA4PqJt706ILRY= X-Google-Smtp-Source: ABdhPJw7pGHg63Wd6YbBVyy9xUXridLW6IguhuGjOhd6bVObozVss8jPIV3gNzSSkSPXYpbSgDgcqg== X-Received: by 2002:a17:906:3bcb:b0:6cf:cf86:28d7 with SMTP id v11-20020a1709063bcb00b006cfcf8628d7mr3441587ejf.274.1645123806736; Thu, 17 Feb 2022 10:50:06 -0800 (PST) Received: from localhost.localdomain (dhcp-077-250-038-153.chello.nl. [77.250.38.153]) by smtp.googlemail.com with ESMTPSA id q7sm3493268edv.93.2022.02.17.10.50.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 10:50:06 -0800 (PST) From: Jakob Koschel To: 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." , Jakob Koschel Subject: [RFC PATCH 09/13] drbd: future proof usage of list iterator after the loop Date: Thu, 17 Feb 2022 19:48:25 +0100 Message-Id: <20220217184829.1991035-10-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220217184829.1991035-1-jakobkoschel@gmail.com> References: <20220217184829.1991035-1-jakobkoschel@gmail.com> 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" With the speculative safe version of the list iterator req will be NULL if the terminating condition was hit and needs to be reset to req derived from the head, before calling list_for_each_entry_safe_from(). Signed-off-by: Jakob Koschel --- drivers/block/drbd/drbd_main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index 6f450816c4fa..d98205b46f59 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c @@ -227,6 +227,8 @@ void tl_release(struct drbd_connection *connection, uns= igned int barrier_nr, list_for_each_entry(req, &connection->transfer_log, tl_requests) if (req->epoch =3D=3D expect_epoch) break; + if (!req) + req =3D list_entry(req, &connection->transfer_log, tl_requests); list_for_each_entry_safe_from(req, r, &connection->transfer_log, tl_reque= sts) { if (req->epoch !=3D expect_epoch) break; --=20 2.25.1 From nobody Sun Jun 28 00:10:37 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 D5EE5C43217 for ; Thu, 17 Feb 2022 18:50:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244801AbiBQSut (ORCPT ); Thu, 17 Feb 2022 13:50:49 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:45660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244659AbiBQSu0 (ORCPT ); Thu, 17 Feb 2022 13:50:26 -0500 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10BA2532E5; Thu, 17 Feb 2022 10:50:09 -0800 (PST) Received: by mail-ed1-x52d.google.com with SMTP id z22so11335916edd.1; Thu, 17 Feb 2022 10:50:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/E7vDJlr3ShCmm14rXXbmLyiW36foVXBUCP88CYbZEQ=; b=UZNPaJbQTUyjcPbr/PNBbpLXQRT7b7gb4jnh8EQAYcDSaxNcnhmHXvL8dFXa4HwFff ZBW0wACsTlHyQ5wWSmgJ8NQFgE5BWKRMrVIO+2Pt7/v71HX2bJUwn/ThGTRtJRQHdq8b 1CXkbmgbaAqofVAMOW6tWeegzhzQWbcwr/6PAhz4+hoaT4+ZNlG+l3+M2wVNdBZP+yxJ EPKctpk/bEedKWCtPMie0yZpg3BEuwbXeUSp+anEzwJcDIs5yfUJlRgncigJx+4Hvwvj Hdf6JRkQMBsA8wZmeLAYbs1SdpbRoq57z/xUVZA3zyOh3BM/9cPhu72bRO+3bwX8a0+h Xu3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/E7vDJlr3ShCmm14rXXbmLyiW36foVXBUCP88CYbZEQ=; b=sFsDuocLH5gct/BUFdeHOd28HsemhTgH6PEQDXRNnR8FJaAf8/nZ1ZCsNz4Q/b76m4 r+XRFzxWxMdm4l9XrOX8aJsnbPoEakH2QBE0Yb9k9Kua4XRpjPWM2RCd+9YYopOzh3Yd LLjmYC6NtCLfLJGemUmsNDaIOBw/YOVEe06kPeVtCooSECGzM6g+eyLjXKl3amG1dAmq ntXHap80y1UIDxjHR3KQ/xh+HHKDmslcYDIC5RwQrBiWRCNjpAFfzzvBeEqaAcOFzTkM viOvMmBmYXR11ccTuYLTKrjtgzHBAf69pBjEtnHfbul8b5ZLWrJ8c55hsTQCc4AvHm9I DVlw== X-Gm-Message-State: AOAM532d7r7sM3ISFLGLOgg7U/MX6fNW6kugBPrdqIasGXmeaO1ywLxg 1TaOqWRbX5pv4N/A4KwMv6SsCEsj8SiRxEgC3GJMoQ== X-Google-Smtp-Source: ABdhPJwohka0Px+31wNalaj/bE14nYoTr+UZeDUWbd8NMqNlF11xv6t6hTAYV4SuzQfXhziq5TgK/g== X-Received: by 2002:aa7:cc12:0:b0:410:cb7b:a9ba with SMTP id q18-20020aa7cc12000000b00410cb7ba9bamr4125709edt.196.1645123807668; Thu, 17 Feb 2022 10:50:07 -0800 (PST) Received: from localhost.localdomain (dhcp-077-250-038-153.chello.nl. [77.250.38.153]) by smtp.googlemail.com with ESMTPSA id q7sm3493268edv.93.2022.02.17.10.50.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 10:50:07 -0800 (PST) From: Jakob Koschel To: 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." , Jakob Koschel Subject: [RFC PATCH 10/13] powerpc/spufs: future proof usage of list iterator after the loop Date: Thu, 17 Feb 2022 19:48:26 +0100 Message-Id: <20220217184829.1991035-11-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220217184829.1991035-1-jakobkoschel@gmail.com> References: <20220217184829.1991035-1-jakobkoschel@gmail.com> 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" With the speculative safe version of the list iterator spu will be NULL if the terminating condition was hit and needs to be reset to spu derived from the head, before returning spu. Signed-off-by: Jakob Koschel --- arch/powerpc/platforms/cell/spufs/sched.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/powerpc/platforms/cell/spufs/sched.c b/arch/powerpc/platf= orms/cell/spufs/sched.c index 369206489895..5b2afda1653d 100644 --- a/arch/powerpc/platforms/cell/spufs/sched.c +++ b/arch/powerpc/platforms/cell/spufs/sched.c @@ -384,6 +384,8 @@ static struct spu *ctx_location(struct spu *ref, int of= fset, int node) } } =20 + if (!spu) + spu =3D list_entry(spu, ref->aff_list.prev, aff_list); return spu; } =20 --=20 2.25.1 From nobody Sun Jun 28 00:10:37 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 E51D7C4167B for ; Thu, 17 Feb 2022 18:50:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244819AbiBQSuu (ORCPT ); Thu, 17 Feb 2022 13:50:50 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:45692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244661AbiBQSu0 (ORCPT ); Thu, 17 Feb 2022 13:50:26 -0500 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33797532E8; Thu, 17 Feb 2022 10:50:10 -0800 (PST) Received: by mail-ej1-x62f.google.com with SMTP id hw13so9371183ejc.9; Thu, 17 Feb 2022 10:50:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9GeIjFGNQlPHjVyxQ9p3WniDxYBdTULWXBibB0Q7WqU=; b=AT/d0bDaXwtZUv7jKZa/T/kHh8PiMCYDol1M3oUDLpiPOrdMfuKNcAaeyYOM4FOEDf GUPNBXssMOCFu7E1YMimiFFyCBECoRonkTXSm0OEjHiSAq00kFr7fuQgpWsdVWM6bqAj pDty8X5XIYiHt1VIXXkhq5giWimZ6IG71n9/9Fn/42JUXQIBj1vJ5R023OqxSadstq/2 NfwdgdIq2mFCEWH6AnX0S1rr9PS3Fk5FNJ42bjX9ahNZct4ir37/PSwXnYaAomg6hDjI 2/5s5iNRIbn4btEc2OhD4CmzrblK0tf/jxPq+vK2saGrpMUCPr9fWmIVNy+7u3YVHKQr SlVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9GeIjFGNQlPHjVyxQ9p3WniDxYBdTULWXBibB0Q7WqU=; b=lGTvUoaxv3Zwrz0FtPf8IgHoy/iHXAFx+KFrvMWFppF9amoL+/v6iTOjUjgXl+bdNM /zeWgI9AMLFEL07R8yx5x2WJjL0WEk9YcuAObdJCXxJxcoJ2iSRUFwlqdnOGRtDdzBIm NibDDeDBmkHsRBGYHrzPeEeam3km5b86pXPCFmO8BMK7ZZl71VbErIZAVL+gGz/yGPMr a6UMLrpOOvIC7rhU30VlnxQn72OJlZkTq5dmOZWbfF2GxlYCSVpYKri0TVuuEIHwJgWp 7XWgj0VFXqBYoR46Ld2eZdhT2UAMhcI6iGAJuS7Wf1Z2Bi+MVMbXPFMpXlc4u29Flsyg gJSQ== X-Gm-Message-State: AOAM5327cEnJ3tJx4QvUcM4+9G8khdhoCJvk4Db/0bel7B494IDIAlxp VeNPBX3Ir6i2KAT0XmhQ154= X-Google-Smtp-Source: ABdhPJzEhaB0/+2MD0xixooNGABMXJOaaCXHVRbquvgJgqLFVkWEcuyfSRGuWC3n9nrrnkE4qcxY1g== X-Received: by 2002:a17:906:805:b0:6ce:41a8:113 with SMTP id e5-20020a170906080500b006ce41a80113mr3507086ejd.366.1645123808806; Thu, 17 Feb 2022 10:50:08 -0800 (PST) Received: from localhost.localdomain (dhcp-077-250-038-153.chello.nl. [77.250.38.153]) by smtp.googlemail.com with ESMTPSA id q7sm3493268edv.93.2022.02.17.10.50.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 10:50:08 -0800 (PST) From: Jakob Koschel To: 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." , Jakob Koschel Subject: [RFC PATCH 11/13] ath6kl: remove use of list iterator after the loop Date: Thu, 17 Feb 2022 19:48:27 +0100 Message-Id: <20220217184829.1991035-12-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220217184829.1991035-1-jakobkoschel@gmail.com> References: <20220217184829.1991035-1-jakobkoschel@gmail.com> 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" Since the list iteration cannot abort early, cur_ep_dist->list will always reference to ep_list and can therefore be replaced. Signed-off-by: Jakob Koschel --- drivers/net/wireless/ath/ath6kl/htc_mbox.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath6kl/htc_mbox.c b/drivers/net/wirel= ess/ath/ath6kl/htc_mbox.c index e3874421c4c0..cf5b05860799 100644 --- a/drivers/net/wireless/ath/ath6kl/htc_mbox.c +++ b/drivers/net/wireless/ath/ath6kl/htc_mbox.c @@ -104,7 +104,7 @@ static void ath6kl_credit_init(struct ath6kl_htc_credit= _info *cred_info, * it use list_for_each_entry_reverse to walk around the whole ep list. * Therefore assign this lowestpri_ep_dist after walk around the ep_list */ - cred_info->lowestpri_ep_dist =3D cur_ep_dist->list; + cred_info->lowestpri_ep_dist =3D *ep_list; =20 WARN_ON(cred_info->cur_free_credits <=3D 0); =20 --=20 2.25.1 From nobody Sun Jun 28 00:10:37 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 1ABD4C4167E for ; Thu, 17 Feb 2022 18:50:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244854AbiBQSuy (ORCPT ); Thu, 17 Feb 2022 13:50:54 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:45696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244641AbiBQSu0 (ORCPT ); Thu, 17 Feb 2022 13:50:26 -0500 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09E7F532EB; Thu, 17 Feb 2022 10:50:11 -0800 (PST) Received: by mail-ej1-x630.google.com with SMTP id lw4so9369046ejb.12; Thu, 17 Feb 2022 10:50:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Hlr/d/ERnD+pEeo92J4Kt7XJIn6OwqkRg8lOkxiwSi8=; b=D3JhmgGijhe3YeJmKhqsDrxlZTQ+nnCfZEpNZe7LPE6dXw10y8ST1pJLuyZD5e9HsZ lYgmzgswvUJZc5BG65+MszYjimqoG3vM6Ml372J3SYkzyHW1C54yGU6uIqZ4Q+ZuwpjO 5pr91+m/GY85v3qUuCnd9CdkAnGV4Tt9QSlOlvBfAaWd7cE87MC+cDAJ6WtT7kw7bxih Iq//cM3wU2OYT/r4Q6VO4yQnPs/wfiMma84wIdcgzJj85X6E8AzrfOpHeBmYj/jTDGch gGOgACbSUluM7aIKdO2fyOLJ2Zvxkah6bFib0+ej4/7nj4orH5+wHFMQI0spXovkWqSf eikA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Hlr/d/ERnD+pEeo92J4Kt7XJIn6OwqkRg8lOkxiwSi8=; b=bWofK+jJdNavO1pnJjEZI7zufYZcmW7GaypFCRhnCkXrL66XBtOMxKvTSuD37XKymg kp2T3zOZYMytx79M1XuFu0OckRA5glV231zXiW/wIztp+yiGQMNfreViXKK7xeB1O9im 95RqDthf8xBV23dp44MnUHynvQpVm6s3+LD1vdXIgp2qZN8795WupP6mBgJj3cEpPBMq NuMisIdZV9/TsU23UatV8j5TWKX/PPJiV5OsoEWZ/xEdNlbK2bbUGKmopF6/a2uB/8SG 5nTvM5LTkcf2p/guVT8a4rs61SNId9BCM195uZHBgoCoLz8EX6rJha2tDzDz47BzpZus 1lLQ== X-Gm-Message-State: AOAM531QsKxTM2NDa3BLF87/hz9l8j+rh+HAyU/bpV6FFonfyRf2ZZZa 273k8Kg50CbQAJ69fn4Hc1M= X-Google-Smtp-Source: ABdhPJyfVVaVMtT7VEzDXjRAGsw/dEiLnrRHhU06v4Gu0cLH+aZPppiyCb2ciGRnLovYHS91Jz/N0w== X-Received: by 2002:a17:906:1582:b0:6a8:3574:119 with SMTP id k2-20020a170906158200b006a835740119mr3374995ejd.173.1645123809650; Thu, 17 Feb 2022 10:50:09 -0800 (PST) Received: from localhost.localdomain (dhcp-077-250-038-153.chello.nl. [77.250.38.153]) by smtp.googlemail.com with ESMTPSA id q7sm3493268edv.93.2022.02.17.10.50.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 10:50:09 -0800 (PST) From: Jakob Koschel To: 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." , Jakob Koschel Subject: [RFC PATCH 12/13] staging: greybus: audio: Remove usage of list iterator after the loop Date: Thu, 17 Feb 2022 19:48:28 +0100 Message-Id: <20220217184829.1991035-13-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220217184829.1991035-1-jakobkoschel@gmail.com> References: <20220217184829.1991035-1-jakobkoschel@gmail.com> 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" The list iterator module should not be used if data =3D=3D NULL. module can only old a legitimate value if data !=3D NULL. Signed-off-by: Jakob Koschel --- drivers/staging/greybus/audio_codec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/greybus/audio_codec.c b/drivers/staging/greybu= s/audio_codec.c index b589cf6b1d03..e19b91e7a72e 100644 --- a/drivers/staging/greybus/audio_codec.c +++ b/drivers/staging/greybus/audio_codec.c @@ -599,8 +599,8 @@ static int gbcodec_mute_stream(struct snd_soc_dai *dai,= int mute, int stream) break; } if (!data) { - dev_err(dai->dev, "%s:%s DATA connection missing\n", - dai->name, module->name); + dev_err(dai->dev, "%s DATA connection missing\n", + dai->name); mutex_unlock(&codec->lock); return -ENODEV; } --=20 2.25.1 From nobody Sun Jun 28 00:10:37 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 2A668C4167D for ; Thu, 17 Feb 2022 18:50:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244872AbiBQSuz (ORCPT ); Thu, 17 Feb 2022 13:50:55 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:45700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244649AbiBQSu0 (ORCPT ); Thu, 17 Feb 2022 13:50:26 -0500 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6775522F1; Thu, 17 Feb 2022 10:50:11 -0800 (PST) Received: by mail-ej1-x634.google.com with SMTP id p9so9428087ejd.6; Thu, 17 Feb 2022 10:50:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zM+Hp2WVjXIaMPVWa2mQUV9ISK0HqYCrHac37DPF8pw=; b=BolWhcpS/6HTOxCBDIDuBl/h5hPvE9JkG/muCPtASmFx6+y5sndVaFYhkOPuPssfkn N+WkOdD+19aO763ei3Eu2WU9ftQN1kp2LK8+YjHnTP+d1bzQRvVcFvzir84VaaZy28qh snuYfFYT79MuLmapUWJYpxEHds4dVHjeyRv0d+6T2s9RwEDKe+ZQu7lgo9gpCtIbQU/4 3A+2aUTEa797Akyg/0hLzZ8eZn+p9LnYhoJV8TN3b6tuVbcogD/UXwv+tlWJ9SDzZCrg +P8c0Giv0WWtwBFlUZ0Oq0JXsY7DLui47NCMGSowRFKP1k4VtDZGpz5Ldv6bL7JB4BA9 14Uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zM+Hp2WVjXIaMPVWa2mQUV9ISK0HqYCrHac37DPF8pw=; b=lAJM+uUNMVavKbvgr28gZUaExTKc9uT1rHYnMG69Fhw0oJBm7L2q0ivNkcFybxExHh LR4uRJTpQNdFOtvUDnIzrj0AmoyICsyE4ChUrbm9fOeeEQTE+lUG2eYRJzRnVb6ft14j SucmcA9lwClWjVtJw92O1ayd7gx8UTeuuU8Ak9sitMhooQHeP1rDGwBtfmhWpB8GS0z3 M8IRzh937gDGCMla1rYyEr2LDXWvXICDZcKbdbPihNsTHUjtuNd5wBV53rJ3wkVBQo3K 7Gx1P+82R7x3kx5yWnYIVcnUOQ84zkhnC6rCZwOE+DDZ8QRQ53i4JhD1IFtbC9s+oWU+ DLKQ== X-Gm-Message-State: AOAM533hD4jvIIYgmzjWvGha5J/zTEofD4EJhVCDlgGJulOfsyK9ykFh QSZ209r1ahSqWVAniECldU32OKfK9Aj1Ok0bZmrk0Q== X-Google-Smtp-Source: ABdhPJxAa77nD+43PdtywudpGPQcktl4VzQxfGah+xpGfQDtyZvDMsYlyiTUJn8yQjbvV3UEVOkWiA== X-Received: by 2002:a17:906:82c4:b0:6b7:e0fc:c9e0 with SMTP id a4-20020a17090682c400b006b7e0fcc9e0mr3507573ejy.555.1645123810477; Thu, 17 Feb 2022 10:50:10 -0800 (PST) Received: from localhost.localdomain (dhcp-077-250-038-153.chello.nl. [77.250.38.153]) by smtp.googlemail.com with ESMTPSA id q7sm3493268edv.93.2022.02.17.10.50.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 10:50:10 -0800 (PST) From: Jakob Koschel To: 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." , Jakob Koschel Subject: [RFC PATCH 13/13] scsi: mpt3sas: comment about invalid usage of the list iterator Date: Thu, 17 Feb 2022 19:48:29 +0100 Message-Id: <20220217184829.1991035-14-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220217184829.1991035-1-jakobkoschel@gmail.com> References: <20220217184829.1991035-1-jakobkoschel@gmail.com> 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" Since the list iteration never exists early, reply_q is guaranteed to be an invalid variable and should not be used within _base_process_reply_queue(). Since I'm not sure what this code was supposed to do, I just marked this with this comment. Signed-off-by: Jakob Koschel --- drivers/scsi/mpt3sas/mpt3sas_base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt= 3sas_base.c index 511726f92d9a..a6746e124226 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -2013,7 +2013,7 @@ mpt3sas_base_sync_reply_irqs(struct MPT3SAS_ADAPTER *= ioc, u8 poll) } } if (poll) - _base_process_reply_queue(reply_q); + _base_process_reply_queue(reply_q); // COMMENT } =20 /** --=20 2.25.1