Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp2394730rdb; Mon, 5 Feb 2024 05:29:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IESei0k8XET7/6BzudnOqqCxtQmn7V6vVcRC/64iCG2JmRAl4TWf3iAm4hsxPaXYqAzJjCX X-Received: by 2002:a05:6a20:7d84:b0:19e:3391:343b with SMTP id v4-20020a056a207d8400b0019e3391343bmr7829065pzj.27.1707139741220; Mon, 05 Feb 2024 05:29:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707139741; cv=pass; d=google.com; s=arc-20160816; b=ZxuWzvTqea2Ziglg6fkOUNxNRhvDAtyJonqNDvFI8xjPa3acxvUMhYE0tlM5uYr3vJ nqjTdxkw0fvUvDwmiV9dOdIDlP4JOkxeW6dmKnZwDt5Bv1ksVyGgeuavjfxq9VaYfKSg Aq3WvlkdeUPawZnZ137Gkk/9si0QvfsywAf4vAk5Lf4cr9WuFVU0b3q3RLweUf9SPLFM zFgIgM+wAMhbBbcYnWohQl/4m7wwynaROVbKgjE/5ua0mWk+9/XsLPXTp9f8AlJRKFxd vE58j7IiovrvkX2ouLWNez8RVx/Q1r2LuFusAvaa+i4sZ9lt0Mr2LNakN/O+Ei/p25pX zeLw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=57ai5j/KdXT8Xuudktal72yNjlF1/d5qdT3nTQk3sYc=; fh=g7mJhMpaTH1TMs6LySQy5fF3UfL7G02YCRvO9VKuOpQ=; b=vz00l4YbZrwLT9mNUtvbKSA6NLAiuK/S9Hb+dsRwm3lDxCYrh1O2BZQDRdTRJBUm/Y NptwLzjFEtmDDqbS+7E4VtUDUtjT+H2hK/eE1Lk0IgQwKeHi5LH+P9rODZZtqQqTiiWv UPwTcoQyxInBBMX4MMIcOIdm6V538wB63q0HWqxEdrYsaOz4G7YW0Li8vGPltH8uyCEu BIHaMomRCFuNuHnA9n7YyRcvEokdfleteSxz3M1WlK00W4MC1BtDQ4FpFxA+vu28YPj1 WSduHo89EE+25cktPCatHzUM1yULMo9KwQ4kk3wLlaZkMzY5mFiXhVv+nSlIHAbSiGAW ivtA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=SDZwewWG; 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-52677-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52677-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=1; AJvYcCXJGax79PWqrMU6sL/LaiwqZ94BccTNaXE7zRAlWCd6XH+MCsQ+uiYFDN/nI71ZVR8/wmMPBLkDN9OldKtEfxGJWv2G8JpQFnFtNhTQ9A== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id t23-20020a656097000000b005d8b8c4cc37si5850950pgu.295.2024.02.05.05.29.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 05:29:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-52677-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=SDZwewWG; 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-52677-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52677-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 18BDEB298DC for ; Mon, 5 Feb 2024 13:03:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9DDD41C6BE; Mon, 5 Feb 2024 13:01:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="SDZwewWG" Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) (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 743001BDC8 for ; Mon, 5 Feb 2024 13:01:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707138112; cv=none; b=uJ8Ie8PRCvRIe1FC1/212lGhbCPF++J/dgmGcQwVv1L4ytokRg/E5dJG+sY/dmV3TNwYBvYEKccbLSR2sFH7j34IVrB3I/y3J26cxf4cY/gXfIpi5TSsLGfacfvaiqrYdWFHpJWHVGIBtpRJ4gEkQC3gteH8CIozzmYwkRpSt0g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707138112; c=relaxed/simple; bh=u7/FoYb551+6GiEJx2PLVrRRol56CFg9Lgrs6ZHrVGU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=aXp+Ofa9vjzDvNOamr/FmX+f/7KUwUitEnbRF0KW3ObVg5eoNZrJ2NdYp+KzzFPYSOZNXRol4BhpNykMRxKVe8mNIFI7kr3xCI2o0bHxSM4vrEtJiWg0b3+9vxeftCL/1EtPUncknXhdmqRVsfUtGlt+OxhxzBHL0G0YS9EXcEs= 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=SDZwewWG; arc=none smtp.client-ip=209.85.215.180 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-pg1-f180.google.com with SMTP id 41be03b00d2f7-5dc20645871so259396a12.1 for ; Mon, 05 Feb 2024 05:01:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707138111; x=1707742911; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=57ai5j/KdXT8Xuudktal72yNjlF1/d5qdT3nTQk3sYc=; b=SDZwewWG+NQIkeC5kHbN5QjrbnCn0YhohNSrRHvUdrvUD2rXWHN9iCXStKdAlJhZ1c N5420yjHUEONYx6VhZlcw7WaXz5yDR6kASxcYEbi86RxdjEA9Zi6dfvtsx17aFCkwfxH ddvWU7cT9PGayuRtYsLJHGvCJXjwsROm9OB6U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707138111; x=1707742911; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=57ai5j/KdXT8Xuudktal72yNjlF1/d5qdT3nTQk3sYc=; b=H/GcdaZH4bTsIdaGYUqqA2ubS62+r7JPMu3ssdeYTsb2O30jvl2mjIA5/p9Zu8qv7P HITe3KO3X0S2YQC4ye4Teys4vnJLujhT2SHfVphJZBa9s6XPqM4TciSDqB75RWnd0yzT 1Qldat3IYGeGjrKQUXPmm9HzNA+rqbcQUvBt1KJJwMrWmFLzrl0TY8HKKQAYvrsYGMSy fzAvaa4i0UbD5jX8k0Mdq6UNh90Hurs4YfQBI/7S3OLlcG1u++KY5Yw+6tNWhv9xufRn VSOJHSJPq/7+E0Q43q5ggZY1tK6FcMs8bsWFsZnZtExc5nC9IVosEZtSlfQU55FIEU7c LDKg== X-Gm-Message-State: AOJu0YwEkUZhBWxZYCWz0kts9P/YChZnxYkUX1gSXCbB4JAf+I3CI2Pa GvroZ/sZLvIBsoNtowquGzNeC9VsTpbD8ljX0wK47nt37uGJKaJXMwcZZwZw7Q== X-Received: by 2002:a05:6a21:339d:b0:19c:9c76:e9b2 with SMTP id yy29-20020a056a21339d00b0019c9c76e9b2mr8360893pzb.13.1707138110568; Mon, 05 Feb 2024 05:01:50 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUtUWfFSyD5FOGxTMeDCC5sR5gUOAGgcddh8KV/jODNhPn5ACeCKZ3SkqqhVQVpNQraBpC/C1/0tXH2vZKCoyMeSgRjv8RKjZSYXvIGngozhzeSa/rU+CFomNmjTNw8z/lWkx5sC7C8VFqoseDjplggWGRcH7U0J54E28KmSIsCwLP/K6HmevdIjmnwQHT47IHbtlkFVatwH/c18MX95YHvZUWmhxR56RksDd0/ZQfPKkxxPz3sH6mexzOyY+H3hVeuwDE5yeC5Af1o86/PZytEPQ60NHI480KqDdZHH2SaGg1gF3HsPGBqN6dVTRipIvNLrDeCqiK27uPMD7wkobpvF/jZMInY1YW2+2Sir81+QAu2Z6A7VRbZh31vBe2u9NlcWFbRmHdrrqI+aywr5Ca49yqEXBLEjPEis65uNn1MR6zraDeR3OceSvEwQzxRqdoyAt/+OTUDeZu69MrtUNLv Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id o133-20020a62cd8b000000b006e033804fa8sm3691905pfg.101.2024.02.05.05.01.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 05:01:50 -0800 (PST) Date: Mon, 5 Feb 2024 05:01:49 -0800 From: Kees Cook To: Geert Uytterhoeven Cc: Andy Shevchenko , Justin Stitt , linux-hardening@vger.kernel.org, Richard Weinberger , Anton Ivanov , Johannes Berg , Willem de Bruijn , Jason Wang , kernel test robot , Nathan Chancellor , Azeem Shaikh , linux-kernel@vger.kernel.org, linux-um@lists.infradead.org Subject: Re: [PATCH v2 2/4] string: Allow 2-argument strscpy() Message-ID: <202402050459.892907C59C@keescook> References: <20240205122916.it.909-kees@kernel.org> <20240205123525.1379299-2-keescook@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Mon, Feb 05, 2024 at 01:47:08PM +0100, Geert Uytterhoeven wrote: > > +/* > > + * The 2 argument style can only be used when dst is an array with a > > + * known size. > > + */ > > +#define __strscpy0(dst, src, ...) \ > > + sized_strscpy(dst, src, sizeof(dst) + __must_be_array(dst)) > > +#define __strscpy1(dst, src, size) sized_strscpy(dst, src, size) > > (dst), (src), (size) etc. I normally don't do this when macro args are being expanded into function arguments. I've only done it for when macro args are used in expressions. Am I missing a side-effect here, or is this more about stylistic consistency? -- Kees Cook