Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6510817rdb; Thu, 14 Dec 2023 23:59:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IFkhnvlzJIPMBXv6ySJX2AJgGr7qtlPZCEydbDPKP/v+pL6Tu2HoAnDn1/gdCFBqNb/kqJs X-Received: by 2002:a0d:d452:0:b0:5e3:cd96:ce23 with SMTP id w79-20020a0dd452000000b005e3cd96ce23mr1628143ywd.99.1702627167034; Thu, 14 Dec 2023 23:59:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702627166; cv=none; d=google.com; s=arc-20160816; b=PrdseCz1JQvgE+0347lNprwrWKZAYEj01zZjHkJ05bWSf8iG3vnJ1MXQAekZY45cq8 gaEq9+jq7A4jQYVlty1wJEEQ6yQy4VpQxa5vov8FKNWQSZW1I+ecq5B7hjdWyjr7OGef j5vSxGeTHrrHUToxIlZjdDQE79JrXZrBq+rUFSBBuJhpBuMTk8VTHmWzKvZRdLePPhlO d7Hqrf3gHDj5tGU3AE14HU5HC3RnZMEppXjfhePJh/393CW5hKej+tlUCxfZwxzzSiNH UWO8t/SXGBGoq1Uh23HxWiSzUaQDzcigmPDYo+hTPyifDsGdw+kYKU4gHqzmmcpUoUhM lLTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=kS+KsCt9BfbC8mqWlYiyak+nsTKsd1LEGVX3pkRr5p8=; fh=OuvxDo77Do6uBLFUZ1NY/JZZXNK7wZvnurp88/rj1a0=; b=Mol+1Y1z2PLhwGYFwWjFk4LCJJSi29aNXTbD5jVEfMEG88pPWUbnLZ+X/CvNTuT7dO ISOSY7VhodlMhDCHEUuMy9+Z/WbFYdmAfbh6U/I6pi11/96dNhD2b4CF3TxBXMgSYHM5 K+VKs2KWp9IFUvgwlOWQJEmUG43p8mhQHa6N5yzKa7aHnl0tDccUE7rSpyemWdPaZLCk s3BGYjTSJ/MPRdDuxbI1xCEd3SQCSZMuIbNhTD9Qea4sEUGDkg3lFXWYqCvGyq26QT5Q 19X2jX0arf6qZSMVBTSacrWDn8iaUC9aCI66booUIXnKmTgzjpkfQ1zSJeglCTmy7H3a +iSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VWGGsr9g; spf=pass (google.com: domain of linux-kernel+bounces-570-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-570-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id f31-20020a63555f000000b005c625b9f61esi12203475pgm.779.2023.12.14.23.59.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 23:59:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-570-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VWGGsr9g; spf=pass (google.com: domain of linux-kernel+bounces-570-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-570-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id AE1E8280BDB for ; Fri, 15 Dec 2023 07:59:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A679B10A0E; Fri, 15 Dec 2023 07:59:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VWGGsr9g" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D8AB610948 for ; Fri, 15 Dec 2023 07:59:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7BE0AC433C7; Fri, 15 Dec 2023 07:59:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702627161; bh=p7XzuqMp9NhCrk0y1WItaCpAXO5MjmBMXA2NzZY47U4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=VWGGsr9gihUJo9sHqLqsalKs8SLfqSeu8K1zSrDQTHEwTZkdIAb8DT982rC4P3c9c pfXzw/eFxtDF6elSytfdaf9zBqwhWzjHqnW9aOwYyBmMw7UKaP23tMyfVkpdXhh4Fw xzIlsy2i2p8yh7u8GBjmvjgLn5RFk5trsyBwl6qbrFdqPdC/Pxjdn1O1WffR6WBdQP L9XJZjqTZjwamuppNlD5E5gzbBC8mm8V0jdz7FWbx+Bom2eD1saX08XbT/XEFXnV/w pEBrd5yZbwUrIJzFZaVCJ0vCv7p6snQvbVOUFsVgb8Zh5okjqbRz16XMNfbRB/eyb4 kMWZI3VZb2VWw== Date: Fri, 15 Dec 2023 13:21:44 +0530 From: Naveen N Rao To: Nicholas Miehlbradt Cc: glider@google.com, elver@google.com, dvyukov@google.com, akpm@linux-foundation.org, mpe@ellerman.id.au, npiggin@gmail.com, christophe.leroy@csgroup.eu, linux-mm@kvack.org, kasan-dev@googlegroups.com, iii@linux.ibm.com, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 07/13] powerpc/kprobes: Unpoison instruction in kprobe struct Message-ID: References: <20231214055539.9420-1-nicholas@linux.ibm.com> <20231214055539.9420-8-nicholas@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231214055539.9420-8-nicholas@linux.ibm.com> On Thu, Dec 14, 2023 at 05:55:33AM +0000, Nicholas Miehlbradt wrote: > KMSAN does not unpoison the ainsn field of a kprobe struct correctly. > Manually unpoison it to prevent false positives. > > Signed-off-by: Nicholas Miehlbradt > --- > arch/powerpc/kernel/kprobes.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c > index b20ee72e873a..1cbec54f2b6a 100644 > --- a/arch/powerpc/kernel/kprobes.c > +++ b/arch/powerpc/kernel/kprobes.c > @@ -27,6 +27,7 @@ > #include > #include > #include > +#include > > DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL; > DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk); > @@ -179,6 +180,7 @@ int arch_prepare_kprobe(struct kprobe *p) > > if (!ret) { > patch_instruction(p->ainsn.insn, insn); > + kmsan_unpoison_memory(p->ainsn.insn, sizeof(kprobe_opcode_t)); kprobe_opcode_t is u32, but we could be probing a prefixed instruction. You can pass the instruction length through ppc_inst_len(insn). - Naveen