From patchwork Wed Jun 16 06:41:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shravan Kumar Ramani X-Patchwork-Id: 1492771 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G4bFf4Zc0z9sXL; Wed, 16 Jun 2021 16:41:58 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1ltPFK-0008L3-GZ; Wed, 16 Jun 2021 06:41:54 +0000 Received: from mail-il-dmz.mellanox.com ([193.47.165.129] helo=mellanox.co.il) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1ltPFH-0008KT-Ea for kernel-team@lists.ubuntu.com; Wed, 16 Jun 2021 06:41:51 +0000 Received: from Internal Mail-Server by MTLPINE1 (envelope-from shravankr@mellanox.com) with SMTP; 16 Jun 2021 09:41:47 +0300 Received: from farm-0002.mtbu.labs.mlnx (farm-0002.mtbu.labs.mlnx [10.15.2.32]) by mtbu-labmailer.labs.mlnx (8.14.4/8.14.4) with ESMTP id 15G6fk4H000521; Wed, 16 Jun 2021 02:41:46 -0400 Received: (from shravankr@localhost) by farm-0002.mtbu.labs.mlnx (8.14.7/8.13.8/Submit) id 15G6fjj5029295; Wed, 16 Jun 2021 02:41:45 -0400 From: Shravan Kumar Ramani To: kernel-team@lists.ubuntu.com Subject: [SRU][F:linux-bluefield][PATCH v3 0/3] Updates to mlx-bootctl Date: Wed, 16 Jun 2021 02:41:39 -0400 Message-Id: X-Mailer: git-send-email 2.30.1 MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Shravan Kumar Ramani Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" v2 --> v3 Add mutex lock/unlock for SMC calls in show functions, similar to store. Use PAGE_SIZE macro as buffer size for snprintf calls in DRIVER_ATTR_RW functions. Use snprintf instead of sprintf in post_reset_wdog_show. In secure_boot_fuse_state_show, the string comes from the function itself unlike the rest. So it is protected against buffer overflow. v1 --> v2 Split single patch into 3 separate patches based on functionality as suggested. 1. Support VPD info in EEPROM MFG BugLink: https://bugs.launchpad.net/bugs/1931843 SRU Justification: [Impact] The EEPROM MFG partition on BlueField-2 has been updated to include the VPD information for each card. In order to access these newly added fields, the mlx-bootctl driver needs to be updated to provide an access mechanism. [Fix] Add support for VPD fields in the EEPROM MFG and provide access to these via sysfs entries. The newly added sysfs entries are: sku (SKU ID), modl (Model Number), sn (Serial Number) and uuid (UUID). And the previously added opn_str sysfs has been renamed to opn. [Test Case] Though the driver provides read and write access through sysfs, the contents of the MFG partition are written during Manufacturing and then locked in order to protect the info. Writing to this partition will therefore require resetting the MFG info from the UEFI Device Manager, which will unlock the partition and allow for it to be reprogrammed. Reading the sysfs entries will print the contents of each field. It could also be empty if the field was not programmed earlier. [Regression Potential] Can be considered minimum, since the new fields have been added without interfering with the existing fields which might already be present in the EEPROM. 2. Fix potential buffer overflow BugLink: https://bugs.launchpad.net/bugs/1931981 SRU Justification: [Impact] The sysfs store/show functions use sprintf without specifying a size which could lead to potential buffer overflow. [Fix] Replace sprintf with snprintf to avoid buffer overflow. Also, remove the redundant strlen usage since count is already available in the _store functions. [Test Plan] Read/write access to the EEPROM MFG fields can be tested via the sysfs entries that are exposed by the driver. Please note that the MFG partition is locked in order to protect the data and this could block all writes to it. In order to enable writes to the EEPROM, the MFG Info needs to be reset via the UEFI Device Manager. [Regression Potential] Can be considered minimum. 3. Update license and version info BugLink: https://bugs.launchpad.net/bugs/1931984 SRU Justification: [Impact] License info needs to be updated since the current info is no longer accurate. Driver version needs to be incremented since new features have been added. [Fix] Update license info to "Dual BSD/GPL". Increment version to 1.4 [Test Plan] Verify version change [Regression Potential] None Shravan Kumar Ramani (3): UBUNTU: SAUCE: mlx-bootctl: Support VPD info in EEPROM MFG UBUNTU: SAUCE: mlx-bootctl: Fix potential buffer overflow UBUNTU: SAUCE: mlx-bootctl: Update license and version info drivers/platform/mellanox/mlx-bootctl.c | 373 ++++++++++++++++++------ 1 file changed, 289 insertions(+), 84 deletions(-)