lkml.org 
[lkml]   [2023]   [Dec]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
SubjectRe: [PATCH] afs: Fix overwriting of result of DNS query
From
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div class="moz-cite-prefix">On 12/21/2023 9:23 AM, David Howells
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:1700862.1703168632@warthog.procyon.org.uk">
<pre class="moz-quote-pre" wrap="">In afs_update_cell(), ret is the result of the DNS lookup and the errors
are to be handled by a switch - however, the value gets clobbered in
between by setting it to -ENOMEM in case afs_alloc_vlserver_list() fails.

Fix this by moving the setting of -ENOMEM into the error handling for OOM
failure. Further, only do it if we don't have an alternative error to
return.

Found by Linux Verification Center (linuxtesting.org) with SVACE. Based on
a patch from Anastasia Belova[1].

Fixes: d5c32c89b208 ("afs: Fix cell DNS lookup")
Signed-off-by: David Howells <a class="moz-txt-link-rfc2396E" href="mailto:dhowells@redhat.com">&lt;dhowells@redhat.com&gt;</a>
cc: Anastasia Belova <a class="moz-txt-link-rfc2396E" href="mailto:abelova@astralinux.ru">&lt;abelova@astralinux.ru&gt;</a>
cc: Marc Dionne <a class="moz-txt-link-rfc2396E" href="mailto:marc.dionne@auristor.com">&lt;marc.dionne@auristor.com&gt;</a>
cc: <a class="moz-txt-link-abbreviated" href="mailto:linux-afs@lists.infradead.org">linux-afs@lists.infradead.org</a>
cc: <a class="moz-txt-link-abbreviated" href="mailto:lvc-project@linuxtesting.org">lvc-project@linuxtesting.org</a>
Link: <a class="moz-txt-link-freetext" href="https://lore.kernel.org/r/20231221085849.1463-1-abelova@astralinux.ru/">https://lore.kernel.org/r/20231221085849.1463-1-abelova@astralinux.ru/</a> [1]

---
fs/afs/cell.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/afs/cell.c b/fs/afs/cell.c
index 988c2ac7cece..926cb1188eba 100644
--- a/fs/afs/cell.c
+++ b/fs/afs/cell.c
@@ -409,10 +409,12 @@ static int afs_update_cell(struct afs_cell *cell)
if (ret == -ENOMEM)
goto out_wake;

- ret = -ENOMEM;
vllist = afs_alloc_vlserver_list(0);
- if (!vllist)
+ if (!vllist) {
+ if (ret &gt;= 0)
+ ret = -ENOMEM;
goto out_wake;
+ }

switch (ret) {
case -ENODATA:
</pre>
</blockquote>
<p>Reviewed-by: Jeffrey Altman <a class="moz-txt-link-rfc2396E" href="mailto:jaltman@auristor.com">&lt;jaltman@auristor.com&gt;</a></p>
<p><span style="white-space: pre-wrap">
</span></p>
</body>
</html>
[unhandled content-type:application/pkcs7-signature]
\
 
 \ /
  Last update: 2023-12-21 15:32    [W:0.031 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site