From patchwork Tue Feb 24 22:50:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 5875691 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D09949F169 for ; Tue, 24 Feb 2015 22:51:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E14492024F for ; Tue, 24 Feb 2015 22:51:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 90EB220225 for ; Tue, 24 Feb 2015 22:51:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753047AbbBXWvH (ORCPT ); Tue, 24 Feb 2015 17:51:07 -0500 Received: from mail-lb0-f176.google.com ([209.85.217.176]:45209 "EHLO mail-lb0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752262AbbBXWvG (ORCPT ); Tue, 24 Feb 2015 17:51:06 -0500 Received: by lbjb6 with SMTP id b6so62459lbj.12 for ; Tue, 24 Feb 2015 14:51:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=from:to:cc:subject:date:message-id; bh=yRsx9fV+bsdsBqZLNDYdUh9BAcOGmto5Ewg3ECkjzYM=; b=gKdtQR1SsxRggHJ3Bd+tomf+29MkaEd8LubBQhyMtpm928d9MIbiqXRULTVahIG2Yf 0oBT7V6Rw7gsaK2m1X85eVXrh1A66liobKnFlPu5j9tmkKrZ9BOgnOnkDU2douVepDRI h3cIsf0aAJM4yG73Nsru81ZmD4wGG3qKPtZF0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=yRsx9fV+bsdsBqZLNDYdUh9BAcOGmto5Ewg3ECkjzYM=; b=DejdMfFY5QPsPgke902Wv1Wvi6Fz6qpwzLsVL3jqxqtUp/va3y9IahyCYRbxxMPqdK sBg6ywMzbS+5pDIENJSZUoS2ChGPzo9N4b278SfbIHZTj5uPse0bwlBMB7TC4BWWV4GX CYtPw8YpfEHfNinMRYNlAOPtUPVwHx2Sy9IahsfbN/O2QAvAEKqoSKk1eL1dCTLVG2St yWaL0Pq3fQHhLa+MKaMjTAPOdo1CozfS9ABVd/gKlyA30bvnQxwlrjwGlSlolcZA6A2J 8UOrx6Ivr2FpzdSCIsqNhpyi7Kut0MvVeLSHA0yFTx6STKNo6/7vZgpKakJhI/CbZIdz 1iRA== X-Gm-Message-State: ALoCoQm3rumWd6qC0SxaC1E3u6SuEBjjh3xAVpD78J803HC5oxFSBnS/kxO0Ph82b/ZeUGu2UiMB X-Received: by 10.112.155.168 with SMTP id vx8mr183359lbb.110.1424818264849; Tue, 24 Feb 2015 14:51:04 -0800 (PST) Received: from spencer.imf.au.dk ([130.225.20.51]) by mx.google.com with ESMTPSA id pq1sm6521232lbb.41.2015.02.24.14.51.03 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Feb 2015 14:51:04 -0800 (PST) From: Rasmus Villemoes To: Bjorn Helgaas Cc: Borislav Petkov , Rasmus Villemoes , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] PCI/AER: Avoid info leak in __print_tlp_header Date: Tue, 24 Feb 2015 23:50:46 +0100 Message-Id: <1424818246-11841-1-git-send-email-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.1.3 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Commit fab4c256a58b ("PCI/AER: Add a TLP header print helper") introduced the helper function __print_tlp_header, but contrary to the intention, the behaviour did change: Since we're taking the address of the parameter t, the first 4 or 8 bytes printed will be the value of the pointer t itself, and the remaining 12 or 8 bytes will be who-knows-what (something from the stack). We want to treat the four members of the struct aer_header_log_regs as little-endian 32 bit numbers and print those. That can be done without ugly and confusing casts. Fixes: fab4c256a58b ("PCI/AER: Add a TLP header print helper") Signed-off-by: Rasmus Villemoes --- drivers/pci/pcie/aer/aerdrv_errprint.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/pci/pcie/aer/aerdrv_errprint.c b/drivers/pci/pcie/aer/aerdrv_errprint.c index c6849d9e86ce..e328978038c1 100644 --- a/drivers/pci/pcie/aer/aerdrv_errprint.c +++ b/drivers/pci/pcie/aer/aerdrv_errprint.c @@ -132,16 +132,9 @@ static const char *aer_agent_string[] = { static void __print_tlp_header(struct pci_dev *dev, struct aer_header_log_regs *t) { - unsigned char *tlp = (unsigned char *)&t; - - dev_err(&dev->dev, " TLP Header:" - " %02x%02x%02x%02x %02x%02x%02x%02x" - " %02x%02x%02x%02x %02x%02x%02x%02x\n", - *(tlp + 3), *(tlp + 2), *(tlp + 1), *tlp, - *(tlp + 7), *(tlp + 6), *(tlp + 5), *(tlp + 4), - *(tlp + 11), *(tlp + 10), *(tlp + 9), - *(tlp + 8), *(tlp + 15), *(tlp + 14), - *(tlp + 13), *(tlp + 12)); + dev_err(&dev->dev, " TLP Header: %08x %08x %08x %08x\n", + le32_to_cpu(t->dw0), le32_to_cpu(t->dw1), + le32_to_cpu(t->dw2), le32_to_cpu(t->dw3)); } static void __aer_print_error(struct pci_dev *dev,