Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp1896630img; Wed, 27 Feb 2019 07:16:11 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ0rGV0e2zBhcR798W3J+zxOy1ZO2VulYayKDLL3PbNN5+FCqkv0GJrJz3QLItKKFsB63Lb X-Received: by 2002:a63:cf02:: with SMTP id j2mr3476748pgg.113.1551280571630; Wed, 27 Feb 2019 07:16:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551280571; cv=none; d=google.com; s=arc-20160816; b=h/t+LI3nXNz2Evu76EE2WwzUgtZy0eXcaHPIvh6nd6GTyixitR4AL1KV6AStBtX6yW Q9KvsWmO0k9XPmjwPap/9IiNqMNwJdQjPVYFrFoo50eYQ4+B7h6idj7AIiZRBD6VW9sO 4EgOmgLmXUhn6txfTb9BSPqgrSks/LE4zD2aT8ZDc+34tUTaq6Xs9tj4bNtuRp2DpOVk FWrlv4LABuSYESmMhZmEa4jxBhWQG/x+xROVFyIWx7OQirXGnobjcsazVhsDRxkkZNLE 04HXALz5Z9CdcBJ3lBPyU2b+YsCiak2DvDk+fgVsG21BxzyJi3W8C5pf5HdPuzFjB1ss Cygg== 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:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :dkim-signature; bh=JDwKNo4Q1ugW00DDQqC89MJQTNZtVSoArGLMFxH2zRs=; b=i2A6IW0vHrXl79TzuKpGgOij14IUyjg6ODBW+DXDEfexWf9NXzLWewngTY5NI7v252 xCcPEVEFSRQn3bPLmkrVPXYkO9a3VxlpqF3lhSpg2GXdqqp3cFQipvKqMsJCq2Tj+JyK tea61IjJVxI16kxN0bdCC8N2Qpov9JuF066W/Ajz5tdI3N7ZsJYDoSNfEFOcM7aKc+Ne TVR3QETlDaS5RJzfgZXutTPrdtKw0lgUfhIR8KSB0SGzlad6z22YVOEniO7E5M1hgxDn VkOvxdsNKqwClOtKGf2A3j0aI4NN9qevh0TWHG9KJNKt4y6C0WUMUuBA1Wbqe+CKCjcX n4MQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lca.pw header.s=google header.b=dDkDuv5m; 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 h12si12267367pll.332.2019.02.27.07.15.39; Wed, 27 Feb 2019 07:16:11 -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; dkim=pass header.i=@lca.pw header.s=google header.b=dDkDuv5m; 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 S1729857AbfB0OJo (ORCPT + 99 others); Wed, 27 Feb 2019 09:09:44 -0500 Received: from mail-qk1-f196.google.com ([209.85.222.196]:44874 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726401AbfB0OJo (ORCPT ); Wed, 27 Feb 2019 09:09:44 -0500 Received: by mail-qk1-f196.google.com with SMTP id r21so9844799qkl.11 for ; Wed, 27 Feb 2019 06:09:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lca.pw; s=google; h=message-id:subject:from:to:cc:date:in-reply-to:references :mime-version:content-transfer-encoding; bh=JDwKNo4Q1ugW00DDQqC89MJQTNZtVSoArGLMFxH2zRs=; b=dDkDuv5mievBTLrLh0a6kPCLvcttWxQRHOZHcmFRX5LzxlI879UKPFmgR+zlZU7eUi wydriob7LhTjRjZVfnQrnzEnPLgBVoXdwzGYtISIW4ntLMVE/9JIcVrtrxgfC9rwcPj8 Mvz13VqJ9GDMS2igwKnjZb5OHR9RYHHpGA1qstteWRyIKIDZILuPjsnKL9rghoMkpU1R 46l9S1fryRvZXVoOXdp7kO603tJhuc4ujfJCbjE7fePStI3eBf4P3XCjdhb+s5aVNYZt FJl2Z2P4kfHrNAJ4qC7ov9LWUtD7s/3JQShdyV2wPYsjIAOLrelQxJJP1MILcf6ZS4Jb sKhg== 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:mime-version:content-transfer-encoding; bh=JDwKNo4Q1ugW00DDQqC89MJQTNZtVSoArGLMFxH2zRs=; b=NTnmXprAiTPGGTNzoR0Bl4KY0kG9c2beMmzcOzsCtuhYNJ7Mige9Im86ur1BuNCC0L OKf8ZEVtULZmGwEbsti7SePzj2QDScjY9PsRY5znpXYDoaFT80STen8NVD56fLdxpzn9 14aAYkEZN9evnMctAEXM0jMTG7dMoi40t0biD5BAs2/MS4uyxKCLs0ayWcEnoU/zLZCV 8YJE/SenjeTls+LETmG2bsCclEV2Xc6zdLkiguKBLm0s/u6Ou1mDb+Yrne9b2XKhxPt/ u1cScVpSjrnL9SP9C9YDh0qhz0QsRwk6pxB8bUwyf8bFEPgUNB55BmmFW7FmESRVbhq0 Hfqg== X-Gm-Message-State: APjAAAXqu7rokDOV43Z+wdbrBkWIOKfGvrE4EjmTzHUVR4KqG2IgwIWY X+Qll79NKvKVUpJ2hWJxdP4h0g== X-Received: by 2002:a37:a316:: with SMTP id m22mr2322448qke.194.1551276582817; Wed, 27 Feb 2019 06:09:42 -0800 (PST) Received: from dhcp-41-57.bos.redhat.com (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id 70sm19121483qkb.39.2019.02.27.06.09.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Feb 2019 06:09:42 -0800 (PST) Message-ID: <1551276580.7087.1.camel@lca.pw> Subject: Re: [PATCH] tmpfs: fix uninitialized return value in shmem_link From: Qian Cai To: Linus Torvalds Cc: Hugh Dickins , "Darrick J. Wong" , Andrew Morton , Matej Kupljen , Al Viro , Dan Carpenter , Linux List Kernel Mailing , linux-fsdevel , Linux-MM Date: Wed, 27 Feb 2019 09:09:40 -0500 In-Reply-To: References: <20190221222123.GC6474@magnolia> <86649ee4-9794-77a3-502c-f4cd10019c36@lca.pw> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.22.6 (3.22.6-10.el7) Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2019-02-25 at 16:07 -0800, Linus Torvalds wrote: > On Mon, Feb 25, 2019 at 4:03 PM Qian Cai wrote: > > > > > > Of course, that's just gcc. I have no idea what llvm ends up doing. > > > > Clang 7.0: > > > > # clang  -O2 -S -Wall /tmp/test.c > > /tmp/test.c:46:6: warning: variable 'ret' is used uninitialized whenever > > 'if' > > condition is false [-Wsometimes-uninitialized] > > Ok, good. > > Do we have any clang builds in any of the zero-day robot > infrastructure or something? Should we? > > And maybe this was how Dan noticed the problem in the first place? Or > is it just because of his eagle-eyes? > BTW, even clang is able to generate warnings in your sample code, it does not generate any warnings when compiling the buggy shmem.o via "make CC=clang". Here is the objdump for arm64 (with KASAN_SW_TAGS inline). 000000000000effc : {     effc:       f81c0ff7        str     x23, [sp, #-64]!     f000:       a90157f6        stp     x22, x21, [sp, #16]     f004:       a9024ff4        stp     x20, x19, [sp, #32]     f008:       a9037bfd        stp     x29, x30, [sp, #48]     f00c:       9100c3fd        add     x29, sp, #0x30     f010:       aa0203f3        mov     x19, x2     f014:       aa0103f5        mov     x21, x1     f018:       aa0003f4        mov     x20, x0     f01c:       94000000        bl      0 <_mcount>     f020:       91016280        add     x0, x20, #0x58     f024:       d2c20017        mov     x23, #0x100000000000            // #17592186044416     f028:       b2481c08        orr     x8, x0, #0xff00000000000000     f02c:       f2fdfff7        movk    x23, #0xefff, lsl #48     f030:       d344fd08        lsr     x8, x8, #4     f034:       38776909        ldrb    w9, [x8, x23]     f038:       940017d5        bl      14f8c     f03c:       54000060        b.eq    f048   // b.none     f040:       7103fd1f        cmp     w8, #0xff     f044:       54000981        b.ne    f174   // b.any     f048:       f9400014        ldr     x20, [x0]         if (inode->i_nlink) {     f04c:       91010280        add     x0, x20, #0x40     f050:       b2481c08        orr     x8, x0, #0xff00000000000000     f054:       d344fd08        lsr     x8, x8, #4     f058:       38776909        ldrb    w9, [x8, x23]     f05c:       940017cc        bl      14f8c     f060:       54000060        b.eq    f06c   // b.none     f064:       7103fd1f        cmp     w8, #0xff     f068:       540008a1        b.ne    f17c   // b.any     f06c:       b9400008        ldr     w8, [x0]     f070:       34000148        cbz     w8, f098     f074:       940018fd        bl      15468                 ret = shmem_reserve_inode(inode->i_sb);     f078:       38776909        ldrb    w9, [x8, x23]     f07c:       940017c4        bl      14f8c     f080:       54000060        b.eq    f08c   // b.none     f084:       7103fd1f        cmp     w8, #0xff     f088:       540007e1        b.ne    f184   // b.any     f08c:       f9400000        ldr     x0, [x0]     f090:       97fffcf6        bl      e468                 if (ret)     f094:       35000660        cbnz    w0, f160         dir->i_size += BOGO_DIRENT_SIZE;     f098:       910122a0        add     x0, x21, #0x48     f09c:       b2481c08        orr     x8, x0, #0xff00000000000000     f0a0:       d344fd09        lsr     x9, x8, #4     f0a4:       3877692a        ldrb    w10, [x9, x23]     f0a8:       94001828        bl      15148     f0ac:       54000060        b.eq    f0b8   // b.none     f0b0:       7103fd1f        cmp     w8, #0xff     f0b4:       540006c1        b.ne    f18c   // b.any     f0b8:       38776929        ldrb    w9, [x9, x23]     f0bc:       94001a4a        bl      159e4     f0c0:       54000060        b.eq    f0cc   // b.none     f0c4:       7103fd1f        cmp     w8, #0xff     f0c8:       54000661        b.ne    f194   // b.any     f0cc:       f9000009        str     x9, [x0]         inode->i_ctime = dir->i_ctime = dir->i_mtime = current_time(inode);     f0d0:       aa1403e0        mov     x0, x20     f0d4:       910182b6        add     x22, x21, #0x60     f0d8:       94000000        bl      0     f0dc:       b2481ec9        orr     x9, x22, #0xff00000000000000     f0e0:       d344fd29        lsr     x9, x9, #4