Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4210768imu; Mon, 14 Jan 2019 17:39:03 -0800 (PST) X-Google-Smtp-Source: ALg8bN5H9P3NCA9hvtZ8F8T0krsJABdYAiqSeomkqRvD7/9BDvu5DD/NmhSg4/P5hgCS4/JxIMaK X-Received: by 2002:a62:528e:: with SMTP id g136mr1427697pfb.111.1547516342971; Mon, 14 Jan 2019 17:39:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547516342; cv=none; d=google.com; s=arc-20160816; b=Of4xjI5FxIxZfKp8yjjQ0iRk+4bl562niRCZR/mEtUaaLcuLLTeewxeSQMao+sm30P zYnVAatQWvdI5rKxmZvSFaicQU+T3QdTtJ4L9bCaDPlgQJNAw53ymE+5dyC4ckSOcf4Z pJsEID1E0PQWfqYFPHlAysqjBUEL8BGztZzVPgSNlGb3iyQoxolPxinx/BmkmneVmxyD lP5nrQ9dZk0wKykri7tlBJa+xQfDWtCIxWmeoElJauWEuYbdvbcAhlRorb6heTpDn/fM oEPZWVd2iPCjdD7KoaVcA2EX5qRd7e24lYQYqsW8Aeg8S6Wzez4bsbUizhAgSXENcH9d fZ3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=dD3cXzqnTifY+DlmcmSOfw8BIYt+azZnh4seFWq2G0s=; b=mfybQx8Kh5+FVSXcA4U3pWe5B2sUtUM5PjT8P8bxEADpgUzIpiMt2gPgCsq90wFBK6 FEnhXy1moXzsPuYUK6GKDFOPcSf87Xvkxs8VEl3XMv6cnYTOoBJAE1kjQBPi0jv0zS8h EXFguhPuHpydm62v7ehXs3m8ImN8FS2lthx4iiTU4XLP/e7h9pcTqnjqkmYG2izQ9ctX Vag5YXkbRNaIJXiDVHKo+fhZOgB+YN4buXiBsrijAHVo8i7B8I6gESka84uyuD4zleUW 2gqFj4dOyqEAoZQnck/fumTmWQ9K7zq6s7Cb+PAleenUkdFIExyCihJmBVISycorNG0k zRdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XckFj4as; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 123si1984528pfx.109.2019.01.14.17.38.47; Mon, 14 Jan 2019 17:39:02 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=XckFj4as; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727800AbfAOBZn (ORCPT + 99 others); Mon, 14 Jan 2019 20:25:43 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:39636 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727787AbfAOBZn (ORCPT ); Mon, 14 Jan 2019 20:25:43 -0500 Received: by mail-pg1-f194.google.com with SMTP id w6so459326pgl.6 for ; Mon, 14 Jan 2019 17:25:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=dD3cXzqnTifY+DlmcmSOfw8BIYt+azZnh4seFWq2G0s=; b=XckFj4asqCdm0KPp7UyzwahbpUnMz2IpiJz/U8veQ3UZysx4Mzy0NoWlQhH3w3A2y8 wktIeQOsaoZVP4lzwPfhC1W/+ZJbzKa9gvnx5lmaBln6eeC326pyhG1B7dvPA71iSrMt X56R+LVEfBDoKbBXRNRbWKHzwfkgLlmSFpNlApjhx1msBn4m72pmJaEDyNj1diHTtQTW Iw23K9L0Lv1tHpXIseWD8vSMAH3mu3gvB1IMW6lCmnoYnvNTTtr1bKhlKN4BfokjGyWG dBhLlGl7nVG3tSDBd3Q3+9oGGwpSnghrYxyEBYcqIli9gGVpB/+M+Hx19/G0pl6MuHPV znKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=dD3cXzqnTifY+DlmcmSOfw8BIYt+azZnh4seFWq2G0s=; b=YzQz7PK8MONj3dww9etlVJT7YXyYT07JkljaHLYQybYatsAktX/dn6ud3EYgtYBbBX q2s8rU7H8DNG4jwlws63j/dG3Iv4flcrB/poi97PDjsmGhseCDtbADAXuIN/YmMY+8W3 IuxBWPXbsIwFQnFQHheQTeBdkx3RfkzWDAT44qGtNP6J3fs2PRQiyz6tUlEOYtBEg5Ia mJrdUZBlgcWn3Ju54R/8VcItmbanvPyz4mfOMP9yiF/7JFzrqOlNY4CcFMnjg9ZoYDMs 1U1cQGp/6//EvR5h/v8944SuyaL4p8vXT1Id1x9+iHXArMdbj2603JAys5BTWwxCNPzz Wceg== X-Gm-Message-State: AJcUukcCopm37SegJ7CNF7o4I5LXUthJRH4H6MueqGTFdQ/oc5O9oMiU HyYPVazkgaR9OZglu1wUSJo= X-Received: by 2002:a63:4d66:: with SMTP id n38mr1370207pgl.270.1547515541911; Mon, 14 Jan 2019 17:25:41 -0800 (PST) Received: from Asurada-Nvidia.nvidia.com (thunderhill.nvidia.com. [216.228.112.22]) by smtp.gmail.com with ESMTPSA id b27sm1924251pfh.113.2019.01.14.17.25.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Jan 2019 17:25:41 -0800 (PST) Date: Mon, 14 Jan 2019 17:25:37 -0800 From: Nicolin Chen To: Willy Tarreau Cc: Silvio Cesare , linux-kernel@vger.kernel.org, Timur Tabi , Xiubo Li , Fabio Estevam , Dan Carpenter , Kees Cook , Will Deacon , Greg KH Subject: Re: [PATCH 4/8] ASoC: change snprintf to scnprintf for possible overflow Message-ID: <20190115012536.GA12096@Asurada-Nvidia.nvidia.com> References: <20190112152844.26550-1-w@1wt.eu> <20190112152844.26550-4-w@1wt.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190112152844.26550-4-w@1wt.eu> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jan 12, 2019 at 04:28:40PM +0100, Willy Tarreau wrote: > From: Silvio Cesare > > Change snprintf to scnprintf. There are generally two cases where using > snprintf causes problems. > > 1) Uses of size += snprintf(buf, SIZE - size, fmt, ...) > In this case, if snprintf would have written more characters than what the > buffer size (SIZE) is, then size will end up larger than SIZE. In later > uses of snprintf, SIZE - size will result in a negative number, leading > to problems. Note that size might already be too large by using > size = snprintf before the code reaches a case of size += snprintf. > > 2) If size is ultimately used as a length parameter for a copy back to user > space, then it will potentially allow for a buffer overflow and information > disclosure when size is greater than SIZE. When the size is used to index > the buffer directly, we can have memory corruption. This also means when > size = snprintf... is used, it may also cause problems since size may become > large. Copying to userspace is mitigated by the HARDENED_USERCOPY kernel > configuration. > > The solution to these issues is to use scnprintf which returns the number of > characters actually written to the buffer, so the size variable will never > exceed SIZE. > > Signed-off-by: Silvio Cesare > Cc: Nicolin Chen I think you probably need to run get_maintainer.pl for the patch and should send to Mark Brown and CC alsa-devel. And for subject, we usually use prefix "ASoC: imx-audmux:". Otherwise, Acked-by: Nicolin Chen Thanks