Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1991735ybn; Thu, 26 Sep 2019 05:28:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqz1l47CiRDuv4H7z/BMDswAwOBMWk6oFpIgeOAMhJevL7hufgL37J5jAjzGRHqlEKMO4Mrf X-Received: by 2002:a50:935d:: with SMTP id n29mr3299715eda.294.1569500930026; Thu, 26 Sep 2019 05:28:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569500930; cv=none; d=google.com; s=arc-20160816; b=GNReCrG42ggtl/Y+L+qTtswAi2XzFFrz319/EG5rONcLzP5/dzZgoqFP53eE3W7baY Tc3AlwpyfVQO0ncg6RqAc+ulQBdNpYQlmgqM+xDvf+EyTatUEY5lROwjGOlcBELHcymC 0iADBhHbDvrZlslLVaaXjOF/9Povwl7qoVBbBdzp3Tic3YeIz3X/M7nCLyHCPjscJJ38 ZWqFOmuFBburqWJMc1gAdAqg+No0UyRrOaKsu9XYx6i3piIwr91WLtTsSrIOUzCipVl6 +6Fsu6blyV/H9kHVPv13wFpm/v6CZm0VnBD5ExS4Ibg0ppcHYvkzGmtiPw/5VCP61tFz XSag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=p32y5pL62PU7Yf9iy/plIVHUc6YiHXgm7LNnsJBfWag=; b=PketllFKoMpvntPZvnHS5C6Nt4zjDd9Jsf9DjOFKA6L0vNbe6SmZaf5qxwP+YPp84+ wm3z9qZCX6hhZWpDp/CRxUcVSWJcXrn7ADUjj2BFfOGaB8l7vxzKapxox/CHlg48HPpU GgnmZLVYmSk3azU1f0JUIfACucaEYAgYB/v2SDFSTRiqmLbaKGTwP5GECQWLadQrdDHW eVb87eBPsIojFOf0korkSU9yFlnKNrsDKZQ000G9T1VGo2vsKoBfBjJxo9LreXxPt2/5 uTILt8Yk/buzxm2K8wzjCdZKUgWXKhviM2C60tq33CbEwyJm/xrv3RXaDPzOUlEOjBMz wYaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=QOUNhFqA; 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 p36si1220024edc.373.2019.09.26.05.28.25; Thu, 26 Sep 2019 05:28:50 -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; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=QOUNhFqA; 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 S1726335AbfIZM0f (ORCPT + 99 others); Thu, 26 Sep 2019 08:26:35 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:38755 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725917AbfIZM0e (ORCPT ); Thu, 26 Sep 2019 08:26:34 -0400 Received: by mail-wr1-f66.google.com with SMTP id w12so1833227wro.5 for ; Thu, 26 Sep 2019 05:26:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=p32y5pL62PU7Yf9iy/plIVHUc6YiHXgm7LNnsJBfWag=; b=QOUNhFqApk0JZioGtQSmqcw6DrLAybbq5zyIfy4vZUVbIk0srAk//b2mD0SDPpM8uJ 891LzBY3eRJHYK4y5wWOZeWbZqRs20mepTSFNoIae3EMzwh4/3LdP/SEcrGfU6sAQb/8 0L5o4W5RCKH/MeSm2qXQXeKbS6FjhFCheOaLlXJkI3KPTYzsagKWNhqO0Y/9VnQDIGOu 8X+NXogpXrd2GPzJWHPCdqHKrug9a73PnieO6i8eo/Z66MaWiwCwvxuj0bZQq2R1J0Ag 8OJF4cvEQGNIbJyh06yT4xAWUQMM/rej6F3HP8azXufHyMzuY7mbvOGC3E+3IP/FKxkb QoVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=p32y5pL62PU7Yf9iy/plIVHUc6YiHXgm7LNnsJBfWag=; b=Y3iqHYM/ufdUe65Hn6fY24bDrzACKjSPDOR6Xz7YewWoxEwaZT+V2cFCwkuSXe47y7 3ilzRyfOKAo/wCAXM6S1r/dHYFm7Le5v5OED21Hn32Y8EZ0f7Dmk5p+5AtclYrJbk4hu q/S5eGxhYjFbT3hNkwM1zdmfTiFnXSoQysrXbf9aCK8A2L6d+5G8RIfAx3rSZtAGxQ94 tTG+vN94KKKy5+ymHMOczpOVQ9IFqdeWAYsLVMlNjbyBoJbK20+h5wv2q/mBHPG0B7t3 WuS0sB34mCHeN0opQHjBb/24dk1zAJNRRq66TUfjZCvQBrpgJq9/5ho0V/Rlr/qPA/+g QLgw== X-Gm-Message-State: APjAAAUMo179BzbzNyfnfo8IzCo4wE1hFQ1OagiKfSVT8z68iooX5Dkl yert02dpNhvvT1pS+fNQ6gLVfGmofCS9Ng2W X-Received: by 2002:a05:6000:108c:: with SMTP id y12mr1628248wrw.238.1569500792496; Thu, 26 Sep 2019 05:26:32 -0700 (PDT) Received: from [192.168.1.145] ([65.39.69.237]) by smtp.gmail.com with ESMTPSA id e17sm1932014wma.15.2019.09.26.05.26.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Sep 2019 05:26:31 -0700 (PDT) Subject: Re: [PATCH][next] io_uring: ensure variable ret is initialized to zero To: Rasmus Villemoes , Dan Carpenter Cc: Colin King , Alexander Viro , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org References: <20190926095012.31826-1-colin.king@canonical.com> <3aa821ea-3041-fb56-2458-ec643963c511@kernel.dk> <20190926113329.GE27389@kadam> <04262621-68fd-a4bb-ab0c-83954c03fbb0@kernel.dk> <2de0eb45-3abc-3ccd-f3d3-346d899ba50d@rasmusvillemoes.dk> From: Jens Axboe Message-ID: Date: Thu, 26 Sep 2019 14:26:31 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <2de0eb45-3abc-3ccd-f3d3-346d899ba50d@rasmusvillemoes.dk> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/26/19 2:14 PM, Rasmus Villemoes wrote: > On 26/09/2019 13.42, Jens Axboe wrote: >> On 9/26/19 1:33 PM, Dan Carpenter wrote: >>> On Thu, Sep 26, 2019 at 11:56:30AM +0200, Jens Axboe wrote: >>>> On 9/26/19 11:50 AM, Colin King wrote: >>>>> From: Colin Ian King >>>>> >>>>> In the case where sig is NULL the error variable ret is not initialized >>>>> and may contain a garbage value on the final checks to see if ret is >>>>> -ERESTARTSYS. Best to initialize ret to zero before the do loop to >>>>> ensure the ret does not accidentially contain -ERESTARTSYS before the >>>>> loop. >>>> >>>> Oops, weird it didn't complain. I've folded in this fix, as that commit >>>> isn't upstream yet. Thanks! >>> >>> There is a bug in GCC where at certain optimization levels, instead of >>> complaining, it initializes it to zero. >> >> That's awfully nice of it ;-) >> >> Tried with -O0 and still didn't complain for me. >> >> $ gcc --version >> gcc (Ubuntu 9.1.0-2ubuntu2~18.04) 9.1.0 >> >> Tried gcc 5/6/7/8 as well. Might have to go look at what code it's >> generating. >> > > I think it's essentially the same as > https://lore.kernel.org/lkml/CAHk-=whP-9yPAWuJDwA6+rQ-9owuYZgmrMA9AqO3EGJVefe8vg@mail.gmail.com/ > (thread "tmpfs: fix uninitialized return value in shmem_link"). I think you're right, it's the same pattern. If I kill the: if (ret) return ret; inside the if (sig) branch, then gcc does show the warning as it should. -- Jens Axboe