Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp552333rwb; Thu, 27 Jul 2023 17:44:44 -0700 (PDT) X-Google-Smtp-Source: APBJJlFkPXN9B8Nxs6BwI+PVNkiaqeCBvBfb7x2ZVQGVC8LFrESUUcHiXFzeLxO7egbBzWhe4AvQ X-Received: by 2002:a54:480b:0:b0:39c:a986:953a with SMTP id j11-20020a54480b000000b0039ca986953amr940553oij.34.1690505084146; Thu, 27 Jul 2023 17:44:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690505084; cv=none; d=google.com; s=arc-20160816; b=JQDeg3DNZO1EEuFDNee4vvNVIvLtd3nY9R4yAioqf4kmz8uySF2OUfOJBfdG2MLrMs /idmTjvFMwFy89N1CH+Ha28c19NS5qq64rfclm706s2gCloIA/QgrKFRy8ulJuqbb+rU nQtipxof4vRtDSeEPDabydQfZ3n/emMjnyc3gHZP1S3jJjiVLEKkyb4lf/6Gs5W2NbBb XObp3H102zHnmfMZmq1k/y7MUDmfS+iFAE3IT8VumJVvRyGCVvwjSUzokBfT+fB9qyLc G9JLwqe3qfw11imTECeafC9ermrAtVM8G9PsHPElzM0R2h0VYM+Mfgg5n+MZByx81BXY sc0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=KUUKl8lpFugIZxEZ3GnApaiUpJS8dPiRyGkEHfkzlvo=; fh=OyXhNSAMBLB35nIBLDm1J4o79swo8UEYOzEEzXeQiKI=; b=FSQHJSj02DbpbUocYNhryB1VG8oYlEFd2wn3rsQTljgHp3b8+1R2I7uQp//HVzgJS4 GbYbnu9oZP7mJ2PyPhWKaN2NdRMkHUmXHlrTnCp64As61pEPMXyWC82CSxi5r207iXQJ wCI1xz+HqKjvtFqGEJZIdpenn4MrL98G8L/qUv15GxjR/UHSonlF8XQG+pGEanICfvho a6/Gr5hGcbhOdazkMiUyObF3smKKbULhErJ3IV+BKCggiE2QXNf6+R3k74+0C6tgu3pN iZEY4+LIzo9Ll2xRXnzZ+EUFEP2B2Np/kgydGo1QSpHYl1kNUOznh3YL7/eq4wMx9hFL 7PNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=k0s7B5cl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e22-20020a635456000000b00563e080a7cdsi1979354pgm.242.2023.07.27.17.44.05; Thu, 27 Jul 2023 17:44:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=k0s7B5cl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230292AbjG0XsZ (ORCPT + 99 others); Thu, 27 Jul 2023 19:48:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229448AbjG0XsY (ORCPT ); Thu, 27 Jul 2023 19:48:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F58530F7; Thu, 27 Jul 2023 16:48:23 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E749061EFF; Thu, 27 Jul 2023 23:48:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8CB57C433C7; Thu, 27 Jul 2023 23:48:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690501702; bh=leAC5f+fPlZ/cfu7jAxbCYBzhzOHtZlQG/UH+1WwYJQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=k0s7B5clwMRIUnKXxzjuwBkCWS4MLUNGeaj8MCrix0Inaxm9GcXL01oJrC+TDOlTg ArMX+warqSug5XXdNKHTZ+WX+q0fXx7DfyExGtR38N4NQkgnDQN334EWobNwkDFXzh 9lruDdJRfoyOwZBR3iYUL0anjcSSh/ouNhV9UhGYauq3idrDurIAb9ZJGOUDNezQ+h TT2BJYT6OMZ4L+TjeYbUMLrDuNN8QjsnvgmKLIPThgDbfVxf5MZ9mL/SZXfVU8E+uG R1SMBWAVNuHQNbUcS4otOrKg7FPdPx2r52OeUp59iL+dspB9gSnzatRN0Z0Mv+/yoZ P4ezf3AdhlvcA== Date: Thu, 27 Jul 2023 16:48:20 -0700 From: Jakub Kicinski To: Sergey Shtylyov Cc: Paolo Abeni , Zheng Wang , , , , , , , , , , , , , , , , <1395428693sheep@gmail.com>, Subject: Re: [PATCH v4] net: ravb: Fix possible UAF bug in ravb_remove Message-ID: <20230727164820.48c9e685@kernel.org> In-Reply-To: <607f4fe4-5a59-39dd-71c2-0cf769b48187@omp.ru> References: <20230725030026.1664873-1-zyytlz.wz@163.com> <20230725201952.2f23bb3b@kernel.org> <9cfa70cca3cb1dd20bb2cab70a213e5a4dd28f89.camel@redhat.com> <607f4fe4-5a59-39dd-71c2-0cf769b48187@omp.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 27 Jul 2023 21:48:41 +0300 Sergey Shtylyov wrote: > >> Still racy, the carrier can come back up after canceling the work. > > > > I must admit I don't see how/when this driver sets the carrier on ?!? > > The phylib code does it for this MAC driver, see the call tree of > phy_link_change(), on e.g. https://elixir.bootlin.com/linux/v6.5-rc3/source/... > > >> But whatever, this is a non-issue in the first place. > > > > Do you mean the UaF can't happen? I think that is real. > > Looks possible to me, at least now... and anyway, shouldn't we clean up > after ourselves if we call schedule_work()?However my current impression is > that cancel_work_sync() should be called from ravb_close(), after calling > phy_{stop|disconnect}()... > > >> The fact that ravb_tx_timeout_work doesn't take any locks seems much > >> more suspicious. > > > > Indeed! But that should be a different patch, right? > > Yes. > > > Waiting a little more for feedback from renesas. > > Renesas historically hasn't shown much interest to reviewing the sh_eth/ravb > driver patches, so I took that task upon myself. I also happen to be a nominal > author of this driver... :-) Simplest fix I can think of is to take a reference on the netdev before scheduling the work, and then check if it's still registered in the work itself. Wrap the timeout work in rtnl_lock() to avoid any races there.