From patchwork Tue Mar 26 22:03:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jann Horn X-Patchwork-Id: 10872219 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C233417E0 for ; Tue, 26 Mar 2019 22:05:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A0D3F28A9C for ; Tue, 26 Mar 2019 22:05:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F13728C8A; Tue, 26 Mar 2019 22:05:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 309F828A9C for ; Tue, 26 Mar 2019 22:05:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731745AbfCZWFw (ORCPT ); Tue, 26 Mar 2019 18:05:52 -0400 Received: from mail-qt1-f202.google.com ([209.85.160.202]:41686 "EHLO mail-qt1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726277AbfCZWFw (ORCPT ); Tue, 26 Mar 2019 18:05:52 -0400 Received: by mail-qt1-f202.google.com with SMTP id d49so14962083qtk.8 for ; Tue, 26 Mar 2019 15:05:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=5OS7MeeQZkVjDOMphKCQJrQLOTO9o+8UDZ4EUYnvOds=; b=PkCJFz4gIUUzxfFMy4dd9OumgOl5iHmWHQdrsah8NR6wKkHmArUqJsjoTnRlHoLjU9 kZ1NHsaUAbUyuxT7QzvshppCC33sPT2qlAOinWw0eWFQzvgLDRodVsQ6vh4vPgimjjqL losIMDyUQN94ZsYUe3up5iCmUwZDBY6iMxBWuVI+DxaF3vpaG7X7GhpvyBDedC6clBPw AxY3tLUpMOJLrya+t3CW3BnWb+OTFHuItBmWBOnNER8Trsn0ednmN2Bvuu+3jJSSUhlQ 2KAIaldNpXQ3iGxt3QxLCExUwR/slCPnslZNjXk/v27CrgcaRQJr5X3CvYxERlRIT8LF qN2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=5OS7MeeQZkVjDOMphKCQJrQLOTO9o+8UDZ4EUYnvOds=; b=gfb+W4a7jC94Jvwx3cEyaK+5dtm0WL7mSWCavNNF/g4EbmguUfqdHoi4e8BQzoXb4u iVvjRHDWE1E2/Yz197cw9C33hrkmYx4oPdPRN81Er4ctKw8s3LPnY0OtETgbgdkwPW9D CnkX2+PaXQFP+A4s/hMSE75wzYsrO1P2CksaVv2gFCpou9PV/TKiGs53aYu7CKkO7P3A 7lcK205mEbY/TrPl0PIM4YheB/zgo2mw5g9pO0GvCoADdotyr1Hxq7OTfzOGyMkJpdal 3V83mE+PcXAzSfQfoZ0f2LW2jyxYOIO8FAN5pf+Cj5yBl16cyHs4JAYaPfVBQl5JSRc0 7Vjg== X-Gm-Message-State: APjAAAUbgRZQmvFUjR0ApX4Hv0shTAszLNKOlzyJE5NfvXySTGg0aqKa 9xu0xCJYR0wY636fcOQ7hdo8zQmq3Q== X-Google-Smtp-Source: APXvYqx/cNkdwyZirz00IGu2ZgmtakS46fNpTZOT32zHCJpwPLUg87c4TuhXkaDGUy3yld7NLDF76nc2cw== X-Received: by 2002:ac8:27a6:: with SMTP id w35mr27473970qtw.157.1553637951208; Tue, 26 Mar 2019 15:05:51 -0700 (PDT) Date: Tue, 26 Mar 2019 23:03:48 +0100 Message-Id: <20190326220348.61172-1-jannh@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.21.0.392.gf8f6787159e-goog Subject: [PATCH] floppy: fix usercopy direction From: Jann Horn To: Jiri Kosina , Jens Axboe , jannh@google.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Al Viro Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP As sparse points out, these two copy_from_user() should actually be copy_to_user(). Fixes: 229b53c9bf4e ("take floppy compat ioctls to sodding floppy.c") Cc: stable@vger.kernel.org Signed-off-by: Jann Horn Reviewed-by: Mukesh Ojha Acked-by: Alexander Popov --- compile-tested only drivers/block/floppy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index 95f608d1a098..8c641245ff12 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c @@ -3749,7 +3749,7 @@ static int compat_getdrvprm(int drive, v.native_format = UDP->native_format; mutex_unlock(&floppy_mutex); - if (copy_from_user(arg, &v, sizeof(struct compat_floppy_drive_params))) + if (copy_to_user(arg, &v, sizeof(struct compat_floppy_drive_params))) return -EFAULT; return 0; } @@ -3785,7 +3785,7 @@ static int compat_getdrvstat(int drive, bool poll, v.bufblocks = UDRS->bufblocks; mutex_unlock(&floppy_mutex); - if (copy_from_user(arg, &v, sizeof(struct compat_floppy_drive_struct))) + if (copy_to_user(arg, &v, sizeof(struct compat_floppy_drive_struct))) return -EFAULT; return 0; Eintr: