Commit graph

31 commits

Author SHA1 Message Date
Vijay Balaji
04a18622dd sysupgrade-helper : Fix warnings during compilation
This change will fix warnings occurred during
compilation of sysupgrade source files

Change-Id: I0526da607b383064b4c5cea7462fe4c12c669a3b
Signed-off-by: Vijay Balaji <quic_vijbal@quicinc.com>
(cherry picked from commit 6a7c18c463)
2023-09-27 00:16:00 -07:00
Vijay Balaji
f0fa42c10d sysupgrade : corrected typo in rootfs auth message log
We observed a typo in rootfs image authentication
enabled message log and corrected it in this change.

Change-Id: Ie1aa07e0f45fdc3d802d87a03cfe376d7ac43e4e
Signed-off-by: Vijay Balaji <quic_vijbal@quicinc.com>
2023-08-17 11:29:42 +05:30
Vijay Balaji
c9320a61f8 sysupgrade : add support for non-signed rootfs
This change adds support to authenticate signed
rootfs images if rootfs_auth is enabled. It will
authenticate kernel image when rootfs image is not
signed.

Change-Id: I5f9da1c033c5530ebce4bff9f0fb4f69aaca9213
Signed-off-by: Vijay Balaji <quic_vijbal@quicinc.com>
2023-08-02 11:29:29 +05:30
Vijay Balaji
91b4536719 sysupgrade : removed unused code
We want to extract rootfs image from ubi without any
changes, as we are traversing through the rootfs image
for 0xdeadc0de in extract_rootfs_binary() to extract
the image till 0xdeadc0de offset.

Change-Id: Iefeec6db72b65310310d74835b68ec3d22144608
Signed-off-by: Vijay Balaji <quic_vijbal@quicinc.com>
2023-07-21 06:17:36 -07:00
Vijay Balaji
6814dfbb98 sysupgrade : add support to extract rootfs binary
This change adds support to extract rootfs binary
till correct data-block offset and replaces the
binary for image authentication in both
EMMC and Nand flashtypes.

Change-Id: Ib56228a620ffc5bcfae8b51682377b68e273484f
Signed-off-by: Vijay Balaji <quic_vijbal@quicinc.com>
2023-07-18 10:15:22 -07:00
Vijay Balaji
acfb230049 sysupgrade: Use ubi volume name instead of volume id
We observed that ubi_rootfs volume id is different for ipq807x
and ipq95xx, so we use volume name instead of volume id for
rootfs extraction from ubi.

Change-Id: I0b536fbceae47279b81d76f8108ca8640c09657c
Signed-off-by: Vijay Balaji <quic_vijbal@quicinc.com>
2023-06-26 19:19:55 +05:30
Vijay Balaji
4a1f60a52b Sysupgrade-helper : Rootfs Authentication during sysupgrade
This change will add support for rootfs Authentication in all
flashtypes (Nor, Nand, Emmc and norplusnand) during sysupgrade.
Here we are adding support to sign rootfs image with sha384.
The rootfs metadata is available at the end of kernel image.
This change adds supports to extract rootfs metadata from
kernel image and stores in /tmp/metadata.bin.
It also calculates sha384 of rootfs binary and stores in /tmp/sha384_keyXXXXXX 
After this we use below command to authenticate rootfs metadata:
echo -n "0x17 /tmp/metadata.bin /tmp/sha384_keyXXXXXX" > /sys/sec_upgrade/sec_auth

Change-Id: Iaf304d5edcd3bfff849fcb3705f5342f4c354b5b
Signed-off-by: Vijay Balaji <quic_vijbal@quicinc.com>
2023-05-25 00:38:16 -07:00
Ram Chandra Jangir
14023645dd sysupgrade: Consider minimum metadata size as 0x1000
When we use root certificate count as four, then metadata
is generated with size as 0x4000, but for single root
certificate, metadata size will be less than 0x4000, hence
consider minimum metadata size as 0x1000

Change-Id: Ib713e5fd4bcfe493cf482efda54d20ca1604939b
Signed-off-by: Ram Chandra Jangir <quic_rjangir@quicinc.com>
2023-03-14 22:24:11 -07:00
Ram Chandra Jangir
90c4bba23c sysupgrade: Add support to authenticate rootfs image
Add rootfs section to authenticate signed rootfs image
Parse the hlos elf header and get the rootfs metadata offset
Reads metadata available at the end of hlos image and write to /tmp/metadata.bin
Calculate sha384 and write to /tmp/sha384_XXXXX file
Use /tmp/metadata.bin and /tmp/sha384_XXXXX to get rootfs auth by TZ

Change-Id: Iaa4bf6b0cfbae4f4a56187f80f2873cb69550051
Signed-off-by: Ram Chandra Jangir <quic_rjangir@quicinc.com>
2023-02-20 13:09:06 +05:30
Sandhya KS
564a735cdf sysupgrade : Enable support for APDP secure sysupgrade
Change-Id: I8d5c9b2287a7eb61ea6366506d32d35e35e15db9
Signed-off-by: Sandhya KS <quic_sandhyks@quicinc.com>
2022-04-26 13:08:42 +05:30
Selvam Sathappan Periakaruppan
7a087b1264 tools: sysupgrade: Populate kernel volume id dynamically
Change-Id: I29fb7de954fc7f855c49aea933c2adb7f1748f12
Signed-off-by: Selvam Sathappan Periakaruppan <speriaka@codeaurora.org>
2021-10-27 22:49:33 -07:00
Naresh Kumar Mehta
488a613637 sysupgrade: Fix compiler warnings
Change-Id: I69e4d5cf06212feb9e67d7071779846581096bec
Signed-off-by: Naresh Kumar Mehta <naresh@codeaurora.org>
2019-04-05 17:41:16 +05:30
Naresh Kumar Mehta
ca8b173e47 sysupgrade: Remove duplicate declaration
Change-Id: I463a5d7252b54c850ac2e5c9d8b3c679455d66c5
Signed-off-by: Naresh Kumar Mehta <naresh@codeaurora.org>
2019-04-01 14:24:07 +05:30
Avinash Pandey
34ee85c62f sysupgrade: Skip ubi section authentication in NOR/eMMC boot.
Change-Id: I2b2ba59c95eb0e7f9ca17527515f34fc50aeacd6
Signed-off-by: Avinash Pandey <avinasv@codeaurora.org>
2018-08-14 12:42:07 +05:30
Avinash Pandey
37c8e79460 sysupgrade: Avoid dereferencing of buffer to fix KW issue.
This kw issue occurred with below message:
"Use of free memory (access) - possible".
In order to fix this issue, we have removed all 
dereferenced buffer after freeing the buffer..

Change-Id: I080c45b17397333c3f897b960bdf6fca01b7a53e
Signed-off-by: Avinash Pandey <avinasv@codeaurora.org>
2018-03-23 11:25:27 +05:30
Avinash Pandey
a14e102f05 Sysupgrade: Fixing kw issues for buffer overflow.
Kw issues occurred with below message:
 "Array 'buf'of size 256 may use index value(s) -2..0".
In order to fix this issue, error message will be
returned with array index out of index if buffer
size isless than 0 or if it increases buffer size.

Change-Id: I5a7885b0ee2fd6e9c0ac3083b28366f1ae5ceaee
Signed-off-by: Avinash Pandey <avinasv@codeaurora.org>
2018-03-20 13:07:36 +05:30
Linux Build Service Account
6efdb60f4b Merge "sysupgrade: Read the files whose names starts with section type" 2018-03-02 13:51:52 -08:00
Linux Build Service Account
932c29bf3c Merge "sysupgrade: Add SBL_NAND_PREAMBLE if preamble bytes exist in image" 2018-03-02 02:04:54 -08:00
Linux Build Service Account
8775f69613 Merge "sysupgrade: Add support to process SBL for ipq806x nand boot" 2018-03-02 02:04:54 -08:00
Avinash Pandey
745ead5b92 sysupgrade: Read the files whose names starts with section type
Currently we are reading the .bin files who are having the type
in their image names, but this has problem when the image type
is overlapping in two file names ex. wififw_ubi.bin and ubi.bin.
To avoid this problem, we will take files whose names starts
with our image type.

Change-Id: Ib3ab64fb2bbf5c9c59b1ec644c409dee31be77a1
Signed-off-by: Avinash Pandey <avinasv@codeaurora.org>
2018-03-02 12:57:59 +05:30
Linux Build Service Account
64b3c8f03a Merge "Sysupgrade: Add signature certificate size check as warning." 2018-02-26 00:14:45 -08:00
Avinash Pandey
5432bb2a0b Sysupgrade: Add signature certificate size check as warning.
For ipq807x, signature certificate size is dynamic and it is not fixed.
Hence we will treat signature certificate size check as warning. 

Change-Id: I6528212aaf9297217b19cb34311fc96500a7f38f
Signed-off-by: Avinash Pandey <avinasv@codeaurora.org>
2018-02-23 19:52:13 +05:30
Avinash Pandey
7eeddceddf Sysupgrade: Fixing kw issues in string functions.
This change replaces banned function namely, strncat and 
strncpy to strlcat and strlcpy respectively.

Change-Id: Ic02f59b29d1e58a937670f5e53dd1199cb55e53e
Signed-off-by: Avinash Pandey <avinasv@codeaurora.org>
2018-02-22 22:39:07 -08:00
Ram Chandra Jangir
62928dc964 sysupgrade: Add SBL_NAND_PREAMBLE if preamble bytes exist in image
Now we are adding preamble value to read SBL header if ubi section
is present in the image. But in case of NOR+NAND images, though we are
having SBL in NOR and ubi section is also present and NAND_PREAMBLE
is getting added. which is breaking NOR+NAND sysupgrade.

Added functionality to compare first 12 bytes of section with pre
defined PREAMBLE value. If values matches, add the NAND_PREAMBLE to
read SBL header.

Change-Id: I704ee86cc50aa3ce3b2ab6ec34beab866ffde4b9
Signed-off-by: Anto Norbert <norbrt@codeaurora.org>
2018-02-20 15:23:40 +05:30
Ram Chandra Jangir
f40cda9a42 sysupgrade: Add support to process SBL for ipq806x nand boot
This change adds the correct Sbl_Hdr instead of Mbn_Hdr, since
sbl header is different than normal Mbn_Hdr, and adds the sbl
header size as 80.
SBL in nand starts with preamble before the sbl header, so here
it adds the preamble for header start address as well as
src, sig and cert offset values.

Change-Id: I9a56d7b4a51890b74a5ee5fe3047a38801d23803
Signed-off-by: Ram Chandra Jangir <rjangir@codeaurora.org>
2018-02-20 15:20:10 +05:30
Avinash Pandey
bcfcba7eb2 sysupgrade: Add support to authenticate image using TZ
This change will look for existence of file /sys/sec_upgrade/sec_auth
if the file exists, it performs image authentication with the new
approach i.e TZ enabled mechanism.

It reads all the sections of the single image and writes each
section's type and image file path in /sys/sec_upgrade/sec_auth.
If a written section image is a proper signed image, then it will
return success else will cause the failure.

Change-Id: I649581e0ab74a66d677e5bfbf1c34fd83cb2465d
Signed-off-by: Avinash Pandey <avinasv@codeaurora.org>
2018-02-08 16:14:32 +05:30
Pavithra Palanisamy
a392418a4f Sysupgrade: Add support for devcfg version check
This change adds support to check devcfg version and
allows sysupgrade only if the version is higher.

Change-Id: I7192f428c50c1b1b9eeddd1aac0d57d341d32436
Signed-off-by: Pavithra Palanisamy <pavip@codeaurora.org>
2017-11-03 04:18:26 -07:00
Pavithra Palanisamy
0e3043fd78 sysupgrade: Use memcmp() instead of strcmp()
Currently our sysupgrade is comparing the calculated hash,
and referenced hash using strcmp(), A valid binary hash can
contain zeros or null, this can make strcmp() to stop when it
encounters a zero or null. To check the entire hash, not just
the bytes of the hash up to the first zero, we will use memcmp().

The existing code uses mbn_header->code_size for calculating
source offset from the image, this change adds mbn_header_size
for the calculation.

Change-Id: Iaae39d04e8e4aafc686a5acbc499b11b2b8d6602
Signed-off-by: Pavithra Palanisamy <pavip@codeaurora.org>
2017-10-16 10:59:25 +05:30
pavip
fb8e307bbc sysupgrade: Add support to process 64 bit image
The existing sysupgrade treats all images as 32-bit image.
This change adds a check to signify the image class and
adds functions to process the headers respectively.

Change-Id: I04040fdc6e1a9c6c2df2407cd4b26dddaf4a008c
Signed-off-by: Pavithra Palanisamy <pavip@codeaurora.org>
2017-10-13 20:05:52 +05:30
Gokul Sriram Palanisamy
767b457534 ipq807x: Fix KW issues in sysupgrade.c and cmd_bootqca.c
Change-Id: I665f3d596cf235be7347faf68f0bf1ea8b10de7a
Signed-off-by: Gokul Sriram Palanisamy <gokulsri@codeaurora.org>
2017-09-07 04:17:41 -07:00
Sachin Sundar
1ed5f5b1a2 sysupgrade: Add sysupgrade support for signed images.
Change-Id: I2b4a5aeaa311e08ec59f70c3a9e3a88e11dc10f1
Signed-off-by: Sachin Sundar <ssundar@codeaurora.org>
2017-06-08 11:18:32 +05:30