From patchwork Mon Mar 20 07:02:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislav Kinsburskii X-Patchwork-Id: 76275 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp4731vqo; Tue, 28 Mar 2023 15:17:48 -0700 (PDT) X-Google-Smtp-Source: AKy350bECGbKHmaFIpJITXrwesQrrxkJNq5eICLw9zrh7FxxdYS9DgiOX40PelHFWnJ4Y5xbJG8U X-Received: by 2002:aa7:9621:0:b0:625:4189:fcce with SMTP id r1-20020aa79621000000b006254189fccemr16565379pfg.23.1680041867804; Tue, 28 Mar 2023 15:17:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680041867; cv=none; d=google.com; s=arc-20160816; b=cDCPfQn2cNLWd+LYbNlz0mKedN3MRiGuP9hWe0cJ1rMT5Xfs9oawMK91s1Lsn5ELSh UjtT7kRmiDwqyWysYB/gykr4izLiUsQ6G7kClt3gN/wjaPBAFNCt25kLWUlEPrKg1x/S PI518V87uMZ3N8YToXJU3i0gi4+4NkZhGO9qgUbIbnv98Zp+mIlUxxDqITCnPGxqFtwo rpzUiQwsAYXoPVaboikrd+NxjPatMy1LxCVHPM1/fc//XhHL39Dl4D6ca7yvQEftQm2L WdDIpVEBPfs6heGnjU5+mv5YhdJSyZDA4+UwLfsOWXT3Ot2W4CaZ9lEwyYQJQTeRldRO EWEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :user-agent:message-id:date:cc:from:subject:dkim-signature :dkim-filter; bh=5B2i+VHjiu+ubqKoN1kwXRD7hgJa5VH8yOvgkhGgb4o=; b=fE+AvsyAk94S+as7CrCb8kwxGyTE8yObhSbCykirdTlR4md0UHJ7NW5a0G9z+BrsMZ 0ihpbjrMSoUkGIvYDvuRXcUR4zMZuz1bVFAmu9xzRlTDr1Y5MCaQJ0vV9RI+lu5LQTjY K76w5rqg8es/uCGb3cnM7vfmhbB5ASV3quwCEwAaha+ZubHC23gkOQgxd9RFKZcVwG86 JDFeTxk8f44GaRVn31hXyucsVqgMsA6elA/zTzY6iZN4lFzTyGRwuTsgUBU5OM2LrwXH 6jd6Kw/0q4vHHi8bsGjOJBltLyDInbU1cRYm6JLqjarNZ4kaozyyJupMGOvpwmHXue1h faig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=bVJy7siy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v37-20020a631525000000b00502f0410410si29306517pgl.472.2023.03.28.15.17.20; Tue, 28 Mar 2023 15:17:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=bVJy7siy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229852AbjC1Vq6 (ORCPT + 99 others); Tue, 28 Mar 2023 17:46:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229729AbjC1Vq4 (ORCPT ); Tue, 28 Mar 2023 17:46:56 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CCD6B1712 for ; Tue, 28 Mar 2023 14:46:55 -0700 (PDT) Received: from skinsburskii.localdomain (c-67-170-100-148.hsd1.wa.comcast.net [67.170.100.148]) by linux.microsoft.com (Postfix) with ESMTPSA id E93B120FDA86; Tue, 28 Mar 2023 14:46:54 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com E93B120FDA86 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1680040015; bh=5B2i+VHjiu+ubqKoN1kwXRD7hgJa5VH8yOvgkhGgb4o=; h=Subject:From:Cc:Date:From; b=bVJy7siypq98zpsZ4UGlciijsRdOt02pMb0+1UGTYnBeNPJjOKZcj6De5nKHMKSbb kMsSfT15YbCSdocn+371A517/9UGdM0vGS1YFLUPO9zyx2tUvjC7Fqpu1TjRMuXPW8 O7RPTDaweZIwHJXxcn4cvJAi0mxioF+qFB0FFfXg= Subject: [PATCH] printk: Remove obsoleted check for non-existent "user" object From: Stanislav Kinsburskii Cc: Stanislav Kinsburskii , Petr Mladek , Sergey Senozhatsky , Steven Rostedt , John Ogness , linux-kernel@vger.kernel.org Date: Mon, 20 Mar 2023 00:02:01 -0700 Message-ID: <167929571877.2810.9926967619100618792.stgit@skinsburskii.localdomain> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Spam-Status: No, score=-14.6 required=5.0 tests=DATE_IN_PAST_96_XX, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,ENV_AND_HDR_SPF_MATCH, MISSING_HEADERS,RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761651581635357270?= X-GMAIL-MSGID: =?utf-8?q?1761651581635357270?= From: Stanislav Kinsburskii The original check for non-null "user" object was introduced by commit e11fea92e13f ("kmsg: export printk records to the /dev/kmsg interface") when "user" could be NULL if /dev/ksmg was opened for writing. Subsequent change 750afe7babd1 ("printk: add kernel parameter to control writes to /dev/kmsg") made "user" context required for files opened for write, but didn't remove now redundant checks for it to be non-NULL. This patch removes the dead code while preserving the current logic. Signed-off-by: Stanislav Kinsburskii CC: Petr Mladek CC: Sergey Senozhatsky CC: Steven Rostedt CC: John Ogness CC: linux-kernel@vger.kernel.org Reviewed-by: Sergey Senozhatsky Reviewed-by: Petr Mladek --- kernel/printk/printk.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index fd0c9f913940..9644f6e5bf15 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -730,7 +730,7 @@ static ssize_t devkmsg_write(struct kiocb *iocb, struct iov_iter *from) size_t len = iov_iter_count(from); ssize_t ret = len; - if (!user || len > PRINTKRB_RECORD_MAX) + if (len > PRINTKRB_RECORD_MAX) return -EINVAL; /* Ignore when user logging is disabled. */ @@ -792,9 +792,6 @@ static ssize_t devkmsg_read(struct file *file, char __user *buf, }; ssize_t ret; - if (!user) - return -EBADF; - ret = mutex_lock_interruptible(&user->lock); if (ret) return ret; @@ -859,8 +856,6 @@ static loff_t devkmsg_llseek(struct file *file, loff_t offset, int whence) struct devkmsg_user *user = file->private_data; loff_t ret = 0; - if (!user) - return -EBADF; if (offset) return -ESPIPE; @@ -893,9 +888,6 @@ static __poll_t devkmsg_poll(struct file *file, poll_table *wait) struct printk_info info; __poll_t ret = 0; - if (!user) - return EPOLLERR|EPOLLNVAL; - poll_wait(file, &log_wait, wait); if (prb_read_valid_info(prb, atomic64_read(&user->seq), &info, NULL)) { @@ -944,9 +936,6 @@ static int devkmsg_release(struct inode *inode, struct file *file) { struct devkmsg_user *user = file->private_data; - if (!user) - return 0; - ratelimit_state_exit(&user->rs); mutex_destroy(&user->lock);