Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp200690imm; Wed, 12 Sep 2018 21:25:30 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda1KIk1Uj2ZwfIbk7z1iHDsMSAOWYEj4E+/rtGGLgJ0SwSkbLiDzj7BqyH405+a7GYPZelv X-Received: by 2002:a17:902:9696:: with SMTP id n22-v6mr5415662plp.212.1536812730294; Wed, 12 Sep 2018 21:25:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536812730; cv=none; d=google.com; s=arc-20160816; b=JKrQxBnPcgTme24uBHihEs3ztvlbJ6YPFqJGc5bJx3VBMw/N3/kqhbh0NLLfiA2aKB 7142JhdL4yXxx2wEUJPog17MF4JnUUFxIqgi+zn8ZsVIUyHtPXhKPiDedoqDqAMobOnL WIHT363+L4M0hF5mmNstZj54FckH/D/wPlEnC15L8Pi5jgM0Zlbdfl0MzRjKtT8uLDNy 98i0J+BMlCcCY+b2nlEWpsfDo0QDGMpv7pTreqbMvpRqub38YjCR58aDujem4yBG+IuU NdYOegCSjwLIDpRyVbtl1HhWHrvDIc0WRm4IQm0XTJOkn5pxPYm6abcoBTaFk9UVq7hs FSpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature; bh=7oaRrgCH8FMgYqgf5wQKl/zFZfk1zkIZLePlt6j1oKI=; b=rG9AQVlXoVN33acBSJQDt7wW1KWdA+GcjfVe3SmuCQxqn3+fmFmp/9kagrXMPAlS6s HCjrBSOFDgoC9BVT2CgOtOlzY+8jBv+GGXIwNcgox/6LoKSv2KBphq63mLxvSNrijxGf QqAwl3Cv6izwK8HmcGIil9eynjlocs0O/kpxeuI/bqGH7mEv/qFo8muOQ7SXK0ZL83+m VC77iPb9TkIxyWhkzIwexitGOAG5DwxJp6KMSPqkOTeYY3owIYtniv7vfhwSfyrHVJpt p1Yy2KILuAsSgW3lIi9nMm8LIsHFHO5zOSEVO0Rb4mR0tEVlK7KWXrn8pi3sLROaGfCy akQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Dmm8w90a; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p12-v6si3054220pls.53.2018.09.12.21.25.14; Wed, 12 Sep 2018 21:25:30 -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=@chromium.org header.s=google header.b=Dmm8w90a; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726932AbeIMJcv (ORCPT + 99 others); Thu, 13 Sep 2018 05:32:51 -0400 Received: from mail-yb1-f194.google.com ([209.85.219.194]:34175 "EHLO mail-yb1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726604AbeIMJcv (ORCPT ); Thu, 13 Sep 2018 05:32:51 -0400 Received: by mail-yb1-f194.google.com with SMTP id t10-v6so2768868ybb.1 for ; Wed, 12 Sep 2018 21:25:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=7oaRrgCH8FMgYqgf5wQKl/zFZfk1zkIZLePlt6j1oKI=; b=Dmm8w90aXdR9ZS4WLQHZx8Lfpacik8uNqAU9HuAcV2AxAY9QlPRbZi0xM7sKaUuDmV bPy0ZzlFcMULnN6d8SH/0/zwtpO0ICxJiiu8e0PPzqBH3On5YPddngIo976ZuJBBNXoa J4HcDOD0+Cgh2JT/vZxO9+/BEgOCKd8f+M3uk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=7oaRrgCH8FMgYqgf5wQKl/zFZfk1zkIZLePlt6j1oKI=; b=AF4xb6kF4r0R7Mx2U0kWxPsaTVs5dXx8ngDpmG4QwCGEMOiPdiCmOYRNuUOJlS5JR5 Q338IJNYXRedSxmUIkg0RyEGajPsHum3C0SmlcvpydtxquE+Uvczi3JLgxDffHIaw30o Z0edUFbD2iwEeHz4FBJe1aQNEkk53DGQlxAU3ra2tAbQUKHGBTW24BTiHH7fYCgLRUpW aB9iQwavox6KRD184HNSl9G5vAY+CPUUL5PsD7yiLgImKZ4KL7n5sV7xJdNVZJi/gVeN aarLhJqwRkfev7TMEsa/sfiDET8vKQHyi4t27ydaGaNzX/Ny5nW6KjeOBcLjHZqUmuMd 5viQ== X-Gm-Message-State: APzg51AsdGU3UPgG2mm6lAS9v8LlNBWCZ9NrobpEzn6F3BZnieB0ZeMF 3KRjsnKGynj29mcx1tiWrkSyjFQMv34= X-Received: by 2002:a25:1543:: with SMTP id 64-v6mr2656984ybv.468.1536812708283; Wed, 12 Sep 2018 21:25:08 -0700 (PDT) Received: from mail-yw1-f53.google.com (mail-yw1-f53.google.com. [209.85.161.53]) by smtp.gmail.com with ESMTPSA id u191-v6sm978139ywc.0.2018.09.12.21.25.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Sep 2018 21:25:07 -0700 (PDT) Received: by mail-yw1-f53.google.com with SMTP id i144-v6so646272ywc.3 for ; Wed, 12 Sep 2018 21:25:06 -0700 (PDT) X-Received: by 2002:a81:9fd6:: with SMTP id w205-v6mr2623549ywg.288.1536812706455; Wed, 12 Sep 2018 21:25:06 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a25:5f04:0:0:0:0:0 with HTTP; Wed, 12 Sep 2018 21:25:05 -0700 (PDT) In-Reply-To: <41ab11ba9fa03940d129f478109d048b197d9a59.camel@intel.com> References: <1536723394-14616-1-git-send-email-bin.yang@intel.com> <41ab11ba9fa03940d129f478109d048b197d9a59.camel@intel.com> From: Kees Cook Date: Wed, 12 Sep 2018 21:25:05 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] pstore: fix incorrect persistent ram buffer mapping To: "Yang, Bin" Cc: "ccross@android.com" , "Luck, Tony" , "linux-kernel@vger.kernel.org" , "anton@enomsg.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 12, 2018 at 6:21 PM, Yang, Bin wrote: > On Wed, 2018-09-12 at 10:44 -0700, Kees Cook wrote: >> On Tue, Sep 11, 2018 at 8:36 PM, Bin Yang wrote: >> > persistent_ram_vmap() returns the page start vaddr. >> > persistent_ram_iomap() supports non-page-aligned mapping. >> >> Oh, yes, good catch. This should probably be explicitly mentioned in >> comments for these functions. >> >> > persistent_ram_buffer_map() always adds offset-in-page to the vaddr >> > returned from these two functions, which causes incorrect mapping of >> > non-page-aligned persistent ram buffer. >> >> How did you find this problem, and/or how was the problem manifesting? > > By default, ftrace_size is 4096 and max_ftrace_cnt is nr_cpu_ids. The > zone_sz in ramoops_init_przs() is 4096/nr_cpu_ids which might not be > page aligned. If the offset-in-page > 2048, the vaddr will be in next > page. If the next page is not mapped, it will cause kernel panic. > > I just wanted to enable this driver on my board and did not change the > default value of ftrace_size. It resulted kernel panic as below: > > > [ 0.074231] BUG: unable to handle kernel paging request at > ffffa19e0081b000 Perfect, thanks! I've updated your commit log to include these details now. Should be in linux-next shortly. -Kees -- Kees Cook Pixel Security