Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp1103803rdf; Wed, 22 Nov 2023 05:53:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IEbGIUlZbsaflUPfUFioScXPkrfSK9HDYyKZr3NKOxDebZ/1f+vOPKjBrjWdR1rDk7TX3gc X-Received: by 2002:a05:6a20:c909:b0:189:a6b3:ef7b with SMTP id gx9-20020a056a20c90900b00189a6b3ef7bmr2890418pzb.20.1700661189990; Wed, 22 Nov 2023 05:53:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700661189; cv=none; d=google.com; s=arc-20160816; b=KgrZ1/3nFFy3KPgDuaDAdAHKBgagI/OuP3VFZ+Y0ktGJrkvhr6Ktj9LFLLy5tZDs2F qMX0GlG6yv7cFhlxlL4bEev4xmEpRjzqOwW1mvgXmYYqj5fPphjxOQSdbx//xoG7vqWV U/Gv/bDQBVPS0c8H02eqamRQ5pxVhjtK+eFcXcY6gA7FKGo+OPRPdn8qoviHE0SWlCIE 1NsLk0995PCQStVdjlny1YSP/FyWbuQLdtP5j+3R1+A4o1EqvvPM1UkQx1LDSzL1o/Gy AfV75W6HoLSxrjPcweeBFky9zToUjDJFXWWs6/yBHbVrAz6+4EzwftjcghI/hXJOe4p+ xWAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:message-id:content-transfer-encoding :mime-version:subject:date:from:dkim-signature; bh=5DfjWpEKJ3KT08ABWOZKh8cLOfg3oBu9fPbcsszXf1o=; fh=D18ShTGxbz5Dm/mA+EeVLSr7wERt/sJxtCWEr/2FKIE=; b=NhjvxBGQrhyKg+ixtdUDdYo9Nz3VRnk/mpWnQ0JmGsVKtlM6YWTM18r6mdA6kDiYSu 701Br4gXbC7scFVmwjja6HN09N1TJcz3L072+dGKvRP+Bgnsxvngt69HMbX3PtiFRCr+ rGos64cxHn1UYRHIXvJ8RxGCvkWafvXbDg3+ygG61IioXb5Af9STtdSi1YRXqMYer9Fk HZzRUY4ryQVQBZnzCF8GnBG/FySvfj2rViy/TySDP+Ddv+eGSvbj6Z/xLTkBrU3FQyH7 TnUpXskOXjT2fO/V1TGiHWZww23pFF10/r399pS4CqV1BZOVZEiX3qApRM2MnP8HSiCo mB4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=lDL1Cb1p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id bx15-20020a056a02050f00b005b91536981csi14364119pgb.11.2023.11.22.05.53.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 05:53:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=lDL1Cb1p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id B9F5E82516C4; Wed, 22 Nov 2023 05:53:03 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344244AbjKVNww (ORCPT + 99 others); Wed, 22 Nov 2023 08:52:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343968AbjKVNwv (ORCPT ); Wed, 22 Nov 2023 08:52:51 -0500 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEA0D19D; Wed, 22 Nov 2023 05:52:46 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id BBEF220005; Wed, 22 Nov 2023 13:52:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1700661165; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5DfjWpEKJ3KT08ABWOZKh8cLOfg3oBu9fPbcsszXf1o=; b=lDL1Cb1piMbpyf+9ZogEnOpPrKPH1oC/ubPVxPREMfvMvSSfSNv81uGMfL+UeSThHFIYdT yIC5rOuC9XsarVtbhJZwZDSxCvBmiJMuvgLL8l/TZMZ5JIgZrwYHnfJHY+0GLHENF5ZRj8 rcwTXA7wz6b1B58yMcVG7pwPVMnoFqPEPWO9uVo/2YdKwi1YXIJuvqvx/VxI9HX4igvsGh LBQRVQTsmgOPWt0QUJMVpv16A3UeBeopHvaQXnoPWjaLS7VneKsHHRIgwgMq3g0nOob+vN E52WKwDMsbVqzqT0D7noXpKJt43yownKHC0u/qB3j3VNJrV6Xyiq/En5RnTzGg== From: Kory Maincent Date: Wed, 22 Nov 2023 14:52:43 +0100 Subject: [PATCH net-next v3] firmware_loader: Expand Firmware upload error codes with firmware invalid error MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20231122-feature_firmware_error_code-v3-1-04ec753afb71@bootlin.com> X-B4-Tracking: v=1; b=H4sIAKoHXmUC/43N0QrCIBgF4FcZXmdMXei66j0ihnO/TWgav7YWY ++eeFU30d05HPjOSiKgg0iO1UoQZhdd8LmIXUXMqP0VqBtyJ7zmgjEmqQWdHgiddTg9dQ6AGLA zYQDaq0FqWyutLJAs3BGsW4p+Jh4S9bAkcsnL6GIK+Cq3Myv7Xw8zo4y23LRS6EOtGnnqQ0g35 /cmTEWe+YfG2W+NZ80q2WopRaMb+Na2bXsDFoUY+SABAAA= To: Jakub Kicinski , Luis Chamberlain , Russ Weight , Greg Kroah-Hartman , "Rafael J. Wysocki" Cc: Thomas Petazzoni , linux-kernel@vger.kernel.org, Conor Dooley , Andrew Lunn , netdev@vger.kernel.org, Kory Maincent X-Mailer: b4 0.12.4 X-GND-Sasl: kory.maincent@bootlin.com X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,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 groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 22 Nov 2023 05:53:03 -0800 (PST) No error code are available to signal an invalid firmware content. Drivers that can check the firmware content validity can not return this specific failure to the user-space Expand the firmware error code with an additional code: - "firmware invalid" code which can be used when the provided firmware is invalid Sync lib/test_firmware.c file accordingly. Acked-by: Luis Chamberlain Acked-by: Greg Kroah-Hartman Signed-off-by: Kory Maincent --- Changes in v3: - Add the newly introduced error code to test_firmware.c This patch was initially submitted as part of a net patch series. Conor expressed interest in using it in a different subsystem. https://lore.kernel.org/netdev/20231116-feature_poe-v1-7-be48044bf249@bootlin.com/ Consequently, I extracted it from the series and submitted it separately. I first tried to send it to driver-core but it seems also not the best choice: https://lore.kernel.org/lkml/2023111720-slicer-exes-7d9f@gregkh/ Jakub could you create a stable branch for this patch and share the branch information? This way other Maintainers can then pull the patch. --- drivers/base/firmware_loader/sysfs_upload.c | 1 + include/linux/firmware.h | 2 ++ lib/test_firmware.c | 1 + 3 files changed, 4 insertions(+) diff --git a/drivers/base/firmware_loader/sysfs_upload.c b/drivers/base/firmware_loader/sysfs_upload.c index a0af8f5f13d8..829270067d16 100644 --- a/drivers/base/firmware_loader/sysfs_upload.c +++ b/drivers/base/firmware_loader/sysfs_upload.c @@ -27,6 +27,7 @@ static const char * const fw_upload_err_str[] = { [FW_UPLOAD_ERR_INVALID_SIZE] = "invalid-file-size", [FW_UPLOAD_ERR_RW_ERROR] = "read-write-error", [FW_UPLOAD_ERR_WEAROUT] = "flash-wearout", + [FW_UPLOAD_ERR_FW_INVALID] = "firmware-invalid", }; static const char *fw_upload_progress(struct device *dev, diff --git a/include/linux/firmware.h b/include/linux/firmware.h index de7fea3bca51..0311858b46ce 100644 --- a/include/linux/firmware.h +++ b/include/linux/firmware.h @@ -27,6 +27,7 @@ struct firmware { * @FW_UPLOAD_ERR_INVALID_SIZE: invalid firmware image size * @FW_UPLOAD_ERR_RW_ERROR: read or write to HW failed, see kernel log * @FW_UPLOAD_ERR_WEAROUT: FLASH device is approaching wear-out, wait & retry + * @FW_UPLOAD_ERR_FW_INVALID: invalid firmware file * @FW_UPLOAD_ERR_MAX: Maximum error code marker */ enum fw_upload_err { @@ -38,6 +39,7 @@ enum fw_upload_err { FW_UPLOAD_ERR_INVALID_SIZE, FW_UPLOAD_ERR_RW_ERROR, FW_UPLOAD_ERR_WEAROUT, + FW_UPLOAD_ERR_FW_INVALID, FW_UPLOAD_ERR_MAX }; diff --git a/lib/test_firmware.c b/lib/test_firmware.c index add4699fc6cd..9cfdcd6d21db 100644 --- a/lib/test_firmware.c +++ b/lib/test_firmware.c @@ -1132,6 +1132,7 @@ static const char * const fw_upload_err_str[] = { [FW_UPLOAD_ERR_INVALID_SIZE] = "invalid-file-size", [FW_UPLOAD_ERR_RW_ERROR] = "read-write-error", [FW_UPLOAD_ERR_WEAROUT] = "flash-wearout", + [FW_UPLOAD_ERR_FW_INVALID] = "firmware-invalid", }; static void upload_err_inject_error(struct test_firmware_upload *tst, --- base-commit: b85ea95d086471afb4ad062012a4d73cd328fa86 change-id: 20231117-feature_firmware_error_code-b8d7af08a8fe Best regards, -- Köry Maincent, Bootlin Embedded Linux and kernel engineering https://bootlin.com