Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp4457053pxb; Mon, 21 Feb 2022 22:12:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJzbt2w0EDUAO9hOwIjbiuPKnZwAEnXDCTyfcxcSOhJW8fIU309qPrLpOK6CUWUJ0hOZ+04D X-Received: by 2002:a62:e917:0:b0:4e0:1646:3b82 with SMTP id j23-20020a62e917000000b004e016463b82mr23465702pfh.57.1645510337526; Mon, 21 Feb 2022 22:12:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645510337; cv=none; d=google.com; s=arc-20160816; b=vjWw/brmQRDnM+RTloBtYeuQn1it2aPivK29YSsOWo7lkJUTg3/5GfikozdGfK943Q q0s5g6oTnqbV7V3T8uGrTG8jZqXU60cP8vfwZKg/ZFoV9eDuPrKhDV9igxGZ1FW9yjHW TFuibgEEW6oaKw+lp7lYoBfF/GuxZZ9H0S0G7nrQYZWb2RgQ4rJN1tZgfTbq+/XfhgLk Y11tMbcZNTk1OAZxTH2Y0HrywmDNlrMxiA0pbgpUe19uBvevfZmBBP64qIwshoNw0uJM sQE7PshQ7XU93Vko4lokxHHgwkhdtONCB68WAH2vaBmjRBBEdpz9pTzSPlWHdYZC+IqJ dXFQ== 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=bZicIL5cRP1usT59AwnlWg3/orMhghQTF4iswG/60Pk=; b=Tmq02F5ZP6IX1zxNx/a2SLBqZmwHL21crN4CiO6sHlAqzkd4/n6m32O8ASqalNk0KZ DDje9ax6313Skzfqr8CwO8IXqMSsENnBAksT2yXocMSnVaLLQY2iBOdy+RFajxNNAZqF gdv7KIGEX9f4Vu8QB/BYX+SF+YETd+1Ov2JsiBdVZCW/mozsdALQmo0eqm63jK8FBf7x Xjun9UK8cEVgc+ZhdbT7UHj5mRGd4q8hlNRgFqsygvSk9n1vejbGJ2xsd619eHXZrIE5 pHW1nXlKp0S2N+pq5uBW45fTLavuW0G61S4FbLI1J6z4wCLiwtlc9ggCcLdZEmQW5PlJ TF5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=p1RvUpj2; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id b12-20020a17090a488c00b001b98e640f6asi1149258pjh.40.2022.02.21.22.12.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 22:12: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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=p1RvUpj2; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3B2F414035; Mon, 21 Feb 2022 21:51:40 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229985AbiBVFwA (ORCPT + 99 others); Tue, 22 Feb 2022 00:52:00 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:41250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229982AbiBVFvx (ORCPT ); Tue, 22 Feb 2022 00:51:53 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C7766D86C; Mon, 21 Feb 2022 21:51:27 -0800 (PST) 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 369A1615BB; Tue, 22 Feb 2022 04:54:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6BCA4C340E8; Tue, 22 Feb 2022 04:54:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645505683; bh=dnyqlK3OpBmJqYgjXqP/BKGSr4v69qL9WeXUJpQmIsU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=p1RvUpj2koTsEzgAlIoUn2jfGydNzSK2skRBGq8ZWrccAg7xnAjL8M0V/AOL1PqJM Zl894QLv3B809urdpnbvjMsN30TgmQ1WH6sR3EPWJu39cyGpOFJjorx1CIlxXAsiNd q5cjXcqk3UUsY1jD/U0Hc7swjcU+BXTWCEKCs4nGY5LQDWdFgmU5FnokGQTm49h/6a hPTg+fs0jFVW+Y1VierTXltu80GrN45BeqA0RMmPjyaX3fxblGVsmOJ12t0ROwB6oK IuRhE3VqJ5jgHWep5/tOEF840Nx4VRp1Rb0c1Gx3Sfjh/3Sl1fmFwcpCFZu6X0ERR7 eU8YM+k50mEDg== Date: Mon, 21 Feb 2022 20:54:42 -0800 From: Jakub Kicinski To: Niels Dossche Cc: Jiri Pirko , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] devlink: use devlink lock on DEVLINK_CMD_PORT_SPLIT Message-ID: <20220221205442.20da7c35@kicinski-fedora-PC1C0HJN.hsd1.ca.comcast.net> In-Reply-To: <18b57f7b-6aa6-e87f-e187-feead42fc90a@ugent.be> References: <18b57f7b-6aa6-e87f-e187-feead42fc90a@ugent.be> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Mon, 21 Feb 2022 14:33:25 +0100 Niels Dossche wrote: > devlink_nl_cmd_port_split_doit is executed without taking the devlink > instance lock. This function calls to devlink_port_get_from_info, which > calls devlink_port_get_from_attrs, which calls > devlink_port_get_by_index, which accesses devlink->port_list without the > instance lock taken, while in other places devlink->port_list access > always happens with the instance lock taken. The documentation in the > struct also say that the devlink lock protects the port_list. > > The flag for no locking was added after refactoring the code to no > longer use a global lock. > > Fixes: 2406e7e546b2 ("devlink: Add per devlink instance lock") > Signed-off-by: Niels Dossche You can't do this, driver will likely try to register ports and try to re-acquire the same lock. I have a series queued to fix this by moving the locking into drivers. I'll send it out this week.