Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3458690imm; Tue, 17 Jul 2018 05:18:47 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdJBvibI66fkmpboj/yw8lIYGQAnQVwSouJbt4QZ3hK1ldx00M504Boq/ocN4lEEz3mhoQ6 X-Received: by 2002:a17:902:9f81:: with SMTP id g1-v6mr1406748plq.304.1531829927040; Tue, 17 Jul 2018 05:18:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531829927; cv=none; d=google.com; s=arc-20160816; b=LxRuY0BFFpv/h4I10iziUGuLDzAIPFYzC1iUqSJs49lU/MN8plRD84TtgSIOf4arJx hPKftEuguJ+pTS11ezM79ssyM+aqkR3FPMGMkZahYrfEquBj2pePwT1813kozG/mUBAf uyi/1ytRdNqhVy6A33n1pY88sXAmaxDZusdbYkOns8wuwcDik/P1CRJlbWkaCcaOZFXk DONDnMDzpvfPKJj4MIIw3djAmQqRcSX/WzAMoWNtiR2VSePVcsRRy57+1bOqoI01eCkX 0KuOlFYIiF9rCL9tdV8HdoipdKr8DF4RNwxae+wu5N/usWUgO6+60G/i1Q4kADSTM5U0 xH7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organisation:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=ffhe6PFHASpA3ED0m4l2W5+TbzFaWT7SjW7+zMIok1I=; b=dKYIp3Ut23NhHMB/v9YZiMMM7g81AzakT6bGwz7O5p3a09u8FqBm5IhaKFPUvLQWdp vs48YqHIzovGyWXw4gYdzIQLw4TzjWtuFbtComEjZK+/J2W9E4l8d+ia9JejDsSYx2WZ f3FkYi3vm04bWfy7sMq8nkUWGpxpmTtszqZFzyojLqPnTTg0RlAnGNtn5Z0+8ijmO1EN YKqspt745S92UIg8KGOaHv2GNr/qeWvvpzL/iIdg6iHAIfPgSKpsez+Xc0e0f5EtXBmx wxa5hxmKvmU8xdDLHCZvmbjs2juzmnm3RQcJGMR15rUk656rzT27I3rS3IinmI3U+eaz y+rA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@verge.net.au header.s=mail header.b="ht/a+Od6"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a4-v6si853938pgl.9.2018.07.17.05.18.31; Tue, 17 Jul 2018 05:18:47 -0700 (PDT) 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=fail header.i=@verge.net.au header.s=mail header.b="ht/a+Od6"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731416AbeGQMuU (ORCPT + 99 others); Tue, 17 Jul 2018 08:50:20 -0400 Received: from kirsty.vergenet.net ([202.4.237.240]:57053 "EHLO kirsty.vergenet.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731239AbeGQMuU (ORCPT ); Tue, 17 Jul 2018 08:50:20 -0400 Received: from reginn.horms.nl (watermunt.horms.nl [80.127.179.77]) by kirsty.vergenet.net (Postfix) with ESMTPA id 67DEA25BEBD; Tue, 17 Jul 2018 22:17:55 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=verge.net.au; s=mail; t=1531829875; bh=Z/rf9VbXzABrpd78lm3tl+kNWysE3SLlzVis07nPW10=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ht/a+Od6mawSz2J9CDNdC2IC0I4U6avbTBmsZt7G7vo42cZrDNpNs15XHw4NuBF3/ XdSaTzwzU1YMug6Vjh1v0U1MDpp4mioJvcDeH9b9hKBygZdyvkWI0/FwHyceFEmRcQ sSQak7flPZ1t8K5VwnVGRgvxSAzY9EWUtkIQvjRQ= Received: by reginn.horms.nl (Postfix, from userid 7100) id 6DEDB940456; Tue, 17 Jul 2018 14:17:53 +0200 (CEST) Date: Tue, 17 Jul 2018 14:17:53 +0200 From: Simon Horman To: Geert Uytterhoeven Cc: Chris Brandt , Greg Kroah-Hartman , Jiri Slaby , linux-serial@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] serial: sh-sci: Fix use-after-free on subsequent port startup Message-ID: <20180717121752.jdsefuqhlidxkztp@verge.net.au> References: <20180717085810.23502-1-geert+renesas@glider.be> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180717085810.23502-1-geert+renesas@glider.be> Organisation: Horms Solutions BV User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 17, 2018 at 10:58:10AM +0200, Geert Uytterhoeven wrote: > sci_request_irq() checks port->irqstr[j] for a NULL pointer, to decide > if a fallback interrupt name string should be allocated or not. > > While this string is freed during port shutdown, the pointer is not > zeroed. Hence on a subsequent startup of the port, it will still be > pointing to the freed memory, leading to e.g. > > WARNING: CPU: 0 PID: 404 at fs/proc/generic.c:388 __proc_create+0xbc/0x260 > name len 0 > > or to a crash (the latter is more likely with CONFIG_DEBUG_SLAB=y, due > to the poisoning of freed memory). > > Instead of zeroeing the pointer at multiple places, preinitialize > port->irqstr[j] to zero to fix this. > > Fixes: 8b0bbd956228ae87 ("serial: sh-sci: Add support for R7S9210") > Signed-off-by: Geert Uytterhoeven Reviewed-by: Simon Horman