Received: by 10.223.185.116 with SMTP id b49csp1059055wrg; Fri, 23 Feb 2018 11:09:38 -0800 (PST) X-Google-Smtp-Source: AH8x225q5H9Cf/5zVORZVBKIGv96DrORY28uNVht+rj6B3L654F0ykkSv6YmLo3UGkz/dTbRbIGX X-Received: by 2002:a17:902:2c43:: with SMTP id m61-v6mr2600781plb.387.1519412978273; Fri, 23 Feb 2018 11:09:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519412978; cv=none; d=google.com; s=arc-20160816; b=KjUFymea+sWifvFDG4CABHmbNSwqlSM8mFZGwsjbC7icliopUzUn70JYak1d+ttmlB yU1IFiEt5Hjsds3p31cetNQVXVHUHrm7ghgNbENOaq5kRRI+UlAxQBd6p5nME5XQtuNG 2Oi9WlXJiIBYD9KNfTCJe6fAcRBxp9zXSKoGz/lueIid6TwYtjlVFqg0fLsCB8pj5/zE KDmcYElc46hDAUCxCQLj0jESsbf/8PDS1rqxjEKIYTFrYkSdovfP+OvqnRIJKWTsDfGS atO6xWIOS0Im4hjLE2DYz9XrPZViRe+OtoNWhYfENkwgWmcW310ZPCXUdTJ18U0lbZOs FZcA== 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=GluV1uV2rr0c64H4xhiLWi6QkzinZoEbpJt4Sd4nKlk=; b=mnjeKRbmB5QhxZXb7LMt7keOTkupPGjrfhSqj4sYT6rtYPmC2IBAOMZgFpVPExnvPc DTrEzfPU4XhsEuRWNu2+/TBU8x3RXvIcM/H8hUKdnWtTNmvTFUzU+qq4vgLc58U2Y1q1 FVC3khP/CjgkcPL9Lfm3GBWtzueTCFA1714a05lePqjmbDkiVwWN4FmywJCyg7SMoJh8 oFoT2DAdGMZSEmZrq0FRazAfYIPUPvjCNvp2Xg/2QoLIl+otzcAYUedTdUaP8h6obhWi ous38ieExWw4UZ3w65vHy+xp/+Au7WjtsQCahfxXzb1PccU5lYUVDc1/NXZmk7FM4mjy gRLA== 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 i12-v6si2197696plk.508.2018.02.23.11.09.22; Fri, 23 Feb 2018 11:09:38 -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 S935730AbeBWTIp (ORCPT + 99 others); Fri, 23 Feb 2018 14:08:45 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:50096 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965338AbeBWS5R (ORCPT ); Fri, 23 Feb 2018 13:57:17 -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 655CDDFE; Fri, 23 Feb 2018 18:57:08 +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.15 10/45] blk_rq_map_user_iov: fix error override Date: Fri, 23 Feb 2018 19:28:49 +0100 Message-Id: <20180223170716.977053392@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170715.197760019@linuxfoundation.org> References: <20180223170715.197760019@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.15-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 @@ -119,7 +119,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; @@ -148,7 +148,7 @@ unmap_rq: __blk_rq_unmap_user(bio); fail: rq->bio = NULL; - return -EINVAL; + return ret; } EXPORT_SYMBOL(blk_rq_map_user_iov);