Received: by 10.213.65.68 with SMTP id h4csp98180imn; Thu, 15 Mar 2018 18:34:33 -0700 (PDT) X-Google-Smtp-Source: AG47ELtp9oJOOx4BW240pwrEWB7pYR/JtKvWUmeV//oFGIXtS8AfoYXNAwDCWvme+YlXUsQjH+Mk X-Received: by 2002:a17:902:ab89:: with SMTP id f9-v6mr10282697plr.369.1521164073279; Thu, 15 Mar 2018 18:34:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521164073; cv=none; d=google.com; s=arc-20160816; b=r4+RPKqgFlEdo+19RE2/WkoUVu+xOuUcfnRdcf6ikhVnCIuUBUnCsknrqUHOKBBLdz qzPGYuSo3tQa4NkOw6bU0Ht8QhJ/o+P8QahJPSH6mjdY/FVTA3iChk+oP3hVNDaRG+kG CPZLfoizsu+ejMCekC8mAVwMZFjSe4UDBk1oKn1aR0cMKiL7WuQjRGzJKwObA4owPdQN rdj/4Vzh0Vf3ZxVnNuQnHQ0s3a5EMGt1+1OP2NatZOVSfZvpHoZMNxdh4hNR2QrERKW8 YpkQETNZAV1UKYCaq1Y/i+oHoQRjredQHzihXLxibmDQJ267MYRQ6jCrlh0wcnPnh7cn jHSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=p6h2/tJtr5/yi3bM7EpH1sgfM35cKymcl8bCmLuc2jU=; b=H2wcqqEgMWIaiIFkZIPgbS0fwzZSPKYZc4HJkIFKPek6sKa1eHelqcgYYYWNkWCqPn HWt0vI71CTJIfl0klb3e9A0cqsTzvw3+wbhJtlJMxu5YIX14DkHrCbU4bg9xXEbvPTvd oBy2GGq9UV/aZqCcGQPj8vYFdPiQ3ynFPDO/wv1El1lF9MzFV/QV/SKr2Pw0CBhCHp/c 4lZMjsufJTQsAslWF1p7+ul95oTqzzqACQUIrICbQ8MUVGxw1Dh0V7Uh+9DEjROTp4Og j6htuNLwNHbZfkPSsBlN3puHbOXlIDGJv/6x55OtjkSyJARh70qZnGmcmz4PU5um8Wng DaUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZM1W+N8e; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z13si4621328pfh.217.2018.03.15.18.34.19; Thu, 15 Mar 2018 18:34:33 -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=@gmail.com header.s=20161025 header.b=ZM1W+N8e; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932975AbeCPBS7 (ORCPT + 99 others); Thu, 15 Mar 2018 21:18:59 -0400 Received: from mail-pf0-f174.google.com ([209.85.192.174]:41387 "EHLO mail-pf0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932341AbeCPBS5 (ORCPT ); Thu, 15 Mar 2018 21:18:57 -0400 Received: by mail-pf0-f174.google.com with SMTP id f80so3541386pfa.8 for ; Thu, 15 Mar 2018 18:18:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=p6h2/tJtr5/yi3bM7EpH1sgfM35cKymcl8bCmLuc2jU=; b=ZM1W+N8eAa0cuNSOh+BoXpIKV/DtOsj+HxFuA95TDEFKW/dF3DvOhm2qE3vCOLBUa9 uvhbMMYYf/rcgApHlod0obDq8R/D6jbu0Fh6fsDhu6jCcacBRtPZ22XH/WjpuKkRyAhy +9i4imrmFExgT3raUYqC1X+Fv7boiT2ldB4MlIELPXKn3vE+0vaFd7EEUbOrewzT2g8I yOr5/q+BQRBfRsj6cw4QjOONrWIvxDdHpwvfdi374T4nheMJiuRNk4+2FCgWvfWFVM6q ohxoOEHECHEYJGWulwlNLwz2fhYvEu9WKs/pVvvbm05rq0ByqSwTTSNayE0zrz6sZKj3 h34Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=p6h2/tJtr5/yi3bM7EpH1sgfM35cKymcl8bCmLuc2jU=; b=eQ/GofwD6WZMZnmDfamloPKG03obtALBJ4ahMjlhju+ehPv//Btd+rht6hGEdZ3/Tu gg7wAir2m/sYb/TezfB415FVdFEUx/UsO5ia2TRveO+3khRe4SkpSM+AqRmWD10ljxdB hG7U1mkJK7NbqNMthGnH7epTgB7W0cIRCoinF2/QOgV5/udEH6vO5dUPfxjimpKJUBwM 1HZCgx2jFvg13W5l19KGqT+rD/dviuRq38ZJktx3dmXBatvnfySS2f0DxeQRBZ8/8Px5 KeKxZjE3bMqCcumZEsEJ9lna3NRN3qOjye3bBEYLQ+4Ar/OHCpJ9mMTLhjNGDvMk9fUK Z4Eg== X-Gm-Message-State: AElRT7EZplObaPyQ07sz/6WB08rmo73ZnVPlUzaRX9LjeSdOTwlSOhDm 1mUMTfYvxDXp9kpYgLPfs2s= X-Received: by 10.98.207.135 with SMTP id b129mr2789590pfg.84.1521163136948; Thu, 15 Mar 2018 18:18:56 -0700 (PDT) Received: from localhost ([39.7.47.97]) by smtp.gmail.com with ESMTPSA id w10sm10058779pgr.57.2018.03.15.18.18.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 15 Mar 2018 18:18:55 -0700 (PDT) Date: Fri, 16 Mar 2018 10:18:52 +0900 From: Sergey Senozhatsky To: Petr Mladek , Steven Rostedt Cc: Sergey Senozhatsky , Petr Mladek , Linus Torvalds , Andy Shevchenko , Rasmus Villemoes , "Tobin C . Harding" , Joe Perches , Linux Kernel Mailing List , Andrew Morton , Michal Hocko , Sergey Senozhatsky Subject: Re: [PATCH v3] vsprintf: Prevent crash when dereferencing invalid pointers Message-ID: <20180316011852.GA5139@jagdpanzerIV> References: <20180308141824.bfk2pr6wmjh4ytdi@pathway.suse.cz> <20180309150153.3sxbbpd6jdn2d5yy@pathway.suse.cz> <20180314140947.rs3b6i5gguzzu5wi@pathway.suse.cz> <20180315075842.GD3628@jagdpanzerIV> <20180315080309.GF3628@jagdpanzerIV> <20180315130117.7c2fb761@vmware.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180315130117.7c2fb761@vmware.local.home> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (03/15/18 13:01), Steven Rostedt wrote: > > > > +static const char *check_pointer_access(const void *ptr) > > > > +{ > > > > + unsigned char byte; > > > > + > > > > + if (!ptr) > > > > + return "(null)"; > > > > + > > > > + if (probe_kernel_read(&byte, ptr, 1)) > > > ^^^^^ > > > Why one byte? sizeof(ptr)? > > > > I think there is a shorter version - probe_kernel_address(), > > which, seems, was designed for this particular kind of stuff. > > > > void *p; > > > > if (probe_kernel_address(ptr, p)) > > .... > > > > Agreed. Hm, may be sizeof(ptr) still won't suffice. It would be great if we could always look at spec.field_width, which can be up to 2 * sizeof(void *), and then just probe_kernel_read(spec.field_width). E.g., %b/%bl prints out a bitmap, accessing max_t(int, spec.field_width, 0) bits, which is good. But, for instance, %U (uuid printout) doesn't look at spec.field_width, and reads in 16 bytes from the given memory address. Then we have ipv4/ipv6, mac, etc. So I think that checking just 1 byte or sizeof(ptr) is not really enough if we want to fix vsprintf. What do you think? -ss