From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A55BC433F5 for ; Tue, 16 Nov 2021 08:02:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3700361C14 for ; Tue, 16 Nov 2021 08:02:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3700361C14 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 9CEE06B0096; Tue, 16 Nov 2021 03:02:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 97EF16B0098; Tue, 16 Nov 2021 03:02:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 847706B0099; Tue, 16 Nov 2021 03:02:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0129.hostedemail.com [216.40.44.129]) by kanga.kvack.org (Postfix) with ESMTP id 76A706B0096 for ; Tue, 16 Nov 2021 03:02:46 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 3284D86994 for ; Tue, 16 Nov 2021 08:02:46 +0000 (UTC) X-FDA: 78814051932.09.E0EA91A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf22.hostedemail.com (Postfix) with ESMTP id A92621919 for ; Tue, 16 Nov 2021 08:02:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637049755; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LCSrynp2laCG1R5XEbg3KqtinIS3fppXUc3OoVzsOks=; b=G7gljdma5ojE2wOjnRpUf8jL2V0t+Pu9Q+0a0wZRt/Mtibzy3BGzeQJqkKbBfsVZhHpJ8+ oTnHP00jtYUX9cudhvTHb5MQksy8ibbYM4PfRGaGpFNAYAcNjGIiNSpLcpVOKcuuZjpIsS OB9OiZywpMVVHYN2g21PqVUSYQ4bTPE= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-448-_kIWRKBXMTKX03vjej3f8Q-1; Tue, 16 Nov 2021 03:02:34 -0500 X-MC-Unique: _kIWRKBXMTKX03vjej3f8Q-1 Received: by mail-wm1-f71.google.com with SMTP id 69-20020a1c0148000000b0033214e5b021so7009747wmb.3 for ; Tue, 16 Nov 2021 00:02:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=LCSrynp2laCG1R5XEbg3KqtinIS3fppXUc3OoVzsOks=; b=jqI2eJ51NwWGgqmzoBRSYUxUDeSeFGZfyc2WIqLRA0wvX0jdCCH5W5Kp7mJNzm3ZD6 hpBqj7Vug60Y5hlWrMl/aQDl0pYiumKiwqOrun+RAZFaZv6fAToXoEsewcgiWs45wfjt dGQzvr0zEXU7zlmjwosAfTG5ydwfcSgE2V0EMxZN8JBHsnX+VezCeJL20WwpoDVHKq+W 3fmBAEPb7xjs2rKkNSX71Vwf0np2s1oNmlTyhtXxaIwvV3CqYUrEjiHYrSzfFmU8Tgu3 XEtXOlPo0Qbsz4V0DFI6v1RetnE/iN0ISaSzxLhXCcrm7PYq2Jjg5+MaSjJ3v6OcqqsB WMyw== X-Gm-Message-State: AOAM533pOiumFSXqH7pVb8jtqnJyJSXZLycH4soreeXUw9iWbake1bDX sNdBTo5+KCnjekHIKCM55mDpXUBWn1wF/cQf9XkRCSgtQn1jFrlMxCGKE9C5LVnKx44VStGRu17 9SN+HZQW7cpQ= X-Received: by 2002:a5d:6a4d:: with SMTP id t13mr6954084wrw.104.1637049753028; Tue, 16 Nov 2021 00:02:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJx6Utf7cFwIqmSHQp5zkqSecC4ZA2odmOYlZZgrRcZkRsT04uEEng/kHgOkrk3tTuv1xPPHkQ== X-Received: by 2002:a5d:6a4d:: with SMTP id t13mr6954047wrw.104.1637049752784; Tue, 16 Nov 2021 00:02:32 -0800 (PST) Received: from [192.168.3.132] (p4ff23d3a.dip0.t-ipconnect.de. [79.242.61.58]) by smtp.gmail.com with ESMTPSA id m20sm1745208wmq.11.2021.11.16.00.02.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 16 Nov 2021 00:02:32 -0800 (PST) Message-ID: <4289b936-e40c-cde8-eb08-0bd13c44eba3@redhat.com> Date: Tue, 16 Nov 2021 09:02:31 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: [PATCH v2] proc/vmcore: fix clearing user buffer by properly using clear_user() To: Andrew Morton Cc: linux-kernel@vger.kernel.org, Baoquan He , Dave Young , Vivek Goyal , Philipp Rudo , kexec@lists.infradead.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org References: <20211112092750.6921-1-david@redhat.com> <20211115140444.bca2b88cfdd992760a413442@linux-foundation.org> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20211115140444.bca2b88cfdd992760a413442@linux-foundation.org> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-HE-Tag: 1637049756-841373 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: On 15.11.21 23:04, Andrew Morton wrote: > On Fri, 12 Nov 2021 10:27:50 +0100 David Hildenbrand wrote: > >> To clear a user buffer we cannot simply use memset, we have to use >> clear_user(). With a virtio-mem device that registers a vmcore_cb and has >> some logically unplugged memory inside an added Linux memory block, I can >> easily trigger a BUG by copying the vmcore via "cp": >> >> ... >> >> Some x86-64 CPUs have a CPU feature called "Supervisor Mode Access >> Prevention (SMAP)", which is used to detect wrong access from the kernel to >> user buffers like this: SMAP triggers a permissions violation on wrong >> access. In the x86-64 variant of clear_user(), SMAP is properly >> handled via clac()+stac(). >> >> To fix, properly use clear_user() when we're dealing with a user buffer. >> > > I added cc:stable, OK? > I was a bit hesitant because this would (beofe the virtio-mem changes) only trigger under XEN and I was wondering why nobody notices under XEN so far. But yes, even though it only applies to the kdump kernel, cc:stable sounds like the right think to do! Thanks Andrew! -- Thanks, David / dhildenb