Received: by 10.213.65.68 with SMTP id h4csp1497340imn; Thu, 15 Mar 2018 00:59:59 -0700 (PDT) X-Google-Smtp-Source: AG47ELtWRs3IGGp7t56svykekmaZhOE3M7J5wgGdRxb+e35jlLXYt4Khat3XxcKwdgaxiZ1aXDbL X-Received: by 2002:a17:902:6c46:: with SMTP id h6-v6mr7183946pln.333.1521100799508; Thu, 15 Mar 2018 00:59:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521100799; cv=none; d=google.com; s=arc-20160816; b=zaIIcLPW8y/GHCQSwsh0ua91teaVOtOlIxpTg5qjJSCIUXtLsOoK0gu5MzSEIJMPze KX31x/Ek51wY6x1nsJGBQcQPfkbkEMg7gA2MY4ewxnchA4hFCA07H+55MFZcYy6DBUbS xEdtnDvc6ZxKoOJ+NBj+rTrXGGbAhARf9p0zZN7HoY4ju015rD1B7nja8qPBWaS0ccjO 0fkz54VX22fJ4zGxWRMB4WuDBWEh7AoaliGZ9F6ELoLn4pDdbrMSu0tEVsQhIqTb31Mr LA1hLn/oUVK2gsS9yYf3NtRyru/BMiscp3YplJsjZ8XZxReU0IQ7O4L9Mc+4QiIm2T37 qRhg== 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=JdDGXGboLuEkV9E/bWGsPxRVaG3bFolGroIhlWnRJ8Q=; b=yYo2lD9TA3zzvbdl1CGaHFtrqTjjDBmp0jCIpJMq2XBtA6+8hu0vK/P25AzR62Aqdt a6jndhObeIcpFxGZ/Vf9sD8cR/EMdWA76H/ZdPoidv+/1cFi0BtvFUtEGFgnR9CFMXsm qAFwtMmK6CHE2bGn3ZwjFps6g60weGtzg/BlswSzUhKP7U2o4L8u+Zm+YvXZU9UaOT88 FciBCqgMuEQpPZQC7nzSuRrMBGbopVQRIPN02vHSBIemOIqiX7c3d2JE2P7REjE/s2Gk 4ZsNl3jSDkefT0ozD0y0Iz6/isfcJOBUS0GyxW3HtYyHJsSJBMTjkflCvnLHgQkIEKxs vP2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Cftn6ODg; 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 c24-v6si3500952plo.273.2018.03.15.00.59.44; Thu, 15 Mar 2018 00:59:59 -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=Cftn6ODg; 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 S1751517AbeCOH6t (ORCPT + 99 others); Thu, 15 Mar 2018 03:58:49 -0400 Received: from mail-pg0-f48.google.com ([74.125.83.48]:45079 "EHLO mail-pg0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751314AbeCOH6s (ORCPT ); Thu, 15 Mar 2018 03:58:48 -0400 Received: by mail-pg0-f48.google.com with SMTP id s13so2467308pgn.12 for ; Thu, 15 Mar 2018 00:58:47 -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=JdDGXGboLuEkV9E/bWGsPxRVaG3bFolGroIhlWnRJ8Q=; b=Cftn6ODgODsOYXSU7HZZRM3O8boWq7uV1/2QreHaiX/3t6xIsjUpbC6Z5QzqURktCt I9kFj4UrCLvlJsZXp1J7bd44Ghded8JHS3ZkBMICW7tGsED1fDt+R8PVvRA7yZjzgz0p YhjKMOa8PPCRpp9quLfDvtuTAWB1Q+ARadtjP0vou9RRk8MRcP3wpN/I7xjvm6vo3DAT kZzpJ3VViDJGM45BtOhpJas63xOYZCv6YxSWeEkXW4ZC5JoxD4kd4LQ6kWcqyAwyUuZe 0WHACXmchasE4oNdC2ghISxdZpsa7m+V8oE5HI5DIEUdl1HE6jv1OLioIpyp/C0eWpbP gDrQ== 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=JdDGXGboLuEkV9E/bWGsPxRVaG3bFolGroIhlWnRJ8Q=; b=ebXzKPYWDlg0z6tmiB9vwuq9QdNy0jn++x/IBhwHtLLkDQ/ea2JZQj80WBXfRAUCxj wASwiCw1rPeqY1RzjX/QBHE2hRRLs7AymowYVSlVNuVjFWDJj1zttAISAyLekiwAaMR6 yDYFGoLUF/VZDYir5UThatvbskJp3iILxRABznXIsa8F8v979wjom1GTJnOadT3u0DBm r/QgdcZ9yHudQ2x+Umu/UxIIih2NPmuZGVbRQ1+j+6bAfXGq1Lw/hZaW1aAVWsH9jyQd dE5da64+Aw4N//DYVnBiW0D4/WTBirNG0xSWeS5xApu1n2TRxKNy0+j/khhNC39spzx9 CW2A== X-Gm-Message-State: AElRT7FVYux7PWIb42AIzkR7twU0K3VZPcvuo8kEmny6u/HNsRKq7QGz a6DFM880WSVWLIR1JIgBtuk= X-Received: by 10.99.152.10 with SMTP id q10mr6090870pgd.62.1521100727521; Thu, 15 Mar 2018 00:58:47 -0700 (PDT) Received: from localhost ([175.223.21.185]) by smtp.gmail.com with ESMTPSA id d15sm9505108pfj.121.2018.03.15.00.58.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 15 Mar 2018 00:58:46 -0700 (PDT) Date: Thu, 15 Mar 2018 16:58:42 +0900 From: Sergey Senozhatsky To: Petr Mladek Cc: Linus Torvalds , Andy Shevchenko , Rasmus Villemoes , "Tobin C . Harding" , Joe Perches , Linux Kernel Mailing List , Andrew Morton , Michal Hocko , Sergey Senozhatsky , Steven Rostedt , Sergey Senozhatsky Subject: Re: [PATCH v3] vsprintf: Prevent crash when dereferencing invalid pointers Message-ID: <20180315075842.GD3628@jagdpanzerIV> References: <20180306092513.ibodfsnv4xrxdlub@pathway.suse.cz> <1520330185.10722.401.camel@linux.intel.com> <20180307155244.b45c3fb5vcxb4q2l@pathway.suse.cz> <20180308141824.bfk2pr6wmjh4ytdi@pathway.suse.cz> <20180309150153.3sxbbpd6jdn2d5yy@pathway.suse.cz> <20180314140947.rs3b6i5gguzzu5wi@pathway.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180314140947.rs3b6i5gguzzu5wi@pathway.suse.cz> 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/14/18 15:09), Petr Mladek 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)? [..] > char *pointer(const char *fmt, char *buf, char *end, void *ptr, > struct printf_spec spec) > { > + static const char data_access_fmt[] = "RrhbMmIiEUVNadCDgGO"; > const int default_width = 2 * sizeof(void *); > + const char *err_msg = NULL; > + > + /* Prevent silent crash when this is called under logbuf_lock. */ > + if (*fmt && strchr(data_access_fmt, *fmt) != NULL) > + err_msg = check_pointer_access(ptr); Agree with Rasmus, I think switch() is easier. -ss