Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1817111ybb; Thu, 26 Mar 2020 07:52:50 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuAeVo3sGyiDImg1VuyKXKjx9MRWEAPnFU/gvZOLG2b4orgFYdF95rTixxgSYRR0wj4jgZ2 X-Received: by 2002:a9d:638a:: with SMTP id w10mr6405409otk.314.1585234370240; Thu, 26 Mar 2020 07:52:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585234370; cv=none; d=google.com; s=arc-20160816; b=vAKMX53HqtqHOxNzz+6OlB7ecOpgvWUyjnNUrdKSzGRrQLAf5KxV6Odhz2m2Aq5/sE GBqzdReKLa8GmF9VaFUTIZz2k9WM/Q9JCsXbQ4PV7Wvrx2zhkySjauk+39LlgtlT61kP bLeIk7pSTfwPWN4/qKDWx78CgcW5vhNIL8Sm2ZnEQHGqcpOWJIcv+NHwXjCxK2MWJECu hKRfHtgDpzx56k+1qqE4nAEfJiUQBsTFV+6Br0FmTOT4X9tpY/d8bgb9N93v4qrx0FyK cKKeg/LzcvXo3zAQ6ljqW8hDvS1bxdv8zQViZUeGyjjnbEWaNFr4Z6FF7py8rafk9+Ou oDxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=eS7IJYarcYb9lOpcw99WK/uhX/b1sbzNjR3mcvzNLaM=; b=Hw76LgCMIv1z70wEzw7NLIIlOvQZBX2sNdLCv9g4gMpcB3JrLV+S4i7jPIeAdQmhJW +XNjp5FiWgYE6B6FHzlHQQghV2MXJuvhc6e/OqcPl6ljxmeckGn46gwiGekYl1Km5zts IIbgxTdScRQPQRaPZTpVi/pEeGtq2sv5/VDwxFVF4ZtimP/HApPYtGVY5wUQi0YP4hxf APX/4YWVJx2/zkSvx49ph9ika/jcxaKpY69S23q9M47QOqk9Dgktx+hwrfiYoFReQZmx XfH22sNh9HUczXZO/29RtkuYbVIVGadMRN5Ng+JAKVqtzy7x03o0YhvA80ZKYw+/ZPBC zgIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hwiR4bH1; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q7si1060337otk.77.2020.03.26.07.52.36; Thu, 26 Mar 2020 07:52:50 -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=@gmail.com header.s=20161025 header.b=hwiR4bH1; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728364AbgCZOv5 (ORCPT + 99 others); Thu, 26 Mar 2020 10:51:57 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:35884 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728347AbgCZOvz (ORCPT ); Thu, 26 Mar 2020 10:51:55 -0400 Received: by mail-lf1-f67.google.com with SMTP id s1so5071219lfd.3 for ; Thu, 26 Mar 2020 07:51:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=eS7IJYarcYb9lOpcw99WK/uhX/b1sbzNjR3mcvzNLaM=; b=hwiR4bH1c1sgi8xFhbWHo7melUCCYkMLKNTULs35Fwpoy4tBW0B8B6HueDRAwbHGzu 2jjC1CDW4Dwa13kZ6L6r4vHMf9U0pLJWp8LaWHqXjTw0niu5fslaGgxEbTtp7Uu70m76 qFrwfvU1eKQ1pG1tlKsKfy8Uh49mD9z3EjzdqIeJmelOZ5wUYVTbbDtGJ1erw+KT/5KA HSveZONXKB3JKt++avVzwOmQ7nkz3jVwg8+HMCjFQt9jmR94lKB4x39K6DzrsPAXoYnK Lx0DQU4PUJ0ny+4Bn6ll6SNSaHJtsuJ8WlrEyDabzFVRdqyOUuAG3z/PjxX0Pv7al9rd v3pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=eS7IJYarcYb9lOpcw99WK/uhX/b1sbzNjR3mcvzNLaM=; b=tvYaUNjpozdjuYtZTTZmPwZxWuHjJ9RdXZJWgUok6MbP/8X0zBXRp8XXbUf1AfQwTw C3rzJEJtHpKQPI3mKl36LANJreJ+IO+421DgTawKH0IPCw75aOIfOZXR84A9UjZ7HtNl 6X/4a6Ju/jYC90P1MR0Jvzd3qehzoRwJZmej1vtYpiBpgggxv16IlAZia+ThoiqY+833 ZsMzxGJWnEBC+CZaC4XBO9n3KVY4CnIz8UDst2HSqTkFVW9mN2/w+S1Ei7K7R622JMs9 MyD+/ZGj+CxJZALjWHjLhwJnUsUdl1KfIpxU/9v4sFRMhf9Uh4+v/oPw+CW3o4aqmN/j Wy2Q== X-Gm-Message-State: ANhLgQ3U0spVkKFuRbV6HxJDN5hjMVMktQ/SmqZs2KRP4XHgyYN+TQEO sYWhobO4i1fWbHQGowLq3U6WB33Y6V8rghPP5Ks= X-Received: by 2002:ac2:41d3:: with SMTP id d19mr6084914lfi.57.1585234309934; Thu, 26 Mar 2020 07:51:49 -0700 (PDT) MIME-Version: 1.0 References: <20200323064616.GB129571@kroah.com> <20200324121236.GB2333340@kroah.com> In-Reply-To: <20200324121236.GB2333340@kroah.com> From: Kyungtae Kim Date: Thu, 26 Mar 2020 10:51:38 -0400 Message-ID: Subject: Re: UBSAN: Undefined behaviour in drivers/tty/vt/keyboard.c To: Greg KH Cc: jslaby@suse.com, slyfox@gentoo.org, Dmitry Torokhov , rei4dan@gmail.com, Dave Tian , LKML Content-Type: multipart/mixed; boundary="000000000000eed2f105a1c31f07" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --000000000000eed2f105a1c31f07 Content-Type: text/plain; charset="UTF-8" On Tue, Mar 24, 2020 at 01:12:36PM +0100, Greg KH wrote: > On Mon, Mar 23, 2020 at 04:44:31PM -0400, Kyungtae Kim wrote: > > On Mon, Mar 23, 2020 at 07:46:16AM +0100, Greg KH wrote: > > > On Sun, Mar 22, 2020 at 11:34:01PM -0400, Kyungtae Kim wrote: > > > > We report a bug (in linux-5.5.11) found by FuzzUSB (modified version > > > > of syzkaller) > > > > > > > > Seems the variable "npadch" has a very large value (i.e., 333333333) > > > > as a result of multiple executions of the function "k_ascii" (keyboard.c:888) > > > > while the variable "base" has 10. > > > > So their multiplication at line 888 in "k_ascii" will become > > > > larger than the max of type int, causing such an integer overflow. > > > > > > > > I believe this can be solved by checking for overflow ahead of operations > > > > e.g., using check_mul_overflow(). > > > > > > > > kernel config: https://kt0755.github.io/etc/config_v5.5.11 > > > > > > Great, can you send a patch for this? > > > > > > thanks, > > > > > > greg k-h > > > > I'm not sure the following works best. > > > > diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c > > index 15d33fa0c925..c1ae9d2e6970 100644 > > --- a/drivers/tty/vt/keyboard.c > > +++ b/drivers/tty/vt/keyboard.c > > @@ -869,6 +869,7 @@ static void k_meta(struct vc_data *vc, unsigned > > char value, char up_flag) > > static void k_ascii(struct vc_data *vc, unsigned char value, char up_flag) > > { > > int base; > > + int bytes, res; > > > > if (up_flag) > > return; > > @@ -884,6 +885,8 @@ static void k_ascii(struct vc_data *vc, unsigned > > char value, char up_flag) > > > > if (npadch == -1) > > npadch = value; > > + else if (check_mul_overflow(npadch, base, &bytes) || > > check_add_overflow(bytes, value, &res)) > > + return; > > else > > npadch = npadch * base + value; > > } > > Does this solve the issue for you? If so, can you fix it up and resend > it in a format that I can apply it in? > > thanks, > > greg k-h I tested the fixed code using a repro (attached), and observed no such a crash occurred anymore. Anyway I will send a patch in a separate email. Thanks, Kyungtae Kim --000000000000eed2f105a1c31f07 Content-Type: text/x-c-code; charset="US-ASCII"; name="repro-82779.c" Content-Disposition: attachment; filename="repro-82779.c" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_k887jxma0 Ly8gYXV0b2dlbmVyYXRlZCBieSBzeXprYWxsZXIgKGh0dHBzOi8vZ2l0aHViLmNvbS9nb29nbGUv c3l6a2FsbGVyKQoKLy9nY2MgWy1vIC90bXAvc3l6LWV4ZWN1dG9yMTUzODc5ODk3IC1ER09PU19s aW51eD0xIC1ER09BUkNIX2FtZDY0PTEgLURIT1NUR09PU19saW51eD0xIC14IGMgLSAtTzIgLXB0 aHJlYWQgLVdhbGwgLVdlcnJvciAtV3BhcmVudGhlc2VzIC1XdW51c2VkLWNvbnN0LXZhcmlhYmxl IC1XZnJhbWUtbGFyZ2VyLXRoYW49ODE5MiAtbTY0IC1zdGF0aWMgLWZwZXJtaXNzaXZlIC13XQov L2djYyAtTzIgLXB0aHJlYWQgLXN0YXRpYyAKCgojZGVmaW5lIF9HTlVfU09VUkNFIAoKI2luY2x1 ZGUgPGFycGEvaW5ldC5oPgojaW5jbHVkZSA8ZGlyZW50Lmg+CiNpbmNsdWRlIDxlbmRpYW4uaD4K I2luY2x1ZGUgPGVycm5vLmg+CiNpbmNsdWRlIDxmY250bC5oPgojaW5jbHVkZSA8bmV0L2lmLmg+ CiNpbmNsdWRlIDxuZXQvaWZfYXJwLmg+CiNpbmNsdWRlIDxuZXRpbmV0L2luLmg+CiNpbmNsdWR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GFyIHJlcG9ydF9kZXNjW10gPSB7CiAgICAweDA1LCAweDAxLCAvKiBV U0FHRV9QQUdFIChHZW5lcmljIERlc2t0b3ApCSAgICAgICAgICAqLwogICAgMHgwOSwgMHgwNiwg LyogVVNBR0UgKEtleWJvYXJkKSAgICAgICAgICAgICAgICAgICAgICAgKi8KICAgIDB4YTEsIDB4 MDEsIC8qIENPTExFQ1RJT04gKEFwcGxpY2F0aW9uKSAgICAgICAgICAgICAgICovCiAgICAweDA1 LCAweDA3LCAvKiAgIFVTQUdFX1BBR0UgKEtleWJvYXJkKSAgICAgICAgICAgICAgICAqLwogICAg MHgxOSwgMHhlMCwgLyogICBVU0FHRV9NSU5JTVVNIChLZXlib2FyZCBMZWZ0Q29udHJvbCkgKi8K ICAgIDB4MjksIDB4ZTcsIC8qICAgVVNBR0VfTUFYSU1VTSAoS2V5Ym9hcmQgUmlnaHQgR1VJKSAg ICovCiAgICAweDE1LCAweDAwLCAvKiAgIExPR0lDQUxfTUlOSU1VTSAoMCkgICAgICAgICAgICAg ICAgICAqLwogICAgMHgyNSwgMHgwMSwgLyogICBMT0dJQ0FMX01BWElNVU0gKDEpICAgICAgICAg ICAgICAgICAgKi8KICAgIDB4NzUsIDB4MDEsIC8qICAgUkVQT1JUX1NJWkUgKDEpICAgICAgICAg ICAgICAgICAgICAgICovCiAgICAweDk1LCAweDA4LCAvKiAgIFJFUE9SVF9DT1VOVCAoOCkgICAg ICAgICAgICAgICAgICAgICAqLwogICAgMHg4MSwgMHgwMiwgLyogICBJTlBVVCAoRGF0YSxWYXIs QWJzKSAgICAgICAgICAgICAgICAgKi8KICAgIDB4OTUsIDB4MDEsIC8qICAgUkVQT1JUX0NPVU5U ICgxKSAgICAgICAgICAgICAgICAgICAgICovCiAgICAweDc1LCAweDA4LCAvKiAgIFJFUE9SVF9T SVpFICg4KSAgICAgICAgICAgICAgICAgICAgICAqLwogICAgMHg4MSwgMHgwMywgLyogICBJTlBV VCAoQ25zdCxWYXIsQWJzKSAgICAgICAgICAgICAgICAgKi8KICAgIDB4OTUsIDB4MDUsIC8qICAg UkVQT1JUX0NPVU5UICg1KSAgICAgICAgICAgICAgICAgICAgICovCiAgICAweDc1LCAweDAxLCAv KiAgIFJFUE9SVF9TSVpFICgxKSAgICAgICAgICAgICAgICAgICAgICAqLwogICAgMHgwNSwgMHgw OCwgLyogICBVU0FHRV9QQUdFIChMRURzKSAgICAgICAgICAgICAgICAgICAgKi8KICAgIDB4MTks IDB4MDEsIC8qICAgVVNBR0VfTUlOSU1VTSAoTnVtIExvY2spICAgICAgICAgICAgICovCiAgICAw eDI5LCAweDA1LCAvKiAgIFVTQUdFX01BWElNVU0gKEthbmEpICAgICAgICAgICAgICAgICAqLwog ICAgMHg5MSwgMHgwMiwgLyogICBPVVRQVVQgKERhdGEsVmFyLEFicykgICAgICAgICAgICAgICAg Ki8KICAgIDB4OTUsIDB4MDEsIC8qICAgUkVQT1JUX0NPVU5UICgxKSAgICAgICAgICAgICAgICAg ICAgICovCiAgICAweDc1LCAweDAzLCAvKiAgIFJFUE9SVF9TSVpFICgzKSAgICAgICAgICAgICAg ICAgICAgICAqLwogICAgMHg5MSwgMHgwMywgLyogICBPVVRQVVQgKENuc3QsVmFyLEFicykgICAg ICAgICAgICAgICAgKi8KICAgIDB4OTUsIDB4MDYsIC8qICAgUkVQT1JUX0NPVU5UICg2KSAgICAg ICAgICAgICAgICAgICAgICovCiAgICAweDc1LCAweDA4LCAvKiAgIFJFUE9SVF9TSVpFICg4KSAg ICAgICAgICAgICAgICAgICAgICAqLwogICAgMHgxNSwgMHgwMCwgLyogICBMT0dJQ0FMX01JTklN VU0gKDApICAgICAgICAgICAgICAgICAgKi8KICAgIDB4MjUsIDB4NjUsIC8qICAgTE9HSUNBTF9N QVhJTVVNICgxMDEpICAgICAgICAgICAgICAgICovCiAgICAweDA1LCAweDA3LCAvKiAgIFVTQUdF X1BBR0UgKEtleWJvYXJkKSAgICAgICAgICAgICAgICAqLwogICAgMHgxOSwgMH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