Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp659383rdb; Fri, 22 Dec 2023 00:39:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IFXGALBTUcmJrZnoru4JgKwNZ1e3y1ddsLNBjkCq0cgG1+r+tNTSy6OSsXoMFqq4I1fF7Xc X-Received: by 2002:a17:906:4a18:b0:a1f:ad9e:5e15 with SMTP id w24-20020a1709064a1800b00a1fad9e5e15mr296981eju.66.1703234387833; Fri, 22 Dec 2023 00:39:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703234387; cv=none; d=google.com; s=arc-20160816; b=hg4cHc9775fIBAO34oT1T63rXFPM5MdoA9C++Y5JXO//Uq/Z2WeMR8IZA5oGaRr5kr HH32aIxvlHdPEuRVTd+KhwVyThz306azRHuOCHOrPlNz3a3jemoCaabi4du7k+WoN0L+ vhSNnYBwSa3eGfqT/oUdO56/ipt/mvkT0Jtj6AeLAfJqIcKx1SxSotJsqm0B5kAhKWOY E/9T4vTr5i01VqxUySBCCGnxNgUQXh8CLXyyUQd2fFj+JW4P3Wz/nDGB1ZeY0tYiZEAV iLCB7S4spSDvXKFu9oRxwJwM/O63/cjPtWiI0E+Cew9nOj2SEBeHjZGYk6PSPMSFWgOJ EdmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=1J0cv5PkPD3/tUTGQqZFwmVv7+XU6Hfy1EiXRtxA1AU=; fh=YpabPqT0rrtroFAsCgBNWEisidGWuXjqGZZT97zkK5Y=; b=R5qLgIY/AKCZylKZS2pPFmFv7WQs7H7U/1gi3YR79iqLJBwCxSvNJB8cWcRmQjmnwh waI57r/w7ZR9y2ToV+Tr6fi5ROmpsMb9r3vPTY9LVsv1r/4X80DfC18U8Bl6hhMLWTYo Vb6aFC+G10Pc1vtm6d4KF0d3bOZhXQ52NIlX7mh4F3vAbPZq1vAmB1RefSwjX5dVEGPs 2gpr4WBBb6PBz0DO9w7Qfwat3YUNtm65sS3hTupJEyRQ/A65RSKlQ9Jse1IgyHIrLdF2 Eym7xZIeBjyDSRui2eIUnvuCc0N80/WFz6Qebu7OzvfYlmmy4kqvtfGa8TnamHwL9gxu BFBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=vyZ4Wcy5; spf=pass (google.com: domain of linux-kernel+bounces-9510-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9510-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id p19-20020a170906141300b00a231657d374si1587875ejc.831.2023.12.22.00.39.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 00:39:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-9510-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=vyZ4Wcy5; spf=pass (google.com: domain of linux-kernel+bounces-9510-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9510-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 6D5221F26418 for ; Fri, 22 Dec 2023 08:39:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3F3F7101FB; Fri, 22 Dec 2023 08:39:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="vyZ4Wcy5" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (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 20D5CFBFA for ; Fri, 22 Dec 2023 08:39:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-40d3b2c8517so28415e9.1 for ; Fri, 22 Dec 2023 00:39:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1703234365; x=1703839165; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=1J0cv5PkPD3/tUTGQqZFwmVv7+XU6Hfy1EiXRtxA1AU=; b=vyZ4Wcy5wZ+anqBZWKB7oR1SpariMai2l27EVxfoH+cUh53Nf2CC0lhNVzV1nfMU0v CFQmuxoV7bLIXOqFrP1jv3cejQBfc6iERDWtqB/vGi+wxywpBHVftEyu1SBKTW4LmvSx 1hEl6ZY7BxJsUAcdN/AUTyFXzQLEkiuoZgk6qZmBHxCSsEECXqpEQHFlUn9f0PUoAcie WtL43kv3oFQaiYSXSGTtGJTxP2St3Crj4Bc1vRaqisXoK89lMMuOyKxZFUjSY1jlxMRt gA//jTalk85ffsQ2Iok2XaefRIkIYjMr+lis7TiZ5KIrzwG0pSy4a6bPeO4DOcM00gYl dg1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703234365; x=1703839165; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=1J0cv5PkPD3/tUTGQqZFwmVv7+XU6Hfy1EiXRtxA1AU=; b=YdH+GrNVX8xlspCf8U6tCw7VGaV0Ns6RP+BCodvacRP+cZGfTsZqyXDUslgh0pPZoF VsAykSGPTYjCZFPJde+viPw6Zs8nIaDayVtC0fM90+H8BQlUXTMaD2KRjWzdoj4I3+OS DwFYOYtN5wFzjmvUurprlrKUYjVyamoVGPDkkF3VvrmnVgmYh/RrDehtkTZ9zg02mITR wzThy0GpQMJlXFjb3FsHW30bqPu3SqUt2yxZnRRR27Kav7KkdpbNAapTF7WUQUPir//r istpfP32IyyTIAtr99iOU8+K3Xm/Oxd5tTyT3AumStV+LAuw/a2sImfC6HqneuFrMcJ+ ju/w== X-Gm-Message-State: AOJu0YzF/ZOd+6lUjItxK7LYRGZM6Nfab9OJ3IxQc3LHncsC2K3nCZ3j qUcAvpYtOwEzuHdSHylIVy20LlrWwn76vJmDMhiczgg1PHPr X-Received: by 2002:a05:600c:229a:b0:40d:400c:1b1f with SMTP id 26-20020a05600c229a00b0040d400c1b1fmr57309wmf.5.1703234365524; Fri, 22 Dec 2023 00:39:25 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231220155256.407974-1-rf@opensource.cirrus.com> In-Reply-To: <20231220155256.407974-1-rf@opensource.cirrus.com> From: David Gow Date: Fri, 22 Dec 2023 16:39:14 +0800 Message-ID: Subject: Re: [PATCH] kunit: Protect string comparisons against NULL To: Richard Fitzgerald Cc: brendan.higgins@linux.dev, rmoar@google.com, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, patches@opensource.cirrus.com Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha-256; boundary="0000000000005730ae060d1527b7" --0000000000005730ae060d1527b7 Content-Type: text/plain; charset="UTF-8" On Wed, 20 Dec 2023 at 23:52, Richard Fitzgerald wrote: > > Add NULL checks to KUNIT_BINARY_STR_ASSERTION() so that it will fail > cleanly if either pointer is NULL, instead of causing a NULL pointer > dereference in the strcmp(). > > A test failure could be that a string is unexpectedly NULL. This could > be trapped by KUNIT_ASSERT_NOT_NULL() but that would terminate the test > at that point. It's preferable that the KUNIT_EXPECT_STR*() macros can > handle NULL pointers as a failure. > > Signed-off-by: Richard Fitzgerald > --- I think this is the right thing to do. There's possibly an argument that this should succeed if both are NULL, but I prefer it this way. Reviewed-by: David Gow Cheers, -- David --0000000000005730ae060d1527b7 Content-Type: application/pkcs7-signature; name="smime.p7s" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="smime.p7s" Content-Description: S/MIME Cryptographic Signature MIIPnwYJKoZIhvcNAQcCoIIPkDCCD4wCAQExDzANBglghkgBZQMEAgEFADALBgkqhkiG9w0BBwGg ggz5MIIEtjCCA56gAwIBAgIQeAMYYHb81ngUVR0WyMTzqzANBgkqhkiG9w0BAQsFADBMMSAwHgYD VQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMzETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UE AxMKR2xvYmFsU2lnbjAeFw0yMDA3MjgwMDAwMDBaFw0yOTAzMTgwMDAwMDBaMFQxCzAJBgNVBAYT AkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMSowKAYDVQQDEyFHbG9iYWxTaWduIEF0bGFz IFIzIFNNSU1FIENBIDIwMjAwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCvLe9xPU9W dpiHLAvX7kFnaFZPuJLey7LYaMO8P/xSngB9IN73mVc7YiLov12Fekdtn5kL8PjmDBEvTYmWsuQS 6VBo3vdlqqXZ0M9e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