Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2018463pxb; Sat, 23 Jan 2021 13:44:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJwG8ktZU3ez8Pkqu0rgDjb/dBY3VPY6XCJISghLEC0xb9IwHLuAMBvshCiOSz8wcDYTFQeH X-Received: by 2002:a17:906:1a0c:: with SMTP id i12mr589950ejf.325.1611438250642; Sat, 23 Jan 2021 13:44:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611438250; cv=none; d=google.com; s=arc-20160816; b=q53O94Omm/ZeA6iH5IjsoUggkQNiRoPXpuVxy/xkMV/OyMpznyw57eBRVh10a+2DY2 cM6+rymY5/ODTLjJFK2IoJifYYMeQ2zPGAZPVYqWFia/COXAN0HJ6AEr/bQFJBPwDD1J meVGLO4ZyuVGqUQ1eZ118qNFm8hH9pZv4wAiTeKILFlOtHPEh+WAnbaxgv+46QT3DXRi rTt6Z0an3+jnmkuKd3Zqb3zHmRBVYjzepoBc/9cZic2I8dEjHqBEHTSB+YyquUqkAWuI w0kRcLRxA6yTmdeYsd220DMaTugpMVjQhp+ZWdK88+jYRjch7OD0EQyP/OlJw6H6+J7y +W/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:dkim-signature; bh=lE60vpXqpKtW3AkS89mfSNdJOESBN1hLw2h+uxilxmY=; b=TObsfn8izf8z+EhAtVpjjGjX9EcWP6zfvcbRvHyQLdEGSHoQSycCzuww3F7EpXsV54 HuG6mc0ujKFDi0f1elp0DvGgH/xedAlXC5zLLjJr4JP/cMjJlDAgxBldM/3zououNh6p FrTyFZOvJwp9nIlvtT6APLOVBa5KdqAhr2PDawHfRmZJ1FaxrRlvWmaJLx9IcC+glhUC HBDiFZEqGYUTji5sZ8GdAGLGpw2Ix4PwK8uO6hg531ktp2vgaySpg2BxjwVwnIBJD+CI JSZfFtLUwxmIyrQOzpYTcnLgN22n7f6Ei90baWxjFRsFvqjL3+e0zhQw/X3kOTpmVLda KHHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=nk4FF9WU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z9si4376915eja.51.2021.01.23.13.43.47; Sat, 23 Jan 2021 13:44:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=nk4FF9WU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726367AbhAWVm5 (ORCPT + 99 others); Sat, 23 Jan 2021 16:42:57 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:7914 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726288AbhAWVmy (ORCPT ); Sat, 23 Jan 2021 16:42:54 -0500 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 10NLWMKR176482; Sat, 23 Jan 2021 16:41:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : references : date : in-reply-to : message-id : mime-version : content-type; s=pp1; bh=lE60vpXqpKtW3AkS89mfSNdJOESBN1hLw2h+uxilxmY=; b=nk4FF9WUwBXBm8Vzg4UJlIMIY4VgA38j2M6QlgvzABtkp5CHtvjso5uTkCKTkXVtioMq zE2wljsAwmzv/i89JsebhcDMwWyM9y+AOlOfAPXy0OBGrdUwRpfS44pTxBJBJExndiq0 UZEWw735uzw8y5JnxiZSFSR+fL8Hyc8g4zIjv/Hfd3G280BTMQhnTKaughPcovHQwgTa mo7bqRQPgcQAm4jANNVGGiNYXOigFA613BLtlD6XPBeJYf5LfbxxCD1PT3cpzhvaRwWg pR5CExgucFr+BlOwXloVeOMyQXEDnPMeQBZ6VJ9uRypm2A6HSoS/UVkAkQOgEHTnNvun /A== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 368uh1rcbn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 23 Jan 2021 16:41:29 -0500 Received: from m0098396.ppops.net (m0098396.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 10NLYYM8183328; Sat, 23 Jan 2021 16:41:29 -0500 Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0a-001b2d01.pphosted.com with ESMTP id 368uh1rcb4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 23 Jan 2021 16:41:29 -0500 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 10NLXA2t020959; Sat, 23 Jan 2021 21:41:26 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma02fra.de.ibm.com with ESMTP id 368be888u6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 23 Jan 2021 21:41:26 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 10NLfOgl44630354 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 23 Jan 2021 21:41:24 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 60D6A5204E; Sat, 23 Jan 2021 21:41:24 +0000 (GMT) Received: from tuxmaker.linux.ibm.com (unknown [9.152.85.9]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id 1C2BE52050; Sat, 23 Jan 2021 21:41:24 +0000 (GMT) From: Sven Schnelle To: John Ogness Cc: Petr Mladek , Sergey Senozhatsky , Sergey Senozhatsky , Steven Rostedt , Linus Torvalds , linux-kernel@vger.kernel.org Subject: Re: [PATCH] printk: fix buffer overflow potential for print_text() References: <20210114170412.4819-1-john.ogness@linutronix.de> <87v9bomtd0.fsf@jogness.linutronix.de> Date: Sat, 23 Jan 2021 22:41:23 +0100 In-Reply-To: (Sven Schnelle's message of "Sat, 23 Jan 2021 22:18:37 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343,18.0.737 definitions=2021-01-23_12:2021-01-22,2021-01-23 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 phishscore=0 mlxlogscore=992 spamscore=0 malwarescore=0 bulkscore=0 priorityscore=1501 adultscore=0 impostorscore=0 suspectscore=0 clxscore=1015 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101230123 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sven Schnelle writes: > John Ogness writes: > >> On 2021-01-22, Sven Schnelle wrote: > I was able to reproduce it in a virtual machine where i have a few more > ways to debug. What i got was: > > 01: -> 00000000001B8814" MVI 92001000 >> 000000000163F1CD CC 2 > > That's a watchpoint telling me that the code at 0x1b8814 wants to store > one byte to 0x163f1cd, which is the second byte of console_drivers. > > gdb tells me about 0x1b8814: > > (gdb) list *(0x1b8814) > 0x1b8814 is in record_print_text (/home/svens/ibmgit/linux/kernel/printk/printk.c:1402). > 1397 * If a buffer was provided, it will be terminated. Space for the > 1398 * string terminator is guaranteed to be available. The terminator is > 1399 * not counted in the return value. > 1400 */ > 1401 if (buf_size > 0) > 1402 text[len] = 0; I don't think i have really understood how all the printk magic works, but using r->text_buf[len] seems to be the correct place to put the zero byte in that case? > 1403 > 1404 return len; > 1405 } > 1406 >