Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp8273002ybi; Tue, 23 Jul 2019 05:52:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqyds9oy8OD0yjS0txXr5w7LLHyCmJjdpiTot3RspMjs4AWyvE1eO7iA9VCVYcselN52krOJ X-Received: by 2002:a62:e515:: with SMTP id n21mr5715655pff.186.1563886338514; Tue, 23 Jul 2019 05:52:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563886338; cv=none; d=google.com; s=arc-20160816; b=o7arC/yxnh/w9fH8YC6tn6T4b/xFFdf+jOt4WLzEDiaVvjjGSl90aQBdSykl5rKFk8 9w2R3twLvl9ZkjnMN/egECUM4YcZG83sDM3ZHB4TowPgMLjf3V1GiE1F3LWNQZ8fxoki OXCbni/Lq/ubAGzsA0fLu17pDcKJywSFCIPPlMWBYFQn5P8ia42Mk2cBOInCbPEqaAcq AGAialdOFoyilM4PkgK+8vAhu6JrwHtq2R/pUXtkPcknDwTBzeuewdqQFTZJrImN46a+ +zvEk5RQI9+W7Q27YrmXgW69GreimtbuaSz9wbXRb6hp8WJZhOG1KigagIfg3OE9bJT0 Lq0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=CiwTdtcfbgx9m8/q4NIwXQOX29Pf/1TlXiUaoRBxHZg=; b=BaVsppZXE7bzvviIOPozXM85IODT3X9XNtng0/J5s3WPNqQCOtzN1QI4Jggso9piSE zG92sxDrhVcgUBN169tlK1r7ldcwx6Q8PewX6661RUJXydrEL7sXNg4fl+PDtNCYqVV4 aaueJn+QQ4Rdp1m89H2fGPMaaJI1N12EbjsIQ7v+pMkGYQIlhSw0/p9nGAwGP6BcA7/B 9wdfn74FdPk/UAhPcS3HrO0fiMU2aICX0C0GlvgjSO+DHVlH+yJu03PoJwX6HVByuCyW YgdtHsd6vaW+MD8XEulv9B8GMb86r5cuYb4Au8yWuGRzjbKSe2amU0d2exF6IZQM9mNC 0STA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EhNhxh+G; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c1si10606182pgw.444.2019.07.23.05.52.02; Tue, 23 Jul 2019 05:52:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EhNhxh+G; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732500AbfGWEf3 (ORCPT + 99 others); Tue, 23 Jul 2019 00:35:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:45630 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727251AbfGWEf2 (ORCPT ); Tue, 23 Jul 2019 00:35:28 -0400 Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8C1092239E; Tue, 23 Jul 2019 04:35:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563856527; bh=AQsp9oSHDzpg8J1OlQ5PcMgGVnkDTGm7+PlHh0iIzGo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=EhNhxh+G/R7iHdl9olwT2jJMO290P22pFxI4m+8/TVXtNhohSKKQWJwwkMk24ufOc m5mpCkj8b8w4CgZAoql0aZ9wbzRrjh5iDAWE9RhRp1TOf4VO4QvYoHAtDnqhwM73Nu XkgYNlcpF9aw4SPADa8wNfh/ix8qJAqFOoDZQycc= Date: Mon, 22 Jul 2019 21:35:27 -0700 From: Andrew Morton To: Joe Perches Cc: Linus Torvalds , linux-kernel@vger.kernel.org, Jonathan Corbet , Stephen Kitt , Kees Cook , Nitin Gote , jannh@google.com, kernel-hardening@lists.openwall.com, Rasmus Villemoes Subject: Re: [PATCH 1/2] string: Add stracpy and stracpy_pad mechanisms Message-Id: <20190722213527.18deeaf07ae036cce57035ea@linux-foundation.org> In-Reply-To: <7ab8957eaf9b0931a59eff6e2bd8c5169f2f6c41.1563841972.git.joe@perches.com> References: <7ab8957eaf9b0931a59eff6e2bd8c5169f2f6c41.1563841972.git.joe@perches.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 22 Jul 2019 17:38:15 -0700 Joe Perches wrote: > Several uses of strlcpy and strscpy have had defects because the > last argument of each function is misused or typoed. > > Add macro mechanisms to avoid this defect. > > stracpy (copy a string to a string array) must have a string > array as the first argument (to) and uses sizeof(to) as the > size. > > These mechanisms verify that the to argument is an array of > char or other compatible types like u8 or unsigned char. > > A BUILD_BUG is emitted when the type of to is not compatible. > It would be nice to include some conversions. To demonstrate the need, to test the code, etc.