Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3283729ybb; Tue, 31 Mar 2020 02:04:08 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtzQMN1k9SNCIjnXnIcHaq98MOqOPu9h8dvKWwpMGWLNcs7+76Tq5OcxPAnjMS+s9Kixbf0 X-Received: by 2002:a9d:7147:: with SMTP id y7mr12947620otj.230.1585645448292; Tue, 31 Mar 2020 02:04:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585645448; cv=none; d=google.com; s=arc-20160816; b=v7FMsEHOBfO9AwWlBWwYPXwen+8MeJ8U1AMUrNz5bNHXb2vwWENOba6mz7qcUCGYlm UdrmUuf2UgwfsOyW/z1SUSme6wNe/1b1EtAkW6SaJm66AlGDz2m7bknFK1cpiEY1K05J VoAQK4KTg2tBIX953Xno84y2hdz09ObOspeJk4KkZ9dM7ekWdASlbVsLvJ7rsdFb89mB DLEBk4OY6pTvTriXRraTV7Mpsj/fsGV/L9rOYAjcvU1agQT3MtfHQsFd/qd1/RBFabTA o3suYHdBnfSYyAQLyOd8vq7s6W36YCD1S5qNSBc+bvqMd9rwIZ1m3ThxtpFCoSJbe8e/ Pr3Q== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=GNrx8QsPwiw83XMXdQL40mh9HOeL05lAC+bI6ovaSFM=; b=bf4uoVPQyEdbdalTjwtrdFWpFUL9pc7EYLMbXTMVzf9UGh0Qdpx6TxWHxG+ywfGvcU WgIMDVVAfoFdJsszf1J+6zvzu4evCk5KBgQKK7gi/CaSB55YAS2l5YEKBJndfJumWO9E /ij3tvrzDJFYebtomfhMCvPZIdTnFzIo5XsddcIMFOIgr8LYOrQhPH8n19P8o83rz1Om jyKx6ISu3KHyy0iweIGS2Fozaz0wPeCHq1UauNIwwKbaHNCaliMk3pK8URTYws7CY7u2 v0CnWfm2ho4HoV/vpXcAIbjSgFFsH36R4Lc6hcGcMXRY02wJKL7+TuvJM24uPCjyvvT7 +n1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wo+XuDo8; 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 e6si7605829oiy.229.2020.03.31.02.03.55; Tue, 31 Mar 2020 02:04:08 -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; dkim=pass header.i=@kernel.org header.s=default header.b=wo+XuDo8; 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 S1730353AbgCaJB5 (ORCPT + 99 others); Tue, 31 Mar 2020 05:01:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:41274 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730622AbgCaJBy (ORCPT ); Tue, 31 Mar 2020 05:01:54 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4A592208E0; Tue, 31 Mar 2020 09:01:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585645313; bh=QBRWgqCrNTqkqSiXzSZqGwRGdI6o65xRYc1R9QeALGM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wo+XuDo8woeu0zZhsiGxgXY+QcJ0pax5kdtl5svQSLL/vRxG7hKzxE7cQGbQ8oSMS bfrBsQpVBV2thCpW66+mGAaADT4Ax1HkgvtI4tTdnH75dV+O/robnjznVm1GqvKb5x JO2cHoUzz10L50rlAd62qgbXGPvJemC6kyA0Ou7I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bruno Meneguele , "David S. Miller" Subject: [PATCH 5.5 016/170] net/bpfilter: fix dprintf usage for /dev/kmsg Date: Tue, 31 Mar 2020 10:57:10 +0200 Message-Id: <20200331085425.820541703@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200331085423.990189598@linuxfoundation.org> References: <20200331085423.990189598@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bruno Meneguele [ Upstream commit 13d0f7b814d9b4c67e60d8c2820c86ea181e7d99 ] The bpfilter UMH code was recently changed to log its informative messages to /dev/kmsg, however this interface doesn't support SEEK_CUR yet, used by dprintf(). As result dprintf() returns -EINVAL and doesn't log anything. However there already had some discussions about supporting SEEK_CUR into /dev/kmsg interface in the past it wasn't concluded. Since the only user of that from userspace perspective inside the kernel is the bpfilter UMH (userspace) module it's better to correct it here instead waiting a conclusion on the interface. Fixes: 36c4357c63f3 ("net: bpfilter: print umh messages to /dev/kmsg") Signed-off-by: Bruno Meneguele Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/bpfilter/main.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) --- a/net/bpfilter/main.c +++ b/net/bpfilter/main.c @@ -10,7 +10,7 @@ #include #include "msgfmt.h" -int debug_fd; +FILE *debug_f; static int handle_get_cmd(struct mbox_request *cmd) { @@ -35,9 +35,10 @@ static void loop(void) struct mbox_reply reply; int n; + fprintf(debug_f, "testing the buffer\n"); n = read(0, &req, sizeof(req)); if (n != sizeof(req)) { - dprintf(debug_fd, "invalid request %d\n", n); + fprintf(debug_f, "invalid request %d\n", n); return; } @@ -47,7 +48,7 @@ static void loop(void) n = write(1, &reply, sizeof(reply)); if (n != sizeof(reply)) { - dprintf(debug_fd, "reply failed %d\n", n); + fprintf(debug_f, "reply failed %d\n", n); return; } } @@ -55,9 +56,10 @@ static void loop(void) int main(void) { - debug_fd = open("/dev/kmsg", 00000002); - dprintf(debug_fd, "Started bpfilter\n"); + debug_f = fopen("/dev/kmsg", "w"); + setvbuf(debug_f, 0, _IOLBF, 0); + fprintf(debug_f, "Started bpfilter\n"); loop(); - close(debug_fd); + fclose(debug_f); return 0; }