Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp269083pxf; Wed, 31 Mar 2021 03:01:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyB/+XcIDD+kTMQuYjL9rErDJXAWfRAxst4XRhm9a1hNcoVLrq/J8i1wyXg5O/ZZqyo33NN X-Received: by 2002:a05:6402:1d39:: with SMTP id dh25mr2758992edb.282.1617184868036; Wed, 31 Mar 2021 03:01:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617184868; cv=none; d=google.com; s=arc-20160816; b=lAtZds/l13ex6rHkHDO4PWes8mfL4EPdKHMCryPkN16iroV23Ytela6Hr4JITFXUSs SEb2Nz79ipOsJfNpusXSP3I2qhG5SVmtafzws6d8w+9qSUNmucShoThnlhbKrW43ytc4 n7deFlljNIL+ZW1msog8cXy2c9H4l4kv2Ki4f8j606nw2U8ebODLAuiVxJWDwYy35+wk +NYhIcjU7xfULMkBIPqLgG5o1EuEPX5PhGZM7Zv3yzHf3cpeOARtIVH9f5hoMl6/c4vy Tnz+Hv4z94BXdZN/sDwCBPZyTPS9UK/RnY2xrtLyvazD3QzoeG8yQdXBjPeBKW8EoNBA uHUA== 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 :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=HhzP497JwzE7qBvkLi1PWy+Oq7YyictUjri7Hz/xGfs=; b=BOepSYktnRXYNJPXdvkV3d033yywwI1au0uWLCsLhBdFzrhqNZGfgD2lsnaZ/Z6BPW c1nb8KVY58PsAh+KRCb6orjYaTBP4pXZtD0F4+N1rdDEEhuZFqAJiN/77ZvPowQY1hRE wfOyYS+TxOAEltc9cluF5wwc5XSn9Mc0F+3CD1h2yQoUeLII60IasxrtuVUl/KGVuxgB 7j/QaAcy4YaoYmgHLs9IawAERdL0BZqKzEFfWPbuFuhu7+yZmcpGEYUjB724Jz0JY2mt VPvq/40qLoqFFGOhSU0o+4x6VNcg7nxfPzZAmeClw/9VGBlnSw4X9QYpdol/c2e0tCwq MUnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=L5dNcFuS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z13si1469572edc.6.2021.03.31.03.00.44; Wed, 31 Mar 2021 03:01:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=L5dNcFuS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234730AbhCaJ5g (ORCPT + 99 others); Wed, 31 Mar 2021 05:57:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234545AbhCaJ5d (ORCPT ); Wed, 31 Mar 2021 05:57:33 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7486C061574; Wed, 31 Mar 2021 02:57:32 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id e18so19023717wrt.6; Wed, 31 Mar 2021 02:57:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:subject:from:to:cc:date:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=HhzP497JwzE7qBvkLi1PWy+Oq7YyictUjri7Hz/xGfs=; b=L5dNcFuSepOYJgqrnPW7GToj4Rnlj7T/Vtn4sgMAZcbX2LVi9snLxsUQxLaFzljbAD +K9E9/ecIB8wXz1iHX1AY9yhDPyl1Mc6+3EFhIuifBb99xkPd7bewGlk21s4fS0SE7BL 4WKA98Wg54SXDgAHfUD+raOvPy91W/Hk7cw1RT7xNi9TS6RWbft2oVJjVQ3zeKZDRloC AGk2mY9XFiJMEv00wl9oIXKNT2ryAy47sQuAuxd6QaVQtLX3VU+Gl4vB0gLkErE3jg39 W1+iYILcmSlgUkc8yfjNW3vAEkv3AoiTvS+cK2S8pCI8LebS57mOWQk84nAUBuiQCmB4 1JHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=HhzP497JwzE7qBvkLi1PWy+Oq7YyictUjri7Hz/xGfs=; b=QFPebW6hTbb+Fgdt6PKnDulYQtbG8TV/Jx8KKPzDCSDsmYd0GVAFRtT3A6jRHD8Cvh TqqSE7xjedDEsLaUSO2canUsh36hPHAvOSYIpjuUEFymBaAVKAa0bE94UoQaa2vav9b0 GF+2A6SKR0L4a9rla0gnLdd/PaN4wiiIwD1lwAS8fwaJN4o2Z6I6pdSRS3c+eE+0YyHi 76EsQLbhmwAiKXbkCngDGC5urEI5tORWmEzgsQ/szCgjPd/+zVFt1zAhnxrLVV4gqrmg P0UocmULTKtO3avnDY6J581Frd490aBGobMztUmhOREsCgqR3tkb6xR/2sXnQax9fNry VhUA== X-Gm-Message-State: AOAM532G5uxJIi+vTq5ZFRz1fVklpd7vxAsmzR3W0Fccnn2FQJ3ywVa3 Ab/vkZLtu3IhIp+DM/obkEHURKyOXAiFTQ== X-Received: by 2002:adf:d851:: with SMTP id k17mr2752514wrl.254.1617184651468; Wed, 31 Mar 2021 02:57:31 -0700 (PDT) Received: from 192.168.10.5 ([39.46.7.73]) by smtp.gmail.com with ESMTPSA id c2sm3232775wme.15.2021.03.31.02.57.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Mar 2021 02:57:30 -0700 (PDT) Message-ID: Subject: Re: [PATCH] io_uring: Initialize variable before use From: Muhammad Usama Anjum To: Dan Carpenter Cc: Jens Axboe , Pavel Begunkov , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, colin.king@canonical.com Date: Wed, 31 Mar 2021 14:57:25 +0500 In-Reply-To: <20210331084817.GH2088@kadam> References: <20210322184158.GA2095479@LEGION> <20210331084817.GH2088@kadam> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.4-0ubuntu1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2021-03-31 at 11:48 +0300, Dan Carpenter wrote: > On Mon, Mar 22, 2021 at 11:41:58PM +0500, Muhammad Usama Anjum wrote: > > 1) Initialize the struct msghdr msg in the start of the function > > 2) Uninitialized variable msg.msg_flags can get used if branch happens to > > out_free before initialization. > > > > So initialize variable in question in the start of the function for > > simplicity in logic and use. > > > > Addresses-Coverity: ("Uninitialized variable") > > Addresses-Coverity: ("Uninitialized variable read") > > This bug is a false positive. > > When msg.msg_flags is uninitialized then ret is negative and min_ret is > zero. > > fs/io_uring.c > 4666 ret = -EINTR; > 4667 out_free: > 4668 if (req->flags & REQ_F_BUFFER_SELECTED) > 4669 cflags = io_put_recv_kbuf(req); > 4670 if (ret < min_ret || ((flags & MSG_WAITALL) && (msg.msg_flags & (MSG_TRUNC | MSG_CTRUNC)))) > ^^^^^^^^^^^^^ ^^^^^^^^^^^^^ > The first part of the condition is true so the second part is not used. > > 4671 req_set_fail_links(req); > 4672 __io_req_complete(req, issue_flags, ret, cflags); > 4673 return 0; > 4674 } > Understood. Thank you so much! Thanks, Usama > regards, > dan carpenter >