Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2331309ybz; Thu, 23 Apr 2020 16:10:24 -0700 (PDT) X-Google-Smtp-Source: APiQypJ1Dx98nLtwUrjDF3tv5WE3tRT46ZCa7JbXxq0/W1fN0iRCOdlIrZxzXIDe3LDG13Pyucf9 X-Received: by 2002:aa7:dd53:: with SMTP id o19mr4706521edw.180.1587683424274; Thu, 23 Apr 2020 16:10:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587683424; cv=none; d=google.com; s=arc-20160816; b=ZFOuaADOMfIY4ZIjuJsFu61xVXOlEgdH4eB+UT0ZLu9q+pzCwXdiqY//W7T/RUhipl G3Sjeggqii7WWkLL4E0wpJ/nczsE4BKB8XTwELpDPiuoZqkbFsm3247nw9n0kOdjMExJ vj3awHGta/kKU2zTfAVvJpG8/m9ysOZ2zjd2ETUwqWaIAk+smEQJ6mETs7Un7cmXP5/W JdCuCkPc4d5itq0BuLFK9hQShvInbuXw+ytHbdYH0FpxQlPEP1QwGBliGxqKQA0KLHQ1 aj+dfNABQnPnyoR6fFAdgcYjbNHo35NCJok5FRH/7M6FNbR6L+wVX9WHZcdBM2CMNT1S IJ3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=VCFFTntwMaFwKYAqFfkAopL/HBmUNlVtS1IadfIcW1s=; b=WJTBgcS4130g2XuFUW5VSMs9nhcgr+Sf1EywlHJ1qJucdWhrl4gu8gld7Vu2THZvhC xpusjcGLvZaUGWHNoUlsvCSnZOI2mYKx6tAboyOxReChM0Xic2jXqVuV9sJ7vTVx0nQb +TG96A3Jaaww5wxKPB4D2PGHBkk3XRUFhQjEDhoXey50QPmAiI3cpIqwOdnvmkatpYQ4 J5a38Cm7Bopdy79xdKhxBKJzfY2wGFqjIUXQ5NGir1ecaQQfmLNN7swH9OjN7xHPgdm+ T/Ajiz5QUYDqrkt5K0x0N424eeHnBO97qnogQJ26CBFF3vbox1lYIGwL5zcnn+G4huUk qIZw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h5si1953981ejq.430.2020.04.23.16.10.00; Thu, 23 Apr 2020 16:10:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728900AbgDWXHd (ORCPT + 99 others); Thu, 23 Apr 2020 19:07:33 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:51126 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728681AbgDWXHC (ORCPT ); Thu, 23 Apr 2020 19:07:02 -0400 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1jRkvl-0004yI-T7; Fri, 24 Apr 2020 00:06:54 +0100 Received: from ben by deadeye with local (Exim 4.93) (envelope-from ) id 1jRkvk-00E748-IY; Fri, 24 Apr 2020 00:06:52 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, Denis Kirjanov , linux-can@vger.kernel.org, security@kernel.org, "Kees Cook" , davem@davemloft.net, netdev@vger.kernel.org, wg@grandegger.com, "Richard Palethorpe" , mkl@pengutronix.de Date: Fri, 24 Apr 2020 00:07:52 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 245/245] slcan: Don't transmit uninitialized stack data in padding In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.83-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Richard Palethorpe commit b9258a2cece4ec1f020715fe3554bc2e360f6264 upstream. struct can_frame contains some padding which is not explicitly zeroed in slc_bump. This uninitialized data will then be transmitted if the stack initialization hardening feature is not enabled (CONFIG_INIT_STACK_ALL). This commit just zeroes the whole struct including the padding. Signed-off-by: Richard Palethorpe Fixes: a1044e36e457 ("can: add slcan driver for serial/USB-serial CAN adapters") Reviewed-by: Kees Cook Cc: linux-can@vger.kernel.org Cc: netdev@vger.kernel.org Cc: security@kernel.org Cc: wg@grandegger.com Cc: mkl@pengutronix.de Cc: davem@davemloft.net Acked-by: Marc Kleine-Budde Signed-off-by: David S. Miller Signed-off-by: Ben Hutchings --- drivers/net/can/slcan.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) --- a/drivers/net/can/slcan.c +++ b/drivers/net/can/slcan.c @@ -150,7 +150,7 @@ static void slc_bump(struct slcan *sl) u32 tmpid; char *cmd = sl->rbuff; - cf.can_id = 0; + memset(&cf, 0, sizeof(cf)); switch (*cmd) { case 'r': @@ -189,8 +189,6 @@ static void slc_bump(struct slcan *sl) else return; - *(u64 *) (&cf.data) = 0; /* clear payload */ - /* RTR frames may have a dlc > 0 but they never have any data bytes */ if (!(cf.can_id & CAN_RTR_FLAG)) { for (i = 0; i < cf.can_dlc; i++) {