From nobody Tue Jun 30 11:02:18 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C3B8C433F5 for ; Tue, 18 Jan 2022 11:35:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240018AbiARLfg (ORCPT ); Tue, 18 Jan 2022 06:35:36 -0500 Received: from alexa-out-sd-01.qualcomm.com ([199.106.114.38]:38314 "EHLO alexa-out-sd-01.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234332AbiARLff (ORCPT ); Tue, 18 Jan 2022 06:35:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1642505735; x=1674041735; h=from:to:cc:subject:date:message-id:mime-version; bh=Xpnk/KGmrv0cCAMDVblqIQzdev4jRFWvT9glia5SNwY=; b=MwAG7vjLIQi7yX6G2yf6esXSE4/sfFCShJn55fjGgBctEkXITseOYSXL uTec1nlaQVlDJ6VwyUziqq11Cwvn9ucF/4n5f+DSmJHq4K5RF31hzOxGD IwBMQIQxEUgtUvmYLceI6IKe0DgU5PwoRIQncjVFOP5lWMS9CnjfZ9trL Q=; Received: from unknown (HELO ironmsg-SD-alpha.qualcomm.com) ([10.53.140.30]) by alexa-out-sd-01.qualcomm.com with ESMTP; 18 Jan 2022 03:35:34 -0800 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg-SD-alpha.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jan 2022 03:35:34 -0800 Received: from hu-mojha-hyd.qualcomm.com (10.80.80.8) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.19; Tue, 18 Jan 2022 03:35:31 -0800 From: Mukesh Ojha To: CC: , , , , Mukesh Ojha Subject: [PATCH] printk: Fix seq check inside devkmsg_read() Date: Tue, 18 Jan 2022 17:04:48 +0530 Message-ID: <1642505688-1194-1-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01c.na.qualcomm.com (10.47.97.222) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" prb_read_valid() could return a record whose seq number can be newer than the requested one. In that case, we allow the reading of the data instead of erroring out. This commit fixes this by correcting the check. Fixes: ce6de43a547b6e01a3 ("printk: avoid prb_first_valid_seq() where possi= ble") Signed-off-by: Mukesh Ojha --- kernel/printk/printk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 155229f..53b09b98 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -738,7 +738,7 @@ static ssize_t devkmsg_read(struct file *file, char __u= ser *buf, goto out; } =20 - if (r->info->seq !=3D atomic64_read(&user->seq)) { + if (r->info->seq < atomic64_read(&user->seq)) { /* our last seen message is gone, return error and reset */ atomic64_set(&user->seq, r->info->seq); ret =3D -EPIPE; --=20 2.7.4