Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp8278537ybc; Fri, 29 Nov 2019 08:04:34 -0800 (PST) X-Google-Smtp-Source: APXvYqxxY8dbtFcM48acUsfk6JRadRliZKNtApAXngKhDi4HzbItRFCMZBLtwcqkoqnsnd3+7+f0 X-Received: by 2002:a17:906:c296:: with SMTP id r22mr45049850ejz.156.1575043474710; Fri, 29 Nov 2019 08:04:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575043474; cv=none; d=google.com; s=arc-20160816; b=TuoODwPUZRNCqYjQ9je/Yky0cTnkNQKbkU5C+E7NwhodwNcR8yzblrNsM62WNbyd+u yxVMzFPKtTVEcuzRFkx4Te+iSmpaCWTJGODxb5sBHggkwH/5VoSIvh4u3Ky6+wvesRH0 KpxfJGbQGWBVYz4nxzqkh8fzK5vmDIddMIE6z6qJ+AoHbQnoowjcjUVFurLagIWgck8f uHPSGO7iqup+SIshScOnWDUYaZTY49+IOWnHSRnxWlo5s7PvbXnsWHWLtv6kG5KuJTAW n1MSgH1jsjUmjWHFCWtGq92jGd5AiIMCLllVg+uD2X2E4MAHQw4AYOZsWfFAfsDyfsJA cKaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=yXKWGEs5zMbt4fecaFjV6m48YaY+6lVqKX9tY3AeUcs=; b=cvr68UbJWugD9wZYHrzwDqohsMFSFPSXVj+nzUtZk+wUq48695+eFql2OFNcXFsHcW x3RD9mZ931tLQAlyH+XZFnO2Qw5OpFn9q3Yr48sv6VF1lfD3ukKlsOTPSFmDg27oqdfB GDKPQq+y3AT92M7pLJhx6Qe2uF0oW/ONs3rCasXCOfxKSxWP9WcSm/1AhkQwMaFAw0QS +8sye0Qyice1da9wYtz/FRP7kpOyCDAck61EGERjnsL4Oufv5HUDgK+JpDihLSODr8rg PlN7UWIu3XVGg3icLu8SxZFkbnNRP1fXxcRJCUpIE3SFDtVfOT1+dSnash9ibyhc+CIl GwYg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w23si6843297edi.339.2019.11.29.08.04.08; Fri, 29 Nov 2019 08:04:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726963AbfK2QAv (ORCPT + 99 others); Fri, 29 Nov 2019 11:00:51 -0500 Received: from mx2.suse.de ([195.135.220.15]:49952 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726915AbfK2QAv (ORCPT ); Fri, 29 Nov 2019 11:00:51 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id DCBFBAF27; Fri, 29 Nov 2019 16:00:49 +0000 (UTC) Subject: Re: [PATCH v2 1/2] xen/xenbus: reference count registered modules To: Paul Durrant Cc: xen-devel@lists.xenproject.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Stefano Stabellini , Boris Ostrovsky , Juergen Gross References: <20191129134306.2738-1-pdurrant@amazon.com> <20191129134306.2738-2-pdurrant@amazon.com> From: Jan Beulich Message-ID: <599c254c-035b-33a0-9f32-866ffe644ad5@suse.com> Date: Fri, 29 Nov 2019 17:00:58 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1 MIME-Version: 1.0 In-Reply-To: <20191129134306.2738-2-pdurrant@amazon.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 29.11.2019 14:43, Paul Durrant wrote: > To prevent a module being removed whilst attached to a frontend, and Why only frontend? > hence xenbus calling into potentially invalid text, take a reference on > the module before calling the probe() method (dropping it if unsuccessful) > and drop the reference after returning from the remove() method. > > NOTE: This allows the ad-hoc reference counting in xen-netback to be > removed. This will be done in a subsequent patch. > > Suggested-by: Jan Beulich > Signed-off-by: Paul Durrant > > --- a/drivers/xen/xenbus/xenbus_probe.c > +++ b/drivers/xen/xenbus/xenbus_probe.c > @@ -232,9 +232,11 @@ int xenbus_dev_probe(struct device *_dev) > return err; > } > > + __module_get(drv->driver.owner); I guess you really want try_module_get() and deal with it returning false. Jan