Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp101273rdb; Thu, 21 Dec 2023 04:10:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IGHpqloFkSCcCbUJbIPmNbT61HmKJUp51TaQ+3gFiGciwMrMHpyqU6mlTY+cHVg2jBhBY3x X-Received: by 2002:a17:903:447:b0:1d3:e8b1:c2cf with SMTP id iw7-20020a170903044700b001d3e8b1c2cfmr2637253plb.116.1703160631688; Thu, 21 Dec 2023 04:10:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703160631; cv=none; d=google.com; s=arc-20160816; b=dArMG+9TmtyboXIpGQ2iLwEG7YA7Mg3Ic8pm9WtSYAOGGMC50GAoNaez/LeuLoytMB /+rI935LTY3/BvWkLefv/Uo0fuCFYIBaRNOhtlNcf0Cy/a7in7O0gbOg5E+gBYW6pTa0 71/XdJPQa543db3nrLJLajGOCwRvVeP1hdGqmx4BTJHzLNJwXBLFccPNuzUCxWFfQfJF mWJWm5Yrb4Vt/D3DuVn7Rz3PR9s5cfNrK+fOO/BM2xnmmARCXqeYJVdBRuC+9v6a2Ay4 d3exddDyLa80XzZEI0f073GApqCwO1JfYAArgjv7aR0n/y8oUX27wWe/6aA92stAE+b5 3z/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=HNgAHhgASKG5cC6HA2RaRQqlTLp7bCesqBG34hJxbJ8=; fh=FU6qZcSgmaGHjzPl8lrwS9gBMevBFWKrlHPqEWT0SwM=; b=JE9Ya5nmFpl5D2HJTACxCf3RMop8rfBh13MeufInQ8UQ50nskPNdf4NjY1TE4PZTA5 YfkyAr9D2TRV96YHtB13HxAXXAEz5Kuxj9hpKo2DMjM3XKVeFz/aB01Skz+CsGY9WGhG lysEewWjRQk4HIVQ/ctFiKYV252nr1orTPRGM+xC8EHsPu42PDyeI+tUSCZ1mUoKzv3d Y2jHcgniFZws4j6vC87r9NNXZTJvJg87PSI0pfnRI4dtTeNFQI1+BNjr6cgDLN64H1nD jmlvmr2esVt9cvDvzIJ6Yo2f0B0yCQHpTLeKEfYGlu1Sh4mP5I+o52vVcf46JI6ZrRWr 50Dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ellerman.id.au header.s=201909 header.b="UXZ/8iFV"; spf=pass (google.com: domain of linux-kernel+bounces-8314-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8314-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id q4-20020a17090311c400b001d00a866032si1425837plh.223.2023.12.21.04.10.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 04:10:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8314-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@ellerman.id.au header.s=201909 header.b="UXZ/8iFV"; spf=pass (google.com: domain of linux-kernel+bounces-8314-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8314-linux.lists.archive=gmail.com@vger.kernel.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 9A45CB249C1 for ; Thu, 21 Dec 2023 12:10:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2906D6E2C2; Thu, 21 Dec 2023 12:09:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ellerman.id.au header.i=@ellerman.id.au header.b="UXZ/8iFV" X-Original-To: linux-kernel@vger.kernel.org Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C31C96E587 for ; Thu, 21 Dec 2023 12:09:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ellerman.id.au Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ellerman.id.au DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ellerman.id.au; s=201909; t=1703160590; bh=HNgAHhgASKG5cC6HA2RaRQqlTLp7bCesqBG34hJxbJ8=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=UXZ/8iFVFD0RXlNf75DnRzeZjZNqxXdyWlv4k0Hzlfir+cyDg6bzbTkZMQcPEURyP dkTVRxehX5RuNr+aZND8OtKcWszFbK6k8UWIfrAKKvTgU9KtM25R6X2RYV/TGCXe6F dv3/5yh5p0aHNYb1dftrqTuQJW3EQkuse3SZQhoQ3nerzOI/8Hr7sc9fVzUv2thna5 5bnMvnqnCaA1nr0WKnr8U1Ey0AxGM5PNK0A7spgyNi6bRYwkuTIqnw5sBIKTD0uOM9 mYBPuNRUGXdrNxN4h69hABS+DC8IOmVR3y0cPrdjoAD+ad6Soy4Sk6Z1YFgCc0rcmP OL68MK1PQoxAQ== Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4Swq4G3W56z4xCg; Thu, 21 Dec 2023 23:09:50 +1100 (AEDT) From: Michael Ellerman To: Christophe Leroy , Nicholas Miehlbradt , "glider@google.com" , "elver@google.com" , "dvyukov@google.com" , "akpm@linux-foundation.org" , "npiggin@gmail.com" Cc: "linux-mm@kvack.org" , "kasan-dev@googlegroups.com" , "iii@linux.ibm.com" , "linuxppc-dev@lists.ozlabs.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH 02/13] hvc: Fix use of uninitialized array in udbg_hvc_putc In-Reply-To: References: <20231214055539.9420-1-nicholas@linux.ibm.com> <20231214055539.9420-3-nicholas@linux.ibm.com> Date: Thu, 21 Dec 2023 23:09:49 +1100 Message-ID: <87frzvlpte.fsf@mail.lhotse> 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=utf-8 Content-Transfer-Encoding: quoted-printable Christophe Leroy writes: > Le 14/12/2023 =C3=A0 06:55, Nicholas Miehlbradt a =C3=A9crit=C2=A0: >> All elements of bounce_buffer are eventually read and passed to the >> hypervisor so it should probably be fully initialized. > > should or shall ? > >>=20 >> Signed-off-by: Nicholas Miehlbradt > > Should be a Fixed: tag ? > >> --- >> drivers/tty/hvc/hvc_vio.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >>=20 >> diff --git a/drivers/tty/hvc/hvc_vio.c b/drivers/tty/hvc/hvc_vio.c >> index 736b230f5ec0..1e88bfcdde20 100644 >> --- a/drivers/tty/hvc/hvc_vio.c >> +++ b/drivers/tty/hvc/hvc_vio.c >> @@ -227,7 +227,7 @@ static const struct hv_ops hvterm_hvsi_ops =3D { >> static void udbg_hvc_putc(char c) >> { >> int count =3D -1; >> - unsigned char bounce_buffer[16]; >> + unsigned char bounce_buffer[16] =3D { 0 }; > > Why 16 while we have a count of 1 in the call to hvterm_raw_put_chars() ? Because hvterm_raw_put_chars() calls hvc_put_chars() which requires a 16 byte buffer, because it passes the buffer directly to firmware which expects a 16 byte buffer. It's a pretty horrible calling convention, but I guess it's to avoid needing another bounce buffer inside hvc_put_chars(). We should probably do the change below, to at least document the interface better. cheers diff --git a/arch/powerpc/include/asm/hvconsole.h b/arch/powerpc/include/as= m/hvconsole.h index ccb2034506f0..0ee7ed019e23 100644 --- a/arch/powerpc/include/asm/hvconsole.h +++ b/arch/powerpc/include/asm/hvconsole.h @@ -22,7 +22,7 @@ * parm is included to conform to put_chars() function pointer template */ extern int hvc_get_chars(uint32_t vtermno, char *buf, int count); -extern int hvc_put_chars(uint32_t vtermno, const char *buf, int count); +extern int hvc_put_chars(uint32_t vtermno, const char buf[16], int count); /* Provided by HVC VIO */ void hvc_vio_init_early(void); diff --git a/arch/powerpc/platforms/pseries/hvconsole.c b/arch/powerpc/plat= forms/pseries/hvconsole.c index 1ac52963e08b..c40a82e49d59 100644 --- a/arch/powerpc/platforms/pseries/hvconsole.c +++ b/arch/powerpc/platforms/pseries/hvconsole.c @@ -52,7 +52,7 @@ EXPORT_SYMBOL(hvc_get_chars); * firmware. Must be at least 16 bytes, even if count is less than 16. * @count: Send this number of characters. */ -int hvc_put_chars(uint32_t vtermno, const char *buf, int count) +int hvc_put_chars(uint32_t vtermno, const char buf[16], int count) { unsigned long *lbuf =3D (unsigned long *) buf; long ret; diff --git a/drivers/tty/hvc/hvc_vio.c b/drivers/tty/hvc/hvc_vio.c index 736b230f5ec0..011b239a7e52 100644 --- a/drivers/tty/hvc/hvc_vio.c +++ b/drivers/tty/hvc/hvc_vio.c @@ -115,7 +115,7 @@ static int hvterm_raw_get_chars(uint32_t vtermno, char = *buf, int count) * you are sending fewer chars. * @count: number of chars to send. */ -static int hvterm_raw_put_chars(uint32_t vtermno, const char *buf, int cou= nt) +static int hvterm_raw_put_chars(uint32_t vtermno, const char buf[16], int = count) { struct hvterm_priv *pv =3D hvterm_privs[vtermno];