[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201116145012.24471-1-laniel_francis@privacyrequired.com>
Date: Mon, 16 Nov 2020 15:50:07 +0100
From: laniel_francis@...vacyrequired.com
To: linux-hardening@...r.kernel.org
Cc: dja@...ens.net, keescook@...omium.org,
Francis Laniel <laniel_francis@...vacyrequired.com>
Subject: [RFC PATCH v4 0/5] Fortify strscpy()
From: Francis Laniel <laniel_francis@...vacyrequired.com>
Hi.
I hope your families, friends and yourselves are fine.
This patch set answers to this issue:
https://github.com/KSPP/linux/issues/46
I based my modifications on top of two patches from Daniel Axtens which modify
calls to __builtin_object_size to ensure the true size of char * are returned
and not the surrounding structure size.
To sum up, in my first patch I implemented a fortified version of strscpy.
This new version ensures the following before calling vanilla strscpy:
1. There is no read overflow because we either size is smaller than src length
or we shrink size to src length by calling fortified strnlen.
2. There is no write overflow because we either failed during compilation or at
runtime by checking that size is smaller than dest size.
The second patch brings a new file in LKDTM driver to test this new version.
The test ensures the fortified version still returns the same value as the
vanilla one while panic'ing when there is a write overflow.
The third just corrects some typos in LKDTM related file.
If you see any problem or way to improve the code, feel free to share it.
Best regards.
Daniel Axtens (2):
string.h: detect intra-object overflow in fortified string functions
lkdtm: tests for FORTIFY_SOURCE
Francis Laniel (3):
string.h: Add FORTIFY coverage for strscpy()
Add new file in LKDTM to test fortified strscpy.
Correct wrong filenames in comment.
drivers/misc/lkdtm/Makefile | 1 +
drivers/misc/lkdtm/bugs.c | 50 +++++++++++++++
drivers/misc/lkdtm/core.c | 3 +
drivers/misc/lkdtm/fortify.c | 82 +++++++++++++++++++++++++
drivers/misc/lkdtm/lkdtm.h | 19 +++---
include/linux/string.h | 75 ++++++++++++++++++----
tools/testing/selftests/lkdtm/tests.txt | 1 +
7 files changed, 213 insertions(+), 18 deletions(-)
create mode 100644 drivers/misc/lkdtm/fortify.c
--
2.20.1
Powered by blists - more mailing lists