From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753966AbcCIUtr (ORCPT ); Wed, 9 Mar 2016 15:49:47 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:53706 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751999AbcCIUtl (ORCPT ); Wed, 9 Mar 2016 15:49:41 -0500 Date: Wed, 9 Mar 2016 12:49:40 -0800 From: Andrew Morton To: Rasmus Villemoes Cc: Kees Cook , linux-kernel@vger.kernel.org Subject: Re: [RFC 0/7] eliminate snprintf with overlapping src and dst Message-Id: <20160309124940.7d870c59a7a7117c6c6d7937@linux-foundation.org> In-Reply-To: <1457469654-17059-1-git-send-email-linux@rasmusvillemoes.dk> References: <1457469654-17059-1-git-send-email-linux@rasmusvillemoes.dk> X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; 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 List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 8 Mar 2016 21:40:47 +0100 Rasmus Villemoes wrote: > Doing snprintf(buf, len, "%s...", buf, ...) for appending to a buffer > currently works, but it is somewhat fragile, and any other overlap > between source and destination buffers would be a definite bug. This > is an attempt at eliminating the relatively few occurences of this > pattern in the kernel. I dunno, snprintf(analog->name, sizeof(analog->name), "Analog %d-axis %d-button", is pretty damn convenient. Can we instead state that "sprintf shall support this"? Maybe add a little __init testcase to vsprintf.c to check that it continues to work OK.