From patchwork Thu Feb 26 08:55:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 5890051 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7DA60BF440 for ; Thu, 26 Feb 2015 08:55:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5595A20386 for ; Thu, 26 Feb 2015 08:55:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C00072034C for ; Thu, 26 Feb 2015 08:55:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753078AbbBZIz1 (ORCPT ); Thu, 26 Feb 2015 03:55:27 -0500 Received: from mail-la0-f54.google.com ([209.85.215.54]:33026 "EHLO mail-la0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752193AbbBZIz1 (ORCPT ); Thu, 26 Feb 2015 03:55:27 -0500 Received: by labgf13 with SMTP id gf13so9542624lab.0 for ; Thu, 26 Feb 2015 00:55:25 -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:in-reply-to:references; bh=vz3Cwwzy4X/OAiU0bDtaYdYdgM9iHF3XtyfFHpJVAmw=; b=ib3V8LbjUrj86d3CNoPrc99U9UspYYAUzSBTADLbAstFTzyiejtPUmMTJJmAwJms3r XFP/XrQzRgUukurM6j/Q/UqGQo8cv3N33w8X0WdoqtkQLrM1kBNQiyFms/M5JfH3OzB4 +SL/7oYcFi2/ioIxDy+e8TZmId/zM9TerMRDg= 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:in-reply-to :references; bh=vz3Cwwzy4X/OAiU0bDtaYdYdgM9iHF3XtyfFHpJVAmw=; b=Uf3EVpia2h4lvDbprNwO4dGMFkTp49C6A5GFbtMkEWQpzHQ9Id1m1ZPfbo2m1K4D7t Cyxac4ZUqvpfDpsBVskL4R94zj6gsHh4Hn4VqMsgdJADWxVZbVwBBOV3lRCIqSBtlpsb rKPhICIhTWeD4UrwHLBlEOSKhaJgdr1GO7gI2XSQnWzvTgi/NjLIhM6l+oA9QooZRwBD DQFRNfkMRM3fTbaeVRGivYOCWAy7CjM22GeJA5bK0bWxYvB4iwsexy2XkmjwxtCw7tiG 5k7CR4YFXAeMPPXdcnR6KSv/rHdPGhEjcSD4SRicp/6y/PGRdSHcKPqSdVm67g89rOVz kg1Q== X-Gm-Message-State: ALoCoQkFPzp3WuXkcjqGgHGOFc9DTc74NfWTYkD7oohHUU2vxMogbKcFgd0n2M10yBAk8mVrzM4N X-Received: by 10.152.23.195 with SMTP id o3mr6198195laf.11.1424940925708; Thu, 26 Feb 2015 00:55:25 -0800 (PST) Received: from spencer.imf.au.dk ([130.225.20.51]) by mx.google.com with ESMTPSA id rk10sm53913lac.12.2015.02.26.00.55.24 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Feb 2015 00:55:24 -0800 (PST) From: Rasmus Villemoes To: Bjorn Helgaas Cc: Borislav Petkov , Tony Luck , Rasmus Villemoes , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] PCI/AER: Avoid info leak in __print_tlp_header Date: Thu, 26 Feb 2015 09:55:03 +0100 Message-Id: <1424940903-9147-1-git-send-email-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.1.3 In-Reply-To: <20150225225859.GB19236@pd.tnic> References: <20150225225859.GB19236@pd.tnic> 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=unavailable 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 show the values of the four members of the struct aer_header_log_regs; that can be done without ugly and error-prone casts. On little-endian this should produce the same output as originally intended, and since no-one has complained about getting garbage output so far, I think big-endian should be ok too. Fixes: fab4c256a58b ("PCI/AER: Add a TLP header print helper") Signed-off-by: Rasmus Villemoes Acked-by: Borislav Petkov --- v2: Just print ->dwX as-is. drivers/pci/pcie/aer/aerdrv_errprint.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/pci/pcie/aer/aerdrv_errprint.c b/drivers/pci/pcie/aer/aerdrv_errprint.c index c6849d9e86ce..167fe411ce2e 100644 --- a/drivers/pci/pcie/aer/aerdrv_errprint.c +++ b/drivers/pci/pcie/aer/aerdrv_errprint.c @@ -132,16 +132,8 @@ 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", + t->dw0, t->dw1, t->dw2, t->dw3); } static void __aer_print_error(struct pci_dev *dev,