package/mmc-utils: fix build failure due to potential overflow
PATCH 1/1 package/mmc-utils: fix build failure due to potential overflow
Add local patch pending upstream to fix potential overflow on read(). This build failure is catched by fortify.
Fixes:
http://autobuild.buildroot.net/results/a53922c5db3e605a5e81e53c034f45017ebb7db7
Signed-off-by Giulio Benetti <[email protected]>
--- ...001-mmc-utils-fix-potential-overflow.patch | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 package/mmc-utils/0001-mmc-utils-fix-potential-overflow.patch
package/mmc-utils/0001-mmc-utils-fix-potential-overflow.patch new file +49 -0
@@ -0,0 +1,49 @@ +From e8a84c704583083cc8487ba41d1488faf1210aec Mon Sep 17 00:00:00 2001 +From: Giulio Benetti <[email protected]> +Date: Tue, 26 Sep 2023 09:12:23 +0200 +Subject: [PATCH] mmc-utils: fix potential overflow +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +With fortify enabled gcc throws following error: + from mmc_cmds.c:20: +In function ‘read’, + inlined from ‘do_rpmb_write_key’ at mmc_cmds.c:2233:8: +/home/giuliobenetti/br_reproduce/a53922c5db3e605a5e81e53c034f45017ebb7db7/output/host/mipsel-buildroot-linux-gnu/sysroot/usr/include/bits/unistd.h:38:10: error: ‘__read_alias’ writing 228 or more bytes into a region of size 32 overflows the destination [-Werror=stringop-overflow=] + 38 | return __glibc_fortify (read, __nbytes, sizeof (char), + | ^~~~~~~~~~~~~~~ +mmc_cmds.c: In function ‘do_rpmb_write_key’: +mmc_cmds.c:2087:19: note: destination object ‘key_mac’ of size 32 + 2087 | u_int8_t key_mac[32]; + | ^~~~~~~ +/home/giuliobenetti/br_reproduce/a53922c5db3e605a5e81e53c034f45017ebb7db7/output/host/mipsel-buildroot-linux-gnu/sysroot/usr/include/bits/unistd.h:26:16: note: in a call to function ‘__read_alias’ declared with attribute ‘access (write_only, 2, 3)’ + 26 | extern ssize_t __REDIRECT (__read_alias, (int __fd, void *__buf, + | ^~~~~~~~~~ + +read() could potentially return more than nbyte so let's check for +ret < nbyte. + +Upstream: https://patchwork.kernel.org/project/linux-mmc/patch/[email protected]/ + +Signed-off-by: Giulio Benetti <[email protected]> +--- + mmc_cmds.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/mmc_cmds.c b/mmc_cmds.c +index 10d063d..ae7b876 100644 +--- a/mmc_cmds.c ++++ b/mmc_cmds.c +@@ -2065,7 +2065,7 @@ int do_sanitize(int nargs, char **argv) + } \ + else if (r > 0) \ + ret += r; \ +- } while (r != 0 && (size_t)ret != nbyte); \ ++ } while (r != 0 && (size_t)ret < nbyte); \ + \ + ret; \ + }) +-- +2.34.1 +
Signature · 6 lines
2.34.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot