Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1629841pxb; Wed, 9 Feb 2022 00:34:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJzKDwVl9zed490/Mwrb+blJiIcyGXUm9s6IYApQ0PB68r+KuZyJkexttx53li4o+76Py7wS X-Received: by 2002:a17:90a:4a09:: with SMTP id e9mr2214144pjh.36.1644395679779; Wed, 09 Feb 2022 00:34:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644395679; cv=none; d=google.com; s=arc-20160816; b=F1F3yMk1HVVZZOcETzp9qhVN+URk0yA8nA1syg2KiFh8f+PqLdv6WR2A+yZMMQjQAi 3Z2aVBi2NjZ2jQ0fPPWg4TvP7/4QVGXOC1c3+aAuyV2pij3OcoOnqEozuNiU+IDgRgKN zlyynctUxxALe+OvygYt6he9x2nl0TgG6DEnaRpaC2BPZAPR4RW9K1Trn4FpOTREynmH XTgNLFNe6GwqPE9EFFt6q/1AOzeeNo6/3lQBWU4lER021usKGLASRu3dPkMRY9s4RFEh Q+rdt907pwjxzeYq9RJycNvhl7/eLqxcbSAhA8bPKJlgVvDOWB4jdDoHdQ2LvJiSYd3v 4PqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zFRyQYC8aO177l/5OJZbbzZOBabPM0vg7ianE0nb59w=; b=R12b3CASp+No70cKIu0cARgbhudjh/AeZzpFkBifpgPdjcDk+0TPT9TjvTWY6Z1HG0 fEFRDLjVskega0mZAuAFgYJrsMMRoipVdb3NqNzSRkYzP9J3PC0xIPRjCKMSOt8SKvlo erQT1uoJbOpU/aTB/26l1HTnLmAOfVj0Tmc1hnwALVrBlNz0WNKdQL2RIU5xsLDtTW3S 5jGUu9OoWkljzrs8LM5NABvQW0sduPRLbu9DxaelS18CeAflVKKUxPD/g2/u1nK/BjsF B04ya5TmHjyrRBUqP88LTUH0QaN/DqcFw2Y3c+8p4ZXCxmnfbbmmkNfDejhi+AYcZOxk GqLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gnuweeb.org header.s=default header.b=F6YNv0l9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnuweeb.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id s42si17004729pfg.171.2022.02.09.00.34.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 00:34:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gnuweeb.org header.s=default header.b=F6YNv0l9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnuweeb.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 66B2CC050CFD; Wed, 9 Feb 2022 00:34:31 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391286AbiBGOTl (ORCPT + 99 others); Mon, 7 Feb 2022 09:19:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347860AbiBGOGJ (ORCPT ); Mon, 7 Feb 2022 09:06:09 -0500 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79E2AC043188; Mon, 7 Feb 2022 06:06:07 -0800 (PST) Received: from integral2.. (unknown [36.72.214.231]) by gnuweeb.org (Postfix) with ESMTPSA id 2708E7E24F; Mon, 7 Feb 2022 14:06:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1644242766; bh=G0B/qx9vzzQxYGDcP1samCsqc9aLd8Wtz9Gxg69dd2I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F6YNv0l9aRMeGzi7VwFsEMtzG3zQaKwAxd1XnR2M3BlpSiMHYKFvabS7/OpjqfbXi eMVuZ5yNmJcV54+mSeqvGkRHHqSrI0i1CwI5GJlXMco28NE9L5Hjr5LhCqVUXR2AV+ YxVMPyTunprBdUMqqdd8cuEWNrgC/Xjn48JaucpXdDFMF1Q1UhFyluTujQEY/z1ZUA oLk9/QWwoTatM/PuQ/80T585UTJWC+zoR2UOPIs01NmXGivafTILP12QQe7C8SdAOV yastEbo9QPOn2C9M8r4oVMAlV8Rh2tZLKZtNkv2MAiVfSdnynzTtMzM7k9oJ1bnJte lKz9eZJAsrGgA== From: Ammar Faizi To: Jens Axboe Cc: GNU/Weeb Mailing List , io-uring Mailing list , Tea Inside Mailing List , Linux Kernel Mailing List , Alviro Iskandar Setiawan , kernel test robot , Dan Carpenter , "Chen, Rong A" , Pavel Begunkov , Ammar Faizi Subject: [PATCH io_uring-5.17 v2] io_uring: Clean up a false-positive warning from GCC 9.3.0 Date: Mon, 7 Feb 2022 21:05:33 +0700 Message-Id: <20220207140533.565411-1-ammarfaizi2@gnuweeb.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <91e8ca64-0670-d998-73d8-f75ec5264cb0@kernel.dk> References: <20220207114315.555413-1-ammarfaizi2@gnuweeb.org> <91e8ca64-0670-d998-73d8-f75ec5264cb0@kernel.dk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alviro Iskandar Setiawan In io_recv(), if import_single_range() fails, the @flags variable is uninitialized, then it will goto out_free. After the goto, the compiler doesn't know that (ret < min_ret) is always true, so it thinks the "if ((flags & MSG_WAITALL) ..." path could be taken. The complaint comes from gcc-9 (Debian 9.3.0-22) 9.3.0: ``` fs/io_uring.c:5238 io_recvfrom() error: uninitialized symbol 'flags' ``` Fix this by bypassing the @ret and @flags check when import_single_range() fails. Reasons: 1. import_single_range() only returns -EFAULT when it fails. 2. At that point, @flags is uninitialized and shouldn't be read. Reported-by: kernel test robot Reported-by: Dan Carpenter Reported-by: "Chen, Rong A" Link: https://lore.gnuweeb.org/timl/d33bb5a9-8173-f65b-f653-51fc0681c6d6@intel.com/ Cc: Pavel Begunkov Suggested-by: Ammar Faizi Fixes: 7297ce3d59449de49d3c9e1f64ae25488750a1fc ("io_uring: improve send/recv error handling") Signed-off-by: Alviro Iskandar Setiawan Signed-off-by: Ammar Faizi --- v2: - Update the subject line fs/io_uring.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index 2e04f718319d..3445c4da0153 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -5228,7 +5228,6 @@ static int io_recv(struct io_kiocb *req, unsigned int issue_flags) min_ret = iov_iter_count(&msg.msg_iter); ret = sock_recvmsg(sock, &msg, flags); -out_free: if (ret < min_ret) { if (ret == -EAGAIN && force_nonblock) return -EAGAIN; @@ -5236,9 +5235,9 @@ static int io_recv(struct io_kiocb *req, unsigned int issue_flags) ret = -EINTR; req_set_fail(req); } else if ((flags & MSG_WAITALL) && (msg.msg_flags & (MSG_TRUNC | MSG_CTRUNC))) { +out_free: req_set_fail(req); } - __io_req_complete(req, issue_flags, ret, io_put_kbuf(req)); return 0; } base-commit: f6133fbd373811066c8441737e65f384c8f31974 -- 2.32.0