Received: by 10.213.65.68 with SMTP id h4csp1657910imn; Thu, 15 Mar 2018 06:09:01 -0700 (PDT) X-Google-Smtp-Source: AG47ELved+s1+9YY6hi6WZww/Fns74jtIpHL33gBfw+VcSvvcC4ZcpZVfWvPwKHj4PWiK8MPcjGa X-Received: by 2002:a17:902:bc3:: with SMTP id 61-v6mr8009415plr.398.1521119341270; Thu, 15 Mar 2018 06:09:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521119341; cv=none; d=google.com; s=arc-20160816; b=X5Nzdm2VTUOWgII23YlyVNA6sdHwgwrY6Bdle36+em3Ygkt1QS1cNctKj5HDQRBIzh XUh2iFj6SXv0mJoFE4ktfp01EBL4aBtPZJ8ok0PnJgL995KXVpuhTLeDBIcHJUnWU0cF 3rIj8CKkWPjIkiD2xM2CGh2lagWY7lEi9SQFWh0kfwk+dHctpz/q1+G2RJSFWLI2okN9 UvKKgGWciUA41mru4e3/dzww/JVEdSWi2N1a9WQKXkjvVvfpbiJ9kSA6bsXX9EA4xXiI LPHQJmEFSXAUIVeRduNHfuVK+X93xpl4PokAfu0YxlCljBMnUMLksWXrxNQqxi1L0p3E oZQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:date:cc:to:from:subject :message-id:arc-authentication-results; bh=yeNmPIenOJoHwumznFCuGGiEgWPqp7JnQ9x1xUhShYg=; b=GrzerNfUZxNOEN9WThfm6m9A3dkgl17edvsT03X0qdoknqhV1eSZMJ1fZJkPgZdbLN vjxOaSbJ3pzqZrPUhcU9EyVQYC9LOY0oZeEgnE6WHAvvwAvBAzTLyaaEKISvZlAWuqvX SJsnk87LL58wTp8FAgwbXtWC+LpNLo8hzMn1yCA5oOqirwWqOpdmsua2jKR2jbQJLXb1 8/MwRE79k0isuo37vW2ze+Xu+0C1K2Dfb2rtWmtFHmCrN3TX6IscBeEXsU7ljtq7Rc4j I3oyyhvlTgskpDdCxCiWTmuF4XfiVqp8qCqfGrBrqAv9p3pdO2rz5hW9a0MRSBLGCKkg PqqA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u132si3456034pgc.802.2018.03.15.06.08.44; Thu, 15 Mar 2018 06:09:01 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751866AbeCONHK (ORCPT + 99 others); Thu, 15 Mar 2018 09:07:10 -0400 Received: from mga17.intel.com ([192.55.52.151]:41522 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751481AbeCONHJ (ORCPT ); Thu, 15 Mar 2018 09:07:09 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Mar 2018 06:07:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,310,1517904000"; d="scan'208";a="42282618" Received: from smile.fi.intel.com (HELO smile) ([10.237.72.86]) by orsmga002.jf.intel.com with ESMTP; 15 Mar 2018 06:07:05 -0700 Message-ID: <1521119224.10722.664.camel@linux.intel.com> Subject: Re: [PATCH v3] vsprintf: Prevent crash when dereferencing invalid pointers From: Andy Shevchenko To: Sergey Senozhatsky , Petr Mladek Cc: Linus Torvalds , Rasmus Villemoes , "Tobin C . Harding" , Joe Perches , Linux Kernel Mailing List , Andrew Morton , Michal Hocko , Sergey Senozhatsky , Steven Rostedt Date: Thu, 15 Mar 2018 15:07:04 +0200 In-Reply-To: <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> <20180315075842.GD3628@jagdpanzerIV> Organization: Intel Finland Oy Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.26.5-1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2018-03-15 at 16:58 +0900, Sergey Senozhatsky wrote: > On (03/14/18 15:09), Petr Mladek wrote: > > > 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. > One more to the same. Though need to add that we also have to append / update some comment to keep these lists synchronized (in Documentation, around pointer() and here) -- Andy Shevchenko Intel Finland Oy