From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) by gnuweeb.org (Postfix) with ESMTPS id 094A07E24B for ; Mon, 7 Feb 2022 14:33:15 +0000 (UTC) Authentication-Results: gnuweeb.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=Pp2Y1sdY; dkim-atps=neutral Received: by mail-lf1-f45.google.com with SMTP id i17so1197830lfg.11 for ; Mon, 07 Feb 2022 06:33:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=KnaNqe0F/0qK8+8Ot3QUBi9cDcEuhiBIvkTGowrpFEs=; b=Pp2Y1sdYIzC+VATQtqdX6bmOnoUIS7hr/RcEeZ0+AeYoQ9S2gTYb4ZXM8iclajmCME 0r0rXd28riCvI5VWZp41PbGv+sS0prg0MIzKJmnh7kEgQPqdKrmr3ePDYkMigzlPJ5VF f5k+/0q0SLCpknP08JXKP1wBTTZ/6iGnMPcvyjBXw3ChCzm7NSnfPc4s8RBtoLcbidlu xN/6xfJQflvLWhelC7wQqRJWBO3jCZrxfDWJqp1PAv6Y7wCV2OG0ziCRvbUoNTX9l+xa JiF9oXLlfG4DO6CMxkHt4bL6nA51343foGp0u7Ud8bouZ4Pc+DglhhdNTFpuMhQOtG/Q nz5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=KnaNqe0F/0qK8+8Ot3QUBi9cDcEuhiBIvkTGowrpFEs=; b=j0nj9+hsseE2lH/QtpiPJo2HoArQTAiUuKe7wq+7o7uQANu9NdgdyKrJ0GD1BnHqzj gtNxvu0ymyqlqcct8RixibYojhHYL5OaaH46fhnS+3xBTE6ViUlHZOzqsS2xx95cAD+r MQG9gMTrJe7lOz71iZv9RtuJJI8ZyAb28xu4nqs6t/zA0b4sHNtzy1b+c9oCOlqVNh2/ 6k85PXGUZozTrSXUmgnXS58jtejDvovMscTi6pHOGbAcDG6GezD4fnyEDVFO0qspeKJG 0Aol2yvA6yDVyRUx4OzNZy3pgwrz+rIH7ml+4E6Wg492L8j8x5txGBqSMnDdJt8z7Xzz npkw== X-Gm-Message-State: AOAM532wpyBAb0s+cXxtHwmie7XVV9QsrKJuxCXCc/ft2hZnWaoIOyTv Pq9K7+UNDj4l4tOazseBez8Yb4ZDIuh9ZgJZBOA= X-Google-Smtp-Source: ABdhPJzqYRh55B1K0DlHc0a9idH2yG3fhQdcqL0ycqGvzogj798XtyNELAgH38g/ltV5HyyUsCGJjzLFNXsYU4UEipQ= X-Received: by 2002:a05:6512:1151:: with SMTP id m17mr8599456lfg.610.1644244393124; Mon, 07 Feb 2022 06:33:13 -0800 (PST) MIME-Version: 1.0 References: <20220207114315.555413-1-ammarfaizi2@gnuweeb.org> <91e8ca64-0670-d998-73d8-f75ec5264cb0@kernel.dk> <20220207142046.GP1978@kadam> In-Reply-To: <20220207142046.GP1978@kadam> From: Alviro Iskandar Setiawan Date: Mon, 7 Feb 2022 21:33:02 +0700 Message-ID: Subject: Re: [PATCH io_uring-5.17] io_uring: Fix build error potential reading uninitialized value To: Dan Carpenter Cc: Jens Axboe , Ammar Faizi , "GNU/Weeb Mailing List" , io-uring Mailing list , Tea Inside Mailing List , Linux Kernel Mailing List , kernel test robot , "Chen, Rong A" , Pavel Begunkov Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: On Mon, Feb 7, 2022 at 9:21 PM Dan Carpenter wro= te: > On Mon, Feb 07, 2022 at 06:45:57AM -0700, Jens Axboe wrote: > > On 2/7/22 4:43 AM, Ammar Faizi wrote: > > > 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. > > > > The compiler should be able to deduce this, and I guess newer compilers > > do which is why we haven't seen this warning before. The compiler can't deduce this because the import_single_range() is located in a different translation unit (different C file), so it can't prove that (ret < min_ret) is always true as it can't see the function definition (in reality, it is always true because it only returns either 0 or -EFAULT). > > No, we disabled GCC's uninitialized variable checking a couple years > back. Linus got sick of the false positives. You can still see it if > you enable W=3D2 > > fs/io_uring.c: In function =E2=80=98io_recv=E2=80=99: > fs/io_uring.c:5252:20: warning: =E2=80=98flags=E2=80=99 may be used unini= tialized in this function [-Wmaybe-uninitialized] > } else if ((flags & MSG_WAITALL) && (msg.msg_flags & (MSG_TRUNC | MSG_C= TRUNC))) { > ~~~~~~~^~~~~~~~~~~~~~ > > If you introduce an uninitialized variable bug then likelyhood is the > kbuild-bot will send you a Clang warning or a Smatch warning or both. > I don't think anyone looks at GCC W=3D2 warnings. > This warning is valid, and the compiler should really warn that. But again, in reality, this is still a false-positive warning, because that "else if" will never be taken from the "goto out_free" path. -- Viro