Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3199946imm; Sun, 1 Jul 2018 15:05:57 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdxtOVFtLngyBvsrv61facc/rY9ihrp4PyWqXJXENL1W3QCp1RWlP/tdLEL9BFgX9srkeEH X-Received: by 2002:a62:9849:: with SMTP id q70-v6mr9157979pfd.178.1530482757095; Sun, 01 Jul 2018 15:05:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530482757; cv=none; d=google.com; s=arc-20160816; b=yu5ESCDHIv8Wlt+0Wj802+sfA+Oj2fVt5g7CGamn0iIrm5l5KOrG+JyqSv97sRx+9A 8Mhr/rye9CiUNHj0OCiS7iiR7SH7HxZYaxD/YutBawgD0x0NWy7dYDIF1EPR/N+jhHbm 0khQsVBYfyqmjYu3ANY00OouMW6ihWrU2OVhDzjH1VmIPIO8rzoCWebZjbPNc9GU+VK4 AfTjAjQpTKgJ6YmZlOmeF0kfxO5dfSSxOdAmXP/q40Ayqr8kkPL6qQwSGnpWcSdbG6rw 2WMf51aFREeKOAAU98nI+vMfV/La2Sq72N1iVCXvUZoti7zzrFWYoX6cSG/12CZzChhr 9Qzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:mime-version:user-agent:date:message-id :autocrypt:openpgp:subject:from:cc:to:dkim-signature :arc-authentication-results; bh=UDGViSBvKFUNRlIlOw8lpNEcWlpqy/qfV0Lh51l3Dfw=; b=cYx05GNiVpzmaqGYxULZJkDXcBzBpFovnpaOBW7U5RhAiDQDR3FZYzUu6KBufiHrXp WVVw/vN5uYvmU1i1xrbQHL3zdDHnjSmvDL6GEQrrGExKn18SsKlHnJ863TLD9LX/jPig lVF77UGW1r1rRxXjZuc3GkA3NcSyBiKVqQgCjYJ1eII55tJCpCxXu/UGpuGuFpPp3SZ0 jm7rxC4AupaJMeW7AlRgafzr2xvRjI1dFeCqI6L0YW48y0LvrcoMraLjKgrVylDo6zBq A4sI8amMXpboQDRSdeEqx/64UydhHv2eR7ES59vFzIXhbvfUbzDW2HOS5/fy9e8J9D9T u8Jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CGPmqUsG; 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 a7-v6si15377423pfg.200.2018.07.01.15.05.22; Sun, 01 Jul 2018 15:05:57 -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=CGPmqUsG; 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 S1752542AbeGAWES (ORCPT + 99 others); Sun, 1 Jul 2018 18:04:18 -0400 Received: from mail-ed1-f66.google.com ([209.85.208.66]:34747 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752407AbeGAWEP (ORCPT ); Sun, 1 Jul 2018 18:04:15 -0400 Received: by mail-ed1-f66.google.com with SMTP id d3-v6so251467edi.1; Sun, 01 Jul 2018 15:04:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:cc:from:subject:openpgp:autocrypt:message-id:date:user-agent :mime-version:content-transfer-encoding:content-language; bh=UDGViSBvKFUNRlIlOw8lpNEcWlpqy/qfV0Lh51l3Dfw=; b=CGPmqUsGTd7+5g6QGIrgS+GM/PHV68WVXHjIM257/YQen7surhanGo7D58X6ujkhH8 N+z5bRuqQRp35F49l787/pGUxS4nZl98ST3KHiWFikytwFxXU/jkQr+5nL3Xf5POL75+ jIDyhmKsYWWNK5MRorVBeVd44IA8ACRV9nTEY7p+mdBuLMSkv59JgKgMOPSvrR7enxkQ A5+QOVtxFgLG3XETu0Brv8toH93YxjvqMSPmIGuHsKGAWVWeyUv77k+002nU1KC90WBY mr8Z7BHE3wqAKd+4Veosoy3eJGMG8gUF0CdJV0sqORqjuIiqRIvA5e4aisTvh5t4p8Nd tCoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:from:subject:openpgp:autocrypt:message-id :date:user-agent:mime-version:content-transfer-encoding :content-language; bh=UDGViSBvKFUNRlIlOw8lpNEcWlpqy/qfV0Lh51l3Dfw=; b=rzwxU1MRhqwTXmKcniqbDj+Q02FPcAIpPK3iD/oLA7wRQ6J5jt5Pbf68FlNjyRswNX nEPRA1BOFJWQB/5MbJTkm/Nf407UyzVMHvZPLIpdImg8cxLXyDswhku6ETwQDmweqfGI /qwfG89JGoBKVDV/9lyVaYpG24e8rjVG2FPnSRvg9RVvFfOfc621K1ra2L0T3lNqZhLB GzHdno98olGpsdwDUkPAL89MXxwroLSvyKDEkg3Y+0Y0kw9IiD52dDRMDwVQGfrgZW8T pQOcgPpsHfx46xnyszqnDRCXdkt+h9p7J35fjCrcmu03rhyeXyrQ6VZP+76sMcMQC1gP +xuA== X-Gm-Message-State: APt69E1eUPjqu0Vi8n18bwnHT5NvyCLknGKr2EYrekjKSZql1IepxVtm jHfsEErDdQY+EZNtaaGG5sOdsiOE X-Received: by 2002:a50:93c5:: with SMTP id o63-v6mr21109959eda.311.1530482653885; Sun, 01 Jul 2018 15:04:13 -0700 (PDT) Received: from [192.168.42.231] (pd-18-110-102.service.infuturo.it. [151.18.110.102]) by smtp.gmail.com with ESMTPSA id g25-v6sm3022491edp.97.2018.07.01.15.04.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 15:04:12 -0700 (PDT) To: raven@themaw.net, autofs@vger.kernel.org Cc: linux-kernel@vger.kernel.org, syzkaller@googlegroups.com From: tomas Subject: [PATCH upstream] KASAN: slab-out-of-bounds Read in getname_kernel Openpgp: preference=signencrypt Autocrypt: addr=tomasbortoli@gmail.com; prefer-encrypt=mutual; keydata= xsFNBFpCTZMBEADNZ1+Ibh0Z4pgGRcd1aOUMbe/YfHktmajjcoTnKmZZunjoUVAl8waeLITd BC2c8i1wHzHcnthrmb1izs5XlG6PZnl8n5tjysSNbwggzS1NcEK1qgn5VjNlHQ5aRMUwCC51 kicBiNmlQk2UuzzWwdheRGnaf+O1MNhC0GBeEDKQAL5obOU92pzflv6wWNACr+lHxdnpyies mOnRMjH16NjuTkrGbEmJe+MKp0qbjvR3R/dmFC1wczniRMQmV5w3MZ/N9wRappE+Atc1fOM+ wP7AWNuPvrKg4bN5uqKZLDFH7OFpxvjgVdWM40n0cQfqElWY9as+228Sltdd1XyHtUWRF2VW O1l5L0kX0+7+B5k/fpLhXqD3Z7DK7wRXpXmY59pofk7aFdcN97ZK+r6R7mqrwX4W9IpsPhkT kUyg3/Dx/khBZlJKFoUP325/hoH684bSiPEBroel9alB7gTq2ueoFwy6R3q5CMUw3D+CZWHA 3xllu46TRQ/Vt2g0cIHQNPoye2OWYFJ6kSEvaLpymjNDJ9ph2EuHegonDfOaYSq34ic2BcdB JkCgXRLP5K7KtRNJqqR+DM8xByeGmQv9yp6S97el+SiM9R53RhHawJZGz0EPl+2Q6+5mgh3u wXOlkmGrrSrlB8lc567l34ECl6NFtUPIL7H5vppIXAFl7JZUdQARAQABzR50b21hcyA8dG9t YXNib3J0b2xpQGdtYWlsLmNvbT7CwZQEEwEIAD4WIQSKOZIc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LCaQp1 C0NRT5Tn9zpLxtf5nBExFd/zVENY5vAV2ZbKQdemO54O7j6B9DSgVRrm83GCZxbL4d+qTYBF 3tSCWw/6SG1F3q9gR9QrSC2YRjCmhijUVEh6FhZwB58TNZ1sEEttrps8TDa5tUd9 Message-ID: <38c5a8ad-c192-74b9-b2ff-9eb2a3386930@gmail.com> Date: Mon, 2 Jul 2018 00:04:10 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, I've looked into this issue found by Syzbot and I made a patch: https://syzkaller.appspot.com/bug?id=3Dd03abd8b42847f7f69b1d1d7f97208ae42= 5b1163 The autofs subsystem does not check that the "path" parameter is present within the "param" struct passed by the userspace in case the AUTOFS_DEV_IOCTL_OPENMOUNT_CMD command is passed. Indeed, it assumes a path is always provided (though a path is not always present, as per how the struct is defined: https://github.com/torvalds/linux/blob/master/include/uapi/linux/auto_dev= -ioctl.h#L89). Skipping the check provokes an oob read in "strlen", called by "getname_kernel", in turn called by the autofs to assess the length of the non-existing path. To solve it, modify the "validate_dev_ioctl" function to check also that a path has been provided if the command is AUTOFS_DEV_IOCTL_OPENMOUNT_CMD= =2E --- b/fs/autofs/dev-ioctl.c=C2=A0=C2=A0=C2=A0 2018-07-01 23:10:16.0597286= 21 +0200 +++ a/fs/autofs/dev-ioctl.c=C2=A0=C2=A0=C2=A0 2018-07-01 23:10:24.3117921= 33 +0200 @@ -136,6 +136,9 @@ static int validate_dev_ioctl(int cmd, s =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 } =C2=A0=C2=A0=C2=A0=C2=A0 } +=C2=A0=C2=A0=C2=A0 /* AUTOFS_DEV_IOCTL_OPENMOUNT_CMD without path */ +=C2=A0=C2=A0=C2=A0 else if(_IOC_NR(cmd) =3D=3D AUTOFS_DEV_IOCTL_OPENMOUN= T_CMD) +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 return -EINVAL; =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 err =3D 0; =C2=A0out: Tested and solves the issue on Linus' main git tree. Tomas