Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp177999lqc; Thu, 7 Mar 2024 14:01:50 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVAsQO2OYUBfWwFYSVHWcU/4R1wgNMPq/pcokxndZkdeagvOcb4uvaRK3u9yysVnLWONHMkuaZQHeroyt/TukiIQnYsY3KKz0JGUC7mJg== X-Google-Smtp-Source: AGHT+IFzTI03ronlFMSKajIM/8eAgSGnsPf1T5Oma6OPArNyoLKiRYNBBFCM4ktbduNe7tQX6pE9 X-Received: by 2002:a92:da04:0:b0:365:e274:5e55 with SMTP id z4-20020a92da04000000b00365e2745e55mr15967957ilm.7.1709848909852; Thu, 07 Mar 2024 14:01:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709848909; cv=pass; d=google.com; s=arc-20160816; b=eK51H8UclXgF+/yI26I6tMg8k3xJjKNoVO+IzceJeeCcflbA8IHSwRseYqCFksm2wX md1Xe+wx+a8V87p7mopmXc/cf6vJRVomEgvnz1lvUSG6wE0hJ+uuB+4YMkEqpdMv35IV qigc26e5X0WDNTAh0K66somy3c91Os9UOmyWzqiRfssD6sUmzkG/8ZOp0HcNA/tctjR1 A8CMMXdTcZKlDuUC1TaGntk7GD3K5nbvDaibS3m4BcDERW3qqCKGwDTtKIQJY/7Fo9Ru wi+udFc1P1s3SwGdoXej0uAJNLXRDEDYHGAkMeaI+MNlZgFpiu2hQ7UF4IgcxjAmjezy SWPw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Xk1r50txwz1RYBNnNACPrtpLjSt2J+M9p6ir6BbTeIY=; fh=Pawwg7dIh7I9zH1HXubZMHCG1/ZE7yvTKWEVlpHr6no=; b=vyiQ7nSNiTiGecB3/YzmDsDn29qPnRlXh7Qp8SLFiw8jXWVj79qigoXsdC+g9hOUW8 JH379XF502INsgcMJD/13z51h6p65Jkx9uRqgOJHcU3VpwQY2sRY/1LsddFK64GYUlJr pYajt0ukRDHV45i5nt/96OdlSclQK1NertTeHJpA48RNgK6kAnaEJPajY50r6yoKzgQl 60RnyFOvUNq/tiVH2buoajmLpTmI1Cl1tRSDXclEHCWB/WKlgBrwqLm8iDMLfyokwGR5 5Yg89tYW0B/ZFHSUoSlHZDYr3bDRBmnUo3zYEmPxIw7qC+sBUQNhUhRfjaMbRRIj9ZH2 P2QA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EqFn8JHe; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-96297-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96297-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id c3-20020a056e020cc300b00365f40c7f83si3227797ilj.34.2024.03.07.14.01.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 14:01:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-96297-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EqFn8JHe; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-96297-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96297-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id AA36F281A7F for ; Thu, 7 Mar 2024 22:01:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 590E713C9C6; Thu, 7 Mar 2024 22:01:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="EqFn8JHe" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 81AE91EF13 for ; Thu, 7 Mar 2024 22:01:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709848903; cv=none; b=gDyWd2miGIyO1OI9CdhehyXk4qv3iWmxgH9taMCy7qMFBG9+8xSkvN5tucntALngkOtorKppRW0hNmfKbcXBVDWdya6ouiz2IXv7ZInBWo0lGXWFsC5WYklGHADmmMjIZ3DtySFuQVa7kY/9/FjwqpBt1wbgCau5UeVgc9oNrsg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709848903; c=relaxed/simple; bh=nDeOjZWqj/4+jb6Q9hD/6xFbGYGNpR7zTPy2r3dn57g=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=a5f9DYGz+nom3eu6URhP4BVCABBGg6easq0zLbQbhjtnaQurgZxarYfAiySuBdPlgsHsN+ggQxzp9AbjvDIj3ZsPlsOv+/kzsW7BJEb4gti+f11HEdXFYDLBU7B+Qq/0FcOczE6rb+1nIBtVluowBFqqmVjHUFZ+v3BsmSRATPQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=EqFn8JHe; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B05EAC433C7; Thu, 7 Mar 2024 22:01:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1709848903; bh=nDeOjZWqj/4+jb6Q9hD/6xFbGYGNpR7zTPy2r3dn57g=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=EqFn8JHeYhX4kS+gSxhubKKoP0X3sPqDJw3a7cWjQuxBApQzJ3ApObGSgh090u9DB oXAI0ug0USae+Cvvvwj+taY90e1m8pOyrgrQeDeoxPLkluzLzb9WV/uHkYpBAr+GX2 0mA5MLq8yAIwqnUWe7ZqCJtGvPOzaQ2BFtcjUeuw= Date: Thu, 7 Mar 2024 22:01:40 +0000 From: Greg KH To: John Garry Cc: mcgrof@kernel.org, russ.weight@linux.dev, rafael@kernel.org, linux-kernel@vger.kernel.org, masahiroy@kernel.org Subject: Re: [PATCH v2] firmware_loader: Use init_utsname()->release Message-ID: <2024030757-trickily-tuesday-bfcc@gregkh> References: <20240223153121.440763-1-john.g.garry@oracle.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240223153121.440763-1-john.g.garry@oracle.com> On Fri, Feb 23, 2024 at 03:31:21PM +0000, John Garry wrote: > Instead of using UTS_RELEASE, use init_utsname()->release, which means > that we don't need to rebuild the code just for the git head commit > changing. But you are now exchanging build "convience" with code complexity and runtime checking. Which is better, and which is "provable"? > Note: As mentioned by Masahiro in [0], when CONFIG_MODVERSIONS=y it > could be possible for a driver to be built as a module with a different > kernel baseline and so use a different UTS_RELEASE from that baseline. So > now using init_utsname()->release could lead to a change in behaviour > in this driver. However, considering the nature of this driver and how it > would not make sense to build it as an external module against a different > tree, this change should not have any effect on users. This is not a "driver", it's the firmware core so this does not make sense. > > [0] https://lore.kernel.org/lkml/CAK7LNAQ_r5yUjNpOppLkDBQ12sDxBYQTvRZGn1ng8D1POfZr_A@mail.gmail.com/ > > Reviewed-by: Luis Chamberlain > Signed-off-by: John Garry > --- > Changes in v2: > - moved note into commit log and tweaked slightly > - add Luis' RB tags, thanks > > Also verified against fw loader selftest - it seems to show no regression > from baseline, however the baeline sometimes hangs (and also does with > this patch). > > diff --git a/drivers/base/firmware_loader/main.c b/drivers/base/firmware_loader/main.c > index 3c67f24785fc..9a3671659134 100644 > --- a/drivers/base/firmware_loader/main.c > +++ b/drivers/base/firmware_loader/main.c > @@ -38,7 +38,7 @@ > #include > #include > > -#include > +#include > > #include "../base.h" > #include "firmware.h" > @@ -471,9 +471,9 @@ static int fw_decompress_xz(struct device *dev, struct fw_priv *fw_priv, > static char fw_path_para[256]; > static const char * const fw_path[] = { > fw_path_para, > - "/lib/firmware/updates/" UTS_RELEASE, > + "/lib/firmware/updates/", /* UTS_RELEASE is appended later */ > "/lib/firmware/updates", > - "/lib/firmware/" UTS_RELEASE, > + "/lib/firmware/", /* UTS_RELEASE is appended later */ > "/lib/firmware" > }; > > @@ -496,7 +496,7 @@ fw_get_filesystem_firmware(struct device *device, struct fw_priv *fw_priv, > size_t size; > int i, len, maxlen = 0; > int rc = -ENOENT; > - char *path, *nt = NULL; > + char *path, *fw_path_string, *nt = NULL; > size_t msize = INT_MAX; > void *buffer = NULL; > dev_err(device, "%s suffix=%s\n", __func__, suffix); > @@ -511,6 +511,12 @@ fw_get_filesystem_firmware(struct device *device, struct fw_priv *fw_priv, > if (!path) > return -ENOMEM; > > + fw_path_string = __getname(); > + if (!fw_path_string) { > + __putname(path); > + return -ENOMEM; > + } > + > wait_for_initramfs(); > for (i = 0; i < ARRAY_SIZE(fw_path); i++) { > size_t file_size = 0; > @@ -521,16 +527,32 @@ fw_get_filesystem_firmware(struct device *device, struct fw_priv *fw_priv, > if (!fw_path[i][0]) > continue; > > + len = snprintf(fw_path_string, PATH_MAX, "%s", fw_path[i]); > + if (len >= PATH_MAX) { > + rc = -ENAMETOOLONG; > + break; > + } > + > + /* Special handling to append UTS_RELEASE */ You don't really document why you want to do that here, and ick: > + if ((fw_path[i] != fw_path_para) && (fw_path[i][len - 1] == '/')) { > + len = snprintf(fw_path_string, PATH_MAX, "%s%s", > + fw_path[i], init_utsname()->release); You now have a "rule" where a trailing / means we add the UTS_RELEASE to it, how is anyone going to remember that if they want to add a new path to the array above? this is going to be a maintenance nightmare, sorry. greg k-h