Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp53594rdb; Fri, 16 Feb 2024 20:53:52 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWkOyBONNMjn9vhGVBzTrN3uW9W/zp6nuah+9v4wI+8jRXgc5gU7azjd+TfRUFjcZwdX1NJzOIRFSPbkDa7QDvr6V6bqHQtgM7e+n2Ydw== X-Google-Smtp-Source: AGHT+IHdB41mFAYD9YksCn0Pf0/zt8CkqTnBoDuIcKdEb2CqRH+X9pkuRm3U5HOCfjpqjBgCXcgo X-Received: by 2002:a05:6a20:c907:b0:19e:b9ab:189e with SMTP id gx7-20020a056a20c90700b0019eb9ab189emr9669167pzb.60.1708145631878; Fri, 16 Feb 2024 20:53:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708145631; cv=pass; d=google.com; s=arc-20160816; b=M1Tfg17ZMG6tSWaD6o2lCACVUH25uuYPhhVOFezxmGQf/6IdYRA3PObAgecdTpaqr1 1AusoENc9L8fWFdjxkb0xl6h88AXqHDzHdlELxS5KfFyipEuH2lVZ9DHUt7cebtJTX9t 11KA8sesa/h0wRXIXFa27TIXl9lZaeYu61CQlPqZMu/F/YBEUCq0OSzNWO/lljWLUqaQ sZYUhf0ZQpO3lAxENHg2Cu4vqtQoYQw8ZgIyTydo0G/KdQrrKP3t316Y3qC2vId+XGYA yUI2LjyoWZ4X38PWfgsD4KT7kcG2IfQH1dnrmUDVUIs0nqayaaE3a+oZPK9ca9J2+VCe R/0g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=Pre8rdxQFTXsJMOmbo4q2vB4alhDjD0VEGxZ6UooGwo=; fh=qqIaYyR1h7VzXJJWwvjEf6z3VGteuwJ2kLjywtjNvSM=; b=T3O7Ha4bxQIuOpS/1UcfqHCCbs+t4k046p+k7lrvB10Al2cTzPSONcDHgsHSssmeeR NehjHGrNBl/axc7MVOR8Jgxd5LdB1MAx2b4WR5iFEOKE8mq/3XoL0iJu58nf7tYzrXij bhcXQMEqyI63zt6vyKJ6+VtU5JAEVFCTcBmTwwgELGKdU2Nks5DJzIeSkYnJKTti1Yu6 W/QGw+Mg2JDIwH7mhO8ZFrRH1KKR2annlhgoaRNDpG66CrCrKecr1UBoYjEy+nxzSSR1 UrNCyrDxqnCPyLrXKBFnX9D4ZB2lJ8W/r9yTRUmYycfHs9ScQ0YBZt7ohQh/2UwJH1Fg ds9g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=HSAL6gG1; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-69684-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69684-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id a10-20020a170902ee8a00b001da2c896119si911164pld.432.2024.02.16.20.53.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 20:53:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69684-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=HSAL6gG1; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-69684-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69684-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 9261428284F for ; Sat, 17 Feb 2024 04:53:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EC1CC1CA9A; Sat, 17 Feb 2024 04:53:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="HSAL6gG1" Received: from mail-ot1-f50.google.com (mail-ot1-f50.google.com [209.85.210.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 97AA81C2AF for ; Sat, 17 Feb 2024 04:53:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708145620; cv=none; b=hyL77/sEo1w1UVXsw9OkzvPbOJNGhKiOjgT2tYhsMeZAP/lgQEeIJBwKSTqEpuwzkV0LaWqgYK38dvbp2iJfNdwremYlAqJTrRSnu/Hrj307xxsqHgecOk5QeG02UKaHqqYvijLpMI2eBCUrAn5M4SB+314I5ULaGQqZtILJ+bs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708145620; c=relaxed/simple; bh=zRpD3i14j/2w1ZsYki0VbB7I7bNWgKIPU4c0cpGG3xY=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=DYrk2M1U7e+CqOs6Ayc4mP0GPnmeh2W+mG6V6o8jhBNmsCyQGtoAwynaFe4+55BninMTHDzfna2EFA3LUoxCtyr6BZ8aVFO+B7j3df/N2F78WKY7DwYBTlJ/dzD0On0V4GFZcgxCnfMz1BdQgpBSO1HFFt0UI+CfqVUO3L89Q9I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=HSAL6gG1; arc=none smtp.client-ip=209.85.210.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-ot1-f50.google.com with SMTP id 46e09a7af769-6e125818649so1338205a34.1 for ; Fri, 16 Feb 2024 20:53:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1708145617; x=1708750417; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Pre8rdxQFTXsJMOmbo4q2vB4alhDjD0VEGxZ6UooGwo=; b=HSAL6gG1ntFsT5uPB5pn97va67f0Sqk9Nx9RwRl8OfJnSCex4wN4QWdF0MtBTK0Iyn 3IXeK/zNj/1sbsElyPGarHHStxMTkYN/BSEnqa5vki3/nnJq3FPwsa4mLIUss7K+wo50 aP+ugiPlwcRqwrMcj5ilQ4DEgJ3KyWMAoUOOQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708145617; x=1708750417; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Pre8rdxQFTXsJMOmbo4q2vB4alhDjD0VEGxZ6UooGwo=; b=q6it6qjkvyp8neyAB7YHFekey0iUgCNwT1PIOYrZ0sdOV4lNlNw1W6OOMitd2UbMoi cpB4gAT9L95ZNJfPv0z/hWdZZJ8IWorq6x2EVB2Ccau2WGITEWx42M0Fi0z5woO8GOPY nq3P4DhS1wJGfc5Yi3spG3XRBwKJbcDZI4MBwNCZ5U/HZq1+tfXVLrT/TaWOn77n4Tom mh1bmzioWPKZPlWuLqtykYdHK2V7Ns476v5k7DCeNSsGSw8eOkBQe38A5Et61NNfW1Qq xJzzJyEEnF5GpfFUSTdKvUy6JBtK8S4OW5vdUk2hyudKEGQY//jSZW5ddmGVK6syLlC6 uvOg== X-Forwarded-Encrypted: i=1; AJvYcCXQWKUaHYf216PFlcHBKfLGfy9QJvw4nYdY9IzGeGaXxqdXlfCUqyG29+T/ULgOj9Gdy34ZbryjHl4hcXiK5pd5TWeJSOE/hClTSnoo X-Gm-Message-State: AOJu0YxjnsRpf37XgcT8LXqCqqLXpeayqq9o+m5E6oTLB0ZmVEKZ8Tos qVD/QO+6DJBOl5JKYa5H4lxDOqwXiKNltMfZEJoHrcmZaB5VRL6QLad+e0rt1A== X-Received: by 2002:a9d:6f91:0:b0:6e2:f006:47fd with SMTP id h17-20020a9d6f91000000b006e2f00647fdmr7007844otq.14.1708145617638; Fri, 16 Feb 2024 20:53:37 -0800 (PST) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id fd3-20020a056a002e8300b006e0dd50b0d0sm781429pfb.8.2024.02.16.20.53.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 20:53:36 -0800 (PST) From: Kees Cook To: linux-hardening@vger.kernel.org Cc: Kees Cook , Alexander Lobakin , Andy Shevchenko , Cezary Rojewski , Puyou Lu , Mark Brown , Brendan Higgins , David Gow , Nick Desaulniers , linux-kernel@vger.kernel.org, kunit-dev@googlegroups.com Subject: [PATCH v3 0/5] fortify: Add KUnit tests for runtime overflows Date: Fri, 16 Feb 2024 20:48:23 -0800 Message-Id: <20240217043535.make.664-kees@kernel.org> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1353; i=keescook@chromium.org; h=from:subject:message-id; bh=zRpD3i14j/2w1ZsYki0VbB7I7bNWgKIPU4c0cpGG3xY=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBl0DqctI0mx20hHHhmadUsrvuh0OTaGgyzHOFy6 FSuahTJRSqJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZdA6nAAKCRCJcvTf3G3A Jlc3D/9VDNUP82RbsQ7PRTxtIAEJZw7ZbJP1Dv4HKergyingJKkG0gvnVqc+iIWlznrnLjq7k6x InDEYdELraJvCAI8EAofWD+lN/ECQJ7F/ItkrijKGJRvJ8guO602oGXIdlzD0qjnDPAf8HoAlRl v+0DxCV+HoEOHcNknGTBsrbvGEYjcfOHxcbc0Gog31000YXqe9CAiu2vvjlNXw3hsj6ol0k2CPX gSIyrZb2b0l1eDcPlP/YyOrf7tD5ibzmLcHiIheJ60WV1eCmvmzkpter7jBqwYUpFrvU5G5zbeC HYf7AXLXXQd5X1kmJq9EPHOcMl5EXCTTFFD0eSveJ2UMrmCyIFCLNfgVBcjzOzPMDO6sbNurvMZ iK1dcVJwtNPxQ+5zkhnV70iov8QuYIFjGVOLlCmX+zE+6KjrGSQKc4L6SjAuUq4dWrW4maSAlGh vcdgzrtvUvotsZX8fFVg/lUwINWvaiLVandW0LcvSiO2YgUl2IyWoxHmPFPR4hfAn3ySkeyTUjw zziZonywo1HczNweOA5W8NnGZtBiCX40TQrzLMyIGK572rhnljvAgKcxZeWPJnmA0De+WbZTW/i pUyu+OKQhD+BHxEKsRJnWr0SbLxh4OEzxSNGJyyw356tvONJj1VeZvIIlDDsbMqjSU7ZxIJkIj6 5OLIjFf bta9meKA== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: 8bit Hi, This series is the rest of the v2 series that was half landed last year, and finally introduces KUnit runtime testing of the CONFIG_FORTIFY_SOURCE APIs. Additionally FORTIFY failure messages are improved to give more context about read/write and sizes. -Kees v3 - rebase (goodbye strlcpy) - avoid extra macros for replacing fortify_panic() (nick) - generally clean up macro usage - avoid build warnings when testing known overflow conditions v2 https://lore.kernel.org/all/20230407192717.636137-10-keescook@chromium.org/ v1 https://lore.kernel.org/lkml/20230405235832.never.487-kees@kernel.org/ Kees Cook (5): fortify: Split reporting and avoid passing string pointer fortify: Allow KUnit test to build without FORTIFY fortify: Provide KUnit counters for failure testing fortify: Add KUnit tests for runtime overflows fortify: Improve buffer overflow reporting arch/arm/boot/compressed/misc.c | 2 +- arch/x86/boot/compressed/misc.c | 2 +- include/linux/fortify-string.h | 100 +++-- lib/Kconfig.debug | 2 +- lib/Makefile | 1 + lib/fortify_kunit.c | 662 +++++++++++++++++++++++++++++++- lib/string_helpers.c | 26 +- tools/objtool/noreturns.h | 2 +- 8 files changed, 761 insertions(+), 36 deletions(-) -- 2.34.1