Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1163334ybi; Fri, 14 Jun 2019 09:38:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqwNVw9SHu5/zdDTHE5u6KMQpWY1db+oGASzas89ji3rV5unRhFJnE+Pg03eeDKs65RLtfwh X-Received: by 2002:a17:902:1e6:: with SMTP id b93mr50645510plb.295.1560530329642; Fri, 14 Jun 2019 09:38:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560530329; cv=none; d=google.com; s=arc-20160816; b=cR4QZuG7n8npqB4LQgmP+QuNTU03i5MnuHB4YQhDirwtPN9UjxTfXTgvDmOUEOwEIe qpjvTHCTdJT3hCO2YHIOWEsChmpxyyrEeitfiDuX4O7+zT+6pZMYTOKpbfmG+waZArhR zhh/CWRThkPWjrfEm3x863sysCsA9//58W9mgp0Hhka8Xxy/Eu8ZQUm02koSXfshlVEB AxGWTcFdseZyGDXAqcICzYWDpa1knuW+KyNI+ClNbj2Acpcm+xLpfwL7dbUgwUgotXAR 7bwZlwXof6L3oXlWocUWGVcmkV74HDYSnwQLp0dD1/+aqxEAcqvg+jj48BS/cqfpp2US NjxQ== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Z4SjrzX9/OeU+Lv+uUWBB57LwmWSQVK6ShfsyoZoruU=; b=nyv18xYp+9ILPHFiwubZ3I1vA5VolZ+I1aLC7/dXLbQLN3YlgoIN9utiXOaQ+oDYLh 3Xz1DcDWQn6kSMczA4PMek8nV4lRmOjVEcPgVsh/sHo2FLA0yKcd3CJ4RKjZ+34Kyt2q 91lQ29+ReT/5hbxNrYUwLU7gp8uB3XPuo43/RvcPSRw56DLC3kpi0La2UKI3ZLdUOAnJ my4ThGFhhmZOVpjHxy/HSFSAEbBoH7rXJpQS9jgirxX8sCk4UU4vw7QAIDCLIrZ0Zge7 J2CoiUEusY3ZyJf0KfSq6qgkgVTEVU7rV+0bM/Q+5yc/B9sWbcWOwSRxtiM+H73R0KGn u1dQ== 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 g21si2626100plo.306.2019.06.14.09.38.34; Fri, 14 Jun 2019 09:38:49 -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; 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 S1726322AbfFNQg5 (ORCPT + 99 others); Fri, 14 Jun 2019 12:36:57 -0400 Received: from mx2.suse.de ([195.135.220.15]:38268 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726063AbfFNQg5 (ORCPT ); Fri, 14 Jun 2019 12:36:57 -0400 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 E210FAF58; Fri, 14 Jun 2019 16:36:55 +0000 (UTC) Date: Fri, 14 Jun 2019 18:36:55 +0200 From: Libor Pechacek To: Joe Lawrence Cc: Petr Mladek , Miroslav Benes , linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, linux-kbuild@vger.kernel.org Subject: Re: [PATCH v4 00/10] klp-convert livepatch build tooling Message-ID: <20190614163655.GC15002@fm.suse.cz> References: <20190509143859.9050-1-joe.lawrence@redhat.com> <20190614083435.uq3mk6mprbatysol@pathway.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 On Fri 14-06-19 10:20:09, Joe Lawrence wrote: > On 6/14/19 4:34 AM, Petr Mladek wrote: [...] > > Anyway, I am curious about one thing. I saw: > > > > function __load_mod() { > > local mod="$1"; shift > > > > local msg="% modprobe $mod $*" > > log "${msg%% }" > > ret=$(modprobe "$mod" "$@" 2>&1) > > if [[ "$ret" != "" ]]; then > > die "$ret" > > fi > > > > # Wait for module in sysfs ... > > loop_until '[[ -e "/sys/module/$mod" ]]' || > > die "failed to load module $mod" > > } > > > > Is the waiting for sysfs really necessary here? > > > > Note that it is /sys/module and not /sys/kernel/livepatch/. > > I can't remember if that was just paranoid-protective-bash coding or > actually required. Libor provided great feedback on the initial patch > series that introduced the self-tests, perhaps he remembers. I don't recall analyzing this spot in detail but looking at it now I don't see anything wrong with it. While the check is likely superfluous, I'm not against keeping it in place. > > My understanding is that modprobe waits until the module succesfully > > loaded. mod_sysfs_setup() is called before the module init callback. > > Therefore the sysfs interface should be read before modprobe returns. > > Do I miss something? > > > > If it works different way then there might be some races because > > mod_sysfs_setup() is called before the module is alive. > > All of this is called from a single bash script function, so in a call stack > fashion, something like this would occur when loading a livepatch module: > > [ mod_sysfs_setup() ] > modprobe waits for: .init complete, MODULE_STATE_LIVE > __load_mod() waits for: /sys/module/$mod > load_lp_nowait() waits for: /sys/kernel/livepatch/$mod > load_lp() waits for: /sys/kernel/livepatch/$mod/transition = 0 > test-script.sh > > So I would think that by calling modprobe, we ensure that the module code is > ready to go. The /sys/module/$mod check might be redundant as you say, but > because modprobe completed, we should be safe, no? > > The only "nowait" function we have is load_lp_nowait(), which would let us > march onward before the livepatch transition may have completed. And even that one is waiting for the live patch module name appear under /sys/kernel/livepatch/. This is IMHO acceptable level of paranoia. Libor -- Libor Pechacek SUSE Labs