Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp397498lqb; Fri, 24 May 2024 01:28:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX4TEwnryYOWgBTau3RR5LyWNFgdhr20Ghnw2f2/bjO3JHU2htco6Hb82mmdZWl/wrXFnDSIFpZkXe86mwl5rDyxFlMQSK7AG2fKgJGsQ== X-Google-Smtp-Source: AGHT+IE7Ugz73QS3orE52S9lz/GerTbKgYSIji9+tb83q2Zh87KGk8N8aZlhkUzv03GF4ccp7NZ+ X-Received: by 2002:a05:6a21:3405:b0:1af:e624:b9b2 with SMTP id adf61e73a8af0-1b212d2a900mr1782873637.19.1716539334944; Fri, 24 May 2024 01:28:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716539334; cv=pass; d=google.com; s=arc-20160816; b=0XmED/CO+2QYzTtt2iJFpWZyrqt/Z/vONhYgcptRITSUPWwCXoHYSpxV1x597sPWp9 OUZ5x/YwLgC8zTQEV3sgsxThCp7/6JC1cRP2GIXQZZWIkAcOqZLGqbQ/4YKujTieOJfe psb09auF96BQnQCRKvk2otK0TxrIi79r7Ss0IgP4eQ36/xTMnt2TMU8QWHydOCobb3rf zAEfhaYbjeg4ejFvW9rycMoxiW9Gpl2V3UlVly+aYGXCEljEL+OfsXIbAKTrH6H+OC+L OU+TAv2kvzMf8vFRQ9YWxAXotexJoesA7cqaDyvhRWSc6lhVaW/qmwmV1hYUaOJbtBUW K2cQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=q54jWehm6D0NKJU6RXOGEDssE+ymCHStnW0K2QTOJ1I=; fh=DNjN1MLVrXl/ihmaK4KaY4GXR2c13RoZdtfkwfzdSBc=; b=UvGXNZDjCi7jpuvo7qWByPlC6taPtp5oEQLexPVQNTwmbDjaKsLDsYMVWaCOSrVViD ByaswlY6UkYLWsdupAYmmAf6lRR7cajb99XF1/yJb7kisOxNTaKk4i1pM8cvsd9GxoEt fEDvXRWCEbu/DTzUGxflp6bBCR2RfTuttUgFbhyTcGYd+HqWkBhAd8vYOCrZYrG4PvZC LPB5NryXY74u4LaAWf9zNdYlqGI2YWhd4dUc8s7mT+Xg0p9FpI9Wud580vOkn/9xPLI7 EIivTCxmGIEshpwbad2KsUEloqoxpFTWV8ARaEjAGA0p88ONvSGgcsxTQSF9UqXfPP3Z I1kg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=H+pJCFuf; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-188463-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-188463-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1f44c78a337si9259725ad.106.2024.05.24.01.28.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 01:28:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-188463-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=@google.com header.s=20230601 header.b=H+pJCFuf; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-188463-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-188463-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 88C0A282ED6 for ; Fri, 24 May 2024 08:28:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 11D9812883C; Fri, 24 May 2024 08:28:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="H+pJCFuf" Received: from mail-qv1-f49.google.com (mail-qv1-f49.google.com [209.85.219.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D6D333A29C for ; Fri, 24 May 2024 08:28:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716539329; cv=none; b=mP6RVFoOCpAcBeAONutKcwFrua36kY/rOo+SCiB+uD+jCourf6JFd/bdJ9NPcfVyWbV0L0n+a2wfkqKK/zcj5VaEDoheZhXnH/iXKouHy9qb6uM93nEwyRXs/ITfT2kC8P373VNueM4KYG22EHLEsnkWKTyh16xgKst45CRqSyc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716539329; c=relaxed/simple; bh=q54jWehm6D0NKJU6RXOGEDssE+ymCHStnW0K2QTOJ1I=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=hYzi/qaHFqeI3g3O5LtQbz6a0nsKlYUGE6qKCfp92kqM9BcS+bQHkFD5SfX4Lg4bl2We8FXeHoJusm94qjBb8Ohctza99IMayY4tQgDFJhw0p4rhE+/coOMK+xlptmv3PemsDjPWElGBNrlD+hoX8EwQadHZg90+n0QlfW0armM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=H+pJCFuf; arc=none smtp.client-ip=209.85.219.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-qv1-f49.google.com with SMTP id 6a1803df08f44-6a919a4bb83so29434696d6.1 for ; Fri, 24 May 2024 01:28:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1716539327; x=1717144127; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=q54jWehm6D0NKJU6RXOGEDssE+ymCHStnW0K2QTOJ1I=; b=H+pJCFufBaRt+7nosz/HQkpL8/vzmCgAdkDpzwqlVbK0EGBfbEUt3XgpW7U4HEaoS0 9YTP9TU4FuxFUC4F11dSn5meNEFz7g41/gObKLlYxHLgLvmvPYfAeMk5POsybnFzpxH4 FrCHjg6eXxFJi+eWc52L9kwZh7oAiwVYalwhg6r4UF4MJb4Ia7iVbhBUPn64gE+whTdK yPkTwB1AZA8Spsl5FEqvgRKM8NmEv0j0G/bt47VUI0oSBYMoS8+w8Dkmp0XY5AHAHNqG x4KjtMpuW8iuO2L9c5Zlfwm3uM3auwWHdS+O8tmJXc3V6T2BOcZav/ml+g4zs5PYf9Pd UYYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716539327; x=1717144127; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=q54jWehm6D0NKJU6RXOGEDssE+ymCHStnW0K2QTOJ1I=; b=fmmIE9A4MrCBNr7Fvk5bM3rEFDd3i7bRVy5QZAfyFtLorE6JpmDpsJZGSzVUqC4L3R KJWkhzumuHes32hPDpF72IvjqVRhwVFlnrfqiikh5Ur39o2QQyCU//Xnw4g4yyk90wzU OD/Y2n8ddN7Hl5LMeQrBHXLFLGKPqOlynDXfvLP2zBYHTKLc+DTcb/dOrQB3IM4QhC0w AtL+aBDAeGF6zD3X8HqLxpnfHS7dMk45VzCmCZmLbhWhltJKhKNymca+XfLvMn0Zp78s 2HepFbfLoSqoTdJVVg6iRbtWtE86XHJILtMBJx7CSgDo1ydjsoOtQ0Mx+tUZSV0nIj0v e5vg== X-Forwarded-Encrypted: i=1; AJvYcCWGdURuLPCC8qt9/jJo4sGu1v/5vywom9xrBPnCrAAMtH5Y6WATWZktQIb5VbkVZrwearsCyZsaCx+eaoebJXLc3bhoW8UyRuCrTUQc X-Gm-Message-State: AOJu0YzbhzPSEPqZt9oXwGu8C5MhUDQNOw9DmD/DoqqGM6T22NN1ztss Ueb+oH+qWwX5dHC1fVMRP0Lrc47R2uCqLotXZM1WcDHo1UgL7mazkEm9kXDVYLcQHsBFC50OQeY w1gQDPdlm6nF57BfPWIzA/EQhAelV+jFsNPDA X-Received: by 2002:a05:6214:4a86:b0:6ab:710a:d84a with SMTP id 6a1803df08f44-6abc3e88e06mr16373676d6.23.1716539326544; Fri, 24 May 2024 01:28:46 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240523215029.4160518-1-bjohannesmeyer@gmail.com> In-Reply-To: <20240523215029.4160518-1-bjohannesmeyer@gmail.com> From: Alexander Potapenko Date: Fri, 24 May 2024 10:28:05 +0200 Message-ID: Subject: Re: [PATCH] x86: kmsan: Fix hook for unaligned accesses To: Brian Johannesmeyer Cc: Marco Elver , Dmitry Vyukov , Andrew Morton , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H . Peter Anvin" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, May 23, 2024 at 11:50=E2=80=AFPM Brian Johannesmeyer wrote: > > When called with a 'from' that is not 4-byte-aligned, > string_memcpy_fromio() calls the movs() macro to copy the first few bytes= , > so that 'from' becomes 4-byte-aligned before calling rep_movs(). This > movs() macro modifies 'to', and the subsequent line modifies 'n'. > > As a result, on unaligned accesses, kmsan_unpoison_memory() uses the > updated (aligned) values of 'to' and 'n'. Hence, it does not unpoison the > entire region. > > This patch saves the original values of 'to' and 'n', and passes those to > kmsan_unpoison_memory(), so that the entire region is unpoisoned. Nice catch! Does it fix any known bugs? > Signed-off-by: Brian Johannesmeyer Reviewed-by: Alexander Potapenko