Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1017715lqm; Thu, 2 May 2024 02:46:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWm3fY13gvyFMYlRwqWYN/kFiEBkBTmsC6zoiBRkpAWF4gsAyqxy4L50E+UMAfzRSZI3Qfz5ogmPP8WQwLH5O7AR/cdPabJza5mrlKVDA== X-Google-Smtp-Source: AGHT+IH4RR2tD79W99ZscNttwU9zrCdAye72tvghmeBDxMp0wVYzVrn9eB4plw3s9v0Y5au6l5cL X-Received: by 2002:a05:620a:4510:b0:790:83af:9897 with SMTP id t16-20020a05620a451000b0079083af9897mr2010422qkp.9.1714643181721; Thu, 02 May 2024 02:46:21 -0700 (PDT) Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id b14-20020a05620a0f8e00b00790690cc1d7si549771qkn.145.2024.05.02.02.46.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 02:46:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-166247-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b="iB/Gdxgy"; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-166247-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166247-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 701261C21DB5 for ; Thu, 2 May 2024 09:46:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8C9E655E6A; Thu, 2 May 2024 09:46:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iB/Gdxgy" Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (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 3353C339AC; Thu, 2 May 2024 09:46:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714643173; cv=none; b=NifZDRxcQKvd8/ZmiDJq6l1ZsxgIBPvnJ/3lHVPAQgWeLvNR06hwcUpWcJTemgmAkMONXFUx5DB7dFjXgI+y3QIXVvm1bw9Ic7pGrKCtYHVIlhJx42+Z98Fh1p64pX8oHK637+nBiwu9MeRxDag7D8E5Hsgi33LyH9FmtFDQRTQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714643173; c=relaxed/simple; bh=HSCsS0VMbbwL27ifhnBpJsIh1itQ1kPGQcaJIdkB6W8=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=Q9p7Npeo3IiklZ2pph8USTOxyt05bM6L65Wsk0rk7FAM5QbEaH4UaKZn5fvhvQ13akwZ5O23YMsXQ4Kx+d8mZn1Xir75P6HypSqgp+nzg9u1xulCC+jq4aHOvzTsMHDhdDCLWFnixXvU14sNrRAJKUuqWirNSmfpoqjenY8gaBc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=iB/Gdxgy; arc=none smtp.client-ip=209.85.218.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-a58fbbcd77aso531903766b.2; Thu, 02 May 2024 02:46:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714643170; x=1715247970; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=HxlfYdWRqZamGcObQHKAKiiU621r7BisqkBpH82ZMAs=; b=iB/Gdxgy0zibCbzPSnoV8hh2bANeeyn01lpCEv008m7vON92yNqhScvbBPbT2cmzwG nPPQjuPEWGk7aGE3LSYgJlqC501fK7PCDdXiZOeMez1TdXwNk5bD+6AZLwuu1qjOvg0Q Ab4gg89vqydSV9lZwIw5Gw4+Ludl+6NLcS6D1nM39x6etNRQWl50ohHf3J57Sgeo5Eti YJNUmCCXuab10SfRKOiHfG5gercRVkzDAPcMuKQegTzImPICDqzeDZUtbhsNnxyimI04 D8f968YKT3lkkvVBSJtwWA6qLchn75+hKs8T4jUKObC2kIhAkW4k6dPYGZWY/3yCfmfx 8vEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714643170; x=1715247970; h=content-transfer-encoding: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=HxlfYdWRqZamGcObQHKAKiiU621r7BisqkBpH82ZMAs=; b=wT57wEpoEa2mzyTfOJgSPDjPEkV1GGChRXZiijVFUmnKO1P/eqalUTj3yO5Quw29Ml kZ99Jh+mVt9WjSRXwMas/yMvs/Jd6trNanAFDn6cW+oxXnlORZ6swrQxdOTGpM+KeyBN VhHVSLCwL9Cv0VN7Shh1Yew/lE5f+0SbYDGyBp9lmwy4F3uSn5ky5iGiBGxuE6ifm8tr KFLVIFS9P2fWHwtzYjxYnUX1lEbjjK/lZ72/LkMSo/1cyRaK7SChSOtKOjTblTyF4XfM Mt5dDCoLhxnJMqJqy2qbVZOF60RAcwj2/TOwRQJ3xVQNGwLtChhjNUKt5aJDgb2nAWlf 0xBA== X-Forwarded-Encrypted: i=1; AJvYcCUyDqcMm/JgMVITkio7en/xJv8dUm9zHVwFzHHkwxVXhbysJFwhoVOaVJIaANlau5Gc6Es17s3cEozFL2VJewdB3TssAjsKTZtn+6EgUTseFk+P51gvGKrdvnFbwi/nIF2tmDhyMnD3R6h0jCp3 X-Gm-Message-State: AOJu0YyDn7yf/vUrpIjKLaKYJRQbk/dcsJdjTh+fahZNPvc5+ujsaF4y SMUKUFBeaDCw7D/NB/Bf9+iYdTUSsRAiScrsEeFfd9pViQF9Pug85ikwPFuIHBs0j2yaEnl7FiQ 9u3dmYreC0Dc9nvoS1Fn9ICmX7FY= X-Received: by 2002:a17:906:d105:b0:a46:cef3:4aba with SMTP id b5-20020a170906d10500b00a46cef34abamr3315096ejz.75.1714643170161; Thu, 02 May 2024 02:46:10 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240501233201.work.732-kees@kernel.org> In-Reply-To: <20240501233201.work.732-kees@kernel.org> From: Andy Shevchenko Date: Thu, 2 May 2024 12:45:33 +0300 Message-ID: Subject: Re: [PATCH] string: Add additional __realloc_size() annotations for "dup" helpers To: Kees Cook Cc: Andy Shevchenko , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, May 2, 2024 at 2:32=E2=80=AFAM Kees Cook wr= ote: > > Several other "dup"-style interfaces could use the __realloc_size() > attribute. (As a reminder to myself and others: "realloc" is used here > instead of "alloc" because the "alloc_size" attribute implies that the > memory contents are uninitialized. Since we're copying contents into the > resulting allocation, it must use "realloc_size" to avoid confusing the > compiler's optimization passes.) > > Add KUnit test coverage where possible. (KUnit still does not have the > ability to manipulate userspace memory.) Makes sense to me, Reviewed-by: Andy Shevchenko .. > + checker(len, kmemdup_array(test_phrases[idx], len, 1, \ > + gfp), kfree(p)); \ Despite being longer, I would put gfp on the previous line for the sake of logical split (and additionally to be consistent with the below). > + checker(len, kmemdup(test_phrases[idx], len, gfp), \ > + kfree(p)); \ --=20 With Best Regards, Andy Shevchenko