Received: by 10.223.185.116 with SMTP id b49csp1034939wrg; Fri, 23 Feb 2018 10:43:36 -0800 (PST) X-Google-Smtp-Source: AH8x224hAH4U4A2kGpPPhh0/C0JnBjhC8tSlrYSV3/jlQZA8p8utD5mw53d9nALWPkFgHfy0UEhW X-Received: by 10.98.245.18 with SMTP id n18mr2612640pfh.25.1519411416275; Fri, 23 Feb 2018 10:43:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519411416; cv=none; d=google.com; s=arc-20160816; b=WoXWHxy53+aBMeCueHYb0ERar9LGpBRsW8r2VvXOIsvEp5kM9zkqk12LvMpN7b4sQL uy6tgrGG7AHU3qOQ0eddycm6DtbjmashmfrX6dhszma3DJtOU0ROGJ0pJ8DBQRxgfZ8a xuToTyqixZuRRIaBfzbPge0Rnyo2nKVfmgJbImvamIXkIZSaB2W9sjo5y79Gru2mN6NT YeMNyVwBSo7Ye/wy2P8xqQgVy8YV2ZPiybNdQWyhXm8ytgL91hVPzQOjALeMwedCtyMN jFK9LV5AP3PCLEMrtx5CM9+ATepcwCydtmSWkkGMPpK8f1kdhTrbk1JP2HpzWMlzCLJ1 bUSw== 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 :arc-authentication-results; bh=jkz3x4PTQ/KnIroJw+sCCSdS6b2T+LPZZW99XXUE20o=; b=WpFa4aMUQcTg9lFAUgjvif7Vj/tuthKp3F3V7FFcr+7ZfGXZyuvpKgdVR9Ykfd14Ew UMQTz6IFN1Q/9ht56lU1bDiXAXq6Rkzh+KQ+s3+qFQhKBfOkmXRBNVzsZk7eQAsmg1dF fuOgMXxp7+ajQwzglJqQWd/gWk2EojNBeL6Nm3XJl55IEE9yHyc/i15kfM8BzRZCb1Jc MvGKDAAPiV+RwwRf0iK0/FzMuzSNx87IHxxH1jd0FJSl22Te7GGjbDdGFMjQbBRd8EBe tDdWdXG2If2hj01778kMAAhIgzmvihKmd8SWiEgRG6IpJufUhD3g0EghkkOTVOsblRC4 kGgA== 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 t8si1823005pgu.454.2018.02.23.10.43.21; Fri, 23 Feb 2018 10:43:36 -0800 (PST) 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 S932663AbeBWSmt (ORCPT + 99 others); Fri, 23 Feb 2018 13:42:49 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:41918 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932515AbeBWSmq (ORCPT ); Fri, 23 Feb 2018 13:42:46 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 5409D1050; Fri, 23 Feb 2018 18:42:45 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Douglas Gilbert , Jens Axboe Subject: [PATCH 4.9 019/145] blk_rq_map_user_iov: fix error override Date: Fri, 23 Feb 2018 19:25:25 +0100 Message-Id: <20180223170727.146950163@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170724.669759283@linuxfoundation.org> References: <20180223170724.669759283@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.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Douglas Gilbert commit 69e0927b3774563c19b5fb32e91d75edc147fb62 upstream. During stress tests by syzkaller on the sg driver the block layer infrequently returns EINVAL. Closer inspection shows the block layer was trying to return ENOMEM (which is much more understandable) but for some reason overroad that useful error. Patch below does not show this (unchanged) line: ret =__blk_rq_map_user_iov(rq, map_data, &i, gfp_mask, copy); That 'ret' was being overridden when that function failed. Signed-off-by: Douglas Gilbert Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- block/blk-map.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/block/blk-map.c +++ b/block/blk-map.c @@ -116,7 +116,7 @@ int blk_rq_map_user_iov(struct request_q unsigned long align = q->dma_pad_mask | queue_dma_alignment(q); struct bio *bio = NULL; struct iov_iter i; - int ret; + int ret = -EINVAL; if (!iter_is_iovec(iter)) goto fail; @@ -145,7 +145,7 @@ unmap_rq: __blk_rq_unmap_user(bio); fail: rq->bio = NULL; - return -EINVAL; + return ret; } EXPORT_SYMBOL(blk_rq_map_user_iov);