From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5411E248886 for ; Fri, 20 Mar 2026 08:54:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773996862; cv=none; b=cjZFfrdCWd4ueTJ36mcAbWR+rgxKLTJLZmzoXQKQbBxrpnnZtC6TYVYT/P7B1somoz+CSv9nwX9DssDpco5caNdAG7mOPM2894nWMNRAKKc1RmsM77ZbLEsQBZSZmUXHUjq7Iq0IHfaZYdwP8Cw+v/Ws56k2UGgsfw8ovqkzpi4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773996862; c=relaxed/simple; bh=BeACco3JxOlgG6uF+9XH++Lpt3pFNhIivBjOPtAEmGU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=I74AwbcscNG831NCdzdxL7jgYT7In9SHy3Ist0XWqwgeZhlHHOj1s3IeMrN+FrciDfoATtM5rjHn+tXygPpyfRTNfVcBw6zIH69OcAqn8/WZVfrOBkpCnyQVsXOLnIg+uARn9wy16DaRaCLTikxrVcPF4gZxLeKyUdZjTHDd/MA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=QdS+IdQv; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="QdS+IdQv" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-486fd5360d4so12786845e9.1 for ; Fri, 20 Mar 2026 01:54:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1773996860; x=1774601660; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=UXk7WuX16/b56NVWJi4EpXQUSCIiXxIRoXZt38/Nsm0=; b=QdS+IdQvXvRBBGQodLx+KQ7TV8s6UUlUEcJCg5xDoTWdt5vH7vYBJMpXf7F/qNNjlo ygZpO0FJCUIj6VZ+s5jOxX6vHz2stM4LB5IgZHpY9UsJ+oskre0wzdK0B4qoSzsP+u48 1rRVmCbRQ8ThaorE4xd7dteQ2OS0w+mmgUr2cadDPsqlLZ0aEUzeboZftzAIEIr8/wC+ TkEQChG2g/GH90J4nZsyZ1tJ2Iblpcd5evtlfLGVPuqStKLQ0oeNAumrdPXDZDHPWO+J exTlG8TzSuDPWwKwfhyyUMoCppEMkPBeB2A6PmhxLFcVSh5CFUOXtO04W8BGhsuRHbRS pAVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773996860; x=1774601660; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UXk7WuX16/b56NVWJi4EpXQUSCIiXxIRoXZt38/Nsm0=; b=h59Dcqhyz2yvy6ghVJ92bEtAW0z++rIp0MHPtKxgx74PQVyx1s8Ttk3Kbx7KIqtHBM fF9687xqiII3x3A2sQ1I+O5IkHHJc+L7L6zZVZBhwR2RtU3Bohtbxmvu33XfRcenTqHg yGhGiycIlAuT3iE9pyQ8c0VZ0dd+KqywbejMjorSLGvXeunVMVF7wLFeo+DH3cmi6mbV jIdowA9c23cgaUbBNlEzm8hSZIwECHZE5VZCDwGjtM3Dm093oQRv6ZQ8wOrsif9SHhOI 3d0sgZyrPms/jqSv9F+jcAhjKMjOywLmGoXw7jEXzFQ4S9gwWpA3G3NmwshIdLsJbcHR gb4A== X-Forwarded-Encrypted: i=1; AJvYcCUq//GBC0kDAX48uZLJ622Uy2qlCjWJ9yPidI9IGQyZen5OFItMDHoAiQk63h/tppQ7hYF03wq1OHmkevk=@vger.kernel.org X-Gm-Message-State: AOJu0YxK7iPLtEz5uQrEE8I/DQidOdCI5/mZKQS7slip/RlG92o5dGSl UDUViTSHYxXzOAjND4cYqjSJDiCZ1jSi6TvRDAVfR2TiMixRJ/FhyVQtzTTc+wkK0dU6x9nK0hj 9VKIB X-Gm-Gg: ATEYQzwcxfTb/sR93KetI9rqIa8X+lB/F6AlafJu54rquwoenXW0+jzwHa7KW3YuyvG 8o8DBqTag6yfmXt8mfGG1dtVNgMZHPi1MDfgjL6FeauE+eGKocw4+IDGDld9qNn10uhgG3oGtd6 JObVZeX3BYZVshMr1QTHI3NLSNOyjTZaKfNDOqlmXurD8HW8Zbpu74tS9cPrQnAn0pTeWZr/ZBa XdMPgi/WnqPxhfPKdh+qUmoDqdvrZGl8iYi86xKDaeMge4cukkbZn8jrTg5u7bx8W7zqAlgYSvc PVhfvbAsLqQrZl2GMQfTXGR+iDLVFy8A0BZRVKOApozqPM538Fn3QFGAMb+tziGy0b9fbM6dcu2 y2yWjsOtSGM2rEEs07LQlQLqJ3rWT4s8hYvXiZ/sZjIPZ3QoHMLdOjz94RyZfz8IFlkgsqZWn3h hzryPzqrc7J3UEZk7ZEZo2cJiVPw== X-Received: by 2002:a05:600c:4750:b0:485:3812:36dc with SMTP id 5b1f17b1804b1-486fedbd0bbmr31187175e9.9.1773996859614; Fri, 20 Mar 2026 01:54:19 -0700 (PDT) Received: from pathway.suse.cz ([176.114.240.130]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-486fe807262sm13317375e9.0.2026.03.20.01.54.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Mar 2026 01:54:19 -0700 (PDT) Date: Fri, 20 Mar 2026 09:54:17 +0100 From: Petr Mladek To: Andy Shevchenko Cc: Shuvam Pandey , Steven Rostedt , Rasmus Villemoes , Sergey Senozhatsky , Andrew Morton , linux-kernel@vger.kernel.org Subject: Re: [PATCH] printf: add bad-pointer tests for %ptT and %ptS Message-ID: References: <20260316105844.31906-1-shuvampandey1@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Mon 2026-03-16 16:55:36, Andy Shevchenko wrote: > On Mon, Mar 16, 2026 at 04:43:34PM +0545, Shuvam Pandey wrote: > > The printf KUnit suite exercises valid %ptR, %ptT, and %ptS inputs, > > but it does not cover bad pointers for the time64_t and timespec64 > > paths. > > > > Add NULL and low-address pointer cases for %ptT and %ptS. The new > > checks verify that time_and_date() rejects bad pointers before > > dereferencing them and formats them as "(null)" or "(efault)". > > > > Validated with the printf KUnit suite on arm64 QEMU and an > > incremental W=1 build of lib/tests/printf_kunit.o. > > NAK. > > It has nothing to do with %pt. Let me play the devil advocate. There is no single check which would catch bad pointers for the various %p? format modifiers. It is because some of them handle them differently, for example, %pK, %pe, or plain %p. I want to say that wrong pointers passed to %pt? are caught only because of the explicit check in: static noinline_for_stack char *time_and_date(char *buf, char *end, void *ptr, struct printf_spec spec, const char *fmt) { if (check_pointer(&buf, end, ptr, spec)) return buf; [...] } So, pointer-modifier-specific checks of wrong input might make sense. Of course, it would be nice to create some generic solution for all affected pointer modifiers and not just for "%pt?". Best Regards, Petr