Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1727580ima; Thu, 25 Oct 2018 04:05:41 -0700 (PDT) X-Google-Smtp-Source: AJdET5fFDTr1H7/TfvYQBun4qMQv91CiHnrevvC8S+74R/4TV8fw6UyNGn8Qb2WAs8vnfw9hjt2f X-Received: by 2002:a62:9702:: with SMTP id n2-v6mr1090510pfe.222.1540465540959; Thu, 25 Oct 2018 04:05:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540465540; cv=none; d=google.com; s=arc-20160816; b=k59K06+Zv+IxHJ0dwPna9rpbqdehq1/MzkmzNFDbkuxgCU0cU1+RUYwaCrTOV0fF5L qR84tKNUeubgxJPKNtKYNOxsq0qNP0/Jkqmmyze4wGHBusMgcYi/vH7171i5DAK9rkOr 3YYgO3yCHHcRDXdaHrAHbKSwU9FTg1UHN63ctg+yldLbZQGPa5u9Uqtzb5LArOSB16CD KFWXpn3P1viRIVKtrqxn9B3D4Abp0Cvm65P01RBPNiEXwf4rXiP14AvDoSxtHxhjQDzA fHROJAltGtYJzkHgaMk4gDU9hEhgTuiTorX63r3u3pLbne8t03ZJvF5TKNOqJEi9Rpqa YcjQ== 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=GiYeJ0fu3Rb+xAfppx9URTKVBMbdBGdZ7pIhWmWLkPg=; b=LY3/WjsYBHWVubyYCmW6l7Gr3Y7ZiwQxA1kV84ehg712cK5JgimLhD60iCshZZy1ph OMyT73GOAH4dMi/+6agtzOQ+gBxHFBVPCCICpevb32qfSNzHMS3YElktNZtrflWK/LZG 0n2S7rQGjQlsqUwpbWC4KO/35alK0xgzYwV1zAbH3cM4BabcaVYuQwRTsAqpnhLD9eUG 0pBnY9WIBwkQgJfnoMFECEotlRv+3sBxCRpyO6mMs8nt54ONnTiDxiCZpod4CHLlhn4w fcd5Yskk0TsAkpJatrQVl46pgY9Z2Q3HY7JTcJqeSgtl8F3R85IFmyqdtuMF5pPOi740 bIXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HAIqic0z; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d32-v6si7639028pla.384.2018.10.25.04.05.22; Thu, 25 Oct 2018 04:05:40 -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=@linaro.org header.s=google header.b=HAIqic0z; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727356AbeJYTgj (ORCPT + 99 others); Thu, 25 Oct 2018 15:36:39 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:38429 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727206AbeJYTgi (ORCPT ); Thu, 25 Oct 2018 15:36:38 -0400 Received: by mail-ot1-f66.google.com with SMTP id l1so8682875otj.5 for ; Thu, 25 Oct 2018 04:04:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=GiYeJ0fu3Rb+xAfppx9URTKVBMbdBGdZ7pIhWmWLkPg=; b=HAIqic0zKAgkfd/VBFZMiKbS2vuFUilMEwTE7FJwBqVO+TNDVKxKIfqVI+L7fcJ9uH RWrjISAxPm+ELcskx/uWzJYsN624C9W/kWI9F0AEbukzoMg/F9d+C4yhgLXQVlpwZDRS PbQmy1mLAdzUL7Fpu+fvt41A3Rgxj/S3ixy0o= 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=GiYeJ0fu3Rb+xAfppx9URTKVBMbdBGdZ7pIhWmWLkPg=; b=l6ZTIkzYtNe1VbQzucLA5VtnupCwxv3WinghLsm+M9d6xv26o9e0Miki8WB1RukIQC yzKCMwCw3xQ37k7lO3eZdWR9tSA8fv5Dx364RG8OCW+xz/gesGYeTYRxpUpB/aI9pGbB VV7LqbmaXOlpmZjm7S2vxAXwMTXlo/+SfFUUTuQEl2cvpqv2+VQn8HOdrQHfiywBzW6R Me/3s+RRnBMs/zawl4EdC54zx7yEvmOvGLJj8O6i4323m7wXa+eG0CJbdZm2+YyTftLW DsfqTZTejNUtnLBPcpPiZDVm89VI6D/MPv5369PpMabGcIrgU6bZ7Cr4BVl5qxt0zRpg 0e9A== X-Gm-Message-State: AGRZ1gIcMCXfRK54XYiFQaoTffpSFlku7kXKvZGh7fqheyI9G34YTL6a hP4yXLJ+bKmyewssAXckdJxO2k1GjPwaJg== X-Received: by 2002:a9d:66f:: with SMTP id 102mr1114604otn.308.1540465461867; Thu, 25 Oct 2018 04:04:21 -0700 (PDT) Received: from mail-ot1-f46.google.com (mail-ot1-f46.google.com. [209.85.210.46]) by smtp.gmail.com with ESMTPSA id w17sm2444839oth.1.2018.10.25.04.04.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Oct 2018 04:04:20 -0700 (PDT) Received: by mail-ot1-f46.google.com with SMTP id p23so8660015otf.11 for ; Thu, 25 Oct 2018 04:04:19 -0700 (PDT) X-Received: by 2002:a9d:5a0e:: with SMTP id v14mr1064196oth.189.1540465459338; Thu, 25 Oct 2018 04:04:19 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ac9:2056:0:0:0:0:0 with HTTP; Thu, 25 Oct 2018 04:03:47 -0700 (PDT) In-Reply-To: <20181025052901.GA17799@jagdpanzerIV> References: <20181025012745.20884-1-rafael.tinoco@linaro.org> <20181025052901.GA17799@jagdpanzerIV> From: Rafael David Tinoco Date: Thu, 25 Oct 2018 08:03:47 -0300 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/2] mm/zsmalloc.c: check encoded object value overflow for PAE To: Sergey Senozhatsky Cc: Rafael David Tinoco , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, Russell King , Mark Brown , Nitin Gupta , Minchan Kim , Andrew Morton 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 Thu, Oct 25, 2018 at 2:29 AM, Sergey Senozhatsky wrote: > On (10/24/18 22:27), Rafael David Tinoco wrote: >> static unsigned long location_to_obj(struct page *page, unsigned int obj_idx) >> { >> - unsigned long obj; >> + unsigned long obj, pfn; >> + >> + pfn = page_to_pfn(page); >> + >> + if (unlikely(OBJ_OVERFLOW(pfn))) >> + BUG(); > > The trend these days is to have less BUG/BUG_ON-s in the kernel. > > -ss For this case, IMHO, it is worth. It will avoid a investigation like: https://bugs.linaro.org/show_bug.cgi?id=3765#c7 and and #c8, where I had to poison slab allocation - to force both zs_handle and zspage slabs not to be merged - and to make sure the zspage slab had a good magic number AND to identify why the bad paging request happened. If this happens again, for any other arch supporting PAE that does not declare MAX_POSSIBLE_PHYSMEM_BITS or MAX_PHYSMEM_BITS appropriately, the kernel will panic, no matter what, by the time it reaches obj_to_location(). Things can be more complicated about declarations for PAE if we consider ARM can declare MAX_PHYSMEM_BITS differently in arch/arm/mach-XXX and/or, for this case, when having, or not SPARSEMEM set (if I had SPARSEMEM set I would not face this, for example). If this occurs, the kernel will panic, no matter what, by the time it reaches obj_to_location()... so why not to BUG() here and let user to know exactly where it panic-ed and why ? Other option would be to WARN() here and let it panic naturally because of bad paging request in a very near future... please advise. Thanks, Best Rgds -Rafael