From patchwork Fri Jun 17 22:54:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 9185125 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 890DE6075D for ; Fri, 17 Jun 2016 22:56:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 788B627EE2 for ; Fri, 17 Jun 2016 22:56:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C35C27F07; Fri, 17 Jun 2016 22:56: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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 087A327EE2 for ; Fri, 17 Jun 2016 22:56:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753515AbcFQWz2 (ORCPT ); Fri, 17 Jun 2016 18:55:28 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:34824 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753495AbcFQWzN (ORCPT ); Fri, 17 Jun 2016 18:55:13 -0400 Received: by mail-wm0-f66.google.com with SMTP id k184so1033574wme.2; Fri, 17 Jun 2016 15:55:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VyeMCjlzVpKpnhfQ5xwXIl55tZHiuePnFdT/J4lZ7IU=; b=Kv+AbIdq5QFnD3sslxRPpUGL9h0huymVsLCV12k0uqeforYk+3oVrmZ49t5m0mZcuV WRzZNCEKY8mR4dIhL1UbK5WtxCTYwkQyKT5AJVMcceyI75Y29jx/9Oxsmak/oDQnSxoI vx9wMsCrohfhnh/MeaLsuVrBGnUP0mQBUs+4dZW2RtAtMytpeGqyQBI2P/ZRvatsDmhT taGsXNl8cUhegW++5pddpJiKrHXruim8cFMw0IfKfiJSgcZprmiuTqh0ELGAoqYitLsk QNjj0H9DT5IvbkqXsT2hOgrar5eN2GEfFpsPclCjpDb6sAJPA5Fcvd2XIwGFhuMvJfxo UqKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VyeMCjlzVpKpnhfQ5xwXIl55tZHiuePnFdT/J4lZ7IU=; b=ZqyEGkG+RgKxIj8UARsxFnf9luIF9IuicMsSimperxWYQ42yfhG2sbO8C3Ab+oDFvj NRmIZ+iAZsCqRcMw+p9t3jJ9mSWXnClfyRInTpWLqTX5DBRYJDyJKgaDb7v/uLnGmP7p N4yXHBJ78l9h1OQm5NJZk4gE2uuex1WfKHd+Og+bjq3IRpGSzxB+mhMhwQmUZShC09TA 2wt7SASL5A8sI1yJ1+fYBjmiUw2qOf6BUSGrE6y33dH+X4e+GyWlsjvYR7vqwzww89Ym 8AZ2Xuh7wAUWZYsMezN3VplRZWZYAMTGzSgtxkyC1XuAK4FqHcdwgA0rCS3LLJ+Mufz1 aucw== X-Gm-Message-State: ALyK8tKQuifenfJngR0Q+mExryOkDy/0Nk41SZ99CKl1KxzVwBACBn354JBceqUswOIshQ== X-Received: by 10.194.133.135 with SMTP id pc7mr4308238wjb.49.1466204111971; Fri, 17 Jun 2016 15:55:11 -0700 (PDT) Received: from Pali-Latitude.lan (pali.kolej.mff.cuni.cz. [78.128.193.202]) by smtp.gmail.com with ESMTPSA id d137sm806128wmd.12.2016.06.17.15.55.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Jun 2016 15:55:11 -0700 (PDT) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Jean Delvare , Guenter Roeck , Jan C Peters , Thorsten Leemhuis , =?UTF-8?q?David=20Santamar=C3=ADa=20Rogado?= , Peter Saunderson , Tolga Cakir , "Austin S. Hemmelgarn" , Mario_Limonciello@dell.com, Gabriele Mazzotta , =?UTF-8?q?Micha=C5=82=20K=C4=99pie=C5=84?= , Dakota Whipple , Leon Yu Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= Subject: [PATCH 1/6] hwmon: (dell-smm) Fail in ioctl I8K_BIOS_VERSION when bios version is not a number Date: Sat, 18 Jun 2016 00:54:44 +0200 Message-Id: <1466204089-17030-2-git-send-email-pali.rohar@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1466204089-17030-1-git-send-email-pali.rohar@gmail.com> References: <1466204089-17030-1-git-send-email-pali.rohar@gmail.com> MIME-Version: 1.0 Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP ABI of I8K_BIOS_VERSION ioctl can return only number. But new BIOS versions contain also other characters, which does not fit into that ABI. So in case of non digit values return -EINVAL. Reported-by: Mario Limonciello Signed-off-by: Pali Rohár --- drivers/hwmon/dell-smm-hwmon.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c index c43318d..480b2fa 100644 --- a/drivers/hwmon/dell-smm-hwmon.c +++ b/drivers/hwmon/dell-smm-hwmon.c @@ -35,6 +35,7 @@ #include #include #include +#include #include @@ -387,6 +388,10 @@ i8k_ioctl_unlocked(struct file *fp, unsigned int cmd, unsigned long arg) switch (cmd) { case I8K_BIOS_VERSION: + if (!isdigit(bios_version[0]) || !isdigit(bios_version[1]) || + !isdigit(bios_version[2])) + return -EINVAL; + val = (bios_version[0] << 16) | (bios_version[1] << 8) | bios_version[2]; break;