Message ID | 20191122112621.204798-30-glider@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <SRS0=DNi/=ZO=kvack.org=owner-linux-mm@kernel.org> Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5188414DB for <patchwork-linux-mm@patchwork.kernel.org>; Fri, 22 Nov 2019 11:28:00 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1DF3C20674 for <patchwork-linux-mm@patchwork.kernel.org>; Fri, 22 Nov 2019 11:28:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Af9aH6WE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1DF3C20674 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 72BF36B04F7; Fri, 22 Nov 2019 06:27:58 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6DBB36B04F9; Fri, 22 Nov 2019 06:27:58 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5F2866B04FA; Fri, 22 Nov 2019 06:27:58 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0141.hostedemail.com [216.40.44.141]) by kanga.kvack.org (Postfix) with ESMTP id 4A6796B04F7 for <linux-mm@kvack.org>; Fri, 22 Nov 2019 06:27:58 -0500 (EST) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id 0EACB181AEF30 for <linux-mm@kvack.org>; Fri, 22 Nov 2019 11:27:58 +0000 (UTC) X-FDA: 76183689036.14.war89_b4be756c3443 X-Spam-Summary: 2,0,0,130738caffd68c26,d41d8cd98f00b204,3pmbxxqykcb09eb67k9hh9e7.5hfebgnq-ffdo35d.hk9@flex--glider.bounces.google.com,:akpm@linux-foundation.org:axboe@kernel.dk:tytso@mit.edu:dmitry.torokhov@gmail.com:martin.petersen@oracle.com:mst@redhat.com:hch@lst.de:edumazet@google.com:ericvh@gmail.com:tiwai@suse.com:vegard.nossum@oracle.com:dvyukov@google.com:willy@infradead.org::glider@google.com:viro@zeniv.linux.org.uk:adilger.kernel@dilger.ca:andreyknvl@google.com:aryabinin@virtuozzo.com:luto@kernel.org:ard.biesheuvel@linaro.org:arnd@arndb.de:hch@infradead.org:darrick.wong@oracle.com:davem@davemloft.net:ebiggers@google.com:gregkh@linuxfoundation.org:harry.wentland@amd.com:herbert@gondor.apana.org.au:iii@linux.ibm.com:mingo@elte.hu:jasowang@redhat.com:m.szyprowski@samsung.com:elver@google.com:mark.rutland@arm.com:schwidefsky@de.ibm.com:monstr@monstr.eu:pmladek@suse.com:cai@lca.pw:rdunlap@infradead.org:robin.murphy@arm.com:sergey.senozhatsky@gmail.com:rostedt@goodmis.org :tglx@li X-HE-Tag: war89_b4be756c3443 X-Filterd-Recvd-Size: 5745 Received: from mail-qk1-f201.google.com (mail-qk1-f201.google.com [209.85.222.201]) by imf42.hostedemail.com (Postfix) with ESMTP for <linux-mm@kvack.org>; Fri, 22 Nov 2019 11:27:57 +0000 (UTC) Received: by mail-qk1-f201.google.com with SMTP id o184so3148904qkf.14 for <linux-mm@kvack.org>; Fri, 22 Nov 2019 03:27:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=jBaXXUPeySZWzgssX3OEiSTrQlVNNEmfCQp9qjzrNgs=; b=Af9aH6WEMPP3eNpJ08BJ9nMVI8jJeWrYIySsr3aa1Inq43jWn3dZy66jPcZr8eVwj7 OlYtCRuwMNxfxJaMLHjm8C1wav29mlOa1dLaP8aX1u+/xj2X6GPCuREubSuO0DlMy5yQ 5fijHBTEEkmSmgAjDAohVRHAbdFQ0kuU8fI6LXs4o4wOWDKAIn2wYobYfqOszqOsWw2L XGHAVMmQy8//MCxteFxwKaJuwH8CNlduMe7cwhH2mNjXabgWM5WUKoajLMHeQkjrSyr/ Wnjs6OsoLQkkcbI98zixK+ARNcq+Wu1mujOh5GXTBkHIJS+pF8hGmHzATJYbZgKZ0lN4 GclQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=jBaXXUPeySZWzgssX3OEiSTrQlVNNEmfCQp9qjzrNgs=; b=FJA0CrlnAH69g7cA6c5YIXPnjBhmoIcKwjHiYN5rqfluDLmTtPoYcT4AE0ST73lc+u 78gTQu6wL+4jI+opFg7c8gFdxSAV0H5PHkcYmIbC/CtOqGBzr3m27BHShHJUD/4qZiBi erlro/s+VKQl7qcJoTmD9OShQAdSpqwebTQNNLgENJM44xQXpK328Mcl2LbRIxKWgUM+ z2zJaW87ZPIno3r5pfQiYdjdpVnikYzCQsObCKBxHXAOBuBBFF4j5CyqMNjRq5su/yAo cecW6oX5TtWciEUYNei6R0srjIyKRN/6tpiycMHG1JK8FhLzZ48KoonoJ828VJw5535D eMgw== X-Gm-Message-State: APjAAAUH1KStyhtFnFYLstYRfhRVd5T4YZieRJYK7CAgoZpaorDw5hzz 97i8A62bvS3mLxcL2QYJJX6i3cJ0lRI= X-Google-Smtp-Source: APXvYqyekH6lBwzi+YYml5Q4+yBUVHJNXEr7EDDK8BUj/sidDZSb9Z5OHoOEEx3e2P/oUecn90p8yr6H2hU= X-Received: by 2002:a37:6d41:: with SMTP id i62mr1267469qkc.211.1574422076772; Fri, 22 Nov 2019 03:27:56 -0800 (PST) Date: Fri, 22 Nov 2019 12:26:14 +0100 In-Reply-To: <20191122112621.204798-1-glider@google.com> Message-Id: <20191122112621.204798-30-glider@google.com> Mime-Version: 1.0 References: <20191122112621.204798-1-glider@google.com> X-Mailer: git-send-email 2.24.0.432.g9d3f5f5b63-goog Subject: [PATCH RFC v3 29/36] kmsan: handle /dev/[u]random From: glider@google.com To: Andrew Morton <akpm@linux-foundation.org>, Jens Axboe <axboe@kernel.dk>, "Theodore Ts'o" <tytso@mit.edu>, Dmitry Torokhov <dmitry.torokhov@gmail.com>, "Martin K. Petersen" <martin.petersen@oracle.com>, "Michael S. Tsirkin" <mst@redhat.com>, Christoph Hellwig <hch@lst.de>, Eric Dumazet <edumazet@google.com>, Eric Van Hensbergen <ericvh@gmail.com>, Takashi Iwai <tiwai@suse.com>, Vegard Nossum <vegard.nossum@oracle.com>, Dmitry Vyukov <dvyukov@google.com>, Matthew Wilcox <willy@infradead.org>, linux-mm@kvack.org Cc: glider@google.com, viro@zeniv.linux.org.uk, adilger.kernel@dilger.ca, andreyknvl@google.com, aryabinin@virtuozzo.com, luto@kernel.org, ard.biesheuvel@linaro.org, arnd@arndb.de, hch@infradead.org, darrick.wong@oracle.com, davem@davemloft.net, ebiggers@google.com, gregkh@linuxfoundation.org, harry.wentland@amd.com, herbert@gondor.apana.org.au, iii@linux.ibm.com, mingo@elte.hu, jasowang@redhat.com, m.szyprowski@samsung.com, elver@google.com, mark.rutland@arm.com, schwidefsky@de.ibm.com, monstr@monstr.eu, pmladek@suse.com, cai@lca.pw, rdunlap@infradead.org, robin.murphy@arm.com, sergey.senozhatsky@gmail.com, rostedt@goodmis.org, tglx@linutronix.de, gor@linux.ibm.com, wsa@the-dreams.de Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> |
Series |
Add KernelMemorySanitizer infrastructure
|
expand
|
diff --git a/drivers/char/random.c b/drivers/char/random.c index de434feb873a..9b1639c73b65 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -320,6 +320,7 @@ #include <linux/fs.h> #include <linux/genhd.h> #include <linux/interrupt.h> +#include <linux/kmsan-checks.h> #include <linux/mm.h> #include <linux/nodemask.h> #include <linux/spinlock.h> @@ -1061,6 +1062,11 @@ static void _extract_crng(struct crng_state *crng, spin_lock_irqsave(&crng->lock, flags); if (arch_get_random_long(&v)) crng->state[14] ^= v; + /* + * Regardless of where the random data comes from, KMSAN should treat + * it as initialized. + */ + kmsan_unpoison_shadow(crng->state, sizeof(crng->state)); chacha20_block(&crng->state[0], out); if (crng->state[12] == 0) crng->state[13]++;
The random number generator may use uninitialized memory, but it may not return uninitialized values. Unpoison the output buffer in _extract_crng() to prevent false reports. Signed-off-by: Alexander Potapenko <glider@google.com> To: Alexander Potapenko <glider@google.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Jens Axboe <axboe@kernel.dk> Cc: "Theodore Ts'o" <tytso@mit.edu> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com> Cc: Martin K. Petersen <martin.petersen@oracle.com> Cc: "Michael S. Tsirkin" <mst@redhat.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Eric Dumazet <edumazet@google.com> Cc: Eric Van Hensbergen <ericvh@gmail.com> Cc: Takashi Iwai <tiwai@suse.com> Cc: Vegard Nossum <vegard.nossum@oracle.com> Cc: Dmitry Vyukov <dvyukov@google.com> Cc: Matthew Wilcox <willy@infradead.org> Cc: linux-mm@kvack.org --- This patch was previously known as "kmsan: unpoisoning buffers from devices etc.", but it turned out to be possible to drop most of the annotations from that patch, so it only relates to /dev/random now. Change-Id: Id460e7a86ce564f1357469f53d0c7410ca08f0e9 --- drivers/char/random.c | 6 ++++++ 1 file changed, 6 insertions(+)