Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10254550ybi; Thu, 11 Jul 2019 02:19:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqwJuXcLTbE5njrPTea4X/3QCv6YIsx4jiUZKbMp5S/KDaNpZ4iB6rAQWZiQZHAjSYQy9qeA X-Received: by 2002:a17:902:27e6:: with SMTP id i35mr3488925plg.190.1562836745497; Thu, 11 Jul 2019 02:19:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562836745; cv=none; d=google.com; s=arc-20160816; b=s+FQaEHZBynZXuRR2Yc7whUsiqWW/FvHppGROzqh4It6PQJMocwKLbKE90/ha/lL8m EQPk+4Zg+RjQ7InENa7dZcVWLdtDEK5ty00iqyqjGEastMrUnEIyojHahl4LXXq5UN9A 2vMBmJGLq6yfWRKNTJCY8hXY8XO4cyVqn1NnPivj2EXFUg/moW9mgTLJWOAAlwelTxyN oeK+tKlJmdotFEoXVFhItk8UfH94YHfcVlxrjrOZKfEYVP9xQgUl+ieqDn1iPy9fUslm D4n8BIUCOL8l8MsiEu2lMczvpQqBAj/Z4e4LzQ71ESfSWd+hS77NDSYKCDkNmjRZztsz NbAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=BJaqNQiaWz4IxMifm+8jkrjlESYxJn/dng2qMZSFyTE=; b=UsHb7cGwI7JWrO21PPu8aB+HFkMNkuCzl/KxYmfAKPjEq602uqVzw7cqmgIp4ZWRdj ++DGpP3iHCxloKrBZYH+TJblguisb7Fm7rkjJz7xUVOIFSIhWPU3j7Ikymw2HRO8icfM 2LXop2rV7h3QOUhHu3MnqSEMZuPGV29maMIjxePQOcAraCDEFehtN+WXohOuU/itaPJA +Om+cYtkMtoYSrwa5im9NOQu0/wzq2PGCsj/gd4QWHndF5Uz1C3SDNrU5SAYn/Y/iCGh cHjuodQTq5Vgng0/tgfU8Pxo6w9jARXqYpsLoY8BheHD06ZsVmniwCWLgTGzq8I72ySh /6pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Yll/OcT2"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j187si4633113pge.591.2019.07.11.02.18.49; Thu, 11 Jul 2019 02:19:05 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b="Yll/OcT2"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728307AbfGKJR2 (ORCPT + 99 others); Thu, 11 Jul 2019 05:17:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:34744 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727972AbfGKJR2 (ORCPT ); Thu, 11 Jul 2019 05:17:28 -0400 Received: from linux-8ccs (nat.nue.novell.com [195.135.221.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9000B21537; Thu, 11 Jul 2019 09:17:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562836648; bh=BJaqNQiaWz4IxMifm+8jkrjlESYxJn/dng2qMZSFyTE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Yll/OcT24z/unZKChbj3v+bkPTEA1e678eVnFAxCeW2RUFxNS8mz8Tr9TMv42wVEz GA2Gdp8DD89ezkFOAArBdHQK/59cTzhgrlPAYlsDTE/jQv6iapTLvkqq+ET3YvQOCP EyYq9dIhBdYKK8vZMOOQjHD3qhMPFJZyIBCdrao8= Date: Thu, 11 Jul 2019 11:17:23 +0200 From: Jessica Yu To: Zhiqiang Liu Cc: rusty@rustcorp.com.au, kay.sievers@vrfy.org, clabbe.montjoie@gmail.com, LKML , wangxiaogang3@huawei.com, zhoukang7@huawei.com, Mingfangsen Subject: Re: [PATCH v2] module: add usage links when calling ref_module func Message-ID: <20190711091723.GA28411@linux-8ccs> References: <4fec6c3b-03b8-dd57-4009-99431105a8a5@huawei.com> <20190709161039.GA3501@linux-8ccs> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-OS: Linux linux-8ccs 4.12.14-lp150.12.28-default x86_64 User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org +++ Zhiqiang Liu [11/07/19 14:03 +0800]: > > >On 2019/7/10 0:10, Jessica Yu wrote: >> +++ Zhiqiang Liu [03/07/19 10:09 +0800]: >>> From: Zhiqiang Liu >> >>> V1->V2: >>> - remove incorrect Fixes tag >>> - fix error handling of sysfs_create_link as suggested by Jessica Yu >>> >>> Signed-off-by: Zhiqiang Liu >>> Suggested-by: Jessica Yu >>> Reviewed-by: Kang Zhou >>> --- >>> kernel/module.c | 18 ++++++++++++++---- >>> 1 file changed, 14 insertions(+), 4 deletions(-) >>> >>> diff --git a/kernel/module.c b/kernel/module.c >>> index 80c7c09584cf..672abce2222c 100644 >>> --- a/kernel/module.c >>> +++ b/kernel/module.c >>> @@ -837,25 +837,26 @@ static int already_uses(struct module *a, struct module *b) >>> ?*??? 'b' can walk the list to see who sourced them), and of 'a' >>> ?*??? targets (so 'a' can see what modules it targets). >>> ?*/ >>> /* Module a uses b: caller needs module_mutex() */ >>> int ref_module(struct module *a, struct module *b) >>> { >>> +??? struct module_use *use; >>> ????int err; >>> >>> ????if (b == NULL || already_uses(a, b)) >>> @@ -866,9 +867,18 @@ int ref_module(struct module *a, struct module *b) >>> ????if (err) >>> ??????? return err; >>> >>> -??? err = add_module_usage(a, b); >>> +??? use = add_module_usage(a, b); >>> +??? if (!use) { >>> +??????? module_put(b); >>> +??????? return -ENOMEM; >>> +??? } >>> + >>> +??? err = sysfs_create_link(b->holders_dir, &a->mkobj.kobj, a->name); >> >> Sigh. This ultimately doesn't work because in load_module(), we use >> ref_module() in resolve_symbol(), and mod->mkobj.kobj doesn't get >> initialized until mod_sysfs_init(), which happens much later in >> load_module(). So what happens is that the ref_module(mod, owner) call >> in resolve_symbol() returns an error because sysfs_create_link() fails here. >> We could *maybe* move sysfs initialization earlier in load_module() >> but that is an entirely untested idea and I would need to think about >> that more. > >Thank you for the reply. >I have tested the patch through livepatch. Maybe I miss somethings. >I will rewrite the patch and test it entirely before sending the v3 patch. Thanks Zhiqiang. A boot test and testing loading modules with dependencies would be really appreciated. Thanks! Jessica