Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3859748ybl; Mon, 26 Aug 2019 01:30:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqxMM5qgPuk/juFRcM1xDKjKqzG4WgTVHNO+sms5JAXZ9VosRzWKCFDOQ/u3CxV2Bz0SjX5U X-Received: by 2002:a17:90a:5d0d:: with SMTP id s13mr16081857pji.133.1566808255018; Mon, 26 Aug 2019 01:30:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566808255; cv=none; d=google.com; s=arc-20160816; b=sZbDz+qOTX9IpiUUSZNvOCa8kVC9KHgIwf0R+PWUjIG1aJpeqgiaQEx+qha+2Uzsgt 0f2KjfLt+hnwurdUVV0efKbvX/puq3ne8u7f5AibdoA4f4pBJCDb3RlSIGu3Xuw8dXus 1BMMNLCiJnHAsqJqH206WAW0Fea1P6+75Blb53o61oIvQXquGttMx6xneEHXMca0WTvd enNnOO/7VvNxhoJofIBd3eqmkGvyD20hmK0qpBn8v7+h6a85/I3IB02sw3Oj8qAVPBpW 4fmwb/9Znwd9fe6zo5xwnOAAmaj/VujOvegSQpEb1M634TA6qnz6/ZsTQ4EQgNS2eMxc aRBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :user-agent:mime-version:in-reply-to:references:cc:to:subject:from :date; bh=RyL5L7d/SH2PoxR0cQ2vEWmZLOMNZtpLurCAMhLwwUY=; b=Qfs5s70B+3bwghLkTHNEToEtBpSnLUhHq9tegPw1bfAmYQXdBnsD5gPvryn9cWKJc8 jh0EVRRilAEowjiXzJivJka974JCYDomKQNvhjyzh8L6UnemdA9aACYSX/S48k/4LqXH p7K0uLpuzWp8LJYRkUMzgyHKnW0zF995hPHFbnj8Y7VwC48s28A9vwRpvF1KE369MoBs Ce3e4eMCN9I9Se4W98E7W6P0zJ6Ru2kNpiG15/3cIBrq4miPln85SjmH0PQuvGyvlzzB BRhJu1tQXeTmVEPH25m33Lhz/Ti83NTPcT2dZJTCS+XQUN6QfBC7sUCUCywiHhZVY3hx qnHg== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g5si8538956pgs.414.2019.08.26.01.30.39; Mon, 26 Aug 2019 01:30:54 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729782AbfHZG7S convert rfc822-to-8bit (ORCPT + 99 others); Mon, 26 Aug 2019 02:59:18 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:2224 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729487AbfHZG7P (ORCPT ); Mon, 26 Aug 2019 02:59:15 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x7Q6vpOr025879 for ; Mon, 26 Aug 2019 02:59:13 -0400 Received: from e06smtp01.uk.ibm.com (e06smtp01.uk.ibm.com [195.75.94.97]) by mx0a-001b2d01.pphosted.com with ESMTP id 2um7ewwk38-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 26 Aug 2019 02:59:13 -0400 Received: from localhost by e06smtp01.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 26 Aug 2019 07:59:11 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp01.uk.ibm.com (192.168.101.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 26 Aug 2019 07:59:09 +0100 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x7Q6x8gc37028070 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Aug 2019 06:59:08 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 31AD1A4059; Mon, 26 Aug 2019 06:59:08 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DCBD5A405B; Mon, 26 Aug 2019 06:59:07 +0000 (GMT) Received: from localhost (unknown [9.124.35.18]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 26 Aug 2019 06:59:07 +0000 (GMT) Date: Mon, 26 Aug 2019 12:29:05 +0530 From: "Naveen N. Rao" Subject: Re: [PATCH] bpf: handle 32-bit zext during constant blinding To: Jiong Wang , Alexei Starovoitov , Daniel Borkmann Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Michael Ellerman , netdev@vger.kernel.org References: <20190821192358.31922-1-naveen.n.rao@linux.vnet.ibm.com> <87zhk2faqg.fsf@netronome.com> In-Reply-To: <87zhk2faqg.fsf@netronome.com> MIME-Version: 1.0 User-Agent: astroid/0.15.0 (https://github.com/astroidmail/astroid) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8BIT X-TM-AS-GCONF: 00 x-cbid: 19082606-4275-0000-0000-0000035D680B X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19082606-4276-0000-0000-0000386F9425 Message-Id: <1566802541.7onbueyw0d.naveen@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-08-26_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908260077 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Jiong Wang wrote: > > Naveen N. Rao writes: > >> Since BPF constant blinding is performed after the verifier pass, the >> ALU32 instructions inserted for doubleword immediate loads don't have a >> corresponding zext instruction. 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 > > Thanks for the fix. > > Reviewed-by: Jiong Wang > > Just two other comments during review in case I am wrong on somewhere. > > - Use verifier_zext instead of bpf_jit_needs_zext() seems better, even > though the latter could avoid extending function argument. > > Because JIT back-ends look at verifier_zext, true means zext inserted > by verifier so JITs won't do the code-gen. > > Use verifier_zext is sort of keeping JIT blinding the same behaviour > has verifier even though blinding doesn't belong to verifier, but for > such insn patching, it could be seen as a extension of verifier, > therefore use verifier_zext seems better than bpf_jit_needs_zext() to > me. > > - JIT blinding is also escaping the HI32 randomization which happens > inside verifier, otherwise x86-64 regression should have caught this issue. Jiong, Thanks for the review. Alexei, Daniel, Can you please pick this up for v5.3. This is a regression and is causing a crash on powerpc. - Naveen