Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp581074ybl; Wed, 21 Aug 2019 02:15:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqyoD9WuKls7bJdDwWG4mueCsfAnEugj5+ymMhg25wFvZCnMXqHbc3Ub4EVO8dnaYaDIupb1 X-Received: by 2002:a17:902:26b:: with SMTP id 98mr10197057plc.61.1566378952783; Wed, 21 Aug 2019 02:15:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566378952; cv=none; d=google.com; s=arc-20160816; b=fqf7eKQ+r/jR/YeTXmhbmz9OakilfZV5VTxH9GFTlqcEWn8GnKtDlvHuYdlH4B7Ut/ F8/qb7ZxukQEcFSyTTjqtq8pdLpEwW634LDgpHsrrhipidD6DSu7VFgf34gvLmFDOH9Q y7vgUbZoAv7L3C7JWgDHwqier9367RDFhV+nN7mjspSJISSSWZ0TSv/CTBaAZda1ITjX LraZxEp/wUMWTro4F9x+KC5EOXs8n4n/KiuD00SjbITIuczQD4blkqn8Nx9Bg1rzjPHe buAdVhQ3+/waHrvDARQai8A0CgtBHPQVCXbNPKo3gYu3fyp6bSz33NXDcI79zSGCEUEq 72wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:in-reply-to :subject:cc:to:from:user-agent:references:dkim-signature; bh=fQeTw8XVpz3MXJ+9QKUltKbufjCfYbnuGVJHHdsUDLI=; b=LH7VTJO/8SywH/CK/5j0+ub2Fn9doxfaHi3lP7jL9y9uwdLAiRff+OiKHoEmyPEnea /D2KZLO2wiLZ3ltJ+Oz+wC5jOzNIEwGJDW5W+pXwkIPv+4RyInIKUDuEouE30/ScEQ/9 jX892BDESDP3mGSHU0Vrnht7SFx/rd7lssAN3q9WlKZoiGvcUXBaT/ZyfLYaPalOM0Mj UVFrfvDwD9C5gaycRe/2bM5SVhP76hcCvGiktkA6ZUcvB2xrrzh5OAXTR2z8pLm938fj E0EPJkd44DoHia679BlwEmOtLuYuq/qERB8uKp8PX8MTYBa6igd5HGWQD83dZwYTal7N np6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@netronome-com.20150623.gappssmtp.com header.s=20150623 header.b=eN2sJxBY; 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 g17si5831290plj.399.2019.08.21.02.15.37; Wed, 21 Aug 2019 02:15:52 -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=@netronome-com.20150623.gappssmtp.com header.s=20150623 header.b=eN2sJxBY; 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 S1726953AbfHUJF5 (ORCPT + 99 others); Wed, 21 Aug 2019 05:05:57 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:40609 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726425AbfHUJF5 (ORCPT ); Wed, 21 Aug 2019 05:05:57 -0400 Received: by mail-wr1-f65.google.com with SMTP id c3so1259267wrd.7 for ; Wed, 21 Aug 2019 02:05:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=references:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version; bh=fQeTw8XVpz3MXJ+9QKUltKbufjCfYbnuGVJHHdsUDLI=; b=eN2sJxBYytWmV3/n076E7pwNxHyBqPih6k1yaMTSgWesLfORTfAQd/TyGk2BSf6eDw OTh9CSsPjuOfOv+ZYebNkiivlWNXMt3AWrscTv4UmcqfK3bvUEiI9sjHdDpJ5U1JrXtG PVfMJKDMCk7WSQ0dnvEFFQiJS+Rwz3XRCMLCflYtp7yecqs+fBoJ9udb+dMYH7Ka9+VE iaBGNJmfnZSOqQVqUEKnIQjlYppxz9AotT+CDtLRDn5JYGqQy9GibuJ8n/zwK3KZoy+1 yFN/6kJyjNUE/X4QgWakwmg3FJEgjx8TyiP/2HLaWHDxdIRt39KUcrClx9ExN44FOYAj sQDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:date:message-id:mime-version; bh=fQeTw8XVpz3MXJ+9QKUltKbufjCfYbnuGVJHHdsUDLI=; b=dtc/ukLplEjvnLQ9X0PeO9uoBLBv+5Qdh1dv1kaBDVHaISmbfpbOStKZQCJQr0I1qW O6FG8EEo831txiEerMCyQnBEmQQU4WJDB8q81j/SomsGGtyTaCM6+VmV6Is40HJcRTfp ai2mTDfJi1exMfyaKVdIEa8wi2j+JXON+dVk3LIMFHoLzH5rqq8Roru4c8fbZcU6yt8I j37ttu/c4wOZWrhyW4s451hNxoEGIpV3FatYx1X/aHFU/zjeWuln0gJuJn1YNndwnr4r B0aCud0Gt00KW32AFdKZyZo7YMBF8dRBIQAvSYGsU5IhwxQIK3SJ067UqSDmMZwNUYXd 0LEg== X-Gm-Message-State: APjAAAVOctxaf2uqbN3yqyoNIox/zzV8gpRvozg6CKkT+U/U+MLwgw+h hk+sj8YBrUPmmKFh1kT/aSQ7rg== X-Received: by 2002:adf:ed4a:: with SMTP id u10mr14236353wro.284.1566378355151; Wed, 21 Aug 2019 02:05:55 -0700 (PDT) Received: from LAPTOP-V3S7NLPL ([217.38.71.146]) by smtp.gmail.com with ESMTPSA id 91sm64065796wrp.3.2019.08.21.02.05.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Aug 2019 02:05:54 -0700 (PDT) References: <20190813171018.28221-1-naveen.n.rao@linux.vnet.ibm.com> <1566376025.68ldwx3wc7.naveen@linux.ibm.com> User-agent: mu4e 0.9.18; emacs 25.2.2 From: Jiong Wang To: "Naveen N. Rao" Cc: Alexei Starovoitov , Daniel Borkmann , Jiong Wang , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Michael Ellerman , netdev@vger.kernel.org Subject: Re: [RFC PATCH] bpf: handle 32-bit zext during constant blinding In-reply-to: <1566376025.68ldwx3wc7.naveen@linux.ibm.com> Date: Wed, 21 Aug 2019 10:05:53 +0100 Message-ID: <87y2zmubv2.fsf@netronome.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Naveen N. Rao writes: > Naveen N. Rao wrote: >> Since BPF constant blinding is performed after the verifier pass, there >> are certain ALU32 instructions inserted which don't have a corresponding >> zext instruction inserted after. This is causing a kernel oops on >> powerpc and can be reproduced by running 'test_cgroup_storage' with >> bpf_jit_harden=2. >> >> Fix this by emitting BPF_ZEXT during constant blinding if >> prog->aux->verifier_zext is set. >> >> Fixes: a4b1d3c1ddf6cb ("bpf: verifier: insert zero extension according to analysis result") >> Reported-by: Michael Ellerman >> Signed-off-by: Naveen N. Rao >> --- >> This approach (the location where zext is being introduced below, in >> particular) works for powerpc, but I am not entirely sure if this is >> sufficient for other architectures as well. This is broken on v5.3-rc4. > > Alexie, Daniel, Jiong, > Any feedback on this? The fix on BPF_LD | BPF_IMM | BPF_DW looks correct to me, but the two other places looks to me is unnecessary, as those destinations are exposed to external and if they are used as 64-bit then there will be zext inserted for them. Have you verified removing those two fixes will still cause the bug? Regards, Jiong > > - Naveen