Received: by 10.192.165.148 with SMTP id m20csp4170107imm; Mon, 30 Apr 2018 13:06:35 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr/NHhAJO+BaB8qIsm1vAZwZW3mlVMwVufk+YEeBvytlWdf4fuOq2elYPkcziuHpfjWinPg X-Received: by 2002:a65:5c88:: with SMTP id a8-v6mr10765467pgt.373.1525118795640; Mon, 30 Apr 2018 13:06:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525118795; cv=none; d=google.com; s=arc-20160816; b=aR/BZZotaUw2zT6vTMXLfp4wdNw7AtU6nRmoBWeEWP4lEbpxcvvbqvm4zvcz188kGT BxcsCb9hDNXTpdkxxt5WWeScTebz9tn6mGXVJm3+nvaAjJkYj4xlBw7vqxXmBudqJsSY oQ/NxPuiCEGjp1d6xlft8hi5j3LrTnZRYelHlJ4Ftf6X5NCrzGjRwVgdB8myi/ekKKKO FAciA+J6ad6r1lANCepR+oWY7B4eqzjLXH2Ur39SdhDH3QprFOleOKU3RqszP6Ez1h7K hcO9eJ9S0M/sFmhGGVVA89iCatWfY1pqHBBG/qDdRdHP8Km507p6vFiCZRrnoAoGfkM1 haOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dmarc-filter :arc-authentication-results; bh=SYWn/NVvNwt8tevKIboiMQYHRhlb63diNwGidwdNw88=; b=g7FxEXW8mYdzSz6Tiws2Ihz+oGxjw8P2I32uCEcfDTCkF50xnWaA/Iipbv1gYX5eK3 PwnMrfk/pdna14iCLMw/8PhvN+pJZ9lo4Di6Fok9fLyRS7nWvo+E1nigkW2XBTmswa6D hvgQiIoWK5Q2eWtcIhBiIZCZFoY4PAmRe6hb1+fJu0xKOWL1yvkZtMC6j+EaAMB0Crpu zQXqMvs1OZxXomisrLBPeqqAZuY4wDuQz4AdJfFXTrdE9gk6RLtgi82TiWhfhyZsYzOf DOnRq9kv0Hr/lTkFB9gqOkZH2p79GM2NTSx/uyr3azEtIA2LYsLKPuHUneqMEL2L0tpg gEiw== ARC-Authentication-Results: i=1; mx.google.com; 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 s14-v6si6540482pgf.640.2018.04.30.13.06.21; Mon, 30 Apr 2018 13:06:35 -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; 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 S932192AbeD3T13 (ORCPT + 99 others); Mon, 30 Apr 2018 15:27:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:33912 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755962AbeD3T10 (ORCPT ); Mon, 30 Apr 2018 15:27:26 -0400 Received: from localhost (unknown [104.132.1.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C9DC822DC1; Mon, 30 Apr 2018 19:27:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C9DC822DC1 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oleksandr Natalenko , Kees Cook , Jens Axboe Subject: [PATCH 4.14 57/91] bfq-iosched: ensure to clear bic/bfqq pointers when preparing request Date: Mon, 30 Apr 2018 12:24:39 -0700 Message-Id: <20180430184007.145652337@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430184004.216234025@linuxfoundation.org> References: <20180430184004.216234025@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jens Axboe commit 72961c4e6082be79825265d9193272b8a1634dec upstream. Even if we don't have an IO context attached to a request, we still need to clear the priv[0..1] pointers, as they could be pointing to previously used bic/bfqq structures. If we don't do so, we'll either corrupt memory on dispatching a request, or cause an imbalance in counters. Inspired by a fix from Kees. Reported-by: Oleksandr Natalenko Reported-by: Kees Cook Cc: stable@vger.kernel.org Fixes: aee69d78dec0 ("block, bfq: introduce the BFQ-v0 I/O scheduler as an extra scheduler") Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- block/bfq-iosched.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -4447,8 +4447,16 @@ static void bfq_prepare_request(struct r bool new_queue = false; bool bfqq_already_existing = false, split = false; - if (!rq->elv.icq) + /* + * Even if we don't have an icq attached, we should still clear + * the scheduler pointers, as they might point to previously + * allocated bic/bfqq structs. + */ + if (!rq->elv.icq) { + rq->elv.priv[0] = rq->elv.priv[1] = NULL; return; + } + bic = icq_to_bic(rq->elv.icq); spin_lock_irq(&bfqd->lock);