Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3802265ybi; Mon, 29 Jul 2019 12:55:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqwDWG2W9Z4Io08YZjtZ4W/xqqau2mEt9yxUzR49+BLQQ4v/Hyy8CSMMSFWsqTVYwPGwQUv3 X-Received: by 2002:a65:68c9:: with SMTP id k9mr72592067pgt.17.1564430153993; Mon, 29 Jul 2019 12:55:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564430153; cv=none; d=google.com; s=arc-20160816; b=PRU+xmeb1I2Uu0l297omKt8grP+l9qnoCV2uV7jqO8JDTRQ+RdCLYs8/cX3VDv6EHR 0UVpGLxfKBpuFniZJIDbTtC4Lsv0mjVT4c5xIIvcu/7Co3eN84O9FrkhS7OzW5+akvF3 ms3kj+lBqzVGEGvpi8QNSGikvNTh2XeuysjdDQ7udp5PRD9bHZOm3Hw6KNp7/V17p+T7 0z+eWL9anoZeD19IFxoCoo86uEosmLWK1mTY0kv1Y8YyjsZrWJA+HWsV0mgtImruYff3 Q3Q4h/1A706HifORiOubEAVPECN1GBTm9E4/nbRgC2/QFfVrxCIvOcni9PxU4jQeQDqL wkFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=rV0BWhQpsymsk2lEuHqJ9KSwMlz9Mxa6d2ZW8W/Vkn8=; b=IjHeL6lHP3DupZeblZTx7dbh5dONr1EsNzkcu/5nziHmNSBR+Lzg812/bITCdrDdwQ vbT7dviunP7smbJlyMboNbllr46EDaht7meV/q3a/qgFR00M/Ijwbr+XKNCIeZ64gMKy aVypsi7+oWB51wcQcCttksVeojm9xsLUnffyr92pfVsE4dSijpJnb9DwhfJzDsIWwMaF CQXnVJw4dz0CJSS+TR5FEZXSgw5s9I+8knQwCmqlFiZb3UPidqlgbzf1llnixt66ZoFc UDC+oRHNMosbawmLTrXQCX1Mr4fFwwaznFPs7qB+rK6GBza/vSfpirwrdJ9EP2ZtOlsy ahgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="uoPegt/e"; 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 p35si27349516pgb.484.2019.07.29.12.55.38; Mon, 29 Jul 2019 12:55:53 -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=@kernel.org header.s=default header.b="uoPegt/e"; 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 S2404059AbfG2Tya (ORCPT + 99 others); Mon, 29 Jul 2019 15:54:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:46996 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390733AbfG2TyU (ORCPT ); Mon, 29 Jul 2019 15:54:20 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B8A5E21655; Mon, 29 Jul 2019 19:54:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564430060; bh=n6R0gcYCZXGZoQwAw6Op0fgmjeV8rEY30bF0MOUNEQk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uoPegt/eW+KezImSpriYL+1Fv6R1v/T3rLO274BQJccIWtZhy0emhGxUcrWH5hAJN Th/LMofQ8SoADUxdAIzWhq1RJxBOAOfuQEq+asA5AD1fmaAQqSbmyz0JFd6rliT4ID liUAElfC8rMT81IfLAQVhtX07v0U+QeB6W0U5tqA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Juri Lelli , Eiichi Tsukata , Thomas Gleixner Subject: [PATCH 5.2 183/215] x86/stacktrace: Prevent access_ok() warnings in arch_stack_walk_user() Date: Mon, 29 Jul 2019 21:22:59 +0200 Message-Id: <20190729190811.906620918@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190739.971253303@linuxfoundation.org> References: <20190729190739.971253303@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eiichi Tsukata commit 2af7c85714d8cafadf925d55441458eae312cd6b upstream. When arch_stack_walk_user() is called from atomic contexts, access_ok() can trigger the following warning if compiled with CONFIG_DEBUG_ATOMIC_SLEEP=y. Reproducer: // CONFIG_DEBUG_ATOMIC_SLEEP=y # cd /sys/kernel/debug/tracing # echo 1 > options/userstacktrace # echo 1 > events/irq/irq_handler_entry/enable WARNING: CPU: 0 PID: 2649 at arch/x86/kernel/stacktrace.c:103 arch_stack_walk_user+0x6e/0xf6 CPU: 0 PID: 2649 Comm: bash Not tainted 5.3.0-rc1+ #99 RIP: 0010:arch_stack_walk_user+0x6e/0xf6 Call Trace: stack_trace_save_user+0x10a/0x16d trace_buffer_unlock_commit_regs+0x185/0x240 trace_event_buffer_commit+0xec/0x330 trace_event_raw_event_irq_handler_entry+0x159/0x1e0 __handle_irq_event_percpu+0x22d/0x440 handle_irq_event_percpu+0x70/0x100 handle_irq_event+0x5a/0x8b handle_edge_irq+0x12f/0x3f0 handle_irq+0x34/0x40 do_IRQ+0xa6/0x1f0 common_interrupt+0xf/0xf Fix it by calling __range_not_ok() directly instead of access_ok() as copy_from_user_nmi() does. This is fine here because the actual copy is inside a pagefault disabled region. Reported-by: Juri Lelli Signed-off-by: Eiichi Tsukata Signed-off-by: Thomas Gleixner Link: https://lkml.kernel.org/r/20190722083216.16192-2-devel@etsukata.com Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/stacktrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/x86/kernel/stacktrace.c +++ b/arch/x86/kernel/stacktrace.c @@ -100,7 +100,7 @@ copy_stack_frame(const void __user *fp, { int ret; - if (!access_ok(fp, sizeof(*frame))) + if (__range_not_ok(fp, sizeof(*frame), TASK_SIZE)) return 0; ret = 1;